@@ -7,6 +7,9 @@ import { fileURLToPath } from 'node:url';
77const scriptFolder = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
88const repoRoot = path . resolve ( scriptFolder , '..' , '..' , '..' , '..' , '..' , '..' ) ;
99const rushBin = path . join ( repoRoot , 'apps' , 'rush' , 'bin' , 'rush' ) ;
10+ const rushVersion = JSON . parse (
11+ fs . readFileSync ( path . join ( repoRoot , 'apps' , 'rush' , 'package.json' ) , 'utf8' )
12+ ) . version ;
1013const outputFolder = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'rush-reporter-demo-' ) ) ;
1114const commonArgs = [ 'build' , '--only' , '@rushstack/rush-reporter' ] ;
1215const baseEnv = { ...process . env } ;
@@ -44,6 +47,9 @@ const plaintext = run('plaintext', [
4447 `--output=json://${ plaintextEventsPath } ?logLevel=debug`
4548] ) . stdout ;
4649const json = run ( 'json' , [ ...commonArgs , '--reporter=json' , '--log-level=debug' ] ) . stdout ;
50+ const previewJson = run ( 'preview-json' , [ ...commonArgs , '--reporter=json' ] , {
51+ RUSH_PREVIEW_VERSION : rushVersion
52+ } ) ;
4753const ai = run ( 'ai' , [ ...commonArgs , '--reporter=ai' ] ) . stdout ;
4854const file = run ( 'file' , [ ...commonArgs , '--reporter=file' ] ) ;
4955const quiet = run ( 'quiet' , [ ...commonArgs , '--reporter=plaintext' , '--log-level=quiet' ] ) . stdout ;
@@ -66,6 +72,18 @@ const flagOffHelp = run('help-flag-off', ['--help']).stdout;
6672const help = run ( 'help' , [ '--help' , '--reporter=json' ] , { RUSH_REPORTER : 'legacy' } ) . stdout ;
6773const commandJson = run ( 'command-json' , [ 'list' , '--json' , '--reporter=file' ] ) ;
6874const commandJsonConflict = run ( 'command-json-conflict' , [ 'list' , '--json' , '--reporter=json' ] , { } , 1 ) ;
75+ const duplicateOutputPath = path . join ( outputFolder , 'duplicate-output.jsonl' ) ;
76+ const outputConflict = run (
77+ 'output-conflict' ,
78+ [
79+ ...commonArgs ,
80+ '--reporter=plaintext' ,
81+ `--output=json://${ duplicateOutputPath } ` ,
82+ `--output=file://${ duplicateOutputPath } `
83+ ] ,
84+ { } ,
85+ 1
86+ ) ;
6987const tempOverride = path . join ( outputFolder , 'rush-temp-override' ) ;
7088const tempOverrideFile = run ( 'temp-override' , [ ...commonArgs , '--reporter=file' ] , {
7189 RUSH_TEMP_FOLDER : tempOverride
@@ -86,18 +104,6 @@ const purgeLogMatch = tempPurge.stderr.match(/^Rush full log: (.+)$/m);
86104if ( ! purgeLogMatch || purgeLogMatch [ 1 ] . startsWith ( tempOverride ) || ! fs . existsSync ( purgeLogMatch [ 1 ] ) ) {
87105 throw new Error ( 'The active purge reporter log was not preserved outside RUSH_TEMP_FOLDER.' ) ;
88106}
89- const duplicateOutputPath = path . join ( outputFolder , 'duplicate-output.jsonl' ) ;
90- const outputConflict = run (
91- 'output-conflict' ,
92- [
93- ...commonArgs ,
94- '--reporter=plaintext' ,
95- `--output=json://${ duplicateOutputPath } ` ,
96- `--output=file://${ duplicateOutputPath } `
97- ] ,
98- { } ,
99- 1
100- ) ;
101107
102108function parseNdjson ( text , name ) {
103109 if ( text . includes ( '\u001b' ) ) {
@@ -110,6 +116,7 @@ function parseNdjson(text, name) {
110116}
111117
112118const jsonEvents = parseNdjson ( json , 'json' ) ;
119+ const previewJsonEvents = parseNdjson ( previewJson . stdout , 'preview-json' ) ;
113120const aiRecords = parseNdjson ( ai , 'ai' ) ;
114121const failureJsonEvents = parseNdjson ( failureJson , 'failure-json' ) ;
115122const failureAiRecords = parseNdjson ( failureAi , 'failure-ai' ) ;
@@ -185,6 +192,12 @@ const aiFinal = aiRecords.at(-1);
185192if ( aiFinal ?. kind !== 'ai.final' || aiFinal . log ?. complete !== true ) {
186193 throw new Error ( 'AI output did not include a complete full-log reference.' ) ;
187194}
195+ if (
196+ ! previewJson . stderr . includes ( 'RUSH_PREVIEW_VERSION' ) ||
197+ ! previewJsonEvents . some ( ( event ) => event . type === 'sessionCompleted' )
198+ ) {
199+ throw new Error ( 'The matching preview version did not preserve payload-only reporter stdout.' ) ;
200+ }
188201const failureAiFinal = failureAiRecords . at ( - 1 ) ;
189202if (
190203 failureAiFinal ?. result !== 'failed' ||
0 commit comments