@oclif/plugin-update 4.2.4 → 4.2.6-qa.0

Sign up to get free protection for your applications and to get access to all the features.
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.4/src/commands/update.ts)_
58
+ _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v4.2.6-qa.0/src/commands/update.ts)_
59
59
  <!-- commandsstop -->
60
60
 
61
61
  # Contributing
@@ -16,5 +16,4 @@ export default class UpdateCommand extends Command {
16
16
  version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
17
17
  };
18
18
  run(): Promise<void>;
19
- private promptForVersion;
20
19
  }
@@ -1,5 +1,5 @@
1
+ import select from '@inquirer/select';
1
2
  import { Args, Command, Flags, ux } from '@oclif/core';
2
- import inquirer from 'inquirer';
3
3
  import { basename } from 'node:path';
4
4
  import { sort } from 'semver';
5
5
  import { Updater } from '../update.js';
@@ -50,9 +50,8 @@ export default class UpdateCommand extends Command {
50
50
  const { args, flags } = await this.parse(UpdateCommand);
51
51
  const updater = new Updater(this.config);
52
52
  if (flags.available) {
53
- const index = await updater.fetchVersionIndex();
53
+ const [index, localVersions] = await Promise.all([updater.fetchVersionIndex(), updater.findLocalVersions()]);
54
54
  const allVersions = sort(Object.keys(index)).reverse();
55
- const localVersions = await updater.findLocalVersions();
56
55
  const table = allVersions.map((version) => {
57
56
  const location = localVersions.find((l) => basename(l).startsWith(version)) || index[version];
58
57
  return { location, version };
@@ -67,17 +66,14 @@ export default class UpdateCommand extends Command {
67
66
  autoUpdate: flags.autoupdate,
68
67
  channel: args.channel,
69
68
  force: flags.force,
70
- version: flags.interactive ? await this.promptForVersion(updater) : flags.version,
69
+ version: flags.interactive ? await promptForVersion(updater) : flags.version,
71
70
  });
72
71
  }
73
- async promptForVersion(updater) {
74
- const choices = sort(Object.keys(await updater.fetchVersionIndex())).reverse();
75
- const { version } = await inquirer.prompt({
76
- choices: [...choices, new inquirer.Separator()],
77
- message: 'Select a version to update to',
78
- name: 'version',
79
- type: 'list',
80
- });
81
- return version;
82
- }
83
72
  }
73
+ const promptForVersion = async (updater) => select({
74
+ choices: sort(Object.keys(await updater.fetchVersionIndex()))
75
+ .reverse()
76
+ .map((v) => ({ value: v })),
77
+ loop: false,
78
+ message: 'Select a version to update to',
79
+ });
@@ -1,5 +1,5 @@
1
- import { spawn } from 'cross-spawn';
2
1
  import makeDebug from 'debug';
2
+ import { spawn } from 'node:child_process';
3
3
  import { existsSync } from 'node:fs';
4
4
  import { open, stat, writeFile } from 'node:fs/promises';
5
5
  import { join } from 'node:path';
@@ -61,6 +61,7 @@ export const init = async function (opts) {
61
61
  detached: !config.windows,
62
62
  env: autoupdateEnv,
63
63
  stdio: ['ignore', stream, stream],
64
+ ...(config.windows ? { shell: true } : {}),
64
65
  })
65
66
  .on('error', (e) => process.emitWarning(e))
66
67
  .unref();