@oclif/plugin-update 4.2.13 → 4.3.0

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.
package/README.md CHANGED
@@ -55,7 +55,7 @@ EXAMPLES
55
55
  $ oclif-example update --available
56
56
  ```
57
57
 
58
- _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v4.2.13/src/commands/update.ts)_
58
+ _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v4.3.0/src/commands/update.ts)_
59
59
  <!-- commandsstop -->
60
60
 
61
61
  # Contributing
@@ -1,7 +1,7 @@
1
1
  import { Command } from '@oclif/core';
2
2
  export default class UpdateCommand extends Command {
3
3
  static args: {
4
- channel: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
4
+ channel: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
5
  };
6
6
  static description: string;
7
7
  static examples: {
@@ -9,11 +9,11 @@ export default class UpdateCommand extends Command {
9
9
  description: string;
10
10
  }[];
11
11
  static flags: {
12
- autoupdate: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
- available: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
- force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
15
- interactive: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
16
- version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ autoupdate: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ available: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ interactive: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
17
  };
18
18
  run(): Promise<void>;
19
19
  }
@@ -2,6 +2,7 @@ import select from '@inquirer/select';
2
2
  import { Args, Command, Flags, ux } from '@oclif/core';
3
3
  import { basename } from 'node:path';
4
4
  import { sort } from 'semver';
5
+ import TtyTable from 'tty-table';
5
6
  import { Updater } from '../update.js';
6
7
  export default class UpdateCommand extends Command {
7
8
  static args = {
@@ -51,12 +52,17 @@ export default class UpdateCommand extends Command {
51
52
  const updater = new Updater(this.config);
52
53
  if (flags.available) {
53
54
  const [index, localVersions] = await Promise.all([updater.fetchVersionIndex(), updater.findLocalVersions()]);
54
- const allVersions = sort(Object.keys(index)).reverse();
55
- const table = allVersions.map((version) => {
55
+ // eslint-disable-next-line new-cap
56
+ const t = TtyTable([
57
+ { align: 'left', value: 'Location' },
58
+ { align: 'left', value: 'Version' },
59
+ ], sort(Object.keys(index))
60
+ .reverse()
61
+ .map((version) => {
56
62
  const location = localVersions.find((l) => basename(l).startsWith(version)) || index[version];
57
- return { location, version };
58
- });
59
- ux.table(table, { location: {}, version: {} });
63
+ return [location, version];
64
+ }), { compact: true });
65
+ ux.stdout(t.render());
60
66
  return;
61
67
  }
62
68
  if (args.channel && flags.version) {
package/dist/update.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Config, ux } from '@oclif/core';
2
2
  import chalk from 'chalk';
3
+ import makeDebug from 'debug';
3
4
  import fileSize from 'filesize';
4
5
  import { got } from 'got';
5
6
  import { existsSync } from 'node:fs';
@@ -7,6 +8,7 @@ import { mkdir, readFile, readdir, rm, stat, symlink, utimes, writeFile } from '
7
8
  import { basename, dirname, join } from 'node:path';
8
9
  import { Extractor } from './tar.js';
9
10
  import { ls, wait } from './util.js';
11
+ const debug = makeDebug('oclif:update');
10
12
  const filesize = (n) => {
11
13
  const [num, suffix] = fileSize(n, { output: 'array' });
12
14
  return Number.parseFloat(num).toFixed(1) + ` ${suffix}`;
@@ -73,8 +75,8 @@ export class Updater {
73
75
  }
74
76
  await this.config.runHook('update', { channel, version });
75
77
  ux.action.stop();
76
- ux.log();
77
- 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}.`);
78
+ ux.stdout();
79
+ ux.stdout(`Updating to a specific version will not update the channel. If autoupdate is enabled, the CLI will eventually be updated back to ${channel}.`);
78
80
  }
79
81
  else {
80
82
  const manifest = await fetchChannelManifest(channel, this.config);
@@ -91,7 +93,7 @@ export class Updater {
91
93
  }
92
94
  await this.touch();
93
95
  await this.tidy();
94
- ux.debug('done');
96
+ debug('done');
95
97
  }
96
98
  async createBin(version) {
97
99
  const dst = this.clientBin;
@@ -149,7 +151,7 @@ ${binPathEnvVar}="\$DIR/${bin}" ${redirectedEnvVar}=1 "$DIR/../${version}/bin/${
149
151
  }
150
152
  // removes any unused CLIs
151
153
  async tidy() {
152
- ux.debug('tidy');
154
+ debug('tidy');
153
155
  try {
154
156
  const root = this.clientRoot;
155
157
  if (!existsSync(root))
@@ -173,7 +175,7 @@ ${binPathEnvVar}="\$DIR/${bin}" ${redirectedEnvVar}=1 "$DIR/../${version}/bin/${
173
175
  // touch the client so it won't be tidied up right away
174
176
  try {
175
177
  const p = join(this.clientRoot, this.config.version);
176
- ux.debug('touching client at', p);
178
+ debug('touching client at', p);
177
179
  if (!existsSync(p))
178
180
  return;
179
181
  return utimes(p, new Date(), new Date());
@@ -226,14 +228,14 @@ const notUpdatable = (config) => {
226
228
  ux.warn(instructions);
227
229
  // once the spinner stops, it'll eat this blank line
228
230
  // https://github.com/oclif/core/issues/799
229
- ux.log();
231
+ ux.stdout();
230
232
  }
231
233
  return true;
232
234
  }
233
235
  return false;
234
236
  };
235
237
  const composeS3SubDir = (config) => {
236
- let s3SubDir = config.pjson.oclif.update.s3.folder || '';
238
+ let s3SubDir = config.pjson.oclif.update?.s3?.folder || '';
237
239
  if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/')
238
240
  s3SubDir = `${s3SubDir}/`;
239
241
  return s3SubDir;
@@ -272,16 +274,16 @@ const debounce = async (cacheDir) => {
272
274
  if (m > new Date()) {
273
275
  const msg = `waiting until ${m.toISOString()} to update`;
274
276
  if (output) {
275
- ux.debug(msg);
277
+ debug(msg);
276
278
  }
277
279
  else {
278
- ux.log(msg);
280
+ ux.stdout(msg);
279
281
  output = true;
280
282
  }
281
283
  await wait(60 * 1000); // wait 1 minute
282
284
  return debounce(cacheDir);
283
285
  }
284
- ux.log('time to update');
286
+ ux.stdout('time to update');
285
287
  };
286
288
  const setChannel = async (channel, dataDir) => writeFile(join(dataDir, 'channel'), channel, 'utf8');
287
289
  const fetchChannelManifest = async (channel, config) => {
@@ -358,10 +360,10 @@ const determineCurrentVersion = async (clientBin, version) => {
358
360
  }
359
361
  catch (error) {
360
362
  if (error instanceof Error) {
361
- ux.debug(error.name, error.message);
363
+ debug(error.name, error.message);
362
364
  }
363
365
  else if (typeof error === 'string') {
364
- ux.debug(error);
366
+ debug(error);
365
367
  }
366
368
  }
367
369
  return version;
@@ -88,5 +88,5 @@
88
88
  ]
89
89
  }
90
90
  },
91
- "version": "4.2.13"
91
+ "version": "4.3.0"
92
92
  }
package/package.json CHANGED
@@ -1,32 +1,33 @@
1
1
  {
2
2
  "name": "@oclif/plugin-update",
3
- "version": "4.2.13",
3
+ "version": "4.3.0",
4
4
  "author": "Salesforce",
5
5
  "bugs": "https://github.com/oclif/plugin-update/issues",
6
6
  "dependencies": {
7
7
  "@inquirer/select": "^2.3.4",
8
- "@oclif/core": "^3.26.6",
8
+ "@oclif/core": "^4.0.0-beta.13",
9
9
  "chalk": "^5",
10
10
  "debug": "^4.3.1",
11
11
  "filesize": "^6.1.0",
12
12
  "got": "^13",
13
13
  "semver": "^7.6.0",
14
- "tar-fs": "^2.1.1"
14
+ "tar-fs": "^2.1.1",
15
+ "tty-table": "^4.2.3"
15
16
  },
16
17
  "devDependencies": {
17
- "@commitlint/config-conventional": "^18",
18
+ "@commitlint/config-conventional": "^19",
18
19
  "@oclif/plugin-help": "^6",
19
20
  "@oclif/prettier-config": "^0.2.1",
20
- "@oclif/test": "^3",
21
21
  "@types/chai": "^4.3.11",
22
22
  "@types/debug": "^4.1.12",
23
23
  "@types/execa": "^0.9.0",
24
24
  "@types/mocha": "^10",
25
25
  "@types/node": "^18",
26
26
  "@types/semver": "^7.5.8",
27
+ "@types/sinon": "^17.0.3",
27
28
  "@types/tar-fs": "^2.0.2",
28
29
  "chai": "^4.4.1",
29
- "commitlint": "^18",
30
+ "commitlint": "^19",
30
31
  "eslint": "^8.57.0",
31
32
  "eslint-config-oclif": "^5.2.0",
32
33
  "eslint-config-oclif-typescript": "^3.1.7",
@@ -38,7 +39,7 @@
38
39
  "oclif": "^4",
39
40
  "prettier": "^3.2.5",
40
41
  "shx": "^0.3.4",
41
- "sinon": "^17",
42
+ "sinon": "^18.0.0",
42
43
  "strip-ansi": "^7.1.0",
43
44
  "ts-node": "^10.9.2",
44
45
  "typescript": "^5.4.5"