@oclif/core 3.0.0-beta.2 → 3.0.0-beta.20
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 +10 -6
- package/flush.js +1 -1
- package/handle.js +1 -1
- package/lib/args.d.ts +1 -1
- package/lib/args.js +17 -18
- package/lib/cli-ux/action/base.d.ts +3 -5
- package/lib/cli-ux/action/base.js +32 -26
- package/lib/cli-ux/action/simple.js +13 -18
- package/lib/cli-ux/action/spinner.d.ts +4 -2
- package/lib/cli-ux/action/spinner.js +27 -19
- package/lib/cli-ux/action/spinners.js +1 -1
- package/lib/cli-ux/action/types.d.ts +5 -0
- package/lib/cli-ux/action/types.js +2 -0
- package/lib/cli-ux/config.d.ts +0 -1
- package/lib/cli-ux/config.js +17 -21
- package/lib/cli-ux/exit.d.ts +1 -1
- package/lib/cli-ux/exit.js +4 -1
- package/lib/cli-ux/flush.d.ts +1 -0
- package/lib/cli-ux/flush.js +28 -0
- package/lib/cli-ux/index.d.ts +10 -30
- package/lib/cli-ux/index.js +32 -75
- package/lib/cli-ux/list.js +3 -3
- package/lib/cli-ux/prompt.js +32 -22
- package/lib/cli-ux/stream.js +1 -0
- package/lib/cli-ux/styled/index.d.ts +5 -6
- package/lib/cli-ux/styled/index.js +11 -11
- package/lib/cli-ux/styled/json.js +8 -5
- package/lib/cli-ux/styled/object.js +7 -9
- package/lib/cli-ux/styled/table.d.ts +4 -4
- package/lib/cli-ux/styled/table.js +61 -64
- package/lib/cli-ux/styled/tree.js +1 -3
- package/lib/cli-ux/wait.js +3 -5
- package/lib/command.d.ts +15 -19
- package/lib/command.js +117 -96
- package/lib/config/config.d.ts +16 -23
- package/lib/config/config.js +180 -334
- package/lib/config/index.d.ts +1 -1
- package/lib/config/index.js +1 -2
- package/lib/config/plugin-loader.d.ts +30 -0
- package/lib/config/plugin-loader.js +145 -0
- package/lib/config/plugin.d.ts +6 -11
- package/lib/config/plugin.js +112 -78
- package/lib/config/ts-node.d.ts +2 -1
- package/lib/config/ts-node.js +64 -51
- package/lib/config/util.d.ts +1 -11
- package/lib/config/util.js +6 -59
- package/lib/errors/config.js +1 -1
- package/lib/errors/errors/cli.d.ts +1 -1
- package/lib/errors/errors/cli.js +18 -14
- package/lib/errors/errors/exit.d.ts +0 -3
- package/lib/errors/errors/exit.js +1 -1
- package/lib/errors/errors/module-load.d.ts +0 -3
- package/lib/errors/errors/module-load.js +1 -1
- package/lib/errors/errors/pretty-print.js +11 -9
- package/lib/errors/handle.d.ts +12 -2
- package/lib/errors/handle.js +28 -18
- package/lib/errors/index.d.ts +2 -2
- package/lib/errors/index.js +20 -19
- package/lib/errors/logger.js +9 -8
- package/lib/execute.d.ts +49 -0
- package/lib/execute.js +63 -0
- package/lib/flags.d.ts +102 -31
- package/lib/flags.js +81 -46
- package/lib/help/command.d.ts +2 -0
- package/lib/help/command.js +68 -53
- package/lib/help/docopts.js +9 -13
- package/lib/help/formatter.d.ts +1 -1
- package/lib/help/formatter.js +35 -24
- package/lib/help/index.d.ts +7 -3
- package/lib/help/index.js +77 -55
- package/lib/help/root.js +7 -9
- package/lib/help/util.d.ts +1 -7
- package/lib/help/util.js +8 -28
- package/lib/index.d.ts +19 -18
- package/lib/index.js +36 -48
- package/lib/interfaces/config.d.ts +30 -30
- package/lib/interfaces/errors.d.ts +1 -1
- package/lib/interfaces/hooks.d.ts +3 -3
- package/lib/interfaces/index.d.ts +14 -14
- package/lib/interfaces/parser.d.ts +188 -116
- package/lib/interfaces/pjson.d.ts +2 -1
- package/lib/interfaces/plugin.d.ts +10 -1
- package/lib/main.d.ts +0 -48
- package/lib/main.js +11 -66
- package/lib/module-loader.d.ts +68 -79
- package/lib/module-loader.js +183 -150
- package/lib/parser/errors.d.ts +3 -3
- package/lib/parser/errors.js +17 -10
- package/lib/parser/help.js +5 -5
- package/lib/parser/parse.d.ts +3 -0
- package/lib/parser/parse.js +114 -115
- package/lib/parser/validate.js +45 -25
- package/lib/performance.d.ts +5 -1
- package/lib/performance.js +40 -19
- 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} +6 -15
- package/lib/util/util.js +98 -0
- package/package.json +32 -34
- package/lib/cli-ux/action/pride-spinner.d.ts +0 -4
- package/lib/cli-ux/action/pride-spinner.js +0 -30
- package/lib/util.js +0 -126
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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.20",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@types/cli-progress": "^3.11.0",
|
|
9
8
|
"ansi-escapes": "^4.3.2",
|
|
10
9
|
"ansi-styles": "^4.3.0",
|
|
11
10
|
"cardinal": "^2.1.1",
|
|
@@ -14,7 +13,6 @@
|
|
|
14
13
|
"cli-progress": "^3.12.0",
|
|
15
14
|
"debug": "^4.3.4",
|
|
16
15
|
"ejs": "^3.1.8",
|
|
17
|
-
"fs-extra": "^9.1.0",
|
|
18
16
|
"get-package-type": "^0.1.0",
|
|
19
17
|
"globby": "^11.1.0",
|
|
20
18
|
"hyperlinker": "^1.0.0",
|
|
@@ -24,39 +22,33 @@
|
|
|
24
22
|
"natural-orderby": "^2.0.3",
|
|
25
23
|
"object-treeify": "^1.1.33",
|
|
26
24
|
"password-prompt": "^1.1.2",
|
|
27
|
-
"semver": "^7.5.3",
|
|
28
25
|
"slice-ansi": "^4.0.0",
|
|
29
26
|
"string-width": "^4.2.3",
|
|
30
27
|
"strip-ansi": "^6.0.1",
|
|
31
28
|
"supports-color": "^8.1.1",
|
|
32
29
|
"supports-hyperlinks": "^2.2.0",
|
|
33
|
-
"ts-node": "^10.9.1",
|
|
34
|
-
"tslib": "^2.5.0",
|
|
35
30
|
"widest-line": "^3.1.0",
|
|
36
31
|
"wordwrap": "^1.0.0",
|
|
37
32
|
"wrap-ansi": "^7.0.0"
|
|
38
33
|
},
|
|
39
34
|
"devDependencies": {
|
|
40
|
-
"@commitlint/config-conventional": "^
|
|
35
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
41
36
|
"@oclif/plugin-help": "^5.2.8",
|
|
42
|
-
"@oclif/plugin-plugins": "^
|
|
43
|
-
"@oclif/
|
|
37
|
+
"@oclif/plugin-plugins": "^3.3.0",
|
|
38
|
+
"@oclif/prettier-config": "^0.2.1",
|
|
39
|
+
"@oclif/test": "^3.0.1",
|
|
44
40
|
"@types/ansi-styles": "^3.2.1",
|
|
45
41
|
"@types/benchmark": "^2.1.2",
|
|
46
|
-
"@types/chai": "^4.3.4",
|
|
47
42
|
"@types/chai-as-promised": "^7.1.5",
|
|
43
|
+
"@types/chai": "^4.3.4",
|
|
48
44
|
"@types/clean-stack": "^2.1.1",
|
|
45
|
+
"@types/cli-progress": "^3.11.0",
|
|
49
46
|
"@types/ejs": "^3.1.2",
|
|
50
|
-
"@types/fs-extra": "^9.0.13",
|
|
51
47
|
"@types/indent-string": "^4.0.1",
|
|
52
48
|
"@types/js-yaml": "^3.12.7",
|
|
53
|
-
"@types/mocha": "^
|
|
54
|
-
"@types/nock": "^11.1.0",
|
|
55
|
-
"@types/node": "^16",
|
|
49
|
+
"@types/mocha": "^10.0.2",
|
|
56
50
|
"@types/node-notifier": "^8.0.2",
|
|
57
|
-
"@types/
|
|
58
|
-
"@types/semver": "^7.5.0",
|
|
59
|
-
"@types/shelljs": "^0.8.11",
|
|
51
|
+
"@types/node": "^18",
|
|
60
52
|
"@types/slice-ansi": "^4.0.0",
|
|
61
53
|
"@types/strip-ansi": "^5.2.1",
|
|
62
54
|
"@types/supports-color": "^8.1.1",
|
|
@@ -65,25 +57,29 @@
|
|
|
65
57
|
"benchmark": "^2.1.4",
|
|
66
58
|
"chai": "^4.3.7",
|
|
67
59
|
"chai-as-promised": "^7.1.1",
|
|
68
|
-
"commitlint": "^
|
|
60
|
+
"commitlint": "^17.7.2",
|
|
69
61
|
"cross-env": "^7.0.3",
|
|
70
|
-
"eslint": "^
|
|
71
|
-
"eslint-config-oclif": "^
|
|
72
|
-
"eslint-config-oclif-typescript": "^
|
|
73
|
-
"
|
|
62
|
+
"eslint": "^8.49.0",
|
|
63
|
+
"eslint-config-oclif": "^5.0.0",
|
|
64
|
+
"eslint-config-oclif-typescript": "^2.0.1",
|
|
65
|
+
"eslint-config-prettier": "^9.0.0",
|
|
66
|
+
"fancy-test": "^3.0.1",
|
|
74
67
|
"globby": "^11.1.0",
|
|
75
|
-
"husky": "
|
|
68
|
+
"husky": "^8",
|
|
69
|
+
"lint-staged": "^14.0.1",
|
|
70
|
+
"madge": "^6.1.0",
|
|
76
71
|
"mocha": "^10.2.0",
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"shelljs": "^0.8.5",
|
|
72
|
+
"nyc": "^15.1.0",
|
|
73
|
+
"prettier": "^3.0.3",
|
|
80
74
|
"shx": "^0.3.4",
|
|
81
75
|
"sinon": "^11.1.2",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
76
|
+
"ts-node": "^10.9.1",
|
|
77
|
+
"tsd": "^0.29.0",
|
|
78
|
+
"tslib": "^2.5.0",
|
|
79
|
+
"typescript": "^5"
|
|
84
80
|
},
|
|
85
81
|
"engines": {
|
|
86
|
-
"node": ">=
|
|
82
|
+
"node": ">=18.0.0"
|
|
87
83
|
},
|
|
88
84
|
"files": [
|
|
89
85
|
"/lib",
|
|
@@ -96,7 +92,7 @@
|
|
|
96
92
|
"oclif"
|
|
97
93
|
],
|
|
98
94
|
"license": "MIT",
|
|
99
|
-
"main": "lib/index.js",
|
|
95
|
+
"main": "./lib/index.js",
|
|
100
96
|
"repository": "oclif/core",
|
|
101
97
|
"oclif": {
|
|
102
98
|
"bin": "oclif",
|
|
@@ -112,14 +108,16 @@
|
|
|
112
108
|
"build": "shx rm -rf lib && tsc",
|
|
113
109
|
"commitlint": "commitlint",
|
|
114
110
|
"compile": "tsc",
|
|
115
|
-
"
|
|
116
|
-
"
|
|
111
|
+
"format": "prettier --write \"+(src|test)/**/*.+(ts|js|json)\"",
|
|
112
|
+
"lint": "eslint . --ext .ts",
|
|
113
|
+
"posttest": "yarn lint && yarn test:circular-deps",
|
|
117
114
|
"prepack": "yarn run build",
|
|
118
|
-
"pretest": "yarn build
|
|
115
|
+
"pretest": "yarn build && tsc -p test --noEmit --skipLibCheck",
|
|
116
|
+
"test:circular-deps": "madge lib/ -c",
|
|
119
117
|
"test:e2e": "mocha --forbid-only \"test/**/*.e2e.ts\" --parallel --timeout 1200000",
|
|
120
118
|
"test:esm-cjs": "cross-env DEBUG=e2e:* ts-node test/integration/esm-cjs.ts",
|
|
121
119
|
"test:perf": "ts-node test/perf/parser.perf.ts",
|
|
122
|
-
"test": "mocha --forbid-only \"test/**/*.test.ts\""
|
|
120
|
+
"test": "nyc mocha --forbid-only \"test/**/*.test.ts\""
|
|
123
121
|
},
|
|
124
122
|
"types": "lib/index.d.ts"
|
|
125
123
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const chalk = require("chalk");
|
|
4
|
-
const supportsColor = require("supports-color");
|
|
5
|
-
const spinner_1 = require("./spinner");
|
|
6
|
-
function color(s, frameIndex) {
|
|
7
|
-
const prideColors = [
|
|
8
|
-
chalk.keyword('pink'),
|
|
9
|
-
chalk.red,
|
|
10
|
-
chalk.keyword('orange'),
|
|
11
|
-
chalk.yellow,
|
|
12
|
-
chalk.green,
|
|
13
|
-
chalk.cyan,
|
|
14
|
-
chalk.blue,
|
|
15
|
-
chalk.magenta,
|
|
16
|
-
];
|
|
17
|
-
if (!supportsColor)
|
|
18
|
-
return s;
|
|
19
|
-
const has256 = supportsColor.stdout ? supportsColor.stdout.has256 : (process.env.TERM || '').includes('256');
|
|
20
|
-
const prideColor = prideColors[frameIndex] || prideColors[0];
|
|
21
|
-
return has256 ? prideColor(s) : chalk.magenta(s);
|
|
22
|
-
}
|
|
23
|
-
class PrideSpinnerAction extends spinner_1.default {
|
|
24
|
-
_frame() {
|
|
25
|
-
const frame = this.frames[this.frameIndex];
|
|
26
|
-
this.frameIndex = ++this.frameIndex % this.frames.length;
|
|
27
|
-
return color(frame, this.frameIndex);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.default = PrideSpinnerAction;
|
package/lib/util.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureArgObject = exports.requireJson = exports.isNotFalsy = exports.isTruthy = exports.fileExists = exports.dirExists = exports.capitalize = exports.sumBy = exports.maxBy = exports.isProd = exports.castArray = exports.sortBy = exports.last = exports.uniqBy = exports.compact = exports.pickBy = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
function pickBy(obj, fn) {
|
|
7
|
-
return Object.entries(obj)
|
|
8
|
-
.reduce((o, [k, v]) => {
|
|
9
|
-
if (fn(v))
|
|
10
|
-
o[k] = v;
|
|
11
|
-
return o;
|
|
12
|
-
}, {});
|
|
13
|
-
}
|
|
14
|
-
exports.pickBy = pickBy;
|
|
15
|
-
function compact(a) {
|
|
16
|
-
return a.filter((a) => Boolean(a));
|
|
17
|
-
}
|
|
18
|
-
exports.compact = compact;
|
|
19
|
-
function uniqBy(arr, fn) {
|
|
20
|
-
return arr.filter((a, i) => {
|
|
21
|
-
const aVal = fn(a);
|
|
22
|
-
return !arr.find((b, j) => j > i && fn(b) === aVal);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.uniqBy = uniqBy;
|
|
26
|
-
function last(arr) {
|
|
27
|
-
if (!arr)
|
|
28
|
-
return;
|
|
29
|
-
return arr.slice(-1)[0];
|
|
30
|
-
}
|
|
31
|
-
exports.last = last;
|
|
32
|
-
function sortBy(arr, fn) {
|
|
33
|
-
function compare(a, b) {
|
|
34
|
-
a = a === undefined ? 0 : a;
|
|
35
|
-
b = b === undefined ? 0 : b;
|
|
36
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
37
|
-
if (a.length === 0 && b.length === 0)
|
|
38
|
-
return 0;
|
|
39
|
-
const diff = compare(a[0], b[0]);
|
|
40
|
-
if (diff !== 0)
|
|
41
|
-
return diff;
|
|
42
|
-
return compare(a.slice(1), b.slice(1));
|
|
43
|
-
}
|
|
44
|
-
if (a < b)
|
|
45
|
-
return -1;
|
|
46
|
-
if (a > b)
|
|
47
|
-
return 1;
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
|
-
return arr.sort((a, b) => compare(fn(a), fn(b)));
|
|
51
|
-
}
|
|
52
|
-
exports.sortBy = sortBy;
|
|
53
|
-
function castArray(input) {
|
|
54
|
-
if (input === undefined)
|
|
55
|
-
return [];
|
|
56
|
-
return Array.isArray(input) ? input : [input];
|
|
57
|
-
}
|
|
58
|
-
exports.castArray = castArray;
|
|
59
|
-
function isProd() {
|
|
60
|
-
return !['development', 'test'].includes(process.env.NODE_ENV ?? '');
|
|
61
|
-
}
|
|
62
|
-
exports.isProd = isProd;
|
|
63
|
-
function maxBy(arr, fn) {
|
|
64
|
-
if (arr.length === 0) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
return arr.reduce((maxItem, i) => {
|
|
68
|
-
const curr = fn(i);
|
|
69
|
-
const max = fn(maxItem);
|
|
70
|
-
return curr > max ? i : maxItem;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
exports.maxBy = maxBy;
|
|
74
|
-
function sumBy(arr, fn) {
|
|
75
|
-
return arr.reduce((sum, i) => sum + fn(i), 0);
|
|
76
|
-
}
|
|
77
|
-
exports.sumBy = sumBy;
|
|
78
|
-
function capitalize(s) {
|
|
79
|
-
return s ? s.charAt(0).toUpperCase() + s.slice(1).toLowerCase() : '';
|
|
80
|
-
}
|
|
81
|
-
exports.capitalize = capitalize;
|
|
82
|
-
const dirExists = async (input) => {
|
|
83
|
-
if (!fs.existsSync(input)) {
|
|
84
|
-
throw new Error(`No directory found at ${input}`);
|
|
85
|
-
}
|
|
86
|
-
if (!(await fs.promises.stat(input)).isDirectory()) {
|
|
87
|
-
throw new Error(`${input} exists but is not a directory`);
|
|
88
|
-
}
|
|
89
|
-
return input;
|
|
90
|
-
};
|
|
91
|
-
exports.dirExists = dirExists;
|
|
92
|
-
const fileExists = async (input) => {
|
|
93
|
-
if (!fs.existsSync(input)) {
|
|
94
|
-
throw new Error(`No file found at ${input}`);
|
|
95
|
-
}
|
|
96
|
-
if (!(await fs.promises.stat(input)).isFile()) {
|
|
97
|
-
throw new Error(`${input} exists but is not a file`);
|
|
98
|
-
}
|
|
99
|
-
return input;
|
|
100
|
-
};
|
|
101
|
-
exports.fileExists = fileExists;
|
|
102
|
-
function isTruthy(input) {
|
|
103
|
-
return ['true', '1', 'yes', 'y'].includes(input.toLowerCase());
|
|
104
|
-
}
|
|
105
|
-
exports.isTruthy = isTruthy;
|
|
106
|
-
function isNotFalsy(input) {
|
|
107
|
-
return !['false', '0', 'no', 'n'].includes(input.toLowerCase());
|
|
108
|
-
}
|
|
109
|
-
exports.isNotFalsy = isNotFalsy;
|
|
110
|
-
function requireJson(...pathParts) {
|
|
111
|
-
return JSON.parse(fs.readFileSync((0, path_1.join)(...pathParts), 'utf8'));
|
|
112
|
-
}
|
|
113
|
-
exports.requireJson = requireJson;
|
|
114
|
-
/**
|
|
115
|
-
* Ensure that the provided args are an object. This is for backwards compatibility with v1 commands which
|
|
116
|
-
* defined args as an array.
|
|
117
|
-
*
|
|
118
|
-
* @param args Either an array of args or an object of args
|
|
119
|
-
* @returns ArgInput
|
|
120
|
-
*/
|
|
121
|
-
function ensureArgObject(args) {
|
|
122
|
-
return (Array.isArray(args) ? (args ?? []).reduce((x, y) => {
|
|
123
|
-
return { ...x, [y.name]: y };
|
|
124
|
-
}, {}) : args ?? {});
|
|
125
|
-
}
|
|
126
|
-
exports.ensureArgObject = ensureArgObject;
|