1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
7 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
8 | };
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.createPromptModule = createPromptModule;
|
11 | const prompts_1 = require("@inquirer/prompts");
|
12 | const prompt_mjs_1 = __importDefault(require('./ui/prompt.js'));
|
13 | const defaultPrompts = {
|
14 | input: prompts_1.input,
|
15 | select: prompts_1.select,
|
16 |
|
17 | list: prompts_1.select,
|
18 | number: prompts_1.number,
|
19 | confirm: prompts_1.confirm,
|
20 | rawlist: prompts_1.rawlist,
|
21 | expand: prompts_1.expand,
|
22 | checkbox: prompts_1.checkbox,
|
23 | password: prompts_1.password,
|
24 | editor: prompts_1.editor,
|
25 | };
|
26 |
|
27 |
|
28 |
|
29 | function createPromptModule(opt) {
|
30 | function promptModule(questions, answers) {
|
31 | const runner = new prompt_mjs_1.default(promptModule.prompts, opt);
|
32 | try {
|
33 | return runner.run(questions, answers);
|
34 | }
|
35 | catch (error) {
|
36 | const promise = Promise.reject(error);
|
37 | return Object.assign(promise, { ui: runner });
|
38 | }
|
39 | }
|
40 | promptModule.prompts = Object.assign({}, defaultPrompts);
|
41 | |
42 |
|
43 |
|
44 | promptModule.registerPrompt = function (name, prompt) {
|
45 | promptModule.prompts[name] = prompt;
|
46 | return this;
|
47 | };
|
48 | |
49 |
|
50 |
|
51 | promptModule.restoreDefaultPrompts = function () {
|
52 | promptModule.prompts = Object.assign({}, defaultPrompts);
|
53 | };
|
54 | return promptModule;
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 | const prompt = createPromptModule();
|
60 |
|
61 | function registerPrompt(name, newPrompt) {
|
62 | prompt.registerPrompt(name, newPrompt);
|
63 | }
|
64 | function restoreDefaultPrompts() {
|
65 | prompt.restoreDefaultPrompts();
|
66 | }
|
67 | const inquirer = {
|
68 | prompt,
|
69 | ui: {
|
70 | Prompt: prompt_mjs_1.default,
|
71 | },
|
72 | createPromptModule,
|
73 | registerPrompt,
|
74 | restoreDefaultPrompts,
|
75 | Separator: prompts_1.Separator,
|
76 | };
|
77 | exports.default = inquirer;
|