@@ -13,6 +13,7 @@ import { workspaceRoot } from '../../utils/workspace-root';
13
13
import { minimatch } from 'minimatch' ;
14
14
import { join } from 'path' ;
15
15
import { performance } from 'perf_hooks' ;
16
+
16
17
import { LoadedNxPlugin } from '../plugins/internal-api' ;
17
18
import {
18
19
MergeNodesError ,
@@ -30,6 +31,11 @@ import {
30
31
} from '../error-types' ;
31
32
import { CreateNodesResult } from '../plugins/public-api' ;
32
33
import { isGlobPattern } from '../../utils/globs' ;
34
+ import { isOnDaemon } from '../../daemon/is-on-daemon' ;
35
+ import {
36
+ DelayedSpinner ,
37
+ SHOULD_SHOW_SPINNERS ,
38
+ } from '../../utils/delayed-spinner' ;
33
39
34
40
export type SourceInformation = [ file : string | null , plugin : string ] ;
35
41
export type ConfigurationSourceMaps = Record <
@@ -324,6 +330,32 @@ export async function createProjectConfigurations(
324
330
) : Promise < ConfigurationResult > {
325
331
performance . mark ( 'build-project-configs:start' ) ;
326
332
333
+ let spinner : DelayedSpinner ;
334
+ const inProgressPlugins = new Set < string > ( ) ;
335
+
336
+ function updateSpinner ( ) {
337
+ if ( ! spinner ) {
338
+ return ;
339
+ }
340
+
341
+ if ( inProgressPlugins . size === 1 ) {
342
+ return `Creating project graph nodes with ${ inProgressPlugins . keys ( ) [ 0 ] } ` ;
343
+ } else if ( process . env . NX_VERBOSE_LOGGING === 'true' ) {
344
+ return [
345
+ `Creating project graph nodes with ${ inProgressPlugins . size } plugins` ,
346
+ ...Array . from ( inProgressPlugins ) . map ( ( p ) => ` - ${ p } ` ) ,
347
+ ] . join ( '\n' ) ;
348
+ } else {
349
+ return `Creating project graph nodes with ${ inProgressPlugins . size } plugins` ;
350
+ }
351
+ }
352
+
353
+ if ( SHOULD_SHOW_SPINNERS ) {
354
+ spinner = new DelayedSpinner (
355
+ `Creating project graph nodes with ${ plugins . length } plugins`
356
+ ) ;
357
+ }
358
+
327
359
const results : Array < ReturnType < LoadedNxPlugin [ 'createNodes' ] [ 1 ] > > = [ ] ;
328
360
const errors : Array <
329
361
| AggregateCreateNodesError
@@ -352,44 +384,55 @@ export async function createProjectConfigurations(
352
384
exclude
353
385
) ;
354
386
387
+ inProgressPlugins . add ( pluginName ) ;
355
388
let r = createNodes ( matchingConfigFiles , {
356
389
nxJsonConfiguration : nxJson ,
357
390
workspaceRoot : root ,
358
- } ) . catch ( ( e : Error ) => {
359
- const errorBodyLines = [
360
- `An error occurred while processing files for the ${ pluginName } plugin.` ,
361
- ] ;
362
- const error : AggregateCreateNodesError = isAggregateCreateNodesError ( e )
363
- ? // This is an expected error if something goes wrong while processing files.
364
- e
365
- : // This represents a single plugin erroring out with a hard error.
366
- new AggregateCreateNodesError ( [ [ null , e ] ] , [ ] ) ;
367
-
368
- const innerErrors = error . errors ;
369
- for ( const [ file , e ] of innerErrors ) {
370
- if ( file ) {
371
- errorBodyLines . push ( ` - ${ file } : ${ e . message } ` ) ;
372
- } else {
373
- errorBodyLines . push ( ` - ${ e . message } ` ) ;
374
- }
375
- if ( e . stack ) {
376
- const innerStackTrace = ' ' + e . stack . split ( '\n' ) ?. join ( '\n ' ) ;
377
- errorBodyLines . push ( innerStackTrace ) ;
391
+ } )
392
+ . catch ( ( e : Error ) => {
393
+ const errorBodyLines = [
394
+ `An error occurred while processing files for the ${ pluginName } plugin.` ,
395
+ ] ;
396
+ const error : AggregateCreateNodesError = isAggregateCreateNodesError ( e )
397
+ ? // This is an expected error if something goes wrong while processing files.
398
+ e
399
+ : // This represents a single plugin erroring out with a hard error.
400
+ new AggregateCreateNodesError ( [ [ null , e ] ] , [ ] ) ;
401
+
402
+ const innerErrors = error . errors ;
403
+ for ( const [ file , e ] of innerErrors ) {
404
+ if ( file ) {
405
+ errorBodyLines . push ( ` - ${ file } : ${ e . message } ` ) ;
406
+ } else {
407
+ errorBodyLines . push ( ` - ${ e . message } ` ) ;
408
+ }
409
+ if ( e . stack ) {
410
+ const innerStackTrace =
411
+ ' ' + e . stack . split ( '\n' ) ?. join ( '\n ' ) ;
412
+ errorBodyLines . push ( innerStackTrace ) ;
413
+ }
378
414
}
379
- }
380
415
381
- error . stack = errorBodyLines . join ( '\n' ) ;
416
+ error . stack = errorBodyLines . join ( '\n' ) ;
382
417
383
- // This represents a single plugin erroring out with a hard error.
384
- errors . push ( error ) ;
385
- // The plugin didn't return partial results, so we return an empty array.
386
- return error . partialResults . map ( ( r ) => [ pluginName , r [ 0 ] , r [ 1 ] ] as const ) ;
387
- } ) ;
418
+ // This represents a single plugin erroring out with a hard error.
419
+ errors . push ( error ) ;
420
+ // The plugin didn't return partial results, so we return an empty array.
421
+ return error . partialResults . map (
422
+ ( r ) => [ pluginName , r [ 0 ] , r [ 1 ] ] as const
423
+ ) ;
424
+ } )
425
+ . finally ( ( ) => {
426
+ inProgressPlugins . delete ( pluginName ) ;
427
+ updateSpinner ( ) ;
428
+ } ) ;
388
429
389
430
results . push ( r ) ;
390
431
}
391
432
392
433
return Promise . all ( results ) . then ( ( results ) => {
434
+ spinner ?. cleanup ( ) ;
435
+
393
436
const { projectRootMap, externalNodes, rootMap, configurationSourceMaps } =
394
437
mergeCreateNodesResults ( results , nxJson , errors ) ;
395
438
0 commit comments