@inquirer/prompts 1.2.2 → 2.0.0
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 +37 -0
- package/dist/cjs/index.js +16 -3
- package/dist/cjs/types/index.d.cts +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/types/index.d.mts +2 -2
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -9,6 +9,12 @@ A collection of common interactive command line user interfaces.
|
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
|
12
|
+
Give it a try in your own terminal!
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npx @inquirer/demo@latest
|
|
16
|
+
```
|
|
17
|
+
|
|
12
18
|
# Installation
|
|
13
19
|
|
|
14
20
|
```sh
|
|
@@ -145,6 +151,20 @@ const allowEmail = await confirm(
|
|
|
145
151
|
);
|
|
146
152
|
```
|
|
147
153
|
|
|
154
|
+
## Canceling prompt
|
|
155
|
+
|
|
156
|
+
All prompt functions are returning a cancelable promise. This special promise type has a `cancel` method that'll cancel and cleanup the prompt.
|
|
157
|
+
|
|
158
|
+
On calling `cancel`, the answer promise will become rejected.
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
import { confirm } from '@inquirer/prompts';
|
|
162
|
+
|
|
163
|
+
const answer = confirm(...); // note: for this you cannot use `await`
|
|
164
|
+
|
|
165
|
+
answer.cancel();
|
|
166
|
+
```
|
|
167
|
+
|
|
148
168
|
# Recipes
|
|
149
169
|
|
|
150
170
|
## Get answers in an object
|
|
@@ -177,6 +197,23 @@ if (allowEmail) {
|
|
|
177
197
|
}
|
|
178
198
|
```
|
|
179
199
|
|
|
200
|
+
## Get default value after timeout
|
|
201
|
+
|
|
202
|
+
```js
|
|
203
|
+
import { input } from '@inquirer/prompts';
|
|
204
|
+
|
|
205
|
+
const answer = input(...);
|
|
206
|
+
|
|
207
|
+
const defaultValue = new Promise(resolve => {
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
resolve(...);
|
|
210
|
+
answer.cancel();
|
|
211
|
+
}, 5000);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const answer = await Promise.race([defaultValue, answer])
|
|
215
|
+
```
|
|
216
|
+
|
|
180
217
|
# Community prompts
|
|
181
218
|
|
|
182
219
|
If you created a cool prompt, [send us a PR adding it](https://github.com/SBoudrias/Inquirer.js/edit/master/README.md) to the list below!
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
18
|
};
|
|
5
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
20
|
+
exports.select = exports.rawlist = exports.password = exports.input = exports.expand = exports.editor = exports.confirm = exports.checkbox = void 0;
|
|
7
21
|
const checkbox_1 = __importDefault(require("@inquirer/checkbox"));
|
|
8
22
|
exports.checkbox = checkbox_1.default;
|
|
9
23
|
const confirm_1 = __importDefault(require("@inquirer/confirm"));
|
|
@@ -20,5 +34,4 @@ const rawlist_1 = __importDefault(require("@inquirer/rawlist"));
|
|
|
20
34
|
exports.rawlist = rawlist_1.default;
|
|
21
35
|
const select_1 = __importDefault(require("@inquirer/select"));
|
|
22
36
|
exports.select = select_1.default;
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return core_1.Separator; } });
|
|
37
|
+
__exportStar(require("@inquirer/core"), exports);
|
|
@@ -6,5 +6,5 @@ import input from '@inquirer/input';
|
|
|
6
6
|
import password from '@inquirer/password';
|
|
7
7
|
import rawlist from '@inquirer/rawlist';
|
|
8
8
|
import select from '@inquirer/select';
|
|
9
|
-
|
|
10
|
-
export { checkbox, confirm, editor, expand, input, password, rawlist, select
|
|
9
|
+
export * from '@inquirer/core';
|
|
10
|
+
export { checkbox, confirm, editor, expand, input, password, rawlist, select };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -6,5 +6,5 @@ import input from '@inquirer/input';
|
|
|
6
6
|
import password from '@inquirer/password';
|
|
7
7
|
import rawlist from '@inquirer/rawlist';
|
|
8
8
|
import select from '@inquirer/select';
|
|
9
|
-
|
|
10
|
-
export { checkbox, confirm, editor, expand, input, password, rawlist, select
|
|
9
|
+
export * from '@inquirer/core';
|
|
10
|
+
export { checkbox, confirm, editor, expand, input, password, rawlist, select };
|
|
@@ -6,5 +6,5 @@ import input from '@inquirer/input';
|
|
|
6
6
|
import password from '@inquirer/password';
|
|
7
7
|
import rawlist from '@inquirer/rawlist';
|
|
8
8
|
import select from '@inquirer/select';
|
|
9
|
-
|
|
10
|
-
export { checkbox, confirm, editor, expand, input, password, rawlist, select
|
|
9
|
+
export * from '@inquirer/core';
|
|
10
|
+
export { checkbox, confirm, editor, expand, input, password, rawlist, select };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/prompts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Inquirer prompts, combined in a single package",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"typings": "./dist/cjs/types/index.d.cts",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"scripts": {
|
|
58
58
|
"tsc": "yarn run clean && yarn run tsc:esm && yarn run tsc:cjs",
|
|
59
59
|
"clean": "rm -rf dist",
|
|
60
|
-
"tsc:esm": "tsc -p ./tsconfig.
|
|
60
|
+
"tsc:esm": "tsc -p ./tsconfig.json",
|
|
61
61
|
"tsc:cjs": "tsc -p ./tsconfig.cjs.json && yarn run fix-ext",
|
|
62
|
-
"fix-ext": "node --no-warnings=ExperimentalWarning --loader=ts-node/esm ../../tools/
|
|
62
|
+
"fix-ext": "node --no-warnings=ExperimentalWarning --loader=ts-node/esm ../../tools/fix-ext.mts"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=14.18.0"
|
|
@@ -77,16 +77,16 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@inquirer/checkbox": "^1.
|
|
81
|
-
"@inquirer/confirm": "^
|
|
82
|
-
"@inquirer/core": "^
|
|
83
|
-
"@inquirer/editor": "^1.0
|
|
84
|
-
"@inquirer/expand": "^1.0
|
|
85
|
-
"@inquirer/input": "^1.
|
|
86
|
-
"@inquirer/password": "^1.0
|
|
87
|
-
"@inquirer/rawlist": "^1.
|
|
88
|
-
"@inquirer/select": "^1.
|
|
80
|
+
"@inquirer/checkbox": "^1.3.0",
|
|
81
|
+
"@inquirer/confirm": "^2.0.0",
|
|
82
|
+
"@inquirer/core": "^2.0.0",
|
|
83
|
+
"@inquirer/editor": "^1.1.0",
|
|
84
|
+
"@inquirer/expand": "^1.1.0",
|
|
85
|
+
"@inquirer/input": "^1.2.0",
|
|
86
|
+
"@inquirer/password": "^1.1.0",
|
|
87
|
+
"@inquirer/rawlist": "^1.2.0",
|
|
88
|
+
"@inquirer/select": "^1.2.0"
|
|
89
89
|
},
|
|
90
90
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/prompts/README.md",
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "86531864067faf1d6e76f1581c9aa72cb1b03753"
|
|
92
92
|
}
|