@inquirer/prompts 1.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 +188 -0
- package/dist/.DS_Store +0 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/types/index.d.mts +9 -0
- package/dist/esm/index.mjs +9 -0
- package/dist/esm/types/index.d.mts +9 -0
- package/package.json +89 -0
package/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<img width="75px" height="75px" align="right" alt="Inquirer Logo" src="https://raw.githubusercontent.com/SBoudrias/Inquirer.js/master/assets/inquirer_readme.svg?sanitize=true" title="Inquirer.js"/>
|
|
2
|
+
|
|
3
|
+
# Inquirer
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/@inquirer%2Finput.svg)
|
|
6
|
+
[](https://codecov.io/gh/SBoudrias/Inquirer.js)
|
|
7
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2FSBoudrias%2FInquirer.js?ref=badge_shield)
|
|
8
|
+
|
|
9
|
+
A collection of common interactive command line user interfaces.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
# Installation
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @inquirer/prompts
|
|
17
|
+
|
|
18
|
+
yarn add @inquirer/prompts
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Inquirer recently underwent a rewrite from the ground up to reduce the package size and improve performance. The previous version of the package is still maintained (though not actively developed), and offered hundreds of community contributed prompts that might not have been migrated to the latest API. If this is what you're looking for, the [previous package is over here](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/inquirer).
|
|
22
|
+
|
|
23
|
+
# Usage
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { input } from '@inquirer/prompts';
|
|
27
|
+
|
|
28
|
+
const answer = await input({ message: 'Enter your name' });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
# Prompts
|
|
32
|
+
|
|
33
|
+
## [Input](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/input)
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { input } from '@inquirer/prompts';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/input) for usage example and options documentation.
|
|
42
|
+
|
|
43
|
+
## [Select](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/select)
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { select } from '@inquirer/prompts';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/select) for usage example and options documentation.
|
|
52
|
+
|
|
53
|
+
## [Checkbox](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/checkbox)
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { checkbox } from '@inquirer/prompts';
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/checkbox) for usage example and options documentation.
|
|
62
|
+
|
|
63
|
+
## [Confirm](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/confirm)
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { confirm } from '@inquirer/prompts';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/confirm) for usage example and options documentation.
|
|
72
|
+
|
|
73
|
+
## [Password](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/password)
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
import { password } from '@inquirer/prompts';
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/password) for usage example and options documentation.
|
|
82
|
+
|
|
83
|
+
## [Expand](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/expand)
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+

|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { expand } from '@inquirer/prompts';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/expand) for usage example and options documentation.
|
|
93
|
+
|
|
94
|
+
## [Editor](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/editor)
|
|
95
|
+
|
|
96
|
+
Launches an instance of the users preferred editor on a temporary file. Once the user exits their editor, the content of the temporary file is read as the answer. The editor used is determined by reading the $VISUAL or $EDITOR environment variables. If neither of those are present, the OS default is used (notepad on Windows, vim on Mac or Linux.)
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import { editor } from '@inquirer/prompts';
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/editor) for usage example and options documentation.
|
|
103
|
+
|
|
104
|
+
## [Raw List](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/rawlist)
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import { rawlist } from '@inquirer/prompts';
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
[See documentation](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/rawlist) for usage example and options documentation.
|
|
113
|
+
|
|
114
|
+
# Create your own prompts
|
|
115
|
+
|
|
116
|
+
The [API documentation is over here](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/core), and our [testing utilities here](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/testing).
|
|
117
|
+
|
|
118
|
+
# Advanced usage
|
|
119
|
+
|
|
120
|
+
All inquirer prompts are a function taking 2 arguments. The first argument is the prompt configuration. The second is providing contextual or runtime configuration.
|
|
121
|
+
|
|
122
|
+
The context options are:
|
|
123
|
+
|
|
124
|
+
| Property | Type | Required | Description |
|
|
125
|
+
| ----------------- | ----------------------- | -------- | ------------------------------------------------------------ |
|
|
126
|
+
| input | `NodeJS.ReadableStream` | no | The stdin stream (defaults to `process.stdin`) |
|
|
127
|
+
| output | `NodeJS.WritableStream` | no | The stdout stream (defaults to `process.stdout`) |
|
|
128
|
+
| clearPromptOnDone | `boolean` | no | If true, we'll clear the screen after the prompt is answered |
|
|
129
|
+
|
|
130
|
+
Example:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
import { confirm } from '@inquirer/prompts';
|
|
134
|
+
|
|
135
|
+
const allowEmail = await confirm(
|
|
136
|
+
{ message: 'Do you allow us to send you email?' },
|
|
137
|
+
{
|
|
138
|
+
output: new Stream.Writable({
|
|
139
|
+
write(chunk, _encoding, next) {
|
|
140
|
+
// Do something
|
|
141
|
+
next();
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
clearPromptOnDone: true,
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
# Recipes
|
|
150
|
+
|
|
151
|
+
## Get answers in an object
|
|
152
|
+
|
|
153
|
+
When asking many questions, you might not want to keep one variable per answer everywhere. In which case, you can put the answer inside an object.
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
import { input, confirm } from '@inquirer/prompts';
|
|
157
|
+
|
|
158
|
+
const answers = {
|
|
159
|
+
firstName: await input({ message: 'What\'s your first name?' }),
|
|
160
|
+
allowEmail: await confirm({ message: 'Do you allow us to send you email?' }),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
console.log(answers.firstName);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Ask a question conditionally
|
|
167
|
+
|
|
168
|
+
Maybe some questions depend on some other question's answer.
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
import { input, confirm } from '@inquirer/prompts';
|
|
172
|
+
|
|
173
|
+
const allowEmail = await confirm({ message: 'Do you allow us to send you email?' });
|
|
174
|
+
|
|
175
|
+
let email;
|
|
176
|
+
if (allowEmail) {
|
|
177
|
+
email = await input({ message: 'What is your email address' });
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
# Community prompts
|
|
182
|
+
|
|
183
|
+
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!
|
|
184
|
+
|
|
185
|
+
# License
|
|
186
|
+
|
|
187
|
+
Copyright (c) 2023 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))
|
|
188
|
+
Licensed under the MIT license.
|
package/dist/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.select = exports.rawlist = exports.password = exports.input = exports.expand = exports.editor = exports.confirm = exports.checkbox = void 0;
|
|
7
|
+
const checkbox_1 = __importDefault(require("@inquirer/checkbox"));
|
|
8
|
+
exports.checkbox = checkbox_1.default;
|
|
9
|
+
const confirm_1 = __importDefault(require("@inquirer/confirm"));
|
|
10
|
+
exports.confirm = confirm_1.default;
|
|
11
|
+
const editor_1 = __importDefault(require("@inquirer/editor"));
|
|
12
|
+
exports.editor = editor_1.default;
|
|
13
|
+
const expand_1 = __importDefault(require("@inquirer/expand"));
|
|
14
|
+
exports.expand = expand_1.default;
|
|
15
|
+
const input_1 = __importDefault(require("@inquirer/input"));
|
|
16
|
+
exports.input = input_1.default;
|
|
17
|
+
const password_1 = __importDefault(require("@inquirer/password"));
|
|
18
|
+
exports.password = password_1.default;
|
|
19
|
+
const rawlist_1 = __importDefault(require("@inquirer/rawlist"));
|
|
20
|
+
exports.rawlist = rawlist_1.default;
|
|
21
|
+
const select_1 = __importDefault(require("@inquirer/select"));
|
|
22
|
+
exports.select = select_1.default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import checkbox from '@inquirer/checkbox';
|
|
2
|
+
import confirm from '@inquirer/confirm';
|
|
3
|
+
import editor from '@inquirer/editor';
|
|
4
|
+
import expand from '@inquirer/expand';
|
|
5
|
+
import input from '@inquirer/input';
|
|
6
|
+
import password from '@inquirer/password';
|
|
7
|
+
import rawlist from '@inquirer/rawlist';
|
|
8
|
+
import select from '@inquirer/select';
|
|
9
|
+
export { checkbox, confirm, editor, expand, input, password, rawlist, select };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import checkbox from '@inquirer/checkbox';
|
|
2
|
+
import confirm from '@inquirer/confirm';
|
|
3
|
+
import editor from '@inquirer/editor';
|
|
4
|
+
import expand from '@inquirer/expand';
|
|
5
|
+
import input from '@inquirer/input';
|
|
6
|
+
import password from '@inquirer/password';
|
|
7
|
+
import rawlist from '@inquirer/rawlist';
|
|
8
|
+
import select from '@inquirer/select';
|
|
9
|
+
export { checkbox, confirm, editor, expand, input, password, rawlist, select };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import checkbox from '@inquirer/checkbox';
|
|
2
|
+
import confirm from '@inquirer/confirm';
|
|
3
|
+
import editor from '@inquirer/editor';
|
|
4
|
+
import expand from '@inquirer/expand';
|
|
5
|
+
import input from '@inquirer/input';
|
|
6
|
+
import password from '@inquirer/password';
|
|
7
|
+
import rawlist from '@inquirer/rawlist';
|
|
8
|
+
import select from '@inquirer/select';
|
|
9
|
+
export { checkbox, confirm, editor, expand, input, password, rawlist, select };
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inquirer/prompts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Inquirer prompts, combined in a single package",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"typings": "./dist/cjs/types/index.d.mts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"answer",
|
|
16
|
+
"answers",
|
|
17
|
+
"ask",
|
|
18
|
+
"base",
|
|
19
|
+
"cli",
|
|
20
|
+
"command",
|
|
21
|
+
"command-line",
|
|
22
|
+
"confirm",
|
|
23
|
+
"enquirer",
|
|
24
|
+
"generate",
|
|
25
|
+
"generator",
|
|
26
|
+
"hyper",
|
|
27
|
+
"input",
|
|
28
|
+
"inquire",
|
|
29
|
+
"inquirer",
|
|
30
|
+
"interface",
|
|
31
|
+
"iterm",
|
|
32
|
+
"javascript",
|
|
33
|
+
"menu",
|
|
34
|
+
"node",
|
|
35
|
+
"nodejs",
|
|
36
|
+
"prompt",
|
|
37
|
+
"promptly",
|
|
38
|
+
"prompts",
|
|
39
|
+
"question",
|
|
40
|
+
"readline",
|
|
41
|
+
"scaffold",
|
|
42
|
+
"scaffolder",
|
|
43
|
+
"scaffolding",
|
|
44
|
+
"stdin",
|
|
45
|
+
"stdout",
|
|
46
|
+
"terminal",
|
|
47
|
+
"tty",
|
|
48
|
+
"ui",
|
|
49
|
+
"yeoman",
|
|
50
|
+
"yo",
|
|
51
|
+
"zsh",
|
|
52
|
+
"types",
|
|
53
|
+
"typescript"
|
|
54
|
+
],
|
|
55
|
+
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"scripts": {
|
|
58
|
+
"tsc": "yarn run clean && yarn run tsc:esm && yarn run tsc:cjs",
|
|
59
|
+
"clean": "rm -rf dist",
|
|
60
|
+
"tsc:esm": "tsc -p ./tsconfig.esm.json",
|
|
61
|
+
"tsc:cjs": "tsc -p ./tsconfig.cjs.json && yarn run fix-ext",
|
|
62
|
+
"fix-ext": "ts-node ../../tools/rename-ext.ts"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=14.18.0"
|
|
66
|
+
},
|
|
67
|
+
"exports": {
|
|
68
|
+
".": {
|
|
69
|
+
"import": {
|
|
70
|
+
"types": "./dist/esm/types/index.d.mts",
|
|
71
|
+
"default": "./dist/esm/index.mjs"
|
|
72
|
+
},
|
|
73
|
+
"require": {
|
|
74
|
+
"types": "./dist/cjs/types/index.d.mts",
|
|
75
|
+
"default": "./dist/cjs/index.js"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@inquirer/checkbox": "^1.0.0",
|
|
81
|
+
"@inquirer/confirm": "^1.0.0",
|
|
82
|
+
"@inquirer/editor": "^1.0.0",
|
|
83
|
+
"@inquirer/expand": "^1.0.0",
|
|
84
|
+
"@inquirer/input": "^1.0.0",
|
|
85
|
+
"@inquirer/password": "^1.0.0",
|
|
86
|
+
"@inquirer/rawlist": "^1.0.0",
|
|
87
|
+
"@inquirer/select": "^1.0.0"
|
|
88
|
+
}
|
|
89
|
+
}
|