@oclif/core 1.20.4 → 1.21.0

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.
@@ -3,7 +3,7 @@ export interface ITask {
3
3
  status: string | undefined;
4
4
  active: boolean;
5
5
  }
6
- export declare type ActionType = 'spinner' | 'simple' | 'debug';
6
+ export type ActionType = 'spinner' | 'simple' | 'debug';
7
7
  export interface Options {
8
8
  stdout?: boolean;
9
9
  }
@@ -1,5 +1,5 @@
1
1
  import { ActionBase } from './action/base';
2
- export declare type Levels = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
2
+ export type Levels = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
3
3
  export interface ConfigMessage {
4
4
  type: 'config';
5
5
  prop: string;
@@ -1,3 +1,3 @@
1
- export declare type IListItem = [string, string | undefined];
2
- export declare type IList = IListItem[];
1
+ export type IListItem = [string, string | undefined];
2
+ export type IList = IListItem[];
3
3
  export declare function renderList(items: IListItem[]): string;
package/lib/command.js CHANGED
@@ -29,17 +29,6 @@ const jsonFlag = {
29
29
  * in your project.
30
30
  */
31
31
  class Command {
32
- constructor(argv, config) {
33
- this.argv = argv;
34
- this.config = config;
35
- this.id = this.ctor.id;
36
- try {
37
- this.debug = require('debug')(this.id ? `${this.config.bin}:${this.id}` : this.config.bin);
38
- }
39
- catch {
40
- this.debug = () => { };
41
- }
42
- }
43
32
  static get enableJsonFlag() {
44
33
  return this._enableJsonFlag;
45
34
  }
@@ -67,6 +56,17 @@ class Command {
67
56
  static set flags(flags) {
68
57
  this._flags = Object.assign({}, this._flags ?? {}, this.globalFlags, flags);
69
58
  }
59
+ constructor(argv, config) {
60
+ this.argv = argv;
61
+ this.config = config;
62
+ this.id = this.ctor.id;
63
+ try {
64
+ this.debug = require('debug')(this.id ? `${this.config.bin}:${this.id}` : this.config.bin);
65
+ }
66
+ catch {
67
+ this.debug = () => { };
68
+ }
69
+ }
70
70
  get ctor() {
71
71
  return this.constructor;
72
72
  }
@@ -1,5 +1,5 @@
1
1
  import { PrettyPrintableError } from '../../interfaces/errors';
2
- declare type CLIErrorDisplayOptions = {
2
+ type CLIErrorDisplayOptions = {
3
3
  name?: string;
4
4
  bang?: string;
5
5
  };
@@ -1,13 +1,13 @@
1
1
  import * as Interfaces from '../interfaces';
2
- export declare type HelpSectionKeyValueTable = {
2
+ export type HelpSectionKeyValueTable = {
3
3
  name: string;
4
4
  description: string;
5
5
  }[];
6
- export declare type HelpSection = {
6
+ export type HelpSection = {
7
7
  header: string;
8
8
  body: string | HelpSectionKeyValueTable | [string, string | undefined][] | undefined;
9
9
  } | undefined;
10
- export declare type HelpSectionRenderer = (data: {
10
+ export type HelpSectionRenderer = (data: {
11
11
  cmd: Interfaces.Command;
12
12
  flags: Interfaces.Command.Flag[];
13
13
  args: Interfaces.Command.Arg[];
package/lib/help/index.js CHANGED
@@ -38,10 +38,6 @@ class HelpBase extends formatter_1.HelpFormatter {
38
38
  }
39
39
  exports.HelpBase = HelpBase;
40
40
  class Help extends HelpBase {
41
- constructor(config, opts = {}) {
42
- super(config, opts);
43
- this.CommandHelpClass = command_1.default;
44
- }
45
41
  /*
46
42
  * _topics is to work around Interfaces.topics mistakenly including commands that do
47
43
  * not have children, as well as topics. A topic has children, either commands or other topics. When
@@ -69,6 +65,10 @@ class Help extends HelpBase {
69
65
  topics = (0, util_1.uniqBy)(topics, t => t.name);
70
66
  return topics;
71
67
  }
68
+ constructor(config, opts = {}) {
69
+ super(config, opts);
70
+ this.CommandHelpClass = command_1.default;
71
+ }
72
72
  async showHelp(argv) {
73
73
  const originalArgv = argv.slice(1);
74
74
  argv = argv.filter(arg => !(0, util_2.getHelpFlagAdditions)(this.config).includes(arg));
@@ -1,2 +1,2 @@
1
- export declare type AlphabetUppercase = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
2
- export declare type AlphabetLowercase = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
1
+ export type AlphabetUppercase = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
2
+ export type AlphabetLowercase = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
@@ -1,7 +1,7 @@
1
1
  import { Config, LoadOptions } from './config';
2
2
  import { ArgInput, BooleanFlagProps, Deprecation, FlagInput, OptionFlagProps } from './parser';
3
3
  import { Plugin as IPlugin } from './plugin';
4
- export declare type Example = string | {
4
+ export type Example = string | {
5
5
  description: string;
6
6
  command: string;
7
7
  };
@@ -3,9 +3,9 @@ import { Hooks, Hook } from './hooks';
3
3
  import { Command } from './command';
4
4
  import { Plugin, Options } from './plugin';
5
5
  import { Topic } from './topic';
6
- export declare type LoadOptions = Options | string | Config | undefined;
7
- export declare type PlatformTypes = 'darwin' | 'linux' | 'win32' | 'aix' | 'freebsd' | 'openbsd' | 'sunos' | 'wsl';
8
- export declare type ArchTypes = 'arm' | 'arm64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x32' | 'x64' | 'x86';
6
+ export type LoadOptions = Options | string | Config | undefined;
7
+ export type PlatformTypes = 'darwin' | 'linux' | 'win32' | 'aix' | 'freebsd' | 'openbsd' | 'sunos' | 'wsl';
8
+ export type ArchTypes = 'arm' | 'arm64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x32' | 'x64' | 'x86';
9
9
  export interface Config {
10
10
  name: string;
11
11
  version: string;
@@ -1,4 +1,4 @@
1
- export declare type CommandError = Error & {
1
+ export type CommandError = Error & {
2
2
  exitCode?: number;
3
3
  };
4
4
  export interface OclifError {
@@ -29,6 +29,6 @@ import { FlagInput } from './parser';
29
29
  * }
30
30
  * }
31
31
  */
32
- export declare type InferredFlags<T> = T extends FlagInput<infer F> ? F & {
32
+ export type InferredFlags<T> = T extends FlagInput<infer F> ? F & {
33
33
  json: boolean | undefined;
34
34
  } : unknown;
@@ -72,7 +72,7 @@ export interface Hooks {
72
72
  return: void;
73
73
  };
74
74
  }
75
- export declare type Hook<T extends keyof P, P extends Hooks = Hooks> = (this: Hook.Context, options: P[T]['options'] & {
75
+ export type Hook<T extends keyof P, P extends Hooks = Hooks> = (this: Hook.Context, options: P[T]['options'] & {
76
76
  config: Config;
77
77
  }) => Promise<P[T]['return']>;
78
78
  export declare namespace Hook {
@@ -1,6 +1,6 @@
1
1
  import { AlphabetLowercase, AlphabetUppercase } from './alphabet';
2
2
  import { Config } from './config';
3
- export declare type ParseFn<T> = (input: string) => Promise<T>;
3
+ export type ParseFn<T> = (input: string) => Promise<T>;
4
4
  export interface Arg<T = string> {
5
5
  name: string;
6
6
  description?: string;
@@ -21,32 +21,32 @@ export interface ArgBase<T> {
21
21
  options?: string[];
22
22
  ignoreStdin?: boolean;
23
23
  }
24
- export declare type RequiredArg<T> = ArgBase<T> & {
24
+ export type RequiredArg<T> = ArgBase<T> & {
25
25
  required: true;
26
26
  value: T;
27
27
  };
28
- export declare type OptionalArg<T> = ArgBase<T> & {
28
+ export type OptionalArg<T> = ArgBase<T> & {
29
29
  required: false;
30
30
  value?: T;
31
31
  };
32
- export declare type ParserArg<T> = RequiredArg<T> | OptionalArg<T>;
32
+ export type ParserArg<T> = RequiredArg<T> | OptionalArg<T>;
33
33
  export interface FlagOutput {
34
34
  [name: string]: any;
35
35
  }
36
- export declare type ArgInput = Arg<any>[];
36
+ export type ArgInput = Arg<any>[];
37
37
  export interface CLIParseErrorOptions {
38
38
  parse: {
39
39
  input?: ParserInput;
40
40
  output?: ParserOutput;
41
41
  };
42
42
  }
43
- export declare type OutputArgs = {
43
+ export type OutputArgs = {
44
44
  [name: string]: any;
45
45
  };
46
- export declare type OutputFlags<T extends ParserInput['flags']> = {
46
+ export type OutputFlags<T extends ParserInput['flags']> = {
47
47
  [P in keyof T]: any;
48
48
  };
49
- export declare type ParserOutput<TFlags extends OutputFlags<any> = any, GFlags extends OutputFlags<any> = any, TArgs extends OutputArgs = any> = {
49
+ export type ParserOutput<TFlags extends OutputFlags<any> = any, GFlags extends OutputFlags<any> = any, TArgs extends OutputArgs = any> = {
50
50
  flags: TFlags & GFlags & {
51
51
  json: boolean | undefined;
52
52
  };
@@ -55,49 +55,49 @@ export declare type ParserOutput<TFlags extends OutputFlags<any> = any, GFlags e
55
55
  raw: ParsingToken[];
56
56
  metadata: Metadata;
57
57
  };
58
- export declare type ArgToken = {
58
+ export type ArgToken = {
59
59
  type: 'arg';
60
60
  input: string;
61
61
  };
62
- export declare type FlagToken = {
62
+ export type FlagToken = {
63
63
  type: 'flag';
64
64
  flag: string;
65
65
  input: string;
66
66
  };
67
- export declare type ParsingToken = ArgToken | FlagToken;
67
+ export type ParsingToken = ArgToken | FlagToken;
68
68
  export interface FlagUsageOptions {
69
69
  displayRequired?: boolean;
70
70
  }
71
- export declare type Metadata = {
71
+ export type Metadata = {
72
72
  flags: {
73
73
  [key: string]: MetadataFlag;
74
74
  };
75
75
  };
76
- declare type MetadataFlag = {
76
+ type MetadataFlag = {
77
77
  setFromDefault?: boolean;
78
78
  };
79
- export declare type ListItem = [string, string | undefined];
80
- export declare type List = ListItem[];
81
- export declare type DefaultContext<T, P> = {
79
+ export type ListItem = [string, string | undefined];
80
+ export type List = ListItem[];
81
+ export type DefaultContext<T, P> = {
82
82
  options: P & OptionFlag<T>;
83
83
  flags: Record<string, string>;
84
84
  };
85
- export declare type Default<T, P = Record<string, unknown>> = T | ((context: DefaultContext<T, P>) => Promise<T>);
86
- export declare type DefaultHelp<T, P = Record<string, unknown>> = T | ((context: DefaultContext<T, P>) => Promise<string | undefined>);
87
- export declare type FlagRelationship = string | {
85
+ export type Default<T, P = Record<string, unknown>> = T | ((context: DefaultContext<T, P>) => Promise<T>);
86
+ export type DefaultHelp<T, P = Record<string, unknown>> = T | ((context: DefaultContext<T, P>) => Promise<string | undefined>);
87
+ export type FlagRelationship = string | {
88
88
  name: string;
89
89
  when: (flags: Record<string, unknown>) => Promise<boolean>;
90
90
  };
91
- export declare type Relationship = {
91
+ export type Relationship = {
92
92
  type: 'all' | 'some' | 'none';
93
93
  flags: FlagRelationship[];
94
94
  };
95
- export declare type Deprecation = {
95
+ export type Deprecation = {
96
96
  to?: string;
97
97
  message?: string;
98
98
  version?: string;
99
99
  };
100
- export declare type FlagProps = {
100
+ export type FlagProps = {
101
101
  name: string;
102
102
  char?: AlphabetLowercase | AlphabetUppercase;
103
103
  /**
@@ -161,32 +161,32 @@ export declare type FlagProps = {
161
161
  */
162
162
  deprecateAliases?: boolean;
163
163
  };
164
- export declare type BooleanFlagProps = FlagProps & {
164
+ export type BooleanFlagProps = FlagProps & {
165
165
  type: 'boolean';
166
166
  allowNo: boolean;
167
167
  };
168
- export declare type OptionFlagProps = FlagProps & {
168
+ export type OptionFlagProps = FlagProps & {
169
169
  type: 'option';
170
170
  helpValue?: string;
171
171
  options?: string[];
172
172
  multiple?: boolean;
173
173
  };
174
- export declare type FlagParser<T, I, P = any> = (input: I, context: any, opts: P & OptionFlag<T>) => Promise<T>;
175
- export declare type FlagBase<T, I, P = any> = FlagProps & {
174
+ export type FlagParser<T, I, P = any> = (input: I, context: any, opts: P & OptionFlag<T>) => Promise<T | T[]>;
175
+ export type FlagBase<T, I, P = any> = FlagProps & {
176
176
  parse: FlagParser<T, I, P>;
177
177
  };
178
- export declare type BooleanFlag<T> = FlagBase<T, boolean> & BooleanFlagProps & {
178
+ export type BooleanFlag<T> = FlagBase<T, boolean> & BooleanFlagProps & {
179
179
  /**
180
180
  * specifying a default of false is the same as not specifying a default
181
181
  */
182
182
  default?: Default<boolean>;
183
183
  };
184
- export declare type CustomOptionFlag<T, P = any, M = false> = FlagBase<T, string, P> & OptionFlagProps & {
184
+ export type CustomOptionFlag<T, P = any, M = false> = FlagBase<T, string, P> & OptionFlagProps & {
185
185
  defaultHelp?: DefaultHelp<T>;
186
186
  input: string[];
187
187
  default?: M extends true ? Default<T[] | undefined, P> : Default<T | undefined, P>;
188
188
  };
189
- export declare type OptionFlag<T> = FlagBase<T, string> & OptionFlagProps & {
189
+ export type OptionFlag<T> = FlagBase<T, string> & OptionFlagProps & {
190
190
  defaultHelp?: DefaultHelp<T>;
191
191
  input: string[];
192
192
  } & ({
@@ -196,7 +196,7 @@ export declare type OptionFlag<T> = FlagBase<T, string> & OptionFlagProps & {
196
196
  default?: Default<T[] | undefined>;
197
197
  multiple: true;
198
198
  });
199
- export declare type Definition<T, P = Record<string, unknown>> = {
199
+ export type Definition<T, P = Record<string, unknown>> = {
200
200
  (options: P & {
201
201
  multiple: true;
202
202
  } & ({
@@ -214,7 +214,7 @@ export declare type Definition<T, P = Record<string, unknown>> = {
214
214
  }) & Partial<OptionFlag<T>>): OptionFlag<T>;
215
215
  (options?: P & Partial<OptionFlag<T>>): OptionFlag<T | undefined>;
216
216
  };
217
- export declare type EnumFlagOptions<T, M = false> = Partial<CustomOptionFlag<T, any, M>> & {
217
+ export type EnumFlagOptions<T, M = false> = Partial<CustomOptionFlag<T, any, M>> & {
218
218
  options: T[];
219
219
  } & ({
220
220
  default?: Default<T | undefined>;
@@ -223,8 +223,8 @@ export declare type EnumFlagOptions<T, M = false> = Partial<CustomOptionFlag<T,
223
223
  default?: Default<T[] | undefined>;
224
224
  multiple: true;
225
225
  });
226
- export declare type Flag<T> = BooleanFlag<T> | OptionFlag<T>;
227
- export declare type Input<TFlags extends FlagOutput, GFlags extends FlagOutput> = {
226
+ export type Flag<T> = BooleanFlag<T> | OptionFlag<T>;
227
+ export type Input<TFlags extends FlagOutput, GFlags extends FlagOutput> = {
228
228
  flags?: FlagInput<TFlags>;
229
229
  globalFlags?: FlagInput<GFlags>;
230
230
  args?: ArgInput;
@@ -240,7 +240,7 @@ export interface ParserInput {
240
240
  context: any;
241
241
  '--'?: boolean;
242
242
  }
243
- export declare type CompletionContext = {
243
+ export type CompletionContext = {
244
244
  args?: {
245
245
  [name: string]: string;
246
246
  };
@@ -250,17 +250,17 @@ export declare type CompletionContext = {
250
250
  argv?: string[];
251
251
  config: Config;
252
252
  };
253
- export declare type Completion = {
253
+ export type Completion = {
254
254
  skipCache?: boolean;
255
255
  cacheDuration?: number;
256
256
  cacheKey?(ctx: CompletionContext): Promise<string>;
257
257
  options(ctx: CompletionContext): Promise<string[]>;
258
258
  };
259
- export declare type CompletableOptionFlag<T> = OptionFlag<T> & {
259
+ export type CompletableOptionFlag<T> = OptionFlag<T> & {
260
260
  completion?: Completion;
261
261
  };
262
- export declare type CompletableFlag<T> = BooleanFlag<T> | CompletableOptionFlag<T>;
263
- export declare type FlagInput<T extends FlagOutput = {
262
+ export type CompletableFlag<T> = BooleanFlag<T> | CompletableOptionFlag<T>;
263
+ export type FlagInput<T extends FlagOutput = {
264
264
  [flag: string]: any;
265
265
  }> = {
266
266
  [P in keyof T]: CompletableFlag<T[P]>;
@@ -1,7 +1,7 @@
1
1
  import { CLIError } from '../errors';
2
2
  import { ParserArg, CLIParseErrorOptions, OptionFlag, Flag } from '../interfaces';
3
3
  export { CLIError } from '../errors';
4
- export declare type Validation = {
4
+ export type Validation = {
5
5
  name: string;
6
6
  status: 'success' | 'failed';
7
7
  validationFn: string;
@@ -167,7 +167,7 @@ class Parser {
167
167
  const value = flag.parse ? await flag.parse(input, this.context, flag) : input;
168
168
  if (flag.multiple) {
169
169
  flags[token.flag] = flags[token.flag] || [];
170
- flags[token.flag].push(value);
170
+ flags[token.flag].push(...(Array.isArray(value) ? value : [value]));
171
171
  }
172
172
  else {
173
173
  flags[token.flag] = value;
@@ -2,6 +2,6 @@ export declare function pickBy<T extends {
2
2
  [s: string]: T[keyof T];
3
3
  } | ArrayLike<T[keyof T]>>(obj: T, fn: (i: T[keyof T]) => boolean): Partial<T>;
4
4
  export declare function maxBy<T>(arr: T[], fn: (i: T) => number): T | undefined;
5
- declare type SortTypes = string | number | undefined | boolean;
5
+ type SortTypes = string | number | undefined | boolean;
6
6
  export declare function sortBy<T>(arr: T[], fn: (i: T) => SortTypes | SortTypes[]): T[];
7
7
  export {};
package/lib/settings.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare type Settings = {
1
+ export type Settings = {
2
2
  /**
3
3
  * Show additional debug output without DEBUG. Mainly shows stackstraces.
4
4
  *
package/lib/util.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare function compact<T>(a: (T | undefined)[]): T[];
2
2
  export declare function uniqBy<T>(arr: T[], fn: (cur: T) => any): T[];
3
- declare type SortTypes = string | number | undefined | boolean;
3
+ type SortTypes = string | number | undefined | boolean;
4
4
  export declare function sortBy<T>(arr: T[], fn: (i: T) => SortTypes | SortTypes[]): T[];
5
5
  export declare function castArray<T>(input?: T | T[]): T[];
6
6
  export declare function isProd(): boolean;
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": "1.20.4",
4
+ "version": "1.21.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
@@ -36,11 +36,11 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@commitlint/config-conventional": "^12.1.4",
39
- "@oclif/plugin-help": "^5.1.17",
40
- "@oclif/plugin-plugins": "^2.1.6",
41
- "@oclif/test": "^2.2.8",
39
+ "@oclif/plugin-help": "^5.1.19",
40
+ "@oclif/plugin-plugins": "^2.1.7",
41
+ "@oclif/test": "^2.2.12",
42
42
  "@types/ansi-styles": "^3.2.1",
43
- "@types/chai": "^4.3.0",
43
+ "@types/chai": "^4.3.4",
44
44
  "@types/chai-as-promised": "^7.1.5",
45
45
  "@types/clean-stack": "^2.1.1",
46
46
  "@types/cli-progress": "^3.9.2",
@@ -58,7 +58,7 @@
58
58
  "@types/strip-ansi": "^5.2.1",
59
59
  "@types/supports-color": "^8.1.1",
60
60
  "@types/wrap-ansi": "^3.0.0",
61
- "chai": "^4.3.6",
61
+ "chai": "^4.3.7",
62
62
  "chai-as-promised": "^7.1.1",
63
63
  "commitlint": "^12.1.4",
64
64
  "eslint": "^7.32.0",
@@ -74,8 +74,8 @@
74
74
  "shx": "^0.3.4",
75
75
  "sinon": "^11.1.2",
76
76
  "ts-node": "^10.9.1",
77
- "tsd": "^0.22.0",
78
- "typescript": "^4.8.3"
77
+ "tsd": "^0.25.0",
78
+ "typescript": "^4.9.3"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=14.0.0"