@oclif/core 5.0.1 → 5.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.
Files changed (90) hide show
  1. package/lib/args.d.ts +2 -2
  2. package/lib/cache.d.ts +2 -2
  3. package/lib/command.d.ts +10 -14
  4. package/lib/command.js +9 -7
  5. package/lib/config/config.d.ts +10 -10
  6. package/lib/config/config.js +17 -13
  7. package/lib/config/plugin-loader.d.ts +5 -5
  8. package/lib/config/plugin-loader.js +31 -29
  9. package/lib/config/plugin.d.ts +7 -8
  10. package/lib/config/plugin.js +14 -15
  11. package/lib/config/ts-path.d.ts +2 -2
  12. package/lib/config/ts-path.js +1 -1
  13. package/lib/config/util.d.ts +1 -1
  14. package/lib/config/util.js +4 -3
  15. package/lib/constraints.d.ts +19 -19
  16. package/lib/constraints.js +14 -14
  17. package/lib/errors/error.d.ts +1 -1
  18. package/lib/errors/errors/cli.d.ts +1 -1
  19. package/lib/errors/errors/exit.d.ts +1 -1
  20. package/lib/errors/errors/module-load.d.ts +1 -1
  21. package/lib/errors/errors/pretty-print.d.ts +1 -1
  22. package/lib/errors/errors/pretty-print.js +1 -1
  23. package/lib/errors/handle.d.ts +2 -2
  24. package/lib/errors/index.d.ts +1 -1
  25. package/lib/execute.d.ts +1 -1
  26. package/lib/flags.d.ts +7 -7
  27. package/lib/flush.js +10 -6
  28. package/lib/help/command.d.ts +9 -11
  29. package/lib/help/command.js +9 -10
  30. package/lib/help/docopts.d.ts +4 -4
  31. package/lib/help/docopts.js +2 -2
  32. package/lib/help/formatter.d.ts +7 -7
  33. package/lib/help/index.d.ts +4 -6
  34. package/lib/help/index.js +8 -7
  35. package/lib/help/root.d.ts +1 -1
  36. package/lib/help/root.js +1 -1
  37. package/lib/help/util.d.ts +1 -1
  38. package/lib/help/util.js +1 -1
  39. package/lib/index.js +1 -0
  40. package/lib/interfaces/args.d.ts +1 -1
  41. package/lib/interfaces/config.d.ts +8 -8
  42. package/lib/interfaces/errors.d.ts +4 -4
  43. package/lib/interfaces/flags.d.ts +1 -1
  44. package/lib/interfaces/help.d.ts +3 -3
  45. package/lib/interfaces/hooks.d.ts +12 -12
  46. package/lib/interfaces/manifest.d.ts +2 -4
  47. package/lib/interfaces/parser.d.ts +13 -25
  48. package/lib/interfaces/pjson.d.ts +12 -22
  49. package/lib/interfaces/plugin.d.ts +11 -13
  50. package/lib/interfaces/s3-manifest.d.ts +2 -2
  51. package/lib/interfaces/topic.d.ts +2 -2
  52. package/lib/interfaces/ts-config.d.ts +2 -2
  53. package/lib/logger.d.ts +2 -2
  54. package/lib/logger.js +6 -2
  55. package/lib/main.d.ts +1 -1
  56. package/lib/main.js +3 -5
  57. package/lib/module-loader.d.ts +2 -2
  58. package/lib/module-loader.js +6 -5
  59. package/lib/parser/errors.d.ts +3 -3
  60. package/lib/parser/help.d.ts +2 -2
  61. package/lib/parser/parse.d.ts +2 -2
  62. package/lib/parser/parse.js +24 -24
  63. package/lib/parser/validate.d.ts +1 -1
  64. package/lib/parser/validate.js +25 -24
  65. package/lib/performance.d.ts +4 -4
  66. package/lib/performance.js +3 -3
  67. package/lib/util/aggregate-flags.d.ts +1 -1
  68. package/lib/util/cache-command.d.ts +2 -2
  69. package/lib/util/cache-command.js +3 -3
  70. package/lib/util/cache-default-value.d.ts +1 -1
  71. package/lib/util/determine-priority.d.ts +1 -1
  72. package/lib/util/ensure-arg-object.d.ts +3 -5
  73. package/lib/util/ensure-arg-object.js +1 -1
  74. package/lib/util/find-root.js +3 -1
  75. package/lib/util/read-pjson.d.ts +1 -1
  76. package/lib/util/read-tsconfig.d.ts +1 -1
  77. package/lib/util/util.d.ts +3 -5
  78. package/lib/util/util.js +1 -1
  79. package/lib/ux/action/base.d.ts +2 -2
  80. package/lib/ux/action/base.js +4 -4
  81. package/lib/ux/action/simple.d.ts +1 -1
  82. package/lib/ux/action/spinner.d.ts +2 -2
  83. package/lib/ux/action/spinner.js +4 -1
  84. package/lib/ux/action/types.d.ts +1 -1
  85. package/lib/ux/colorize-json.js +4 -4
  86. package/lib/ux/index.d.ts +2 -2
  87. package/lib/ux/list.js +1 -0
  88. package/lib/ux/theme.d.ts +1 -1
  89. package/lib/ux/write.d.ts +2 -2
  90. package/package.json +1 -1
package/lib/args.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { URL } from 'node:url';
2
- import { Arg, ArgDefinition } from './interfaces/parser';
2
+ import { type Arg, type ArgDefinition } from './interfaces/parser';
3
3
  /**
4
4
  * Create a custom arg.
5
5
  *
@@ -36,7 +36,7 @@ export declare const file: ArgDefinition<string, {
36
36
  export declare const url: ArgDefinition<URL, Record<string, unknown>>;
37
37
  declare const stringArg: ArgDefinition<string, Record<string, unknown>>;
38
38
  export { stringArg as string };
39
- type ReadonlyElementOf<T extends ReadonlyArray<unknown>> = T[number];
39
+ type ReadonlyElementOf<T extends readonly unknown[]> = T[number];
40
40
  /**
41
41
  * Create an arg that infers the type from the provided options.
42
42
  *
package/lib/cache.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Config } from './config/config';
2
- import { OclifConfiguration, Plugin } from './interfaces';
1
+ import { type Config } from './config/config';
2
+ import { type OclifConfiguration, type Plugin } from './interfaces';
3
3
  type CacheContents = {
4
4
  rootPlugin: Plugin;
5
5
  config: Config;
package/lib/command.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Config } from './config';
2
- import { PrettyPrintableError } from './errors';
3
- import { LoadOptions } from './interfaces/config';
4
- import { CommandError } from './interfaces/errors';
5
- import { ArgInput, ArgOutput, ArgProps, BooleanFlagProps, Constraint, Deprecation, FlagInput, FlagOutput, Arg as IArg, Flag as IFlag, Input, OptionFlagProps, ParserOutput } from './interfaces/parser';
6
- import { Plugin } from './interfaces/plugin';
2
+ import { type PrettyPrintableError } from './errors';
3
+ import { type LoadOptions } from './interfaces/config';
4
+ import { type CommandError } from './interfaces/errors';
5
+ import { type ArgInput, type ArgOutput, type ArgProps, type BooleanFlagProps, type Constraint, type Deprecation, type FlagInput, type FlagOutput, type Arg as IArg, type Flag as IFlag, type Input, type OptionFlagProps, type ParserOutput } from './interfaces/parser';
6
+ import { type Plugin } from './interfaces/plugin';
7
7
  /**
8
8
  * An abstract class which acts as the base for each command
9
9
  * in your project.
@@ -137,7 +137,7 @@ export declare namespace Command {
137
137
  * is executed then the `load` method is used to require the command class.
138
138
  */
139
139
  type Loadable = Cached & {
140
- load(): Promise<Command.Class>;
140
+ load(): Promise<Class>;
141
141
  };
142
142
  /**
143
143
  * A cached version of the command. This is created by the cachedCommand utility and
@@ -147,16 +147,12 @@ export declare namespace Command {
147
147
  [key: string]: unknown;
148
148
  aliasPermutations?: string[] | undefined;
149
149
  aliases: string[];
150
- args: {
151
- [name: string]: Arg.Cached;
152
- };
150
+ args: Record<string, Arg.Cached>;
153
151
  deprecateAliases?: boolean | undefined;
154
152
  deprecationOptions?: Deprecation | undefined;
155
153
  description?: string | undefined;
156
154
  examples?: Example[] | undefined;
157
- flags: {
158
- [name: string]: Flag.Cached;
159
- };
155
+ flags: Record<string, Flag.Cached>;
160
156
  hasDynamicHelp?: boolean;
161
157
  hidden: boolean;
162
158
  hiddenAliases: string[];
@@ -185,8 +181,8 @@ export declare namespace Command {
185
181
  type Cached = Omit<Arg, 'input' | 'parse'> & ArgProps;
186
182
  type Any = Arg | Cached;
187
183
  }
188
- type Example = {
184
+ type Example = string | {
189
185
  command: string;
190
186
  description: string;
191
- } | string;
187
+ };
192
188
  }
package/lib/command.js CHANGED
@@ -214,7 +214,7 @@ class Command {
214
214
  }
215
215
  }
216
216
  error(input, options = {}) {
217
- return Errors.error(input, options);
217
+ Errors.error(input, options);
218
218
  }
219
219
  exit(code = 0) {
220
220
  Errors.exit(code);
@@ -248,19 +248,21 @@ class Command {
248
248
  jsonIndex !== -1 && jsonIndex < passThroughIndex;
249
249
  }
250
250
  log(message = '', ...args) {
251
- if (!this.jsonEnabled()) {
252
- message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
253
- ux_1.ux.stdout(message, ...args);
251
+ if (this.jsonEnabled()) {
252
+ return;
254
253
  }
254
+ message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
255
+ ux_1.ux.stdout(message, ...args);
255
256
  }
256
257
  logJson(json) {
257
258
  ux_1.ux.stdout(ux_1.ux.colorizeJson(json, { pretty: true, theme: this.config.theme?.json }));
258
259
  }
259
260
  logToStderr(message = '', ...args) {
260
- if (!this.jsonEnabled()) {
261
- message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
262
- ux_1.ux.stderr(message, ...args);
261
+ if (this.jsonEnabled()) {
262
+ return;
263
263
  }
264
+ message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
265
+ ux_1.ux.stderr(message, ...args);
264
266
  }
265
267
  async parse(options, argv = this.argv) {
266
268
  if (!options)
@@ -1,8 +1,8 @@
1
- import { Command } from '../command';
2
- import { Hook, Hooks, OclifConfiguration, PJSON, S3Templates, Topic, UserPJSON } from '../interfaces';
3
- import { ArchTypes, Config as IConfig, LoadOptions, PlatformTypes, VersionDetails } from '../interfaces/config';
4
- import { Plugin as IPlugin, Options } from '../interfaces/plugin';
5
- import { Theme } from '../interfaces/theme';
1
+ import { type Command } from '../command';
2
+ import { type Hook, type Hooks, type OclifConfiguration, type PJSON, type S3Templates, type Topic, type UserPJSON } from '../interfaces';
3
+ import { type ArchTypes, type Config as IConfig, type LoadOptions, type PlatformTypes, type VersionDetails } from '../interfaces/config';
4
+ import { type Plugin as IPlugin, type Options } from '../interfaces/plugin';
5
+ import { type Theme } from '../interfaces/theme';
6
6
  export declare class Config implements IConfig {
7
7
  options: Options;
8
8
  arch: ArchTypes;
@@ -34,14 +34,14 @@ export declare class Config implements IConfig {
34
34
  version: string;
35
35
  protected warned: boolean;
36
36
  windows: boolean;
37
- private _base;
37
+ private readonly _base;
38
38
  private _commandIDs;
39
- private _commands;
40
- private _topics;
41
- private commandPermutations;
39
+ private readonly _commands;
40
+ private readonly _topics;
41
+ private readonly commandPermutations;
42
42
  private pluginLoader;
43
43
  private rootPlugin;
44
- private topicPermutations;
44
+ private readonly topicPermutations;
45
45
  constructor(options: Options);
46
46
  static load(opts?: LoadOptions): Promise<Config>;
47
47
  get commandIDs(): string[];
@@ -39,7 +39,7 @@ function displayWarnings() {
39
39
  });
40
40
  }
41
41
  function channelFromVersion(version) {
42
- const m = version.match(/[^-]+(?:-([^.]+))?/);
42
+ const m = /[^-]+(?:-([^.]+))?/.exec(version);
43
43
  return (m && m[1]) || 'stable';
44
44
  }
45
45
  function isConfig(o) {
@@ -151,7 +151,7 @@ class Config {
151
151
  return [...this._topics.values()];
152
152
  }
153
153
  get versionDetails() {
154
- const [cliVersion, architecture, nodeVersion] = this.userAgent.split(' ');
154
+ const [cliVersion, architecture, nodeVersion] = this.userAgent.split(' ', 3);
155
155
  return {
156
156
  architecture,
157
157
  cliVersion,
@@ -194,9 +194,9 @@ class Config {
194
194
  .map((a) => a.replaceAll('-', ''));
195
195
  const possibleMatches = [...this.commandPermutations.get(partialCmdId)].map((k) => this._commands.get(k));
196
196
  const matches = possibleMatches.filter((command) => {
197
- const cmdFlags = Object.entries(command.flags).flatMap(([flag, def]) => def.char ? [def.char, flag] : [flag]);
197
+ const cmdFlags = new Set(Object.entries(command.flags).flatMap(([flag, def]) => (def.char ? [def.char, flag] : [flag])));
198
198
  // A command is a match if the provided flags belong to the full command
199
- return flags.every((f) => cmdFlags.includes(f));
199
+ return flags.every((f) => cmdFlags.has(f));
200
200
  });
201
201
  return matches;
202
202
  }
@@ -223,10 +223,11 @@ class Config {
223
223
  const commands = [...this._commands.values()];
224
224
  const validPermutations = [...this.commandPermutations.getAllValid()];
225
225
  for (const permutation of validPermutations) {
226
- if (!this._commands.has(permutation)) {
227
- const cmd = this._commands.get(this.getCmdLookupId(permutation));
228
- commands.push({ ...cmd, id: permutation });
226
+ if (this._commands.has(permutation)) {
227
+ continue;
229
228
  }
229
+ const cmd = this._commands.get(this.getCmdLookupId(permutation));
230
+ commands.push({ ...cmd, id: permutation });
230
231
  }
231
232
  return commands;
232
233
  }
@@ -343,7 +344,9 @@ class Config {
343
344
  macosCacheDir() {
344
345
  return (this.platform === 'darwin' && (0, node_path_1.join)(this.home, 'Library', 'Caches', this.dirname)) || undefined;
345
346
  }
346
- async runCommand(id, argv = [], cachedCommand = null) {
347
+ async runCommand(id, argv = [],
348
+ // eslint-disable-next-line @typescript-eslint/no-restricted-types
349
+ cachedCommand = null) {
347
350
  const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, `config.runCommand#${id}`);
348
351
  debug('runCommand %s %o', id, argv);
349
352
  let c = cachedCommand ?? this.findCommand(id);
@@ -557,14 +560,14 @@ class Config {
557
560
  manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- platform %>-<%- arch %>",
558
561
  unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-<%- platform %>-<%- arch %><%- ext %>",
559
562
  versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %><%- ext %>",
560
- ...(s3?.templates && s3?.templates.target),
563
+ ...s3?.templates?.target,
561
564
  },
562
565
  vanilla: {
563
566
  baseDir: '<%- bin %>',
564
567
  manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %>version",
565
568
  unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %><%- ext %>",
566
569
  versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %><%- ext %>",
567
- ...(s3?.templates && s3?.templates.vanilla),
570
+ ...s3?.templates?.vanilla,
568
571
  },
569
572
  };
570
573
  return {
@@ -706,10 +709,11 @@ class Config {
706
709
  marker?.stop();
707
710
  }
708
711
  maybeAdjustDebugSetting() {
709
- if (this.scopedEnvVarTrue('DEBUG')) {
710
- settings_1.settings.debug = true;
711
- displayWarnings();
712
+ if (!this.scopedEnvVarTrue('DEBUG')) {
713
+ return;
712
714
  }
715
+ settings_1.settings.debug = true;
716
+ displayWarnings();
713
717
  }
714
718
  warn(err, scope) {
715
719
  if (this.warned)
@@ -1,5 +1,5 @@
1
- import { PJSON } from '../interfaces';
2
- import { Plugin as IPlugin } from '../interfaces/plugin';
1
+ import { type PJSON } from '../interfaces';
2
+ import { type Plugin as IPlugin } from '../interfaces/plugin';
3
3
  type PluginLoaderOptions = {
4
4
  plugins?: IPlugin[] | PluginsMap | undefined;
5
5
  root: string;
@@ -19,12 +19,12 @@ type LoadOpts = {
19
19
  type PluginsMap = Map<string, IPlugin>;
20
20
  export default class PluginLoader {
21
21
  options: PluginLoaderOptions;
22
- errors: (Error | string)[];
22
+ errors: Array<Error | string>;
23
23
  plugins: PluginsMap;
24
- private pluginsProvided;
24
+ private readonly pluginsProvided;
25
25
  constructor(options: PluginLoaderOptions);
26
26
  loadChildren(opts: LoadOpts): Promise<{
27
- errors: (Error | string)[];
27
+ errors: Array<Error | string>;
28
28
  plugins: PluginsMap;
29
29
  }>;
30
30
  loadRoot({ pjson }: {
@@ -18,10 +18,11 @@ class PluginLoader {
18
18
  pluginsProvided = false;
19
19
  constructor(options) {
20
20
  this.options = options;
21
- if (options.plugins) {
22
- this.pluginsProvided = true;
23
- this.plugins = Array.isArray(options.plugins) ? new Map(options.plugins.map((p) => [p.name, p])) : options.plugins;
21
+ if (!options.plugins) {
22
+ return;
24
23
  }
24
+ this.pluginsProvided = true;
25
+ this.plugins = Array.isArray(options.plugins) ? new Map(options.plugins.map((p) => [p.name, p])) : options.plugins;
25
26
  }
26
27
  async loadChildren(opts) {
27
28
  if (!this.pluginsProvided || opts.force) {
@@ -75,37 +76,38 @@ class PluginLoader {
75
76
  }
76
77
  }
77
78
  async loadDevPlugins(opts) {
78
- if (opts.devPlugins !== false) {
79
- // do not load oclif.devPlugins in production
80
- if ((0, util_1.isProd)())
81
- return;
82
- try {
83
- const { devPlugins } = opts.rootPlugin.pjson.oclif;
84
- if (devPlugins) {
79
+ if (opts.devPlugins === false) {
80
+ return;
81
+ }
82
+ // do not load oclif.devPlugins in production
83
+ if ((0, util_1.isProd)())
84
+ return;
85
+ try {
86
+ const { devPlugins } = opts.rootPlugin.pjson.oclif;
87
+ if (devPlugins) {
88
+ const allDeps = { ...opts.rootPlugin.pjson.dependencies, ...opts.rootPlugin.pjson.devDependencies };
89
+ const plugins = findMatchingDependencies(allDeps ?? {}, devPlugins);
90
+ await this.loadPlugins(opts.rootPlugin.root, 'dev', plugins);
91
+ }
92
+ const { dev: pluginAdditionsDev, path } = opts.pluginAdditions ?? { core: [] };
93
+ if (pluginAdditionsDev) {
94
+ if (path) {
95
+ // If path is provided, load plugins from the path
96
+ const pjson = await (0, fs_1.readJson)((0, node_path_1.join)(path, 'package.json'));
97
+ const allDeps = { ...pjson.dependencies, ...pjson.devDependencies };
98
+ const plugins = findMatchingDependencies(allDeps ?? {}, pluginAdditionsDev);
99
+ await this.loadPlugins(path, 'dev', plugins);
100
+ }
101
+ else {
85
102
  const allDeps = { ...opts.rootPlugin.pjson.dependencies, ...opts.rootPlugin.pjson.devDependencies };
86
- const plugins = findMatchingDependencies(allDeps ?? {}, devPlugins);
103
+ const plugins = findMatchingDependencies(allDeps ?? {}, pluginAdditionsDev);
87
104
  await this.loadPlugins(opts.rootPlugin.root, 'dev', plugins);
88
105
  }
89
- const { dev: pluginAdditionsDev, path } = opts.pluginAdditions ?? { core: [] };
90
- if (pluginAdditionsDev) {
91
- if (path) {
92
- // If path is provided, load plugins from the path
93
- const pjson = await (0, fs_1.readJson)((0, node_path_1.join)(path, 'package.json'));
94
- const allDeps = { ...pjson.dependencies, ...pjson.devDependencies };
95
- const plugins = findMatchingDependencies(allDeps ?? {}, pluginAdditionsDev);
96
- await this.loadPlugins(path, 'dev', plugins);
97
- }
98
- else {
99
- const allDeps = { ...opts.rootPlugin.pjson.dependencies, ...opts.rootPlugin.pjson.devDependencies };
100
- const plugins = findMatchingDependencies(allDeps ?? {}, pluginAdditionsDev);
101
- await this.loadPlugins(opts.rootPlugin.root, 'dev', plugins);
102
- }
103
- }
104
- }
105
- catch (error) {
106
- process.emitWarning(error);
107
106
  }
108
107
  }
108
+ catch (error) {
109
+ process.emitWarning(error);
110
+ }
109
111
  }
110
112
  async loadPlugins(root, type, plugins, parent) {
111
113
  if (!plugins || plugins.length === 0)
@@ -1,9 +1,10 @@
1
- import { Command } from '../command';
2
- import { Manifest } from '../interfaces/manifest';
3
- import { HookOptions, PJSON } from '../interfaces/pjson';
4
- import { Plugin as IPlugin, PluginOptions } from '../interfaces/plugin';
5
- import { Topic } from '../interfaces/topic';
1
+ import { type Command } from '../command';
2
+ import { type Manifest } from '../interfaces/manifest';
3
+ import { type HookOptions, type PJSON } from '../interfaces/pjson';
4
+ import { type Plugin as IPlugin, type PluginOptions } from '../interfaces/plugin';
5
+ import { type Topic } from '../interfaces/topic';
6
6
  export declare class Plugin implements IPlugin {
7
+ #private;
7
8
  options: PluginOptions;
8
9
  _base: string;
9
10
  protected _debug: (..._: any) => void;
@@ -14,9 +15,7 @@ export declare class Plugin implements IPlugin {
14
15
  commands: Command.Loadable[];
15
16
  commandsDir: string | undefined;
16
17
  hasManifest: boolean;
17
- hooks: {
18
- [key: string]: HookOptions[];
19
- };
18
+ hooks: Record<string, HookOptions[]>;
20
19
  isRoot: boolean;
21
20
  manifest: Manifest;
22
21
  moduleType: 'commonjs' | 'module';
@@ -36,7 +36,7 @@ const cachedCommandCanBeUsed = (manifest, id) => Boolean(manifest?.commands[id]
36
36
  const searchForCommandClass = (cmd) => {
37
37
  if (typeof cmd.run === 'function')
38
38
  return cmd;
39
- if (cmd.default && cmd.default.run)
39
+ if (cmd.default?.run)
40
40
  return cmd.default;
41
41
  return Object.values(cmd).find((cmd) => typeof cmd.run === 'function');
42
42
  };
@@ -103,6 +103,7 @@ class Plugin {
103
103
  type;
104
104
  valid = false;
105
105
  version;
106
+ #base = `${_pjson.name}@${_pjson.version}`;
106
107
  commandCache;
107
108
  commandDiscoveryOpts;
108
109
  flexibleTaxonomy;
@@ -172,11 +173,9 @@ class Plugin {
172
173
  // Linked plugins already have a root so there's no need to search for it.
173
174
  // However there could be child plugins nested inside the linked plugin, in which
174
175
  // case we still need to search for the child plugin's root.
175
- const root = this.options.pjson && this.options.isRoot
176
+ const root = (this.options.pjson && this.options.isRoot) || (this.type === 'link' && !this.parent)
176
177
  ? this.options.root
177
- : this.type === 'link' && !this.parent
178
- ? this.options.root
179
- : await (0, find_root_1.findRoot)(this.options.name, this.options.root);
178
+ : await (0, find_root_1.findRoot)(this.options.name, this.options.root);
180
179
  if (!root)
181
180
  throw new errors_1.CLIError(`could not find package.json with ${(0, node_util_1.inspect)(this.options)}`);
182
181
  this.root = root;
@@ -213,14 +212,14 @@ class Plugin {
213
212
  .sort((a, b) => a.id.localeCompare(b.id));
214
213
  }
215
214
  async _manifest() {
216
- const ignoreManifest = Boolean(this.options.ignoreManifest);
217
- const errorOnManifestCreate = Boolean(this.options.errorOnManifestCreate);
218
- const respectNoCacheDefault = Boolean(this.options.respectNoCacheDefault);
215
+ const isIgnoreManifest = Boolean(this.options.ignoreManifest);
216
+ const isErrorOnManifestCreate = Boolean(this.options.errorOnManifestCreate);
217
+ const isRespectNoCacheDefault = Boolean(this.options.respectNoCacheDefault);
219
218
  const readManifest = async (dotfile = false) => {
220
219
  try {
221
220
  const p = (0, node_path_1.join)(this.root, `${dotfile ? '.' : ''}oclif.manifest.json`);
222
221
  const manifest = await (0, fs_1.readJson)(p);
223
- if (!process.env.OCLIF_NEXT_VERSION && manifest.version.split('-')[0] !== this.version.split('-')[0]) {
222
+ if (!process.env.OCLIF_NEXT_VERSION && manifest.version.split('-', 1)[0] !== this.version.split('-', 1)[0]) {
224
223
  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.`);
225
224
  }
226
225
  else {
@@ -240,7 +239,7 @@ class Plugin {
240
239
  }
241
240
  };
242
241
  const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, `plugin.manifest#${this.name}`, { plugin: this.name });
243
- if (!ignoreManifest) {
242
+ if (!isIgnoreManifest) {
244
243
  const manifest = await readManifest();
245
244
  if (manifest) {
246
245
  marker?.addDetails({ commandCount: Object.keys(manifest.commands).length, fromCache: true });
@@ -254,7 +253,7 @@ class Plugin {
254
253
  commands: (await Promise.all(this.commandIDs.map(async (id) => {
255
254
  try {
256
255
  const found = await this.findCommand(id, { must: true });
257
- const cached = await (0, cache_command_1.cacheCommand)(found, this, respectNoCacheDefault);
256
+ const cached = await (0, cache_command_1.cacheCommand)(found, this, isRespectNoCacheDefault);
258
257
  // Ensure that id is set to the id being processed
259
258
  // This is necessary because the id is set by findCommand but if there
260
259
  // are multiple instances of a Command, then the id will be set to the
@@ -269,10 +268,10 @@ class Plugin {
269
268
  }
270
269
  catch (error) {
271
270
  const scope = `findCommand (${id})`;
272
- if (Boolean(errorOnManifestCreate) === false)
273
- this.warn(error, scope);
274
- else
271
+ if (isErrorOnManifestCreate) {
275
272
  throw this.addErrorScope(error, scope);
273
+ }
274
+ this.warn(error, scope);
276
275
  }
277
276
  })))
278
277
  .filter((f) => Boolean(f))
@@ -290,7 +289,7 @@ class Plugin {
290
289
  err.name = err.name ?? (0, node_util_1.inspect)(err).trim();
291
290
  err.detail = (0, util_1.compact)([
292
291
  err.detail,
293
- `module: ${this._base}`,
292
+ `module: ${this.#base}`,
294
293
  scope && `task: ${scope}`,
295
294
  `plugin: ${this.name}`,
296
295
  `root: ${this.root}`,
@@ -1,4 +1,4 @@
1
- import { Plugin, TSConfig } from '../interfaces';
1
+ import { type Plugin, type TSConfig } from '../interfaces';
2
2
  export declare const TS_CONFIGS: Record<string, TSConfig | undefined>;
3
3
  /**
4
4
  * Convert a path from the compiled ./lib files to the ./src typescript source
@@ -6,4 +6,4 @@ export declare const TS_CONFIGS: Record<string, TSConfig | undefined>;
6
6
  * if there is a tsconfig and the original sources exist, it attempts to require ts-node
7
7
  */
8
8
  export declare function tsPath(root: string, orig: string, plugin: Plugin): Promise<string>;
9
- export declare function tsPath(root: string, orig: string | undefined, plugin?: Plugin | undefined): Promise<string | undefined>;
9
+ export declare function tsPath(root: string, orig: string | undefined, plugin?: Plugin): Promise<string | undefined>;
@@ -188,7 +188,7 @@ function cannotTranspileEsm(rootPlugin, plugin, isProduction) {
188
188
  function cannotUseTsNode(root, plugin, isProduction) {
189
189
  if (plugin?.moduleType !== 'module' || isProduction)
190
190
  return false;
191
- const nodeMajor = Number.parseInt(process.version.replace('v', '').split('.')[0], 10);
191
+ const nodeMajor = Number.parseInt(process.version.replace('v', '').split('.', 1)[0], 10);
192
192
  return RUN_TIME === 'ts-node' && nodeMajor >= 20;
193
193
  }
194
194
  /**
@@ -1,5 +1,5 @@
1
1
  export declare function makeDebug(...scope: string[]): (..._: any) => void;
2
- export declare function getPermutations(arr: string[]): Array<string[]>;
2
+ export declare function getPermutations(arr: string[]): string[][];
3
3
  export declare function getCommandIdPermutations(commandId: string): string[];
4
4
  /**
5
5
  * Return an array of ids that represent all the usable combinations that a user could enter.
@@ -6,7 +6,9 @@ exports.getPermutations = getPermutations;
6
6
  exports.getCommandIdPermutations = getCommandIdPermutations;
7
7
  const logger_1 = require("../logger");
8
8
  function makeDebug(...scope) {
9
- return (formatter, ...args) => (0, logger_1.getLogger)(['config', ...scope].join(':')).debug(formatter, ...args);
9
+ return (formatter, ...args) => {
10
+ (0, logger_1.getLogger)(['config', ...scope].join(':')).debug(formatter, ...args);
11
+ };
10
12
  }
11
13
  // Adapted from https://github.com/angus-c/just/blob/master/packages/array-permutations/index.js
12
14
  function getPermutations(arr) {
@@ -17,8 +19,7 @@ function getPermutations(arr) {
17
19
  const output = [];
18
20
  const partialPermutations = getPermutations(arr.slice(1));
19
21
  const first = arr[0];
20
- for (let i = 0, len = partialPermutations.length; i < len; i++) {
21
- const partial = partialPermutations[i];
22
+ for (const partial of partialPermutations) {
22
23
  for (let j = 0, len2 = partial.length; j <= len2; j++) {
23
24
  const start = partial.slice(0, j);
24
25
  const end = partial.slice(j);