@oclif/core 5.1.0 → 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
@@ -1,4 +1,4 @@
1
- import * as Interfaces from '../interfaces';
1
+ import type * as Interfaces from '../interfaces';
2
2
  import { HelpFormatter } from './formatter';
3
3
  export default class RootHelp extends HelpFormatter {
4
4
  config: Interfaces.Config;
package/lib/help/root.js CHANGED
@@ -26,7 +26,7 @@ class RootHelp extends formatter_1.HelpFormatter {
26
26
  root() {
27
27
  let description = this.config.pjson.oclif.description || this.config.pjson.description || '';
28
28
  description = this.render(description);
29
- description = description.split('\n')[0];
29
+ description = description.split('\n', 1)[0];
30
30
  let output = (0, util_1.compact)([
31
31
  (0, theme_1.colorize)(this.config?.theme?.commandSummary, description),
32
32
  this.version(),
@@ -1,4 +1,4 @@
1
- import { Deprecation, Config as IConfig } from '../interfaces';
1
+ import { type Deprecation, type Config as IConfig } from '../interfaces';
2
2
  export declare function template(context: any): (t: string) => string;
3
3
  export declare function standardizeIDFromArgv(argv: string[], config: IConfig): string[];
4
4
  export declare function getHelpFlagAdditions(config: IConfig): string[];
package/lib/help/util.js CHANGED
@@ -66,7 +66,7 @@ function standardizeIDFromArgv(argv, config) {
66
66
  function getHelpFlagAdditions(config) {
67
67
  const helpFlags = ['--help'];
68
68
  const additionalHelpFlags = config.pjson.oclif.additionalHelpFlags ?? [];
69
- return [...new Set([...additionalHelpFlags, ...helpFlags]).values()];
69
+ return [...new Set([...additionalHelpFlags, ...helpFlags])];
70
70
  }
71
71
  function formatFlagDeprecationWarning(flag, opts) {
72
72
  let message = `The "${flag}" flag has been deprecated`;
package/lib/index.js CHANGED
@@ -83,6 +83,7 @@ Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function
83
83
  Object.defineProperty(exports, "Help", { enumerable: true, get: function () { return help_1.Help; } });
84
84
  Object.defineProperty(exports, "HelpBase", { enumerable: true, get: function () { return help_1.HelpBase; } });
85
85
  Object.defineProperty(exports, "loadHelpClass", { enumerable: true, get: function () { return help_1.loadHelpClass; } });
86
+ // eslint-disable-next-line @typescript-eslint/consistent-type-exports
86
87
  exports.Interfaces = __importStar(require("./interfaces"));
87
88
  var logger_1 = require("./logger");
88
89
  Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_1.getLogger; } });
@@ -1,4 +1,4 @@
1
- import { ArgInput } from './parser';
1
+ import { type ArgInput } from './parser';
2
2
  /**
3
3
  * Infer the args that are returned by Command.parse. This is useful for when you want to assign the args as a class property.
4
4
  *
@@ -1,9 +1,9 @@
1
- import { Command } from '../command';
2
- import { Hook, Hooks } from './hooks';
3
- import { OclifConfiguration, PJSON, S3Templates } from './pjson';
4
- import { Options, Plugin } from './plugin';
5
- import { Theme } from './theme';
6
- import { Topic } from './topic';
1
+ import { type Command } from '../command';
2
+ import { type Hook, type Hooks } from './hooks';
3
+ import { type OclifConfiguration, type PJSON, type S3Templates } from './pjson';
4
+ import { type Options, type Plugin } from './plugin';
5
+ import { type Theme } from './theme';
6
+ import { type Topic } from './topic';
7
7
  export type LoadOptions = Config | Options | string | undefined;
8
8
  export type PlatformTypes = 'wsl' | NodeJS.Platform;
9
9
  export type ArchTypes = 'arm' | 'arm64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x32' | 'x64' | 'x86';
@@ -130,10 +130,10 @@ export interface Config {
130
130
  }
131
131
  export declare namespace Config {
132
132
  namespace s3Key {
133
- interface Options {
133
+ type Options = {
134
134
  [key: string]: any;
135
135
  arch?: ArchTypes;
136
136
  platform?: PlatformTypes;
137
- }
137
+ };
138
138
  }
139
139
  }
@@ -1,12 +1,12 @@
1
1
  export type CommandError = Error & {
2
2
  exitCode?: number;
3
3
  };
4
- export interface OclifError {
4
+ export type OclifError = {
5
5
  oclif: {
6
6
  exit?: number | undefined;
7
7
  };
8
- }
9
- export interface PrettyPrintableError {
8
+ };
9
+ export type PrettyPrintableError = {
10
10
  /**
11
11
  * a unique error code for this error class
12
12
  */
@@ -24,4 +24,4 @@ export interface PrettyPrintableError {
24
24
  * a suggestion that may be useful or provide additional context
25
25
  */
26
26
  suggestions?: string[] | undefined;
27
- }
27
+ };
@@ -1,4 +1,4 @@
1
- import { FlagInput } from './parser';
1
+ import { type FlagInput } from './parser';
2
2
  /**
3
3
  * Infer the flags that are returned by Command.parse. This is useful for when you want to assign the flags as a class property.
4
4
  *
@@ -1,4 +1,4 @@
1
- export interface HelpOptions {
1
+ export type HelpOptions = {
2
2
  all?: boolean;
3
3
  /**
4
4
  * Use docopts as the usage. Defaults to true.
@@ -52,7 +52,7 @@ export interface HelpOptions {
52
52
  stripAnsi?: boolean;
53
53
  /**
54
54
  * Use USAGE, but some may want to use USAGE as used in gnu man pages. See help recommendations at
55
- * http://www.gnu.org/software/help2man/#--help-recommendations
55
+ * https://www.gnu.org/software/help2man/#--help-recommendations
56
56
  */
57
57
  usageHeader?: string;
58
- }
58
+ };
@@ -1,11 +1,11 @@
1
- import { Command } from '../command';
2
- import { Config } from './config';
3
- import { Input, OutputFlags } from './parser';
4
- import { Plugin } from './plugin';
5
- interface HookMeta {
1
+ import { type Command } from '../command';
2
+ import { type Config } from './config';
3
+ import { type Input, type OutputFlags } from './parser';
4
+ import { type Plugin } from './plugin';
5
+ type HookMeta = {
6
6
  options: Record<string, unknown>;
7
7
  return: any;
8
- }
8
+ };
9
9
  type Context = {
10
10
  debug(...args: any[]): void;
11
11
  error(message: Error | string, options?: {
@@ -16,7 +16,7 @@ type Context = {
16
16
  log(message?: any, ...args: any[]): void;
17
17
  warn(message: string): void;
18
18
  };
19
- export interface Hooks {
19
+ export type Hooks = {
20
20
  [event: string]: HookMeta;
21
21
  command_incomplete: {
22
22
  options: {
@@ -108,7 +108,7 @@ export interface Hooks {
108
108
  };
109
109
  return: void;
110
110
  };
111
- }
111
+ };
112
112
  export type Hook<T extends keyof P, P extends Hooks = Hooks> = (this: Hook.Context, options: P[T]['options'] & {
113
113
  config: Config;
114
114
  context: Context;
@@ -160,7 +160,7 @@ export declare namespace Hook {
160
160
  * Runs when a command from an uninstalled JIT plugins is run.
161
161
  */
162
162
  type JitPluginNotInstalled = Hook<'jit_plugin_not_installed'>;
163
- interface Context {
163
+ type Context = {
164
164
  config: Config;
165
165
  debug(...args: any[]): void;
166
166
  error(message: Error | string, options?: {
@@ -170,8 +170,8 @@ export declare namespace Hook {
170
170
  exit(code?: number): void;
171
171
  log(message?: any, ...args: any[]): void;
172
172
  warn(message: string): void;
173
- }
174
- interface Result<T> {
173
+ };
174
+ type Result<T> = {
175
175
  failures: Array<{
176
176
  error: Error;
177
177
  plugin: Plugin;
@@ -180,6 +180,6 @@ export declare namespace Hook {
180
180
  plugin: Plugin;
181
181
  result: T;
182
182
  }>;
183
- }
183
+ };
184
184
  }
185
185
  export {};
@@ -1,7 +1,5 @@
1
- import { Command } from '../command';
1
+ import { type Command } from '../command';
2
2
  export type Manifest = {
3
- commands: {
4
- [id: string]: Command.Cached;
5
- };
3
+ commands: Record<string, Command.Cached>;
6
4
  version: string;
7
5
  };
@@ -1,12 +1,8 @@
1
- import { Command } from '../command';
2
- import { Validation } from '../parser/errors';
3
- import { AlphabetLowercase, AlphabetUppercase } from './alphabet';
4
- export type FlagOutput = {
5
- [name: string]: any;
6
- };
7
- export type ArgOutput = {
8
- [name: string]: any;
9
- };
1
+ import { type Command } from '../command';
2
+ import { type Validation } from '../parser/errors';
3
+ import { type AlphabetLowercase, type AlphabetUppercase } from './alphabet';
4
+ export type FlagOutput = Record<string, any>;
5
+ export type ArgOutput = Record<string, any>;
10
6
  export type CLIParseErrorOptions = {
11
7
  parse: {
12
8
  input?: ParserInput | undefined;
@@ -45,9 +41,7 @@ export type FlagUsageOptions = {
45
41
  displayRequired?: boolean;
46
42
  };
47
43
  export type Metadata = {
48
- flags: {
49
- [key: string]: MetadataFlag;
50
- };
44
+ flags: Record<string, MetadataFlag>;
51
45
  };
52
46
  export type MetadataFlag = {
53
47
  setFromDefault?: boolean;
@@ -162,7 +156,7 @@ export type FlagProps = {
162
156
  /**
163
157
  * Alternate short chars that can be used for this flag.
164
158
  */
165
- charAliases?: (AlphabetLowercase | AlphabetUppercase)[];
159
+ charAliases?: Array<AlphabetLowercase | AlphabetUppercase>;
166
160
  /**
167
161
  * Emit deprecation warning when a flag alias is provided
168
162
  */
@@ -298,7 +292,7 @@ type ReturnTypeSwitches = {
298
292
  * - It's possible that T extends an Array, if so we want to return T so that the return isn't T[][]
299
293
  * - If requiredOrDefaulted is false && multiple is false, then the return type is T | undefined
300
294
  */
301
- type FlagReturnType<T, R extends ReturnTypeSwitches> = R['requiredOrDefaulted'] extends true ? R['multiple'] extends true ? [T] extends [Array<unknown>] ? T : T[] : T : R['multiple'] extends true ? [T] extends [Array<unknown>] ? T | undefined : T[] | undefined : T | undefined;
295
+ type FlagReturnType<T, R extends ReturnTypeSwitches> = R['requiredOrDefaulted'] extends true ? R['multiple'] extends true ? [T] extends [unknown[]] ? T : T[] : T : R['multiple'] extends true ? [T] extends [unknown[]] ? T | undefined : T[] | undefined : T | undefined;
302
296
  /**
303
297
  * FlagDefinition types a function that takes `options` and returns an OptionFlag<T>.
304
298
  *
@@ -476,19 +470,13 @@ export type ParserInput = {
476
470
  export type ParserContext = Command & {
477
471
  token?: FlagToken | ArgToken | undefined;
478
472
  };
479
- export type FlagInput<T extends FlagOutput = {
480
- [flag: string]: any;
481
- }> = {
473
+ export type FlagInput<T extends FlagOutput = Record<string, any>> = {
482
474
  [P in keyof T]: Flag<T[P]>;
483
475
  };
484
- export type ArgInput<T extends ArgOutput = {
485
- [arg: string]: any;
486
- }> = {
476
+ export type ArgInput<T extends ArgOutput = Record<string, any>> = {
487
477
  [P in keyof T]: Arg<T[P]>;
488
478
  };
489
- export type SingleFlagTester = {
490
- [key: string]: (val: any) => boolean;
491
- };
479
+ export type SingleFlagTester = Record<string, (val: any) => boolean>;
492
480
  export type MultiFlagTester = (flags: FlagOutput) => boolean;
493
481
  type SimpleFlagGroup = string;
494
482
  type ComplexFlagGroup = {
@@ -496,7 +484,7 @@ type ComplexFlagGroup = {
496
484
  flags: string[];
497
485
  };
498
486
  export type FlagGroup = SimpleFlagGroup | ComplexFlagGroup;
499
- export interface Constraint {
487
+ export type Constraint = {
500
488
  _evaluateAgainstFlags(flags: FlagOutput): Validation;
501
489
  allFlagCriteriaSatisfied(criterionTester: SingleFlagTester): Constraint;
502
490
  and: Constraint;
@@ -516,5 +504,5 @@ export interface Constraint {
516
504
  thisIsTrue(flagTester: MultiFlagTester): Constraint;
517
505
  unless: Constraint;
518
506
  when: Constraint;
519
- }
507
+ };
520
508
  export {};
@@ -1,5 +1,5 @@
1
- import { HelpOptions } from './help';
2
- import { Theme } from './theme';
1
+ import { type HelpOptions } from './help';
2
+ import { type Theme } from './theme';
3
3
  export type CommandDiscovery = {
4
4
  /**
5
5
  * The strategy to use for loading commands.
@@ -177,9 +177,7 @@ export type OclifConfiguration = {
177
177
  /**
178
178
  * Register hooks to run at various points in the CLI lifecycle.
179
179
  */
180
- hooks?: {
181
- [name: string]: string | string[] | HookOptions | HookOptions[] | (string | HookOptions)[];
182
- };
180
+ hooks?: Record<string, string | string[] | HookOptions | HookOptions[] | Array<string | HookOptions>>;
183
181
  /**
184
182
  * Plugins that can be installed just-in-time.
185
183
  */
@@ -235,13 +233,11 @@ export type OclifConfiguration = {
235
233
  /**
236
234
  * Customize the topics in the CLI.
237
235
  */
238
- topics?: {
239
- [k: string]: {
240
- description?: string;
241
- hidden?: boolean;
242
- subtopics?: OclifConfiguration['topics'];
243
- };
244
- };
236
+ topics?: Record<string, {
237
+ description?: string;
238
+ hidden?: boolean;
239
+ subtopics?: OclifConfiguration['topics'];
240
+ }>;
245
241
  /**
246
242
  * Tar flags configuration for different platforms.
247
243
  *
@@ -253,9 +249,7 @@ export type OclifConfiguration = {
253
249
  * }
254
250
  *
255
251
  */
256
- tarFlags?: {
257
- [platform: string]: string;
258
- };
252
+ tarFlags?: Record<string, string>;
259
253
  update?: {
260
254
  autoupdate?: {
261
255
  debounce?: number;
@@ -296,18 +290,14 @@ export type LinkedPlugin = {
296
290
  };
297
291
  export type UserPJSON = {
298
292
  oclif: {
299
- plugins?: (UserPlugin | LinkedPlugin)[];
293
+ plugins?: Array<UserPlugin | LinkedPlugin>;
300
294
  };
301
295
  private?: boolean;
302
296
  };
303
297
  export type PJSON = {
304
298
  [k: string]: any;
305
- dependencies?: {
306
- [name: string]: string;
307
- };
308
- devDependencies?: {
309
- [name: string]: string;
310
- };
299
+ dependencies?: Record<string, string>;
300
+ devDependencies?: Record<string, string>;
311
301
  name: string;
312
302
  oclif: OclifConfiguration;
313
303
  version: string;
@@ -1,8 +1,8 @@
1
- import { Command } from '../command';
2
- import { Logger } from './logger';
3
- import { HookOptions, PJSON } from './pjson';
4
- import { Topic } from './topic';
5
- export interface PluginOptions {
1
+ import { type Command } from '../command';
2
+ import { type Logger } from './logger';
3
+ import { type HookOptions, type PJSON } from './pjson';
4
+ import { type Topic } from './topic';
5
+ export type PluginOptions = {
6
6
  children?: Plugin[] | undefined;
7
7
  errorOnManifestCreate?: boolean | undefined;
8
8
  flexibleTaxonomy?: boolean | undefined;
@@ -16,8 +16,8 @@ export interface PluginOptions {
16
16
  tag?: string | undefined;
17
17
  type?: string | undefined;
18
18
  url?: string | undefined;
19
- }
20
- export interface Options extends PluginOptions {
19
+ };
20
+ export type Options = {
21
21
  channel?: string | undefined;
22
22
  devPlugins?: boolean | undefined;
23
23
  enablePerf?: boolean | undefined;
@@ -32,8 +32,8 @@ export interface Options extends PluginOptions {
32
32
  plugins?: Map<string, Plugin> | undefined;
33
33
  userPlugins?: boolean | undefined;
34
34
  version?: string | undefined;
35
- }
36
- export interface Plugin {
35
+ } & PluginOptions;
36
+ export type Plugin = {
37
37
  /**
38
38
  * ../config version
39
39
  */
@@ -52,9 +52,7 @@ export interface Plugin {
52
52
  must: boolean;
53
53
  }): Promise<Command.Class> | undefined;
54
54
  readonly hasManifest: boolean;
55
- hooks: {
56
- [key: string]: HookOptions[];
57
- };
55
+ hooks: Record<string, HookOptions[]>;
58
56
  /**
59
57
  * True if the plugin is the root plugin.
60
58
  */
@@ -101,4 +99,4 @@ export interface Plugin {
101
99
  * example: 1.2.3
102
100
  */
103
101
  version: string;
104
- }
102
+ };
@@ -1,4 +1,4 @@
1
- export interface S3Manifest {
1
+ export type S3Manifest = {
2
2
  baseDir: string;
3
3
  gz: string;
4
4
  node: {
@@ -11,4 +11,4 @@ export interface S3Manifest {
11
11
  sha256xz?: string;
12
12
  version: string;
13
13
  xz?: string;
14
- }
14
+ };
@@ -1,5 +1,5 @@
1
- export interface Topic {
1
+ export type Topic = {
2
2
  description?: string | undefined;
3
3
  hidden?: boolean | undefined;
4
4
  name: string;
5
- }
5
+ };
@@ -1,4 +1,4 @@
1
- export interface TSConfig {
1
+ export type TSConfig = {
2
2
  compilerOptions: {
3
3
  baseUrl?: string;
4
4
  emitDecoratorMetadata?: boolean;
@@ -20,4 +20,4 @@ export interface TSConfig {
20
20
  scope?: boolean;
21
21
  swc?: boolean;
22
22
  };
23
- }
23
+ };
package/lib/logger.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { LoadOptions } from './interfaces/config';
2
- import { Logger } from './interfaces/logger';
1
+ import { type LoadOptions } from './interfaces/config';
2
+ import { type Logger } from './interfaces/logger';
3
3
  /**
4
4
  * Returns a logger instance for the given namespace.
5
5
  * If a namespace is provided, a child logger is returned.
package/lib/logger.js CHANGED
@@ -14,7 +14,9 @@ function makeLogger(namespace = OCLIF_NS) {
14
14
  return {
15
15
  child: (ns, delimiter) => makeLogger(`${namespace}${delimiter ?? ':'}${ns}`),
16
16
  debug,
17
- error: (formatter, ...args) => makeLogger(`${namespace}:error`).debug(formatter, ...args),
17
+ error(formatter, ...args) {
18
+ makeLogger(`${namespace}:error`).debug(formatter, ...args);
19
+ },
18
20
  info: debug,
19
21
  namespace,
20
22
  trace: debug,
@@ -74,7 +76,9 @@ function set(newLogger) {
74
76
  * Convenience function to create a debug function for a specific namespace
75
77
  */
76
78
  function makeDebug(namespace) {
77
- return (formatter, ...args) => getLogger(namespace).debug(formatter, ...args);
79
+ return (formatter, ...args) => {
80
+ getLogger(namespace).debug(formatter, ...args);
81
+ };
78
82
  }
79
83
  function setLogger(loadOptions) {
80
84
  if (loadOptions && typeof loadOptions !== 'string' && 'logger' in loadOptions && loadOptions.logger) {
package/lib/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as Interfaces from './interfaces';
1
+ import type * as Interfaces from './interfaces';
2
2
  export declare const helpAddition: (argv: string[], config: Interfaces.Config) => boolean;
3
3
  export declare const versionAddition: (argv: string[], config?: Interfaces.Config) => boolean;
4
4
  export declare function run(argv?: string[], options?: Interfaces.LoadOptions): Promise<unknown>;
package/lib/main.js CHANGED
@@ -28,10 +28,8 @@ const helpAddition = (argv, config) => {
28
28
  exports.helpAddition = helpAddition;
29
29
  const versionAddition = (argv, config) => {
30
30
  const additionalVersionFlags = config?.pjson.oclif.additionalVersionFlags ?? [];
31
- const mergedVersionFlags = [...new Set(['--version', ...additionalVersionFlags]).values()];
32
- if (mergedVersionFlags.includes(argv[0]))
33
- return true;
34
- return false;
31
+ const mergedVersionFlags = [...new Set(['--version', ...additionalVersionFlags])];
32
+ return Boolean(mergedVersionFlags.includes(argv[0]));
35
33
  };
36
34
  exports.versionAddition = versionAddition;
37
35
  async function run(argv, options) {
@@ -47,7 +45,7 @@ async function run(argv, options) {
47
45
  debug(`process.execPath: ${process.execPath}`);
48
46
  debug(`process.execArgv: ${process.execArgv}`);
49
47
  debug('process.argv: %O', process.argv);
50
- argv = argv ?? process.argv.slice(2);
48
+ argv ??= process.argv.slice(2);
51
49
  // Handle the case when a file URL string or URL is passed in such as 'import.meta.url'; covert to file path.
52
50
  if (options && ((typeof options === 'string' && options.startsWith('file://')) || options instanceof node_url_1.URL)) {
53
51
  options = (0, node_url_1.fileURLToPath)(options);
@@ -1,5 +1,5 @@
1
- import { Command } from './command';
2
- import { Config as IConfig, Plugin as IPlugin } from './interfaces';
1
+ import { type Command } from './command';
2
+ import { type Config as IConfig, type Plugin as IPlugin } from './interfaces';
3
3
  /**
4
4
  * Loads and returns a module.
5
5
  *
@@ -4,6 +4,7 @@ exports.load = load;
4
4
  exports.loadWithData = loadWithData;
5
5
  exports.loadWithDataFromManifest = loadWithDataFromManifest;
6
6
  exports.isPathModule = isPathModule;
7
+ /* eslint-disable import-x/newline-after-import, import-x/first -- these rules cause circular fix problems */
7
8
  const getPackageType = require('get-package-type');
8
9
  const node_fs_1 = require("node:fs");
9
10
  const node_path_1 = require("node:path");
@@ -161,19 +162,19 @@ async function resolvePath(config, modulePath) {
161
162
  filePath =
162
163
  (isPlugin(config) ? await (0, ts_path_1.tsPath)(config.root, modulePath, config) : await (0, ts_path_1.tsPath)(config.root, modulePath)) ??
163
164
  modulePath;
164
- let fileExists = false;
165
+ let isFileExists = false;
165
166
  let isDirectory = false;
166
167
  if ((0, fs_1.existsSync)(filePath)) {
167
- fileExists = true;
168
+ isFileExists = true;
168
169
  try {
169
170
  if ((0, node_fs_1.lstatSync)(filePath)?.isDirectory?.()) {
170
- fileExists = false;
171
+ isFileExists = false;
171
172
  isDirectory = true;
172
173
  }
173
174
  }
174
175
  catch { }
175
176
  }
176
- if (!fileExists) {
177
+ if (!isFileExists) {
177
178
  // Try all supported extensions.
178
179
  let foundPath = findFile(filePath);
179
180
  if (!foundPath && isDirectory) {
@@ -202,5 +203,5 @@ function findFile(filePath) {
202
203
  return testPath;
203
204
  }
204
205
  }
205
- return null;
206
+ return undefined;
206
207
  }
@@ -1,5 +1,5 @@
1
1
  import { CLIError } from '../errors';
2
- import { Arg, ArgInput, CLIParseErrorOptions, OptionFlag } from '../interfaces/parser';
2
+ import { type Arg, type ArgInput, type CLIParseErrorOptions, type OptionFlag } from '../interfaces/parser';
3
3
  export { CLIError } from '../errors';
4
4
  export type Validation = {
5
5
  name: string;
@@ -22,9 +22,9 @@ export declare class InvalidArgsSpecError extends CLIParseError {
22
22
  });
23
23
  }
24
24
  export declare class RequiredArgsError extends CLIParseError {
25
- args: Arg<any>[];
25
+ args: Array<Arg<any>>;
26
26
  constructor({ args, exit, flagsWithMultiple, parse, }: CLIParseErrorOptions & {
27
- args: Arg<any>[];
27
+ args: Array<Arg<any>>;
28
28
  flagsWithMultiple?: string[];
29
29
  });
30
30
  }
@@ -1,3 +1,3 @@
1
- import { Flag, FlagUsageOptions } from '../interfaces/parser';
1
+ import { type Flag, type FlagUsageOptions } from '../interfaces/parser';
2
2
  export declare function flagUsage(flag: Flag<any>, options?: FlagUsageOptions): [string, string | undefined];
3
- export declare function flagUsages(flags: Flag<any>[], options?: FlagUsageOptions): [string, string | undefined][];
3
+ export declare function flagUsages(flags: Array<Flag<any>>, options?: FlagUsageOptions): Array<[string, string | undefined]>;
@@ -1,4 +1,4 @@
1
- import { OutputArgs, OutputFlags, ParserInput, ParserOutput } from '../interfaces/parser';
1
+ import { type OutputArgs, type OutputFlags, type ParserInput, type ParserOutput } from '../interfaces/parser';
2
2
  declare global {
3
3
  /**
4
4
  * Cache the stdin so that it can be read multiple times.
@@ -13,7 +13,7 @@ declare global {
13
13
  stdinCache?: string;
14
14
  };
15
15
  }
16
- export declare const readStdin: () => Promise<null | string>;
16
+ export declare const readStdin: () => Promise<undefined | string>;
17
17
  export declare class Parser<T extends ParserInput, TFlags extends OutputFlags<T['flags']>, BFlags extends OutputFlags<T['flags']>, TArgs extends OutputArgs<T['args']>> {
18
18
  private readonly input;
19
19
  private readonly argv;