Skip to content

Commit 2612af0

Browse files
committed
remove i18n-report.json
1 parent d2d4015 commit 2612af0

8 files changed

Lines changed: 146 additions & 6028 deletions

File tree

‎napi/angular-compiler/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/test-results
44
/playwright-report
55
/e2e/compare/compare-report.json
6+
/e2e/compare/i18n-report.json
67
/e2e/compare/dist

‎napi/angular-compiler/e2e/compare/fixtures/index.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
import fg from "fast-glob";
9-
import { dirname, basename, relative } from "path";
10-
import { fileURLToPath } from "url";
9+
import { dirname, relative } from "path";
10+
import { fileURLToPath, pathToFileURL } from "url";
1111
import type { Fixture } from "./types.js";
1212

1313
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -37,7 +37,9 @@ export async function discoverFixtures(
3737

3838
for (const file of files) {
3939
try {
40-
const module = await import(file);
40+
// Use pathToFileURL for cross-platform compatibility (fixes Windows paths)
41+
const fileUrl = pathToFileURL(file).href;
42+
const module = await import(fileUrl);
4143

4244
if (module.fixture && isValidFixture(module.fixture)) {
4345
// Set default filePath if not provided

‎napi/angular-compiler/e2e/compare/i18n-report.json‎

Lines changed: 0 additions & 6018 deletions
This file was deleted.

‎napi/angular-compiler/e2e/compare/src/compilers/angular.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,24 @@ class AngularJsEmitter {
500500
const inner = node.expr ? this.emitExpr(node.expr) : "undefined";
501501
return `(${inner})`;
502502

503+
case "DynamicImportExpr": {
504+
// Dynamic import expression: import('module')
505+
// url can be a string or an expression
506+
const url =
507+
typeof node.url === "string" ? JSON.stringify(node.url) : this.emitExpr(node.url);
508+
return `import(${url})`;
509+
}
510+
511+
case "RegularExpressionLiteralExpr": {
512+
// Regular expression literal: /pattern/flags
513+
const flags = node.flags || "";
514+
return `/${node.body}/${flags}`;
515+
}
516+
517+
case "VoidExpr":
518+
// Void expression: void (expr)
519+
return `void (${this.emitExpr(node.expr)})`;
520+
503521
default:
504522
// Emit a valid expression with a comment for unknown expression types
505523
// Using (void 0) produces undefined which is valid in any expression context

‎napi/angular-compiler/e2e/compare/src/compilers/oxc.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { compileTemplateSync, type TransformOptions } from "@oxc/vite-plugin-angular";
1+
import { compileTemplateSync, Severity, type TransformOptions } from "@oxc/vite-plugin-angular";
22
import type { CompilerOutput } from "../types.js";
33

44
/**
@@ -16,8 +16,8 @@ export function compileWithOxc(
1616
const result = compileTemplateSync(template, className, filePath, options);
1717
const compilationTimeMs = performance.now() - startTime;
1818

19-
// Check for errors - errors array contains all diagnostics
20-
const errors = result.errors;
19+
// Only fail on actual errors, not warnings or advice
20+
const errors = result.errors.filter((e) => e.severity === Severity.Error);
2121

2222
if (errors.length > 0) {
2323
return {

‎napi/angular-compiler/e2e/compare/src/index.ts‎

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
import { parseArgs } from "util";
1010
import { writeFile } from "fs/promises";
11-
import { resolve } from "path";
11+
import path, { resolve } from "path";
1212
import { runComparison } from "./runner.js";
1313
import { runFixtures, printFixtureSummary } from "../fixtures/runner.js";
1414
import { listFixtures } from "../fixtures/index.js";
15+
import { formatPresetList, getPreset, getPresetNames, mergePresetWithCli } from "./presets.js";
1516
import type { CompilerConfig } from "./types.js";
1617

1718
async function main(): Promise<void> {
@@ -78,6 +79,15 @@ async function main(): Promise<void> {
7879
type: "boolean",
7980
description: "List all available fixtures without running",
8081
},
82+
// Preset options
83+
preset: {
84+
type: "string",
85+
description: "Use a predefined configuration preset",
86+
},
87+
"list-presets": {
88+
type: "boolean",
89+
description: "List all available presets without running",
90+
},
8191
},
8292
});
8393

@@ -86,13 +96,37 @@ async function main(): Promise<void> {
8696
process.exit(0);
8797
}
8898

99+
// Handle --list-presets
100+
if (values["list-presets"]) {
101+
console.log(formatPresetList());
102+
process.exit(0);
103+
}
104+
89105
// Handle --list-fixtures
90106
if (values["list-fixtures"]) {
91107
const listing = await listFixtures(values.category);
92108
console.log(listing);
93109
process.exit(0);
94110
}
95111

112+
// Validate and resolve preset if specified
113+
let presetInclude: string[] | undefined;
114+
let presetExclude: string[] | undefined;
115+
let presetName: string | undefined;
116+
117+
if (values.preset) {
118+
const preset = getPreset(values.preset);
119+
if (!preset) {
120+
console.error(`Error: Unknown preset "${values.preset}"`);
121+
console.error(`Available presets: ${getPresetNames().join(', ')}`);
122+
process.exit(1);
123+
}
124+
presetName = preset.name;
125+
const merged = mergePresetWithCli(preset, values.include, values.exclude);
126+
presetInclude = merged.include;
127+
presetExclude = merged.exclude;
128+
}
129+
96130
// Determine run mode
97131
const runFixturesOnly = values.fixtures && !values.both;
98132
const runBoth = values.both;
@@ -114,7 +148,7 @@ async function main(): Promise<void> {
114148

115149
// Write fixture report
116150
const fixtureOutputPath = runBoth
117-
? resolve(values.output!.replace(".json", "-fixtures.json"))
151+
? resolve(values.output!.slice(0, -path.extname(values.output!).length) + "-fixtures.json")
118152
: resolve(values.output!);
119153
await writeFile(fixtureOutputPath, JSON.stringify(fixtureReport, null, 2), "utf-8");
120154
console.log(`\nFixture report written to: ${fixtureOutputPath}`);
@@ -129,10 +163,11 @@ async function main(): Promise<void> {
129163

130164
const config: CompilerConfig = {
131165
projectRoot,
132-
include: values.include,
133-
exclude: values.exclude,
166+
include: presetInclude ?? values.include,
167+
exclude: presetExclude ?? values.exclude,
134168
parallel: !values["no-parallel"] && values.parallel !== false,
135169
outputPath: values.output,
170+
presetName,
136171
};
137172

138173
if (runBoth) {
@@ -186,6 +221,10 @@ FIXTURE OPTIONS:
186221
--category <name> Filter fixtures by category (can be repeated)
187222
--list-fixtures List all available fixtures without running
188223
224+
PRESET OPTIONS:
225+
--preset <name> Use a predefined configuration preset
226+
--list-presets List all available presets without running
227+
189228
EXAMPLES:
190229
# Compare bitwarden-clients
191230
pnpm compare -p ../bitwarden-clients
@@ -205,6 +244,15 @@ EXAMPLES:
205244
# List all fixtures
206245
pnpm compare --list-fixtures
207246
247+
# Use a preset for bitwarden
248+
pnpm compare -p ../bitwarden-clients --preset bitwarden
249+
250+
# Use a preset with additional patterns
251+
pnpm compare -p ../angular-material --preset material-angular --include "src/cdk-experimental/**/*.ts"
252+
253+
# List all presets
254+
pnpm compare --list-presets
255+
208256
REPORT FORMAT:
209257
The JSON report includes:
210258
- summary: Statistics (total, matched, mismatched, errors, pass rate)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Preset definitions for the Angular compiler comparison tool.
3+
*/
4+
5+
export interface Preset {
6+
name: string;
7+
description: string;
8+
include: string[];
9+
exclude: string[];
10+
}
11+
12+
export const PRESETS: Record<string, Preset> = {
13+
'bitwarden': {
14+
name: 'bitwarden',
15+
description: 'Bitwarden clients - .component.ts suffix',
16+
include: ['**/*.component.ts'],
17+
exclude: ['**/node_modules/**', '**/*.spec.ts', '**/*.test.ts'],
18+
},
19+
'material-angular': {
20+
name: 'material-angular',
21+
description: 'Angular Material/CDK - no .component.ts suffix',
22+
include: [
23+
'src/material/*/*.ts',
24+
'src/cdk/*/*.ts',
25+
'src/components-examples/**/*-example.ts',
26+
'src/dev-app/**/*.ts',
27+
],
28+
exclude: [
29+
'**/node_modules/**', '**/testing/**', '**/*.spec.ts', '**/*.test.ts',
30+
'**/*-module.ts', '**/public-api.ts', '**/index.ts', '**/BUILD.bazel',
31+
'**/*.harness.ts', '**/*.e2e.ts', '**/schematics/**',
32+
],
33+
},
34+
};
35+
36+
export function getPreset(name: string): Preset | undefined {
37+
return PRESETS[name];
38+
}
39+
40+
export function getPresetNames(): string[] {
41+
return Object.keys(PRESETS);
42+
}
43+
44+
export function formatPresetList(): string {
45+
const lines: string[] = ['Available presets:'];
46+
for (const [name, preset] of Object.entries(PRESETS)) {
47+
lines.push(` ${name}`);
48+
lines.push(` ${preset.description}`);
49+
lines.push(` Include: ${preset.include.length} pattern(s)`);
50+
lines.push(` Exclude: ${preset.exclude.length} pattern(s)`);
51+
lines.push('');
52+
}
53+
return lines.join('\n');
54+
}
55+
56+
export function mergePresetWithCli(
57+
preset: Preset,
58+
cliInclude?: string[],
59+
cliExclude?: string[],
60+
): { include: string[]; exclude: string[] } {
61+
return {
62+
include: [...preset.include, ...(cliInclude || [])],
63+
exclude: [...preset.exclude, ...(cliExclude || [])],
64+
};
65+
}

‎napi/angular-compiler/e2e/compare/src/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export interface CompilerConfig {
1212
parallel?: boolean;
1313
/** Output file path for JSON report */
1414
outputPath?: string;
15+
/** Name of the preset being used (for reporting purposes) */
16+
presetName?: string;
1517
}
1618

1719
/**

0 commit comments

Comments
 (0)