@oclif/core 3.0.0-beta.1 → 3.0.0-beta.3
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 +9 -7
- package/lib/command.d.ts +2 -0
- package/lib/command.js +4 -4
- package/lib/config/config.d.ts +9 -12
- package/lib/config/config.js +90 -137
- package/lib/config/index.d.ts +2 -1
- package/lib/config/index.js +2 -1
- package/lib/config/plugin-loader.d.ts +30 -0
- package/lib/config/plugin-loader.js +129 -0
- package/lib/config/plugin.d.ts +5 -10
- package/lib/config/plugin.js +21 -17
- package/lib/config/ts-node.d.ts +3 -2
- package/lib/config/ts-node.js +83 -36
- package/lib/errors/config.js +5 -5
- package/lib/errors/errors/cli.d.ts +1 -0
- package/lib/errors/errors/cli.js +1 -0
- package/lib/errors/handle.d.ts +2 -2
- package/lib/errors/handle.js +4 -5
- package/lib/errors/index.d.ts +2 -1
- package/lib/errors/index.js +9 -2
- package/lib/errors/logger.js +3 -3
- package/lib/execute.d.ts +49 -0
- package/lib/execute.js +62 -0
- package/lib/flags.js +6 -4
- package/lib/help/index.js +3 -3
- package/lib/index.d.ts +9 -7
- package/lib/index.js +13 -19
- package/lib/interfaces/config.d.ts +26 -26
- package/lib/interfaces/parser.d.ts +14 -66
- package/lib/interfaces/pjson.d.ts +2 -0
- package/lib/interfaces/plugin.d.ts +8 -1
- package/lib/interfaces/ts-config.d.ts +9 -0
- package/lib/main.d.ts +1 -54
- package/lib/main.js +11 -73
- package/lib/module-loader.d.ts +1 -2
- package/lib/module-loader.js +9 -9
- package/lib/parser/errors.js +1 -1
- package/lib/parser/parse.js +1 -34
- package/lib/performance.d.ts +1 -1
- package/lib/performance.js +2 -3
- package/lib/screen.js +2 -2
- package/lib/settings.d.ts +2 -1
- package/lib/settings.js +2 -2
- package/lib/{cli-ux → ux}/action/base.js +2 -2
- package/lib/{cli-ux → ux}/action/spinner.js +1 -1
- package/lib/{cli-ux → ux}/config.d.ts +0 -1
- package/lib/{cli-ux → ux}/config.js +6 -10
- package/lib/{cli-ux → ux}/exit.d.ts +1 -1
- package/lib/{cli-ux → ux}/exit.js +1 -1
- package/lib/ux/flush.d.ts +1 -0
- package/lib/ux/flush.js +27 -0
- package/lib/{cli-ux → ux}/index.d.ts +8 -27
- package/lib/{cli-ux → ux}/index.js +21 -80
- package/lib/{cli-ux → ux}/prompt.js +2 -2
- package/lib/{cli-ux → ux}/styled/json.js +3 -3
- package/package.json +24 -19
- package/flush.d.ts +0 -3
- package/flush.js +0 -1
- package/handle.js +0 -1
- package/lib/cli-ux/action/pride-spinner.d.ts +0 -4
- package/lib/cli-ux/action/pride-spinner.js +0 -30
- /package/lib/{cli-ux → ux}/action/base.d.ts +0 -0
- /package/lib/{cli-ux → ux}/action/simple.d.ts +0 -0
- /package/lib/{cli-ux → ux}/action/simple.js +0 -0
- /package/lib/{cli-ux → ux}/action/spinner.d.ts +0 -0
- /package/lib/{cli-ux → ux}/action/spinners.d.ts +0 -0
- /package/lib/{cli-ux → ux}/action/spinners.js +0 -0
- /package/lib/{cli-ux → ux}/list.d.ts +0 -0
- /package/lib/{cli-ux → ux}/list.js +0 -0
- /package/lib/{cli-ux → ux}/prompt.d.ts +0 -0
- /package/lib/{cli-ux → ux}/stream.d.ts +0 -0
- /package/lib/{cli-ux → ux}/stream.js +0 -0
- /package/lib/{cli-ux → ux}/styled/index.d.ts +0 -0
- /package/lib/{cli-ux → ux}/styled/index.js +0 -0
- /package/lib/{cli-ux → ux}/styled/json.d.ts +0 -0
- /package/lib/{cli-ux → ux}/styled/object.d.ts +0 -0
- /package/lib/{cli-ux → ux}/styled/object.js +0 -0
- /package/lib/{cli-ux → ux}/styled/progress.d.ts +0 -0
- /package/lib/{cli-ux → ux}/styled/progress.js +0 -0
- /package/lib/{cli-ux → ux}/styled/table.d.ts +0 -0
- /package/lib/{cli-ux → ux}/styled/table.js +0 -0
- /package/lib/{cli-ux → ux}/styled/tree.d.ts +0 -0
- /package/lib/{cli-ux → ux}/styled/tree.js +0 -0
- /package/lib/{cli-ux → ux}/wait.d.ts +0 -0
- /package/lib/{cli-ux → ux}/wait.js +0 -0
package/lib/execute.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const settings_1 = require("./settings");
|
|
4
|
+
const flush_1 = require("./ux/flush");
|
|
5
|
+
const handle_1 = require("./errors/handle");
|
|
6
|
+
const main_1 = require("./main");
|
|
7
|
+
/**
|
|
8
|
+
* Load and run oclif CLI
|
|
9
|
+
*
|
|
10
|
+
* @param options - options to load the CLI
|
|
11
|
+
* @returns Promise<void>
|
|
12
|
+
*
|
|
13
|
+
* @example For ESM dev.js
|
|
14
|
+
* ```
|
|
15
|
+
* #!/usr/bin/env node
|
|
16
|
+
* void (async () => {
|
|
17
|
+
* const oclif = await import('@oclif/core')
|
|
18
|
+
* await oclif.execute({development: true, dir: import.meta.url})
|
|
19
|
+
* })()
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example For ESM run.js
|
|
23
|
+
* ```
|
|
24
|
+
* #!/usr/bin/env node
|
|
25
|
+
* void (async () => {
|
|
26
|
+
* const oclif = await import('@oclif/core')
|
|
27
|
+
* await oclif.execute({dir: import.meta.url})
|
|
28
|
+
* })()
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example For CJS dev.js
|
|
32
|
+
* ```
|
|
33
|
+
* #!/usr/bin/env node
|
|
34
|
+
* void (async () => {
|
|
35
|
+
* const oclif = await import('@oclif/core')
|
|
36
|
+
* await oclif.execute({development: true, dir: __dirname})
|
|
37
|
+
* })()
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example For CJS run.js
|
|
41
|
+
* ```
|
|
42
|
+
* #!/usr/bin/env node
|
|
43
|
+
* void (async () => {
|
|
44
|
+
* const oclif = await import('@oclif/core')
|
|
45
|
+
* await oclif.execute({dir: __dirname})
|
|
46
|
+
* })()
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async function execute(options) {
|
|
50
|
+
if (options.development) {
|
|
51
|
+
// In dev mode -> use ts-node and dev plugins
|
|
52
|
+
process.env.NODE_ENV = 'development';
|
|
53
|
+
settings_1.default.debug = true;
|
|
54
|
+
}
|
|
55
|
+
return (0, main_1.default)(options.args ?? process.argv.slice(2), options.loadOptions ?? options.dir)
|
|
56
|
+
.then(async (result) => {
|
|
57
|
+
(0, flush_1.default)();
|
|
58
|
+
return result;
|
|
59
|
+
})
|
|
60
|
+
.catch(async (error) => (0, handle_1.default)(error));
|
|
61
|
+
}
|
|
62
|
+
exports.default = execute;
|
package/lib/flags.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.help = exports.version = exports.string = exports.url = exports.file = e
|
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
const help_1 = require("./help");
|
|
6
6
|
const util_1 = require("./util");
|
|
7
|
+
const errors_1 = require("./errors");
|
|
7
8
|
function custom(defaults) {
|
|
8
9
|
return (options = {}) => {
|
|
9
10
|
return {
|
|
@@ -29,12 +30,12 @@ exports.boolean = boolean;
|
|
|
29
30
|
exports.integer = custom({
|
|
30
31
|
parse: async (input, _, opts) => {
|
|
31
32
|
if (!/^-?\d+$/.test(input))
|
|
32
|
-
throw new
|
|
33
|
+
throw new errors_1.CLIError(`Expected an integer but received: ${input}`);
|
|
33
34
|
const num = Number.parseInt(input, 10);
|
|
34
35
|
if (opts.min !== undefined && num < opts.min)
|
|
35
|
-
throw new
|
|
36
|
+
throw new errors_1.CLIError(`Expected an integer greater than or equal to ${opts.min} but received: ${input}`);
|
|
36
37
|
if (opts.max !== undefined && num > opts.max)
|
|
37
|
-
throw new
|
|
38
|
+
throw new errors_1.CLIError(`Expected an integer less than or equal to ${opts.max} but received: ${input}`);
|
|
38
39
|
return num;
|
|
39
40
|
},
|
|
40
41
|
});
|
|
@@ -84,7 +85,8 @@ const help = (opts = {}) => {
|
|
|
84
85
|
description: 'Show CLI help.',
|
|
85
86
|
...opts,
|
|
86
87
|
parse: async (_, cmd) => {
|
|
87
|
-
|
|
88
|
+
const Help = await (0, help_1.loadHelpClass)(cmd.config);
|
|
89
|
+
await new Help(cmd.config, cmd.config.pjson.helpOptions).showHelp(cmd.id ? [cmd.id, ...cmd.argv] : cmd.argv);
|
|
88
90
|
cmd.exit(0);
|
|
89
91
|
},
|
|
90
92
|
});
|
package/lib/help/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const util_1 = require("../util");
|
|
|
10
10
|
const util_2 = require("./util");
|
|
11
11
|
const formatter_1 = require("./formatter");
|
|
12
12
|
const config_1 = require("../config/config");
|
|
13
|
-
const stream_1 = require("../
|
|
13
|
+
const stream_1 = require("../ux/stream");
|
|
14
14
|
var command_2 = require("./command");
|
|
15
15
|
Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return command_2.CommandHelp; } });
|
|
16
16
|
var util_3 = require("./util");
|
|
@@ -91,7 +91,7 @@ class Help extends HelpBase {
|
|
|
91
91
|
const command = this.config.findCommand(subject);
|
|
92
92
|
if (command) {
|
|
93
93
|
if (command.hasDynamicHelp && command.pluginType !== 'jit') {
|
|
94
|
-
const dynamicCommand = await (0, config_1.toCached)(await command.load()
|
|
94
|
+
const dynamicCommand = await (0, config_1.toCached)(await command.load());
|
|
95
95
|
await this.showCommandHelp(dynamicCommand);
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
@@ -123,7 +123,7 @@ class Help extends HelpBase {
|
|
|
123
123
|
const depth = name.split(':').length;
|
|
124
124
|
const subTopics = this.sortedTopics.filter(t => t.name.startsWith(name + ':') && t.name.split(':').length === depth + 1);
|
|
125
125
|
const subCommands = this.sortedCommands.filter(c => c.id.startsWith(name + ':') && c.id.split(':').length === depth + 1);
|
|
126
|
-
const plugin = this.config.plugins.
|
|
126
|
+
const plugin = this.config.plugins.get(command.pluginName);
|
|
127
127
|
const state = this.config.pjson?.oclif?.state || plugin?.pjson?.oclif?.state || command.state;
|
|
128
128
|
if (state) {
|
|
129
129
|
this.log(state === 'deprecated' ?
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Command } from './command';
|
|
2
|
-
import
|
|
2
|
+
import run from './main';
|
|
3
|
+
import execute from './execute';
|
|
4
|
+
import handle from './errors/handle';
|
|
3
5
|
import { Config, Plugin, tsPath, toCached } from './config';
|
|
4
6
|
import * as Interfaces from './interfaces';
|
|
5
7
|
import * as Errors from './errors';
|
|
@@ -9,10 +11,10 @@ import { CommandHelp, HelpBase, Help, loadHelpClass } from './help';
|
|
|
9
11
|
import { toStandardizedId, toConfiguredId } from './help/util';
|
|
10
12
|
import * as Parser from './parser';
|
|
11
13
|
import { Hook } from './interfaces/hooks';
|
|
12
|
-
import
|
|
14
|
+
import settings, { Settings } from './settings';
|
|
13
15
|
import { HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable } from './help/formatter';
|
|
14
|
-
import
|
|
15
|
-
import { stderr, stdout } from './
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
export { Args, Command, CommandHelp, Config, Errors, Flags,
|
|
16
|
+
import ux from './ux';
|
|
17
|
+
import { stderr, stdout } from './ux/stream';
|
|
18
|
+
import Performance from './performance';
|
|
19
|
+
import flush from './ux/flush';
|
|
20
|
+
export { Args, Command, CommandHelp, Config, Errors, execute, Flags, flush, handle, Help, HelpBase, HelpSection, HelpSectionKeyValueTable, HelpSectionRenderer, Hook, Interfaces, loadHelpClass, Parser, Performance, Plugin, run, settings, Settings, stderr, stdout, toCached, toConfiguredId, toStandardizedId, tsPath, ux, };
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const semver = require("semver");
|
|
3
|
+
exports.ux = exports.tsPath = exports.toStandardizedId = exports.toConfiguredId = exports.toCached = exports.stdout = exports.stderr = exports.settings = exports.run = exports.Plugin = exports.Performance = exports.Parser = exports.loadHelpClass = exports.Interfaces = exports.HelpBase = exports.Help = exports.handle = exports.flush = exports.Flags = exports.execute = exports.Errors = exports.Config = exports.CommandHelp = exports.Command = exports.Args = void 0;
|
|
5
4
|
const command_1 = require("./command");
|
|
6
5
|
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return command_1.Command; } });
|
|
7
6
|
const main_1 = require("./main");
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
exports.run = main_1.default;
|
|
8
|
+
const execute_1 = require("./execute");
|
|
9
|
+
exports.execute = execute_1.default;
|
|
10
|
+
const handle_1 = require("./errors/handle");
|
|
11
|
+
exports.handle = handle_1.default;
|
|
10
12
|
const config_1 = require("./config");
|
|
11
13
|
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
|
|
12
14
|
Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return config_1.Plugin; } });
|
|
@@ -31,17 +33,16 @@ Object.defineProperty(exports, "toConfiguredId", { enumerable: true, get: functi
|
|
|
31
33
|
const Parser = require("./parser");
|
|
32
34
|
exports.Parser = Parser;
|
|
33
35
|
const settings_1 = require("./settings");
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
exports.ux =
|
|
37
|
-
const
|
|
38
|
-
const stream_1 = require("./cli-ux/stream");
|
|
36
|
+
exports.settings = settings_1.default;
|
|
37
|
+
const ux_1 = require("./ux");
|
|
38
|
+
exports.ux = ux_1.default;
|
|
39
|
+
const stream_1 = require("./ux/stream");
|
|
39
40
|
Object.defineProperty(exports, "stderr", { enumerable: true, get: function () { return stream_1.stderr; } });
|
|
40
41
|
Object.defineProperty(exports, "stdout", { enumerable: true, get: function () { return stream_1.stdout; } });
|
|
41
42
|
const performance_1 = require("./performance");
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
exports.flush =
|
|
43
|
+
exports.Performance = performance_1.default;
|
|
44
|
+
const flush_1 = require("./ux/flush");
|
|
45
|
+
exports.flush = flush_1.default;
|
|
45
46
|
function checkCWD() {
|
|
46
47
|
try {
|
|
47
48
|
process.cwd();
|
|
@@ -52,11 +53,4 @@ function checkCWD() {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
function checkNodeVersion() {
|
|
56
|
-
const pjson = (0, util_2.requireJson)(__dirname, '..', 'package.json');
|
|
57
|
-
if (!semver.satisfies(process.versions.node, pjson.engines.node)) {
|
|
58
|
-
stream_1.stderr.write(`WARNING\nWARNING Node version must be ${pjson.engines.node} to use this CLI\nWARNING Current node version: ${process.versions.node}\nWARNING\n`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
56
|
checkCWD();
|
|
62
|
-
checkNodeVersion();
|
|
@@ -21,91 +21,90 @@ export type VersionDetails = {
|
|
|
21
21
|
rootPath?: string;
|
|
22
22
|
};
|
|
23
23
|
export interface Config {
|
|
24
|
-
name: string;
|
|
25
|
-
version: string;
|
|
26
|
-
channel: string;
|
|
27
|
-
pjson: PJSON.CLI;
|
|
28
|
-
root: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly version: string;
|
|
26
|
+
readonly channel: string;
|
|
27
|
+
readonly pjson: PJSON.CLI;
|
|
28
|
+
readonly root: string;
|
|
29
29
|
/**
|
|
30
30
|
* process.arch
|
|
31
31
|
*/
|
|
32
|
-
arch: ArchTypes;
|
|
32
|
+
readonly arch: ArchTypes;
|
|
33
33
|
/**
|
|
34
34
|
* bin name of CLI command
|
|
35
35
|
*/
|
|
36
|
-
bin: string;
|
|
36
|
+
readonly bin: string;
|
|
37
37
|
/**
|
|
38
38
|
* cache directory to use for CLI
|
|
39
39
|
*
|
|
40
40
|
* example ~/Library/Caches/mycli or ~/.cache/mycli
|
|
41
41
|
*/
|
|
42
|
-
cacheDir: string;
|
|
42
|
+
readonly cacheDir: string;
|
|
43
43
|
/**
|
|
44
44
|
* config directory to use for CLI
|
|
45
45
|
*
|
|
46
46
|
* example: ~/.config/mycli
|
|
47
47
|
*/
|
|
48
|
-
configDir: string;
|
|
48
|
+
readonly configDir: string;
|
|
49
49
|
/**
|
|
50
50
|
* data directory to use for CLI
|
|
51
51
|
*
|
|
52
52
|
* example: ~/.local/share/mycli
|
|
53
53
|
*/
|
|
54
|
-
dataDir: string;
|
|
54
|
+
readonly dataDir: string;
|
|
55
55
|
/**
|
|
56
56
|
* base dirname to use in cacheDir/configDir/dataDir
|
|
57
57
|
*/
|
|
58
|
-
dirname: string;
|
|
58
|
+
readonly dirname: string;
|
|
59
59
|
/**
|
|
60
60
|
* points to a file that should be appended to for error logs
|
|
61
61
|
*
|
|
62
62
|
* example: ~/Library/Caches/mycli/error.log
|
|
63
63
|
*/
|
|
64
|
-
errlog: string;
|
|
64
|
+
readonly errlog: string;
|
|
65
65
|
/**
|
|
66
66
|
* path to home directory
|
|
67
67
|
*
|
|
68
68
|
* example: /home/myuser
|
|
69
69
|
*/
|
|
70
|
-
home: string;
|
|
70
|
+
readonly home: string;
|
|
71
71
|
/**
|
|
72
72
|
* process.platform
|
|
73
73
|
*/
|
|
74
|
-
platform: PlatformTypes;
|
|
74
|
+
readonly platform: PlatformTypes;
|
|
75
75
|
/**
|
|
76
76
|
* active shell
|
|
77
77
|
*/
|
|
78
|
-
shell: string;
|
|
78
|
+
readonly shell: string;
|
|
79
79
|
/**
|
|
80
80
|
* user agent to use for http calls
|
|
81
81
|
*
|
|
82
82
|
* example: mycli/1.2.3 (darwin-x64) node-9.0.0
|
|
83
83
|
*/
|
|
84
|
-
userAgent: string;
|
|
84
|
+
readonly userAgent: string;
|
|
85
85
|
/**
|
|
86
86
|
* if windows
|
|
87
87
|
*/
|
|
88
|
-
windows: boolean;
|
|
88
|
+
readonly windows: boolean;
|
|
89
89
|
/**
|
|
90
90
|
* debugging level
|
|
91
91
|
*
|
|
92
92
|
* set by ${BIN}_DEBUG or DEBUG=$BIN
|
|
93
93
|
*/
|
|
94
|
-
debug: number;
|
|
94
|
+
readonly debug: number;
|
|
95
95
|
/**
|
|
96
96
|
* npm registry to use for installing plugins
|
|
97
97
|
*/
|
|
98
|
-
npmRegistry?: string;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
binPath?: string;
|
|
98
|
+
readonly npmRegistry?: string;
|
|
99
|
+
readonly plugins: Map<string, Plugin>;
|
|
100
|
+
readonly binPath?: string;
|
|
102
101
|
/**
|
|
103
102
|
* name of any bin aliases that will execute the cli
|
|
104
103
|
*/
|
|
105
|
-
binAliases?: string[];
|
|
106
|
-
nsisCustomization?: string;
|
|
107
|
-
valid: boolean;
|
|
108
|
-
flexibleTaxonomy?: boolean;
|
|
104
|
+
readonly binAliases?: string[];
|
|
105
|
+
readonly nsisCustomization?: string;
|
|
106
|
+
readonly valid: boolean;
|
|
107
|
+
readonly flexibleTaxonomy?: boolean;
|
|
109
108
|
topicSeparator: ':' | ' ';
|
|
110
109
|
readonly commands: Command.Loadable[];
|
|
111
110
|
readonly topics: Topic[];
|
|
@@ -135,6 +134,7 @@ export interface Config {
|
|
|
135
134
|
s3Url(key: string): string;
|
|
136
135
|
s3Key(type: 'versioned' | 'unversioned', ext: '.tar.gz' | '.tar.xz', options?: Config.s3Key.Options): string;
|
|
137
136
|
s3Key(type: keyof PJSON.S3.Templates, options?: Config.s3Key.Options): string;
|
|
137
|
+
getPluginsList(): Plugin[];
|
|
138
138
|
}
|
|
139
139
|
export declare namespace Config {
|
|
140
140
|
namespace s3Key {
|
|
@@ -62,88 +62,26 @@ export type DefaultContext<T> = {
|
|
|
62
62
|
/**
|
|
63
63
|
* Type to define a default value for a flag.
|
|
64
64
|
* @param context The context of the flag.
|
|
65
|
-
* @param isWritingManifest Informs the function that a manifest file is being written.
|
|
66
|
-
* The manifest file is used to store the flag definitions, with a default value if present, for a command and is published to npm.
|
|
67
|
-
* When a manifest file is being written, the default value may contain data that should not be included in the manifest.
|
|
68
|
-
* The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
|
|
69
|
-
* in the function's implementation.
|
|
70
|
-
* @example
|
|
71
|
-
* static flags = {
|
|
72
|
-
* foo: flags.string({
|
|
73
|
-
* defaultHelp: async (context, isWritingManifest) => {
|
|
74
|
-
* if (isWritingManifest) {
|
|
75
|
-
* return undefined
|
|
76
|
-
* }
|
|
77
|
-
* return 'value that is used outside a manifest'
|
|
78
|
-
* },
|
|
79
|
-
* }),
|
|
80
|
-
* }
|
|
81
65
|
*/
|
|
82
|
-
export type FlagDefault<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P
|
|
66
|
+
export type FlagDefault<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P>>) => Promise<T>);
|
|
83
67
|
/**
|
|
84
68
|
* Type to define a defaultHelp value for a flag.
|
|
85
69
|
* The defaultHelp value is used in the help output for the flag and when writing a manifest.
|
|
86
70
|
* It is also can be used to provide a value for the flag when issuing certain error messages.
|
|
87
71
|
*
|
|
88
72
|
* @param context The context of the flag.
|
|
89
|
-
* @param isWritingManifest Informs the function that a manifest file is being written.
|
|
90
|
-
* The manifest file is used to store the flag definitions, with a default value if present via defaultHelp, for a command and is published to npm.
|
|
91
|
-
* When a manifest file is being written, the default value may contain data that should not be included in the manifest.
|
|
92
|
-
* The plugin developer can use isWritingManifest to determine if the defaultHelp value should be omitted from the manifest.
|
|
93
|
-
* in the function's implementation.
|
|
94
|
-
* @example
|
|
95
|
-
* static flags = {
|
|
96
|
-
* foo: flags.string({
|
|
97
|
-
* defaultHelp: async (context, isWritingManifest) => {
|
|
98
|
-
* if (isWritingManifest) {
|
|
99
|
-
* return undefined
|
|
100
|
-
* }
|
|
101
|
-
* return 'value that is used outside a manifest'
|
|
102
|
-
* },
|
|
103
|
-
* }),
|
|
104
|
-
* }
|
|
105
73
|
*/
|
|
106
|
-
export type FlagDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P
|
|
74
|
+
export type FlagDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P>>) => Promise<string | undefined>);
|
|
107
75
|
/**
|
|
108
76
|
* Type to define a default value for an arg.
|
|
109
77
|
* @param context The context of the arg.
|
|
110
|
-
* @param isWritingManifest Informs the function that a manifest file is being written.
|
|
111
|
-
* The manifest file is used to store the arg definitions, with a default value if present, for a command and is published to npm.
|
|
112
|
-
* When a manifest file is being written, the default value may contain data that should not be included in the manifest.
|
|
113
|
-
* The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
|
|
114
|
-
* in the function's implementation.
|
|
115
|
-
* @example
|
|
116
|
-
* public static readonly args = {
|
|
117
|
-
* one: Args.string({
|
|
118
|
-
* default: async (context, isWritingManifest) => {
|
|
119
|
-
* if (isWritingManifest) {
|
|
120
|
-
* return undefined
|
|
121
|
-
* }
|
|
122
|
-
* return 'value that is used outside a manifest'
|
|
123
|
-
* }),
|
|
124
|
-
* };
|
|
125
78
|
*/
|
|
126
|
-
export type ArgDefault<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P
|
|
79
|
+
export type ArgDefault<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P>>) => Promise<T>);
|
|
127
80
|
/**
|
|
128
81
|
* Type to define a defaultHelp value for an arg.
|
|
129
82
|
* @param context The context of the arg.
|
|
130
|
-
* @param isWritingManifest Informs the function that a manifest file is being written.
|
|
131
|
-
* The manifest file is used to store the arg definitions, with a default value if present via defaultHelp, for a command and is published to npm.
|
|
132
|
-
* When a manifest file is being written, the default value may contain data that should not be included in the manifest.
|
|
133
|
-
* The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
|
|
134
|
-
* in the function's implementation.
|
|
135
|
-
* @example
|
|
136
|
-
* public static readonly args = {
|
|
137
|
-
* one: Args.string({
|
|
138
|
-
* defaultHelp: async (context, isWritingManifest) => {
|
|
139
|
-
* if (isWritingManifest) {
|
|
140
|
-
* return undefined
|
|
141
|
-
* }
|
|
142
|
-
* return 'value that is used outside a manifest'
|
|
143
|
-
* }),
|
|
144
|
-
* };
|
|
145
83
|
*/
|
|
146
|
-
export type ArgDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P
|
|
84
|
+
export type ArgDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P>>) => Promise<string | undefined>);
|
|
147
85
|
export type FlagRelationship = string | {
|
|
148
86
|
name: string;
|
|
149
87
|
when: (flags: Record<string, unknown>) => Promise<boolean>;
|
|
@@ -226,6 +164,11 @@ export type FlagProps = {
|
|
|
226
164
|
* separate on spaces.
|
|
227
165
|
*/
|
|
228
166
|
delimiter?: ',';
|
|
167
|
+
/**
|
|
168
|
+
* If true, the value returned by defaultHelp will not be cached in the oclif.manifest.json.
|
|
169
|
+
* This is helpful if the default value contains sensitive data that shouldn't be published to npm.
|
|
170
|
+
*/
|
|
171
|
+
noCacheDefault?: boolean;
|
|
229
172
|
};
|
|
230
173
|
export type ArgProps = {
|
|
231
174
|
name: string;
|
|
@@ -245,6 +188,11 @@ export type ArgProps = {
|
|
|
245
188
|
required?: boolean;
|
|
246
189
|
options?: string[];
|
|
247
190
|
ignoreStdin?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* If true, the value returned by defaultHelp will not be cached in the oclif.manifest.json.
|
|
193
|
+
* This is helpful if the default value contains sensitive data that shouldn't be published to npm.
|
|
194
|
+
*/
|
|
195
|
+
noCacheDefault?: boolean;
|
|
248
196
|
};
|
|
249
197
|
export type BooleanFlagProps = FlagProps & {
|
|
250
198
|
type: 'boolean';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HelpOptions } from './help';
|
|
2
2
|
export interface PJSON {
|
|
3
3
|
[k: string]: any;
|
|
4
|
+
version: string;
|
|
4
5
|
dependencies?: {
|
|
5
6
|
[name: string]: string;
|
|
6
7
|
};
|
|
@@ -12,6 +13,7 @@ export interface PJSON {
|
|
|
12
13
|
bin?: string;
|
|
13
14
|
dirname?: string;
|
|
14
15
|
hooks?: Record<string, string | string[]>;
|
|
16
|
+
plugins?: string[];
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
export declare namespace PJSON {
|
|
@@ -8,8 +8,10 @@ export interface PluginOptions {
|
|
|
8
8
|
tag?: string;
|
|
9
9
|
ignoreManifest?: boolean;
|
|
10
10
|
errorOnManifestCreate?: boolean;
|
|
11
|
+
respectNoCacheDefault?: boolean;
|
|
11
12
|
parent?: Plugin;
|
|
12
13
|
children?: Plugin[];
|
|
14
|
+
flexibleTaxonomy?: boolean;
|
|
13
15
|
}
|
|
14
16
|
export interface Options extends PluginOptions {
|
|
15
17
|
devPlugins?: boolean;
|
|
@@ -18,6 +20,7 @@ export interface Options extends PluginOptions {
|
|
|
18
20
|
channel?: string;
|
|
19
21
|
version?: string;
|
|
20
22
|
enablePerf?: boolean;
|
|
23
|
+
plugins?: Map<string, Plugin>;
|
|
21
24
|
}
|
|
22
25
|
export interface Plugin {
|
|
23
26
|
/**
|
|
@@ -49,6 +52,10 @@ export interface Plugin {
|
|
|
49
52
|
* examples: core, link, user, dev
|
|
50
53
|
*/
|
|
51
54
|
type: string;
|
|
55
|
+
/**
|
|
56
|
+
* Plugin is written in ESM or CommonJS
|
|
57
|
+
*/
|
|
58
|
+
moduleType: 'module' | 'commonjs';
|
|
52
59
|
/**
|
|
53
60
|
* base path of plugin
|
|
54
61
|
*/
|
|
@@ -74,5 +81,5 @@ export interface Plugin {
|
|
|
74
81
|
findCommand(id: string, opts?: {
|
|
75
82
|
must: boolean;
|
|
76
83
|
}): Promise<Command.Class> | undefined;
|
|
77
|
-
load(
|
|
84
|
+
load(): Promise<void>;
|
|
78
85
|
}
|
|
@@ -7,5 +7,14 @@ export interface TSConfig {
|
|
|
7
7
|
esModuleInterop?: boolean;
|
|
8
8
|
experimentalDecorators?: boolean;
|
|
9
9
|
emitDecoratorMetadata?: boolean;
|
|
10
|
+
module?: string;
|
|
11
|
+
moduleResolution?: string;
|
|
12
|
+
sourceMap?: boolean;
|
|
13
|
+
jsx?: boolean;
|
|
14
|
+
};
|
|
15
|
+
'ts-node'?: {
|
|
16
|
+
esm?: boolean;
|
|
17
|
+
experimentalSpecifierResolution?: 'node' | 'explicit';
|
|
18
|
+
scope?: boolean;
|
|
10
19
|
};
|
|
11
20
|
}
|
package/lib/main.d.ts
CHANGED
|
@@ -2,57 +2,4 @@ import * as Interfaces from './interfaces';
|
|
|
2
2
|
import { Config } from './config';
|
|
3
3
|
export declare const helpAddition: (argv: string[], config: Interfaces.Config) => boolean;
|
|
4
4
|
export declare const versionAddition: (argv: string[], config?: Interfaces.Config) => boolean;
|
|
5
|
-
export
|
|
6
|
-
/**
|
|
7
|
-
* Load and run oclif CLI
|
|
8
|
-
*
|
|
9
|
-
* @param options - options to load the CLI
|
|
10
|
-
* @returns Promise<void>
|
|
11
|
-
*
|
|
12
|
-
* @example For ESM dev.js
|
|
13
|
-
* ```
|
|
14
|
-
* #!/usr/bin/env ts-node
|
|
15
|
-
* // eslint-disable-next-line node/shebang
|
|
16
|
-
* (async () => {
|
|
17
|
-
* const oclif = await import('@oclif/core')
|
|
18
|
-
* await oclif.execute({type: 'esm', development: true, dir: import.meta.url})
|
|
19
|
-
* })()
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @example For ESM run.js
|
|
23
|
-
* ```
|
|
24
|
-
* #!/usr/bin/env node
|
|
25
|
-
* // eslint-disable-next-line node/shebang
|
|
26
|
-
* (async () => {
|
|
27
|
-
* const oclif = await import('@oclif/core')
|
|
28
|
-
* await oclif.execute({type: 'esm', dir: import.meta.url})
|
|
29
|
-
* })()
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @example For CJS dev.js
|
|
33
|
-
* ```
|
|
34
|
-
* #!/usr/bin/env node
|
|
35
|
-
* // eslint-disable-next-line node/shebang
|
|
36
|
-
* (async () => {
|
|
37
|
-
* const oclif = await import('@oclif/core')
|
|
38
|
-
* await oclif.execute({type: 'cjs', development: true, dir: __dirname})
|
|
39
|
-
* })()
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @example For CJS run.js
|
|
43
|
-
* ```
|
|
44
|
-
* #!/usr/bin/env node
|
|
45
|
-
* // eslint-disable-next-line node/shebang
|
|
46
|
-
* (async () => {
|
|
47
|
-
* const oclif = await import('@oclif/core')
|
|
48
|
-
* await oclif.execute({type: 'cjs', dir: import.meta.url})
|
|
49
|
-
* })()
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function execute(options: {
|
|
53
|
-
type: 'cjs' | 'esm';
|
|
54
|
-
dir: string;
|
|
55
|
-
args?: string[];
|
|
56
|
-
loadOptions?: Interfaces.LoadOptions;
|
|
57
|
-
development?: boolean;
|
|
58
|
-
}): Promise<void>;
|
|
5
|
+
export default function run(argv?: string[], options?: Interfaces.LoadOptions): Promise<unknown>;
|