@oclif/core 3.0.0-beta.18 → 3.0.0-beta.19
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/args.js +4 -4
- package/lib/cli-ux/action/base.js +1 -0
- package/lib/cli-ux/action/spinner.js +3 -5
- package/lib/cli-ux/action/spinners.js +1 -1
- package/lib/cli-ux/config.js +7 -6
- package/lib/cli-ux/flush.js +2 -2
- package/lib/cli-ux/index.js +1 -1
- package/lib/cli-ux/list.js +3 -3
- package/lib/cli-ux/prompt.js +8 -3
- package/lib/cli-ux/styled/object.js +2 -2
- package/lib/cli-ux/styled/table.js +23 -20
- package/lib/cli-ux/wait.js +1 -1
- package/lib/command.js +9 -9
- package/lib/config/config.d.ts +8 -8
- package/lib/config/config.js +45 -39
- package/lib/config/plugin-loader.js +7 -7
- package/lib/config/plugin.js +26 -23
- package/lib/config/ts-node.js +8 -10
- package/lib/config/util.js +2 -2
- package/lib/errors/errors/cli.js +1 -0
- package/lib/errors/errors/pretty-print.js +2 -1
- package/lib/errors/handle.js +2 -1
- package/lib/errors/logger.js +2 -2
- package/lib/flags.d.ts +4 -4
- package/lib/flags.js +3 -3
- package/lib/help/command.js +43 -32
- package/lib/help/docopts.js +5 -5
- package/lib/help/formatter.js +7 -7
- package/lib/help/index.js +39 -42
- package/lib/help/root.js +2 -7
- package/lib/help/util.js +1 -1
- package/lib/interfaces/hooks.d.ts +3 -3
- package/lib/interfaces/index.d.ts +1 -1
- package/lib/interfaces/parser.d.ts +15 -15
- package/lib/interfaces/pjson.d.ts +1 -1
- package/lib/module-loader.d.ts +8 -8
- package/lib/module-loader.js +12 -9
- package/lib/parser/errors.d.ts +1 -1
- package/lib/parser/errors.js +9 -9
- package/lib/parser/help.js +2 -3
- package/lib/parser/parse.js +64 -43
- package/lib/parser/validate.js +37 -21
- package/lib/performance.js +9 -6
- package/lib/util/aggregate-flags.js +1 -3
- package/lib/util/cache-command.js +28 -20
- package/lib/util/index.js +4 -6
- package/package.json +13 -11
|
@@ -9,11 +9,13 @@ const cache_default_value_1 = require("./cache-default-value");
|
|
|
9
9
|
// and flags as well as add in the json flag if enableJsonFlag is enabled.
|
|
10
10
|
function mergePrototype(result, cmd) {
|
|
11
11
|
const proto = Object.getPrototypeOf(cmd);
|
|
12
|
-
const filteredProto = (0, index_1.pickBy)(proto, v => v !== undefined);
|
|
12
|
+
const filteredProto = (0, index_1.pickBy)(proto, (v) => v !== undefined);
|
|
13
13
|
return Object.keys(proto).length > 0 ? mergePrototype({ ...filteredProto, ...result }, proto) : result;
|
|
14
14
|
}
|
|
15
15
|
async function cacheFlags(cmdFlags, respectNoCacheDefault) {
|
|
16
|
-
const promises = Object.entries(cmdFlags).map(async ([name, flag]) =>
|
|
16
|
+
const promises = Object.entries(cmdFlags).map(async ([name, flag]) => [
|
|
17
|
+
name,
|
|
18
|
+
{
|
|
17
19
|
name,
|
|
18
20
|
char: flag.char,
|
|
19
21
|
summary: flag.summary,
|
|
@@ -30,23 +32,28 @@ async function cacheFlags(cmdFlags, respectNoCacheDefault) {
|
|
|
30
32
|
aliases: flag.aliases,
|
|
31
33
|
charAliases: flag.charAliases,
|
|
32
34
|
noCacheDefault: flag.noCacheDefault,
|
|
33
|
-
...flag.type === 'boolean'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
...(flag.type === 'boolean'
|
|
36
|
+
? {
|
|
37
|
+
allowNo: flag.allowNo,
|
|
38
|
+
type: flag.type,
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
type: flag.type,
|
|
42
|
+
helpValue: flag.helpValue,
|
|
43
|
+
multiple: flag.multiple,
|
|
44
|
+
options: flag.options,
|
|
45
|
+
delimiter: flag.delimiter,
|
|
46
|
+
default: await (0, cache_default_value_1.cacheDefaultValue)(flag, respectNoCacheDefault),
|
|
47
|
+
hasDynamicHelp: typeof flag.defaultHelp === 'function',
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
46
51
|
return Object.fromEntries(await Promise.all(promises));
|
|
47
52
|
}
|
|
48
53
|
async function cacheArgs(cmdArgs, respectNoCacheDefault) {
|
|
49
|
-
const promises = Object.entries(cmdArgs).map(async ([name, arg]) =>
|
|
54
|
+
const promises = Object.entries(cmdArgs).map(async ([name, arg]) => [
|
|
55
|
+
name,
|
|
56
|
+
{
|
|
50
57
|
name,
|
|
51
58
|
description: arg.description,
|
|
52
59
|
required: arg.required,
|
|
@@ -54,7 +61,8 @@ async function cacheArgs(cmdArgs, respectNoCacheDefault) {
|
|
|
54
61
|
default: await (0, cache_default_value_1.cacheDefaultValue)(arg, respectNoCacheDefault),
|
|
55
62
|
hidden: arg.hidden,
|
|
56
63
|
noCacheDefault: arg.noCacheDefault,
|
|
57
|
-
}
|
|
64
|
+
},
|
|
65
|
+
]);
|
|
58
66
|
return Object.fromEntries(await Promise.all(promises));
|
|
59
67
|
}
|
|
60
68
|
async function cacheCommand(uncachedCmd, plugin, respectNoCacheDefault = false) {
|
|
@@ -78,7 +86,7 @@ async function cacheCommand(uncachedCmd, plugin, respectNoCacheDefault = false)
|
|
|
78
86
|
deprecateAliases: cmd.deprecateAliases,
|
|
79
87
|
flags,
|
|
80
88
|
args,
|
|
81
|
-
hasDynamicHelp: Object.values(flags).some(f => f.hasDynamicHelp),
|
|
89
|
+
hasDynamicHelp: Object.values(flags).some((f) => f.hasDynamicHelp),
|
|
82
90
|
};
|
|
83
91
|
// do not include these properties in manifest
|
|
84
92
|
const ignoreCommandProperties = [
|
|
@@ -93,8 +101,8 @@ async function cacheCommand(uncachedCmd, plugin, respectNoCacheDefault = false)
|
|
|
93
101
|
];
|
|
94
102
|
// Add in any additional properties that are not standard command properties.
|
|
95
103
|
const stdKeysAndIgnored = new Set([...Object.keys(stdProperties), ...ignoreCommandProperties]);
|
|
96
|
-
const keysToAdd = Object.keys(cmd).filter(property => !stdKeysAndIgnored.has(property));
|
|
97
|
-
const additionalProperties = Object.fromEntries(keysToAdd.map(key => [key, cmd[key]]));
|
|
104
|
+
const keysToAdd = Object.keys(cmd).filter((property) => !stdKeysAndIgnored.has(property));
|
|
105
|
+
const additionalProperties = Object.fromEntries(keysToAdd.map((key) => [key, cmd[key]]));
|
|
98
106
|
return { ...stdProperties, ...additionalProperties };
|
|
99
107
|
}
|
|
100
108
|
exports.cacheCommand = cacheCommand;
|
package/lib/util/index.js
CHANGED
|
@@ -7,8 +7,7 @@ const node_path_1 = require("node:path");
|
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
8
|
const debug = require('debug');
|
|
9
9
|
function pickBy(obj, fn) {
|
|
10
|
-
return Object.entries(obj)
|
|
11
|
-
.reduce((o, [k, v]) => {
|
|
10
|
+
return Object.entries(obj).reduce((o, [k, v]) => {
|
|
12
11
|
if (fn(v))
|
|
13
12
|
o[k] = v;
|
|
14
13
|
return o;
|
|
@@ -94,7 +93,7 @@ async function exists(path) {
|
|
|
94
93
|
}
|
|
95
94
|
exports.exists = exists;
|
|
96
95
|
const dirExists = async (input) => {
|
|
97
|
-
if (!await exists(input)) {
|
|
96
|
+
if (!(await exists(input))) {
|
|
98
97
|
throw new Error(`No directory found at ${input}`);
|
|
99
98
|
}
|
|
100
99
|
const fileStat = await (0, promises_1.stat)(input);
|
|
@@ -105,7 +104,7 @@ const dirExists = async (input) => {
|
|
|
105
104
|
};
|
|
106
105
|
exports.dirExists = dirExists;
|
|
107
106
|
const fileExists = async (input) => {
|
|
108
|
-
if (!await exists(input)) {
|
|
107
|
+
if (!(await exists(input))) {
|
|
109
108
|
throw new Error(`No file found at ${input}`);
|
|
110
109
|
}
|
|
111
110
|
const fileStat = await (0, promises_1.stat)(input);
|
|
@@ -178,8 +177,7 @@ function readJsonSync(path, parse = true) {
|
|
|
178
177
|
}
|
|
179
178
|
exports.readJsonSync = readJsonSync;
|
|
180
179
|
function mapValues(obj, fn) {
|
|
181
|
-
return Object.entries(obj)
|
|
182
|
-
.reduce((o, [k, v]) => {
|
|
180
|
+
return Object.entries(obj).reduce((o, [k, v]) => {
|
|
183
181
|
o[k] = fn(v, k);
|
|
184
182
|
return o;
|
|
185
183
|
}, {});
|
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": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.19",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"wrap-ansi": "^7.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@commitlint/config-conventional": "^
|
|
36
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
37
37
|
"@oclif/plugin-help": "^5.2.8",
|
|
38
38
|
"@oclif/plugin-plugins": "^3.3.0",
|
|
39
|
-
"@oclif/prettier-config": "^0.
|
|
40
|
-
"@oclif/test": "^3.0.
|
|
39
|
+
"@oclif/prettier-config": "^0.2.1",
|
|
40
|
+
"@oclif/test": "^3.0.1",
|
|
41
41
|
"@types/ansi-styles": "^3.2.1",
|
|
42
42
|
"@types/benchmark": "^2.1.2",
|
|
43
43
|
"@types/chai": "^4.3.4",
|
|
@@ -46,8 +46,7 @@
|
|
|
46
46
|
"@types/ejs": "^3.1.2",
|
|
47
47
|
"@types/indent-string": "^4.0.1",
|
|
48
48
|
"@types/js-yaml": "^3.12.7",
|
|
49
|
-
"@types/mocha": "^
|
|
50
|
-
"@types/nock": "^11.1.0",
|
|
49
|
+
"@types/mocha": "^10.0.2",
|
|
51
50
|
"@types/node": "^18",
|
|
52
51
|
"@types/node-notifier": "^8.0.2",
|
|
53
52
|
"@types/slice-ansi": "^4.0.0",
|
|
@@ -58,22 +57,24 @@
|
|
|
58
57
|
"benchmark": "^2.1.4",
|
|
59
58
|
"chai": "^4.3.7",
|
|
60
59
|
"chai-as-promised": "^7.1.1",
|
|
61
|
-
"commitlint": "^
|
|
60
|
+
"commitlint": "^17.7.2",
|
|
62
61
|
"cross-env": "^7.0.3",
|
|
63
62
|
"eslint": "^8.49.0",
|
|
64
63
|
"eslint-config-oclif": "^5.0.0",
|
|
65
64
|
"eslint-config-oclif-typescript": "^2.0.1",
|
|
66
|
-
"
|
|
65
|
+
"eslint-config-prettier": "^9.0.0",
|
|
66
|
+
"fancy-test": "^3.0.1",
|
|
67
67
|
"globby": "^11.1.0",
|
|
68
|
-
"husky": "
|
|
68
|
+
"husky": "^8",
|
|
69
|
+
"lint-staged": "^14.0.1",
|
|
69
70
|
"madge": "^6.1.0",
|
|
70
71
|
"mocha": "^10.2.0",
|
|
71
|
-
"nock": "^13.3.0",
|
|
72
72
|
"nyc": "^15.1.0",
|
|
73
|
+
"prettier": "^3.0.3",
|
|
73
74
|
"shx": "^0.3.4",
|
|
74
75
|
"sinon": "^11.1.2",
|
|
75
|
-
"tsd": "^0.29.0",
|
|
76
76
|
"ts-node": "^10.9.1",
|
|
77
|
+
"tsd": "^0.29.0",
|
|
77
78
|
"tslib": "^2.5.0",
|
|
78
79
|
"typescript": "^5"
|
|
79
80
|
},
|
|
@@ -107,6 +108,7 @@
|
|
|
107
108
|
"build": "shx rm -rf lib && tsc",
|
|
108
109
|
"commitlint": "commitlint",
|
|
109
110
|
"compile": "tsc",
|
|
111
|
+
"format": "prettier --write \"+(src|test)/**/*.+(ts|js|json)\"",
|
|
110
112
|
"lint": "eslint . --ext .ts",
|
|
111
113
|
"posttest": "yarn lint && yarn test:circular-deps",
|
|
112
114
|
"prepack": "yarn run build",
|