@@ -12,7 +12,9 @@ const concurrency = os.cpus().length;
12
12
13
13
console . log ( { concurrency } ) ;
14
14
15
- const queue = new PQueue ( { concurrency, autoStart : false } ) ;
15
+ let installQueue = new PQueue ( { concurrency, autoStart : false } ) ;
16
+ let buildQueue = new PQueue ( { concurrency, autoStart : false } ) ;
17
+ let typecheckQueue = new PQueue ( { concurrency, autoStart : false } ) ;
16
18
17
19
const TO_IGNORE = new Set ( [
18
20
"__scripts" ,
@@ -59,45 +61,41 @@ const list = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
59
61
console . log ( `Testing changed examples: ${ list . format ( examples ) } ` ) ;
60
62
61
63
for ( const example of examples ) {
62
- queue . add ( async ( ) => {
63
- const pkgJson = await PackageJson . load ( example ) ;
64
+ const pkgJson = await PackageJson . load ( example ) ;
64
65
65
- /** @type {import('execa').Options } */
66
- const options = { cwd : example , reject : false } ;
66
+ /** @type {import('execa').Options } */
67
+ const options = { cwd : example , reject : false } ;
67
68
68
- const pm = pnpmExamples . has ( example )
69
- ? "pnpm"
70
- : yarnExamples . has ( example )
71
- ? "yarn"
72
- : "npm" ;
69
+ const pm = pnpmExamples . has ( example )
70
+ ? "pnpm"
71
+ : yarnExamples . has ( example )
72
+ ? "yarn"
73
+ : "npm" ;
73
74
75
+ installQueue . add ( async ( ) => {
74
76
const hasSetup = ! ! pkgJson . content . scripts ?. __setup ;
75
77
76
78
if ( hasSetup ) {
77
79
console . log ( "🔧\u00A0Running setup script for" , example ) ;
78
80
const setupResult = await execa ( pm , [ "run" , "__setup" ] , options ) ;
79
81
if ( setupResult . exitCode ) {
80
82
console . error ( setupResult . stderr ) ;
81
- throw new Error ( `🚨\u00A0Error running setup script for ${ example } ` ) ;
83
+ throw new Error ( `Error running setup script for ${ example } ` ) ;
82
84
}
83
85
}
84
86
85
87
console . log ( `📥\u00A0Installing ${ example } with "${ pm } "` ) ;
86
- /** @type {import('execa').ExecaChildProcess<string> } */
87
- let installResult ;
88
- if ( pm === "npm" ) {
89
- installResult = await execa (
90
- pm ,
91
- [ "--silent" , "--legacy-peer-deps" ] ,
92
- options
93
- ) ;
94
- } else {
95
- installResult = await execa ( pm , [ "--silent" ] , options ) ;
96
- }
88
+ let installResult = await execa (
89
+ pm ,
90
+ pm === "npm"
91
+ ? [ "install" , "--silent" , "--legacy-peer-deps" ]
92
+ : [ "install" , "--silent" ] ,
93
+ options
94
+ ) ;
97
95
98
96
if ( installResult . exitCode ) {
99
97
console . error ( installResult . stderr ) ;
100
- throw new Error ( `🚨\u00A0Error installing ${ example } ` ) ;
98
+ throw new Error ( `Error installing ${ example } ` ) ;
101
99
}
102
100
103
101
const hasPrisma = fse . existsSync (
@@ -114,29 +112,45 @@ for (const example of examples) {
114
112
115
113
if ( prismaGenerateCommand . exitCode ) {
116
114
console . error ( prismaGenerateCommand . stderr ) ;
117
- throw new Error ( `🚨\u00A0Error generating prisma types for ${ example } ` ) ;
115
+ throw new Error ( `Error generating prisma types for ${ example } ` ) ;
118
116
}
119
117
}
118
+ } ) ;
120
119
120
+ buildQueue . add ( async ( ) => {
121
121
console . log ( `📦\u00A0Building ${ example } ` ) ;
122
122
const buildResult = await execa ( pm , [ "run" , "build" ] , options ) ;
123
123
124
124
if ( buildResult . exitCode ) {
125
125
console . error ( buildResult . stderr ) ;
126
- throw new Error ( `🚨\u00A0Error building ${ example } ` ) ;
126
+ throw new Error ( `Error building ${ example } ` ) ;
127
127
}
128
+ } ) ;
128
129
130
+ typecheckQueue . add ( async ( ) => {
129
131
console . log ( `🕵️\u00A0Typechecking ${ example } ` ) ;
130
132
const typecheckResult = await execa ( pm , [ "run" , "typecheck" ] , options ) ;
131
133
132
134
if ( typecheckResult . exitCode ) {
133
135
console . error ( typecheckResult . stderr ) ;
134
- throw new Error ( `🚨\u00A0Error typechecking ${ example } ` ) ;
136
+ throw new Error ( `Error typechecking ${ example } ` ) ;
135
137
}
136
138
} ) ;
137
139
}
138
140
139
- queue . start ( ) ;
140
- queue . on ( "error" , ( error ) => {
141
- console . error ( "🚨" , error ) ;
141
+ installQueue . start ( ) ;
142
+ installQueue . on ( "error" , ( error ) => console . error ( "🚨" , error ) ) ;
143
+
144
+ installQueue . on ( "empty" , ( ) => {
145
+ console . log ( `installQueue is complete, moving on to buildQueue` ) ;
146
+ return buildQueue . start ( ) ;
147
+ } ) ;
148
+
149
+ buildQueue . on ( "empty" , ( ) => {
150
+ console . log ( `buildQueue is complete, moving on to typecheckQueue` ) ;
151
+ return typecheckQueue . start ( ) ;
142
152
} ) ;
153
+
154
+ buildQueue . on ( "error" , ( error ) => console . error ( "🚨" , error ) ) ;
155
+
156
+ typecheckQueue . on ( "error" , ( error ) => console . error ( "🚨" , error ) ) ;
0 commit comments