@@ -7,7 +7,20 @@ import path from 'path';
7
7
const TAR_NAME = 'openai.tgz' ;
8
8
const PACK_FILE = `.pack/${ TAR_NAME } ` ;
9
9
10
+ async function defaultNodeRunner ( ) {
11
+ await installPackage ( ) ;
12
+ await run ( 'npm' , [ 'run' , 'tsc' ] ) ;
13
+ if ( state . live ) await run ( 'npm' , [ 'test' ] ) ;
14
+ }
15
+
10
16
const 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 ,
11
24
'ts-browser-webpack' : async ( ) => {
12
25
await installPackage ( ) ;
13
26
@@ -45,36 +58,6 @@ const projects = {
45
58
await run ( 'npm' , [ 'run' , 'deploy' ] ) ;
46
59
}
47
60
} ,
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
- } ,
78
61
bun : async ( ) => {
79
62
if ( state . fromNpm ) {
80
63
await run ( 'bun' , [ 'install' , '-D' , state . fromNpm ] ) ;
@@ -116,6 +99,7 @@ const projects = {
116
99
} ;
117
100
118
101
const projectNames = Object . keys ( projects ) as Array < keyof typeof projects > ;
102
+ const projectNamesSet = new Set ( projectNames ) ;
119
103
120
104
function parseArgs ( ) {
121
105
return yargs ( process . argv . slice ( 2 ) )
@@ -189,10 +173,13 @@ async function main() {
189
173
await buildPackage ( ) ;
190
174
}
191
175
176
+ const positionalArgs = args . _ . filter ( Boolean ) ;
177
+
192
178
// For some reason `yargs` doesn't pick up the positional args correctly
193
179
const projectsToRun = (
194
180
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 ) )
196
183
: projectNames ) as typeof projectNames ;
197
184
console . error ( `running projects: ${ projectsToRun } ` ) ;
198
185
@@ -234,10 +221,11 @@ async function main() {
234
221
const project = queue . shift ( ) ;
235
222
if ( ! project ) break ;
236
223
237
- let stdout , stderr ;
224
+ // preserve interleaved ordering of writes to stdout/stderr
225
+ const chunks : { dest : 'stdout' | 'stderr' ; data : string | Buffer } [ ] = [ ] ;
238
226
try {
239
227
runningProjects . add ( project ) ;
240
- const result = await execa (
228
+ const child = execa (
241
229
'yarn' ,
242
230
[
243
231
'tsn' ,
@@ -252,16 +240,19 @@ async function main() {
252
240
] ,
253
241
{ stdio : 'pipe' , encoding : 'utf8' , maxBuffer : 100 * 1024 * 1024 } ,
254
242
) ;
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 ;
256
246
} catch ( error ) {
257
- ( { stdout, stderr } = error as any ) ;
258
247
failed . push ( project ) ;
259
248
} finally {
260
249
runningProjects . delete ( project ) ;
261
250
}
262
251
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
+ }
265
256
}
266
257
} ) ,
267
258
) ;
@@ -274,18 +265,21 @@ async function main() {
274
265
275
266
await withChdir ( path . join ( rootDir , 'ecosystem-tests' , project ) , async ( ) => {
276
267
console . error ( '\n' ) ;
277
- console . error ( banner ( project ) ) ;
268
+ console . error ( banner ( `▶️ ${ project } ` ) ) ;
278
269
console . error ( '\n' ) ;
279
270
280
271
try {
281
272
await withRetry ( fn , project , state . retry ) ;
282
- console . error ( `✅ - Successfully ran ${ project } ` ) ;
273
+ console . error ( '\n' ) ;
274
+ console . error ( banner ( `✅ ${ project } ` ) ) ;
283
275
} catch ( err ) {
284
276
if ( err && ( err as any ) . shortMessage ) {
285
- console . error ( '❌' , ( err as any ) . shortMessage ) ;
277
+ console . error ( ( err as any ) . shortMessage ) ;
286
278
} else {
287
- console . error ( '❌' , err ) ;
279
+ console . error ( err ) ;
288
280
}
281
+ console . error ( '\n' ) ;
282
+ console . error ( banner ( `❌ ${ project } ` ) ) ;
289
283
failed . push ( project ) ;
290
284
}
291
285
console . error ( '\n' ) ;
@@ -331,8 +325,6 @@ async function buildPackage() {
331
325
return ;
332
326
}
333
327
334
- await run ( 'yarn' , [ 'build' ] ) ;
335
-
336
328
if ( ! ( await pathExists ( '.pack' ) ) ) {
337
329
await fs . mkdir ( '.pack' ) ;
338
330
}
0 commit comments