@oclif/core 3.19.5 → 3.19.7
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/cli-ux/prompt.js +14 -20
- package/lib/main.js +11 -5
- package/package.json +5 -5
package/lib/cli-ux/prompt.js
CHANGED
|
@@ -28,38 +28,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.anykey = exports.confirm = exports.prompt = void 0;
|
|
30
30
|
const chalk_1 = __importDefault(require("chalk"));
|
|
31
|
-
const node_readline_1 = __importDefault(require("node:readline"));
|
|
32
31
|
const Errors = __importStar(require("../errors"));
|
|
33
32
|
const config_1 = require("./config");
|
|
34
33
|
function normal(options, retries = 100) {
|
|
35
34
|
if (retries < 0)
|
|
36
35
|
throw new Error('no input');
|
|
37
|
-
const ac = new AbortController();
|
|
38
|
-
const { signal } = ac;
|
|
39
36
|
return new Promise((resolve, reject) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
let timeout;
|
|
45
|
-
// Only set the timeout if the input is a TTY
|
|
46
|
-
if (options.timeout && options.isTTY) {
|
|
47
|
-
timeout = setTimeout(() => ac.abort(), options.timeout);
|
|
48
|
-
signal.addEventListener('abort', () => {
|
|
49
|
-
rl.close();
|
|
50
|
-
clearTimeout(timeout);
|
|
37
|
+
let timer;
|
|
38
|
+
if (options.timeout) {
|
|
39
|
+
timer = setTimeout(() => {
|
|
40
|
+
process.stdin.pause();
|
|
51
41
|
reject(new Error('Prompt timeout'));
|
|
52
|
-
},
|
|
42
|
+
}, options.timeout);
|
|
43
|
+
timer.unref();
|
|
53
44
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
process.stdin.setEncoding('utf8');
|
|
46
|
+
process.stderr.write(options.prompt);
|
|
47
|
+
process.stdin.resume();
|
|
48
|
+
process.stdin.once('data', (b) => {
|
|
49
|
+
if (timer)
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
process.stdin.pause();
|
|
52
|
+
const data = (typeof b === 'string' ? b : b.toString()).trim();
|
|
57
53
|
if (!options.default && options.required && data === '') {
|
|
58
|
-
clearTimeout(timeout);
|
|
59
54
|
resolve(normal(options, retries - 1));
|
|
60
55
|
}
|
|
61
56
|
else {
|
|
62
|
-
clearTimeout(timeout);
|
|
63
57
|
resolve(data || options.default);
|
|
64
58
|
}
|
|
65
59
|
});
|
package/lib/main.js
CHANGED
|
@@ -38,6 +38,11 @@ async function run(argv, options) {
|
|
|
38
38
|
await performance_1.Performance.collect();
|
|
39
39
|
performance_1.Performance.debug();
|
|
40
40
|
};
|
|
41
|
+
const showHelp = async (argv) => {
|
|
42
|
+
const Help = await (0, help_1.loadHelpClass)(config);
|
|
43
|
+
const help = new Help(config, config.pjson.oclif.helpOptions ?? config.pjson.helpOptions);
|
|
44
|
+
await help.showHelp(argv);
|
|
45
|
+
};
|
|
41
46
|
debug(`process.execPath: ${process.execPath}`);
|
|
42
47
|
debug(`process.execArgv: ${process.execArgv}`);
|
|
43
48
|
debug('process.argv: %O', process.argv);
|
|
@@ -58,9 +63,7 @@ async function run(argv, options) {
|
|
|
58
63
|
}
|
|
59
64
|
// display help version if applicable
|
|
60
65
|
if ((0, exports.helpAddition)(argv, config)) {
|
|
61
|
-
|
|
62
|
-
const help = new Help(config, config.pjson.oclif.helpOptions ?? config.pjson.helpOptions);
|
|
63
|
-
await help.showHelp(argv);
|
|
66
|
+
await showHelp(argv);
|
|
64
67
|
await collectPerf();
|
|
65
68
|
return;
|
|
66
69
|
}
|
|
@@ -68,8 +71,11 @@ async function run(argv, options) {
|
|
|
68
71
|
const cmd = config.findCommand(id);
|
|
69
72
|
if (!cmd) {
|
|
70
73
|
const topic = config.flexibleTaxonomy ? null : config.findTopic(id);
|
|
71
|
-
if (topic)
|
|
72
|
-
|
|
74
|
+
if (topic) {
|
|
75
|
+
await showHelp([id]);
|
|
76
|
+
await collectPerf();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
73
79
|
if (config.pjson.oclif.default) {
|
|
74
80
|
id = config.pjson.oclif.default;
|
|
75
81
|
argvSlice = argv;
|
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.19.
|
|
4
|
+
"version": "3.19.7",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"commitlint": "^17.8.1",
|
|
65
65
|
"cross-env": "^7.0.3",
|
|
66
66
|
"eslint": "^8.56.0",
|
|
67
|
-
"eslint-config-oclif": "^5.0.
|
|
68
|
-
"eslint-config-oclif-typescript": "^3.0.
|
|
67
|
+
"eslint-config-oclif": "^5.0.2",
|
|
68
|
+
"eslint-config-oclif-typescript": "^3.0.48",
|
|
69
69
|
"eslint-config-prettier": "^9.1.0",
|
|
70
|
-
"fancy-test": "^3.0.
|
|
70
|
+
"fancy-test": "^3.0.11",
|
|
71
71
|
"globby": "^11.1.0",
|
|
72
72
|
"husky": "^8",
|
|
73
73
|
"lint-staged": "^14.0.1",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"shx": "^0.3.4",
|
|
79
79
|
"sinon": "^16.1.3",
|
|
80
80
|
"ts-node": "^10.9.2",
|
|
81
|
-
"tsd": "^0.30.
|
|
81
|
+
"tsd": "^0.30.6",
|
|
82
82
|
"typescript": "^5"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|