@oclif/core 3.0.0-beta.18 → 3.0.0-beta.19

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.
Files changed (47) hide show
  1. package/lib/args.js +4 -4
  2. package/lib/cli-ux/action/base.js +1 -0
  3. package/lib/cli-ux/action/spinner.js +3 -5
  4. package/lib/cli-ux/action/spinners.js +1 -1
  5. package/lib/cli-ux/config.js +7 -6
  6. package/lib/cli-ux/flush.js +2 -2
  7. package/lib/cli-ux/index.js +1 -1
  8. package/lib/cli-ux/list.js +3 -3
  9. package/lib/cli-ux/prompt.js +8 -3
  10. package/lib/cli-ux/styled/object.js +2 -2
  11. package/lib/cli-ux/styled/table.js +23 -20
  12. package/lib/cli-ux/wait.js +1 -1
  13. package/lib/command.js +9 -9
  14. package/lib/config/config.d.ts +8 -8
  15. package/lib/config/config.js +45 -39
  16. package/lib/config/plugin-loader.js +7 -7
  17. package/lib/config/plugin.js +26 -23
  18. package/lib/config/ts-node.js +8 -10
  19. package/lib/config/util.js +2 -2
  20. package/lib/errors/errors/cli.js +1 -0
  21. package/lib/errors/errors/pretty-print.js +2 -1
  22. package/lib/errors/handle.js +2 -1
  23. package/lib/errors/logger.js +2 -2
  24. package/lib/flags.d.ts +4 -4
  25. package/lib/flags.js +3 -3
  26. package/lib/help/command.js +43 -32
  27. package/lib/help/docopts.js +5 -5
  28. package/lib/help/formatter.js +7 -7
  29. package/lib/help/index.js +39 -42
  30. package/lib/help/root.js +2 -7
  31. package/lib/help/util.js +1 -1
  32. package/lib/interfaces/hooks.d.ts +3 -3
  33. package/lib/interfaces/index.d.ts +1 -1
  34. package/lib/interfaces/parser.d.ts +15 -15
  35. package/lib/interfaces/pjson.d.ts +1 -1
  36. package/lib/module-loader.d.ts +8 -8
  37. package/lib/module-loader.js +12 -9
  38. package/lib/parser/errors.d.ts +1 -1
  39. package/lib/parser/errors.js +9 -9
  40. package/lib/parser/help.js +2 -3
  41. package/lib/parser/parse.js +64 -43
  42. package/lib/parser/validate.js +37 -21
  43. package/lib/performance.js +9 -6
  44. package/lib/util/aggregate-flags.js +1 -3
  45. package/lib/util/cache-command.js +28 -20
  46. package/lib/util/index.js +4 -6
  47. package/package.json +13 -11
@@ -7,19 +7,19 @@ const errors_1 = require("../errors");
7
7
  const util_1 = require("./util");
8
8
  const node_url_1 = require("node:url");
9
9
  const node_os_1 = require("node:os");
10
- const util_2 = require("../util");
10
+ const index_1 = require("../util/index");
11
11
  const node_path_1 = require("node:path");
12
12
  const performance_1 = require("../performance");
13
13
  const plugin_loader_1 = tslib_1.__importDefault(require("./plugin-loader"));
14
14
  const is_wsl_1 = tslib_1.__importDefault(require("is-wsl"));
15
15
  const node_util_1 = require("node:util");
16
- const util_3 = require("../help/util");
16
+ const util_2 = require("../help/util");
17
17
  const module_loader_1 = require("../module-loader");
18
18
  const settings_1 = require("../settings");
19
19
  const stream_1 = require("../cli-ux/stream");
20
20
  // eslint-disable-next-line new-cap
21
21
  const debug = (0, util_1.Debug)();
22
- const _pjson = (0, util_2.requireJson)(__dirname, '..', '..', 'package.json');
22
+ const _pjson = (0, index_1.requireJson)(__dirname, '..', '..', 'package.json');
23
23
  const BASE = `${_pjson.name}@${_pjson.version}`;
24
24
  function channelFromVersion(version) {
25
25
  const m = version.match(/[^-]+(?:-([^.]+))?/);
@@ -130,7 +130,8 @@ class Config {
130
130
  }
131
131
  // eslint-disable-next-line complexity
132
132
  async load() {
133
- settings_1.settings.performanceEnabled = (settings_1.settings.performanceEnabled === undefined ? this.options.enablePerf : settings_1.settings.performanceEnabled) ?? false;
133
+ settings_1.settings.performanceEnabled =
134
+ (settings_1.settings.performanceEnabled === undefined ? this.options.enablePerf : settings_1.settings.performanceEnabled) ?? false;
134
135
  const marker = performance_1.Performance.mark('config.load');
135
136
  this.pluginLoader = new plugin_loader_1.default({ root: this.options.root, plugins: this.options.plugins });
136
137
  Config._rootPlugin = await this.pluginLoader.loadRoot();
@@ -143,8 +144,8 @@ class Config {
143
144
  this.version = this.options.version || this.pjson.version || '0.0.0';
144
145
  this.channel = this.options.channel || channelFromVersion(this.version);
145
146
  this.valid = Config._rootPlugin.valid;
146
- this.arch = ((0, node_os_1.arch)() === 'ia32' ? 'x86' : (0, node_os_1.arch)());
147
- this.platform = is_wsl_1.default ? 'wsl' : (0, util_2.getPlatform)();
147
+ this.arch = (0, node_os_1.arch)() === 'ia32' ? 'x86' : (0, node_os_1.arch)();
148
+ this.platform = is_wsl_1.default ? 'wsl' : (0, index_1.getPlatform)();
148
149
  this.windows = this.platform === 'win32';
149
150
  this.bin = this.pjson.oclif.bin || this.name;
150
151
  this.binAliases = this.pjson.oclif.binAliases;
@@ -159,7 +160,7 @@ class Config {
159
160
  this.userAgent = `${this.name}/${this.version} ${this.platform}-${this.arch} node-${process.version}`;
160
161
  this.shell = this._shell();
161
162
  this.debug = this._debug();
162
- this.home = process.env.HOME || (this.windows && this.windowsHome()) || (0, util_2.getHomeDir)() || (0, node_os_1.tmpdir)();
163
+ this.home = process.env.HOME || (this.windows && this.windowsHome()) || (0, index_1.getHomeDir)() || (0, node_os_1.tmpdir)();
163
164
  this.cacheDir = this.scopedEnvVar('CACHE_DIR') || this.macosCacheDir() || this.dir('cache');
164
165
  this.configDir = this.scopedEnvVar('CONFIG_DIR') || this.dir('config');
165
166
  this.dataDir = this.scopedEnvVar('DATA_DIR') || this.dir('data');
@@ -180,14 +181,14 @@ class Config {
180
181
  unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-<%- platform %>-<%- arch %><%- ext %>",
181
182
  versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %><%- ext %>",
182
183
  manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- platform %>-<%- arch %>",
183
- ...s3.templates && s3.templates.target,
184
+ ...(s3.templates && s3.templates.target),
184
185
  },
185
186
  vanilla: {
186
187
  unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %><%- ext %>",
187
188
  versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %><%- ext %>",
188
189
  baseDir: '<%- bin %>',
189
190
  manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %>version",
190
- ...s3.templates && s3.templates.vanilla,
191
+ ...(s3.templates && s3.templates.vanilla),
191
192
  },
192
193
  };
193
194
  await this.loadPluginsAndCommands();
@@ -238,7 +239,7 @@ class Config {
238
239
  reject(new Error(`Timed out after ${ms} ms.`));
239
240
  }, ms).unref();
240
241
  });
241
- return Promise.race([promise, timeout]).then(result => {
242
+ return Promise.race([promise, timeout]).then((result) => {
242
243
  clearTimeout(id);
243
244
  return result;
244
245
  });
@@ -350,10 +351,10 @@ class Config {
350
351
  return result;
351
352
  }
352
353
  scopedEnvVar(k) {
353
- return process.env[this.scopedEnvVarKeys(k).find(k => process.env[k])];
354
+ return process.env[this.scopedEnvVarKeys(k).find((k) => process.env[k])];
354
355
  }
355
356
  scopedEnvVarTrue(k) {
356
- const v = process.env[this.scopedEnvVarKeys(k).find(k => process.env[k])];
357
+ const v = process.env[this.scopedEnvVarKeys(k).find((k) => process.env[k])];
357
358
  return v === '1' || v === 'true';
358
359
  }
359
360
  /**
@@ -363,7 +364,7 @@ class Config {
363
364
  */
364
365
  scopedEnvVarKey(k) {
365
366
  return [this.bin, k]
366
- .map(p => p.replaceAll('@', '').replaceAll(/[/-]/g, '_'))
367
+ .map((p) => p.replaceAll('@', '').replaceAll(/[/-]/g, '_'))
367
368
  .join('_')
368
369
  .toUpperCase();
369
370
  }
@@ -373,7 +374,9 @@ class Config {
373
374
  * @returns {string[]} e.g. ['SF_DEBUG', 'SFDX_DEBUG']
374
375
  */
375
376
  scopedEnvVarKeys(k) {
376
- return [this.bin, ...this.binAliases ?? []].filter(Boolean).map(alias => [alias.replaceAll('@', '').replaceAll(/[/-]/g, '_'), k].join('_').toUpperCase());
377
+ return [this.bin, ...(this.binAliases ?? [])]
378
+ .filter(Boolean)
379
+ .map((alias) => [alias.replaceAll('@', '').replaceAll(/[/-]/g, '_'), k].join('_').toUpperCase());
377
380
  }
378
381
  findCommand(id, opts = {}) {
379
382
  const lookupId = this.getCmdLookupId(id);
@@ -404,12 +407,14 @@ class Config {
404
407
  * @returns string[]
405
408
  */
406
409
  findMatches(partialCmdId, argv) {
407
- const flags = argv.filter(arg => !(0, util_3.getHelpFlagAdditions)(this).includes(arg) && arg.startsWith('-')).map(a => a.replaceAll('-', ''));
408
- const possibleMatches = [...this.commandPermutations.get(partialCmdId)].map(k => this._commands.get(k));
409
- const matches = possibleMatches.filter(command => {
410
+ const flags = argv
411
+ .filter((arg) => !(0, util_2.getHelpFlagAdditions)(this).includes(arg) && arg.startsWith('-'))
412
+ .map((a) => a.replaceAll('-', ''));
413
+ const possibleMatches = [...this.commandPermutations.get(partialCmdId)].map((k) => this._commands.get(k));
414
+ const matches = possibleMatches.filter((command) => {
410
415
  const cmdFlags = Object.entries(command.flags).flatMap(([flag, def]) => def.char ? [def.char, flag] : [flag]);
411
416
  // A command is a match if the provided flags belong to the full command
412
- return flags.every(f => cmdFlags.includes(f));
417
+ return flags.every((f) => cmdFlags.includes(f));
413
418
  });
414
419
  return matches;
415
420
  }
@@ -433,7 +438,7 @@ class Config {
433
438
  * @returns string[]
434
439
  */
435
440
  getAllCommandIDs() {
436
- return this.getAllCommands().map(c => c.id);
441
+ return this.getAllCommands().map((c) => c.id);
437
442
  }
438
443
  get commands() {
439
444
  return [...this._commands.values()];
@@ -441,7 +446,7 @@ class Config {
441
446
  get commandIDs() {
442
447
  if (this._commandIDs)
443
448
  return this._commandIDs;
444
- this._commandIDs = this.commands.map(c => c.id);
449
+ this._commandIDs = this.commands.map((c) => c.id);
445
450
  return this._commandIDs;
446
451
  }
447
452
  get topics() {
@@ -453,7 +458,7 @@ class Config {
453
458
  cliVersion,
454
459
  architecture,
455
460
  nodeVersion,
456
- pluginVersions: Object.fromEntries([...this.plugins.values()].map(p => [p.name, { version: p.version, type: p.type, root: p.root }])),
461
+ pluginVersions: Object.fromEntries([...this.plugins.values()].map((p) => [p.name, { version: p.version, type: p.type, root: p.root }])),
457
462
  osVersion: `${(0, node_os_1.type)()} ${(0, node_os_1.release)()}`,
458
463
  shell: this.shell,
459
464
  rootPath: this.root,
@@ -479,16 +484,16 @@ class Config {
479
484
  return [...this.plugins.values()];
480
485
  }
481
486
  dir(category) {
482
- const base = process.env[`XDG_${category.toUpperCase()}_HOME`]
483
- || (this.windows && process.env.LOCALAPPDATA)
484
- || (0, node_path_1.join)(this.home, category === 'data' ? '.local/share' : '.' + category);
487
+ const base = process.env[`XDG_${category.toUpperCase()}_HOME`] ||
488
+ (this.windows && process.env.LOCALAPPDATA) ||
489
+ (0, node_path_1.join)(this.home, category === 'data' ? '.local/share' : '.' + category);
485
490
  return (0, node_path_1.join)(base, this.dirname);
486
491
  }
487
492
  windowsHome() {
488
493
  return this.windowsHomedriveHome() || this.windowsUserprofileHome();
489
494
  }
490
495
  windowsHomedriveHome() {
491
- return (process.env.HOMEDRIVE && process.env.HOMEPATH && (0, node_path_1.join)(process.env.HOMEDRIVE, process.env.HOMEPATH));
496
+ return process.env.HOMEDRIVE && process.env.HOMEPATH && (0, node_path_1.join)(process.env.HOMEDRIVE, process.env.HOMEPATH);
492
497
  }
493
498
  windowsUserprofileHome() {
494
499
  return process.env.USERPROFILE;
@@ -532,7 +537,7 @@ class Config {
532
537
  if (err instanceof Error) {
533
538
  const modifiedErr = err;
534
539
  modifiedErr.name = `${err.name} Plugin: ${this.name}`;
535
- modifiedErr.detail = (0, util_2.compact)([
540
+ modifiedErr.detail = (0, index_1.compact)([
536
541
  err.detail,
537
542
  `module: ${this._base}`,
538
543
  scope && `task: ${scope}`,
@@ -546,7 +551,7 @@ class Config {
546
551
  // err is an object
547
552
  process.emitWarning('Config.warn expected either a string or Error, but instead received an object');
548
553
  err.name = `${err.name} Plugin: ${this.name}`;
549
- err.detail = (0, util_2.compact)([
554
+ err.detail = (0, index_1.compact)([
550
555
  err.detail,
551
556
  `module: ${this._base}`,
552
557
  scope && `task: ${scope}`,
@@ -557,11 +562,12 @@ class Config {
557
562
  process.emitWarning(JSON.stringify(err));
558
563
  }
559
564
  get isProd() {
560
- return (0, util_2.isProd)();
565
+ return (0, index_1.isProd)();
561
566
  }
562
567
  isJitPluginCommand(c) {
563
568
  // Return true if the command's plugin is listed under oclif.jitPlugins AND if the plugin hasn't been loaded to this.plugins
564
- return Object.keys(this.pjson.oclif.jitPlugins ?? {}).includes(c.pluginName ?? '') && Boolean(c?.pluginName && !this.plugins.has(c.pluginName));
569
+ return (Object.keys(this.pjson.oclif.jitPlugins ?? {}).includes(c.pluginName ?? '') &&
570
+ Boolean(c?.pluginName && !this.plugins.has(c.pluginName)));
565
571
  }
566
572
  getCmdLookupId(id) {
567
573
  if (this._commands.has(id))
@@ -623,7 +629,7 @@ class Config {
623
629
  }
624
630
  loadTopics(plugin) {
625
631
  const marker = performance_1.Performance.mark(`config.loadTopics#${plugin.name}`, { plugin: plugin.name });
626
- for (const topic of (0, util_2.compact)(plugin.topics)) {
632
+ for (const topic of (0, index_1.compact)(plugin.topics)) {
627
633
  const existing = this._topics.get(topic.name);
628
634
  if (existing) {
629
635
  existing.description = topic.description || existing.description;
@@ -638,7 +644,7 @@ class Config {
638
644
  }
639
645
  }
640
646
  // Add missing topics for displaying help when partial commands are entered.
641
- for (const c of plugin.commands.filter(c => !c.hidden)) {
647
+ for (const c of plugin.commands.filter((c) => !c.hidden)) {
642
648
  const parts = c.id.split(':');
643
649
  while (parts.length > 0) {
644
650
  const name = parts.join(':');
@@ -703,14 +709,14 @@ class Config {
703
709
  return commandPlugins[0];
704
710
  }
705
711
  /**
706
- * Insert legacy plugins
707
- *
708
- * Replace invalid CLI plugins (cli-engine plugins, mostly Heroku) loaded via `this.loadPlugins`
709
- * with oclif-compatible ones returned by @oclif/plugin-legacy init hook.
710
- *
711
- * @param plugins array of oclif-compatible plugins
712
- * @returns void
713
- */
712
+ * Insert legacy plugins
713
+ *
714
+ * Replace invalid CLI plugins (cli-engine plugins, mostly Heroku) loaded via `this.loadPlugins`
715
+ * with oclif-compatible ones returned by @oclif/plugin-legacy init hook.
716
+ *
717
+ * @param plugins array of oclif-compatible plugins
718
+ * @returns void
719
+ */
714
720
  insertLegacyPlugins(plugins) {
715
721
  for (const plugin of plugins) {
716
722
  this.plugins.set(plugin.name, plugin);
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const Plugin = tslib_1.__importStar(require("./plugin"));
5
- const util_1 = require("../util");
6
- const util_2 = require("./util");
5
+ const index_1 = require("../util/index");
6
+ const util_1 = require("./util");
7
7
  const performance_1 = require("../performance");
8
8
  const node_path_1 = require("node:path");
9
9
  // eslint-disable-next-line new-cap
10
- const debug = (0, util_2.Debug)();
10
+ const debug = (0, util_1.Debug)();
11
11
  class PluginLoader {
12
12
  options;
13
13
  plugins = new Map();
@@ -17,14 +17,14 @@ class PluginLoader {
17
17
  this.options = options;
18
18
  if (options.plugins) {
19
19
  this.pluginsProvided = true;
20
- this.plugins = Array.isArray(options.plugins) ? new Map(options.plugins.map(p => [p.name, p])) : options.plugins;
20
+ this.plugins = Array.isArray(options.plugins) ? new Map(options.plugins.map((p) => [p.name, p])) : options.plugins;
21
21
  }
22
22
  }
23
23
  async loadRoot() {
24
24
  let rootPlugin;
25
25
  if (this.pluginsProvided) {
26
26
  const plugins = [...this.plugins.values()];
27
- rootPlugin = plugins.find(p => p.root === this.options.root) ?? plugins[0];
27
+ rootPlugin = plugins.find((p) => p.root === this.options.root) ?? plugins[0];
28
28
  }
29
29
  else {
30
30
  const marker = performance_1.Performance.mark('plugin.load#root');
@@ -59,7 +59,7 @@ class PluginLoader {
59
59
  async loadDevPlugins(opts) {
60
60
  if (opts.devPlugins !== false) {
61
61
  // do not load oclif.devPlugins in production
62
- if ((0, util_1.isProd)())
62
+ if ((0, index_1.isProd)())
63
63
  return;
64
64
  try {
65
65
  const { devPlugins } = opts.rootPlugin.pjson.oclif;
@@ -76,7 +76,7 @@ class PluginLoader {
76
76
  try {
77
77
  const userPJSONPath = (0, node_path_1.join)(opts.dataDir, 'package.json');
78
78
  debug('reading user plugins pjson %s', userPJSONPath);
79
- const pjson = await (0, util_1.readJson)(userPJSONPath);
79
+ const pjson = await (0, index_1.readJson)(userPJSONPath);
80
80
  if (!pjson.oclif)
81
81
  pjson.oclif = { schema: 1 };
82
82
  if (!pjson.oclif.plugins)
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Plugin = void 0;
4
4
  const errors_1 = require("../errors");
5
5
  const util_1 = require("./util");
6
- const util_2 = require("../util");
6
+ const index_1 = require("../util/index");
7
7
  const node_path_1 = require("node:path");
8
8
  const module_loader_1 = require("../module-loader");
9
9
  const performance_1 = require("../performance");
@@ -11,15 +11,15 @@ const cache_command_1 = require("../util/cache-command");
11
11
  const node_util_1 = require("node:util");
12
12
  const globby_1 = require("globby");
13
13
  const ts_node_1 = require("./ts-node");
14
- const _pjson = (0, util_2.requireJson)(__dirname, '..', '..', 'package.json');
14
+ const _pjson = (0, index_1.requireJson)(__dirname, '..', '..', 'package.json');
15
15
  function topicsToArray(input, base) {
16
16
  if (!input)
17
17
  return [];
18
18
  base = base ? `${base}:` : '';
19
19
  if (Array.isArray(input)) {
20
- return [...input, input.flatMap(t => topicsToArray(t.subtopics, `${base}${t.name}`))];
20
+ return [...input, input.flatMap((t) => topicsToArray(t.subtopics, `${base}${t.name}`))];
21
21
  }
22
- return Object.keys(input).flatMap(k => {
22
+ return Object.keys(input).flatMap((k) => {
23
23
  input[k].name = k;
24
24
  return [{ ...input[k], name: `${base}${k}` }, ...topicsToArray(input[k].subtopics, `${base}${input[k].name}`)];
25
25
  });
@@ -36,7 +36,7 @@ async function findSourcesRoot(root) {
36
36
  for (const next of up(root)) {
37
37
  const cur = (0, node_path_1.join)(next, 'package.json');
38
38
  // eslint-disable-next-line no-await-in-loop
39
- if (await (0, util_2.exists)(cur))
39
+ if (await (0, index_1.exists)(cur))
40
40
  return (0, node_path_1.dirname)(cur);
41
41
  }
42
42
  }
@@ -57,11 +57,11 @@ async function findRootLegacy(name, root) {
57
57
  if (name) {
58
58
  cur = (0, node_path_1.join)(next, 'node_modules', name, 'package.json');
59
59
  // eslint-disable-next-line no-await-in-loop
60
- if (await (0, util_2.exists)(cur))
60
+ if (await (0, index_1.exists)(cur))
61
61
  return (0, node_path_1.dirname)(cur);
62
62
  try {
63
63
  // eslint-disable-next-line no-await-in-loop
64
- const pkg = await (0, util_2.readJson)((0, node_path_1.join)(next, 'package.json'));
64
+ const pkg = await (0, index_1.readJson)((0, node_path_1.join)(next, 'package.json'));
65
65
  if (pkg.name === name)
66
66
  return next;
67
67
  }
@@ -70,7 +70,7 @@ async function findRootLegacy(name, root) {
70
70
  else {
71
71
  cur = (0, node_path_1.join)(next, 'package.json');
72
72
  // eslint-disable-next-line no-await-in-loop
73
- if (await (0, util_2.exists)(cur))
73
+ if (await (0, index_1.exists)(cur))
74
74
  return (0, node_path_1.dirname)(cur);
75
75
  }
76
76
  }
@@ -86,7 +86,7 @@ async function findRoot(name, root) {
86
86
  }
87
87
  return findSourcesRoot(root);
88
88
  }
89
- const cachedCommandCanBeUsed = (manifest, id) => Boolean(manifest?.commands[id] && ('isESM' in manifest.commands[id] && 'relativePath' in manifest.commands[id]));
89
+ const cachedCommandCanBeUsed = (manifest, id) => Boolean(manifest?.commands[id] && 'isESM' in manifest.commands[id] && 'relativePath' in manifest.commands[id]);
90
90
  const search = (cmd) => {
91
91
  if (typeof cmd.run === 'function')
92
92
  return cmd;
@@ -136,7 +136,7 @@ class Plugin {
136
136
  throw new errors_1.CLIError(`could not find package.json with ${(0, node_util_1.inspect)(this.options)}`);
137
137
  this.root = root;
138
138
  this._debug('reading %s plugin %s', this.type, root);
139
- this.pjson = await (0, util_2.readJson)((0, node_path_1.join)(root, 'package.json'));
139
+ this.pjson = await (0, index_1.readJson)((0, node_path_1.join)(root, 'package.json'));
140
140
  this.flexibleTaxonomy = this.options?.flexibleTaxonomy || this.pjson.oclif?.flexibleTaxonomy || false;
141
141
  this.moduleType = this.pjson.type === 'module' ? 'module' : 'commonjs';
142
142
  this.name = this.pjson.name;
@@ -144,7 +144,7 @@ class Plugin {
144
144
  const pjsonPath = (0, node_path_1.join)(root, 'package.json');
145
145
  if (!this.name)
146
146
  throw new errors_1.CLIError(`no name in ${pjsonPath}`);
147
- if (!(0, util_2.isProd)() && !this.pjson.files)
147
+ if (!(0, index_1.isProd)() && !this.pjson.files)
148
148
  this.warn(`files attribute must be specified in ${pjsonPath}`);
149
149
  // eslint-disable-next-line new-cap
150
150
  this._debug = (0, util_1.Debug)(this.name);
@@ -155,10 +155,9 @@ class Plugin {
155
155
  else {
156
156
  this.pjson.oclif = this.pjson['cli-engine'] || {};
157
157
  }
158
- this.hooks = (0, util_2.mapValues)(this.pjson.oclif.hooks || {}, i => Array.isArray(i) ? i : [i]);
158
+ this.hooks = (0, index_1.mapValues)(this.pjson.oclif.hooks || {}, (i) => (Array.isArray(i) ? i : [i]));
159
159
  this.manifest = await this._manifest();
160
- this.commands = Object
161
- .entries(this.manifest.commands)
160
+ this.commands = Object.entries(this.manifest.commands)
162
161
  .map(([id, c]) => ({
163
162
  ...c,
164
163
  pluginAlias: this.alias,
@@ -181,12 +180,8 @@ class Plugin {
181
180
  return [];
182
181
  const marker = performance_1.Performance.mark(`plugin.commandIDs#${this.name}`, { plugin: this.name });
183
182
  this._debug(`loading IDs from ${this.commandsDir}`);
184
- const patterns = [
185
- '**/*.+(js|cjs|mjs|ts|tsx)',
186
- '!**/*.+(d.ts|test.ts|test.js|spec.ts|spec.js)?(x)',
187
- ];
188
- const ids = (0, globby_1.sync)(patterns, { cwd: this.commandsDir })
189
- .map(file => {
183
+ const patterns = ['**/*.+(js|cjs|mjs|ts|tsx)', '!**/*.+(d.ts|test.ts|test.js|spec.ts|spec.js)?(x)'];
184
+ const ids = (0, globby_1.sync)(patterns, { cwd: this.commandsDir }).map((file) => {
190
185
  const p = (0, node_path_1.parse)(file);
191
186
  const topics = p.dir.split('/');
192
187
  const command = p.name !== 'index' && p.name;
@@ -207,6 +202,7 @@ class Plugin {
207
202
  let isESM;
208
203
  let filePath;
209
204
  try {
205
+ ;
210
206
  ({ isESM, module, filePath } = cachedCommandCanBeUsed(this.manifest, id)
211
207
  ? await (0, module_loader_1.loadWithDataFromManifest)(this.manifest.commands[id], this.root)
212
208
  : await (0, module_loader_1.loadWithData)(this, (0, node_path_1.join)(this.commandsDir ?? this.pjson.oclif.commands, ...id.split(':'))));
@@ -239,7 +235,7 @@ class Plugin {
239
235
  const readManifest = async (dotfile = false) => {
240
236
  try {
241
237
  const p = (0, node_path_1.join)(this.root, `${dotfile ? '.' : ''}oclif.manifest.json`);
242
- const manifest = await (0, util_2.readJson)(p);
238
+ const manifest = await (0, index_1.readJson)(p);
243
239
  if (!process.env.OCLIF_NEXT_VERSION && manifest.version.split('-')[0] !== this.version.split('-')[0]) {
244
240
  process.emitWarning(`Mismatched version in ${this.name} plugin manifest. Expected: ${this.version} Received: ${manifest.version}\nThis usually means you have an oclif.manifest.json file that should be deleted in development. This file should be automatically generated when publishing.`);
245
241
  }
@@ -275,7 +271,7 @@ class Plugin {
275
271
  const cached = await (0, cache_command_1.cacheCommand)(await this.findCommand(id, { must: true }), this, respectNoCacheDefault);
276
272
  if (this.flexibleTaxonomy) {
277
273
  const permutations = (0, util_1.getCommandIdPermutations)(id);
278
- const aliasPermutations = cached.aliases.flatMap(a => (0, util_1.getCommandIdPermutations)(a));
274
+ const aliasPermutations = cached.aliases.flatMap((a) => (0, util_1.getCommandIdPermutations)(a));
279
275
  return [id, { ...cached, permutations, aliasPermutations }];
280
276
  }
281
277
  return [id, cached];
@@ -308,7 +304,14 @@ class Plugin {
308
304
  }
309
305
  addErrorScope(err, scope) {
310
306
  err.name = `${err.name} Plugin: ${this.name}`;
311
- err.detail = (0, util_2.compact)([err.detail, `module: ${this._base}`, scope && `task: ${scope}`, `plugin: ${this.name}`, `root: ${this.root}`, 'See more details with DEBUG=*']).join('\n');
307
+ err.detail = (0, index_1.compact)([
308
+ err.detail,
309
+ `module: ${this._base}`,
310
+ scope && `task: ${scope}`,
311
+ `plugin: ${this.name}`,
312
+ `root: ${this.root}`,
313
+ 'See more details with DEBUG=*',
314
+ ]).join('\n');
312
315
  return err;
313
316
  }
314
317
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tsPath = exports.TS_CONFIGS = void 0;
4
- const util_1 = require("../util");
4
+ const index_1 = require("../util/index");
5
5
  const node_path_1 = require("node:path");
6
- const util_2 = require("./util");
6
+ const util_1 = require("./util");
7
7
  const node_fs_1 = require("node:fs");
8
8
  const errors_1 = require("../errors");
9
9
  const settings_1 = require("../settings");
10
10
  // eslint-disable-next-line new-cap
11
- const debug = (0, util_2.Debug)('ts-node');
11
+ const debug = (0, util_1.Debug)('ts-node');
12
12
  exports.TS_CONFIGS = {};
13
13
  const REGISTERED = new Set();
14
14
  /**
@@ -35,10 +35,10 @@ function loadTSConfig(root) {
35
35
  }
36
36
  }
37
37
  if ((0, node_fs_1.existsSync)(tsconfigPath) && typescript) {
38
- const tsconfig = typescript.parseConfigFileTextToJson(tsconfigPath, (0, util_1.readJsonSync)(tsconfigPath, false)).config;
38
+ const tsconfig = typescript.parseConfigFileTextToJson(tsconfigPath, (0, index_1.readJsonSync)(tsconfigPath, false)).config;
39
39
  if (!tsconfig || !tsconfig.compilerOptions) {
40
- throw new Error(`Could not read and parse tsconfig.json at ${tsconfigPath}, or it `
41
- + 'did not contain a "compilerOptions" section.');
40
+ throw new Error(`Could not read and parse tsconfig.json at ${tsconfigPath}, or it ` +
41
+ 'did not contain a "compilerOptions" section.');
42
42
  }
43
43
  exports.TS_CONFIGS[root] = tsconfig;
44
44
  return tsconfig;
@@ -62,9 +62,7 @@ function registerTSNode(root) {
62
62
  (0, errors_1.memoizedWarn)(`Could not find ts-node at ${tsNodePath}. Please ensure that ts-node is a devDependency. Falling back to compiled source.`);
63
63
  return;
64
64
  }
65
- const typeRoots = [
66
- (0, node_path_1.join)(root, 'node_modules', '@types'),
67
- ];
65
+ const typeRoots = [(0, node_path_1.join)(root, 'node_modules', '@types')];
68
66
  const rootDirs = [];
69
67
  if (tsconfig.compilerOptions.rootDirs) {
70
68
  for (const r of tsconfig.compilerOptions.rootDirs) {
@@ -119,7 +117,7 @@ function tsPath(root, orig, plugin) {
119
117
  debug(`Skipping ts-node registration for ${root} because tsNodeEnabled is explicitly set to false`);
120
118
  return orig;
121
119
  }
122
- const isProduction = (0, util_1.isProd)();
120
+ const isProduction = (0, index_1.isProd)();
123
121
  /**
124
122
  * Skip ts-node registration for ESM plugins.
125
123
  * The node ecosystem is not mature enough to support auto-transpiling ESM modules at this time.
@@ -48,7 +48,7 @@ function getPermutations(arr) {
48
48
  }
49
49
  exports.getPermutations = getPermutations;
50
50
  function getCommandIdPermutations(commandId) {
51
- return getPermutations(commandId.split(':')).flatMap(c => c.join(':'));
51
+ return getPermutations(commandId.split(':')).flatMap((c) => c.join(':'));
52
52
  }
53
53
  exports.getCommandIdPermutations = getCommandIdPermutations;
54
54
  /**
@@ -70,5 +70,5 @@ exports.getCommandIdPermutations = getCommandIdPermutations;
70
70
  * @param commandIds string[]
71
71
  * @returns string[]
72
72
  */
73
- const collectUsableIds = (commandIds) => new Set(commandIds.flatMap(id => id.split(':').map((_, i, a) => a.slice(0, i + 1).join(':'))));
73
+ const collectUsableIds = (commandIds) => new Set(commandIds.flatMap((id) => id.split(':').map((_, i, a) => a.slice(0, i + 1).join(':'))));
74
74
  exports.collectUsableIds = collectUsableIds;
@@ -13,6 +13,7 @@ const wrap_ansi_1 = tslib_1.__importDefault(require("wrap-ansi"));
13
13
  */
14
14
  function addOclifExitCode(error, options) {
15
15
  if (!('oclif' in error)) {
16
+ ;
16
17
  error.oclif = {};
17
18
  }
18
19
  error.oclif.exit = options?.exit === undefined ? 2 : options.exit;
@@ -11,6 +11,7 @@ function applyPrettyPrintOptions(error, options) {
11
11
  for (const key of prettyErrorKeys) {
12
12
  const applyOptionsKey = !(key in error) && options[key];
13
13
  if (applyOptionsKey) {
14
+ ;
14
15
  error[key] = options[key];
15
16
  }
16
17
  }
@@ -23,7 +24,7 @@ const formatSuggestions = (suggestions) => {
23
24
  return undefined;
24
25
  if (suggestions.length === 1)
25
26
  return `${label} ${suggestions[0]}`;
26
- const multiple = suggestions.map(suggestion => `* ${suggestion}`).join('\n');
27
+ const multiple = suggestions.map((suggestion) => `* ${suggestion}`).join('\n');
27
28
  return `${label}\n${(0, indent_string_1.default)(multiple, 2)}`;
28
29
  };
29
30
  function prettyPrint(error) {
@@ -34,7 +34,8 @@ async function handle(err) {
34
34
  if (stack) {
35
35
  config_1.config.errorLogger.log(stack);
36
36
  }
37
- await config_1.config.errorLogger.flush()
37
+ await config_1.config.errorLogger
38
+ .flush()
38
39
  .then(() => exports.Exit.exit(exitCode))
39
40
  .catch(console.error);
40
41
  }
@@ -6,7 +6,7 @@ const node_path_1 = require("node:path");
6
6
  const stripAnsi = require("strip-ansi");
7
7
  const timestamp = () => new Date().toISOString();
8
8
  let timer;
9
- const wait = (ms) => new Promise(resolve => {
9
+ const wait = (ms) => new Promise((resolve) => {
10
10
  if (timer)
11
11
  timer.unref();
12
12
  timer = setTimeout(() => resolve(null), ms);
@@ -25,7 +25,7 @@ class Logger {
25
25
  }
26
26
  log(msg) {
27
27
  msg = stripAnsi(chomp(msg));
28
- const lines = msg.split('\n').map(l => `${timestamp()} ${l}`.trimEnd());
28
+ const lines = msg.split('\n').map((l) => `${timestamp()} ${l}`.trimEnd());
29
29
  this.buffer.push(...lines);
30
30
  this.flush(50).catch(console.error);
31
31
  }
package/lib/flags.d.ts CHANGED
@@ -84,7 +84,7 @@ export declare function option<T extends readonly string[], P extends CustomOpti
84
84
  required: true;
85
85
  } | {
86
86
  default: OptionFlag<ElementType<T>[], P>['default'] | undefined;
87
- })): FlagDefinition<typeof defaults.options[number], P, {
87
+ })): FlagDefinition<(typeof defaults.options)[number], P, {
88
88
  multiple: true;
89
89
  requiredOrDefaulted: true;
90
90
  }>;
@@ -95,7 +95,7 @@ export declare function option<T extends readonly string[], P extends CustomOpti
95
95
  required: true;
96
96
  } | {
97
97
  default: OptionFlag<ElementType<T>, P>['default'];
98
- })): FlagDefinition<typeof defaults.options[number], P, {
98
+ })): FlagDefinition<(typeof defaults.options)[number], P, {
99
99
  multiple: false;
100
100
  requiredOrDefaulted: true;
101
101
  }>;
@@ -104,7 +104,7 @@ export declare function option<T extends readonly string[], P extends CustomOpti
104
104
  default?: OptionFlag<ElementType<T>, P>['default'] | undefined;
105
105
  multiple?: false | undefined;
106
106
  required?: false | undefined;
107
- }): FlagDefinition<typeof defaults.options[number], P, {
107
+ }): FlagDefinition<(typeof defaults.options)[number], P, {
108
108
  multiple: false;
109
109
  requiredOrDefaulted: false;
110
110
  }>;
@@ -113,7 +113,7 @@ export declare function option<T extends readonly string[], P extends CustomOpti
113
113
  multiple: true;
114
114
  default?: OptionFlag<ElementType<T>[], P>['default'] | undefined;
115
115
  required?: false | undefined;
116
- }): FlagDefinition<typeof defaults.options[number], P, {
116
+ }): FlagDefinition<(typeof defaults.options)[number], P, {
117
117
  multiple: true;
118
118
  requiredOrDefaulted: false;
119
119
  }>;
package/lib/flags.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.option = exports.help = exports.version = exports.string = exports.url = exports.file = exports.directory = exports.integer = exports.boolean = exports.custom = void 0;
4
- const util_1 = require("./util");
4
+ const index_1 = require("./util/index");
5
5
  const errors_1 = require("./errors");
6
6
  const node_url_1 = require("node:url");
7
7
  const help_1 = require("./help");
@@ -57,14 +57,14 @@ exports.integer = custom({
57
57
  exports.directory = custom({
58
58
  async parse(input, _, opts) {
59
59
  if (opts.exists)
60
- return (0, util_1.dirExists)(input);
60
+ return (0, index_1.dirExists)(input);
61
61
  return input;
62
62
  },
63
63
  });
64
64
  exports.file = custom({
65
65
  async parse(input, _, opts) {
66
66
  if (opts.exists)
67
- return (0, util_1.fileExists)(input);
67
+ return (0, index_1.fileExists)(input);
68
68
  return input;
69
69
  },
70
70
  });