@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
@@ -33,7 +33,7 @@ const readStdin = async () => {
33
33
  // This means that reading from stdin could hang indefinitely while waiting for a non-existent pipe.
34
34
  // Because of this, we have to set a timeout to prevent the process from hanging.
35
35
  if (stdin.isTTY)
36
- return null;
36
+ return undefined;
37
37
  if (globalThis.oclif?.stdinCache) {
38
38
  debug('resolved stdin from global cache', globalThis.oclif.stdinCache);
39
39
  return globalThis.oclif.stdinCache;
@@ -42,7 +42,7 @@ const readStdin = async () => {
42
42
  const lines = [];
43
43
  const ac = new AbortController();
44
44
  const { signal } = ac;
45
- const timeout = setTimeout(() => ac.abort(), 10);
45
+ const timeout = setTimeout(() => { ac.abort(); }, Number(process.env.OCLIF_STDIN_TIMEOUT_MS) || 10);
46
46
  const rl = (0, node_readline_1.createInterface)({
47
47
  input: stdin,
48
48
  output: stdout,
@@ -62,7 +62,7 @@ const readStdin = async () => {
62
62
  debug('stdin aborted');
63
63
  clearTimeout(timeout);
64
64
  rl.close();
65
- resolve(null);
65
+ resolve(undefined);
66
66
  }, { once: true });
67
67
  });
68
68
  };
@@ -105,11 +105,11 @@ class Parser {
105
105
  if (i !== -1) {
106
106
  const sliced = arg.slice(i + 1);
107
107
  this.argv.unshift(sliced);
108
- const equalsParsed = await parseFlag(arg.slice(0, i));
109
- if (!equalsParsed) {
108
+ const isEqualsParsed = await parseFlag(arg.slice(0, i));
109
+ if (!isEqualsParsed) {
110
110
  this.argv.shift();
111
111
  }
112
- return equalsParsed;
112
+ return isEqualsParsed;
113
113
  }
114
114
  return false;
115
115
  }
@@ -147,23 +147,23 @@ class Parser {
147
147
  }
148
148
  return true;
149
149
  };
150
- let parsingFlags = true;
150
+ let isParsingFlags = true;
151
151
  const nonExistentFlags = [];
152
- let dashdash = false;
152
+ let isDashdash = false;
153
153
  const originalArgv = [...this.argv];
154
154
  while (this.argv.length > 0) {
155
155
  const input = this.argv.shift();
156
- if (parsingFlags && input.startsWith('-') && input !== '-') {
156
+ if (isParsingFlags && input.startsWith('-') && input !== '-') {
157
157
  // attempt to parse as arg
158
158
  if (this.input['--'] !== false && input === '--') {
159
- parsingFlags = false;
159
+ isParsingFlags = false;
160
160
  continue;
161
161
  }
162
162
  if (await parseFlag(input)) {
163
163
  continue;
164
164
  }
165
165
  if (input === '--') {
166
- dashdash = true;
166
+ isDashdash = true;
167
167
  continue;
168
168
  }
169
169
  if (this.input['--'] !== false && !isNegativeNumber(input)) {
@@ -175,7 +175,7 @@ class Parser {
175
175
  continue;
176
176
  }
177
177
  }
178
- if (parsingFlags && this.currentFlag && this.currentFlag.multiple && !this.currentFlag.multipleNonGreedy) {
178
+ if (isParsingFlags && this.currentFlag && this.currentFlag.multiple && !this.currentFlag.multipleNonGreedy) {
179
179
  this.raw.push({ flag: this.currentFlag.name, input, type: 'flag' });
180
180
  continue;
181
181
  }
@@ -185,7 +185,7 @@ class Parser {
185
185
  }
186
186
  const [{ args, argv }, { flags, metadata }] = await Promise.all([this._args(), this._flags()]);
187
187
  this._debugOutput(argv, args, flags);
188
- const unsortedArgv = (dashdash ? [...argv, ...nonExistentFlags, '--'] : [...argv, ...nonExistentFlags]);
188
+ const unsortedArgv = (isDashdash ? [...argv, ...nonExistentFlags, '--'] : [...argv, ...nonExistentFlags]);
189
189
  return {
190
190
  args: args,
191
191
  argv: unsortedArgv.sort((a, b) => originalArgv.indexOf(a) - originalArgv.indexOf(b)),
@@ -199,7 +199,7 @@ class Parser {
199
199
  const argv = [];
200
200
  const args = {};
201
201
  const tokens = this._argTokens;
202
- let stdinRead = false;
202
+ let isStdinRead = false;
203
203
  const ctx = this.context;
204
204
  const parseArgInput = async (name, arg, input) => {
205
205
  if (arg.options && !arg.options.includes(input)) {
@@ -226,10 +226,10 @@ class Parser {
226
226
  args[name] = value;
227
227
  };
228
228
  const tryStdin = async (name, arg) => {
229
- if (arg.ignoreStdin || stdinRead)
229
+ if (arg.ignoreStdin || isStdinRead)
230
230
  return;
231
231
  let stdin = await (0, exports.readStdin)();
232
- stdinRead = true;
232
+ isStdinRead = true;
233
233
  if (!stdin)
234
234
  return;
235
235
  stdin = stdin.trim();
@@ -365,7 +365,7 @@ class Parser {
365
365
  // multiple with custom delimiter
366
366
  if (fws.inputFlag.flag.type === 'option' && fws.inputFlag.flag.delimiter && fws.inputFlag.flag.multiple) {
367
367
  // regex that will identify unescaped delimiters
368
- const makeDelimiter = (delimiter) => new RegExp(`(?<!\\\\)${delimiter}`);
368
+ const makeDelimiter = (delimiter) => new RegExp(String.raw `(?<!\\)${delimiter}`);
369
369
  return {
370
370
  ...fws,
371
371
  valueFunction: async (i) => (await Promise.all((i.tokens ?? [])
@@ -388,7 +388,7 @@ class Parser {
388
388
  if (fws.inputFlag.flag.type === 'option' && fws.inputFlag.flag.multiple) {
389
389
  return {
390
390
  ...fws,
391
- valueFunction: async (i) => Promise.all((fws.tokens ?? []).map((token) => parseFlagOrThrowError(validateOptions(i.inputFlag.flag, token.input), i.inputFlag.flag, this.context, token))),
391
+ valueFunction: async (i) => Promise.all((fws.tokens ?? []).map(async (token) => parseFlagOrThrowError(validateOptions(i.inputFlag.flag, token.input), i.inputFlag.flag, this.context, token))),
392
392
  };
393
393
  }
394
394
  // simple option flag
@@ -492,17 +492,17 @@ class Parser {
492
492
  };
493
493
  }
494
494
  _setNames() {
495
- for (const k of Object.keys(this.input.flags)) {
496
- this.input.flags[k].name = k;
495
+ for (const [k, value] of Object.entries(this.input.flags)) {
496
+ value.name = k;
497
497
  }
498
- for (const k of Object.keys(this.input.args)) {
499
- this.input.args[k].name = k;
498
+ for (const [k, value] of Object.entries(this.input.args)) {
499
+ value.name = k;
500
500
  }
501
501
  }
502
502
  findFlag(arg) {
503
503
  const isLong = arg.startsWith('--');
504
- const short = isLong ? false : arg.startsWith('-');
505
- const name = isLong ? this.findLongFlag(arg) : short ? this.findShortFlag(arg) : undefined;
504
+ const isShort = isLong ? false : arg.startsWith('-');
505
+ const name = isLong ? this.findLongFlag(arg) : isShort ? this.findShortFlag(arg) : undefined;
506
506
  return { isLong, name };
507
507
  }
508
508
  findLongFlag(arg) {
@@ -1,4 +1,4 @@
1
- import { ParserInput, ParserOutput } from '../interfaces/parser';
1
+ import { type ParserInput, type ParserOutput } from '../interfaces/parser';
2
2
  export declare function validate(parse: {
3
3
  input: ParserInput;
4
4
  output: ParserOutput;
@@ -40,7 +40,7 @@ async function validate(parse) {
40
40
  }
41
41
  }
42
42
  }
43
- const variadicArgFound = variadicIndex !== -1;
43
+ const isVariadicArgFound = variadicIndex !== -1;
44
44
  if (parse.output.nonExistentFlags?.length > 0) {
45
45
  throw new errors_1.NonExistentFlagsError({
46
46
  flags: parse.output.nonExistentFlags,
@@ -62,7 +62,7 @@ async function validate(parse) {
62
62
  if (!arg.required) {
63
63
  hasOptional = true;
64
64
  }
65
- else if (hasOptional && !variadicArgFound) {
65
+ else if (hasOptional && !isVariadicArgFound) {
66
66
  // (required arg) check whether an optional has occurred before
67
67
  // optionals should follow required, not before
68
68
  // Skip this check when a variadic arg is present, since the variadic
@@ -119,15 +119,16 @@ async function validate(parse) {
119
119
  });
120
120
  }
121
121
  function validateConstraints() {
122
- if (parse.input.constraints) {
123
- const validations = parse.input.constraints.map((c) => c._evaluateAgainstFlags(parse.output.flags));
124
- const failed = validations.filter((v) => v.status === 'failed');
125
- if (failed.length > 0) {
126
- throw new errors_1.ViolatedFlagConstraintError({
127
- failed,
128
- parse,
129
- });
130
- }
122
+ if (!parse.input.constraints) {
123
+ return;
124
+ }
125
+ const validations = parse.input.constraints.map((c) => c._evaluateAgainstFlags(parse.output.flags));
126
+ const failed = validations.filter((v) => v.status === 'failed');
127
+ if (failed.length > 0) {
128
+ throw new errors_1.ViolatedFlagConstraintError({
129
+ failed,
130
+ parse,
131
+ });
131
132
  }
132
133
  }
133
134
  async function resolveFlags(flags) {
@@ -137,8 +138,8 @@ async function validate(parse) {
137
138
  if (typeof flag === 'string') {
138
139
  return [flag, parse.output.flags[flag]];
139
140
  }
140
- const result = await flag.when(parse.output.flags);
141
- return result ? [flag.name, parse.output.flags[flag.name]] : null;
141
+ const isResult = await flag.when(parse.output.flags);
142
+ return isResult ? [flag.name, parse.output.flags[flag.name]] : null;
142
143
  });
143
144
  const resolved = await Promise.all(promises);
144
145
  cachedResolvedFlags = Object.fromEntries(resolved.filter((r) => r !== null));
@@ -150,7 +151,7 @@ async function validate(parse) {
150
151
  const intersection = Object.entries(parse.input.flags)
151
152
  .map((entry) => entry[0]) // array of flag names
152
153
  .filter((flagName) => parse.output.flags[flagName] !== undefined) // with values
153
- .filter((flagName) => flag.exactlyOne && flag.exactlyOne.includes(flagName)); // and in the exactlyOne list
154
+ .filter((flagName) => flag.exactlyOne?.includes(flagName)); // and in the exactlyOne list
154
155
  if (intersection.length === 0) {
155
156
  // the command's exactlyOne may or may not include itself, so we'll use Set to add + de-dupe
156
157
  const deduped = (0, util_1.uniq)(flag.exactlyOne?.map((flag) => `--${flag}`) ?? []).join(', ');
@@ -164,7 +165,7 @@ async function validate(parse) {
164
165
  const intersection = Object.entries(parse.input.flags)
165
166
  .map((entry) => entry[0]) // array of flag names
166
167
  .filter((flagName) => parse.output.flags[flagName] !== undefined) // with values
167
- .filter((flagName) => flag.atLeastOne && flag.atLeastOne.includes(flagName)); // and in the atLeastOne list
168
+ .filter((flagName) => flag.atLeastOne?.includes(flagName)); // and in the atLeastOne list
168
169
  if (intersection.length === 0) {
169
170
  // the command's atLeastOne may or may not include itself, so we'll use Set to add + de-dupe
170
171
  const deduped = (0, util_1.uniq)(flag.atLeastOne?.map((flag) => `--${flag}`) ?? []).join(', ');
@@ -179,9 +180,9 @@ async function validate(parse) {
179
180
  const keys = getPresentFlags(resolved);
180
181
  for (const flag of keys) {
181
182
  // do not enforce exclusivity for flags that were defaulted
182
- if (parse.output.metadata.flags && parse.output.metadata.flags[flag]?.setFromDefault)
183
+ if (parse.output.metadata.flags?.[flag]?.setFromDefault)
183
184
  continue;
184
- if (parse.output.metadata.flags && parse.output.metadata.flags[name]?.setFromDefault)
185
+ if (parse.output.metadata.flags?.[name]?.setFromDefault)
185
186
  continue;
186
187
  if (parse.output.flags[flag] !== undefined) {
187
188
  const flagValue = parse.output.metadata.flags?.[flag]?.defaultHelp ?? parse.output.flags[flag];
@@ -200,9 +201,9 @@ async function validate(parse) {
200
201
  const resolved = await resolveFlags(flags);
201
202
  for (const flag of Object.keys(parse.output.flags)) {
202
203
  // do not enforce exclusivity for flags that were defaulted
203
- if (parse.output.metadata.flags && parse.output.metadata.flags[flag]?.setFromDefault)
204
+ if (parse.output.metadata.flags?.[flag]?.setFromDefault)
204
205
  continue;
205
- if (parse.output.metadata.flags && parse.output.metadata.flags[name]?.setFromDefault)
206
+ if (parse.output.metadata.flags?.[name]?.setFromDefault)
206
207
  continue;
207
208
  if (flag !== name && parse.output.flags[flag] !== undefined && !combinableFlags.has(flag)) {
208
209
  const formattedFlags = Object.keys(resolved)
@@ -231,8 +232,8 @@ async function validate(parse) {
231
232
  async function validateDependsOn(name, flags) {
232
233
  const base = { name, validationFn: 'validateDependsOn' };
233
234
  const resolved = await resolveFlags(flags);
234
- const foundAll = Object.values(resolved).every((val) => val !== undefined);
235
- if (!foundAll) {
235
+ const isFoundAll = Object.values(resolved).every((val) => val !== undefined);
236
+ if (!isFoundAll) {
236
237
  const formattedFlags = Object.keys(resolved)
237
238
  .map((f) => `--${f}`)
238
239
  .join(', ');
@@ -247,8 +248,8 @@ async function validate(parse) {
247
248
  async function validateSome(name, flags) {
248
249
  const base = { name, validationFn: 'validateSome' };
249
250
  const resolved = await resolveFlags(flags);
250
- const foundAtLeastOne = Object.values(resolved).some(Boolean);
251
- if (!foundAtLeastOne) {
251
+ const isFoundAtLeastOne = Object.values(resolved).some(Boolean);
252
+ if (!isFoundAtLeastOne) {
252
253
  const formattedFlags = Object.keys(resolved)
253
254
  .map((f) => `--${f}`)
254
255
  .join(', ');
@@ -261,7 +262,7 @@ async function validate(parse) {
261
262
  return { ...base, status: 'success' };
262
263
  }
263
264
  function validateRelationships(name, flag) {
264
- return (flag.relationships ?? []).map((relationship) => {
265
+ return (flag.relationships ?? []).map(async (relationship) => {
265
266
  switch (relationship.type) {
266
267
  case 'all': {
267
268
  return validateDependsOn(name, relationship.flags);
@@ -34,8 +34,8 @@ declare class Marker {
34
34
  module: string;
35
35
  scope: string;
36
36
  stopped: boolean;
37
- private startMarker;
38
- private stopMarker;
37
+ private readonly startMarker;
38
+ private readonly stopMarker;
39
39
  constructor(owner: string, name: string, details?: Details);
40
40
  addDetails(details: Details): void;
41
41
  measure(): void;
@@ -43,8 +43,8 @@ declare class Marker {
43
43
  }
44
44
  export declare class Performance {
45
45
  private static _oclifPerf;
46
- private static _results;
47
- private static markers;
46
+ private static readonly _results;
47
+ private static readonly markers;
48
48
  /**
49
49
  * Collect performance results into static Performance.results
50
50
  *
@@ -21,8 +21,8 @@ class Marker {
21
21
  this.details = details;
22
22
  this.startMarker = `${this.name}-start`;
23
23
  this.stopMarker = `${this.name}-stop`;
24
- const [caller, scope] = name.split('#');
25
- const [module, method] = caller.split('.');
24
+ const [caller, scope] = name.split('#', 2);
25
+ const [module, method] = caller.split('.', 2);
26
26
  this.module = module;
27
27
  this.method = method;
28
28
  this.scope = scope;
@@ -221,7 +221,7 @@ class Performance {
221
221
  static get results() {
222
222
  if (!Performance.enabled)
223
223
  return new Map();
224
- return new Map([...Performance._results.entries()].filter(([owner]) => owner !== exports.OCLIF_MARKER_OWNER));
224
+ return new Map([...Performance._results].filter(([owner]) => owner !== exports.OCLIF_MARKER_OWNER));
225
225
  }
226
226
  }
227
227
  exports.Performance = Performance;
@@ -1,2 +1,2 @@
1
- import { FlagInput, FlagOutput } from '../interfaces/parser';
1
+ import { type FlagInput, type FlagOutput } from '../interfaces/parser';
2
2
  export declare function aggregateFlags<F extends FlagOutput, B extends FlagOutput>(flags: FlagInput<F> | undefined, baseFlags: FlagInput<B> | undefined, enableJsonFlag: boolean | undefined): FlagInput<F>;
@@ -1,3 +1,3 @@
1
- import { Command } from '../command';
2
- import { Plugin as IPlugin } from '../interfaces/plugin';
1
+ import { type Command } from '../command';
2
+ import { type Plugin as IPlugin } from '../interfaces/plugin';
3
3
  export declare function cacheCommand(uncachedCmd: Command.Class, plugin?: IPlugin, respectNoCacheDefault?: boolean): Promise<Command.Cached>;
@@ -93,9 +93,9 @@ async function cacheCommand(uncachedCmd, plugin, respectNoCacheDefault = false)
93
93
  hidden: cmd.hidden,
94
94
  hiddenAliases: cmd.hiddenAliases ?? [],
95
95
  id: cmd.id,
96
- pluginAlias: plugin && plugin.alias,
97
- pluginName: plugin && plugin.name,
98
- pluginType: plugin && plugin.type,
96
+ pluginAlias: plugin?.alias,
97
+ pluginName: plugin?.name,
98
+ pluginType: plugin?.type,
99
99
  state: cmd.state,
100
100
  strict: cmd.strict,
101
101
  summary: cmd.summary,
@@ -1,2 +1,2 @@
1
- import { Arg, OptionFlag } from '../interfaces/parser';
1
+ import { type Arg, type OptionFlag } from '../interfaces/parser';
2
2
  export declare const cacheDefaultValue: (flagOrArg: Arg<any> | OptionFlag<any>, respectNoCacheDefault: boolean) => Promise<any>;
@@ -1,4 +1,4 @@
1
- import { Command } from '../command';
1
+ import { type Command } from '../command';
2
2
  /**
3
3
  * This function is responsible for locating the correct plugin to use for a named command id
4
4
  * It searches the {Config} registered commands to match either the raw command id or the command alias
@@ -1,5 +1,5 @@
1
- import { Command } from '../command';
2
- import { ArgInput } from '../interfaces/parser';
1
+ import { type Command } from '../command';
2
+ import { type ArgInput } from '../interfaces/parser';
3
3
  /**
4
4
  * Ensure that the provided args are an object. This is for backwards compatibility with v1 commands which
5
5
  * defined args as an array.
@@ -7,6 +7,4 @@ import { ArgInput } from '../interfaces/parser';
7
7
  * @param args Either an array of args or an object of args
8
8
  * @returns ArgInput
9
9
  */
10
- export declare function ensureArgObject(args?: {
11
- [name: string]: Command.Arg.Cached;
12
- } | ArgInput | any[]): ArgInput;
10
+ export declare function ensureArgObject(args?: Record<string, Command.Arg.Cached> | ArgInput | any[]): ArgInput;
@@ -9,5 +9,5 @@ exports.ensureArgObject = ensureArgObject;
9
9
  * @returns ArgInput
10
10
  */
11
11
  function ensureArgObject(args) {
12
- return (Array.isArray(args) ? (args ?? []).reduce((x, y) => ({ ...x, [y.name]: y }), {}) : args ?? {});
12
+ return (Array.isArray(args) ? (args ?? []).reduce((x, y) => ({ ...x, [y.name]: y }), {}) : (args ?? {}));
13
13
  }
@@ -6,7 +6,9 @@ const node_path_1 = require("node:path");
6
6
  const logger_1 = require("../logger");
7
7
  const fs_1 = require("./fs");
8
8
  function debug(...scope) {
9
- return (formatter, ...args) => (0, logger_1.getLogger)(['find-root', ...scope].join(':')).debug(formatter, ...args);
9
+ return (formatter, ...args) => {
10
+ (0, logger_1.getLogger)(['find-root', ...scope].join(':')).debug(formatter, ...args);
11
+ };
10
12
  }
11
13
  // essentially just "cd .."
12
14
  function* up(from) {
@@ -1,4 +1,4 @@
1
- import { PJSON } from '../interfaces';
1
+ import { type PJSON } from '../interfaces';
2
2
  /**
3
3
  * Read the package.json file from a given path and add the oclif config (found by lilconfig) if it exists.
4
4
  *
@@ -1,2 +1,2 @@
1
- import { TSConfig } from '../interfaces';
1
+ import { type TSConfig } from '../interfaces';
2
2
  export declare function readTSConfig(root: string, tsconfigName?: string): Promise<TSConfig | undefined>;
@@ -1,7 +1,5 @@
1
- export declare function pickBy<T extends {
2
- [s: string]: T[keyof T];
3
- } | ArrayLike<T[keyof T]>>(obj: T, fn: (i: T[keyof T]) => boolean): Partial<T>;
4
- export declare function compact<T>(a: (T | undefined)[]): T[];
1
+ export declare function pickBy<T extends Record<string, T[keyof T]> | ArrayLike<T[keyof T]>>(obj: T, fn: (i: T[keyof T]) => boolean): Partial<T>;
2
+ export declare function compact<T>(a: Array<T | undefined>): T[];
5
3
  export declare function uniqBy<T>(arr: T[], fn: (cur: T) => any): T[];
6
4
  export declare function last<T>(arr?: T[]): T | undefined;
7
5
  type SortTypes = boolean | number | string | undefined;
@@ -19,5 +17,5 @@ export declare function mapValues<T extends Record<string, any>, TResult>(obj: {
19
17
  }, fn: (i: T[keyof T], k: keyof T) => TResult): {
20
18
  [P in keyof T]: TResult;
21
19
  };
22
- export declare function mergeNestedObjects(objs: Record<string, any>[], path: string): Record<string, any>;
20
+ export declare function mergeNestedObjects(objs: Array<Record<string, any>>, path: string): Record<string, any>;
23
21
  export {};
package/lib/util/util.js CHANGED
@@ -28,7 +28,7 @@ function compact(a) {
28
28
  function uniqBy(arr, fn) {
29
29
  return arr.filter((a, i) => {
30
30
  const aVal = fn(a);
31
- return !arr.some((b, j) => j > i && fn(b) === aVal);
31
+ return arr.every((b, j) => !(j > i && fn(b) === aVal));
32
32
  });
33
33
  }
34
34
  function last(arr) {
@@ -1,4 +1,4 @@
1
- import { Options } from './types';
1
+ import { type Options } from './types';
2
2
  type Task = {
3
3
  action: string;
4
4
  active: boolean;
@@ -7,7 +7,7 @@ type Task = {
7
7
  export type ActionType = 'debug' | 'simple' | 'spinner';
8
8
  export declare class ActionBase {
9
9
  std: 'stderr' | 'stdout';
10
- protected stdmocks?: ['stderr' | 'stdout', string[]][];
10
+ protected stdmocks?: Array<['stderr' | 'stdout', string[]]>;
11
11
  type: ActionType;
12
12
  private stdmockOrigs;
13
13
  private get globals();
@@ -133,9 +133,9 @@ class ActionBase {
133
133
  }
134
134
  }
135
135
  }
136
- pause(fn, icon) {
136
+ async pause(fn, icon) {
137
137
  const { task } = this;
138
- const active = task && task.active;
138
+ const active = task?.active;
139
139
  if (task && active) {
140
140
  this._pause(icon);
141
141
  this._stdout(false);
@@ -149,7 +149,7 @@ class ActionBase {
149
149
  }
150
150
  async pauseAsync(fn, icon) {
151
151
  const { task } = this;
152
- const active = task && task.active;
152
+ const active = task?.active;
153
153
  if (task && active) {
154
154
  this._pause(icon);
155
155
  this._stdout(false);
@@ -163,7 +163,7 @@ class ActionBase {
163
163
  }
164
164
  start(action, status, opts = {}) {
165
165
  this.std = opts.stdout ? 'stdout' : 'stderr';
166
- const task = { action, active: Boolean(this.task && this.task.active), status };
166
+ const task = { action, active: Boolean(this.task?.active), status };
167
167
  this.task = task;
168
168
  this._start(opts);
169
169
  task.active = true;
@@ -1,4 +1,4 @@
1
- import { ActionBase, ActionType } from './base';
1
+ import { ActionBase, type ActionType } from './base';
2
2
  export default class SimpleAction extends ActionBase {
3
3
  type: ActionType;
4
4
  protected _pause(icon?: string): void;
@@ -1,5 +1,5 @@
1
- import { ActionBase, ActionType } from './base';
2
- import { Options } from './types';
1
+ import { ActionBase, type ActionType } from './base';
2
+ import { type Options } from './types';
3
3
  export default class SpinnerAction extends ActionBase {
4
4
  type: ActionType;
5
5
  private color;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* eslint-disable import-x/newline-after-import, import-x/first -- these rules cause circular fix problems */
6
7
  const ansiEscapes = require('ansi-escapes');
7
8
  const ansis_1 = __importDefault(require("ansis"));
8
9
  const cli_spinners_1 = __importDefault(require("cli-spinners"));
@@ -42,7 +43,9 @@ class SpinnerAction extends base_1.ActionBase {
42
43
  if (this.spinner)
43
44
  clearInterval(this.spinner);
44
45
  this._render();
45
- this.spinner = setInterval((icon) => this._render.bind(this)(icon), process.platform === 'win32' ? 500 : 100, 'spinner');
46
+ this.spinner = setInterval((icon) => {
47
+ this._render.bind(this)(icon);
48
+ }, process.platform === 'win32' ? 500 : 100, 'spinner');
46
49
  const interval = this.spinner;
47
50
  interval.unref();
48
51
  }
@@ -1,4 +1,4 @@
1
- import * as spinners from 'cli-spinners';
1
+ import type * as spinners from 'cli-spinners';
2
2
  export type Options = {
3
3
  stdout?: boolean;
4
4
  style?: spinners.SpinnerName | 'random';
@@ -37,7 +37,7 @@ function serializer(replacer, cycleReplacer) {
37
37
  // eslint-disable-next-line no-bitwise, @typescript-eslint/no-unused-expressions
38
38
  ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
39
39
  // eslint-disable-next-line no-bitwise, @typescript-eslint/no-unused-expressions
40
- ~thisPos ? keys.splice(thisPos, Number.POSITIVE_INFINITY, key) : keys.push(key);
40
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
41
41
  // @ts-expect-error because `this` is not typed
42
42
  if (stack.includes(value))
43
43
  value = cycleReplacer.call(this, key, value);
@@ -59,18 +59,18 @@ function stringifyInput(json, options) {
59
59
  function tokenize(json, options) {
60
60
  let input = stringifyInput(json, options);
61
61
  const tokens = [];
62
- let foundToken = false;
62
+ let isFoundToken = false;
63
63
  do {
64
64
  for (const tokenType of tokenTypes) {
65
65
  const match = tokenType.regex.exec(input);
66
66
  if (match) {
67
67
  tokens.push({ type: tokenType.tokenType, value: match[0] });
68
68
  input = input.slice(match[0].length);
69
- foundToken = true;
69
+ isFoundToken = true;
70
70
  break;
71
71
  }
72
72
  }
73
- } while (hasRemainingTokens(input, foundToken));
73
+ } while (hasRemainingTokens(input, isFoundToken));
74
74
  return tokens;
75
75
  }
76
76
  function hasRemainingTokens(input, foundToken) {
package/lib/ux/index.d.ts CHANGED
@@ -56,13 +56,13 @@ export declare const ux: {
56
56
  *
57
57
  * See node's util.format() for formatting options.
58
58
  */
59
- stderr: (str?: string | string[] | undefined, ...args: string[]) => void;
59
+ stderr: (str?: string | string[], ...args: string[]) => void;
60
60
  /**
61
61
  * Log a formatted string to stdout.
62
62
  *
63
63
  * See node's util.format() for formatting options.
64
64
  */
65
- stdout: (str?: string | string[] | undefined, ...args: string[]) => void;
65
+ stdout: (str?: string | string[], ...args: string[]) => void;
66
66
  /**
67
67
  * Prints a pretty warning message to stderr.
68
68
  */
package/lib/ux/list.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = renderList;
4
+ /* eslint-disable import-x/first -- these rules cause circular fix problems */
4
5
  const wordwrap = require('wordwrap');
5
6
  const screen_1 = require("../screen");
6
7
  const util_1 = require("../util/util");
package/lib/ux/theme.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StandardAnsi, Theme } from '../interfaces/theme';
1
+ import { type StandardAnsi, type Theme } from '../interfaces/theme';
2
2
  /**
3
3
  * Add color to text.
4
4
  * @param color color to use. Can be hex code (e.g. `#ff0000`), rgb (e.g. `rgb(255, 255, 255)`) or a standard ansi color (e.g. `red`)
package/lib/ux/write.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const stdout: (str?: string | string[] | undefined, ...args: string[]) => void;
2
- export declare const stderr: (str?: string | string[] | undefined, ...args: string[]) => void;
1
+ export declare const stdout: (str?: string | string[], ...args: string[]) => void;
2
+ export declare const stderr: (str?: string | string[], ...args: string[]) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "5.0.1",
4
+ "version": "5.1.1",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {