@oclif/plugin-update 3.0.13 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commands/update.d.ts +3 -4
- package/lib/commands/update.js +5 -3
- package/lib/hooks/init.js +1 -1
- package/lib/update.js +26 -26
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
package/lib/commands/update.d.ts
CHANGED
@@ -2,9 +2,8 @@ import { Command } from '@oclif/core';
|
|
2
2
|
export default class UpdateCommand extends Command {
|
3
3
|
static description: string;
|
4
4
|
static args: {
|
5
|
-
|
6
|
-
|
7
|
-
}[];
|
5
|
+
channel: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
6
|
+
};
|
8
7
|
static examples: {
|
9
8
|
description: string;
|
10
9
|
command: string;
|
@@ -12,7 +11,7 @@ export default class UpdateCommand extends Command {
|
|
12
11
|
static flags: {
|
13
12
|
autoupdate: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
14
13
|
available: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
15
|
-
version: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
14
|
+
version: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
16
15
|
interactive: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
17
16
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
18
17
|
};
|
package/lib/commands/update.js
CHANGED
@@ -18,11 +18,11 @@ class UpdateCommand extends core_1.Command {
|
|
18
18
|
const location = localVersions.find(l => path.basename(l).startsWith(version)) || index[version];
|
19
19
|
return { version, location };
|
20
20
|
});
|
21
|
-
core_1.
|
21
|
+
core_1.ux.table(table, { version: {}, location: {} });
|
22
22
|
return;
|
23
23
|
}
|
24
24
|
if (args.channel && flags.version) {
|
25
|
-
this.error('You cannot
|
25
|
+
this.error('You cannot specify both a version and a channel.');
|
26
26
|
}
|
27
27
|
return updater.runUpdate({
|
28
28
|
channel: args.channel,
|
@@ -44,7 +44,9 @@ class UpdateCommand extends core_1.Command {
|
|
44
44
|
}
|
45
45
|
exports.default = UpdateCommand;
|
46
46
|
UpdateCommand.description = 'update the <%= config.bin %> CLI';
|
47
|
-
UpdateCommand.args =
|
47
|
+
UpdateCommand.args = {
|
48
|
+
channel: core_1.Args.string({ optional: true }),
|
49
|
+
};
|
48
50
|
UpdateCommand.examples = [
|
49
51
|
{
|
50
52
|
description: 'Update to the stable channel:',
|
package/lib/hooks/init.js
CHANGED
package/lib/update.js
CHANGED
@@ -26,9 +26,9 @@ class Updater {
|
|
26
26
|
const { autoUpdate, version, force = false } = options;
|
27
27
|
if (autoUpdate)
|
28
28
|
await this.debounce();
|
29
|
-
core_1.
|
29
|
+
core_1.ux.action.start(`${this.config.name}: Updating CLI`);
|
30
30
|
if (this.notUpdatable()) {
|
31
|
-
core_1.
|
31
|
+
core_1.ux.action.stop('not updatable');
|
32
32
|
return;
|
33
33
|
}
|
34
34
|
const channel = options.channel || await this.determineChannel();
|
@@ -36,7 +36,7 @@ class Updater {
|
|
36
36
|
if (version) {
|
37
37
|
const localVersion = force ? null : await this.findLocalVersion(version);
|
38
38
|
if (this.alreadyOnVersion(current, localVersion || null)) {
|
39
|
-
core_1.
|
39
|
+
core_1.ux.action.stop(this.config.scopedEnvVar('HIDE_UPDATED_MESSAGE') ? 'done' : `already on version ${current}`);
|
40
40
|
return;
|
41
41
|
}
|
42
42
|
await this.config.runHook('preupdate', { channel, version });
|
@@ -54,26 +54,26 @@ class Updater {
|
|
54
54
|
await this.update(manifest, current, updated, force, channel);
|
55
55
|
}
|
56
56
|
await this.config.runHook('update', { channel, version });
|
57
|
-
core_1.
|
58
|
-
core_1.
|
59
|
-
core_1.
|
57
|
+
core_1.ux.action.stop();
|
58
|
+
core_1.ux.log();
|
59
|
+
core_1.ux.log(`Updating to a specific version will not update the channel. If autoupdate is enabled, the CLI will eventually be updated back to ${channel}.`);
|
60
60
|
}
|
61
61
|
else {
|
62
62
|
const manifest = await this.fetchChannelManifest(channel);
|
63
63
|
const updated = manifest.sha ? `${manifest.version}-${manifest.sha}` : manifest.version;
|
64
64
|
if (!force && this.alreadyOnVersion(current, updated)) {
|
65
|
-
core_1.
|
65
|
+
core_1.ux.action.stop(this.config.scopedEnvVar('HIDE_UPDATED_MESSAGE') ? 'done' : `already on version ${current}`);
|
66
66
|
}
|
67
67
|
else {
|
68
68
|
await this.config.runHook('preupdate', { channel, version: updated });
|
69
69
|
await this.update(manifest, current, updated, force, channel);
|
70
70
|
}
|
71
71
|
await this.config.runHook('update', { channel, version: updated });
|
72
|
-
core_1.
|
72
|
+
core_1.ux.action.stop();
|
73
73
|
}
|
74
74
|
await this.touch();
|
75
75
|
await this.tidy();
|
76
|
-
core_1.
|
76
|
+
core_1.ux.debug('done');
|
77
77
|
}
|
78
78
|
async findLocalVersions() {
|
79
79
|
await this.ensureClientDir();
|
@@ -83,7 +83,7 @@ class Updater {
|
|
83
83
|
.map(f => path.join(this.clientRoot, f));
|
84
84
|
}
|
85
85
|
async fetchVersionIndex() {
|
86
|
-
core_1.
|
86
|
+
core_1.ux.action.status = 'fetching version index';
|
87
87
|
const newIndexUrl = this.config.s3Url(this.s3VersionIndexKey());
|
88
88
|
try {
|
89
89
|
const { body } = await http_call_1.default.get(newIndexUrl);
|
@@ -152,7 +152,7 @@ class Updater {
|
|
152
152
|
return this.fetchManifest(s3Key);
|
153
153
|
}
|
154
154
|
async fetchManifest(s3Key) {
|
155
|
-
core_1.
|
155
|
+
core_1.ux.action.status = 'fetching manifest';
|
156
156
|
const url = this.config.s3Url(s3Key);
|
157
157
|
const { body } = await http_call_1.default.get(url);
|
158
158
|
if (typeof body === 'string') {
|
@@ -180,11 +180,11 @@ class Updater {
|
|
180
180
|
arch: this.config.arch,
|
181
181
|
});
|
182
182
|
const extraction = (0, tar_1.extract)(stream, baseDir, output, sha256gz);
|
183
|
-
if (core_1.
|
183
|
+
if (core_1.ux.action.type === 'spinner') {
|
184
184
|
const total = Number.parseInt(stream.headers['content-length'], 10);
|
185
185
|
let current = 0;
|
186
186
|
const updateStatus = (0, lodash_throttle_1.default)((newStatus) => {
|
187
|
-
core_1.
|
187
|
+
core_1.ux.action.status = newStatus;
|
188
188
|
}, 250, { leading: true, trailing: false });
|
189
189
|
stream.on('data', data => {
|
190
190
|
current += data.length;
|
@@ -196,7 +196,7 @@ class Updater {
|
|
196
196
|
}
|
197
197
|
// eslint-disable-next-line max-params
|
198
198
|
async update(manifest, current, updated, force, channel) {
|
199
|
-
core_1.
|
199
|
+
core_1.ux.action.start(`${this.config.name}: Updating CLI from ${color_1.default.green(current)} to ${color_1.default.green(updated)}${channel === 'stable' ? '' : ' (' + color_1.default.yellow(channel) + ')'}`);
|
200
200
|
await this.ensureClientDir();
|
201
201
|
const output = path.join(this.clientRoot, updated);
|
202
202
|
if (force || !await fs.pathExists(output))
|
@@ -206,7 +206,7 @@ class Updater {
|
|
206
206
|
await this.createBin(updated);
|
207
207
|
}
|
208
208
|
async updateToExistingVersion(current, updated) {
|
209
|
-
core_1.
|
209
|
+
core_1.ux.action.start(`${this.config.name}: Updating CLI from ${color_1.default.green(current)} to ${color_1.default.green(updated)}`);
|
210
210
|
await this.ensureClientDir();
|
211
211
|
await this.refreshConfig(updated);
|
212
212
|
await this.createBin(updated);
|
@@ -215,7 +215,7 @@ class Updater {
|
|
215
215
|
if (!this.config.binPath) {
|
216
216
|
const instructions = this.config.scopedEnvVar('UPDATE_INSTRUCTIONS');
|
217
217
|
if (instructions)
|
218
|
-
core_1.
|
218
|
+
core_1.ux.warn(instructions);
|
219
219
|
return true;
|
220
220
|
}
|
221
221
|
return false;
|
@@ -238,7 +238,7 @@ class Updater {
|
|
238
238
|
return matches ? matches[1] : this.config.version;
|
239
239
|
}
|
240
240
|
catch (error) {
|
241
|
-
core_1.
|
241
|
+
core_1.ux.debug(error);
|
242
242
|
}
|
243
243
|
return this.config.version;
|
244
244
|
}
|
@@ -254,12 +254,12 @@ class Updater {
|
|
254
254
|
}
|
255
255
|
async logChop() {
|
256
256
|
try {
|
257
|
-
core_1.
|
257
|
+
core_1.ux.debug('log chop');
|
258
258
|
const logChopper = require('log-chopper').default;
|
259
259
|
await logChopper.chop(this.config.errlog);
|
260
260
|
}
|
261
261
|
catch (error) {
|
262
|
-
core_1.
|
262
|
+
core_1.ux.debug(error.message);
|
263
263
|
}
|
264
264
|
}
|
265
265
|
async mtime(f) {
|
@@ -275,20 +275,20 @@ class Updater {
|
|
275
275
|
if (m > new Date()) {
|
276
276
|
const msg = `waiting until ${m.toISOString()} to update`;
|
277
277
|
if (output) {
|
278
|
-
core_1.
|
278
|
+
core_1.ux.debug(msg);
|
279
279
|
}
|
280
280
|
else {
|
281
|
-
core_1.
|
281
|
+
core_1.ux.log(msg);
|
282
282
|
output = true;
|
283
283
|
}
|
284
284
|
await (0, util_1.wait)(60 * 1000); // wait 1 minute
|
285
285
|
return this.debounce();
|
286
286
|
}
|
287
|
-
core_1.
|
287
|
+
core_1.ux.log('time to update');
|
288
288
|
}
|
289
289
|
// removes any unused CLIs
|
290
290
|
async tidy() {
|
291
|
-
core_1.
|
291
|
+
core_1.ux.debug('tidy');
|
292
292
|
try {
|
293
293
|
const root = this.clientRoot;
|
294
294
|
if (!await fs.pathExists(root))
|
@@ -308,20 +308,20 @@ class Updater {
|
|
308
308
|
await this.logChop();
|
309
309
|
}
|
310
310
|
catch (error) {
|
311
|
-
core_1.
|
311
|
+
core_1.ux.warn(error);
|
312
312
|
}
|
313
313
|
}
|
314
314
|
async touch() {
|
315
315
|
// touch the client so it won't be tidied up right away
|
316
316
|
try {
|
317
317
|
const p = path.join(this.clientRoot, this.config.version);
|
318
|
-
core_1.
|
318
|
+
core_1.ux.debug('touching client at', p);
|
319
319
|
if (!await fs.pathExists(p))
|
320
320
|
return;
|
321
321
|
await fs.utimes(p, new Date(), new Date());
|
322
322
|
}
|
323
323
|
catch (error) {
|
324
|
-
core_1.
|
324
|
+
core_1.ux.warn(error);
|
325
325
|
}
|
326
326
|
}
|
327
327
|
async refreshConfig(version) {
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"3.
|
1
|
+
{"version":"3.1.1","commands":{"update":{"id":"update","description":"update the <%= config.bin %> CLI","strict":true,"pluginName":"@oclif/plugin-update","pluginAlias":"@oclif/plugin-update","pluginType":"core","aliases":[],"examples":[{"description":"Update to the stable channel:","command":"<%= config.bin %> <%= command.id %> stable"},{"description":"Update to a specific version:","command":"<%= config.bin %> <%= command.id %> --version 1.0.0"},{"description":"Interactively select version:","command":"<%= config.bin %> <%= command.id %> --interactive"},{"description":"See available versions:","command":"<%= config.bin %> <%= command.id %> --available"}],"flags":{"autoupdate":{"name":"autoupdate","type":"boolean","hidden":true,"allowNo":false},"available":{"name":"available","type":"boolean","char":"a","description":"Install a specific version.","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"Install a specific version.","multiple":false,"exclusive":["interactive"]},"interactive":{"name":"interactive","type":"boolean","char":"i","description":"Interactively select version to install. This is ignored if a channel is provided.","allowNo":false,"exclusive":["version"]},"force":{"name":"force","type":"boolean","description":"Force a re-download of the requested version.","allowNo":false}},"args":{"channel":{"name":"channel"}}}}}
|
package/package.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oclif/plugin-update",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.1.1",
|
4
4
|
"author": "Salesforce",
|
5
5
|
"bugs": "https://github.com/oclif/plugin-update/issues",
|
6
6
|
"dependencies": {
|
7
7
|
"@oclif/color": "^1.0.3",
|
8
|
-
"@oclif/core": "^
|
8
|
+
"@oclif/core": "^2.0.7",
|
9
9
|
"cross-spawn": "^7.0.3",
|
10
10
|
"debug": "^4.3.1",
|
11
11
|
"filesize": "^6.1.0",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
21
|
"@oclif/plugin-help": "^5.2.0",
|
22
|
-
"@oclif/test": "^2.3.
|
22
|
+
"@oclif/test": "^2.3.3",
|
23
23
|
"@types/chai": "^4.3.4",
|
24
24
|
"@types/cross-spawn": "^6.0.2",
|
25
25
|
"@types/execa": "^0.9.0",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"globby": "^11.0.2",
|
40
40
|
"mocha": "^9",
|
41
41
|
"nock": "^13.3.0",
|
42
|
-
"oclif": "^
|
42
|
+
"oclif": "^3.5.0",
|
43
43
|
"qqjs": "^0.3.11",
|
44
44
|
"sinon": "^12.0.1",
|
45
45
|
"ts-node": "^9.1.1",
|