@oclif/core 4.0.0-beta.7 → 4.0.0-beta.9

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 (49) hide show
  1. package/lib/args.d.ts +4 -4
  2. package/lib/cache.d.ts +3 -3
  3. package/lib/cache.js +1 -1
  4. package/lib/command.d.ts +18 -19
  5. package/lib/command.js +10 -8
  6. package/lib/config/config.d.ts +10 -30
  7. package/lib/config/config.js +25 -66
  8. package/lib/config/plugin-loader.d.ts +6 -6
  9. package/lib/config/plugin-loader.js +3 -26
  10. package/lib/config/plugin.d.ts +3 -3
  11. package/lib/config/plugin.js +2 -5
  12. package/lib/config/ts-path.d.ts +1 -1
  13. package/lib/errors/errors/cli.d.ts +5 -5
  14. package/lib/errors/errors/pretty-print.d.ts +2 -2
  15. package/lib/flags.d.ts +4 -4
  16. package/lib/flush.js +2 -2
  17. package/lib/help/formatter.d.ts +3 -3
  18. package/lib/help/index.d.ts +1 -0
  19. package/lib/help/index.js +19 -10
  20. package/lib/index.d.ts +4 -5
  21. package/lib/index.js +1 -1
  22. package/lib/interfaces/config.d.ts +9 -9
  23. package/lib/interfaces/errors.d.ts +5 -5
  24. package/lib/interfaces/flags.d.ts +3 -2
  25. package/lib/interfaces/hooks.d.ts +1 -1
  26. package/lib/interfaces/index.d.ts +1 -1
  27. package/lib/interfaces/parser.d.ts +7 -8
  28. package/lib/interfaces/pjson.d.ts +217 -151
  29. package/lib/interfaces/plugin.d.ts +25 -25
  30. package/lib/interfaces/topic.d.ts +2 -2
  31. package/lib/main.js +2 -2
  32. package/lib/parser/errors.d.ts +1 -1
  33. package/lib/parser/index.d.ts +1 -1
  34. package/lib/settings.d.ts +5 -5
  35. package/lib/util/aggregate-flags.d.ts +1 -1
  36. package/lib/util/aggregate-flags.js +2 -3
  37. package/lib/util/cache-command.js +3 -4
  38. package/lib/util/determine-priority.d.ts +21 -0
  39. package/lib/util/determine-priority.js +55 -0
  40. package/lib/util/ids.d.ts +1 -1
  41. package/lib/util/read-pjson.d.ts +1 -1
  42. package/lib/ux/colorize-json.d.ts +2 -2
  43. package/lib/ux/index.d.ts +7 -2
  44. package/lib/ux/index.js +15 -3
  45. package/lib/ux/theme.d.ts +1 -1
  46. package/package.json +26 -11
  47. package/flush.d.ts +0 -3
  48. package/flush.js +0 -1
  49. package/handle.js +0 -1
package/lib/args.d.ts CHANGED
@@ -21,14 +21,14 @@ import { Arg, ArgDefinition } from './interfaces/parser';
21
21
  export declare function custom<T = string, P = Record<string, unknown>>(defaults: Partial<Arg<T, P>>): ArgDefinition<T, P>;
22
22
  export declare const boolean: ArgDefinition<boolean, Record<string, unknown>>;
23
23
  export declare const integer: ArgDefinition<number, {
24
- max?: number | undefined;
25
- min?: number | undefined;
24
+ max?: number;
25
+ min?: number;
26
26
  }>;
27
27
  export declare const directory: ArgDefinition<string, {
28
- exists?: boolean | undefined;
28
+ exists?: boolean;
29
29
  }>;
30
30
  export declare const file: ArgDefinition<string, {
31
- exists?: boolean | undefined;
31
+ exists?: boolean;
32
32
  }>;
33
33
  /**
34
34
  * Initializes a string as a URL. Throws an error
package/lib/cache.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Config } from './config/config';
2
- import { PJSON, Plugin } from './interfaces';
2
+ import { OclifConfiguration, Plugin } from './interfaces';
3
3
  type OclifCoreInfo = {
4
4
  name: string;
5
5
  version: string;
@@ -7,7 +7,7 @@ type OclifCoreInfo = {
7
7
  type CacheContents = {
8
8
  rootPlugin: Plugin;
9
9
  config: Config;
10
- exitCodes: PJSON.Plugin['oclif']['exitCodes'];
10
+ exitCodes: OclifConfiguration['exitCodes'];
11
11
  '@oclif/core': OclifCoreInfo;
12
12
  };
13
13
  type ValueOf<T> = T[keyof T];
@@ -21,7 +21,7 @@ export default class Cache extends Map<keyof CacheContents, ValueOf<CacheContent
21
21
  get(key: 'config'): Config | undefined;
22
22
  get(key: '@oclif/core'): OclifCoreInfo;
23
23
  get(key: 'rootPlugin'): Plugin | undefined;
24
- get(key: 'exitCodes'): PJSON.Plugin['oclif']['exitCodes'] | undefined;
24
+ get(key: 'exitCodes'): OclifConfiguration['exitCodes'] | undefined;
25
25
  private getOclifCoreMeta;
26
26
  }
27
27
  export {};
package/lib/cache.js CHANGED
@@ -28,7 +28,7 @@ class Cache extends Map {
28
28
  try {
29
29
  return {
30
30
  name: '@oclif/core',
31
- version: JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8')),
31
+ version: JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8')).version,
32
32
  };
33
33
  }
34
34
  catch {
package/lib/command.d.ts CHANGED
@@ -15,7 +15,6 @@ export declare abstract class Command {
15
15
  static aliases: string[];
16
16
  /** An order-dependent object of arguments for the command */
17
17
  static args: ArgInput;
18
- static baseFlags: FlagInput;
19
18
  /**
20
19
  * Emit deprecation warning when a command alias is used
21
20
  */
@@ -109,7 +108,7 @@ export declare abstract class Command {
109
108
  log(message?: string, ...args: any[]): void;
110
109
  protected logJson(json: unknown): void;
111
110
  logToStderr(message?: string, ...args: any[]): void;
112
- protected parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(options?: Input<F, B, A>, argv?: string[]): Promise<ParserOutput<F, B, A>>;
111
+ protected parse<F extends FlagOutput, A extends ArgOutput>(options?: Input<F, A>, argv?: string[]): Promise<ParserOutput<F, A>>;
113
112
  protected toErrorJson(err: unknown): any;
114
113
  protected toSuccessJson(result: unknown): any;
115
114
  warn(input: Error | string): Error | string;
@@ -143,15 +142,15 @@ export declare namespace Command {
143
142
  */
144
143
  type Cached = {
145
144
  [key: string]: unknown;
146
- aliasPermutations?: string[];
145
+ aliasPermutations?: string[] | undefined;
147
146
  aliases: string[];
148
147
  args: {
149
148
  [name: string]: Arg.Cached;
150
149
  };
151
- deprecateAliases?: boolean;
152
- deprecationOptions?: Deprecation;
153
- description?: string;
154
- examples?: Example[];
150
+ deprecateAliases?: boolean | undefined;
151
+ deprecationOptions?: Deprecation | undefined;
152
+ description?: string | undefined;
153
+ examples?: Example[] | undefined;
155
154
  flags: {
156
155
  [name: string]: Flag.Cached;
157
156
  };
@@ -159,22 +158,22 @@ export declare namespace Command {
159
158
  hidden: boolean;
160
159
  hiddenAliases: string[];
161
160
  id: string;
162
- isESM?: boolean;
163
- permutations?: string[];
164
- pluginAlias?: string;
165
- pluginName?: string;
166
- pluginType?: string;
167
- relativePath?: string[];
168
- state?: 'beta' | 'deprecated' | string;
169
- strict?: boolean;
170
- summary?: string;
171
- type?: string;
172
- usage?: string | string[];
161
+ isESM?: boolean | undefined;
162
+ permutations?: string[] | undefined;
163
+ pluginAlias?: string | undefined;
164
+ pluginName?: string | undefined;
165
+ pluginType?: string | undefined;
166
+ relativePath?: string[] | undefined;
167
+ state?: 'beta' | 'deprecated' | string | undefined;
168
+ strict?: boolean | undefined;
169
+ summary?: string | undefined;
170
+ type?: string | undefined;
171
+ usage?: string | string[] | undefined;
173
172
  };
174
173
  type Flag = IFlag<any>;
175
174
  namespace Flag {
176
175
  type Cached = Omit<Flag, 'input' | 'parse'> & (BooleanFlagProps | OptionFlagProps) & {
177
- hasDynamicHelp?: boolean;
176
+ hasDynamicHelp?: boolean | undefined;
178
177
  };
179
178
  type Any = Cached | Flag;
180
179
  }
package/lib/command.js CHANGED
@@ -39,7 +39,7 @@ const Parser = __importStar(require("./parser"));
39
39
  const aggregate_flags_1 = require("./util/aggregate-flags");
40
40
  const ids_1 = require("./util/ids");
41
41
  const util_2 = require("./util/util");
42
- const ux_1 = __importDefault(require("./ux"));
42
+ const ux_1 = require("./ux");
43
43
  const pjson = cache_1.default.getInstance().get('@oclif/core');
44
44
  /**
45
45
  * swallows stdout epipe errors
@@ -61,7 +61,6 @@ class Command {
61
61
  static aliases = [];
62
62
  /** An order-dependent object of arguments for the command */
63
63
  static args = {};
64
- static baseFlags;
65
64
  /**
66
65
  * Emit deprecation warning when a command alias is used
67
66
  */
@@ -148,6 +147,9 @@ class Command {
148
147
  opts = (0, node_url_1.fileURLToPath)(opts);
149
148
  }
150
149
  const config = await config_1.Config.load(opts || require.main?.filename || __dirname);
150
+ const cache = cache_1.default.getInstance();
151
+ if (!cache.has('config'))
152
+ cache.set('config', config);
151
153
  const cmd = new this(argv, config);
152
154
  if (!cmd.id) {
153
155
  const id = cmd.constructor.name.toLowerCase();
@@ -168,7 +170,7 @@ class Command {
168
170
  if (!err.message)
169
171
  throw err;
170
172
  try {
171
- ux_1.default.action.stop(ansis_1.default.bold.red('!'));
173
+ ux_1.ux.action.stop(ansis_1.default.bold.red('!'));
172
174
  }
173
175
  catch { }
174
176
  throw err;
@@ -211,16 +213,16 @@ class Command {
211
213
  log(message = '', ...args) {
212
214
  if (!this.jsonEnabled()) {
213
215
  message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
214
- ux_1.default.stdout(message, ...args);
216
+ ux_1.ux.stdout(message, ...args);
215
217
  }
216
218
  }
217
219
  logJson(json) {
218
- ux_1.default.stdout(ux_1.default.colorizeJson(json, { pretty: true, theme: this.config.theme?.json }));
220
+ ux_1.ux.stdout(ux_1.ux.colorizeJson(json, { pretty: true, theme: this.config.theme?.json }));
219
221
  }
220
222
  logToStderr(message = '', ...args) {
221
223
  if (!this.jsonEnabled()) {
222
224
  message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
223
- ux_1.default.stderr(message, ...args);
225
+ ux_1.ux.stderr(message, ...args);
224
226
  }
225
227
  }
226
228
  async parse(options, argv = this.argv) {
@@ -229,7 +231,7 @@ class Command {
229
231
  const opts = {
230
232
  context: this,
231
233
  ...options,
232
- flags: (0, aggregate_flags_1.aggregateFlags)(options.flags, options.baseFlags, options.enableJsonFlag),
234
+ flags: (0, aggregate_flags_1.aggregateFlags)(options.flags, options.enableJsonFlag),
233
235
  };
234
236
  const hookResult = await this.config.runHook('preparse', { argv: [...argv], options: opts });
235
237
  // Since config.runHook will only run the hook for the root plugin, hookResult.successes will always have a length of 0 or 1
@@ -266,7 +268,7 @@ class Command {
266
268
  }
267
269
  }
268
270
  warnIfFlagDeprecated(flags) {
269
- const allFlags = (0, aggregate_flags_1.aggregateFlags)(this.ctor.flags, this.ctor.baseFlags, this.ctor.enableJsonFlag);
271
+ const allFlags = (0, aggregate_flags_1.aggregateFlags)(this.ctor.flags, this.ctor.enableJsonFlag);
270
272
  for (const flag of Object.keys(flags)) {
271
273
  const flagDef = allFlags[flag];
272
274
  const deprecated = flagDef?.deprecated;
@@ -1,5 +1,5 @@
1
1
  import { Command } from '../command';
2
- import { Hook, Hooks, PJSON, Topic } from '../interfaces';
2
+ import { Hook, Hooks, OclifConfiguration, PJSON, S3Templates, Topic, UserPJSON } from '../interfaces';
3
3
  import { ArchTypes, Config as IConfig, LoadOptions, PlatformTypes, VersionDetails } from '../interfaces/config';
4
4
  import { Plugin as IPlugin, Options } from '../interfaces/plugin';
5
5
  import { Theme } from '../interfaces/theme';
@@ -7,8 +7,8 @@ export declare class Config implements IConfig {
7
7
  options: Options;
8
8
  arch: ArchTypes;
9
9
  bin: string;
10
- binAliases?: string[];
11
- binPath?: string;
10
+ binAliases?: string[] | undefined;
11
+ binPath?: string | undefined;
12
12
  cacheDir: string;
13
13
  channel: string;
14
14
  configDir: string;
@@ -18,18 +18,18 @@ export declare class Config implements IConfig {
18
18
  home: string;
19
19
  isSingleCommandCLI: boolean;
20
20
  name: string;
21
- npmRegistry?: string;
22
- nsisCustomization?: string;
23
- pjson: PJSON.CLI;
21
+ npmRegistry?: string | undefined;
22
+ nsisCustomization?: string | undefined;
23
+ pjson: PJSON;
24
24
  platform: PlatformTypes;
25
25
  plugins: Map<string, IPlugin>;
26
26
  root: string;
27
27
  shell: string;
28
- theme?: Theme;
28
+ theme?: Theme | undefined;
29
29
  topicSeparator: ' ' | ':';
30
- updateConfig: NonNullable<PJSON.CLI['oclif']['update']>;
30
+ updateConfig: NonNullable<OclifConfiguration['update']>;
31
31
  userAgent: string;
32
- userPJSON?: PJSON.User;
32
+ userPJSON?: UserPJSON | undefined;
33
33
  valid: boolean;
34
34
  version: string;
35
35
  protected warned: boolean;
@@ -96,7 +96,7 @@ export declare class Config implements IConfig {
96
96
  protected macosCacheDir(): string | undefined;
97
97
  runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable | null): Promise<T>;
98
98
  runHook<T extends keyof Hooks>(event: T, opts: Hooks[T]['options'], timeout?: number, captureErrors?: boolean): Promise<Hook.Result<Hooks[T]['return']>>;
99
- s3Key(type: keyof PJSON.S3.Templates, ext?: '.tar.gz' | '.tar.xz' | IConfig.s3Key.Options, options?: IConfig.s3Key.Options): string;
99
+ s3Key(type: keyof S3Templates, ext?: '.tar.gz' | '.tar.xz' | IConfig.s3Key.Options, options?: IConfig.s3Key.Options): string;
100
100
  s3Url(key: string): string;
101
101
  scopedEnvVar(k: string): string | undefined;
102
102
  /**
@@ -117,26 +117,6 @@ export declare class Config implements IConfig {
117
117
  protected windowsUserprofileHome(): string | undefined;
118
118
  protected _shell(): string;
119
119
  private buildS3Config;
120
- /**
121
- * This method is responsible for locating the correct plugin to use for a named command id
122
- * It searches the {Config} registered commands to match either the raw command id or the command alias
123
- * It is possible that more than one command will be found. This is due the ability of two distinct plugins to
124
- * create the same command or command alias.
125
- *
126
- * In the case of more than one found command, the function will select the command based on the order in which
127
- * the plugin is included in the package.json `oclif.plugins` list. The command that occurs first in the list
128
- * is selected as the command to run.
129
- *
130
- * Commands can also be present from either an install or a link. When a command is one of these and a core plugin
131
- * is present, this function defers to the core plugin.
132
- *
133
- * If there is not a core plugin command present, this function will return the first
134
- * plugin as discovered (will not change the order)
135
- *
136
- * @param commands commands to determine the priority of
137
- * @returns command instance {Command.Loadable} or undefined
138
- */
139
- private determinePriority;
140
120
  private getCmdLookupId;
141
121
  private getTopicLookupId;
142
122
  /**
@@ -39,10 +39,11 @@ const logger_1 = require("../logger");
39
39
  const module_loader_1 = require("../module-loader");
40
40
  const performance_1 = require("../performance");
41
41
  const settings_1 = require("../settings");
42
+ const determine_priority_1 = require("../util/determine-priority");
42
43
  const fs_1 = require("../util/fs");
43
44
  const os_1 = require("../util/os");
44
45
  const util_2 = require("../util/util");
45
- const ux_1 = __importDefault(require("../ux"));
46
+ const ux_1 = require("../ux");
46
47
  const theme_1 = require("../ux/theme");
47
48
  const plugin_loader_1 = __importDefault(require("./plugin-loader"));
48
49
  const ts_path_1 = require("./ts-path");
@@ -318,10 +319,9 @@ class Config {
318
319
  node: this.pjson.oclif.update?.node ?? {},
319
320
  s3: this.buildS3Config(),
320
321
  };
321
- this.isSingleCommandCLI = Boolean(this.pjson.oclif.default ||
322
- (typeof this.pjson.oclif.commands !== 'string' &&
323
- this.pjson.oclif.commands?.strategy === 'single' &&
324
- this.pjson.oclif.commands?.target));
322
+ this.isSingleCommandCLI = Boolean(typeof this.pjson.oclif.commands !== 'string' &&
323
+ this.pjson.oclif.commands?.strategy === 'single' &&
324
+ this.pjson.oclif.commands?.target);
325
325
  this.maybeAdjustDebugSetting();
326
326
  await this.loadPluginsAndCommands();
327
327
  debug('config done');
@@ -358,12 +358,17 @@ class Config {
358
358
  async loadTheme() {
359
359
  if (this.scopedEnvVarTrue('DISABLE_THEME'))
360
360
  return;
361
- const defaultThemeFile = this.pjson.oclif.theme
362
- ? (0, node_path_1.resolve)(this.root, this.pjson.oclif.theme)
363
- : this.pjson.oclif.theme;
364
361
  const userThemeFile = (0, node_path_1.resolve)(this.configDir, 'theme.json');
362
+ const getDefaultTheme = async () => {
363
+ if (!this.pjson.oclif.theme)
364
+ return;
365
+ if (typeof this.pjson.oclif.theme === 'string') {
366
+ return (0, fs_1.safeReadJson)((0, node_path_1.resolve)(this.root, this.pjson.oclif.theme));
367
+ }
368
+ return this.pjson.oclif.theme;
369
+ };
365
370
  const [defaultTheme, userTheme] = await Promise.all([
366
- defaultThemeFile ? await (0, fs_1.safeReadJson)(defaultThemeFile) : undefined,
371
+ await getDefaultTheme(),
367
372
  await (0, fs_1.safeReadJson)(userThemeFile),
368
373
  ]);
369
374
  // Merge the default theme with the user theme, giving the user theme precedence.
@@ -468,7 +473,7 @@ class Config {
468
473
  (0, errors_1.exit)(code);
469
474
  },
470
475
  log(message, ...args) {
471
- ux_1.default.stdout(message, ...args);
476
+ ux_1.ux.stdout(message, ...args);
472
477
  },
473
478
  warn(message) {
474
479
  (0, errors_1.warn)(message);
@@ -528,7 +533,7 @@ class Config {
528
533
  options = ext;
529
534
  else if (ext)
530
535
  options.ext = ext;
531
- const template = this.updateConfig.s3.templates[options.platform ? 'target' : 'vanilla'][type] ?? '';
536
+ const template = this.updateConfig.s3?.templates?.[options.platform ? 'target' : 'vanilla'][type] ?? '';
532
537
  return ejs.render(template, { ...this, ...options });
533
538
  }
534
539
  s3Url(key) {
@@ -618,58 +623,6 @@ class Config {
618
623
  templates,
619
624
  };
620
625
  }
621
- /**
622
- * This method is responsible for locating the correct plugin to use for a named command id
623
- * It searches the {Config} registered commands to match either the raw command id or the command alias
624
- * It is possible that more than one command will be found. This is due the ability of two distinct plugins to
625
- * create the same command or command alias.
626
- *
627
- * In the case of more than one found command, the function will select the command based on the order in which
628
- * the plugin is included in the package.json `oclif.plugins` list. The command that occurs first in the list
629
- * is selected as the command to run.
630
- *
631
- * Commands can also be present from either an install or a link. When a command is one of these and a core plugin
632
- * is present, this function defers to the core plugin.
633
- *
634
- * If there is not a core plugin command present, this function will return the first
635
- * plugin as discovered (will not change the order)
636
- *
637
- * @param commands commands to determine the priority of
638
- * @returns command instance {Command.Loadable} or undefined
639
- */
640
- determinePriority(commands) {
641
- const oclifPlugins = this.pjson.oclif?.plugins ?? [];
642
- const commandPlugins = commands.sort((a, b) => {
643
- const pluginAliasA = a.pluginAlias ?? 'A-Cannot-Find-This';
644
- const pluginAliasB = b.pluginAlias ?? 'B-Cannot-Find-This';
645
- const aIndex = oclifPlugins.indexOf(pluginAliasA);
646
- const bIndex = oclifPlugins.indexOf(pluginAliasB);
647
- // When both plugin types are 'core' plugins sort based on index
648
- if (a.pluginType === 'core' && b.pluginType === 'core') {
649
- // If b appears first in the pjson.plugins sort it first
650
- return aIndex - bIndex;
651
- }
652
- // if b is a core plugin and a is not sort b first
653
- if (b.pluginType === 'core' && a.pluginType !== 'core') {
654
- return 1;
655
- }
656
- // if a is a core plugin and b is not sort a first
657
- if (a.pluginType === 'core' && b.pluginType !== 'core') {
658
- return -1;
659
- }
660
- // if a is a jit plugin and b is not sort b first
661
- if (a.pluginType === 'jit' && b.pluginType !== 'jit') {
662
- return 1;
663
- }
664
- // if b is a jit plugin and a is not sort a first
665
- if (b.pluginType === 'jit' && a.pluginType !== 'jit') {
666
- return -1;
667
- }
668
- // neither plugin is core, so do not change the order
669
- return 0;
670
- });
671
- return commandPlugins[0];
672
- }
673
626
  getCmdLookupId(id) {
674
627
  if (this._commands.has(id))
675
628
  return id;
@@ -697,7 +650,7 @@ class Config {
697
650
  for (const plugin of plugins) {
698
651
  this.plugins.set(plugin.name, plugin);
699
652
  // Delete all commands from the legacy plugin so that we can re-add them.
700
- // This is necessary because this.determinePriority will pick the initial
653
+ // This is necessary because determinePriority will pick the initial
701
654
  // command that was added, which won't have been converted by PluginLegacy yet.
702
655
  for (const cmd of plugin.commands ?? []) {
703
656
  this._commands.delete(cmd.id);
@@ -718,7 +671,10 @@ class Config {
718
671
  for (const command of plugin.commands) {
719
672
  // set canonical command id
720
673
  if (this._commands.has(command.id)) {
721
- const prioritizedCommand = this.determinePriority([this._commands.get(command.id), command]);
674
+ const prioritizedCommand = (0, determine_priority_1.determinePriority)(this.pjson.oclif.plugins ?? [], [
675
+ this._commands.get(command.id),
676
+ command,
677
+ ]);
722
678
  this._commands.set(prioritizedCommand.id, prioritizedCommand);
723
679
  }
724
680
  else {
@@ -735,7 +691,10 @@ class Config {
735
691
  }
736
692
  const handleAlias = (alias, hidden = false) => {
737
693
  if (this._commands.has(alias)) {
738
- const prioritizedCommand = this.determinePriority([this._commands.get(alias), command]);
694
+ const prioritizedCommand = (0, determine_priority_1.determinePriority)(this.pjson.oclif.plugins ?? [], [
695
+ this._commands.get(alias),
696
+ command,
697
+ ]);
739
698
  this._commands.set(alias, { ...prioritizedCommand, id: alias });
740
699
  }
741
700
  else {
@@ -1,20 +1,20 @@
1
1
  import { PJSON } from '../interfaces';
2
2
  import { Plugin as IPlugin } from '../interfaces/plugin';
3
3
  type PluginLoaderOptions = {
4
- plugins?: IPlugin[] | PluginsMap;
4
+ plugins?: IPlugin[] | PluginsMap | undefined;
5
5
  root: string;
6
6
  };
7
7
  type LoadOpts = {
8
8
  dataDir: string;
9
- devPlugins?: boolean;
10
- force?: boolean;
9
+ devPlugins?: boolean | undefined;
10
+ force?: boolean | undefined;
11
11
  rootPlugin: IPlugin;
12
- userPlugins?: boolean;
12
+ userPlugins?: boolean | undefined;
13
13
  pluginAdditions?: {
14
14
  core?: string[];
15
15
  dev?: string[];
16
16
  path?: string;
17
- };
17
+ } | undefined;
18
18
  };
19
19
  type PluginsMap = Map<string, IPlugin>;
20
20
  export default class PluginLoader {
@@ -28,7 +28,7 @@ export default class PluginLoader {
28
28
  plugins: PluginsMap;
29
29
  }>;
30
30
  loadRoot({ pjson }: {
31
- pjson?: PJSON.Plugin;
31
+ pjson?: PJSON | undefined;
32
32
  }): Promise<IPlugin>;
33
33
  private loadCorePlugins;
34
34
  private loadDevPlugins;
@@ -1,34 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  const minimatch_1 = require("minimatch");
27
4
  const node_path_1 = require("node:path");
28
5
  const performance_1 = require("../performance");
29
6
  const fs_1 = require("../util/fs");
30
7
  const util_1 = require("../util/util");
31
- const Plugin = __importStar(require("./plugin"));
8
+ const plugin_1 = require("./plugin");
32
9
  const util_2 = require("./util");
33
10
  const debug = (0, util_2.makeDebug)();
34
11
  function findMatchingDependencies(dependencies, patterns) {
@@ -62,7 +39,7 @@ class PluginLoader {
62
39
  }
63
40
  else {
64
41
  const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, 'plugin.load#root');
65
- rootPlugin = new Plugin.Plugin({ isRoot: true, pjson, root: this.options.root });
42
+ rootPlugin = new plugin_1.Plugin({ isRoot: true, pjson, root: this.options.root });
66
43
  await rootPlugin.load();
67
44
  marker?.addDetails({
68
45
  commandCount: rootPlugin.commands.length,
@@ -154,7 +131,7 @@ class PluginLoader {
154
131
  if (this.plugins.has(name))
155
132
  return;
156
133
  const pluginMarker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, `plugin.load#${name}`);
157
- const instance = new Plugin.Plugin(opts);
134
+ const instance = new plugin_1.Plugin(opts);
158
135
  await instance.load();
159
136
  pluginMarker?.addDetails({
160
137
  commandCount: instance.commands.length,
@@ -19,10 +19,10 @@ export declare class Plugin implements IPlugin {
19
19
  manifest: Manifest;
20
20
  moduleType: 'commonjs' | 'module';
21
21
  name: string;
22
- parent: Plugin | undefined;
23
- pjson: PJSON.Plugin;
22
+ parent?: Plugin | undefined;
23
+ pjson: PJSON;
24
24
  root: string;
25
- tag?: string;
25
+ tag?: string | undefined;
26
26
  type: string;
27
27
  valid: boolean;
28
28
  version: string;
@@ -57,12 +57,9 @@ function processCommandIds(files) {
57
57
  return id === '' ? symbols_1.SINGLE_COMMAND_CLI_SYMBOL : id;
58
58
  });
59
59
  }
60
- function determineCommandDiscoveryOptions(commandDiscovery, defaultCmdId) {
60
+ function determineCommandDiscoveryOptions(commandDiscovery) {
61
61
  if (!commandDiscovery)
62
62
  return;
63
- if (typeof commandDiscovery === 'string' && defaultCmdId) {
64
- return { strategy: 'single', target: commandDiscovery };
65
- }
66
63
  if (typeof commandDiscovery === 'string') {
67
64
  return { globPatterns: GLOB_PATTERNS, strategy: 'pattern', target: commandDiscovery };
68
65
  }
@@ -202,7 +199,7 @@ class Plugin {
202
199
  k,
203
200
  (0, util_1.castArray)(v).map((v) => determineHookOptions(v)),
204
201
  ]));
205
- this.commandDiscoveryOpts = determineCommandDiscoveryOptions(this.pjson.oclif?.commands, this.pjson.oclif?.default);
202
+ this.commandDiscoveryOpts = determineCommandDiscoveryOptions(this.pjson.oclif?.commands);
206
203
  this._debug('command discovery options', this.commandDiscoveryOpts);
207
204
  this.manifest = await this._manifest();
208
205
  this.commands = Object.entries(this.manifest.commands)
@@ -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): Promise<string | undefined>;
9
+ export declare function tsPath(root: string, orig: string | undefined, plugin?: Plugin | undefined): Promise<string | undefined>;
@@ -3,15 +3,15 @@ import { OclifError, PrettyPrintableError } from '../../interfaces/errors';
3
3
  * properties specific to internal oclif error handling
4
4
  */
5
5
  export declare function addOclifExitCode(error: Record<string, any>, options?: {
6
- exit?: false | number;
6
+ exit?: false | number | undefined;
7
7
  }): OclifError;
8
8
  export declare class CLIError extends Error implements OclifError {
9
- code?: string;
9
+ code?: string | undefined;
10
10
  oclif: OclifError['oclif'];
11
- skipOclifErrorHandling?: boolean;
12
- suggestions?: string[];
11
+ skipOclifErrorHandling?: boolean | undefined;
12
+ suggestions?: string[] | undefined;
13
13
  constructor(error: Error | string, options?: {
14
- exit?: false | number;
14
+ exit?: false | number | undefined;
15
15
  } & PrettyPrintableError);
16
16
  get bang(): string | undefined;
17
17
  get stack(): string;
@@ -1,7 +1,7 @@
1
1
  import { PrettyPrintableError } from '../../interfaces/errors';
2
2
  type CLIErrorDisplayOptions = {
3
- bang?: string;
4
- name?: string;
3
+ bang?: string | undefined;
4
+ name?: string | undefined;
5
5
  };
6
6
  export declare function applyPrettyPrintOptions(error: Error, options: PrettyPrintableError): PrettyPrintableError;
7
7
  export default function prettyPrint(error: Error & PrettyPrintableError & CLIErrorDisplayOptions): string | undefined;
package/lib/flags.d.ts CHANGED
@@ -72,8 +72,8 @@ export declare function boolean<T = boolean>(options?: Partial<BooleanFlag<T>>):
72
72
  * - `max` option allows to set a maximum value.
73
73
  */
74
74
  export declare const integer: FlagDefinition<number, {
75
- max?: number | undefined;
76
- min?: number | undefined;
75
+ max?: number;
76
+ min?: number;
77
77
  }, {
78
78
  multiple: false;
79
79
  requiredOrDefaulted: false;
@@ -84,7 +84,7 @@ export declare const integer: FlagDefinition<number, {
84
84
  * - `exists` option allows you to throw an error if the directory does not exist.
85
85
  */
86
86
  export declare const directory: FlagDefinition<string, {
87
- exists?: boolean | undefined;
87
+ exists?: boolean;
88
88
  }, {
89
89
  multiple: false;
90
90
  requiredOrDefaulted: false;
@@ -95,7 +95,7 @@ export declare const directory: FlagDefinition<string, {
95
95
  * - `exists` option allows you to throw an error if the file does not exist.
96
96
  */
97
97
  export declare const file: FlagDefinition<string, {
98
- exists?: boolean | undefined;
98
+ exists?: boolean;
99
99
  }, {
100
100
  multiple: false;
101
101
  requiredOrDefaulted: false;
package/lib/flush.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flush = void 0;
4
- const errors_1 = require("./errors");
4
+ const error_1 = require("./errors/error");
5
5
  function timeout(p, ms) {
6
6
  function wait(ms, unref = false) {
7
7
  return new Promise((resolve) => {
@@ -10,7 +10,7 @@ function timeout(p, ms) {
10
10
  t.unref();
11
11
  });
12
12
  }
13
- return Promise.race([p, wait(ms, true).then(() => (0, errors_1.error)('timed out'))]);
13
+ return Promise.race([p, wait(ms, true).then(() => (0, error_1.error)('timed out'))]);
14
14
  }
15
15
  async function _flush() {
16
16
  const p = new Promise((resolve) => {