@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.
- package/README.md +4 -2
- package/flush.d.ts +3 -0
- package/flush.js +1 -0
- package/handle.js +1 -0
- package/lib/args.d.ts +2 -2
- package/lib/args.js +17 -18
- package/lib/{ux → cli-ux}/action/base.d.ts +19 -21
- package/lib/{ux → cli-ux}/action/base.js +126 -120
- package/lib/{ux → cli-ux}/action/simple.js +25 -30
- package/lib/{ux → cli-ux}/action/spinner.d.ts +9 -7
- package/lib/{ux → cli-ux}/action/spinner.js +45 -37
- package/lib/{ux → cli-ux}/action/spinners.js +187 -187
- package/lib/cli-ux/action/types.d.ts +5 -0
- package/lib/cli-ux/action/types.js +2 -0
- package/lib/{ux → cli-ux}/config.d.ts +5 -5
- package/lib/{ux → cli-ux}/config.js +17 -17
- package/lib/{ux → cli-ux}/exit.js +3 -0
- package/lib/cli-ux/flush.d.ts +1 -0
- package/lib/cli-ux/flush.js +28 -0
- package/lib/cli-ux/index.d.ts +39 -0
- package/lib/{ux → cli-ux}/index.js +74 -88
- package/lib/{ux → cli-ux}/list.js +3 -3
- package/lib/{ux → cli-ux}/prompt.d.ts +3 -3
- package/lib/{ux → cli-ux}/prompt.js +35 -25
- package/lib/{ux → cli-ux}/stream.d.ts +6 -6
- package/lib/{ux → cli-ux}/stream.js +11 -10
- package/lib/cli-ux/styled/index.d.ts +4 -0
- package/lib/cli-ux/styled/index.js +11 -0
- package/lib/{ux → cli-ux}/styled/object.js +7 -9
- package/lib/{ux → cli-ux}/styled/table.d.ts +10 -10
- package/lib/{ux → cli-ux}/styled/table.js +130 -133
- package/lib/{ux → cli-ux}/styled/tree.js +11 -13
- package/lib/cli-ux/wait.js +5 -0
- package/lib/command.d.ts +82 -88
- package/lib/command.js +196 -175
- package/lib/config/config.d.ts +89 -90
- package/lib/config/config.js +466 -566
- package/lib/config/index.d.ts +0 -1
- package/lib/config/index.js +1 -3
- package/lib/config/plugin-loader.d.ts +12 -12
- package/lib/config/plugin-loader.js +72 -56
- package/lib/config/plugin.d.ts +25 -24
- package/lib/config/plugin.js +188 -154
- package/lib/config/ts-node.d.ts +2 -1
- package/lib/config/ts-node.js +71 -58
- package/lib/config/util.d.ts +1 -11
- package/lib/config/util.js +6 -59
- package/lib/errors/config.d.ts +1 -1
- package/lib/errors/config.js +6 -6
- package/lib/errors/errors/cli.d.ts +7 -7
- package/lib/errors/errors/cli.js +20 -16
- package/lib/errors/errors/exit.d.ts +1 -4
- package/lib/errors/errors/exit.js +1 -1
- package/lib/errors/errors/module-load.d.ts +1 -4
- package/lib/errors/errors/module-load.js +1 -1
- package/lib/errors/errors/pretty-print.d.ts +1 -1
- package/lib/errors/errors/pretty-print.js +12 -10
- package/lib/errors/handle.d.ts +12 -2
- package/lib/errors/handle.js +26 -14
- package/lib/errors/index.d.ts +10 -10
- package/lib/errors/index.js +25 -24
- package/lib/errors/logger.d.ts +2 -2
- package/lib/errors/logger.js +14 -13
- package/lib/execute.d.ts +6 -6
- package/lib/execute.js +10 -9
- package/lib/flags.d.ts +103 -32
- package/lib/flags.js +79 -45
- package/lib/help/command.d.ts +16 -14
- package/lib/help/command.js +178 -163
- package/lib/help/docopts.d.ts +5 -5
- package/lib/help/docopts.js +50 -54
- package/lib/help/formatter.d.ts +37 -37
- package/lib/help/formatter.js +66 -55
- package/lib/help/index.d.ts +25 -21
- package/lib/help/index.js +169 -147
- package/lib/help/root.d.ts +1 -1
- package/lib/help/root.js +15 -17
- package/lib/help/util.d.ts +2 -8
- package/lib/help/util.js +8 -28
- package/lib/index.d.ts +19 -20
- package/lib/index.js +37 -43
- package/lib/interfaces/config.d.ts +67 -66
- package/lib/interfaces/errors.d.ts +5 -5
- package/lib/interfaces/help.d.ts +17 -17
- package/lib/interfaces/hooks.d.ts +49 -49
- package/lib/interfaces/index.d.ts +7 -7
- package/lib/interfaces/manifest.d.ts +1 -1
- package/lib/interfaces/parser.d.ts +175 -51
- package/lib/interfaces/pjson.d.ts +41 -41
- package/lib/interfaces/plugin.d.ts +47 -41
- package/lib/interfaces/s3-manifest.d.ts +7 -7
- package/lib/interfaces/topic.d.ts +1 -1
- package/lib/interfaces/ts-config.d.ts +7 -7
- package/lib/main.d.ts +2 -2
- package/lib/main.js +16 -16
- package/lib/module-loader.d.ts +67 -77
- package/lib/module-loader.js +183 -150
- package/lib/parser/errors.d.ts +7 -7
- package/lib/parser/errors.js +29 -22
- package/lib/parser/help.js +5 -5
- package/lib/parser/index.js +2 -2
- package/lib/parser/parse.d.ts +9 -6
- package/lib/parser/parse.js +253 -221
- package/lib/parser/validate.js +53 -33
- package/lib/performance.d.ts +43 -32
- package/lib/performance.js +133 -91
- package/lib/screen.js +2 -2
- package/lib/settings.d.ts +11 -12
- package/lib/settings.js +2 -2
- package/lib/util/aggregate-flags.d.ts +2 -0
- package/lib/util/aggregate-flags.js +13 -0
- package/lib/util/cache-command.d.ts +3 -0
- package/lib/util/cache-command.js +109 -0
- package/lib/util/cache-default-value.d.ts +2 -0
- package/lib/util/cache-default-value.js +28 -0
- package/lib/util/ensure-arg-object.d.ts +12 -0
- package/lib/util/ensure-arg-object.js +14 -0
- package/lib/util/fs.d.ts +7 -0
- package/lib/util/fs.js +54 -0
- package/lib/util/os.d.ts +19 -0
- package/lib/util/os.js +28 -0
- package/lib/{util.d.ts → util/util.d.ts} +7 -16
- package/lib/util/util.js +98 -0
- package/package.json +35 -37
- package/lib/util.js +0 -126
- package/lib/ux/flush.d.ts +0 -1
- package/lib/ux/flush.js +0 -27
- package/lib/ux/index.d.ts +0 -58
- package/lib/ux/styled/index.d.ts +0 -6
- package/lib/ux/styled/index.js +0 -13
- package/lib/ux/styled/json.d.ts +0 -1
- package/lib/ux/styled/json.js +0 -15
- package/lib/ux/wait.js +0 -7
- package/lib/{ux → cli-ux}/action/simple.d.ts +4 -4
- package/lib/{ux → cli-ux}/action/spinners.d.ts +117 -117
- package/lib/{ux → cli-ux}/exit.d.ts +2 -2
- package/lib/{ux → cli-ux}/list.d.ts +0 -0
- package/lib/{ux → cli-ux}/styled/object.d.ts +0 -0
- package/lib/{ux → cli-ux}/styled/progress.d.ts +0 -0
- package/lib/{ux → cli-ux}/styled/progress.js +0 -0
- package/lib/{ux → cli-ux}/styled/tree.d.ts +1 -1
- /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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
static
|
|
71
|
-
|
|
72
|
-
static
|
|
73
|
-
static
|
|
74
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
error(input:
|
|
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:
|
|
91
|
+
error(input: Error | string, options?: {
|
|
103
92
|
code?: string;
|
|
104
93
|
exit?: number;
|
|
105
94
|
} & PrettyPrintableError): never;
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
140
|
-
hidden: boolean;
|
|
141
|
-
state?: 'beta' | 'deprecated' | string;
|
|
142
|
-
deprecationOptions?: Deprecation;
|
|
129
|
+
aliasPermutations?: string[];
|
|
143
130
|
aliases: string[];
|
|
144
|
-
|
|
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
|
-
|
|
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 =
|
|
155
|
+
type Flag = IFlag<any>;
|
|
164
156
|
namespace Flag {
|
|
165
|
-
type Cached = Omit<Flag, '
|
|
166
|
-
|
|
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, '
|
|
164
|
+
type Cached = Omit<Arg, 'input' | 'parse'> & ArgProps;
|
|
171
165
|
type Any = Arg | Cached;
|
|
172
166
|
}
|
|
173
|
-
type Example =
|
|
174
|
-
description: string;
|
|
167
|
+
type Example = {
|
|
175
168
|
command: string;
|
|
176
|
-
|
|
169
|
+
description: string;
|
|
170
|
+
} | string;
|
|
177
171
|
}
|