@modern-js/utils 1.4.1 → 1.7.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/CHANGELOG.md +39 -0
- package/compiled/address/index.js +1 -0
- package/compiled/address/lib/address.d.ts +28 -0
- package/compiled/address/package.json +1 -0
- package/compiled/browserslist/index.js +1 -1
- package/compiled/dotenv/index.js +1 -0
- package/compiled/dotenv/license +23 -0
- package/compiled/dotenv/package.json +1 -0
- package/compiled/dotenv/types/index.d.ts +59 -0
- package/compiled/dotenv-expand/index.d.ts +15 -0
- package/compiled/dotenv-expand/index.js +1 -0
- package/compiled/dotenv-expand/license +24 -0
- package/compiled/dotenv-expand/package.json +1 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/compiled/fast-glob/index.js +37 -0
- package/compiled/fast-glob/license +21 -0
- package/compiled/fast-glob/out/index.d.ts +27 -0
- package/compiled/fast-glob/out/managers/tasks.d.ts +22 -0
- package/compiled/fast-glob/out/settings.d.ts +164 -0
- package/compiled/fast-glob/out/types/index.d.ts +31 -0
- package/compiled/fast-glob/package.json +1 -0
- package/compiled/globby/index.d.ts +186 -0
- package/compiled/globby/index.js +1 -0
- package/compiled/globby/license +9 -0
- package/compiled/globby/package.json +1 -0
- package/compiled/inquirer/index.d.ts +997 -0
- package/compiled/inquirer/index.js +9 -0
- package/compiled/inquirer/lib/objects/choice.d.ts +65 -0
- package/compiled/inquirer/lib/objects/choices.d.ts +206 -0
- package/compiled/inquirer/lib/objects/separator.d.ts +37 -0
- package/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
- package/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
- package/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
- package/compiled/inquirer/license +22 -0
- package/compiled/inquirer/package.json +1 -0
- package/compiled/inquirer/through/index.d.ts +25 -0
- package/compiled/json5/index.js +1 -0
- package/compiled/json5/lib/index.d.ts +4 -0
- package/compiled/json5/lib/parse.d.ts +15 -0
- package/compiled/json5/lib/stringify.d.ts +89 -0
- package/compiled/json5/package.json +1 -0
- package/compiled/lodash/index.js +4 -8
- package/compiled/mime-types/index.d.ts +14 -0
- package/compiled/mime-types/index.js +14 -0
- package/compiled/mime-types/license +23 -0
- package/compiled/mime-types/package.json +1 -0
- package/compiled/minimist/index.d.ts +95 -0
- package/compiled/minimist/index.js +1 -0
- package/compiled/minimist/license +18 -0
- package/compiled/minimist/package.json +1 -0
- package/compiled/ora/cli-spinners/index.d.ts +125 -0
- package/compiled/ora/index.d.ts +277 -0
- package/compiled/ora/index.js +3 -0
- package/compiled/ora/license +9 -0
- package/compiled/ora/package.json +1 -0
- package/compiled/semver/classes/comparator.d.ts +17 -0
- package/compiled/semver/classes/range.d.ts +21 -0
- package/compiled/semver/classes/semver.d.ts +62 -0
- package/compiled/semver/functions/clean.d.ts +8 -0
- package/compiled/semver/functions/cmp.d.ts +16 -0
- package/compiled/semver/functions/coerce.d.ts +12 -0
- package/compiled/semver/functions/compare-build.d.ts +16 -0
- package/compiled/semver/functions/compare-loose.d.ts +5 -0
- package/compiled/semver/functions/compare.d.ts +20 -0
- package/compiled/semver/functions/diff.d.ts +13 -0
- package/compiled/semver/functions/eq.d.ts +9 -0
- package/compiled/semver/functions/gt.d.ts +9 -0
- package/compiled/semver/functions/gte.d.ts +9 -0
- package/compiled/semver/functions/inc.d.ts +15 -0
- package/compiled/semver/functions/lt.d.ts +9 -0
- package/compiled/semver/functions/lte.d.ts +8 -0
- package/compiled/semver/functions/major.d.ts +9 -0
- package/compiled/semver/functions/minor.d.ts +9 -0
- package/compiled/semver/functions/neq.d.ts +9 -0
- package/compiled/semver/functions/parse.d.ts +12 -0
- package/compiled/semver/functions/patch.d.ts +9 -0
- package/compiled/semver/functions/prerelease.d.ts +12 -0
- package/compiled/semver/functions/rcompare.d.ts +15 -0
- package/compiled/semver/functions/rsort.d.ts +9 -0
- package/compiled/semver/functions/satisfies.d.ts +14 -0
- package/compiled/semver/functions/sort.d.ts +9 -0
- package/compiled/semver/functions/valid.d.ts +11 -0
- package/compiled/semver/index.d.ts +133 -0
- package/compiled/semver/index.js +1 -0
- package/compiled/semver/internals/identifiers.d.ts +13 -0
- package/compiled/semver/license +15 -0
- package/compiled/semver/package.json +1 -0
- package/compiled/semver/ranges/gtr.d.ts +14 -0
- package/compiled/semver/ranges/intersects.d.ts +13 -0
- package/compiled/semver/ranges/ltr.d.ts +14 -0
- package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-version.d.ts +10 -0
- package/compiled/semver/ranges/outside.d.ts +15 -0
- package/compiled/semver/ranges/simplify.d.ts +14 -0
- package/compiled/semver/ranges/subset.d.ts +13 -0
- package/compiled/semver/ranges/to-comparators.d.ts +9 -0
- package/compiled/semver/ranges/valid.d.ts +12 -0
- package/compiled/slash/index.d.ts +25 -0
- package/compiled/slash/index.js +1 -0
- package/compiled/slash/license +9 -0
- package/compiled/slash/package.json +1 -0
- package/compiled/url-join/index.d.ts +17 -0
- package/compiled/url-join/index.js +1 -0
- package/compiled/url-join/license +21 -0
- package/compiled/url-join/package.json +1 -0
- package/dist/alias.js +4 -1
- package/dist/analyzeProject.d.ts +1 -0
- package/dist/analyzeProject.js +31 -0
- package/dist/compiled.d.ts +34 -17
- package/dist/compiled.js +59 -21
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/emptyDir.js +4 -13
- package/dist/format.js +6 -1
- package/dist/getEntryOptions.js +2 -1
- package/dist/getPackageManager.js +19 -30
- package/dist/getPort.js +3 -12
- package/dist/getServerConfig.js +2 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/logger.d.ts +3 -0
- package/dist/logger.js +21 -6
- package/dist/monorepo.js +4 -1
- package/dist/nodeEnv.js +24 -39
- package/dist/prettyInstructions.js +3 -3
- package/dist/runtimeExports.js +1 -1
- package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
- package/dist/{ssrHelpers.js → ssr.js} +0 -0
- package/dist/storage.js +1 -1
- package/dist/watch.js +9 -18
- package/package.json +41 -35
- package/tsconfig.json +1 -0
- package/dist/getCacheIdentifier.d.ts +0 -7
- package/dist/getCacheIdentifier.js +0 -24
- package/modern.config.js +0 -6
- package/tests/.eslintrc.js +0 -6
- package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
- package/tests/applyOptionsChain.test.ts +0 -100
- package/tests/compatRequire.test.ts +0 -32
- package/tests/debug.test.ts +0 -25
- package/tests/ensureAbsolutePath.test.ts +0 -16
- package/tests/findExists.test.ts +0 -22
- package/tests/fixtures/browserlist/develop/package.json +0 -11
- package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
- package/tests/fixtures/browserlist/pkg/package.json +0 -7
- package/tests/fixtures/compat-require/cjs.js +0 -1
- package/tests/fixtures/compat-require/empty.js +0 -1
- package/tests/fixtures/compat-require/esm.js +0 -5
- package/tests/fixtures/compat-require/foo.js +0 -3
- package/tests/fixtures/file-exists/a.ejs +0 -0
- package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
- package/tests/fixtures/file-exists/a.mjs +0 -0
- package/tests/fixtures/file-exists/a.ts +0 -0
- package/tests/format.test.ts +0 -60
- package/tests/generateMetaTags.test.ts +0 -19
- package/tests/getBrowserslist.test.ts +0 -32
- package/tests/getCacheIdentifier.test.ts +0 -37
- package/tests/getEntryOptions.test.ts +0 -53
- package/tests/index.test.ts +0 -18
- package/tests/is.test.ts +0 -27
- package/tests/isPlatform.test.ts +0 -19
- package/tests/isType.test.ts +0 -85
- package/tests/logger.test.ts +0 -53
- package/tests/prettyInstructions.test.ts +0 -139
- package/tests/removeSlash.test.ts +0 -19
- package/tests/tsconfig.json +0 -11
- package/tests/wait.ts +0 -38
|
@@ -0,0 +1,997 @@
|
|
|
1
|
+
// Type definitions for inquirer 8.2
|
|
2
|
+
// Project: https://github.com/SBoudrias/Inquirer.js
|
|
3
|
+
// Definitions by: Qubo <https://github.com/tkQubo>
|
|
4
|
+
// Parvez <https://github.com/ppathan>
|
|
5
|
+
// Jouderian <https://github.com/jouderianjr>
|
|
6
|
+
// Qibang <https://github.com/bang88>
|
|
7
|
+
// Jason Dreyzehner <https://github.com/bitjson>
|
|
8
|
+
// Synarque <https://github.com/synarque>
|
|
9
|
+
// Justin Rockwood <https://github.com/jrockwood>
|
|
10
|
+
// Keith Kelly <https://github.com/kwkelly>
|
|
11
|
+
// Richard Lea <https://github.com/chigix>
|
|
12
|
+
// Jed Mao <https://github.com/jedmao>
|
|
13
|
+
// Manuel Thalmann <https://github.com/manuth>
|
|
14
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
15
|
+
// TypeScript Version: 4.2
|
|
16
|
+
import { Interface as ReadlineInterface } from 'readline';
|
|
17
|
+
import { Observable } from './rxjs';
|
|
18
|
+
import Choice = require('./lib/objects/choice');
|
|
19
|
+
import Choices = require('./lib/objects/choices');
|
|
20
|
+
import Separator = require('./lib/objects/separator');
|
|
21
|
+
import './lib/prompts/base';
|
|
22
|
+
import './lib/prompts/checkbox';
|
|
23
|
+
import './lib/prompts/confirm';
|
|
24
|
+
import './lib/prompts/editor';
|
|
25
|
+
import './lib/prompts/expand';
|
|
26
|
+
import './lib/prompts/input';
|
|
27
|
+
import './lib/prompts/list';
|
|
28
|
+
import './lib/prompts/number';
|
|
29
|
+
import './lib/prompts/password';
|
|
30
|
+
import './lib/prompts/rawlist';
|
|
31
|
+
import './lib/utils/events';
|
|
32
|
+
import './lib/utils/paginator';
|
|
33
|
+
import './lib/utils/readline';
|
|
34
|
+
import './lib/utils/screen-manager';
|
|
35
|
+
import './lib/utils/utils';
|
|
36
|
+
import BottomBar = require('./lib/ui/bottom-bar');
|
|
37
|
+
import PromptUI = require('./lib/ui/prompt');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Represents a union which preserves autocompletion.
|
|
41
|
+
*
|
|
42
|
+
* @template T
|
|
43
|
+
* The keys which are available for autocompletion.
|
|
44
|
+
*
|
|
45
|
+
* @template F
|
|
46
|
+
* The fallback-type.
|
|
47
|
+
*/
|
|
48
|
+
type LiteralUnion<T extends F, F = string> = T | (F & {});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Provides prompts for answering questions.
|
|
52
|
+
*/
|
|
53
|
+
interface PromptModuleBase {
|
|
54
|
+
/**
|
|
55
|
+
* Registers a new prompt-type.
|
|
56
|
+
*
|
|
57
|
+
* @param name
|
|
58
|
+
* The name of the prompt.
|
|
59
|
+
*
|
|
60
|
+
* @param prompt
|
|
61
|
+
* The constructor of the prompt.
|
|
62
|
+
*/
|
|
63
|
+
registerPrompt(name: string, prompt: inquirer.prompts.PromptConstructor): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Registers the default prompts.
|
|
67
|
+
*/
|
|
68
|
+
restoreDefaultPrompts(): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Represents a list-based question.
|
|
73
|
+
*
|
|
74
|
+
* @template T
|
|
75
|
+
* The type of the answers.
|
|
76
|
+
*
|
|
77
|
+
* @template TChoiceMap
|
|
78
|
+
* The valid choices for the question.
|
|
79
|
+
*/
|
|
80
|
+
interface ListQuestionOptionsBase<T extends inquirer.Answers, TChoiceMap extends inquirer.Answers> extends inquirer.Question<T> {
|
|
81
|
+
/**
|
|
82
|
+
* The choices of the prompt.
|
|
83
|
+
*/
|
|
84
|
+
choices?: inquirer.AsyncDynamicQuestionProperty<ReadonlyArray<inquirer.DistinctChoice<TChoiceMap>>, T> | undefined;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The number of elements to show on each page.
|
|
88
|
+
*/
|
|
89
|
+
pageSize?: number | undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Provides components for the module.
|
|
94
|
+
*/
|
|
95
|
+
declare namespace inquirer {
|
|
96
|
+
/**
|
|
97
|
+
* Represents either a key of `T` or a `string`.
|
|
98
|
+
*
|
|
99
|
+
* @template T
|
|
100
|
+
* The type of the keys to suggest.
|
|
101
|
+
*/
|
|
102
|
+
type KeyUnion<T> = LiteralUnion<Extract<keyof T, string>>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Converts the specified union-type `U` to an intersection-type.
|
|
106
|
+
*
|
|
107
|
+
* @template U
|
|
108
|
+
* The union to convert to an intersection.
|
|
109
|
+
*/
|
|
110
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Provides an input and an output-stream.
|
|
114
|
+
*/
|
|
115
|
+
interface StreamOptions {
|
|
116
|
+
/**
|
|
117
|
+
* A stream to read the input from.
|
|
118
|
+
*/
|
|
119
|
+
input?: NodeJS.ReadStream | undefined;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A stream to write the output to.
|
|
123
|
+
*/
|
|
124
|
+
output?: NodeJS.WriteStream | undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Provides the functionality to prompt questions to the user.
|
|
129
|
+
*/
|
|
130
|
+
interface PromptModule extends PromptModuleBase {
|
|
131
|
+
/**
|
|
132
|
+
* The prompts of the prompt-module.
|
|
133
|
+
*/
|
|
134
|
+
prompts: prompts.PromptCollection;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Prompts the questions to the user.
|
|
138
|
+
*/
|
|
139
|
+
<T extends Answers = Answers>(questions: QuestionCollection<T>, initialAnswers?: Partial<T>): Promise<T> & { ui: PromptUI<T> };
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Registers a new prompt-type.
|
|
143
|
+
*
|
|
144
|
+
* @param name
|
|
145
|
+
* The name of the prompt.
|
|
146
|
+
*
|
|
147
|
+
* @param prompt
|
|
148
|
+
* The constructor of the prompt.
|
|
149
|
+
*/
|
|
150
|
+
registerPrompt(name: string, prompt: prompts.PromptConstructor): this;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface Inquirer extends PromptModuleBase {
|
|
154
|
+
/**
|
|
155
|
+
* Registers a new prompt-type.
|
|
156
|
+
*
|
|
157
|
+
* @param name
|
|
158
|
+
* The name of the prompt.
|
|
159
|
+
*
|
|
160
|
+
* @param prompt
|
|
161
|
+
* The constructor of the prompt.
|
|
162
|
+
*/
|
|
163
|
+
registerPrompt(name: string, prompt: prompts.PromptConstructor): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Creates a prompt-module.
|
|
167
|
+
*
|
|
168
|
+
* @param opt
|
|
169
|
+
* The streams for the prompt-module.
|
|
170
|
+
*
|
|
171
|
+
* @returns
|
|
172
|
+
* The new prompt-module.
|
|
173
|
+
*/
|
|
174
|
+
createPromptModule(opt?: StreamOptions): PromptModule;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The default prompt-module.
|
|
178
|
+
*/
|
|
179
|
+
prompt: PromptModule;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The prompts of the default prompt-module.
|
|
183
|
+
*
|
|
184
|
+
* @deprecated
|
|
185
|
+
*/
|
|
186
|
+
prompts: {};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Represents a choice-item separator.
|
|
190
|
+
*/
|
|
191
|
+
Separator: typeof Separator;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Provides ui-components.
|
|
195
|
+
*/
|
|
196
|
+
ui: {
|
|
197
|
+
/**
|
|
198
|
+
* Represents the bottom-bar UI.
|
|
199
|
+
*/
|
|
200
|
+
BottomBar: typeof BottomBar;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Represents the prompt ui.
|
|
204
|
+
*/
|
|
205
|
+
Prompt: typeof PromptUI;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A set of answers.
|
|
211
|
+
*/
|
|
212
|
+
interface Answers extends Record<string, any> {}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Provides the functionality to validate answers.
|
|
216
|
+
*
|
|
217
|
+
* @template T
|
|
218
|
+
* The type of the answers.
|
|
219
|
+
*/
|
|
220
|
+
type Validator<T extends Answers = Answers> = Question<T>['validate'];
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Provides the functionality to transform an answer.
|
|
224
|
+
*
|
|
225
|
+
* @template T
|
|
226
|
+
* The type of the answers.
|
|
227
|
+
*/
|
|
228
|
+
type Transformer<T extends Answers = Answers> = InputQuestionOptions<T>['transformer'];
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Represents a dynamic property for a question.
|
|
232
|
+
*
|
|
233
|
+
* @template T
|
|
234
|
+
* The type of the property.
|
|
235
|
+
*
|
|
236
|
+
* @template TAnswers
|
|
237
|
+
* The type of the answers.
|
|
238
|
+
*/
|
|
239
|
+
type DynamicQuestionProperty<T, TAnswers extends Answers = Answers> = T | ((answers: TAnswers) => T);
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Represents a dynamic property for a question which can be fetched asynchronously.
|
|
243
|
+
*
|
|
244
|
+
* @template T
|
|
245
|
+
* The type of the property.
|
|
246
|
+
*
|
|
247
|
+
* @template TAnswers
|
|
248
|
+
* The type of the answers.
|
|
249
|
+
*/
|
|
250
|
+
type AsyncDynamicQuestionProperty<T, TAnswers extends Answers = Answers> = DynamicQuestionProperty<
|
|
251
|
+
T | Promise<T>,
|
|
252
|
+
TAnswers
|
|
253
|
+
>;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Provides options for a question.
|
|
257
|
+
*
|
|
258
|
+
* @template T
|
|
259
|
+
* The type of the answers.
|
|
260
|
+
*/
|
|
261
|
+
interface Question<T extends Answers = Answers> {
|
|
262
|
+
/**
|
|
263
|
+
* The type of the question.
|
|
264
|
+
*/
|
|
265
|
+
type?: string | undefined;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* The key to save the answer to the answers-hash.
|
|
269
|
+
*/
|
|
270
|
+
name?: KeyUnion<T> | undefined;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The message to show to the user.
|
|
274
|
+
*/
|
|
275
|
+
message?: AsyncDynamicQuestionProperty<string, T> | undefined;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The default value of the question.
|
|
279
|
+
*/
|
|
280
|
+
default?: AsyncDynamicQuestionProperty<any, T> | undefined;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The prefix of the `message`.
|
|
284
|
+
*/
|
|
285
|
+
prefix?: string | undefined;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* The suffix of the `message`.
|
|
289
|
+
*/
|
|
290
|
+
suffix?: string | undefined;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Post-processes the answer.
|
|
294
|
+
*
|
|
295
|
+
* @param input
|
|
296
|
+
* The answer provided by the user.
|
|
297
|
+
*
|
|
298
|
+
* @param answers
|
|
299
|
+
* The answers provided by the user.
|
|
300
|
+
*/
|
|
301
|
+
filter?(input: any, answers: T): any;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* A value indicating whether the question should be prompted.
|
|
305
|
+
*/
|
|
306
|
+
when?: AsyncDynamicQuestionProperty<boolean, T> | undefined;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Validates the integrity of the answer.
|
|
310
|
+
*
|
|
311
|
+
* @param input
|
|
312
|
+
* The answer provided by the user.
|
|
313
|
+
*
|
|
314
|
+
* @param answers
|
|
315
|
+
* The answers provided by the user.
|
|
316
|
+
*
|
|
317
|
+
* @returns
|
|
318
|
+
* Either a value indicating whether the answer is valid or a `string` which describes the error.
|
|
319
|
+
*/
|
|
320
|
+
validate?(input: any, answers?: T): boolean | string | Promise<boolean | string>;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Force to prompt the question if the answer already exists.
|
|
324
|
+
*/
|
|
325
|
+
askAnswered?: boolean;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Represents the possible answers of each question in the prompt
|
|
330
|
+
*/
|
|
331
|
+
type QuestionAnswer<T extends Answers = Answers> = {
|
|
332
|
+
[K in keyof T]: {
|
|
333
|
+
name: K;
|
|
334
|
+
answer: T[K]
|
|
335
|
+
}
|
|
336
|
+
}[keyof T];
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Represents a choice-item.
|
|
340
|
+
*/
|
|
341
|
+
interface ChoiceBase {
|
|
342
|
+
/**
|
|
343
|
+
* The type of the choice.
|
|
344
|
+
*/
|
|
345
|
+
type?: string | undefined;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Provides options for a choice.
|
|
350
|
+
*/
|
|
351
|
+
interface ChoiceOptions extends ChoiceBase {
|
|
352
|
+
/**
|
|
353
|
+
* @inheritdoc
|
|
354
|
+
*/
|
|
355
|
+
type?: 'choice' | undefined;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* The name of the choice to show to the user.
|
|
359
|
+
*/
|
|
360
|
+
name?: string | undefined;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* The value of the choice.
|
|
364
|
+
*/
|
|
365
|
+
value?: any;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The short form of the name of the choice.
|
|
369
|
+
*/
|
|
370
|
+
short?: string | undefined;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* The extra properties of the choice.
|
|
374
|
+
*/
|
|
375
|
+
extra?: any;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Provides options for a choice of the `ListPrompt`.
|
|
380
|
+
*
|
|
381
|
+
* @template T
|
|
382
|
+
* The type of the answers.
|
|
383
|
+
*/
|
|
384
|
+
interface ListChoiceOptions<T extends Answers = Answers> extends ChoiceOptions {
|
|
385
|
+
/**
|
|
386
|
+
* A value indicating whether the choice is disabled.
|
|
387
|
+
*/
|
|
388
|
+
disabled?: DynamicQuestionProperty<boolean | string, T> | undefined;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Provides options for a choice of the `CheckboxPrompt`.
|
|
393
|
+
*
|
|
394
|
+
* @template T
|
|
395
|
+
* The type of the answers.
|
|
396
|
+
*/
|
|
397
|
+
interface CheckboxChoiceOptions<T extends Answers = Answers> extends ListChoiceOptions<T> {
|
|
398
|
+
/**
|
|
399
|
+
* A value indicating whether the choice should be initially checked.
|
|
400
|
+
*/
|
|
401
|
+
checked?: boolean | undefined;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Provides options for a choice of the `ExpandPrompt`.
|
|
406
|
+
*/
|
|
407
|
+
interface ExpandChoiceOptions extends ChoiceOptions {
|
|
408
|
+
/**
|
|
409
|
+
* The key to press for selecting the choice.
|
|
410
|
+
*/
|
|
411
|
+
key?: string | undefined;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Represents a separator.
|
|
416
|
+
*/
|
|
417
|
+
interface SeparatorOptions extends ChoiceBase {
|
|
418
|
+
/**
|
|
419
|
+
* Gets the type of the choice.
|
|
420
|
+
*/
|
|
421
|
+
type: 'separator';
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Gets or sets the text of the separator.
|
|
425
|
+
*/
|
|
426
|
+
line?: string | undefined;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Provides all valid choice-types for any kind of question.
|
|
431
|
+
*
|
|
432
|
+
* @template T
|
|
433
|
+
* The type of the answers.
|
|
434
|
+
*/
|
|
435
|
+
interface BaseChoiceMap<T extends Answers = Answers> {
|
|
436
|
+
Choice: Choice<T>;
|
|
437
|
+
ChoiceOptions: ChoiceOptions;
|
|
438
|
+
SeparatorOptions: SeparatorOptions;
|
|
439
|
+
Separator: Separator;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Provides all valid choice-types for the `ListQuestion`.
|
|
444
|
+
*
|
|
445
|
+
* @template T
|
|
446
|
+
* The type of the answers.
|
|
447
|
+
*/
|
|
448
|
+
interface ListChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {
|
|
449
|
+
ListChoiceOptions: ListChoiceOptions<T>;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Provides all valid choice-types for the `CheckboxQuestion`.
|
|
454
|
+
*
|
|
455
|
+
* @template T
|
|
456
|
+
* The type of the answers.
|
|
457
|
+
*/
|
|
458
|
+
interface CheckboxChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {
|
|
459
|
+
CheckboxChoiceOptions: CheckboxChoiceOptions<T>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Provides all valid choice-types for the `ExpandQuestion`.
|
|
464
|
+
*
|
|
465
|
+
* @template T
|
|
466
|
+
* The type of the answers.
|
|
467
|
+
*/
|
|
468
|
+
interface ExpandChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {
|
|
469
|
+
ExpandChoiceOptions: ExpandChoiceOptions;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Provides all valid choice-types.
|
|
474
|
+
*
|
|
475
|
+
* @template T
|
|
476
|
+
* The type of the answers.
|
|
477
|
+
*/
|
|
478
|
+
interface AllChoiceMap<T extends Answers = Answers> {
|
|
479
|
+
BaseChoiceMap: BaseChoiceMap<T>[keyof BaseChoiceMap<T>];
|
|
480
|
+
ListChoiceMap: ListChoiceMap<T>[keyof ListChoiceMap<T>];
|
|
481
|
+
CheckboxChoiceMap: CheckboxChoiceMap<T>[keyof CheckboxChoiceMap<T>];
|
|
482
|
+
ExpandChoiceMap: ExpandChoiceMap<T>[keyof ExpandChoiceMap<T>];
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Provides valid choices for the question of the `TChoiceMap`.
|
|
487
|
+
*
|
|
488
|
+
* @template TAnswers
|
|
489
|
+
* The type of the answers.
|
|
490
|
+
*
|
|
491
|
+
* @template TChoiceMap
|
|
492
|
+
* The choice-types to provide.
|
|
493
|
+
*/
|
|
494
|
+
type DistinctChoice<TAnswers extends Answers = Answers, TChoiceMap = AllChoiceMap<TAnswers>> =
|
|
495
|
+
| string
|
|
496
|
+
| TChoiceMap[keyof TChoiceMap];
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Represents a set of choices.
|
|
500
|
+
*
|
|
501
|
+
* @template T
|
|
502
|
+
* The type of the answers.
|
|
503
|
+
*/
|
|
504
|
+
type ChoiceCollection<T extends Answers = Answers> = Array<DistinctChoice<AllChoiceMap<T>>>;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Provides options for a question for the `InputPrompt`.
|
|
508
|
+
*
|
|
509
|
+
* @template T
|
|
510
|
+
* The type of the answers.
|
|
511
|
+
*/
|
|
512
|
+
interface InputQuestionOptions<T extends Answers = Answers> extends Question<T> {
|
|
513
|
+
/**
|
|
514
|
+
* Transforms the value to display to the user.
|
|
515
|
+
*
|
|
516
|
+
* @param input
|
|
517
|
+
* The input provided by the user.
|
|
518
|
+
*
|
|
519
|
+
* @param answers
|
|
520
|
+
* The answers provided by the users.
|
|
521
|
+
*
|
|
522
|
+
* @param flags
|
|
523
|
+
* Additional information about the value.
|
|
524
|
+
*
|
|
525
|
+
* @returns
|
|
526
|
+
* The value to display to the user.
|
|
527
|
+
*/
|
|
528
|
+
transformer?(input: any, answers: T, flags: { isFinal?: boolean | undefined }): string | Promise<string>;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Provides options for a question for the `InputPrompt`.
|
|
533
|
+
*
|
|
534
|
+
* @template T
|
|
535
|
+
* The type of the answers.
|
|
536
|
+
*/
|
|
537
|
+
interface InputQuestion<T extends Answers = Answers> extends InputQuestionOptions<T> {
|
|
538
|
+
/**
|
|
539
|
+
* @inheritdoc
|
|
540
|
+
*/
|
|
541
|
+
type?: 'input' | undefined;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Provides options for a question for the `NumberPrompt`.
|
|
546
|
+
*
|
|
547
|
+
* @template T
|
|
548
|
+
* The type of the answers.
|
|
549
|
+
*/
|
|
550
|
+
interface NumberQuestionOptions<T extends Answers = Answers> extends InputQuestionOptions<T> {}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Provides options for a question for the `NumberPrompt`.
|
|
554
|
+
*
|
|
555
|
+
* @template T
|
|
556
|
+
* The type of the answers.
|
|
557
|
+
*/
|
|
558
|
+
interface NumberQuestion<T extends Answers = Answers> extends NumberQuestionOptions<T> {
|
|
559
|
+
/**
|
|
560
|
+
* @inheritdoc
|
|
561
|
+
*/
|
|
562
|
+
type: 'number';
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Provides options for a question for the `PasswordPrompt`.
|
|
567
|
+
*
|
|
568
|
+
* @template T
|
|
569
|
+
* The type of the answers.
|
|
570
|
+
*/
|
|
571
|
+
interface PasswordQuestionOptions<T extends Answers = Answers> extends InputQuestionOptions<T> {
|
|
572
|
+
/**
|
|
573
|
+
* The character to replace the user-input.
|
|
574
|
+
*/
|
|
575
|
+
mask?: string | undefined;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Provides options for a question for the `PasswordPrompt`.
|
|
580
|
+
*
|
|
581
|
+
* @template T
|
|
582
|
+
* The type of the answers.
|
|
583
|
+
*/
|
|
584
|
+
interface PasswordQuestion<T extends Answers = Answers> extends PasswordQuestionOptions<T> {
|
|
585
|
+
/**
|
|
586
|
+
* @inheritdoc
|
|
587
|
+
*/
|
|
588
|
+
type: 'password';
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Represents a list-based question that can loop.
|
|
593
|
+
*
|
|
594
|
+
* @template T
|
|
595
|
+
* The type of the answers.
|
|
596
|
+
*
|
|
597
|
+
* @template TChoiceMap
|
|
598
|
+
* The valid choices for the question.
|
|
599
|
+
*/
|
|
600
|
+
interface LoopableListQuestionOptionsBase<T extends Answers, TChoiceMap extends Answers> extends ListQuestionOptionsBase<T, TChoiceMap> {
|
|
601
|
+
/**
|
|
602
|
+
* A value indicating whether choices in a list should be looped.
|
|
603
|
+
*/
|
|
604
|
+
loop?: boolean | undefined;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Provides options for a question for the `ListPrompt`.
|
|
609
|
+
*
|
|
610
|
+
* @template T
|
|
611
|
+
* The type of the answers.
|
|
612
|
+
*/
|
|
613
|
+
interface ListQuestionOptions<T extends Answers = Answers>
|
|
614
|
+
extends LoopableListQuestionOptionsBase<T, ListChoiceMap<T>> {}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Provides options for a question for the `ListPrompt`.
|
|
618
|
+
*
|
|
619
|
+
* @template T
|
|
620
|
+
* The type of the answers.
|
|
621
|
+
*/
|
|
622
|
+
interface ListQuestion<T extends Answers = Answers> extends ListQuestionOptions<T> {
|
|
623
|
+
/**
|
|
624
|
+
* @inheritdoc
|
|
625
|
+
*/
|
|
626
|
+
type: 'list';
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Provides options for a question for the `RawListPrompt`.
|
|
631
|
+
*
|
|
632
|
+
* @template T
|
|
633
|
+
* The type of the answers.
|
|
634
|
+
*/
|
|
635
|
+
interface RawListQuestionOptions<T extends Answers = Answers> extends ListQuestionOptions<T> {}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Provides options for a question for the `RawListPrompt`.
|
|
639
|
+
*
|
|
640
|
+
* @template T
|
|
641
|
+
* The type of the answers.
|
|
642
|
+
*/
|
|
643
|
+
interface RawListQuestion<T extends Answers = Answers> extends RawListQuestionOptions<T> {
|
|
644
|
+
/**
|
|
645
|
+
* @inheritdoc
|
|
646
|
+
*/
|
|
647
|
+
type: 'rawlist';
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Provides options for a question for the `ExpandPrompt`.
|
|
652
|
+
*
|
|
653
|
+
* @template T
|
|
654
|
+
* The type of the answers.
|
|
655
|
+
*/
|
|
656
|
+
interface ExpandQuestionOptions<T extends Answers = Answers>
|
|
657
|
+
extends ListQuestionOptionsBase<T, ExpandChoiceMap<T>> {}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Provides options for a question for the `ExpandPrompt`.
|
|
661
|
+
*
|
|
662
|
+
* @template T
|
|
663
|
+
* The type of the answers.
|
|
664
|
+
*/
|
|
665
|
+
interface ExpandQuestion<T extends Answers = Answers> extends ExpandQuestionOptions<T> {
|
|
666
|
+
/**
|
|
667
|
+
* @inheritdoc
|
|
668
|
+
*/
|
|
669
|
+
type: 'expand';
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Provides options for a question for the `CheckboxPrompt`.
|
|
674
|
+
*
|
|
675
|
+
* @template T
|
|
676
|
+
* The type of the answers.
|
|
677
|
+
*/
|
|
678
|
+
interface CheckboxQuestionOptions<T extends Answers = Answers>
|
|
679
|
+
extends LoopableListQuestionOptionsBase<T, CheckboxChoiceMap<T>> {}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Provides options for a question for the `CheckboxPrompt`.
|
|
683
|
+
*
|
|
684
|
+
* @template T
|
|
685
|
+
* The type of the answers.
|
|
686
|
+
*/
|
|
687
|
+
interface CheckboxQuestion<T extends Answers = Answers> extends CheckboxQuestionOptions<T> {
|
|
688
|
+
/**
|
|
689
|
+
* @inheritdoc
|
|
690
|
+
*/
|
|
691
|
+
type: 'checkbox';
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Provides options for a question for the `ConfirmPrompt`.
|
|
696
|
+
*
|
|
697
|
+
* @template T
|
|
698
|
+
* The type of the answers.
|
|
699
|
+
*/
|
|
700
|
+
interface ConfirmQuestionOptions<T extends Answers = Answers> extends Question<T> {}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Provides options for a question for the `ConfirmPrompt`.
|
|
704
|
+
*
|
|
705
|
+
* @template T
|
|
706
|
+
* The type of the answers.
|
|
707
|
+
*/
|
|
708
|
+
interface ConfirmQuestion<T extends Answers = Answers> extends ConfirmQuestionOptions<T> {
|
|
709
|
+
/**
|
|
710
|
+
* @inheritdoc
|
|
711
|
+
*/
|
|
712
|
+
type: 'confirm';
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Provides options for a question for the `EditorPrompt`.
|
|
717
|
+
*
|
|
718
|
+
* @template T
|
|
719
|
+
* The type of the answers.
|
|
720
|
+
*/
|
|
721
|
+
interface EditorQuestionOptions<T extends Answers = Answers> extends Question<T> {}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Provides options for a question for the `EditorPrompt`.
|
|
725
|
+
*
|
|
726
|
+
* @template T
|
|
727
|
+
* The type of the answers.
|
|
728
|
+
*/
|
|
729
|
+
interface EditorQuestion<T extends Answers = Answers> extends EditorQuestionOptions<T> {
|
|
730
|
+
/**
|
|
731
|
+
* @inheritdoc
|
|
732
|
+
*/
|
|
733
|
+
type: 'editor';
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Provides the available question-types.
|
|
738
|
+
*
|
|
739
|
+
* @template T
|
|
740
|
+
* The type of the answers.
|
|
741
|
+
*/
|
|
742
|
+
interface QuestionMap<T extends Answers = Answers> {
|
|
743
|
+
/**
|
|
744
|
+
* The `InputQuestion` type.
|
|
745
|
+
*/
|
|
746
|
+
input: InputQuestion<T>;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* The `NumberQuestion` type.
|
|
750
|
+
*/
|
|
751
|
+
number: NumberQuestion<T>;
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* The `PasswordQuestion` type.
|
|
755
|
+
*/
|
|
756
|
+
password: PasswordQuestion<T>;
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* The `ListQuestion` type.
|
|
760
|
+
*/
|
|
761
|
+
list: ListQuestion<T>;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* The `RawListQuestion` type.
|
|
765
|
+
*/
|
|
766
|
+
rawList: RawListQuestion<T>;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* The `ExpandQuestion` type.
|
|
770
|
+
*/
|
|
771
|
+
expand: ExpandQuestion<T>;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* The `CheckboxQuestion` type.
|
|
775
|
+
*/
|
|
776
|
+
checkbox: CheckboxQuestion<T>;
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* The `ConfirmQuestion` type.
|
|
780
|
+
*/
|
|
781
|
+
confirm: ConfirmQuestion<T>;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* The `EditorQuestion` type.
|
|
785
|
+
*/
|
|
786
|
+
editor: EditorQuestion<T>;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Represents one of the available questions.
|
|
791
|
+
*
|
|
792
|
+
* @template T
|
|
793
|
+
* The type of the answers.
|
|
794
|
+
*/
|
|
795
|
+
type DistinctQuestion<T extends Answers = Answers> = QuestionMap<T>[keyof QuestionMap<T>];
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Indicates the type of a question
|
|
799
|
+
*/
|
|
800
|
+
type QuestionTypeName = DistinctQuestion['type'];
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Represents a collection of questions.
|
|
804
|
+
*
|
|
805
|
+
* @template T
|
|
806
|
+
* The type of the answers.
|
|
807
|
+
*/
|
|
808
|
+
type QuestionCollection<T extends Answers = Answers> =
|
|
809
|
+
| DistinctQuestion<T>
|
|
810
|
+
| ReadonlyArray<DistinctQuestion<T>>
|
|
811
|
+
| Observable<DistinctQuestion<T>>;
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Provides components for the prompts.
|
|
815
|
+
*/
|
|
816
|
+
namespace prompts {
|
|
817
|
+
/**
|
|
818
|
+
* Provides a base for and prompt-options.
|
|
819
|
+
*
|
|
820
|
+
* @template T
|
|
821
|
+
* The type of the answers.
|
|
822
|
+
*/
|
|
823
|
+
type PromptOptions<T extends Question = Question> = T & {
|
|
824
|
+
/**
|
|
825
|
+
* The choices of the prompt.
|
|
826
|
+
*/
|
|
827
|
+
choices: Choices;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Represents the state of a prompt.
|
|
832
|
+
*/
|
|
833
|
+
type PromptState = LiteralUnion<'pending' | 'idle' | 'loading' | 'answered' | 'done'>;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Represents a prompt.
|
|
837
|
+
*/
|
|
838
|
+
interface PromptBase {
|
|
839
|
+
/**
|
|
840
|
+
* Gets or sets a string which represents the state of the prompt.
|
|
841
|
+
*/
|
|
842
|
+
status: PromptState;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Runs the prompt.
|
|
846
|
+
*
|
|
847
|
+
* @returns
|
|
848
|
+
* The result of the prompt.
|
|
849
|
+
*/
|
|
850
|
+
run(): Promise<any>;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Provides the functionality to initialize new prompts.
|
|
855
|
+
*/
|
|
856
|
+
interface PromptConstructor {
|
|
857
|
+
/**
|
|
858
|
+
* Initializes a new instance of a prompt.
|
|
859
|
+
*
|
|
860
|
+
* @param question
|
|
861
|
+
* The question to prompt.
|
|
862
|
+
*
|
|
863
|
+
* @param readLine
|
|
864
|
+
* An object for reading from the command-line.
|
|
865
|
+
*
|
|
866
|
+
* @param answers
|
|
867
|
+
* The answers provided by the user.
|
|
868
|
+
*/
|
|
869
|
+
new (question: any, readLine: ReadlineInterface, answers: Answers): PromptBase;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Provides a set of prompt-constructors.
|
|
874
|
+
*/
|
|
875
|
+
type PromptCollection = Record<string, PromptConstructor>;
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Provides data about the state of a prompt.
|
|
879
|
+
*/
|
|
880
|
+
interface PromptStateData {
|
|
881
|
+
/**
|
|
882
|
+
* Either a string which describes the error of the prompt or a boolean indicating whether the prompt-value is valid.
|
|
883
|
+
*/
|
|
884
|
+
isValid: string | boolean;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Provides data about the successful state of a prompt.
|
|
889
|
+
*
|
|
890
|
+
* @param T
|
|
891
|
+
* The type of the answer.
|
|
892
|
+
*/
|
|
893
|
+
interface SuccessfulPromptStateData<T = any> extends PromptStateData {
|
|
894
|
+
/**
|
|
895
|
+
* @inheritdoc
|
|
896
|
+
*/
|
|
897
|
+
isValid: true;
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* The value of the prompt.
|
|
901
|
+
*/
|
|
902
|
+
value: T;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Provides data about the failed state of a prompt.
|
|
907
|
+
*/
|
|
908
|
+
interface FailedPromptStateData extends PromptStateData {
|
|
909
|
+
/**
|
|
910
|
+
* @inheritdoc
|
|
911
|
+
*/
|
|
912
|
+
isValid: false | string;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Provides pipes for handling events of a prompt.
|
|
917
|
+
*
|
|
918
|
+
* @param T
|
|
919
|
+
* The type of the answer.
|
|
920
|
+
*/
|
|
921
|
+
interface PromptEventPipes<T = any> {
|
|
922
|
+
/**
|
|
923
|
+
* A pypeline for succesful inputs.
|
|
924
|
+
*/
|
|
925
|
+
success: Observable<SuccessfulPromptStateData<T>>;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* An object representing an error.
|
|
929
|
+
*/
|
|
930
|
+
error: Observable<FailedPromptStateData>;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Provides components for the ui.
|
|
936
|
+
*/
|
|
937
|
+
namespace ui {
|
|
938
|
+
/**
|
|
939
|
+
* Provides options for the bottom-bar UI.
|
|
940
|
+
*/
|
|
941
|
+
interface BottomBarOptions extends StreamOptions {
|
|
942
|
+
/**
|
|
943
|
+
* The initial text to display.
|
|
944
|
+
*/
|
|
945
|
+
bottomBar?: string | undefined;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Represents a fetched answer.
|
|
950
|
+
*
|
|
951
|
+
* @template T
|
|
952
|
+
* The type of the answers.
|
|
953
|
+
*/
|
|
954
|
+
type FetchedQuestion<T extends Answers = Answers> = DistinctQuestion<T> & {
|
|
955
|
+
/**
|
|
956
|
+
* The type of the question.
|
|
957
|
+
*/
|
|
958
|
+
type: string;
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* The message to show to the user.
|
|
962
|
+
*/
|
|
963
|
+
message: string;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* The default value of the question.
|
|
967
|
+
*/
|
|
968
|
+
default: any;
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* The choices of the question.
|
|
972
|
+
*/
|
|
973
|
+
choices: ChoiceCollection<T>;
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Represents a fetched answer.
|
|
978
|
+
*/
|
|
979
|
+
interface FetchedAnswer {
|
|
980
|
+
/**
|
|
981
|
+
* The name of the answer.
|
|
982
|
+
*/
|
|
983
|
+
name: string;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* The value of the answer.
|
|
987
|
+
*/
|
|
988
|
+
answer: any;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Provides the functionality to prompt questions.
|
|
995
|
+
*/
|
|
996
|
+
declare var inquirer: inquirer.Inquirer;
|
|
997
|
+
export = inquirer;
|