@oclif/core 3.19.1 → 3.19.2
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 +16 -16
- package/lib/execute.d.ts +4 -10
- package/lib/execute.js +4 -10
- package/package.json +4 -4
package/lib/cli-ux/prompt.js
CHANGED
|
@@ -28,28 +28,22 @@ 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"));
|
|
31
32
|
const Errors = __importStar(require("../errors"));
|
|
32
33
|
const config_1 = require("./config");
|
|
33
34
|
function normal(options, retries = 100) {
|
|
34
35
|
if (retries < 0)
|
|
35
36
|
throw new Error('no input');
|
|
37
|
+
const ac = new AbortController();
|
|
38
|
+
const { signal } = ac;
|
|
36
39
|
return new Promise((resolve, reject) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
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();
|
|
40
|
+
const rl = node_readline_1.default.createInterface({
|
|
41
|
+
input: process.stdin,
|
|
42
|
+
output: process.stdout,
|
|
43
|
+
});
|
|
44
|
+
rl.question(options.prompt, { signal }, (answer) => {
|
|
45
|
+
rl.close();
|
|
46
|
+
const data = answer.trim();
|
|
53
47
|
if (!options.default && options.required && data === '') {
|
|
54
48
|
resolve(normal(options, retries - 1));
|
|
55
49
|
}
|
|
@@ -57,6 +51,12 @@ function normal(options, retries = 100) {
|
|
|
57
51
|
resolve(data || options.default);
|
|
58
52
|
}
|
|
59
53
|
});
|
|
54
|
+
if (options.timeout) {
|
|
55
|
+
signal.addEventListener('abort', () => {
|
|
56
|
+
reject(new Error('Prompt timeout'));
|
|
57
|
+
}, { once: true });
|
|
58
|
+
setTimeout(() => ac.abort(), options.timeout);
|
|
59
|
+
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
function getPrompt(name, type, defaultValue) {
|
package/lib/execute.d.ts
CHANGED
|
@@ -8,23 +8,17 @@ import { LoadOptions } from './interfaces';
|
|
|
8
8
|
* @example For ESM dev.js
|
|
9
9
|
* ```
|
|
10
10
|
* #!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
|
|
11
|
-
*
|
|
12
|
-
* const oclif = await import('@oclif/core')
|
|
13
|
-
* await oclif.execute({development: true, dir: import.meta.url})
|
|
14
|
-
* }
|
|
11
|
+
* import { execute } from '@oclif/core'
|
|
15
12
|
*
|
|
16
|
-
* await
|
|
13
|
+
* await execute({development: true, dir: import.meta.url})
|
|
17
14
|
* ```
|
|
18
15
|
*
|
|
19
16
|
* @example For ESM run.js
|
|
20
17
|
* ```
|
|
21
18
|
* #!/usr/bin/env node
|
|
22
|
-
*
|
|
23
|
-
* const oclif = await import('@oclif/core')
|
|
24
|
-
* await oclif.execute({dir: import.meta.url})
|
|
25
|
-
* }
|
|
19
|
+
* import { execute } from '@oclif/core'
|
|
26
20
|
*
|
|
27
|
-
* await
|
|
21
|
+
* await execute({dir: import.meta.url})
|
|
28
22
|
* ```
|
|
29
23
|
*
|
|
30
24
|
* @example For CJS dev.js
|
package/lib/execute.js
CHANGED
|
@@ -14,23 +14,17 @@ const settings_1 = require("./settings");
|
|
|
14
14
|
* @example For ESM dev.js
|
|
15
15
|
* ```
|
|
16
16
|
* #!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
|
|
17
|
-
*
|
|
18
|
-
* const oclif = await import('@oclif/core')
|
|
19
|
-
* await oclif.execute({development: true, dir: import.meta.url})
|
|
20
|
-
* }
|
|
17
|
+
* import { execute } from '@oclif/core'
|
|
21
18
|
*
|
|
22
|
-
* await
|
|
19
|
+
* await execute({development: true, dir: import.meta.url})
|
|
23
20
|
* ```
|
|
24
21
|
*
|
|
25
22
|
* @example For ESM run.js
|
|
26
23
|
* ```
|
|
27
24
|
* #!/usr/bin/env node
|
|
28
|
-
*
|
|
29
|
-
* const oclif = await import('@oclif/core')
|
|
30
|
-
* await oclif.execute({dir: import.meta.url})
|
|
31
|
-
* }
|
|
25
|
+
* import { execute } from '@oclif/core'
|
|
32
26
|
*
|
|
33
|
-
* await
|
|
27
|
+
* await execute({dir: import.meta.url})
|
|
34
28
|
* ```
|
|
35
29
|
*
|
|
36
30
|
* @example For CJS dev.js
|
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.2",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@oclif/plugin-help": "^6",
|
|
39
39
|
"@oclif/plugin-plugins": "^4",
|
|
40
40
|
"@oclif/prettier-config": "^0.2.1",
|
|
41
|
-
"@oclif/test": "^3.1.
|
|
41
|
+
"@oclif/test": "^3.1.14",
|
|
42
42
|
"@types/ansi-styles": "^3.2.1",
|
|
43
43
|
"@types/benchmark": "^2.1.5",
|
|
44
44
|
"@types/chai": "^4.3.11",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"husky": "^8",
|
|
73
73
|
"lint-staged": "^14.0.1",
|
|
74
74
|
"madge": "^6.1.0",
|
|
75
|
-
"mocha": "^10.
|
|
75
|
+
"mocha": "^10.3.0",
|
|
76
76
|
"nyc": "^15.1.0",
|
|
77
|
-
"prettier": "^3.2.
|
|
77
|
+
"prettier": "^3.2.5",
|
|
78
78
|
"shx": "^0.3.4",
|
|
79
79
|
"sinon": "^16.1.3",
|
|
80
80
|
"ts-node": "^10.9.2",
|