@oclif/core 3.0.2 → 3.0.4
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/lib/command.d.ts +18 -2
- package/lib/execute.d.ts +8 -4
- package/lib/execute.js +8 -4
- package/lib/flags.d.ts +9 -9
- package/lib/help/command.d.ts +2 -2
- package/lib/help/formatter.d.ts +1 -1
- package/lib/help/index.d.ts +8 -8
- package/lib/interfaces/parser.d.ts +2 -1
- package/lib/interfaces/pjson.d.ts +6 -0
- package/package.json +1 -1
package/lib/command.d.ts
CHANGED
|
@@ -117,13 +117,28 @@ export declare abstract class Command {
|
|
|
117
117
|
abstract run(): Promise<any>;
|
|
118
118
|
}
|
|
119
119
|
export declare namespace Command {
|
|
120
|
+
/**
|
|
121
|
+
* The Command class exported by a command file.
|
|
122
|
+
*/
|
|
120
123
|
type Class = typeof Command & {
|
|
121
124
|
id: string;
|
|
122
125
|
run(argv?: string[], config?: LoadOptions): Promise<any>;
|
|
123
126
|
};
|
|
124
|
-
|
|
127
|
+
/**
|
|
128
|
+
* A cached command that's had a `load` method attached to it.
|
|
129
|
+
*
|
|
130
|
+
* The `Plugin` class loads the commands from the manifest (if it exists) or requires and caches
|
|
131
|
+
* the commands directly from the commands directory inside the plugin. At this point the plugin
|
|
132
|
+
* is working with `Command.Cached`. It then appends a `load` method to each one. If the a command
|
|
133
|
+
* is executed then the `load` method is used to require the command class.
|
|
134
|
+
*/
|
|
135
|
+
type Loadable = Cached & {
|
|
125
136
|
load(): Promise<Command.Class>;
|
|
126
|
-
}
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* A cached version of the command. This is created by the cachedCommand utility and
|
|
140
|
+
* stored in the oclif.manifest.json.
|
|
141
|
+
*/
|
|
127
142
|
type Cached = {
|
|
128
143
|
[key: string]: unknown;
|
|
129
144
|
aliasPermutations?: string[];
|
|
@@ -131,6 +146,7 @@ export declare namespace Command {
|
|
|
131
146
|
args: {
|
|
132
147
|
[name: string]: Arg.Cached;
|
|
133
148
|
};
|
|
149
|
+
deprecateAliases?: boolean;
|
|
134
150
|
deprecationOptions?: Deprecation;
|
|
135
151
|
description?: string;
|
|
136
152
|
examples?: Example[];
|
package/lib/execute.d.ts
CHANGED
|
@@ -8,19 +8,23 @@ import { LoadOptions } from './interfaces';
|
|
|
8
8
|
* @example For ESM dev.js
|
|
9
9
|
* ```
|
|
10
10
|
* #!/usr/bin/env ts-node
|
|
11
|
-
*
|
|
11
|
+
* async function main() {
|
|
12
12
|
* const oclif = await import('@oclif/core')
|
|
13
13
|
* await oclif.execute({development: true, dir: import.meta.url})
|
|
14
|
-
* }
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* await main()
|
|
15
17
|
* ```
|
|
16
18
|
*
|
|
17
19
|
* @example For ESM run.js
|
|
18
20
|
* ```
|
|
19
21
|
* #!/usr/bin/env node
|
|
20
|
-
*
|
|
22
|
+
* async function main() {
|
|
21
23
|
* const oclif = await import('@oclif/core')
|
|
22
24
|
* await oclif.execute({dir: import.meta.url})
|
|
23
|
-
* }
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* await main()
|
|
24
28
|
* ```
|
|
25
29
|
*
|
|
26
30
|
* @example For CJS dev.js
|
package/lib/execute.js
CHANGED
|
@@ -14,19 +14,23 @@ const settings_1 = require("./settings");
|
|
|
14
14
|
* @example For ESM dev.js
|
|
15
15
|
* ```
|
|
16
16
|
* #!/usr/bin/env ts-node
|
|
17
|
-
*
|
|
17
|
+
* async function main() {
|
|
18
18
|
* const oclif = await import('@oclif/core')
|
|
19
19
|
* await oclif.execute({development: true, dir: import.meta.url})
|
|
20
|
-
* }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* await main()
|
|
21
23
|
* ```
|
|
22
24
|
*
|
|
23
25
|
* @example For ESM run.js
|
|
24
26
|
* ```
|
|
25
27
|
* #!/usr/bin/env node
|
|
26
|
-
*
|
|
28
|
+
* async function main() {
|
|
27
29
|
* const oclif = await import('@oclif/core')
|
|
28
30
|
* await oclif.execute({dir: import.meta.url})
|
|
29
|
-
* }
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* await main()
|
|
30
34
|
* ```
|
|
31
35
|
*
|
|
32
36
|
* @example For CJS dev.js
|
package/lib/flags.d.ts
CHANGED
|
@@ -76,31 +76,31 @@ export declare const string: FlagDefinition<string, CustomOptions, {
|
|
|
76
76
|
}>;
|
|
77
77
|
export declare const version: (opts?: Partial<BooleanFlag<boolean>>) => BooleanFlag<void>;
|
|
78
78
|
export declare const help: (opts?: Partial<BooleanFlag<boolean>>) => BooleanFlag<void>;
|
|
79
|
-
type
|
|
80
|
-
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<
|
|
79
|
+
type ReadonlyElementOf<T extends ReadonlyArray<unknown>> = T[number];
|
|
80
|
+
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>[], P>> & {
|
|
81
81
|
multiple: true;
|
|
82
82
|
options: T;
|
|
83
83
|
} & ({
|
|
84
|
-
default: OptionFlag<
|
|
84
|
+
default: OptionFlag<ReadonlyElementOf<T>[], P>['default'] | undefined;
|
|
85
85
|
} | {
|
|
86
86
|
required: true;
|
|
87
87
|
})): FlagDefinition<(typeof defaults.options)[number], P, {
|
|
88
88
|
multiple: true;
|
|
89
89
|
requiredOrDefaulted: true;
|
|
90
90
|
}>;
|
|
91
|
-
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<
|
|
91
|
+
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>, P>> & {
|
|
92
92
|
multiple?: false | undefined;
|
|
93
93
|
options: T;
|
|
94
94
|
} & ({
|
|
95
|
-
default: OptionFlag<
|
|
95
|
+
default: OptionFlag<ReadonlyElementOf<T>, P>['default'];
|
|
96
96
|
} | {
|
|
97
97
|
required: true;
|
|
98
98
|
})): FlagDefinition<(typeof defaults.options)[number], P, {
|
|
99
99
|
multiple: false;
|
|
100
100
|
requiredOrDefaulted: true;
|
|
101
101
|
}>;
|
|
102
|
-
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<
|
|
103
|
-
default?: OptionFlag<
|
|
102
|
+
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>, P>> & {
|
|
103
|
+
default?: OptionFlag<ReadonlyElementOf<T>, P>['default'] | undefined;
|
|
104
104
|
multiple?: false | undefined;
|
|
105
105
|
options: T;
|
|
106
106
|
required?: false | undefined;
|
|
@@ -108,8 +108,8 @@ export declare function option<T extends readonly string[], P extends CustomOpti
|
|
|
108
108
|
multiple: false;
|
|
109
109
|
requiredOrDefaulted: false;
|
|
110
110
|
}>;
|
|
111
|
-
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<
|
|
112
|
-
default?: OptionFlag<
|
|
111
|
+
export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>[], P>> & {
|
|
112
|
+
default?: OptionFlag<ReadonlyElementOf<T>[], P>['default'] | undefined;
|
|
113
113
|
multiple: true;
|
|
114
114
|
options: T;
|
|
115
115
|
required?: false | undefined;
|
package/lib/help/command.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Command } from '../command';
|
|
|
2
2
|
import * as Interfaces from '../interfaces';
|
|
3
3
|
import { HelpFormatter, HelpSectionRenderer } from './formatter';
|
|
4
4
|
export declare class CommandHelp extends HelpFormatter {
|
|
5
|
-
command: Command.
|
|
5
|
+
command: Command.Loadable;
|
|
6
6
|
config: Interfaces.Config;
|
|
7
7
|
opts: Interfaces.HelpOptions;
|
|
8
|
-
constructor(command: Command.
|
|
8
|
+
constructor(command: Command.Loadable, config: Interfaces.Config, opts: Interfaces.HelpOptions);
|
|
9
9
|
private formatIfCommand;
|
|
10
10
|
private isCommand;
|
|
11
11
|
protected aliases(aliases: string[] | undefined): string | undefined;
|
package/lib/help/formatter.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type HelpSection = {
|
|
|
10
10
|
} | undefined;
|
|
11
11
|
export type HelpSectionRenderer = (data: {
|
|
12
12
|
args: Command.Arg.Any[];
|
|
13
|
-
cmd: Command.
|
|
13
|
+
cmd: Command.Loadable;
|
|
14
14
|
flags: Command.Flag.Any[];
|
|
15
15
|
}, header: string) => HelpSection | HelpSection[] | string | undefined;
|
|
16
16
|
export declare class HelpFormatter {
|
package/lib/help/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare abstract class HelpBase extends HelpFormatter {
|
|
|
11
11
|
* @param command
|
|
12
12
|
* @param topics
|
|
13
13
|
*/
|
|
14
|
-
abstract showCommandHelp(command: Command.
|
|
14
|
+
abstract showCommandHelp(command: Command.Loadable, topics: Interfaces.Topic[]): Promise<void>;
|
|
15
15
|
/**
|
|
16
16
|
* Show help, used in multi-command CLIs
|
|
17
17
|
* @param args passed into your command, useful for determining which type of help to display
|
|
@@ -22,20 +22,20 @@ export declare class Help extends HelpBase {
|
|
|
22
22
|
protected CommandHelpClass: typeof CommandHelp;
|
|
23
23
|
constructor(config: Interfaces.Config, opts?: Partial<Interfaces.HelpOptions>);
|
|
24
24
|
private get _topics();
|
|
25
|
-
protected command(command: Command.
|
|
26
|
-
protected description(c: Command.
|
|
27
|
-
protected formatCommand(command: Command.
|
|
28
|
-
protected formatCommands(commands: Array<Command.
|
|
25
|
+
protected command(command: Command.Loadable): string;
|
|
26
|
+
protected description(c: Command.Loadable): string;
|
|
27
|
+
protected formatCommand(command: Command.Loadable): string;
|
|
28
|
+
protected formatCommands(commands: Array<Command.Loadable>): string;
|
|
29
29
|
protected formatRoot(): string;
|
|
30
30
|
protected formatTopic(topic: Interfaces.Topic): string;
|
|
31
31
|
protected formatTopics(topics: Interfaces.Topic[]): string;
|
|
32
|
-
protected getCommandHelpClass(command: Command.
|
|
32
|
+
protected getCommandHelpClass(command: Command.Loadable): CommandHelp;
|
|
33
33
|
protected log(...args: string[]): void;
|
|
34
|
-
showCommandHelp(command: Command.
|
|
34
|
+
showCommandHelp(command: Command.Loadable): Promise<void>;
|
|
35
35
|
showHelp(argv: string[]): Promise<void>;
|
|
36
36
|
protected showRootHelp(): Promise<void>;
|
|
37
37
|
protected showTopicHelp(topic: Interfaces.Topic): Promise<void>;
|
|
38
|
-
protected summary(c: Command.
|
|
38
|
+
protected summary(c: Command.Loadable): string | undefined;
|
|
39
39
|
protected get sortedCommands(): Command.Loadable[];
|
|
40
40
|
protected get sortedTopics(): Interfaces.Topic[];
|
|
41
41
|
}
|
|
@@ -210,7 +210,8 @@ export type OptionFlagProps = FlagProps & {
|
|
|
210
210
|
export type FlagParserContext = Command & {
|
|
211
211
|
token: FlagToken;
|
|
212
212
|
};
|
|
213
|
-
|
|
213
|
+
type NonNullableElementOf<T> = [NonNullable<T>] extends [Array<infer U>] ? U : T;
|
|
214
|
+
export type FlagParser<T, I extends string | boolean, P = CustomOptions> = (input: I, context: FlagParserContext, opts: P & OptionFlag<T, P>) => Promise<NonNullableElementOf<T> | undefined>;
|
|
214
215
|
export type ArgParserContext = Command & {
|
|
215
216
|
token: ArgToken;
|
|
216
217
|
};
|
|
@@ -40,6 +40,11 @@ export declare namespace PJSON {
|
|
|
40
40
|
identifier?: string;
|
|
41
41
|
sign?: string;
|
|
42
42
|
};
|
|
43
|
+
windows?: {
|
|
44
|
+
homepage?: string;
|
|
45
|
+
keypath?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
};
|
|
43
48
|
plugins?: string[];
|
|
44
49
|
repositoryPrefix?: string;
|
|
45
50
|
schema?: number;
|
|
@@ -69,6 +74,7 @@ export declare namespace PJSON {
|
|
|
69
74
|
interface S3 {
|
|
70
75
|
acl?: string;
|
|
71
76
|
bucket?: string;
|
|
77
|
+
folder?: string;
|
|
72
78
|
gz?: boolean;
|
|
73
79
|
host?: string;
|
|
74
80
|
templates: {
|