@oclif/core 1.6.3 → 1.8.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/CHANGELOG.md +21 -0
- package/lib/config/config.d.ts +8 -8
- package/lib/config/config.js +2 -2
- package/lib/config/plugin.d.ts +1 -1
- package/lib/help/index.d.ts +2 -2
- package/lib/help/index.js +25 -33
- package/lib/interfaces/command.d.ts +8 -1
- package/lib/interfaces/config.d.ts +6 -6
- package/lib/interfaces/hooks.d.ts +1 -1
- package/lib/interfaces/plugin.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.8.0](https://github.com/oclif/core/compare/v1.7.0...v1.8.0) (2022-05-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* improve Command interface ([#416](https://github.com/oclif/core/issues/416)) ([ed625e1](https://github.com/oclif/core/commit/ed625e1554a09e578e645ddd7aa2ddb1b368c03f))
|
|
11
|
+
|
|
12
|
+
## [1.7.0](https://github.com/oclif/core/compare/v1.6.4...v1.7.0) (2022-04-11)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* move console.log to single class method ([#400](https://github.com/oclif/core/issues/400)) ([2ccb274](https://github.com/oclif/core/commit/2ccb2740912dba3b81c4d36712fbb20fd6a03c23))
|
|
18
|
+
|
|
19
|
+
### [1.6.4](https://github.com/oclif/core/compare/v1.6.3...v1.6.4) (2022-03-31)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* dynamic help ([#395](https://github.com/oclif/core/issues/395)) ([8ecc8f4](https://github.com/oclif/core/commit/8ecc8f41ec62ef5b05bdb70a79dce09b5913d14b))
|
|
25
|
+
|
|
5
26
|
### [1.6.3](https://github.com/oclif/core/compare/v1.6.2...v1.6.3) (2022-03-23)
|
|
6
27
|
|
|
7
28
|
|
package/lib/config/config.d.ts
CHANGED
|
@@ -43,16 +43,16 @@ export declare class Config implements IConfig {
|
|
|
43
43
|
loadDevPlugins(): Promise<void>;
|
|
44
44
|
loadUserPlugins(): Promise<void>;
|
|
45
45
|
runHook<T extends keyof Hooks>(event: T, opts: Hooks[T]['options'], timeout?: number): Promise<Hook.Result<Hooks[T]['return']>>;
|
|
46
|
-
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.
|
|
46
|
+
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable): Promise<T>;
|
|
47
47
|
scopedEnvVar(k: string): string | undefined;
|
|
48
48
|
scopedEnvVarTrue(k: string): boolean;
|
|
49
49
|
scopedEnvVarKey(k: string): string;
|
|
50
50
|
findCommand(id: string, opts: {
|
|
51
51
|
must: true;
|
|
52
|
-
}): Command.
|
|
52
|
+
}): Command.Loadable;
|
|
53
53
|
findCommand(id: string, opts?: {
|
|
54
54
|
must: boolean;
|
|
55
|
-
}): Command.
|
|
55
|
+
}): Command.Loadable | undefined;
|
|
56
56
|
findTopic(id: string, opts: {
|
|
57
57
|
must: true;
|
|
58
58
|
}): Topic;
|
|
@@ -72,18 +72,18 @@ export declare class Config implements IConfig {
|
|
|
72
72
|
* @param argv string[] process.argv containing the flags and arguments provided by the user
|
|
73
73
|
* @returns string[]
|
|
74
74
|
*/
|
|
75
|
-
findMatches(partialCmdId: string, argv: string[]): Command.
|
|
75
|
+
findMatches(partialCmdId: string, argv: string[]): Command.Loadable[];
|
|
76
76
|
/**
|
|
77
77
|
* Returns an array of all commands. If flexible taxonomy is enabled then all permutations will be appended to the array.
|
|
78
|
-
* @returns Command.
|
|
78
|
+
* @returns Command.Loadable[]
|
|
79
79
|
*/
|
|
80
|
-
getAllCommands(): Command.
|
|
80
|
+
getAllCommands(): Command.Loadable[];
|
|
81
81
|
/**
|
|
82
82
|
* Returns an array of all command ids. If flexible taxonomy is enabled then all permutations will be appended to the array.
|
|
83
83
|
* @returns string[]
|
|
84
84
|
*/
|
|
85
85
|
getAllCommandIDs(): string[];
|
|
86
|
-
get commands(): Command.
|
|
86
|
+
get commands(): Command.Loadable[];
|
|
87
87
|
get commandIDs(): string[];
|
|
88
88
|
get topics(): Topic[];
|
|
89
89
|
s3Key(type: keyof PJSON.S3.Templates, ext?: '.tar.gz' | '.tar.xz' | IConfig.s3Key.Options, options?: IConfig.s3Key.Options): string;
|
|
@@ -126,7 +126,7 @@ export declare class Config implements IConfig {
|
|
|
126
126
|
* plugin as discovered (will not change the order)
|
|
127
127
|
*
|
|
128
128
|
* @param commands commands to determine the priority of
|
|
129
|
-
* @returns command instance {Command.
|
|
129
|
+
* @returns command instance {Command.Loadable} or undefined
|
|
130
130
|
*/
|
|
131
131
|
private determinePriority;
|
|
132
132
|
}
|
package/lib/config/config.js
CHANGED
|
@@ -324,7 +324,7 @@ class Config {
|
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
326
|
* Returns an array of all commands. If flexible taxonomy is enabled then all permutations will be appended to the array.
|
|
327
|
-
* @returns Command.
|
|
327
|
+
* @returns Command.Loadable[]
|
|
328
328
|
*/
|
|
329
329
|
getAllCommands() {
|
|
330
330
|
const commands = [...this._commands.values()];
|
|
@@ -573,7 +573,7 @@ class Config {
|
|
|
573
573
|
* plugin as discovered (will not change the order)
|
|
574
574
|
*
|
|
575
575
|
* @param commands commands to determine the priority of
|
|
576
|
-
* @returns command instance {Command.
|
|
576
|
+
* @returns command instance {Command.Loadable} or undefined
|
|
577
577
|
*/
|
|
578
578
|
determinePriority(commands) {
|
|
579
579
|
var _a, _b;
|
package/lib/config/plugin.d.ts
CHANGED
package/lib/help/index.d.ts
CHANGED
|
@@ -20,11 +20,10 @@ export declare abstract class HelpBase extends HelpFormatter {
|
|
|
20
20
|
export declare class Help extends HelpBase {
|
|
21
21
|
protected CommandHelpClass: typeof CommandHelp;
|
|
22
22
|
private get _topics();
|
|
23
|
-
protected get sortedCommands(): Interfaces.Command.
|
|
23
|
+
protected get sortedCommands(): Interfaces.Command.Loadable[];
|
|
24
24
|
protected get sortedTopics(): Interfaces.Topic[];
|
|
25
25
|
constructor(config: Interfaces.Config, opts?: Partial<Interfaces.HelpOptions>);
|
|
26
26
|
showHelp(argv: string[]): Promise<void>;
|
|
27
|
-
private getDynamicCommand;
|
|
28
27
|
showCommandHelp(command: Interfaces.Command): Promise<void>;
|
|
29
28
|
protected showRootHelp(): Promise<void>;
|
|
30
29
|
protected showTopicHelp(topic: Interfaces.Topic): Promise<void>;
|
|
@@ -42,4 +41,5 @@ export declare class Help extends HelpBase {
|
|
|
42
41
|
* @return {string} the readme help string for the given command
|
|
43
42
|
*/
|
|
44
43
|
protected command(command: Interfaces.Command): string;
|
|
44
|
+
protected log(...args: string[]): void;
|
|
45
45
|
}
|
package/lib/help/index.js
CHANGED
|
@@ -8,7 +8,6 @@ const root_1 = require("./root");
|
|
|
8
8
|
const util_1 = require("../util");
|
|
9
9
|
const util_2 = require("./util");
|
|
10
10
|
const formatter_1 = require("./formatter");
|
|
11
|
-
const plugin_1 = require("../config/plugin");
|
|
12
11
|
const config_1 = require("../config/config");
|
|
13
12
|
var command_2 = require("./command");
|
|
14
13
|
Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return command_2.CommandHelp; } });
|
|
@@ -87,7 +86,7 @@ class Help extends HelpBase {
|
|
|
87
86
|
const command = this.config.findCommand(subject);
|
|
88
87
|
if (command) {
|
|
89
88
|
if (command.hasDynamicHelp) {
|
|
90
|
-
const dynamicCommand = await (0, config_1.toCached)(await
|
|
89
|
+
const dynamicCommand = await (0, config_1.toCached)(await command.load());
|
|
91
90
|
await this.showCommandHelp(dynamicCommand);
|
|
92
91
|
}
|
|
93
92
|
else {
|
|
@@ -110,16 +109,6 @@ class Help extends HelpBase {
|
|
|
110
109
|
}
|
|
111
110
|
(0, errors_1.error)(`Command ${subject} not found.`);
|
|
112
111
|
}
|
|
113
|
-
async getDynamicCommand(command) {
|
|
114
|
-
var _a;
|
|
115
|
-
const plugin = new plugin_1.Plugin({ ignoreManifest: true, root: this.config.root, name: (_a = command.pluginAlias) !== null && _a !== void 0 ? _a : command.pluginName });
|
|
116
|
-
await plugin.load();
|
|
117
|
-
const cmd = await plugin.findCommand(command.id);
|
|
118
|
-
if (!cmd) {
|
|
119
|
-
throw new Error(`Command ${command.id} not found.`);
|
|
120
|
-
}
|
|
121
|
-
return cmd;
|
|
122
|
-
}
|
|
123
112
|
async showCommandHelp(command) {
|
|
124
113
|
var _a, _b, _c, _d;
|
|
125
114
|
const name = command.id;
|
|
@@ -129,20 +118,20 @@ class Help extends HelpBase {
|
|
|
129
118
|
const plugin = this.config.plugins.find(p => p.name === command.pluginName);
|
|
130
119
|
const state = ((_b = (_a = this.config.pjson) === null || _a === void 0 ? void 0 : _a.oclif) === null || _b === void 0 ? void 0 : _b.state) || ((_d = (_c = plugin === null || plugin === void 0 ? void 0 : plugin.pjson) === null || _c === void 0 ? void 0 : _c.oclif) === null || _d === void 0 ? void 0 : _d.state) || command.state;
|
|
131
120
|
if (state)
|
|
132
|
-
|
|
121
|
+
this.log(`This command is in ${state}.\n`);
|
|
133
122
|
const summary = this.summary(command);
|
|
134
123
|
if (summary) {
|
|
135
|
-
|
|
124
|
+
this.log(summary + '\n');
|
|
136
125
|
}
|
|
137
|
-
|
|
138
|
-
|
|
126
|
+
this.log(this.formatCommand(command));
|
|
127
|
+
this.log('');
|
|
139
128
|
if (subTopics.length > 0) {
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
this.log(this.formatTopics(subTopics));
|
|
130
|
+
this.log('');
|
|
142
131
|
}
|
|
143
132
|
if (subCommands.length > 0) {
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
this.log(this.formatCommands(subCommands));
|
|
134
|
+
this.log('');
|
|
146
135
|
}
|
|
147
136
|
}
|
|
148
137
|
async showRootHelp() {
|
|
@@ -151,21 +140,21 @@ class Help extends HelpBase {
|
|
|
151
140
|
let rootCommands = this.sortedCommands;
|
|
152
141
|
const state = (_b = (_a = this.config.pjson) === null || _a === void 0 ? void 0 : _a.oclif) === null || _b === void 0 ? void 0 : _b.state;
|
|
153
142
|
if (state)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
this.log(`${this.config.bin} is in ${state}.\n`);
|
|
144
|
+
this.log(this.formatRoot());
|
|
145
|
+
this.log('');
|
|
157
146
|
if (!this.opts.all) {
|
|
158
147
|
rootTopics = rootTopics.filter(t => !t.name.includes(':'));
|
|
159
148
|
rootCommands = rootCommands.filter(c => !c.id.includes(':'));
|
|
160
149
|
}
|
|
161
150
|
if (rootTopics.length > 0) {
|
|
162
|
-
|
|
163
|
-
|
|
151
|
+
this.log(this.formatTopics(rootTopics));
|
|
152
|
+
this.log('');
|
|
164
153
|
}
|
|
165
154
|
if (rootCommands.length > 0) {
|
|
166
155
|
rootCommands = rootCommands.filter(c => c.id);
|
|
167
|
-
|
|
168
|
-
|
|
156
|
+
this.log(this.formatCommands(rootCommands));
|
|
157
|
+
this.log('');
|
|
169
158
|
}
|
|
170
159
|
}
|
|
171
160
|
async showTopicHelp(topic) {
|
|
@@ -176,15 +165,15 @@ class Help extends HelpBase {
|
|
|
176
165
|
const commands = this.sortedCommands.filter(c => c.id.startsWith(name + ':') && c.id.split(':').length === depth + 1);
|
|
177
166
|
const state = (_b = (_a = this.config.pjson) === null || _a === void 0 ? void 0 : _a.oclif) === null || _b === void 0 ? void 0 : _b.state;
|
|
178
167
|
if (state)
|
|
179
|
-
|
|
180
|
-
|
|
168
|
+
this.log(`This topic is in ${state}.\n`);
|
|
169
|
+
this.log(this.formatTopic(topic));
|
|
181
170
|
if (subTopics.length > 0) {
|
|
182
|
-
|
|
183
|
-
|
|
171
|
+
this.log(this.formatTopics(subTopics));
|
|
172
|
+
this.log('');
|
|
184
173
|
}
|
|
185
174
|
if (commands.length > 0) {
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
this.log(this.formatCommands(commands));
|
|
176
|
+
this.log('');
|
|
188
177
|
}
|
|
189
178
|
}
|
|
190
179
|
formatRoot() {
|
|
@@ -272,5 +261,8 @@ class Help extends HelpBase {
|
|
|
272
261
|
command(command) {
|
|
273
262
|
return this.formatCommand(command);
|
|
274
263
|
}
|
|
264
|
+
log(...args) {
|
|
265
|
+
console.log(...args);
|
|
266
|
+
}
|
|
275
267
|
}
|
|
276
268
|
exports.Help = Help;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config, LoadOptions } from './config';
|
|
2
2
|
import { ArgInput, BooleanFlagProps, FlagInput, OptionFlagProps } from './parser';
|
|
3
|
+
import { Plugin as IPlugin } from './plugin';
|
|
3
4
|
export declare type Example = string | {
|
|
4
5
|
description: string;
|
|
5
6
|
command: string;
|
|
@@ -78,7 +79,7 @@ export declare namespace Command {
|
|
|
78
79
|
_base: string;
|
|
79
80
|
}
|
|
80
81
|
interface Class extends Base {
|
|
81
|
-
plugin?:
|
|
82
|
+
plugin?: IPlugin;
|
|
82
83
|
flags?: FlagInput<any>;
|
|
83
84
|
args?: ArgInput;
|
|
84
85
|
strict: boolean;
|
|
@@ -89,6 +90,12 @@ export declare namespace Command {
|
|
|
89
90
|
interface Instance {
|
|
90
91
|
_run(argv: string[]): Promise<any>;
|
|
91
92
|
}
|
|
93
|
+
interface Loadable extends Command {
|
|
94
|
+
load(): Promise<Class>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated use Command.Loadable instead.
|
|
98
|
+
*/
|
|
92
99
|
interface Plugin extends Command {
|
|
93
100
|
load(): Promise<Class>;
|
|
94
101
|
}
|
|
@@ -88,27 +88,27 @@ export interface Config {
|
|
|
88
88
|
valid: boolean;
|
|
89
89
|
flexibleTaxonomy?: boolean;
|
|
90
90
|
topicSeparator: ':' | ' ';
|
|
91
|
-
readonly commands: Command.
|
|
91
|
+
readonly commands: Command.Loadable[];
|
|
92
92
|
readonly topics: Topic[];
|
|
93
93
|
readonly commandIDs: string[];
|
|
94
94
|
runCommand<T = unknown>(id: string, argv?: string[]): Promise<T>;
|
|
95
|
-
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.
|
|
95
|
+
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable): Promise<T>;
|
|
96
96
|
runHook<T extends keyof Hooks>(event: T, opts: Hooks[T]['options'], timeout?: number): Promise<Hook.Result<Hooks[T]['return']>>;
|
|
97
97
|
getAllCommandIDs(): string[];
|
|
98
|
-
getAllCommands(): Command.
|
|
98
|
+
getAllCommands(): Command.Loadable[];
|
|
99
99
|
findCommand(id: string, opts: {
|
|
100
100
|
must: true;
|
|
101
|
-
}): Command.
|
|
101
|
+
}): Command.Loadable;
|
|
102
102
|
findCommand(id: string, opts?: {
|
|
103
103
|
must: boolean;
|
|
104
|
-
}): Command.
|
|
104
|
+
}): Command.Loadable | undefined;
|
|
105
105
|
findTopic(id: string, opts: {
|
|
106
106
|
must: true;
|
|
107
107
|
}): Topic;
|
|
108
108
|
findTopic(id: string, opts?: {
|
|
109
109
|
must: boolean;
|
|
110
110
|
}): Topic | undefined;
|
|
111
|
-
findMatches(id: string, argv: string[]): Command.
|
|
111
|
+
findMatches(id: string, argv: string[]): Command.Loadable[];
|
|
112
112
|
scopedEnvVar(key: string): string | undefined;
|
|
113
113
|
scopedEnvVarKey(key: string): string;
|
|
114
114
|
scopedEnvVarTrue(key: string): boolean;
|
|
@@ -60,7 +60,7 @@ export interface Plugin {
|
|
|
60
60
|
* if it appears to be an npm package but does not look like it's really a CLI plugin, this is set to false
|
|
61
61
|
*/
|
|
62
62
|
valid: boolean;
|
|
63
|
-
commands: Command.
|
|
63
|
+
commands: Command.Loadable[];
|
|
64
64
|
hooks: {
|
|
65
65
|
[k: string]: string[];
|
|
66
66
|
};
|
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.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"chalk": "^4.1.2",
|
|
14
14
|
"clean-stack": "^3.0.1",
|
|
15
15
|
"cli-progress": "^3.10.0",
|
|
16
|
-
"debug": "^4.3.
|
|
16
|
+
"debug": "^4.3.4",
|
|
17
17
|
"ejs": "^3.1.6",
|
|
18
18
|
"fs-extra": "^9.1.0",
|
|
19
19
|
"get-package-type": "^0.1.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@types/fs-extra": "^9.0.13",
|
|
50
50
|
"@types/indent-string": "^4.0.1",
|
|
51
51
|
"@types/js-yaml": "^3.12.7",
|
|
52
|
-
"@types/lodash": "^4.14.
|
|
52
|
+
"@types/lodash": "^4.14.182",
|
|
53
53
|
"@types/mocha": "^8.2.3",
|
|
54
54
|
"@types/nock": "^11.1.0",
|
|
55
55
|
"@types/node": "^15.14.9",
|