88
99import { parseArgs } from "util" ;
1010import { writeFile } from "fs/promises" ;
11- import { resolve } from "path" ;
11+ import path , { resolve } from "path" ;
1212import { runComparison } from "./runner.js" ;
1313import { runFixtures , printFixtureSummary } from "../fixtures/runner.js" ;
1414import { listFixtures } from "../fixtures/index.js" ;
15+ import { formatPresetList , getPreset , getPresetNames , mergePresetWithCli } from "./presets.js" ;
1516import type { CompilerConfig } from "./types.js" ;
1617
1718async 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+
189228EXAMPLES:
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+
208256REPORT FORMAT:
209257 The JSON report includes:
210258 - summary: Statistics (total, matched, mismatched, errors, pass rate)
0 commit comments