Skip to content

Commit 2f78b45

Browse files
committed
feat: add package update dependencies command
1 parent 9e0ed67 commit 2f78b45

2 files changed

Lines changed: 33 additions & 73 deletions

File tree

lib/commands/package/update-dependencies.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ export default class extends Command {
5151
if ( res.ok ) {
5252
if ( res.data.updates ) {
5353
console.log( "Package:", ansi.hl( pkg.workspaceSlug ) );
54-
5554
console.log( res.data.log );
5655
}
5756
}
5857
else {
58+
console.log( "Package:", ansi.hl( pkg.workspaceSlug ) );
59+
console.log( res.data.log );
60+
5961
hasErrors = true;
6062
}
6163
}

lib/commands/workspace/update-dependencies.js

Lines changed: 30 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ansi from "#core/ansi";
12
import ThreadsPoolQueue from "#core/threads/pool/queue";
23
import Command from "#lib/command";
34

@@ -7,33 +8,9 @@ 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-
},
3411
"reinstall": {
35-
"short": "I",
36-
"description": "reinstall all dependencies, even if no updates available",
12+
"short": "r",
13+
"description": "reinstall dependencies",
3714
"default": false,
3815
"schema": {
3916
"type": "boolean",
@@ -53,22 +30,6 @@ export default class extends Command {
5330
"default": true,
5431
"schema": { "type": "boolean" },
5532
},
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-
},
7233
},
7334
"arguments": {
7435
"pattern": {
@@ -86,8 +47,7 @@ export default class extends Command {
8647
} );
8748
if ( !res.ok ) return res;
8849

89-
var hasErrors,
90-
cache = {};
50+
var hasErrors;
9151

9252
const packages = res.data,
9353
threads = new ThreadsPoolQueue( {
@@ -96,52 +56,50 @@ export default class extends Command {
9656

9757
for ( const pkg of packages ) {
9858
threads.pushThread( async () => {
99-
const res = await pkg.getOutdatedDependencies( {
100-
"all": !process.cli.options[ "direct-dependencies" ],
59+
const res = await pkg.updateDependencies( {
60+
"reinstall": process.cli.options.reinstall,
61+
"commit": process.cli.options.commit,
62+
"repeatOnError": false,
10163
} );
10264

103-
return result( res, {
104-
pkg,
105-
"dependencies": res.data,
106-
} );
65+
res.data.package = pkg;
66+
67+
return res;
10768
} );
10869

10970
if ( process.cli.options[ "sub-packages" ] ) {
11071
for ( const subPkg of pkg.subPackages ) {
11172
threads.pushThread( async () => {
112-
const res = await subPkg.getOutdatedDependencies( {
113-
"all": !process.cli.options[ "direct-dependencies" ],
73+
const res = await subPkg.updateDependencies( {
74+
"reinstall": process.cli.options.reinstall,
75+
"commit": process.cli.options.commit,
76+
"repeatOnError": false,
11477
} );
11578

116-
return result( res, {
117-
"pkg": subPkg,
118-
"dependencies": res.data,
119-
} );
79+
res.data.package = pkg;
80+
81+
return res;
12082
} );
12183
}
12284
}
12385
}
12486

12587
while ( ( res = await threads.getResult() ) ) {
12688
if ( res.ok ) {
127-
const pkg = res.data.pkg;
89+
const pkg = res.data.package;
12890

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-
} );
141-
}
91+
if ( res.ok ) {
92+
if ( res.data.updates ) {
93+
console.log( "Package:", ansi.hl( pkg.workspaceSlug ) );
94+
console.log( res.data.log );
95+
}
96+
}
97+
else {
98+
console.log( "Package:", ansi.hl( pkg.workspaceSlug ) );
99+
console.log( res.data.log );
142100

143-
if ( !res.ok ) {
144-
hasErrors = true;
101+
hasErrors = true;
102+
}
145103
}
146104
}
147105

0 commit comments

Comments
 (0)