@@ -124,10 +124,21 @@ async function cloneRepo(
124
124
}
125
125
}
126
126
127
+ async function getMonorepoPackages ( repoDir : string ) : Promise < readonly string [ ] | undefined > {
128
+ try {
129
+ return await pu . getMonorepoOrder ( repoDir ) ;
130
+ }
131
+ catch ( e ) {
132
+ reportError ( e , `Error identifying monorepo packages for ${ repoDir } - treating as separate packages` ) ;
133
+ return undefined ;
134
+ }
135
+ }
136
+
127
137
async function installPackagesAndGetCommands (
128
138
repo : git . Repo ,
129
139
downloadDir : string ,
130
140
repoDir : string ,
141
+ monorepoPackages : readonly string [ ] ,
131
142
cleanOnFailure : boolean ,
132
143
diagnosticOutput : boolean ) : Promise < ip . InstallCommand [ ] | undefined > {
133
144
const packageInstallStart = performance . now ( ) ;
@@ -139,7 +150,7 @@ async function installPackagesAndGetCommands(
139
150
/*ignoreScripts*/ true ,
140
151
/*quietOutput*/ ! diagnosticOutput ,
141
152
/*recursiveSearch*/ ! isUserTestRepo ,
142
- /*lernaPackages */ undefined ,
153
+ /*monorepoPackages */ monorepoPackages ,
143
154
repo . types ) ;
144
155
await installPackages ( repoDir , commands , packageTimeout ) ;
145
156
return commands ;
@@ -180,10 +191,11 @@ async function getTsServerRepoResult(
180
191
}
181
192
182
193
const repoDir = path . join ( downloadDir , repo . name ) ;
194
+ const monorepoPackages = await getMonorepoPackages ( repoDir ) ;
183
195
184
196
// Presumably, people occasionally browse repos without installing the packages first
185
- const installCommands = ( prng . random ( ) > 0.2 )
186
- ? ( await installPackagesAndGetCommands ( repo , downloadDir , repoDir , /*cleanOnFailure*/ true , diagnosticOutput ) ) !
197
+ const installCommands = ( prng . random ( ) > 0.2 ) && monorepoPackages
198
+ ? ( await installPackagesAndGetCommands ( repo , downloadDir , repoDir , monorepoPackages , /*cleanOnFailure*/ true , diagnosticOutput ) ) !
187
199
: [ ] ;
188
200
189
201
const isUserTestRepo = ! repo . url ;
@@ -374,8 +386,9 @@ export async function getTscRepoResult(
374
386
}
375
387
376
388
const repoDir = path . join ( downloadDir , repo . name ) ;
389
+ const monorepoPackages = await getMonorepoPackages ( repoDir ) ;
377
390
378
- if ( ! await installPackagesAndGetCommands ( repo , downloadDir , repoDir , /*cleanOnFailure*/ false , diagnosticOutput ) ) {
391
+ if ( ! monorepoPackages || ! await installPackagesAndGetCommands ( repo , downloadDir , repoDir , monorepoPackages , /*cleanOnFailure*/ false , diagnosticOutput ) ) {
379
392
return { status : "Package install failed" } ;
380
393
}
381
394
@@ -384,7 +397,7 @@ export async function getTscRepoResult(
384
397
const buildStart = performance . now ( ) ;
385
398
try {
386
399
console . log ( `Building with ${ oldTscPath } (old)` ) ;
387
- const oldErrors = await ge . buildAndGetErrors ( repoDir , isUserTestRepo , oldTscPath , executionTimeout , /*skipLibCheck*/ true ) ;
400
+ const oldErrors = await ge . buildAndGetErrors ( repoDir , monorepoPackages , isUserTestRepo , oldTscPath , executionTimeout , /*skipLibCheck*/ true ) ;
388
401
389
402
if ( oldErrors . hasConfigFailure ) {
390
403
console . log ( "Unable to build project graph" ) ;
@@ -424,7 +437,7 @@ export async function getTscRepoResult(
424
437
}
425
438
426
439
console . log ( `Building with ${ newTscPath } (new)` ) ;
427
- const newErrors = await ge . buildAndGetErrors ( repoDir , isUserTestRepo , newTscPath , executionTimeout , /*skipLibCheck*/ true ) ;
440
+ const newErrors = await ge . buildAndGetErrors ( repoDir , monorepoPackages , isUserTestRepo , newTscPath , executionTimeout , /*skipLibCheck*/ true ) ;
428
441
429
442
if ( newErrors . hasConfigFailure ) {
430
443
console . log ( "Unable to build project graph" ) ;
0 commit comments