@inquirer/prompts 1.2.3 → 2.1.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 +57 -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 +11 -11
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,43 @@ if (allowEmail) {
|
|
|
177
197
|
}
|
|
178
198
|
```
|
|
179
199
|
|
|
200
|
+
## Get default value after timeout
|
|
201
|
+
|
|
202
|
+
```js
|
|
203
|
+
import { setTimeout } from 'node:timers/promises';
|
|
204
|
+
import { input } from '@inquirer/prompts';
|
|
205
|
+
|
|
206
|
+
const answer = input(...);
|
|
207
|
+
|
|
208
|
+
const defaultValue = setTimeout(5000).then(() => {
|
|
209
|
+
answer.cancel();
|
|
210
|
+
return 'default answer';
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const answer = await Promise.race([defaultValue, answer])
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Using as pre-commit/git hooks, or scripts
|
|
217
|
+
|
|
218
|
+
By default scripts ran from tools like `husky`/`lint-staged` might not run inside an interactive shell. In non-interactive shell, Inquirer cannot run, and users cannot send keypress events to the process.
|
|
219
|
+
|
|
220
|
+
For it to work, you must make sure you start a `tty` (or "interactive" input stream.)
|
|
221
|
+
|
|
222
|
+
If those scripts are set within your `package.json`, you can define the stream like so:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
"precommit": "my-script < /dev/tty"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Or if in a shell script file, you'll do it like so: (on Windows that's likely your only option)
|
|
229
|
+
|
|
230
|
+
```sh
|
|
231
|
+
#!/bin/sh
|
|
232
|
+
exec < /dev/tty
|
|
233
|
+
|
|
234
|
+
node my-script.js
|
|
235
|
+
```
|
|
236
|
+
|
|
180
237
|
# Community prompts
|
|
181
238
|
|
|
182
239
|
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": "1.
|
|
3
|
+
"version": "2.1.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",
|
|
@@ -77,16 +77,16 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@inquirer/checkbox": "^1.
|
|
81
|
-
"@inquirer/confirm": "^
|
|
82
|
-
"@inquirer/core": "^1.
|
|
83
|
-
"@inquirer/editor": "^1.0
|
|
84
|
-
"@inquirer/expand": "^1.
|
|
85
|
-
"@inquirer/input": "^1.1
|
|
86
|
-
"@inquirer/password": "^1.
|
|
87
|
-
"@inquirer/rawlist": "^1.1
|
|
88
|
-
"@inquirer/select": "^1.1
|
|
80
|
+
"@inquirer/checkbox": "^1.3.1",
|
|
81
|
+
"@inquirer/confirm": "^2.0.1",
|
|
82
|
+
"@inquirer/core": "^2.1.0",
|
|
83
|
+
"@inquirer/editor": "^1.2.0",
|
|
84
|
+
"@inquirer/expand": "^1.1.1",
|
|
85
|
+
"@inquirer/input": "^1.2.1",
|
|
86
|
+
"@inquirer/password": "^1.1.1",
|
|
87
|
+
"@inquirer/rawlist": "^1.2.1",
|
|
88
|
+
"@inquirer/select": "^1.2.1"
|
|
89
89
|
},
|
|
90
90
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/prompts/README.md",
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "d48ecde923e5875de631f7b50f67cfaf00384947"
|
|
92
92
|
}
|