@oclif/plugin-update 3.0.13 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
- name: string;
6
- optional: boolean;
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
  };
@@ -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.CliUx.ux.table(table, { version: {}, location: {} });
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 specifiy both a version and a channel.');
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 = [{ name: 'channel', optional: true }];
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
@@ -38,7 +38,7 @@ const init = async function (opts) {
38
38
  }
39
39
  catch (error) {
40
40
  if (error.code !== 'ENOENT')
41
- core_1.CliUx.ux.error(error.stack);
41
+ core_1.ux.error(error.stack);
42
42
  if (global.testing)
43
43
  return false;
44
44
  debug('autoupdate ENOENT');
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.CliUx.ux.action.start(`${this.config.name}: Updating CLI`);
29
+ core_1.ux.action.start(`${this.config.name}: Updating CLI`);
30
30
  if (this.notUpdatable()) {
31
- core_1.CliUx.ux.action.stop('not updatable');
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.CliUx.ux.action.stop(this.config.scopedEnvVar('HIDE_UPDATED_MESSAGE') ? 'done' : `already on version ${current}`);
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.CliUx.ux.action.stop();
58
- core_1.CliUx.ux.log();
59
- core_1.CliUx.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}.`);
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.CliUx.ux.action.stop(this.config.scopedEnvVar('HIDE_UPDATED_MESSAGE') ? 'done' : `already on version ${current}`);
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.CliUx.ux.action.stop();
72
+ core_1.ux.action.stop();
73
73
  }
74
74
  await this.touch();
75
75
  await this.tidy();
76
- core_1.CliUx.ux.debug('done');
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.CliUx.ux.action.status = 'fetching version index';
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.CliUx.ux.action.status = 'fetching manifest';
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.CliUx.ux.action.type === 'spinner') {
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.CliUx.ux.action.status = newStatus;
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.CliUx.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) + ')'}`);
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.CliUx.ux.action.start(`${this.config.name}: Updating CLI from ${color_1.default.green(current)} to ${color_1.default.green(updated)}`);
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.CliUx.ux.warn(instructions);
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.CliUx.ux.debug(error);
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.CliUx.ux.debug('log chop');
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.CliUx.ux.debug(error.message);
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.CliUx.ux.debug(msg);
278
+ core_1.ux.debug(msg);
279
279
  }
280
280
  else {
281
- core_1.CliUx.ux.log(msg);
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.CliUx.ux.log('time to update');
287
+ core_1.ux.log('time to update');
288
288
  }
289
289
  // removes any unused CLIs
290
290
  async tidy() {
291
- core_1.CliUx.ux.debug('tidy');
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.CliUx.ux.warn(error);
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.CliUx.ux.debug('touching client at', p);
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.CliUx.ux.warn(error);
324
+ core_1.ux.warn(error);
325
325
  }
326
326
  }
327
327
  async refreshConfig(version) {
@@ -1 +1 @@
1
- {"version":"3.0.13","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":[{"name":"channel"}]}}}
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.0.13",
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": "^1.25.0",
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.1",
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": "^2.4.2",
42
+ "oclif": "^3.5.0",
43
43
  "qqjs": "^0.3.11",
44
44
  "sinon": "^12.0.1",
45
45
  "ts-node": "^9.1.1",