1+ import ansi from "#core/ansi" ;
12import ThreadsPoolQueue from "#core/threads/pool/queue" ;
23import Command from "#lib/command" ;
34
@@ -7,68 +8,12 @@ export default class extends Command {
78 static cli ( ) {
89 return {
910 "options" : {
10- "direct-dependencies" : {
11- "short" : "1" ,
12- "description" : "check only the current package direct dependencies" ,
13- "default" : false ,
14- "schema" : {
15- "type" : "boolean" ,
16- } ,
17- } ,
18- "outdated" : {
19- "negatedShort" : "O" ,
20- "description" : "exclude outdated dependencies" ,
21- "default" : true ,
22- "schema" : {
23- "type" : "boolean" ,
24- } ,
25- } ,
26- "install" : {
27- "short" : "i" ,
28- "description" : "install found updatable dependencies" ,
29- "default" : false ,
30- "schema" : {
31- "type" : "boolean" ,
32- } ,
33- } ,
34- "reinstall" : {
35- "short" : "I" ,
36- "description" : "reinstall all dependencies, even if no updates available" ,
37- "default" : false ,
38- "schema" : {
39- "type" : "boolean" ,
40- } ,
41- } ,
42- "commit" : {
43- "negatedShort" : "C" ,
44- "description" : "do not commit and push changes" ,
45- "default" : true ,
46- "schema" : {
47- "type" : "boolean" ,
48- } ,
49- } ,
5011 "sub-packages" : {
5112 "negatedShort" : "S" ,
5213 "description" : "ignore sub-packages" ,
5314 "default" : true ,
5415 "schema" : { "type" : "boolean" } ,
5516 } ,
56- "quiet" : {
57- "short" : "q" ,
58- "description" : "do not show report" ,
59- "default" : false ,
60- "schema" : {
61- "type" : "boolean" ,
62- } ,
63- } ,
64- "confirm" : {
65- "short" : "Y" ,
66- "description" : "ask before install dependencies" ,
67- "default" : false ,
68- "schema" : {
69- "type" : "boolean" ,
70- } ,
71- } ,
7217 } ,
7318 "arguments" : {
7419 "pattern" : {
@@ -86,67 +31,67 @@ export default class extends Command {
8631 } ) ;
8732 if ( ! res . ok ) return res ;
8833
89- var hasErrors ,
90- cache = { } ;
91-
9234 const packages = res . data ,
9335 threads = new ThreadsPoolQueue ( {
94- "maxRunningThreads" : 5 ,
95- } ) ;
36+ "maxRunningThreads" : 10 ,
37+ } ) ,
38+ cache = { } ;
9639
9740 for ( const pkg of packages ) {
41+
42+ // main package
9843 threads . pushThread ( async ( ) => {
9944 const res = await pkg . getOutdatedDependencies ( {
100- "all" : ! process . cli . options [ "direct-dependencies" ] ,
45+ cache ,
10146 } ) ;
10247
103- return result ( res , {
104- pkg,
105- "dependencies" : res . data ,
106- } ) ;
48+ res . data ??= { } ;
49+ res . data . package = pkg ;
50+
51+ return res ;
10752 } ) ;
10853
54+ // sub-packages
10955 if ( process . cli . options [ "sub-packages" ] ) {
11056 for ( const subPkg of pkg . subPackages ) {
11157 threads . pushThread ( async ( ) => {
11258 const res = await subPkg . getOutdatedDependencies ( {
113- "all" : ! process . cli . options [ "direct-dependencies" ] ,
59+ cache ,
11460 } ) ;
11561
116- return result ( res , {
117- " pkg" : subPkg ,
118- "dependencies" : res . data ,
119- } ) ;
62+ res . data ??= { } ;
63+ res . data . package = pkg ;
64+
65+ return res ;
12066 } ) ;
12167 }
12268 }
12369 }
12470
71+ var hasErrors , printNewLine ;
72+
12573 while ( ( res = await threads . getResult ( ) ) ) {
126- if ( res . ok ) {
127- const pkg = res . data . pkg ;
128-
129- res = await pkg . updateDependencies ( {
130- "all" : ! process . cli . options [ "direct-dependencies" ] ,
131- "outdated" : process . cli . options . outdated ,
132- "notInstalled" : process . cli . options [ "not-installed" ] ,
133- "install" : process . cli . options . install ,
134- "reinstall" : process . cli . options . reinstall ,
135- "commit" : process . cli . options . commit ,
136- "quiet" : process . cli . options . quiet ,
137- "confirmInstall" : process . cli . options . confirm ,
138- "outdatedDependencies" : res . data . dependencies ,
139- cache,
140- } ) ;
74+ if ( res . ok && ! res . data . updates ) continue ;
75+
76+ const pkg = res . data . package ;
77+
78+ if ( printNewLine ) {
79+ console . log ( ) ;
80+ }
81+ else {
82+ printNewLine = true ;
14183 }
14284
85+ console . log ( "Package:" , ansi . hl ( pkg . workspaceSlug ) ) ;
86+ console . log ( res . data . log ) ;
87+
14388 if ( ! res . ok ) {
14489 hasErrors = true ;
14590 }
14691 }
14792
14893 if ( hasErrors ) {
149- return result ( [ 500 , "Some dependencies wasn't updated " ] ) ;
94+ return result ( [ 500 , "Some dependencies wasn't checked " ] ) ;
15095 }
15196 }
15297}
0 commit comments