@@ -7,7 +7,20 @@ import path from 'path';
77const TAR_NAME = 'openai.tgz' ;
88const PACK_FILE = `.pack/${ TAR_NAME } ` ;
99
10+ async function defaultNodeRunner ( ) {
11+ await installPackage ( ) ;
12+ await run ( 'npm' , [ 'run' , 'tsc' ] ) ;
13+ if ( state . live ) await run ( 'npm' , [ 'test' ] ) ;
14+ }
15+
1016const projects = {
17+ 'node-ts-cjs' : defaultNodeRunner ,
18+ 'node-ts-cjs-web' : defaultNodeRunner ,
19+ 'node-ts-cjs-auto' : defaultNodeRunner ,
20+ 'node-ts4.5-jest27' : defaultNodeRunner ,
21+ 'node-ts-esm' : defaultNodeRunner ,
22+ 'node-ts-esm-web' : defaultNodeRunner ,
23+ 'node-ts-esm-auto' : defaultNodeRunner ,
1124 'ts-browser-webpack' : async ( ) => {
1225 await installPackage ( ) ;
1326
@@ -45,36 +58,6 @@ const projects = {
4558 await run ( 'npm' , [ 'run' , 'deploy' ] ) ;
4659 }
4760 } ,
48- 'node-ts-cjs' : async ( ) => {
49- await installPackage ( ) ;
50-
51- await run ( 'npm' , [ 'run' , 'tsc' ] ) ;
52-
53- if ( state . live ) {
54- await run ( 'npm' , [ 'test' ] ) ;
55- }
56- } ,
57- 'node-ts-cjs-ts4.5' : async ( ) => {
58- await installPackage ( ) ;
59- await run ( 'npm' , [ 'run' , 'tsc' ] ) ;
60- } ,
61- 'node-ts-cjs-dom' : async ( ) => {
62- await installPackage ( ) ;
63- await run ( 'npm' , [ 'run' , 'tsc' ] ) ;
64- } ,
65- 'node-ts-esm' : async ( ) => {
66- await installPackage ( ) ;
67-
68- await run ( 'npm' , [ 'run' , 'tsc' ] ) ;
69-
70- if ( state . live ) {
71- await run ( 'npm' , [ 'run' , 'test' ] ) ;
72- }
73- } ,
74- 'node-ts-esm-dom' : async ( ) => {
75- await installPackage ( ) ;
76- await run ( 'npm' , [ 'run' , 'tsc' ] ) ;
77- } ,
7861 bun : async ( ) => {
7962 if ( state . fromNpm ) {
8063 await run ( 'bun' , [ 'install' , '-D' , state . fromNpm ] ) ;
@@ -116,6 +99,7 @@ const projects = {
11699} ;
117100
118101const projectNames = Object . keys ( projects ) as Array < keyof typeof projects > ;
102+ const projectNamesSet = new Set ( projectNames ) ;
119103
120104function parseArgs ( ) {
121105 return yargs ( process . argv . slice ( 2 ) )
@@ -189,10 +173,13 @@ async function main() {
189173 await buildPackage ( ) ;
190174 }
191175
176+ const positionalArgs = args . _ . filter ( Boolean ) ;
177+
192178 // For some reason `yargs` doesn't pick up the positional args correctly
193179 const projectsToRun = (
194180 args . projects ?. length ? args . projects
195- : args . _ . length ? args . _
181+ : positionalArgs . length ?
182+ positionalArgs . filter ( ( n ) => typeof n === 'string' && ( projectNamesSet as Set < string > ) . has ( n ) )
196183 : projectNames ) as typeof projectNames ;
197184 console . error ( `running projects: ${ projectsToRun } ` ) ;
198185
@@ -234,10 +221,11 @@ async function main() {
234221 const project = queue . shift ( ) ;
235222 if ( ! project ) break ;
236223
237- let stdout , stderr ;
224+ // preserve interleaved ordering of writes to stdout/stderr
225+ const chunks : { dest : 'stdout' | 'stderr' ; data : string | Buffer } [ ] = [ ] ;
238226 try {
239227 runningProjects . add ( project ) ;
240- const result = await execa (
228+ const child = execa (
241229 'yarn' ,
242230 [
243231 'tsn' ,
@@ -252,16 +240,19 @@ async function main() {
252240 ] ,
253241 { stdio : 'pipe' , encoding : 'utf8' , maxBuffer : 100 * 1024 * 1024 } ,
254242 ) ;
255- ( { stdout, stderr } = result ) ;
243+ child . stdout ?. on ( 'data' , ( data ) => chunks . push ( { dest : 'stdout' , data } ) ) ;
244+ child . stderr ?. on ( 'data' , ( data ) => chunks . push ( { dest : 'stderr' , data } ) ) ;
245+ await child ;
256246 } catch ( error ) {
257- ( { stdout, stderr } = error as any ) ;
258247 failed . push ( project ) ;
259248 } finally {
260249 runningProjects . delete ( project ) ;
261250 }
262251
263- if ( stdout ) process . stdout . write ( stdout ) ;
264- if ( stderr ) process . stderr . write ( stderr ) ;
252+ for ( const { dest, data } of chunks ) {
253+ if ( dest === 'stdout' ) process . stdout . write ( data ) ;
254+ else process . stderr . write ( data ) ;
255+ }
265256 }
266257 } ) ,
267258 ) ;
@@ -274,18 +265,21 @@ async function main() {
274265
275266 await withChdir ( path . join ( rootDir , 'ecosystem-tests' , project ) , async ( ) => {
276267 console . error ( '\n' ) ;
277- console . error ( banner ( project ) ) ;
268+ console . error ( banner ( `▶️ ${ project } ` ) ) ;
278269 console . error ( '\n' ) ;
279270
280271 try {
281272 await withRetry ( fn , project , state . retry ) ;
282- console . error ( `✅ - Successfully ran ${ project } ` ) ;
273+ console . error ( '\n' ) ;
274+ console . error ( banner ( `✅ ${ project } ` ) ) ;
283275 } catch ( err ) {
284276 if ( err && ( err as any ) . shortMessage ) {
285- console . error ( '❌' , ( err as any ) . shortMessage ) ;
277+ console . error ( ( err as any ) . shortMessage ) ;
286278 } else {
287- console . error ( '❌' , err ) ;
279+ console . error ( err ) ;
288280 }
281+ console . error ( '\n' ) ;
282+ console . error ( banner ( `❌ ${ project } ` ) ) ;
289283 failed . push ( project ) ;
290284 }
291285 console . error ( '\n' ) ;
@@ -331,8 +325,6 @@ async function buildPackage() {
331325 return ;
332326 }
333327
334- await run ( 'yarn' , [ 'build' ] ) ;
335-
336328 if ( ! ( await pathExists ( '.pack' ) ) ) {
337329 await fs . mkdir ( '.pack' ) ;
338330 }
0 commit comments