@inquirer/prompts 7.3.3 → 7.4.1
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 +33 -14
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -15,6 +15,16 @@ Give it a try in your own terminal!
|
|
|
15
15
|
npx @inquirer/demo@latest
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
# Special Thanks
|
|
19
|
+
|
|
20
|
+
<div align="center" markdown="1">
|
|
21
|
+
|
|
22
|
+
[](https://graphite.dev/?utm_source=npmjs&utm_medium=repo&utm_campaign=inquirerjs)<br>
|
|
23
|
+
|
|
24
|
+
### [Graphite is the AI developer productivity platform helping teams on GitHub ship higher quality software, faster](https://graphite.dev/?utm_source=npmjs&utm_medium=repo&utm_campaign=inquirerjs)
|
|
25
|
+
|
|
26
|
+
</div>
|
|
27
|
+
|
|
18
28
|
# Installation
|
|
19
29
|
|
|
20
30
|
<table>
|
|
@@ -192,7 +202,7 @@ const allowEmail = await confirm(
|
|
|
192
202
|
|
|
193
203
|
## Canceling prompt
|
|
194
204
|
|
|
195
|
-
This can
|
|
205
|
+
This can be done with either an `AbortController` or `AbortSignal`.
|
|
196
206
|
|
|
197
207
|
```js
|
|
198
208
|
// Example 1: using built-in AbortSignal utilities
|
|
@@ -202,7 +212,7 @@ const answer = await confirm({ ... }, { signal: AbortSignal.timeout(5000) });
|
|
|
202
212
|
```
|
|
203
213
|
|
|
204
214
|
```js
|
|
205
|
-
// Example
|
|
215
|
+
// Example 2: implementing custom cancellation with an AbortController
|
|
206
216
|
import { confirm } from '@inquirer/prompts';
|
|
207
217
|
|
|
208
218
|
const controller = new AbortController();
|
|
@@ -213,18 +223,6 @@ setTimeout(() => {
|
|
|
213
223
|
const answer = await confirm({ ... }, { signal: controller.signal });
|
|
214
224
|
```
|
|
215
225
|
|
|
216
|
-
Alternatively, all prompt functions are returning a cancelable promise. This special promise type has a `cancel` method that'll cancel and cleanup the prompt.
|
|
217
|
-
|
|
218
|
-
On calling `cancel`, the answer promise will become rejected.
|
|
219
|
-
|
|
220
|
-
```js
|
|
221
|
-
import { confirm } from '@inquirer/prompts';
|
|
222
|
-
|
|
223
|
-
const promise = confirm(...); // Warning: for this pattern to work, `await` cannot be used.
|
|
224
|
-
|
|
225
|
-
promise.cancel();
|
|
226
|
-
```
|
|
227
|
-
|
|
228
226
|
# Recipes
|
|
229
227
|
|
|
230
228
|
## Handling `ctrl+c` gracefully
|
|
@@ -351,6 +349,27 @@ import { confirm } from '@inquirer/prompts';
|
|
|
351
349
|
const answer = await confirm({ message: await getMessage() });
|
|
352
350
|
```
|
|
353
351
|
|
|
352
|
+
## Usage with `npx` within bash scripts
|
|
353
|
+
|
|
354
|
+
You can use Inquirer prompts directly in the shell via [`npx`](https://docs.npmjs.com/cli/v8/commands/npx), which is useful for quick scripts or `package.json` commands.
|
|
355
|
+
|
|
356
|
+
A community library, [@inquirer-cli](https://github.com/fishballapp/inquirer-cli), exposes each prompt as a standalone CLI.
|
|
357
|
+
|
|
358
|
+
For example, to prompt for input:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
name=$(npx -y @inquirer-cli/input -r "What is your name?")
|
|
362
|
+
echo "Hello, $name!"
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Or to create an interactive version bump:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
$ npm version $(npx -y @inquirer-cli/select -c patch -c minor -c major 'Select Version')
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Find out more: [@inquirer-cli](https://github.com/fishballapp/inquirer-cli).
|
|
372
|
+
|
|
354
373
|
# Community prompts
|
|
355
374
|
|
|
356
375
|
If you created a cool prompt, [send us a PR adding it](https://github.com/SBoudrias/Inquirer.js/edit/main/README.md) to the list below!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/prompts",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.1",
|
|
4
4
|
"description": "Inquirer prompts, combined in a single package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -76,20 +76,20 @@
|
|
|
76
76
|
"tsc": "tshy"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@inquirer/checkbox": "^4.1.
|
|
80
|
-
"@inquirer/confirm": "^5.1.
|
|
81
|
-
"@inquirer/editor": "^4.2.
|
|
82
|
-
"@inquirer/expand": "^4.0.
|
|
83
|
-
"@inquirer/input": "^4.1.
|
|
84
|
-
"@inquirer/number": "^3.0.
|
|
85
|
-
"@inquirer/password": "^4.0.
|
|
86
|
-
"@inquirer/rawlist": "^4.0.
|
|
87
|
-
"@inquirer/search": "^3.0.
|
|
88
|
-
"@inquirer/select": "^4.
|
|
79
|
+
"@inquirer/checkbox": "^4.1.5",
|
|
80
|
+
"@inquirer/confirm": "^5.1.9",
|
|
81
|
+
"@inquirer/editor": "^4.2.10",
|
|
82
|
+
"@inquirer/expand": "^4.0.12",
|
|
83
|
+
"@inquirer/input": "^4.1.9",
|
|
84
|
+
"@inquirer/number": "^3.0.12",
|
|
85
|
+
"@inquirer/password": "^4.0.12",
|
|
86
|
+
"@inquirer/rawlist": "^4.0.12",
|
|
87
|
+
"@inquirer/search": "^3.0.12",
|
|
88
|
+
"@inquirer/select": "^4.1.1"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@arethetypeswrong/cli": "^0.17.4",
|
|
92
|
-
"@inquirer/type": "^3.0.
|
|
92
|
+
"@inquirer/type": "^3.0.6",
|
|
93
93
|
"@repo/tsconfig": "workspace:*",
|
|
94
94
|
"tshy": "^3.0.2"
|
|
95
95
|
},
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"optional": true
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "d367155a8d64d8b3e93f9c763adccf708aedc8a8"
|
|
117
117
|
}
|