@oclif/core 3.0.0-beta.9 → 3.0.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.
Files changed (142) hide show
  1. package/README.md +4 -2
  2. package/flush.d.ts +3 -0
  3. package/flush.js +1 -0
  4. package/handle.js +1 -0
  5. package/lib/args.d.ts +2 -2
  6. package/lib/args.js +17 -18
  7. package/lib/{ux → cli-ux}/action/base.d.ts +19 -21
  8. package/lib/{ux → cli-ux}/action/base.js +126 -120
  9. package/lib/{ux → cli-ux}/action/simple.js +25 -30
  10. package/lib/{ux → cli-ux}/action/spinner.d.ts +9 -7
  11. package/lib/{ux → cli-ux}/action/spinner.js +45 -37
  12. package/lib/{ux → cli-ux}/action/spinners.js +187 -187
  13. package/lib/cli-ux/action/types.d.ts +5 -0
  14. package/lib/cli-ux/action/types.js +2 -0
  15. package/lib/{ux → cli-ux}/config.d.ts +5 -5
  16. package/lib/{ux → cli-ux}/config.js +17 -17
  17. package/lib/{ux → cli-ux}/exit.js +3 -0
  18. package/lib/cli-ux/flush.d.ts +1 -0
  19. package/lib/cli-ux/flush.js +28 -0
  20. package/lib/cli-ux/index.d.ts +39 -0
  21. package/lib/{ux → cli-ux}/index.js +74 -88
  22. package/lib/{ux → cli-ux}/list.js +3 -3
  23. package/lib/{ux → cli-ux}/prompt.d.ts +3 -3
  24. package/lib/{ux → cli-ux}/prompt.js +35 -25
  25. package/lib/{ux → cli-ux}/stream.d.ts +6 -6
  26. package/lib/{ux → cli-ux}/stream.js +11 -10
  27. package/lib/cli-ux/styled/index.d.ts +4 -0
  28. package/lib/cli-ux/styled/index.js +11 -0
  29. package/lib/{ux → cli-ux}/styled/object.js +7 -9
  30. package/lib/{ux → cli-ux}/styled/table.d.ts +10 -10
  31. package/lib/{ux → cli-ux}/styled/table.js +130 -133
  32. package/lib/{ux → cli-ux}/styled/tree.js +11 -13
  33. package/lib/cli-ux/wait.js +5 -0
  34. package/lib/command.d.ts +82 -88
  35. package/lib/command.js +196 -175
  36. package/lib/config/config.d.ts +89 -90
  37. package/lib/config/config.js +466 -566
  38. package/lib/config/index.d.ts +0 -1
  39. package/lib/config/index.js +1 -3
  40. package/lib/config/plugin-loader.d.ts +12 -12
  41. package/lib/config/plugin-loader.js +72 -56
  42. package/lib/config/plugin.d.ts +25 -24
  43. package/lib/config/plugin.js +188 -154
  44. package/lib/config/ts-node.d.ts +2 -1
  45. package/lib/config/ts-node.js +71 -58
  46. package/lib/config/util.d.ts +1 -11
  47. package/lib/config/util.js +6 -59
  48. package/lib/errors/config.d.ts +1 -1
  49. package/lib/errors/config.js +6 -6
  50. package/lib/errors/errors/cli.d.ts +7 -7
  51. package/lib/errors/errors/cli.js +20 -16
  52. package/lib/errors/errors/exit.d.ts +1 -4
  53. package/lib/errors/errors/exit.js +1 -1
  54. package/lib/errors/errors/module-load.d.ts +1 -4
  55. package/lib/errors/errors/module-load.js +1 -1
  56. package/lib/errors/errors/pretty-print.d.ts +1 -1
  57. package/lib/errors/errors/pretty-print.js +12 -10
  58. package/lib/errors/handle.d.ts +12 -2
  59. package/lib/errors/handle.js +26 -14
  60. package/lib/errors/index.d.ts +10 -10
  61. package/lib/errors/index.js +25 -24
  62. package/lib/errors/logger.d.ts +2 -2
  63. package/lib/errors/logger.js +14 -13
  64. package/lib/execute.d.ts +6 -6
  65. package/lib/execute.js +10 -9
  66. package/lib/flags.d.ts +103 -32
  67. package/lib/flags.js +79 -45
  68. package/lib/help/command.d.ts +16 -14
  69. package/lib/help/command.js +178 -163
  70. package/lib/help/docopts.d.ts +5 -5
  71. package/lib/help/docopts.js +50 -54
  72. package/lib/help/formatter.d.ts +37 -37
  73. package/lib/help/formatter.js +66 -55
  74. package/lib/help/index.d.ts +25 -21
  75. package/lib/help/index.js +169 -147
  76. package/lib/help/root.d.ts +1 -1
  77. package/lib/help/root.js +15 -17
  78. package/lib/help/util.d.ts +2 -8
  79. package/lib/help/util.js +8 -28
  80. package/lib/index.d.ts +19 -20
  81. package/lib/index.js +37 -43
  82. package/lib/interfaces/config.d.ts +67 -66
  83. package/lib/interfaces/errors.d.ts +5 -5
  84. package/lib/interfaces/help.d.ts +17 -17
  85. package/lib/interfaces/hooks.d.ts +49 -49
  86. package/lib/interfaces/index.d.ts +7 -7
  87. package/lib/interfaces/manifest.d.ts +1 -1
  88. package/lib/interfaces/parser.d.ts +175 -51
  89. package/lib/interfaces/pjson.d.ts +41 -41
  90. package/lib/interfaces/plugin.d.ts +47 -41
  91. package/lib/interfaces/s3-manifest.d.ts +7 -7
  92. package/lib/interfaces/topic.d.ts +1 -1
  93. package/lib/interfaces/ts-config.d.ts +7 -7
  94. package/lib/main.d.ts +2 -2
  95. package/lib/main.js +16 -16
  96. package/lib/module-loader.d.ts +67 -77
  97. package/lib/module-loader.js +183 -150
  98. package/lib/parser/errors.d.ts +7 -7
  99. package/lib/parser/errors.js +29 -22
  100. package/lib/parser/help.js +5 -5
  101. package/lib/parser/index.js +2 -2
  102. package/lib/parser/parse.d.ts +9 -6
  103. package/lib/parser/parse.js +253 -221
  104. package/lib/parser/validate.js +53 -33
  105. package/lib/performance.d.ts +43 -32
  106. package/lib/performance.js +133 -91
  107. package/lib/screen.js +2 -2
  108. package/lib/settings.d.ts +11 -12
  109. package/lib/settings.js +2 -2
  110. package/lib/util/aggregate-flags.d.ts +2 -0
  111. package/lib/util/aggregate-flags.js +13 -0
  112. package/lib/util/cache-command.d.ts +3 -0
  113. package/lib/util/cache-command.js +109 -0
  114. package/lib/util/cache-default-value.d.ts +2 -0
  115. package/lib/util/cache-default-value.js +28 -0
  116. package/lib/util/ensure-arg-object.d.ts +12 -0
  117. package/lib/util/ensure-arg-object.js +14 -0
  118. package/lib/util/fs.d.ts +7 -0
  119. package/lib/util/fs.js +54 -0
  120. package/lib/util/os.d.ts +19 -0
  121. package/lib/util/os.js +28 -0
  122. package/lib/{util.d.ts → util/util.d.ts} +7 -16
  123. package/lib/util/util.js +98 -0
  124. package/package.json +35 -37
  125. package/lib/util.js +0 -126
  126. package/lib/ux/flush.d.ts +0 -1
  127. package/lib/ux/flush.js +0 -27
  128. package/lib/ux/index.d.ts +0 -58
  129. package/lib/ux/styled/index.d.ts +0 -6
  130. package/lib/ux/styled/index.js +0 -13
  131. package/lib/ux/styled/json.d.ts +0 -1
  132. package/lib/ux/styled/json.js +0 -15
  133. package/lib/ux/wait.js +0 -7
  134. package/lib/{ux → cli-ux}/action/simple.d.ts +4 -4
  135. package/lib/{ux → cli-ux}/action/spinners.d.ts +117 -117
  136. package/lib/{ux → cli-ux}/exit.d.ts +2 -2
  137. package/lib/{ux → cli-ux}/list.d.ts +0 -0
  138. package/lib/{ux → cli-ux}/styled/object.d.ts +0 -0
  139. package/lib/{ux → cli-ux}/styled/progress.d.ts +0 -0
  140. package/lib/{ux → cli-ux}/styled/progress.js +0 -0
  141. package/lib/{ux → cli-ux}/styled/tree.d.ts +1 -1
  142. /package/lib/{ux → cli-ux}/wait.d.ts +0 -0
package/lib/command.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Config } from './config';
2
2
  import { PrettyPrintableError } from './errors';
3
- import { BooleanFlagProps, CompletableFlag, Deprecation, Arg as IArg, ArgInput, FlagInput, FlagOutput, Input, ArgProps, OptionFlagProps, ParserOutput, ArgOutput } from './interfaces/parser';
4
- import { Plugin } from './interfaces/plugin';
5
3
  import { LoadOptions } from './interfaces/config';
6
4
  import { CommandError } from './interfaces/errors';
5
+ import { ArgInput, ArgOutput, ArgProps, BooleanFlagProps, Deprecation, FlagInput, FlagOutput, Arg as IArg, Flag as IFlag, Input, OptionFlagProps, ParserOutput } from './interfaces/parser';
6
+ import { Plugin } from './interfaces/plugin';
7
7
  /**
8
8
  * An abstract class which acts as the base for each command
9
9
  * in your project.
@@ -11,44 +11,23 @@ import { CommandError } from './interfaces/errors';
11
11
  export declare abstract class Command {
12
12
  argv: string[];
13
13
  config: Config;
14
- private static readonly _base;
15
- /** A command ID, used mostly in error or verbose reporting. */
16
- static id: string;
14
+ /** An array of aliases for this command. */
15
+ static aliases: string[];
16
+ /** An order-dependent object of arguments for the command */
17
+ static args: ArgInput;
18
+ static baseFlags: FlagInput;
17
19
  /**
18
- * The tweet-sized description for your class, used in a parent-commands
19
- * sub-command listing and as the header for the command help.
20
+ * Emit deprecation warning when a command alias is used
20
21
  */
21
- static summary?: string;
22
+ static deprecateAliases?: boolean;
23
+ static deprecationOptions?: Deprecation;
22
24
  /**
23
25
  * A full description of how to use the command.
24
26
  *
25
27
  * If no summary, the first line of the description will be used as the summary.
26
28
  */
27
29
  static description: string | undefined;
28
- /** Hide the command from help */
29
- static hidden: boolean;
30
- /** Mark the command as a given state (e.g. beta or deprecated) in help */
31
- static state?: 'beta' | 'deprecated' | string;
32
- static deprecationOptions?: Deprecation;
33
- /**
34
- * Emit deprecation warning when a command alias is used
35
- */
36
- static deprecateAliases?: boolean;
37
- /**
38
- * An override string (or strings) for the default usage documentation.
39
- */
40
- static usage: string | string[] | undefined;
41
- static help: string | undefined;
42
- /** An array of aliases for this command. */
43
- static aliases: string[];
44
- /** When set to false, allows a variable amount of arguments */
45
- static strict: boolean;
46
- /** An order-dependent object of arguments for the command */
47
- static args: ArgInput;
48
- static plugin: Plugin | undefined;
49
- static readonly pluginName?: string;
50
- static readonly pluginType?: string;
51
- static readonly pluginAlias?: string;
30
+ static enableJsonFlag: boolean;
52
31
  /**
53
32
  * An array of examples to show at the end of the command's help.
54
33
  *
@@ -64,14 +43,35 @@ export declare abstract class Command {
64
43
  * ```
65
44
  */
66
45
  static examples: Command.Example[];
46
+ /** A hash of flags for the command */
47
+ static flags: FlagInput;
67
48
  static hasDynamicHelp: boolean;
68
- protected static '_--': boolean;
69
- protected static _enableJsonFlag: boolean;
70
- static get enableJsonFlag(): boolean;
71
- static set enableJsonFlag(value: boolean);
72
- static get '--'(): boolean;
73
- static set '--'(value: boolean);
74
- get passThroughEnabled(): boolean;
49
+ static help: string | undefined;
50
+ /** Hide the command from help */
51
+ static hidden: boolean;
52
+ /** A command ID, used mostly in error or verbose reporting. */
53
+ static id: string;
54
+ static plugin: Plugin | undefined;
55
+ static readonly pluginAlias?: string;
56
+ static readonly pluginName?: string;
57
+ static readonly pluginType?: string;
58
+ /** Mark the command as a given state (e.g. beta or deprecated) in help */
59
+ static state?: 'beta' | 'deprecated' | string;
60
+ /** When set to false, allows a variable amount of arguments */
61
+ static strict: boolean;
62
+ /**
63
+ * The tweet-sized description for your class, used in a parent-commands
64
+ * sub-command listing and as the header for the command help.
65
+ */
66
+ static summary?: string;
67
+ /**
68
+ * An override string (or strings) for the default usage documentation.
69
+ */
70
+ static usage: string | string[] | undefined;
71
+ private static readonly _base;
72
+ protected debug: (...args: any[]) => void;
73
+ id: string | undefined;
74
+ constructor(argv: string[], config: Config);
75
75
  /**
76
76
  * instantiate and run the command
77
77
  *
@@ -81,50 +81,40 @@ export declare abstract class Command {
81
81
  * @returns {Promise<unknown>} result
82
82
  */
83
83
  static run<T extends Command>(this: new (argv: string[], config: Config) => T, argv?: string[], opts?: LoadOptions): Promise<ReturnType<T['run']>>;
84
- protected static _baseFlags: FlagInput;
85
- static get baseFlags(): FlagInput;
86
- static set baseFlags(flags: FlagInput);
87
- /** A hash of flags for the command */
88
- protected static _flags: FlagInput;
89
- static get flags(): FlagInput;
90
- static set flags(flags: FlagInput);
91
- id: string | undefined;
92
- protected debug: (...args: any[]) => void;
93
- constructor(argv: string[], config: Config);
94
- protected get ctor(): typeof Command;
95
84
  protected _run<T>(): Promise<T>;
96
- exit(code?: number): never;
97
- warn(input: string | Error): string | Error;
98
- error(input: string | Error, options: {
85
+ private removeEnvVar;
86
+ protected catch(err: CommandError): Promise<any>;
87
+ error(input: Error | string, options: {
99
88
  code?: string;
100
89
  exit: false;
101
90
  } & PrettyPrintableError): void;
102
- error(input: string | Error, options?: {
91
+ error(input: Error | string, options?: {
103
92
  code?: string;
104
93
  exit?: number;
105
94
  } & PrettyPrintableError): never;
106
- log(message?: string, ...args: any[]): void;
107
- logToStderr(message?: string, ...args: any[]): void;
95
+ exit(code?: number): never;
96
+ protected finally(_: Error | undefined): Promise<any>;
97
+ protected init(): Promise<any>;
108
98
  /**
109
99
  * Determine if the command is being run with the --json flag in a command that supports it.
110
100
  *
111
101
  * @returns {boolean} true if the command supports json and the --json flag is present
112
102
  */
113
103
  jsonEnabled(): boolean;
104
+ log(message?: string, ...args: any[]): void;
105
+ protected logJson(json: unknown): void;
106
+ logToStderr(message?: string, ...args: any[]): void;
107
+ protected parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(options?: Input<F, B, A>, argv?: string[]): Promise<ParserOutput<F, B, A>>;
108
+ protected toErrorJson(err: unknown): any;
109
+ protected toSuccessJson(result: unknown): any;
110
+ warn(input: Error | string): Error | string;
111
+ protected warnIfCommandDeprecated(): void;
112
+ protected warnIfFlagDeprecated(flags: Record<string, unknown>): void;
113
+ protected get ctor(): typeof Command;
114
114
  /**
115
115
  * actual command run code goes here
116
116
  */
117
117
  abstract run(): Promise<any>;
118
- protected init(): Promise<any>;
119
- protected warnIfFlagDeprecated(flags: Record<string, unknown>): void;
120
- protected warnIfCommandDeprecated(): void;
121
- protected parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(options?: Input<F, B, A>, argv?: string[]): Promise<ParserOutput<F, B, A>>;
122
- protected catch(err: CommandError): Promise<any>;
123
- protected finally(_: Error | undefined): Promise<any>;
124
- protected toSuccessJson(result: unknown): any;
125
- protected toErrorJson(err: unknown): any;
126
- protected logJson(json: unknown): void;
127
- private removeEnvVar;
128
118
  }
129
119
  export declare namespace Command {
130
120
  type Class = typeof Command & {
@@ -136,42 +126,46 @@ export declare namespace Command {
136
126
  }
137
127
  type Cached = {
138
128
  [key: string]: unknown;
139
- id: string;
140
- hidden: boolean;
141
- state?: 'beta' | 'deprecated' | string;
142
- deprecationOptions?: Deprecation;
129
+ aliasPermutations?: string[];
143
130
  aliases: string[];
144
- summary?: string;
131
+ args: {
132
+ [name: string]: Arg.Cached;
133
+ };
134
+ deprecationOptions?: Deprecation;
145
135
  description?: string;
146
- usage?: string | string[];
147
136
  examples?: Example[];
148
- strict?: boolean;
149
- type?: string;
150
- pluginName?: string;
151
- pluginType?: string;
152
- pluginAlias?: string;
153
137
  flags: {
154
138
  [name: string]: Flag.Cached;
155
139
  };
156
- args: {
157
- [name: string]: Arg.Cached;
158
- };
159
140
  hasDynamicHelp?: boolean;
141
+ hidden: boolean;
142
+ id: string;
143
+ isESM?: boolean;
160
144
  permutations?: string[];
161
- aliasPermutations?: string[];
145
+ pluginAlias?: string;
146
+ pluginName?: string;
147
+ pluginType?: string;
148
+ relativePath?: string[];
149
+ state?: 'beta' | 'deprecated' | string;
150
+ strict?: boolean;
151
+ summary?: string;
152
+ type?: string;
153
+ usage?: string | string[];
162
154
  };
163
- type Flag = CompletableFlag<any>;
155
+ type Flag = IFlag<any>;
164
156
  namespace Flag {
165
- type Cached = Omit<Flag, 'parse' | 'input'> & (BooleanFlagProps | OptionFlagProps);
166
- type Any = Flag | Cached;
157
+ type Cached = Omit<Flag, 'input' | 'parse'> & (BooleanFlagProps | OptionFlagProps) & {
158
+ hasDynamicHelp?: boolean;
159
+ };
160
+ type Any = Cached | Flag;
167
161
  }
168
162
  type Arg = IArg<any>;
169
163
  namespace Arg {
170
- type Cached = Omit<Arg, 'parse' | 'input'> & ArgProps;
164
+ type Cached = Omit<Arg, 'input' | 'parse'> & ArgProps;
171
165
  type Any = Arg | Cached;
172
166
  }
173
- type Example = string | {
174
- description: string;
167
+ type Example = {
175
168
  command: string;
176
- };
169
+ description: string;
170
+ } | string;
177
171
  }