@stencil/core 4.17.0 → 4.17.1-dev.1713968712.c1205ef
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/cli/index.cjs +2397 -3
- package/cli/index.js +2425 -3
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +4 -4
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/index.js +51 -16
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/hydrate/index.js +51 -16
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.js +1 -1
- package/internal/package.json +1 -1
- package/internal/testing/index.js +50 -15
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +1 -1
- package/mock-doc/index.js +1 -1
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- package/screenshot/index.js +1 -1
- package/screenshot/package.json +1 -1
- package/screenshot/pixel-match.js +1 -1
- package/sys/node/index.js +1 -1
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +1 -1
- package/testing/package.json +1 -1
package/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI (CommonJS) v4.17.
|
|
2
|
+
Stencil CLI (CommonJS) v4.17.1-dev.1713968712.c1205ef | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
"use strict";
|
|
5
5
|
var __create = Object.create;
|
|
@@ -8,6 +8,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
8
8
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
11
14
|
var __export = (target, all) => {
|
|
12
15
|
for (var name in all)
|
|
13
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,6 +33,2397 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
33
|
));
|
|
31
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
35
|
|
|
36
|
+
// node_modules/kleur/index.js
|
|
37
|
+
var require_kleur = __commonJS({
|
|
38
|
+
"node_modules/kleur/index.js"(exports2, module2) {
|
|
39
|
+
"use strict";
|
|
40
|
+
var { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
|
|
41
|
+
var $ = {
|
|
42
|
+
enabled: !NODE_DISABLE_COLORS && TERM !== "dumb" && FORCE_COLOR !== "0",
|
|
43
|
+
// modifiers
|
|
44
|
+
reset: init(0, 0),
|
|
45
|
+
bold: init(1, 22),
|
|
46
|
+
dim: init(2, 22),
|
|
47
|
+
italic: init(3, 23),
|
|
48
|
+
underline: init(4, 24),
|
|
49
|
+
inverse: init(7, 27),
|
|
50
|
+
hidden: init(8, 28),
|
|
51
|
+
strikethrough: init(9, 29),
|
|
52
|
+
// colors
|
|
53
|
+
black: init(30, 39),
|
|
54
|
+
red: init(31, 39),
|
|
55
|
+
green: init(32, 39),
|
|
56
|
+
yellow: init(33, 39),
|
|
57
|
+
blue: init(34, 39),
|
|
58
|
+
magenta: init(35, 39),
|
|
59
|
+
cyan: init(36, 39),
|
|
60
|
+
white: init(37, 39),
|
|
61
|
+
gray: init(90, 39),
|
|
62
|
+
grey: init(90, 39),
|
|
63
|
+
// background colors
|
|
64
|
+
bgBlack: init(40, 49),
|
|
65
|
+
bgRed: init(41, 49),
|
|
66
|
+
bgGreen: init(42, 49),
|
|
67
|
+
bgYellow: init(43, 49),
|
|
68
|
+
bgBlue: init(44, 49),
|
|
69
|
+
bgMagenta: init(45, 49),
|
|
70
|
+
bgCyan: init(46, 49),
|
|
71
|
+
bgWhite: init(47, 49)
|
|
72
|
+
};
|
|
73
|
+
function run2(arr, str) {
|
|
74
|
+
let i = 0, tmp, beg = "", end = "";
|
|
75
|
+
for (; i < arr.length; i++) {
|
|
76
|
+
tmp = arr[i];
|
|
77
|
+
beg += tmp.open;
|
|
78
|
+
end += tmp.close;
|
|
79
|
+
if (str.includes(tmp.close)) {
|
|
80
|
+
str = str.replace(tmp.rgx, tmp.close + tmp.open);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return beg + str + end;
|
|
84
|
+
}
|
|
85
|
+
function chain(has, keys) {
|
|
86
|
+
let ctx = { has, keys };
|
|
87
|
+
ctx.reset = $.reset.bind(ctx);
|
|
88
|
+
ctx.bold = $.bold.bind(ctx);
|
|
89
|
+
ctx.dim = $.dim.bind(ctx);
|
|
90
|
+
ctx.italic = $.italic.bind(ctx);
|
|
91
|
+
ctx.underline = $.underline.bind(ctx);
|
|
92
|
+
ctx.inverse = $.inverse.bind(ctx);
|
|
93
|
+
ctx.hidden = $.hidden.bind(ctx);
|
|
94
|
+
ctx.strikethrough = $.strikethrough.bind(ctx);
|
|
95
|
+
ctx.black = $.black.bind(ctx);
|
|
96
|
+
ctx.red = $.red.bind(ctx);
|
|
97
|
+
ctx.green = $.green.bind(ctx);
|
|
98
|
+
ctx.yellow = $.yellow.bind(ctx);
|
|
99
|
+
ctx.blue = $.blue.bind(ctx);
|
|
100
|
+
ctx.magenta = $.magenta.bind(ctx);
|
|
101
|
+
ctx.cyan = $.cyan.bind(ctx);
|
|
102
|
+
ctx.white = $.white.bind(ctx);
|
|
103
|
+
ctx.gray = $.gray.bind(ctx);
|
|
104
|
+
ctx.grey = $.grey.bind(ctx);
|
|
105
|
+
ctx.bgBlack = $.bgBlack.bind(ctx);
|
|
106
|
+
ctx.bgRed = $.bgRed.bind(ctx);
|
|
107
|
+
ctx.bgGreen = $.bgGreen.bind(ctx);
|
|
108
|
+
ctx.bgYellow = $.bgYellow.bind(ctx);
|
|
109
|
+
ctx.bgBlue = $.bgBlue.bind(ctx);
|
|
110
|
+
ctx.bgMagenta = $.bgMagenta.bind(ctx);
|
|
111
|
+
ctx.bgCyan = $.bgCyan.bind(ctx);
|
|
112
|
+
ctx.bgWhite = $.bgWhite.bind(ctx);
|
|
113
|
+
return ctx;
|
|
114
|
+
}
|
|
115
|
+
function init(open, close) {
|
|
116
|
+
let blk = {
|
|
117
|
+
open: `\x1B[${open}m`,
|
|
118
|
+
close: `\x1B[${close}m`,
|
|
119
|
+
rgx: new RegExp(`\\x1b\\[${close}m`, "g")
|
|
120
|
+
};
|
|
121
|
+
return function(txt) {
|
|
122
|
+
if (this !== void 0 && this.has !== void 0) {
|
|
123
|
+
this.has.includes(open) || (this.has.push(open), this.keys.push(blk));
|
|
124
|
+
return txt === void 0 ? this : $.enabled ? run2(this.keys, txt + "") : txt + "";
|
|
125
|
+
}
|
|
126
|
+
return txt === void 0 ? chain([open], [blk]) : $.enabled ? run2([blk], txt + "") : txt + "";
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
module2.exports = $;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// node_modules/prompts/lib/util/action.js
|
|
134
|
+
var require_action = __commonJS({
|
|
135
|
+
"node_modules/prompts/lib/util/action.js"(exports2, module2) {
|
|
136
|
+
"use strict";
|
|
137
|
+
module2.exports = (key, isSelect) => {
|
|
138
|
+
if (key.meta && key.name !== "escape")
|
|
139
|
+
return;
|
|
140
|
+
if (key.ctrl) {
|
|
141
|
+
if (key.name === "a")
|
|
142
|
+
return "first";
|
|
143
|
+
if (key.name === "c")
|
|
144
|
+
return "abort";
|
|
145
|
+
if (key.name === "d")
|
|
146
|
+
return "abort";
|
|
147
|
+
if (key.name === "e")
|
|
148
|
+
return "last";
|
|
149
|
+
if (key.name === "g")
|
|
150
|
+
return "reset";
|
|
151
|
+
}
|
|
152
|
+
if (isSelect) {
|
|
153
|
+
if (key.name === "j")
|
|
154
|
+
return "down";
|
|
155
|
+
if (key.name === "k")
|
|
156
|
+
return "up";
|
|
157
|
+
}
|
|
158
|
+
if (key.name === "return")
|
|
159
|
+
return "submit";
|
|
160
|
+
if (key.name === "enter")
|
|
161
|
+
return "submit";
|
|
162
|
+
if (key.name === "backspace")
|
|
163
|
+
return "delete";
|
|
164
|
+
if (key.name === "delete")
|
|
165
|
+
return "deleteForward";
|
|
166
|
+
if (key.name === "abort")
|
|
167
|
+
return "abort";
|
|
168
|
+
if (key.name === "escape")
|
|
169
|
+
return "exit";
|
|
170
|
+
if (key.name === "tab")
|
|
171
|
+
return "next";
|
|
172
|
+
if (key.name === "pagedown")
|
|
173
|
+
return "nextPage";
|
|
174
|
+
if (key.name === "pageup")
|
|
175
|
+
return "prevPage";
|
|
176
|
+
if (key.name === "home")
|
|
177
|
+
return "home";
|
|
178
|
+
if (key.name === "end")
|
|
179
|
+
return "end";
|
|
180
|
+
if (key.name === "up")
|
|
181
|
+
return "up";
|
|
182
|
+
if (key.name === "down")
|
|
183
|
+
return "down";
|
|
184
|
+
if (key.name === "right")
|
|
185
|
+
return "right";
|
|
186
|
+
if (key.name === "left")
|
|
187
|
+
return "left";
|
|
188
|
+
return false;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// node_modules/prompts/lib/util/strip.js
|
|
194
|
+
var require_strip = __commonJS({
|
|
195
|
+
"node_modules/prompts/lib/util/strip.js"(exports2, module2) {
|
|
196
|
+
"use strict";
|
|
197
|
+
module2.exports = (str) => {
|
|
198
|
+
const pattern = [
|
|
199
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
200
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
201
|
+
].join("|");
|
|
202
|
+
const RGX = new RegExp(pattern, "g");
|
|
203
|
+
return typeof str === "string" ? str.replace(RGX, "") : str;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// node_modules/sisteransi/src/index.js
|
|
209
|
+
var require_src = __commonJS({
|
|
210
|
+
"node_modules/sisteransi/src/index.js"(exports2, module2) {
|
|
211
|
+
"use strict";
|
|
212
|
+
var ESC = "\x1B";
|
|
213
|
+
var CSI = `${ESC}[`;
|
|
214
|
+
var beep = "\x07";
|
|
215
|
+
var cursor = {
|
|
216
|
+
to(x, y) {
|
|
217
|
+
if (!y)
|
|
218
|
+
return `${CSI}${x + 1}G`;
|
|
219
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
220
|
+
},
|
|
221
|
+
move(x, y) {
|
|
222
|
+
let ret = "";
|
|
223
|
+
if (x < 0)
|
|
224
|
+
ret += `${CSI}${-x}D`;
|
|
225
|
+
else if (x > 0)
|
|
226
|
+
ret += `${CSI}${x}C`;
|
|
227
|
+
if (y < 0)
|
|
228
|
+
ret += `${CSI}${-y}A`;
|
|
229
|
+
else if (y > 0)
|
|
230
|
+
ret += `${CSI}${y}B`;
|
|
231
|
+
return ret;
|
|
232
|
+
},
|
|
233
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
234
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
235
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
236
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
237
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
238
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
239
|
+
left: `${CSI}G`,
|
|
240
|
+
hide: `${CSI}?25l`,
|
|
241
|
+
show: `${CSI}?25h`,
|
|
242
|
+
save: `${ESC}7`,
|
|
243
|
+
restore: `${ESC}8`
|
|
244
|
+
};
|
|
245
|
+
var scroll = {
|
|
246
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
247
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
248
|
+
};
|
|
249
|
+
var erase = {
|
|
250
|
+
screen: `${CSI}2J`,
|
|
251
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
252
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
253
|
+
line: `${CSI}2K`,
|
|
254
|
+
lineEnd: `${CSI}K`,
|
|
255
|
+
lineStart: `${CSI}1K`,
|
|
256
|
+
lines(count) {
|
|
257
|
+
let clear = "";
|
|
258
|
+
for (let i = 0; i < count; i++)
|
|
259
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
260
|
+
if (count)
|
|
261
|
+
clear += cursor.left;
|
|
262
|
+
return clear;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
module2.exports = { cursor, scroll, erase, beep };
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// node_modules/prompts/lib/util/clear.js
|
|
270
|
+
var require_clear = __commonJS({
|
|
271
|
+
"node_modules/prompts/lib/util/clear.js"(exports2, module2) {
|
|
272
|
+
"use strict";
|
|
273
|
+
var strip = require_strip();
|
|
274
|
+
var { erase, cursor } = require_src();
|
|
275
|
+
var width = (str) => [...strip(str)].length;
|
|
276
|
+
module2.exports = function(prompt, perLine) {
|
|
277
|
+
if (!perLine)
|
|
278
|
+
return erase.line + cursor.to(0);
|
|
279
|
+
let rows = 0;
|
|
280
|
+
const lines = prompt.split(/\r?\n/);
|
|
281
|
+
for (let line of lines) {
|
|
282
|
+
rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
|
|
283
|
+
}
|
|
284
|
+
return erase.lines(rows);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// node_modules/prompts/lib/util/figures.js
|
|
290
|
+
var require_figures = __commonJS({
|
|
291
|
+
"node_modules/prompts/lib/util/figures.js"(exports2, module2) {
|
|
292
|
+
"use strict";
|
|
293
|
+
var main = {
|
|
294
|
+
arrowUp: "\u2191",
|
|
295
|
+
arrowDown: "\u2193",
|
|
296
|
+
arrowLeft: "\u2190",
|
|
297
|
+
arrowRight: "\u2192",
|
|
298
|
+
radioOn: "\u25C9",
|
|
299
|
+
radioOff: "\u25EF",
|
|
300
|
+
tick: "\u2714",
|
|
301
|
+
cross: "\u2716",
|
|
302
|
+
ellipsis: "\u2026",
|
|
303
|
+
pointerSmall: "\u203A",
|
|
304
|
+
line: "\u2500",
|
|
305
|
+
pointer: "\u276F"
|
|
306
|
+
};
|
|
307
|
+
var win = {
|
|
308
|
+
arrowUp: main.arrowUp,
|
|
309
|
+
arrowDown: main.arrowDown,
|
|
310
|
+
arrowLeft: main.arrowLeft,
|
|
311
|
+
arrowRight: main.arrowRight,
|
|
312
|
+
radioOn: "(*)",
|
|
313
|
+
radioOff: "( )",
|
|
314
|
+
tick: "\u221A",
|
|
315
|
+
cross: "\xD7",
|
|
316
|
+
ellipsis: "...",
|
|
317
|
+
pointerSmall: "\xBB",
|
|
318
|
+
line: "\u2500",
|
|
319
|
+
pointer: ">"
|
|
320
|
+
};
|
|
321
|
+
var figures = process.platform === "win32" ? win : main;
|
|
322
|
+
module2.exports = figures;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// node_modules/prompts/lib/util/style.js
|
|
327
|
+
var require_style = __commonJS({
|
|
328
|
+
"node_modules/prompts/lib/util/style.js"(exports2, module2) {
|
|
329
|
+
"use strict";
|
|
330
|
+
var c = require_kleur();
|
|
331
|
+
var figures = require_figures();
|
|
332
|
+
var styles = Object.freeze({
|
|
333
|
+
password: { scale: 1, render: (input) => "*".repeat(input.length) },
|
|
334
|
+
emoji: { scale: 2, render: (input) => "\u{1F603}".repeat(input.length) },
|
|
335
|
+
invisible: { scale: 0, render: (input) => "" },
|
|
336
|
+
default: { scale: 1, render: (input) => `${input}` }
|
|
337
|
+
});
|
|
338
|
+
var render = (type) => styles[type] || styles.default;
|
|
339
|
+
var symbols = Object.freeze({
|
|
340
|
+
aborted: c.red(figures.cross),
|
|
341
|
+
done: c.green(figures.tick),
|
|
342
|
+
exited: c.yellow(figures.cross),
|
|
343
|
+
default: c.cyan("?")
|
|
344
|
+
});
|
|
345
|
+
var symbol = (done, aborted, exited) => aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default;
|
|
346
|
+
var delimiter = (completing) => c.gray(completing ? figures.ellipsis : figures.pointerSmall);
|
|
347
|
+
var item = (expandable, expanded) => c.gray(expandable ? expanded ? figures.pointerSmall : "+" : figures.line);
|
|
348
|
+
module2.exports = {
|
|
349
|
+
styles,
|
|
350
|
+
render,
|
|
351
|
+
symbols,
|
|
352
|
+
symbol,
|
|
353
|
+
delimiter,
|
|
354
|
+
item
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
// node_modules/prompts/lib/util/lines.js
|
|
360
|
+
var require_lines = __commonJS({
|
|
361
|
+
"node_modules/prompts/lib/util/lines.js"(exports2, module2) {
|
|
362
|
+
"use strict";
|
|
363
|
+
var strip = require_strip();
|
|
364
|
+
module2.exports = function(msg, perLine) {
|
|
365
|
+
let lines = String(strip(msg) || "").split(/\r?\n/);
|
|
366
|
+
if (!perLine)
|
|
367
|
+
return lines.length;
|
|
368
|
+
return lines.map((l) => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// node_modules/prompts/lib/util/wrap.js
|
|
374
|
+
var require_wrap = __commonJS({
|
|
375
|
+
"node_modules/prompts/lib/util/wrap.js"(exports2, module2) {
|
|
376
|
+
"use strict";
|
|
377
|
+
module2.exports = (msg, opts = {}) => {
|
|
378
|
+
const tab = Number.isSafeInteger(parseInt(opts.margin)) ? new Array(parseInt(opts.margin)).fill(" ").join("") : opts.margin || "";
|
|
379
|
+
const width = opts.width;
|
|
380
|
+
return (msg || "").split(/\r?\n/g).map((line) => line.split(/\s+/g).reduce((arr, w) => {
|
|
381
|
+
if (w.length + tab.length >= width || arr[arr.length - 1].length + w.length + 1 < width)
|
|
382
|
+
arr[arr.length - 1] += ` ${w}`;
|
|
383
|
+
else
|
|
384
|
+
arr.push(`${tab}${w}`);
|
|
385
|
+
return arr;
|
|
386
|
+
}, [tab]).join("\n")).join("\n");
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// node_modules/prompts/lib/util/entriesToDisplay.js
|
|
392
|
+
var require_entriesToDisplay = __commonJS({
|
|
393
|
+
"node_modules/prompts/lib/util/entriesToDisplay.js"(exports2, module2) {
|
|
394
|
+
"use strict";
|
|
395
|
+
module2.exports = (cursor, total, maxVisible) => {
|
|
396
|
+
maxVisible = maxVisible || total;
|
|
397
|
+
let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2));
|
|
398
|
+
if (startIndex < 0)
|
|
399
|
+
startIndex = 0;
|
|
400
|
+
let endIndex = Math.min(startIndex + maxVisible, total);
|
|
401
|
+
return { startIndex, endIndex };
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// node_modules/prompts/lib/util/index.js
|
|
407
|
+
var require_util = __commonJS({
|
|
408
|
+
"node_modules/prompts/lib/util/index.js"(exports2, module2) {
|
|
409
|
+
"use strict";
|
|
410
|
+
module2.exports = {
|
|
411
|
+
action: require_action(),
|
|
412
|
+
clear: require_clear(),
|
|
413
|
+
style: require_style(),
|
|
414
|
+
strip: require_strip(),
|
|
415
|
+
figures: require_figures(),
|
|
416
|
+
lines: require_lines(),
|
|
417
|
+
wrap: require_wrap(),
|
|
418
|
+
entriesToDisplay: require_entriesToDisplay()
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// node_modules/prompts/lib/elements/prompt.js
|
|
424
|
+
var require_prompt = __commonJS({
|
|
425
|
+
"node_modules/prompts/lib/elements/prompt.js"(exports2, module2) {
|
|
426
|
+
"use strict";
|
|
427
|
+
var readline = require("readline");
|
|
428
|
+
var { action } = require_util();
|
|
429
|
+
var EventEmitter = require("events");
|
|
430
|
+
var { beep, cursor } = require_src();
|
|
431
|
+
var color = require_kleur();
|
|
432
|
+
var Prompt = class extends EventEmitter {
|
|
433
|
+
constructor(opts = {}) {
|
|
434
|
+
super();
|
|
435
|
+
this.firstRender = true;
|
|
436
|
+
this.in = opts.stdin || process.stdin;
|
|
437
|
+
this.out = opts.stdout || process.stdout;
|
|
438
|
+
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
439
|
+
const rl = readline.createInterface({ input: this.in, escapeCodeTimeout: 50 });
|
|
440
|
+
readline.emitKeypressEvents(this.in, rl);
|
|
441
|
+
if (this.in.isTTY)
|
|
442
|
+
this.in.setRawMode(true);
|
|
443
|
+
const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
|
|
444
|
+
const keypress = (str, key) => {
|
|
445
|
+
let a = action(key, isSelect);
|
|
446
|
+
if (a === false) {
|
|
447
|
+
this._ && this._(str, key);
|
|
448
|
+
} else if (typeof this[a] === "function") {
|
|
449
|
+
this[a](key);
|
|
450
|
+
} else {
|
|
451
|
+
this.bell();
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
this.close = () => {
|
|
455
|
+
this.out.write(cursor.show);
|
|
456
|
+
this.in.removeListener("keypress", keypress);
|
|
457
|
+
if (this.in.isTTY)
|
|
458
|
+
this.in.setRawMode(false);
|
|
459
|
+
rl.close();
|
|
460
|
+
this.emit(this.aborted ? "abort" : this.exited ? "exit" : "submit", this.value);
|
|
461
|
+
this.closed = true;
|
|
462
|
+
};
|
|
463
|
+
this.in.on("keypress", keypress);
|
|
464
|
+
}
|
|
465
|
+
fire() {
|
|
466
|
+
this.emit("state", {
|
|
467
|
+
value: this.value,
|
|
468
|
+
aborted: !!this.aborted,
|
|
469
|
+
exited: !!this.exited
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
bell() {
|
|
473
|
+
this.out.write(beep);
|
|
474
|
+
}
|
|
475
|
+
render() {
|
|
476
|
+
this.onRender(color);
|
|
477
|
+
if (this.firstRender)
|
|
478
|
+
this.firstRender = false;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
module2.exports = Prompt;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// node_modules/prompts/lib/elements/text.js
|
|
486
|
+
var require_text = __commonJS({
|
|
487
|
+
"node_modules/prompts/lib/elements/text.js"(exports2, module2) {
|
|
488
|
+
var color = require_kleur();
|
|
489
|
+
var Prompt = require_prompt();
|
|
490
|
+
var { erase, cursor } = require_src();
|
|
491
|
+
var { style, clear, lines, figures } = require_util();
|
|
492
|
+
var TextPrompt = class extends Prompt {
|
|
493
|
+
constructor(opts = {}) {
|
|
494
|
+
super(opts);
|
|
495
|
+
this.transform = style.render(opts.style);
|
|
496
|
+
this.scale = this.transform.scale;
|
|
497
|
+
this.msg = opts.message;
|
|
498
|
+
this.initial = opts.initial || ``;
|
|
499
|
+
this.validator = opts.validate || (() => true);
|
|
500
|
+
this.value = ``;
|
|
501
|
+
this.errorMsg = opts.error || `Please Enter A Valid Value`;
|
|
502
|
+
this.cursor = Number(!!this.initial);
|
|
503
|
+
this.cursorOffset = 0;
|
|
504
|
+
this.clear = clear(``, this.out.columns);
|
|
505
|
+
this.render();
|
|
506
|
+
}
|
|
507
|
+
set value(v) {
|
|
508
|
+
if (!v && this.initial) {
|
|
509
|
+
this.placeholder = true;
|
|
510
|
+
this.rendered = color.gray(this.transform.render(this.initial));
|
|
511
|
+
} else {
|
|
512
|
+
this.placeholder = false;
|
|
513
|
+
this.rendered = this.transform.render(v);
|
|
514
|
+
}
|
|
515
|
+
this._value = v;
|
|
516
|
+
this.fire();
|
|
517
|
+
}
|
|
518
|
+
get value() {
|
|
519
|
+
return this._value;
|
|
520
|
+
}
|
|
521
|
+
reset() {
|
|
522
|
+
this.value = ``;
|
|
523
|
+
this.cursor = Number(!!this.initial);
|
|
524
|
+
this.cursorOffset = 0;
|
|
525
|
+
this.fire();
|
|
526
|
+
this.render();
|
|
527
|
+
}
|
|
528
|
+
exit() {
|
|
529
|
+
this.abort();
|
|
530
|
+
}
|
|
531
|
+
abort() {
|
|
532
|
+
this.value = this.value || this.initial;
|
|
533
|
+
this.done = this.aborted = true;
|
|
534
|
+
this.error = false;
|
|
535
|
+
this.red = false;
|
|
536
|
+
this.fire();
|
|
537
|
+
this.render();
|
|
538
|
+
this.out.write("\n");
|
|
539
|
+
this.close();
|
|
540
|
+
}
|
|
541
|
+
async validate() {
|
|
542
|
+
let valid = await this.validator(this.value);
|
|
543
|
+
if (typeof valid === `string`) {
|
|
544
|
+
this.errorMsg = valid;
|
|
545
|
+
valid = false;
|
|
546
|
+
}
|
|
547
|
+
this.error = !valid;
|
|
548
|
+
}
|
|
549
|
+
async submit() {
|
|
550
|
+
this.value = this.value || this.initial;
|
|
551
|
+
this.cursorOffset = 0;
|
|
552
|
+
this.cursor = this.rendered.length;
|
|
553
|
+
await this.validate();
|
|
554
|
+
if (this.error) {
|
|
555
|
+
this.red = true;
|
|
556
|
+
this.fire();
|
|
557
|
+
this.render();
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
this.done = true;
|
|
561
|
+
this.aborted = false;
|
|
562
|
+
this.fire();
|
|
563
|
+
this.render();
|
|
564
|
+
this.out.write("\n");
|
|
565
|
+
this.close();
|
|
566
|
+
}
|
|
567
|
+
next() {
|
|
568
|
+
if (!this.placeholder)
|
|
569
|
+
return this.bell();
|
|
570
|
+
this.value = this.initial;
|
|
571
|
+
this.cursor = this.rendered.length;
|
|
572
|
+
this.fire();
|
|
573
|
+
this.render();
|
|
574
|
+
}
|
|
575
|
+
moveCursor(n) {
|
|
576
|
+
if (this.placeholder)
|
|
577
|
+
return;
|
|
578
|
+
this.cursor = this.cursor + n;
|
|
579
|
+
this.cursorOffset += n;
|
|
580
|
+
}
|
|
581
|
+
_(c, key) {
|
|
582
|
+
let s1 = this.value.slice(0, this.cursor);
|
|
583
|
+
let s2 = this.value.slice(this.cursor);
|
|
584
|
+
this.value = `${s1}${c}${s2}`;
|
|
585
|
+
this.red = false;
|
|
586
|
+
this.cursor = this.placeholder ? 0 : s1.length + 1;
|
|
587
|
+
this.render();
|
|
588
|
+
}
|
|
589
|
+
delete() {
|
|
590
|
+
if (this.isCursorAtStart())
|
|
591
|
+
return this.bell();
|
|
592
|
+
let s1 = this.value.slice(0, this.cursor - 1);
|
|
593
|
+
let s2 = this.value.slice(this.cursor);
|
|
594
|
+
this.value = `${s1}${s2}`;
|
|
595
|
+
this.red = false;
|
|
596
|
+
if (this.isCursorAtStart()) {
|
|
597
|
+
this.cursorOffset = 0;
|
|
598
|
+
} else {
|
|
599
|
+
this.cursorOffset++;
|
|
600
|
+
this.moveCursor(-1);
|
|
601
|
+
}
|
|
602
|
+
this.render();
|
|
603
|
+
}
|
|
604
|
+
deleteForward() {
|
|
605
|
+
if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
|
|
606
|
+
return this.bell();
|
|
607
|
+
let s1 = this.value.slice(0, this.cursor);
|
|
608
|
+
let s2 = this.value.slice(this.cursor + 1);
|
|
609
|
+
this.value = `${s1}${s2}`;
|
|
610
|
+
this.red = false;
|
|
611
|
+
if (this.isCursorAtEnd()) {
|
|
612
|
+
this.cursorOffset = 0;
|
|
613
|
+
} else {
|
|
614
|
+
this.cursorOffset++;
|
|
615
|
+
}
|
|
616
|
+
this.render();
|
|
617
|
+
}
|
|
618
|
+
first() {
|
|
619
|
+
this.cursor = 0;
|
|
620
|
+
this.render();
|
|
621
|
+
}
|
|
622
|
+
last() {
|
|
623
|
+
this.cursor = this.value.length;
|
|
624
|
+
this.render();
|
|
625
|
+
}
|
|
626
|
+
left() {
|
|
627
|
+
if (this.cursor <= 0 || this.placeholder)
|
|
628
|
+
return this.bell();
|
|
629
|
+
this.moveCursor(-1);
|
|
630
|
+
this.render();
|
|
631
|
+
}
|
|
632
|
+
right() {
|
|
633
|
+
if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
|
|
634
|
+
return this.bell();
|
|
635
|
+
this.moveCursor(1);
|
|
636
|
+
this.render();
|
|
637
|
+
}
|
|
638
|
+
isCursorAtStart() {
|
|
639
|
+
return this.cursor === 0 || this.placeholder && this.cursor === 1;
|
|
640
|
+
}
|
|
641
|
+
isCursorAtEnd() {
|
|
642
|
+
return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
|
|
643
|
+
}
|
|
644
|
+
render() {
|
|
645
|
+
if (this.closed)
|
|
646
|
+
return;
|
|
647
|
+
if (!this.firstRender) {
|
|
648
|
+
if (this.outputError)
|
|
649
|
+
this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
|
|
650
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
651
|
+
}
|
|
652
|
+
super.render();
|
|
653
|
+
this.outputError = "";
|
|
654
|
+
this.outputText = [
|
|
655
|
+
style.symbol(this.done, this.aborted),
|
|
656
|
+
color.bold(this.msg),
|
|
657
|
+
style.delimiter(this.done),
|
|
658
|
+
this.red ? color.red(this.rendered) : this.rendered
|
|
659
|
+
].join(` `);
|
|
660
|
+
if (this.error) {
|
|
661
|
+
this.outputError += this.errorMsg.split(`
|
|
662
|
+
`).reduce((a, l, i) => a + `
|
|
663
|
+
${i ? " " : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
664
|
+
}
|
|
665
|
+
this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0));
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
module2.exports = TextPrompt;
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// node_modules/prompts/lib/elements/select.js
|
|
673
|
+
var require_select = __commonJS({
|
|
674
|
+
"node_modules/prompts/lib/elements/select.js"(exports2, module2) {
|
|
675
|
+
"use strict";
|
|
676
|
+
var color = require_kleur();
|
|
677
|
+
var Prompt = require_prompt();
|
|
678
|
+
var { style, clear, figures, wrap, entriesToDisplay } = require_util();
|
|
679
|
+
var { cursor } = require_src();
|
|
680
|
+
var SelectPrompt = class extends Prompt {
|
|
681
|
+
constructor(opts = {}) {
|
|
682
|
+
super(opts);
|
|
683
|
+
this.msg = opts.message;
|
|
684
|
+
this.hint = opts.hint || "- Use arrow-keys. Return to submit.";
|
|
685
|
+
this.warn = opts.warn || "- This option is disabled";
|
|
686
|
+
this.cursor = opts.initial || 0;
|
|
687
|
+
this.choices = opts.choices.map((ch, idx) => {
|
|
688
|
+
if (typeof ch === "string")
|
|
689
|
+
ch = { title: ch, value: idx };
|
|
690
|
+
return {
|
|
691
|
+
title: ch && (ch.title || ch.value || ch),
|
|
692
|
+
value: ch && (ch.value === void 0 ? idx : ch.value),
|
|
693
|
+
description: ch && ch.description,
|
|
694
|
+
selected: ch && ch.selected,
|
|
695
|
+
disabled: ch && ch.disabled
|
|
696
|
+
};
|
|
697
|
+
});
|
|
698
|
+
this.optionsPerPage = opts.optionsPerPage || 10;
|
|
699
|
+
this.value = (this.choices[this.cursor] || {}).value;
|
|
700
|
+
this.clear = clear("", this.out.columns);
|
|
701
|
+
this.render();
|
|
702
|
+
}
|
|
703
|
+
moveCursor(n) {
|
|
704
|
+
this.cursor = n;
|
|
705
|
+
this.value = this.choices[n].value;
|
|
706
|
+
this.fire();
|
|
707
|
+
}
|
|
708
|
+
reset() {
|
|
709
|
+
this.moveCursor(0);
|
|
710
|
+
this.fire();
|
|
711
|
+
this.render();
|
|
712
|
+
}
|
|
713
|
+
exit() {
|
|
714
|
+
this.abort();
|
|
715
|
+
}
|
|
716
|
+
abort() {
|
|
717
|
+
this.done = this.aborted = true;
|
|
718
|
+
this.fire();
|
|
719
|
+
this.render();
|
|
720
|
+
this.out.write("\n");
|
|
721
|
+
this.close();
|
|
722
|
+
}
|
|
723
|
+
submit() {
|
|
724
|
+
if (!this.selection.disabled) {
|
|
725
|
+
this.done = true;
|
|
726
|
+
this.aborted = false;
|
|
727
|
+
this.fire();
|
|
728
|
+
this.render();
|
|
729
|
+
this.out.write("\n");
|
|
730
|
+
this.close();
|
|
731
|
+
} else
|
|
732
|
+
this.bell();
|
|
733
|
+
}
|
|
734
|
+
first() {
|
|
735
|
+
this.moveCursor(0);
|
|
736
|
+
this.render();
|
|
737
|
+
}
|
|
738
|
+
last() {
|
|
739
|
+
this.moveCursor(this.choices.length - 1);
|
|
740
|
+
this.render();
|
|
741
|
+
}
|
|
742
|
+
up() {
|
|
743
|
+
if (this.cursor === 0) {
|
|
744
|
+
this.moveCursor(this.choices.length - 1);
|
|
745
|
+
} else {
|
|
746
|
+
this.moveCursor(this.cursor - 1);
|
|
747
|
+
}
|
|
748
|
+
this.render();
|
|
749
|
+
}
|
|
750
|
+
down() {
|
|
751
|
+
if (this.cursor === this.choices.length - 1) {
|
|
752
|
+
this.moveCursor(0);
|
|
753
|
+
} else {
|
|
754
|
+
this.moveCursor(this.cursor + 1);
|
|
755
|
+
}
|
|
756
|
+
this.render();
|
|
757
|
+
}
|
|
758
|
+
next() {
|
|
759
|
+
this.moveCursor((this.cursor + 1) % this.choices.length);
|
|
760
|
+
this.render();
|
|
761
|
+
}
|
|
762
|
+
_(c, key) {
|
|
763
|
+
if (c === " ")
|
|
764
|
+
return this.submit();
|
|
765
|
+
}
|
|
766
|
+
get selection() {
|
|
767
|
+
return this.choices[this.cursor];
|
|
768
|
+
}
|
|
769
|
+
render() {
|
|
770
|
+
if (this.closed)
|
|
771
|
+
return;
|
|
772
|
+
if (this.firstRender)
|
|
773
|
+
this.out.write(cursor.hide);
|
|
774
|
+
else
|
|
775
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
776
|
+
super.render();
|
|
777
|
+
let { startIndex, endIndex } = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage);
|
|
778
|
+
this.outputText = [
|
|
779
|
+
style.symbol(this.done, this.aborted),
|
|
780
|
+
color.bold(this.msg),
|
|
781
|
+
style.delimiter(false),
|
|
782
|
+
this.done ? this.selection.title : this.selection.disabled ? color.yellow(this.warn) : color.gray(this.hint)
|
|
783
|
+
].join(" ");
|
|
784
|
+
if (!this.done) {
|
|
785
|
+
this.outputText += "\n";
|
|
786
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
787
|
+
let title, prefix, desc = "", v = this.choices[i];
|
|
788
|
+
if (i === startIndex && startIndex > 0) {
|
|
789
|
+
prefix = figures.arrowUp;
|
|
790
|
+
} else if (i === endIndex - 1 && endIndex < this.choices.length) {
|
|
791
|
+
prefix = figures.arrowDown;
|
|
792
|
+
} else {
|
|
793
|
+
prefix = " ";
|
|
794
|
+
}
|
|
795
|
+
if (v.disabled) {
|
|
796
|
+
title = this.cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
|
|
797
|
+
prefix = (this.cursor === i ? color.bold().gray(figures.pointer) + " " : " ") + prefix;
|
|
798
|
+
} else {
|
|
799
|
+
title = this.cursor === i ? color.cyan().underline(v.title) : v.title;
|
|
800
|
+
prefix = (this.cursor === i ? color.cyan(figures.pointer) + " " : " ") + prefix;
|
|
801
|
+
if (v.description && this.cursor === i) {
|
|
802
|
+
desc = ` - ${v.description}`;
|
|
803
|
+
if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
|
|
804
|
+
desc = "\n" + wrap(v.description, { margin: 3, width: this.out.columns });
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
this.outputText += `${prefix} ${title}${color.gray(desc)}
|
|
809
|
+
`;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
this.out.write(this.outputText);
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
module2.exports = SelectPrompt;
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
// node_modules/prompts/lib/elements/toggle.js
|
|
820
|
+
var require_toggle = __commonJS({
|
|
821
|
+
"node_modules/prompts/lib/elements/toggle.js"(exports2, module2) {
|
|
822
|
+
var color = require_kleur();
|
|
823
|
+
var Prompt = require_prompt();
|
|
824
|
+
var { style, clear } = require_util();
|
|
825
|
+
var { cursor, erase } = require_src();
|
|
826
|
+
var TogglePrompt = class extends Prompt {
|
|
827
|
+
constructor(opts = {}) {
|
|
828
|
+
super(opts);
|
|
829
|
+
this.msg = opts.message;
|
|
830
|
+
this.value = !!opts.initial;
|
|
831
|
+
this.active = opts.active || "on";
|
|
832
|
+
this.inactive = opts.inactive || "off";
|
|
833
|
+
this.initialValue = this.value;
|
|
834
|
+
this.render();
|
|
835
|
+
}
|
|
836
|
+
reset() {
|
|
837
|
+
this.value = this.initialValue;
|
|
838
|
+
this.fire();
|
|
839
|
+
this.render();
|
|
840
|
+
}
|
|
841
|
+
exit() {
|
|
842
|
+
this.abort();
|
|
843
|
+
}
|
|
844
|
+
abort() {
|
|
845
|
+
this.done = this.aborted = true;
|
|
846
|
+
this.fire();
|
|
847
|
+
this.render();
|
|
848
|
+
this.out.write("\n");
|
|
849
|
+
this.close();
|
|
850
|
+
}
|
|
851
|
+
submit() {
|
|
852
|
+
this.done = true;
|
|
853
|
+
this.aborted = false;
|
|
854
|
+
this.fire();
|
|
855
|
+
this.render();
|
|
856
|
+
this.out.write("\n");
|
|
857
|
+
this.close();
|
|
858
|
+
}
|
|
859
|
+
deactivate() {
|
|
860
|
+
if (this.value === false)
|
|
861
|
+
return this.bell();
|
|
862
|
+
this.value = false;
|
|
863
|
+
this.render();
|
|
864
|
+
}
|
|
865
|
+
activate() {
|
|
866
|
+
if (this.value === true)
|
|
867
|
+
return this.bell();
|
|
868
|
+
this.value = true;
|
|
869
|
+
this.render();
|
|
870
|
+
}
|
|
871
|
+
delete() {
|
|
872
|
+
this.deactivate();
|
|
873
|
+
}
|
|
874
|
+
left() {
|
|
875
|
+
this.deactivate();
|
|
876
|
+
}
|
|
877
|
+
right() {
|
|
878
|
+
this.activate();
|
|
879
|
+
}
|
|
880
|
+
down() {
|
|
881
|
+
this.deactivate();
|
|
882
|
+
}
|
|
883
|
+
up() {
|
|
884
|
+
this.activate();
|
|
885
|
+
}
|
|
886
|
+
next() {
|
|
887
|
+
this.value = !this.value;
|
|
888
|
+
this.fire();
|
|
889
|
+
this.render();
|
|
890
|
+
}
|
|
891
|
+
_(c, key) {
|
|
892
|
+
if (c === " ") {
|
|
893
|
+
this.value = !this.value;
|
|
894
|
+
} else if (c === "1") {
|
|
895
|
+
this.value = true;
|
|
896
|
+
} else if (c === "0") {
|
|
897
|
+
this.value = false;
|
|
898
|
+
} else
|
|
899
|
+
return this.bell();
|
|
900
|
+
this.render();
|
|
901
|
+
}
|
|
902
|
+
render() {
|
|
903
|
+
if (this.closed)
|
|
904
|
+
return;
|
|
905
|
+
if (this.firstRender)
|
|
906
|
+
this.out.write(cursor.hide);
|
|
907
|
+
else
|
|
908
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
909
|
+
super.render();
|
|
910
|
+
this.outputText = [
|
|
911
|
+
style.symbol(this.done, this.aborted),
|
|
912
|
+
color.bold(this.msg),
|
|
913
|
+
style.delimiter(this.done),
|
|
914
|
+
this.value ? this.inactive : color.cyan().underline(this.inactive),
|
|
915
|
+
color.gray("/"),
|
|
916
|
+
this.value ? color.cyan().underline(this.active) : this.active
|
|
917
|
+
].join(" ");
|
|
918
|
+
this.out.write(erase.line + cursor.to(0) + this.outputText);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
module2.exports = TogglePrompt;
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
// node_modules/prompts/lib/dateparts/datepart.js
|
|
926
|
+
var require_datepart = __commonJS({
|
|
927
|
+
"node_modules/prompts/lib/dateparts/datepart.js"(exports2, module2) {
|
|
928
|
+
"use strict";
|
|
929
|
+
var DatePart = class _DatePart {
|
|
930
|
+
constructor({ token, date, parts, locales }) {
|
|
931
|
+
this.token = token;
|
|
932
|
+
this.date = date || /* @__PURE__ */ new Date();
|
|
933
|
+
this.parts = parts || [this];
|
|
934
|
+
this.locales = locales || {};
|
|
935
|
+
}
|
|
936
|
+
up() {
|
|
937
|
+
}
|
|
938
|
+
down() {
|
|
939
|
+
}
|
|
940
|
+
next() {
|
|
941
|
+
const currentIdx = this.parts.indexOf(this);
|
|
942
|
+
return this.parts.find((part, idx) => idx > currentIdx && part instanceof _DatePart);
|
|
943
|
+
}
|
|
944
|
+
setTo(val) {
|
|
945
|
+
}
|
|
946
|
+
prev() {
|
|
947
|
+
let parts = [].concat(this.parts).reverse();
|
|
948
|
+
const currentIdx = parts.indexOf(this);
|
|
949
|
+
return parts.find((part, idx) => idx > currentIdx && part instanceof _DatePart);
|
|
950
|
+
}
|
|
951
|
+
toString() {
|
|
952
|
+
return String(this.date);
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
module2.exports = DatePart;
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
// node_modules/prompts/lib/dateparts/meridiem.js
|
|
960
|
+
var require_meridiem = __commonJS({
|
|
961
|
+
"node_modules/prompts/lib/dateparts/meridiem.js"(exports2, module2) {
|
|
962
|
+
"use strict";
|
|
963
|
+
var DatePart = require_datepart();
|
|
964
|
+
var Meridiem = class extends DatePart {
|
|
965
|
+
constructor(opts = {}) {
|
|
966
|
+
super(opts);
|
|
967
|
+
}
|
|
968
|
+
up() {
|
|
969
|
+
this.date.setHours((this.date.getHours() + 12) % 24);
|
|
970
|
+
}
|
|
971
|
+
down() {
|
|
972
|
+
this.up();
|
|
973
|
+
}
|
|
974
|
+
toString() {
|
|
975
|
+
let meridiem = this.date.getHours() > 12 ? "pm" : "am";
|
|
976
|
+
return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
module2.exports = Meridiem;
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// node_modules/prompts/lib/dateparts/day.js
|
|
984
|
+
var require_day = __commonJS({
|
|
985
|
+
"node_modules/prompts/lib/dateparts/day.js"(exports2, module2) {
|
|
986
|
+
"use strict";
|
|
987
|
+
var DatePart = require_datepart();
|
|
988
|
+
var pos = (n) => {
|
|
989
|
+
n = n % 10;
|
|
990
|
+
return n === 1 ? "st" : n === 2 ? "nd" : n === 3 ? "rd" : "th";
|
|
991
|
+
};
|
|
992
|
+
var Day = class extends DatePart {
|
|
993
|
+
constructor(opts = {}) {
|
|
994
|
+
super(opts);
|
|
995
|
+
}
|
|
996
|
+
up() {
|
|
997
|
+
this.date.setDate(this.date.getDate() + 1);
|
|
998
|
+
}
|
|
999
|
+
down() {
|
|
1000
|
+
this.date.setDate(this.date.getDate() - 1);
|
|
1001
|
+
}
|
|
1002
|
+
setTo(val) {
|
|
1003
|
+
this.date.setDate(parseInt(val.substr(-2)));
|
|
1004
|
+
}
|
|
1005
|
+
toString() {
|
|
1006
|
+
let date = this.date.getDate();
|
|
1007
|
+
let day = this.date.getDay();
|
|
1008
|
+
return this.token === "DD" ? String(date).padStart(2, "0") : this.token === "Do" ? date + pos(date) : this.token === "d" ? day + 1 : this.token === "ddd" ? this.locales.weekdaysShort[day] : this.token === "dddd" ? this.locales.weekdays[day] : date;
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
module2.exports = Day;
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
// node_modules/prompts/lib/dateparts/hours.js
|
|
1016
|
+
var require_hours = __commonJS({
|
|
1017
|
+
"node_modules/prompts/lib/dateparts/hours.js"(exports2, module2) {
|
|
1018
|
+
"use strict";
|
|
1019
|
+
var DatePart = require_datepart();
|
|
1020
|
+
var Hours = class extends DatePart {
|
|
1021
|
+
constructor(opts = {}) {
|
|
1022
|
+
super(opts);
|
|
1023
|
+
}
|
|
1024
|
+
up() {
|
|
1025
|
+
this.date.setHours(this.date.getHours() + 1);
|
|
1026
|
+
}
|
|
1027
|
+
down() {
|
|
1028
|
+
this.date.setHours(this.date.getHours() - 1);
|
|
1029
|
+
}
|
|
1030
|
+
setTo(val) {
|
|
1031
|
+
this.date.setHours(parseInt(val.substr(-2)));
|
|
1032
|
+
}
|
|
1033
|
+
toString() {
|
|
1034
|
+
let hours = this.date.getHours();
|
|
1035
|
+
if (/h/.test(this.token))
|
|
1036
|
+
hours = hours % 12 || 12;
|
|
1037
|
+
return this.token.length > 1 ? String(hours).padStart(2, "0") : hours;
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
module2.exports = Hours;
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
// node_modules/prompts/lib/dateparts/milliseconds.js
|
|
1045
|
+
var require_milliseconds = __commonJS({
|
|
1046
|
+
"node_modules/prompts/lib/dateparts/milliseconds.js"(exports2, module2) {
|
|
1047
|
+
"use strict";
|
|
1048
|
+
var DatePart = require_datepart();
|
|
1049
|
+
var Milliseconds = class extends DatePart {
|
|
1050
|
+
constructor(opts = {}) {
|
|
1051
|
+
super(opts);
|
|
1052
|
+
}
|
|
1053
|
+
up() {
|
|
1054
|
+
this.date.setMilliseconds(this.date.getMilliseconds() + 1);
|
|
1055
|
+
}
|
|
1056
|
+
down() {
|
|
1057
|
+
this.date.setMilliseconds(this.date.getMilliseconds() - 1);
|
|
1058
|
+
}
|
|
1059
|
+
setTo(val) {
|
|
1060
|
+
this.date.setMilliseconds(parseInt(val.substr(-this.token.length)));
|
|
1061
|
+
}
|
|
1062
|
+
toString() {
|
|
1063
|
+
return String(this.date.getMilliseconds()).padStart(4, "0").substr(0, this.token.length);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
module2.exports = Milliseconds;
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
// node_modules/prompts/lib/dateparts/minutes.js
|
|
1071
|
+
var require_minutes = __commonJS({
|
|
1072
|
+
"node_modules/prompts/lib/dateparts/minutes.js"(exports2, module2) {
|
|
1073
|
+
"use strict";
|
|
1074
|
+
var DatePart = require_datepart();
|
|
1075
|
+
var Minutes = class extends DatePart {
|
|
1076
|
+
constructor(opts = {}) {
|
|
1077
|
+
super(opts);
|
|
1078
|
+
}
|
|
1079
|
+
up() {
|
|
1080
|
+
this.date.setMinutes(this.date.getMinutes() + 1);
|
|
1081
|
+
}
|
|
1082
|
+
down() {
|
|
1083
|
+
this.date.setMinutes(this.date.getMinutes() - 1);
|
|
1084
|
+
}
|
|
1085
|
+
setTo(val) {
|
|
1086
|
+
this.date.setMinutes(parseInt(val.substr(-2)));
|
|
1087
|
+
}
|
|
1088
|
+
toString() {
|
|
1089
|
+
let m = this.date.getMinutes();
|
|
1090
|
+
return this.token.length > 1 ? String(m).padStart(2, "0") : m;
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
module2.exports = Minutes;
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
// node_modules/prompts/lib/dateparts/month.js
|
|
1098
|
+
var require_month = __commonJS({
|
|
1099
|
+
"node_modules/prompts/lib/dateparts/month.js"(exports2, module2) {
|
|
1100
|
+
"use strict";
|
|
1101
|
+
var DatePart = require_datepart();
|
|
1102
|
+
var Month = class extends DatePart {
|
|
1103
|
+
constructor(opts = {}) {
|
|
1104
|
+
super(opts);
|
|
1105
|
+
}
|
|
1106
|
+
up() {
|
|
1107
|
+
this.date.setMonth(this.date.getMonth() + 1);
|
|
1108
|
+
}
|
|
1109
|
+
down() {
|
|
1110
|
+
this.date.setMonth(this.date.getMonth() - 1);
|
|
1111
|
+
}
|
|
1112
|
+
setTo(val) {
|
|
1113
|
+
val = parseInt(val.substr(-2)) - 1;
|
|
1114
|
+
this.date.setMonth(val < 0 ? 0 : val);
|
|
1115
|
+
}
|
|
1116
|
+
toString() {
|
|
1117
|
+
let month = this.date.getMonth();
|
|
1118
|
+
let tl = this.token.length;
|
|
1119
|
+
return tl === 2 ? String(month + 1).padStart(2, "0") : tl === 3 ? this.locales.monthsShort[month] : tl === 4 ? this.locales.months[month] : String(month + 1);
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
module2.exports = Month;
|
|
1123
|
+
}
|
|
1124
|
+
});
|
|
1125
|
+
|
|
1126
|
+
// node_modules/prompts/lib/dateparts/seconds.js
|
|
1127
|
+
var require_seconds = __commonJS({
|
|
1128
|
+
"node_modules/prompts/lib/dateparts/seconds.js"(exports2, module2) {
|
|
1129
|
+
"use strict";
|
|
1130
|
+
var DatePart = require_datepart();
|
|
1131
|
+
var Seconds = class extends DatePart {
|
|
1132
|
+
constructor(opts = {}) {
|
|
1133
|
+
super(opts);
|
|
1134
|
+
}
|
|
1135
|
+
up() {
|
|
1136
|
+
this.date.setSeconds(this.date.getSeconds() + 1);
|
|
1137
|
+
}
|
|
1138
|
+
down() {
|
|
1139
|
+
this.date.setSeconds(this.date.getSeconds() - 1);
|
|
1140
|
+
}
|
|
1141
|
+
setTo(val) {
|
|
1142
|
+
this.date.setSeconds(parseInt(val.substr(-2)));
|
|
1143
|
+
}
|
|
1144
|
+
toString() {
|
|
1145
|
+
let s = this.date.getSeconds();
|
|
1146
|
+
return this.token.length > 1 ? String(s).padStart(2, "0") : s;
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
module2.exports = Seconds;
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
|
|
1153
|
+
// node_modules/prompts/lib/dateparts/year.js
|
|
1154
|
+
var require_year = __commonJS({
|
|
1155
|
+
"node_modules/prompts/lib/dateparts/year.js"(exports2, module2) {
|
|
1156
|
+
"use strict";
|
|
1157
|
+
var DatePart = require_datepart();
|
|
1158
|
+
var Year = class extends DatePart {
|
|
1159
|
+
constructor(opts = {}) {
|
|
1160
|
+
super(opts);
|
|
1161
|
+
}
|
|
1162
|
+
up() {
|
|
1163
|
+
this.date.setFullYear(this.date.getFullYear() + 1);
|
|
1164
|
+
}
|
|
1165
|
+
down() {
|
|
1166
|
+
this.date.setFullYear(this.date.getFullYear() - 1);
|
|
1167
|
+
}
|
|
1168
|
+
setTo(val) {
|
|
1169
|
+
this.date.setFullYear(val.substr(-4));
|
|
1170
|
+
}
|
|
1171
|
+
toString() {
|
|
1172
|
+
let year = String(this.date.getFullYear()).padStart(4, "0");
|
|
1173
|
+
return this.token.length === 2 ? year.substr(-2) : year;
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
module2.exports = Year;
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1180
|
+
// node_modules/prompts/lib/dateparts/index.js
|
|
1181
|
+
var require_dateparts = __commonJS({
|
|
1182
|
+
"node_modules/prompts/lib/dateparts/index.js"(exports2, module2) {
|
|
1183
|
+
"use strict";
|
|
1184
|
+
module2.exports = {
|
|
1185
|
+
DatePart: require_datepart(),
|
|
1186
|
+
Meridiem: require_meridiem(),
|
|
1187
|
+
Day: require_day(),
|
|
1188
|
+
Hours: require_hours(),
|
|
1189
|
+
Milliseconds: require_milliseconds(),
|
|
1190
|
+
Minutes: require_minutes(),
|
|
1191
|
+
Month: require_month(),
|
|
1192
|
+
Seconds: require_seconds(),
|
|
1193
|
+
Year: require_year()
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
// node_modules/prompts/lib/elements/date.js
|
|
1199
|
+
var require_date = __commonJS({
|
|
1200
|
+
"node_modules/prompts/lib/elements/date.js"(exports2, module2) {
|
|
1201
|
+
"use strict";
|
|
1202
|
+
var color = require_kleur();
|
|
1203
|
+
var Prompt = require_prompt();
|
|
1204
|
+
var { style, clear, figures } = require_util();
|
|
1205
|
+
var { erase, cursor } = require_src();
|
|
1206
|
+
var { DatePart, Meridiem, Day, Hours, Milliseconds, Minutes, Month, Seconds, Year } = require_dateparts();
|
|
1207
|
+
var regex = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g;
|
|
1208
|
+
var regexGroups = {
|
|
1209
|
+
1: ({ token }) => token.replace(/\\(.)/g, "$1"),
|
|
1210
|
+
2: (opts) => new Day(opts),
|
|
1211
|
+
// Day // TODO
|
|
1212
|
+
3: (opts) => new Month(opts),
|
|
1213
|
+
// Month
|
|
1214
|
+
4: (opts) => new Year(opts),
|
|
1215
|
+
// Year
|
|
1216
|
+
5: (opts) => new Meridiem(opts),
|
|
1217
|
+
// AM/PM // TODO (special)
|
|
1218
|
+
6: (opts) => new Hours(opts),
|
|
1219
|
+
// Hours
|
|
1220
|
+
7: (opts) => new Minutes(opts),
|
|
1221
|
+
// Minutes
|
|
1222
|
+
8: (opts) => new Seconds(opts),
|
|
1223
|
+
// Seconds
|
|
1224
|
+
9: (opts) => new Milliseconds(opts)
|
|
1225
|
+
// Fractional seconds
|
|
1226
|
+
};
|
|
1227
|
+
var dfltLocales = {
|
|
1228
|
+
months: "January,February,March,April,May,June,July,August,September,October,November,December".split(","),
|
|
1229
|
+
monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),
|
|
1230
|
+
weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
|
|
1231
|
+
weekdaysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")
|
|
1232
|
+
};
|
|
1233
|
+
var DatePrompt = class extends Prompt {
|
|
1234
|
+
constructor(opts = {}) {
|
|
1235
|
+
super(opts);
|
|
1236
|
+
this.msg = opts.message;
|
|
1237
|
+
this.cursor = 0;
|
|
1238
|
+
this.typed = "";
|
|
1239
|
+
this.locales = Object.assign(dfltLocales, opts.locales);
|
|
1240
|
+
this._date = opts.initial || /* @__PURE__ */ new Date();
|
|
1241
|
+
this.errorMsg = opts.error || "Please Enter A Valid Value";
|
|
1242
|
+
this.validator = opts.validate || (() => true);
|
|
1243
|
+
this.mask = opts.mask || "YYYY-MM-DD HH:mm:ss";
|
|
1244
|
+
this.clear = clear("", this.out.columns);
|
|
1245
|
+
this.render();
|
|
1246
|
+
}
|
|
1247
|
+
get value() {
|
|
1248
|
+
return this.date;
|
|
1249
|
+
}
|
|
1250
|
+
get date() {
|
|
1251
|
+
return this._date;
|
|
1252
|
+
}
|
|
1253
|
+
set date(date) {
|
|
1254
|
+
if (date)
|
|
1255
|
+
this._date.setTime(date.getTime());
|
|
1256
|
+
}
|
|
1257
|
+
set mask(mask) {
|
|
1258
|
+
let result;
|
|
1259
|
+
this.parts = [];
|
|
1260
|
+
while (result = regex.exec(mask)) {
|
|
1261
|
+
let match = result.shift();
|
|
1262
|
+
let idx = result.findIndex((gr) => gr != null);
|
|
1263
|
+
this.parts.push(idx in regexGroups ? regexGroups[idx]({ token: result[idx] || match, date: this.date, parts: this.parts, locales: this.locales }) : result[idx] || match);
|
|
1264
|
+
}
|
|
1265
|
+
let parts = this.parts.reduce((arr, i) => {
|
|
1266
|
+
if (typeof i === "string" && typeof arr[arr.length - 1] === "string")
|
|
1267
|
+
arr[arr.length - 1] += i;
|
|
1268
|
+
else
|
|
1269
|
+
arr.push(i);
|
|
1270
|
+
return arr;
|
|
1271
|
+
}, []);
|
|
1272
|
+
this.parts.splice(0);
|
|
1273
|
+
this.parts.push(...parts);
|
|
1274
|
+
this.reset();
|
|
1275
|
+
}
|
|
1276
|
+
moveCursor(n) {
|
|
1277
|
+
this.typed = "";
|
|
1278
|
+
this.cursor = n;
|
|
1279
|
+
this.fire();
|
|
1280
|
+
}
|
|
1281
|
+
reset() {
|
|
1282
|
+
this.moveCursor(this.parts.findIndex((p) => p instanceof DatePart));
|
|
1283
|
+
this.fire();
|
|
1284
|
+
this.render();
|
|
1285
|
+
}
|
|
1286
|
+
exit() {
|
|
1287
|
+
this.abort();
|
|
1288
|
+
}
|
|
1289
|
+
abort() {
|
|
1290
|
+
this.done = this.aborted = true;
|
|
1291
|
+
this.error = false;
|
|
1292
|
+
this.fire();
|
|
1293
|
+
this.render();
|
|
1294
|
+
this.out.write("\n");
|
|
1295
|
+
this.close();
|
|
1296
|
+
}
|
|
1297
|
+
async validate() {
|
|
1298
|
+
let valid = await this.validator(this.value);
|
|
1299
|
+
if (typeof valid === "string") {
|
|
1300
|
+
this.errorMsg = valid;
|
|
1301
|
+
valid = false;
|
|
1302
|
+
}
|
|
1303
|
+
this.error = !valid;
|
|
1304
|
+
}
|
|
1305
|
+
async submit() {
|
|
1306
|
+
await this.validate();
|
|
1307
|
+
if (this.error) {
|
|
1308
|
+
this.color = "red";
|
|
1309
|
+
this.fire();
|
|
1310
|
+
this.render();
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
this.done = true;
|
|
1314
|
+
this.aborted = false;
|
|
1315
|
+
this.fire();
|
|
1316
|
+
this.render();
|
|
1317
|
+
this.out.write("\n");
|
|
1318
|
+
this.close();
|
|
1319
|
+
}
|
|
1320
|
+
up() {
|
|
1321
|
+
this.typed = "";
|
|
1322
|
+
this.parts[this.cursor].up();
|
|
1323
|
+
this.render();
|
|
1324
|
+
}
|
|
1325
|
+
down() {
|
|
1326
|
+
this.typed = "";
|
|
1327
|
+
this.parts[this.cursor].down();
|
|
1328
|
+
this.render();
|
|
1329
|
+
}
|
|
1330
|
+
left() {
|
|
1331
|
+
let prev = this.parts[this.cursor].prev();
|
|
1332
|
+
if (prev == null)
|
|
1333
|
+
return this.bell();
|
|
1334
|
+
this.moveCursor(this.parts.indexOf(prev));
|
|
1335
|
+
this.render();
|
|
1336
|
+
}
|
|
1337
|
+
right() {
|
|
1338
|
+
let next = this.parts[this.cursor].next();
|
|
1339
|
+
if (next == null)
|
|
1340
|
+
return this.bell();
|
|
1341
|
+
this.moveCursor(this.parts.indexOf(next));
|
|
1342
|
+
this.render();
|
|
1343
|
+
}
|
|
1344
|
+
next() {
|
|
1345
|
+
let next = this.parts[this.cursor].next();
|
|
1346
|
+
this.moveCursor(next ? this.parts.indexOf(next) : this.parts.findIndex((part) => part instanceof DatePart));
|
|
1347
|
+
this.render();
|
|
1348
|
+
}
|
|
1349
|
+
_(c) {
|
|
1350
|
+
if (/\d/.test(c)) {
|
|
1351
|
+
this.typed += c;
|
|
1352
|
+
this.parts[this.cursor].setTo(this.typed);
|
|
1353
|
+
this.render();
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
render() {
|
|
1357
|
+
if (this.closed)
|
|
1358
|
+
return;
|
|
1359
|
+
if (this.firstRender)
|
|
1360
|
+
this.out.write(cursor.hide);
|
|
1361
|
+
else
|
|
1362
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
1363
|
+
super.render();
|
|
1364
|
+
this.outputText = [
|
|
1365
|
+
style.symbol(this.done, this.aborted),
|
|
1366
|
+
color.bold(this.msg),
|
|
1367
|
+
style.delimiter(false),
|
|
1368
|
+
this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []).join("")
|
|
1369
|
+
].join(" ");
|
|
1370
|
+
if (this.error) {
|
|
1371
|
+
this.outputText += this.errorMsg.split("\n").reduce(
|
|
1372
|
+
(a, l, i) => a + `
|
|
1373
|
+
${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`,
|
|
1374
|
+
``
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
this.out.write(erase.line + cursor.to(0) + this.outputText);
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
module2.exports = DatePrompt;
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
// node_modules/prompts/lib/elements/number.js
|
|
1385
|
+
var require_number = __commonJS({
|
|
1386
|
+
"node_modules/prompts/lib/elements/number.js"(exports2, module2) {
|
|
1387
|
+
var color = require_kleur();
|
|
1388
|
+
var Prompt = require_prompt();
|
|
1389
|
+
var { cursor, erase } = require_src();
|
|
1390
|
+
var { style, figures, clear, lines } = require_util();
|
|
1391
|
+
var isNumber = /[0-9]/;
|
|
1392
|
+
var isDef = (any) => any !== void 0;
|
|
1393
|
+
var round = (number, precision) => {
|
|
1394
|
+
let factor = Math.pow(10, precision);
|
|
1395
|
+
return Math.round(number * factor) / factor;
|
|
1396
|
+
};
|
|
1397
|
+
var NumberPrompt = class extends Prompt {
|
|
1398
|
+
constructor(opts = {}) {
|
|
1399
|
+
super(opts);
|
|
1400
|
+
this.transform = style.render(opts.style);
|
|
1401
|
+
this.msg = opts.message;
|
|
1402
|
+
this.initial = isDef(opts.initial) ? opts.initial : "";
|
|
1403
|
+
this.float = !!opts.float;
|
|
1404
|
+
this.round = opts.round || 2;
|
|
1405
|
+
this.inc = opts.increment || 1;
|
|
1406
|
+
this.min = isDef(opts.min) ? opts.min : -Infinity;
|
|
1407
|
+
this.max = isDef(opts.max) ? opts.max : Infinity;
|
|
1408
|
+
this.errorMsg = opts.error || `Please Enter A Valid Value`;
|
|
1409
|
+
this.validator = opts.validate || (() => true);
|
|
1410
|
+
this.color = `cyan`;
|
|
1411
|
+
this.value = ``;
|
|
1412
|
+
this.typed = ``;
|
|
1413
|
+
this.lastHit = 0;
|
|
1414
|
+
this.render();
|
|
1415
|
+
}
|
|
1416
|
+
set value(v) {
|
|
1417
|
+
if (!v && v !== 0) {
|
|
1418
|
+
this.placeholder = true;
|
|
1419
|
+
this.rendered = color.gray(this.transform.render(`${this.initial}`));
|
|
1420
|
+
this._value = ``;
|
|
1421
|
+
} else {
|
|
1422
|
+
this.placeholder = false;
|
|
1423
|
+
this.rendered = this.transform.render(`${round(v, this.round)}`);
|
|
1424
|
+
this._value = round(v, this.round);
|
|
1425
|
+
}
|
|
1426
|
+
this.fire();
|
|
1427
|
+
}
|
|
1428
|
+
get value() {
|
|
1429
|
+
return this._value;
|
|
1430
|
+
}
|
|
1431
|
+
parse(x) {
|
|
1432
|
+
return this.float ? parseFloat(x) : parseInt(x);
|
|
1433
|
+
}
|
|
1434
|
+
valid(c) {
|
|
1435
|
+
return c === `-` || c === `.` && this.float || isNumber.test(c);
|
|
1436
|
+
}
|
|
1437
|
+
reset() {
|
|
1438
|
+
this.typed = ``;
|
|
1439
|
+
this.value = ``;
|
|
1440
|
+
this.fire();
|
|
1441
|
+
this.render();
|
|
1442
|
+
}
|
|
1443
|
+
exit() {
|
|
1444
|
+
this.abort();
|
|
1445
|
+
}
|
|
1446
|
+
abort() {
|
|
1447
|
+
let x = this.value;
|
|
1448
|
+
this.value = x !== `` ? x : this.initial;
|
|
1449
|
+
this.done = this.aborted = true;
|
|
1450
|
+
this.error = false;
|
|
1451
|
+
this.fire();
|
|
1452
|
+
this.render();
|
|
1453
|
+
this.out.write(`
|
|
1454
|
+
`);
|
|
1455
|
+
this.close();
|
|
1456
|
+
}
|
|
1457
|
+
async validate() {
|
|
1458
|
+
let valid = await this.validator(this.value);
|
|
1459
|
+
if (typeof valid === `string`) {
|
|
1460
|
+
this.errorMsg = valid;
|
|
1461
|
+
valid = false;
|
|
1462
|
+
}
|
|
1463
|
+
this.error = !valid;
|
|
1464
|
+
}
|
|
1465
|
+
async submit() {
|
|
1466
|
+
await this.validate();
|
|
1467
|
+
if (this.error) {
|
|
1468
|
+
this.color = `red`;
|
|
1469
|
+
this.fire();
|
|
1470
|
+
this.render();
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
let x = this.value;
|
|
1474
|
+
this.value = x !== `` ? x : this.initial;
|
|
1475
|
+
this.done = true;
|
|
1476
|
+
this.aborted = false;
|
|
1477
|
+
this.error = false;
|
|
1478
|
+
this.fire();
|
|
1479
|
+
this.render();
|
|
1480
|
+
this.out.write(`
|
|
1481
|
+
`);
|
|
1482
|
+
this.close();
|
|
1483
|
+
}
|
|
1484
|
+
up() {
|
|
1485
|
+
this.typed = ``;
|
|
1486
|
+
if (this.value === "") {
|
|
1487
|
+
this.value = this.min - this.inc;
|
|
1488
|
+
}
|
|
1489
|
+
if (this.value >= this.max)
|
|
1490
|
+
return this.bell();
|
|
1491
|
+
this.value += this.inc;
|
|
1492
|
+
this.color = `cyan`;
|
|
1493
|
+
this.fire();
|
|
1494
|
+
this.render();
|
|
1495
|
+
}
|
|
1496
|
+
down() {
|
|
1497
|
+
this.typed = ``;
|
|
1498
|
+
if (this.value === "") {
|
|
1499
|
+
this.value = this.min + this.inc;
|
|
1500
|
+
}
|
|
1501
|
+
if (this.value <= this.min)
|
|
1502
|
+
return this.bell();
|
|
1503
|
+
this.value -= this.inc;
|
|
1504
|
+
this.color = `cyan`;
|
|
1505
|
+
this.fire();
|
|
1506
|
+
this.render();
|
|
1507
|
+
}
|
|
1508
|
+
delete() {
|
|
1509
|
+
let val = this.value.toString();
|
|
1510
|
+
if (val.length === 0)
|
|
1511
|
+
return this.bell();
|
|
1512
|
+
this.value = this.parse(val = val.slice(0, -1)) || ``;
|
|
1513
|
+
if (this.value !== "" && this.value < this.min) {
|
|
1514
|
+
this.value = this.min;
|
|
1515
|
+
}
|
|
1516
|
+
this.color = `cyan`;
|
|
1517
|
+
this.fire();
|
|
1518
|
+
this.render();
|
|
1519
|
+
}
|
|
1520
|
+
next() {
|
|
1521
|
+
this.value = this.initial;
|
|
1522
|
+
this.fire();
|
|
1523
|
+
this.render();
|
|
1524
|
+
}
|
|
1525
|
+
_(c, key) {
|
|
1526
|
+
if (!this.valid(c))
|
|
1527
|
+
return this.bell();
|
|
1528
|
+
const now = Date.now();
|
|
1529
|
+
if (now - this.lastHit > 1e3)
|
|
1530
|
+
this.typed = ``;
|
|
1531
|
+
this.typed += c;
|
|
1532
|
+
this.lastHit = now;
|
|
1533
|
+
this.color = `cyan`;
|
|
1534
|
+
if (c === `.`)
|
|
1535
|
+
return this.fire();
|
|
1536
|
+
this.value = Math.min(this.parse(this.typed), this.max);
|
|
1537
|
+
if (this.value > this.max)
|
|
1538
|
+
this.value = this.max;
|
|
1539
|
+
if (this.value < this.min)
|
|
1540
|
+
this.value = this.min;
|
|
1541
|
+
this.fire();
|
|
1542
|
+
this.render();
|
|
1543
|
+
}
|
|
1544
|
+
render() {
|
|
1545
|
+
if (this.closed)
|
|
1546
|
+
return;
|
|
1547
|
+
if (!this.firstRender) {
|
|
1548
|
+
if (this.outputError)
|
|
1549
|
+
this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
|
|
1550
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
1551
|
+
}
|
|
1552
|
+
super.render();
|
|
1553
|
+
this.outputError = "";
|
|
1554
|
+
this.outputText = [
|
|
1555
|
+
style.symbol(this.done, this.aborted),
|
|
1556
|
+
color.bold(this.msg),
|
|
1557
|
+
style.delimiter(this.done),
|
|
1558
|
+
!this.done || !this.done && !this.placeholder ? color[this.color]().underline(this.rendered) : this.rendered
|
|
1559
|
+
].join(` `);
|
|
1560
|
+
if (this.error) {
|
|
1561
|
+
this.outputError += this.errorMsg.split(`
|
|
1562
|
+
`).reduce((a, l, i) => a + `
|
|
1563
|
+
${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
1564
|
+
}
|
|
1565
|
+
this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
module2.exports = NumberPrompt;
|
|
1569
|
+
}
|
|
1570
|
+
});
|
|
1571
|
+
|
|
1572
|
+
// node_modules/prompts/lib/elements/multiselect.js
|
|
1573
|
+
var require_multiselect = __commonJS({
|
|
1574
|
+
"node_modules/prompts/lib/elements/multiselect.js"(exports2, module2) {
|
|
1575
|
+
"use strict";
|
|
1576
|
+
var color = require_kleur();
|
|
1577
|
+
var { cursor } = require_src();
|
|
1578
|
+
var Prompt = require_prompt();
|
|
1579
|
+
var { clear, figures, style, wrap, entriesToDisplay } = require_util();
|
|
1580
|
+
var MultiselectPrompt = class extends Prompt {
|
|
1581
|
+
constructor(opts = {}) {
|
|
1582
|
+
super(opts);
|
|
1583
|
+
this.msg = opts.message;
|
|
1584
|
+
this.cursor = opts.cursor || 0;
|
|
1585
|
+
this.scrollIndex = opts.cursor || 0;
|
|
1586
|
+
this.hint = opts.hint || "";
|
|
1587
|
+
this.warn = opts.warn || "- This option is disabled -";
|
|
1588
|
+
this.minSelected = opts.min;
|
|
1589
|
+
this.showMinError = false;
|
|
1590
|
+
this.maxChoices = opts.max;
|
|
1591
|
+
this.instructions = opts.instructions;
|
|
1592
|
+
this.optionsPerPage = opts.optionsPerPage || 10;
|
|
1593
|
+
this.value = opts.choices.map((ch, idx) => {
|
|
1594
|
+
if (typeof ch === "string")
|
|
1595
|
+
ch = { title: ch, value: idx };
|
|
1596
|
+
return {
|
|
1597
|
+
title: ch && (ch.title || ch.value || ch),
|
|
1598
|
+
description: ch && ch.description,
|
|
1599
|
+
value: ch && (ch.value === void 0 ? idx : ch.value),
|
|
1600
|
+
selected: ch && ch.selected,
|
|
1601
|
+
disabled: ch && ch.disabled
|
|
1602
|
+
};
|
|
1603
|
+
});
|
|
1604
|
+
this.clear = clear("", this.out.columns);
|
|
1605
|
+
if (!opts.overrideRender) {
|
|
1606
|
+
this.render();
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
reset() {
|
|
1610
|
+
this.value.map((v) => !v.selected);
|
|
1611
|
+
this.cursor = 0;
|
|
1612
|
+
this.fire();
|
|
1613
|
+
this.render();
|
|
1614
|
+
}
|
|
1615
|
+
selected() {
|
|
1616
|
+
return this.value.filter((v) => v.selected);
|
|
1617
|
+
}
|
|
1618
|
+
exit() {
|
|
1619
|
+
this.abort();
|
|
1620
|
+
}
|
|
1621
|
+
abort() {
|
|
1622
|
+
this.done = this.aborted = true;
|
|
1623
|
+
this.fire();
|
|
1624
|
+
this.render();
|
|
1625
|
+
this.out.write("\n");
|
|
1626
|
+
this.close();
|
|
1627
|
+
}
|
|
1628
|
+
submit() {
|
|
1629
|
+
const selected = this.value.filter((e) => e.selected);
|
|
1630
|
+
if (this.minSelected && selected.length < this.minSelected) {
|
|
1631
|
+
this.showMinError = true;
|
|
1632
|
+
this.render();
|
|
1633
|
+
} else {
|
|
1634
|
+
this.done = true;
|
|
1635
|
+
this.aborted = false;
|
|
1636
|
+
this.fire();
|
|
1637
|
+
this.render();
|
|
1638
|
+
this.out.write("\n");
|
|
1639
|
+
this.close();
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
first() {
|
|
1643
|
+
this.cursor = 0;
|
|
1644
|
+
this.render();
|
|
1645
|
+
}
|
|
1646
|
+
last() {
|
|
1647
|
+
this.cursor = this.value.length - 1;
|
|
1648
|
+
this.render();
|
|
1649
|
+
}
|
|
1650
|
+
next() {
|
|
1651
|
+
this.cursor = (this.cursor + 1) % this.value.length;
|
|
1652
|
+
this.render();
|
|
1653
|
+
}
|
|
1654
|
+
up() {
|
|
1655
|
+
if (this.cursor === 0) {
|
|
1656
|
+
this.cursor = this.value.length - 1;
|
|
1657
|
+
} else {
|
|
1658
|
+
this.cursor--;
|
|
1659
|
+
}
|
|
1660
|
+
this.render();
|
|
1661
|
+
}
|
|
1662
|
+
down() {
|
|
1663
|
+
if (this.cursor === this.value.length - 1) {
|
|
1664
|
+
this.cursor = 0;
|
|
1665
|
+
} else {
|
|
1666
|
+
this.cursor++;
|
|
1667
|
+
}
|
|
1668
|
+
this.render();
|
|
1669
|
+
}
|
|
1670
|
+
left() {
|
|
1671
|
+
this.value[this.cursor].selected = false;
|
|
1672
|
+
this.render();
|
|
1673
|
+
}
|
|
1674
|
+
right() {
|
|
1675
|
+
if (this.value.filter((e) => e.selected).length >= this.maxChoices)
|
|
1676
|
+
return this.bell();
|
|
1677
|
+
this.value[this.cursor].selected = true;
|
|
1678
|
+
this.render();
|
|
1679
|
+
}
|
|
1680
|
+
handleSpaceToggle() {
|
|
1681
|
+
const v = this.value[this.cursor];
|
|
1682
|
+
if (v.selected) {
|
|
1683
|
+
v.selected = false;
|
|
1684
|
+
this.render();
|
|
1685
|
+
} else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
|
|
1686
|
+
return this.bell();
|
|
1687
|
+
} else {
|
|
1688
|
+
v.selected = true;
|
|
1689
|
+
this.render();
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
toggleAll() {
|
|
1693
|
+
if (this.maxChoices !== void 0 || this.value[this.cursor].disabled) {
|
|
1694
|
+
return this.bell();
|
|
1695
|
+
}
|
|
1696
|
+
const newSelected = !this.value[this.cursor].selected;
|
|
1697
|
+
this.value.filter((v) => !v.disabled).forEach((v) => v.selected = newSelected);
|
|
1698
|
+
this.render();
|
|
1699
|
+
}
|
|
1700
|
+
_(c, key) {
|
|
1701
|
+
if (c === " ") {
|
|
1702
|
+
this.handleSpaceToggle();
|
|
1703
|
+
} else if (c === "a") {
|
|
1704
|
+
this.toggleAll();
|
|
1705
|
+
} else {
|
|
1706
|
+
return this.bell();
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
renderInstructions() {
|
|
1710
|
+
if (this.instructions === void 0 || this.instructions) {
|
|
1711
|
+
if (typeof this.instructions === "string") {
|
|
1712
|
+
return this.instructions;
|
|
1713
|
+
}
|
|
1714
|
+
return `
|
|
1715
|
+
Instructions:
|
|
1716
|
+
${figures.arrowUp}/${figures.arrowDown}: Highlight option
|
|
1717
|
+
${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
|
|
1718
|
+
` + (this.maxChoices === void 0 ? ` a: Toggle all
|
|
1719
|
+
` : "") + ` enter/return: Complete answer`;
|
|
1720
|
+
}
|
|
1721
|
+
return "";
|
|
1722
|
+
}
|
|
1723
|
+
renderOption(cursor2, v, i, arrowIndicator) {
|
|
1724
|
+
const prefix = (v.selected ? color.green(figures.radioOn) : figures.radioOff) + " " + arrowIndicator + " ";
|
|
1725
|
+
let title, desc;
|
|
1726
|
+
if (v.disabled) {
|
|
1727
|
+
title = cursor2 === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
|
|
1728
|
+
} else {
|
|
1729
|
+
title = cursor2 === i ? color.cyan().underline(v.title) : v.title;
|
|
1730
|
+
if (cursor2 === i && v.description) {
|
|
1731
|
+
desc = ` - ${v.description}`;
|
|
1732
|
+
if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
|
|
1733
|
+
desc = "\n" + wrap(v.description, { margin: prefix.length, width: this.out.columns });
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
return prefix + title + color.gray(desc || "");
|
|
1738
|
+
}
|
|
1739
|
+
// shared with autocompleteMultiselect
|
|
1740
|
+
paginateOptions(options) {
|
|
1741
|
+
if (options.length === 0) {
|
|
1742
|
+
return color.red("No matches for this query.");
|
|
1743
|
+
}
|
|
1744
|
+
let { startIndex, endIndex } = entriesToDisplay(this.cursor, options.length, this.optionsPerPage);
|
|
1745
|
+
let prefix, styledOptions = [];
|
|
1746
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
1747
|
+
if (i === startIndex && startIndex > 0) {
|
|
1748
|
+
prefix = figures.arrowUp;
|
|
1749
|
+
} else if (i === endIndex - 1 && endIndex < options.length) {
|
|
1750
|
+
prefix = figures.arrowDown;
|
|
1751
|
+
} else {
|
|
1752
|
+
prefix = " ";
|
|
1753
|
+
}
|
|
1754
|
+
styledOptions.push(this.renderOption(this.cursor, options[i], i, prefix));
|
|
1755
|
+
}
|
|
1756
|
+
return "\n" + styledOptions.join("\n");
|
|
1757
|
+
}
|
|
1758
|
+
// shared with autocomleteMultiselect
|
|
1759
|
+
renderOptions(options) {
|
|
1760
|
+
if (!this.done) {
|
|
1761
|
+
return this.paginateOptions(options);
|
|
1762
|
+
}
|
|
1763
|
+
return "";
|
|
1764
|
+
}
|
|
1765
|
+
renderDoneOrInstructions() {
|
|
1766
|
+
if (this.done) {
|
|
1767
|
+
return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
|
|
1768
|
+
}
|
|
1769
|
+
const output = [color.gray(this.hint), this.renderInstructions()];
|
|
1770
|
+
if (this.value[this.cursor].disabled) {
|
|
1771
|
+
output.push(color.yellow(this.warn));
|
|
1772
|
+
}
|
|
1773
|
+
return output.join(" ");
|
|
1774
|
+
}
|
|
1775
|
+
render() {
|
|
1776
|
+
if (this.closed)
|
|
1777
|
+
return;
|
|
1778
|
+
if (this.firstRender)
|
|
1779
|
+
this.out.write(cursor.hide);
|
|
1780
|
+
super.render();
|
|
1781
|
+
let prompt = [
|
|
1782
|
+
style.symbol(this.done, this.aborted),
|
|
1783
|
+
color.bold(this.msg),
|
|
1784
|
+
style.delimiter(false),
|
|
1785
|
+
this.renderDoneOrInstructions()
|
|
1786
|
+
].join(" ");
|
|
1787
|
+
if (this.showMinError) {
|
|
1788
|
+
prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
|
|
1789
|
+
this.showMinError = false;
|
|
1790
|
+
}
|
|
1791
|
+
prompt += this.renderOptions(this.value);
|
|
1792
|
+
this.out.write(this.clear + prompt);
|
|
1793
|
+
this.clear = clear(prompt, this.out.columns);
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
module2.exports = MultiselectPrompt;
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
|
|
1800
|
+
// node_modules/prompts/lib/elements/autocomplete.js
|
|
1801
|
+
var require_autocomplete = __commonJS({
|
|
1802
|
+
"node_modules/prompts/lib/elements/autocomplete.js"(exports2, module2) {
|
|
1803
|
+
"use strict";
|
|
1804
|
+
var color = require_kleur();
|
|
1805
|
+
var Prompt = require_prompt();
|
|
1806
|
+
var { erase, cursor } = require_src();
|
|
1807
|
+
var { style, clear, figures, wrap, entriesToDisplay } = require_util();
|
|
1808
|
+
var getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
|
|
1809
|
+
var getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
|
|
1810
|
+
var getIndex = (arr, valOrTitle) => {
|
|
1811
|
+
const index = arr.findIndex((el) => el.value === valOrTitle || el.title === valOrTitle);
|
|
1812
|
+
return index > -1 ? index : void 0;
|
|
1813
|
+
};
|
|
1814
|
+
var AutocompletePrompt = class extends Prompt {
|
|
1815
|
+
constructor(opts = {}) {
|
|
1816
|
+
super(opts);
|
|
1817
|
+
this.msg = opts.message;
|
|
1818
|
+
this.suggest = opts.suggest;
|
|
1819
|
+
this.choices = opts.choices;
|
|
1820
|
+
this.initial = typeof opts.initial === "number" ? opts.initial : getIndex(opts.choices, opts.initial);
|
|
1821
|
+
this.select = this.initial || opts.cursor || 0;
|
|
1822
|
+
this.i18n = { noMatches: opts.noMatches || "no matches found" };
|
|
1823
|
+
this.fallback = opts.fallback || this.initial;
|
|
1824
|
+
this.clearFirst = opts.clearFirst || false;
|
|
1825
|
+
this.suggestions = [];
|
|
1826
|
+
this.input = "";
|
|
1827
|
+
this.limit = opts.limit || 10;
|
|
1828
|
+
this.cursor = 0;
|
|
1829
|
+
this.transform = style.render(opts.style);
|
|
1830
|
+
this.scale = this.transform.scale;
|
|
1831
|
+
this.render = this.render.bind(this);
|
|
1832
|
+
this.complete = this.complete.bind(this);
|
|
1833
|
+
this.clear = clear("", this.out.columns);
|
|
1834
|
+
this.complete(this.render);
|
|
1835
|
+
this.render();
|
|
1836
|
+
}
|
|
1837
|
+
set fallback(fb) {
|
|
1838
|
+
this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
|
|
1839
|
+
}
|
|
1840
|
+
get fallback() {
|
|
1841
|
+
let choice;
|
|
1842
|
+
if (typeof this._fb === "number")
|
|
1843
|
+
choice = this.choices[this._fb];
|
|
1844
|
+
else if (typeof this._fb === "string")
|
|
1845
|
+
choice = { title: this._fb };
|
|
1846
|
+
return choice || this._fb || { title: this.i18n.noMatches };
|
|
1847
|
+
}
|
|
1848
|
+
moveSelect(i) {
|
|
1849
|
+
this.select = i;
|
|
1850
|
+
if (this.suggestions.length > 0)
|
|
1851
|
+
this.value = getVal(this.suggestions, i);
|
|
1852
|
+
else
|
|
1853
|
+
this.value = this.fallback.value;
|
|
1854
|
+
this.fire();
|
|
1855
|
+
}
|
|
1856
|
+
async complete(cb) {
|
|
1857
|
+
const p = this.completing = this.suggest(this.input, this.choices);
|
|
1858
|
+
const suggestions = await p;
|
|
1859
|
+
if (this.completing !== p)
|
|
1860
|
+
return;
|
|
1861
|
+
this.suggestions = suggestions.map((s, i, arr) => ({ title: getTitle(arr, i), value: getVal(arr, i), description: s.description }));
|
|
1862
|
+
this.completing = false;
|
|
1863
|
+
const l = Math.max(suggestions.length - 1, 0);
|
|
1864
|
+
this.moveSelect(Math.min(l, this.select));
|
|
1865
|
+
cb && cb();
|
|
1866
|
+
}
|
|
1867
|
+
reset() {
|
|
1868
|
+
this.input = "";
|
|
1869
|
+
this.complete(() => {
|
|
1870
|
+
this.moveSelect(this.initial !== void 0 ? this.initial : 0);
|
|
1871
|
+
this.render();
|
|
1872
|
+
});
|
|
1873
|
+
this.render();
|
|
1874
|
+
}
|
|
1875
|
+
exit() {
|
|
1876
|
+
if (this.clearFirst && this.input.length > 0) {
|
|
1877
|
+
this.reset();
|
|
1878
|
+
} else {
|
|
1879
|
+
this.done = this.exited = true;
|
|
1880
|
+
this.aborted = false;
|
|
1881
|
+
this.fire();
|
|
1882
|
+
this.render();
|
|
1883
|
+
this.out.write("\n");
|
|
1884
|
+
this.close();
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
abort() {
|
|
1888
|
+
this.done = this.aborted = true;
|
|
1889
|
+
this.exited = false;
|
|
1890
|
+
this.fire();
|
|
1891
|
+
this.render();
|
|
1892
|
+
this.out.write("\n");
|
|
1893
|
+
this.close();
|
|
1894
|
+
}
|
|
1895
|
+
submit() {
|
|
1896
|
+
this.done = true;
|
|
1897
|
+
this.aborted = this.exited = false;
|
|
1898
|
+
this.fire();
|
|
1899
|
+
this.render();
|
|
1900
|
+
this.out.write("\n");
|
|
1901
|
+
this.close();
|
|
1902
|
+
}
|
|
1903
|
+
_(c, key) {
|
|
1904
|
+
let s1 = this.input.slice(0, this.cursor);
|
|
1905
|
+
let s2 = this.input.slice(this.cursor);
|
|
1906
|
+
this.input = `${s1}${c}${s2}`;
|
|
1907
|
+
this.cursor = s1.length + 1;
|
|
1908
|
+
this.complete(this.render);
|
|
1909
|
+
this.render();
|
|
1910
|
+
}
|
|
1911
|
+
delete() {
|
|
1912
|
+
if (this.cursor === 0)
|
|
1913
|
+
return this.bell();
|
|
1914
|
+
let s1 = this.input.slice(0, this.cursor - 1);
|
|
1915
|
+
let s2 = this.input.slice(this.cursor);
|
|
1916
|
+
this.input = `${s1}${s2}`;
|
|
1917
|
+
this.complete(this.render);
|
|
1918
|
+
this.cursor = this.cursor - 1;
|
|
1919
|
+
this.render();
|
|
1920
|
+
}
|
|
1921
|
+
deleteForward() {
|
|
1922
|
+
if (this.cursor * this.scale >= this.rendered.length)
|
|
1923
|
+
return this.bell();
|
|
1924
|
+
let s1 = this.input.slice(0, this.cursor);
|
|
1925
|
+
let s2 = this.input.slice(this.cursor + 1);
|
|
1926
|
+
this.input = `${s1}${s2}`;
|
|
1927
|
+
this.complete(this.render);
|
|
1928
|
+
this.render();
|
|
1929
|
+
}
|
|
1930
|
+
first() {
|
|
1931
|
+
this.moveSelect(0);
|
|
1932
|
+
this.render();
|
|
1933
|
+
}
|
|
1934
|
+
last() {
|
|
1935
|
+
this.moveSelect(this.suggestions.length - 1);
|
|
1936
|
+
this.render();
|
|
1937
|
+
}
|
|
1938
|
+
up() {
|
|
1939
|
+
if (this.select === 0) {
|
|
1940
|
+
this.moveSelect(this.suggestions.length - 1);
|
|
1941
|
+
} else {
|
|
1942
|
+
this.moveSelect(this.select - 1);
|
|
1943
|
+
}
|
|
1944
|
+
this.render();
|
|
1945
|
+
}
|
|
1946
|
+
down() {
|
|
1947
|
+
if (this.select === this.suggestions.length - 1) {
|
|
1948
|
+
this.moveSelect(0);
|
|
1949
|
+
} else {
|
|
1950
|
+
this.moveSelect(this.select + 1);
|
|
1951
|
+
}
|
|
1952
|
+
this.render();
|
|
1953
|
+
}
|
|
1954
|
+
next() {
|
|
1955
|
+
if (this.select === this.suggestions.length - 1) {
|
|
1956
|
+
this.moveSelect(0);
|
|
1957
|
+
} else
|
|
1958
|
+
this.moveSelect(this.select + 1);
|
|
1959
|
+
this.render();
|
|
1960
|
+
}
|
|
1961
|
+
nextPage() {
|
|
1962
|
+
this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
|
|
1963
|
+
this.render();
|
|
1964
|
+
}
|
|
1965
|
+
prevPage() {
|
|
1966
|
+
this.moveSelect(Math.max(this.select - this.limit, 0));
|
|
1967
|
+
this.render();
|
|
1968
|
+
}
|
|
1969
|
+
left() {
|
|
1970
|
+
if (this.cursor <= 0)
|
|
1971
|
+
return this.bell();
|
|
1972
|
+
this.cursor = this.cursor - 1;
|
|
1973
|
+
this.render();
|
|
1974
|
+
}
|
|
1975
|
+
right() {
|
|
1976
|
+
if (this.cursor * this.scale >= this.rendered.length)
|
|
1977
|
+
return this.bell();
|
|
1978
|
+
this.cursor = this.cursor + 1;
|
|
1979
|
+
this.render();
|
|
1980
|
+
}
|
|
1981
|
+
renderOption(v, hovered, isStart, isEnd) {
|
|
1982
|
+
let desc;
|
|
1983
|
+
let prefix = isStart ? figures.arrowUp : isEnd ? figures.arrowDown : " ";
|
|
1984
|
+
let title = hovered ? color.cyan().underline(v.title) : v.title;
|
|
1985
|
+
prefix = (hovered ? color.cyan(figures.pointer) + " " : " ") + prefix;
|
|
1986
|
+
if (v.description) {
|
|
1987
|
+
desc = ` - ${v.description}`;
|
|
1988
|
+
if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
|
|
1989
|
+
desc = "\n" + wrap(v.description, { margin: 3, width: this.out.columns });
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
return prefix + " " + title + color.gray(desc || "");
|
|
1993
|
+
}
|
|
1994
|
+
render() {
|
|
1995
|
+
if (this.closed)
|
|
1996
|
+
return;
|
|
1997
|
+
if (this.firstRender)
|
|
1998
|
+
this.out.write(cursor.hide);
|
|
1999
|
+
else
|
|
2000
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
2001
|
+
super.render();
|
|
2002
|
+
let { startIndex, endIndex } = entriesToDisplay(this.select, this.choices.length, this.limit);
|
|
2003
|
+
this.outputText = [
|
|
2004
|
+
style.symbol(this.done, this.aborted, this.exited),
|
|
2005
|
+
color.bold(this.msg),
|
|
2006
|
+
style.delimiter(this.completing),
|
|
2007
|
+
this.done && this.suggestions[this.select] ? this.suggestions[this.select].title : this.rendered = this.transform.render(this.input)
|
|
2008
|
+
].join(" ");
|
|
2009
|
+
if (!this.done) {
|
|
2010
|
+
const suggestions = this.suggestions.slice(startIndex, endIndex).map((item, i) => this.renderOption(
|
|
2011
|
+
item,
|
|
2012
|
+
this.select === i + startIndex,
|
|
2013
|
+
i === 0 && startIndex > 0,
|
|
2014
|
+
i + startIndex === endIndex - 1 && endIndex < this.choices.length
|
|
2015
|
+
)).join("\n");
|
|
2016
|
+
this.outputText += `
|
|
2017
|
+
` + (suggestions || color.gray(this.fallback.title));
|
|
2018
|
+
}
|
|
2019
|
+
this.out.write(erase.line + cursor.to(0) + this.outputText);
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
module2.exports = AutocompletePrompt;
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
|
|
2026
|
+
// node_modules/prompts/lib/elements/autocompleteMultiselect.js
|
|
2027
|
+
var require_autocompleteMultiselect = __commonJS({
|
|
2028
|
+
"node_modules/prompts/lib/elements/autocompleteMultiselect.js"(exports2, module2) {
|
|
2029
|
+
"use strict";
|
|
2030
|
+
var color = require_kleur();
|
|
2031
|
+
var { cursor } = require_src();
|
|
2032
|
+
var MultiselectPrompt = require_multiselect();
|
|
2033
|
+
var { clear, style, figures } = require_util();
|
|
2034
|
+
var AutocompleteMultiselectPrompt = class extends MultiselectPrompt {
|
|
2035
|
+
constructor(opts = {}) {
|
|
2036
|
+
opts.overrideRender = true;
|
|
2037
|
+
super(opts);
|
|
2038
|
+
this.inputValue = "";
|
|
2039
|
+
this.clear = clear("", this.out.columns);
|
|
2040
|
+
this.filteredOptions = this.value;
|
|
2041
|
+
this.render();
|
|
2042
|
+
}
|
|
2043
|
+
last() {
|
|
2044
|
+
this.cursor = this.filteredOptions.length - 1;
|
|
2045
|
+
this.render();
|
|
2046
|
+
}
|
|
2047
|
+
next() {
|
|
2048
|
+
this.cursor = (this.cursor + 1) % this.filteredOptions.length;
|
|
2049
|
+
this.render();
|
|
2050
|
+
}
|
|
2051
|
+
up() {
|
|
2052
|
+
if (this.cursor === 0) {
|
|
2053
|
+
this.cursor = this.filteredOptions.length - 1;
|
|
2054
|
+
} else {
|
|
2055
|
+
this.cursor--;
|
|
2056
|
+
}
|
|
2057
|
+
this.render();
|
|
2058
|
+
}
|
|
2059
|
+
down() {
|
|
2060
|
+
if (this.cursor === this.filteredOptions.length - 1) {
|
|
2061
|
+
this.cursor = 0;
|
|
2062
|
+
} else {
|
|
2063
|
+
this.cursor++;
|
|
2064
|
+
}
|
|
2065
|
+
this.render();
|
|
2066
|
+
}
|
|
2067
|
+
left() {
|
|
2068
|
+
this.filteredOptions[this.cursor].selected = false;
|
|
2069
|
+
this.render();
|
|
2070
|
+
}
|
|
2071
|
+
right() {
|
|
2072
|
+
if (this.value.filter((e) => e.selected).length >= this.maxChoices)
|
|
2073
|
+
return this.bell();
|
|
2074
|
+
this.filteredOptions[this.cursor].selected = true;
|
|
2075
|
+
this.render();
|
|
2076
|
+
}
|
|
2077
|
+
delete() {
|
|
2078
|
+
if (this.inputValue.length) {
|
|
2079
|
+
this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
|
|
2080
|
+
this.updateFilteredOptions();
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
updateFilteredOptions() {
|
|
2084
|
+
const currentHighlight = this.filteredOptions[this.cursor];
|
|
2085
|
+
this.filteredOptions = this.value.filter((v) => {
|
|
2086
|
+
if (this.inputValue) {
|
|
2087
|
+
if (typeof v.title === "string") {
|
|
2088
|
+
if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
|
|
2089
|
+
return true;
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
if (typeof v.value === "string") {
|
|
2093
|
+
if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
|
|
2094
|
+
return true;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return false;
|
|
2098
|
+
}
|
|
2099
|
+
return true;
|
|
2100
|
+
});
|
|
2101
|
+
const newHighlightIndex = this.filteredOptions.findIndex((v) => v === currentHighlight);
|
|
2102
|
+
this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
|
|
2103
|
+
this.render();
|
|
2104
|
+
}
|
|
2105
|
+
handleSpaceToggle() {
|
|
2106
|
+
const v = this.filteredOptions[this.cursor];
|
|
2107
|
+
if (v.selected) {
|
|
2108
|
+
v.selected = false;
|
|
2109
|
+
this.render();
|
|
2110
|
+
} else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
|
|
2111
|
+
return this.bell();
|
|
2112
|
+
} else {
|
|
2113
|
+
v.selected = true;
|
|
2114
|
+
this.render();
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
handleInputChange(c) {
|
|
2118
|
+
this.inputValue = this.inputValue + c;
|
|
2119
|
+
this.updateFilteredOptions();
|
|
2120
|
+
}
|
|
2121
|
+
_(c, key) {
|
|
2122
|
+
if (c === " ") {
|
|
2123
|
+
this.handleSpaceToggle();
|
|
2124
|
+
} else {
|
|
2125
|
+
this.handleInputChange(c);
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
renderInstructions() {
|
|
2129
|
+
if (this.instructions === void 0 || this.instructions) {
|
|
2130
|
+
if (typeof this.instructions === "string") {
|
|
2131
|
+
return this.instructions;
|
|
2132
|
+
}
|
|
2133
|
+
return `
|
|
2134
|
+
Instructions:
|
|
2135
|
+
${figures.arrowUp}/${figures.arrowDown}: Highlight option
|
|
2136
|
+
${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
|
|
2137
|
+
[a,b,c]/delete: Filter choices
|
|
2138
|
+
enter/return: Complete answer
|
|
2139
|
+
`;
|
|
2140
|
+
}
|
|
2141
|
+
return "";
|
|
2142
|
+
}
|
|
2143
|
+
renderCurrentInput() {
|
|
2144
|
+
return `
|
|
2145
|
+
Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter something to filter")}
|
|
2146
|
+
`;
|
|
2147
|
+
}
|
|
2148
|
+
renderOption(cursor2, v, i) {
|
|
2149
|
+
let title;
|
|
2150
|
+
if (v.disabled)
|
|
2151
|
+
title = cursor2 === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
|
|
2152
|
+
else
|
|
2153
|
+
title = cursor2 === i ? color.cyan().underline(v.title) : v.title;
|
|
2154
|
+
return (v.selected ? color.green(figures.radioOn) : figures.radioOff) + " " + title;
|
|
2155
|
+
}
|
|
2156
|
+
renderDoneOrInstructions() {
|
|
2157
|
+
if (this.done) {
|
|
2158
|
+
return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
|
|
2159
|
+
}
|
|
2160
|
+
const output = [color.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
|
|
2161
|
+
if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
|
|
2162
|
+
output.push(color.yellow(this.warn));
|
|
2163
|
+
}
|
|
2164
|
+
return output.join(" ");
|
|
2165
|
+
}
|
|
2166
|
+
render() {
|
|
2167
|
+
if (this.closed)
|
|
2168
|
+
return;
|
|
2169
|
+
if (this.firstRender)
|
|
2170
|
+
this.out.write(cursor.hide);
|
|
2171
|
+
super.render();
|
|
2172
|
+
let prompt = [
|
|
2173
|
+
style.symbol(this.done, this.aborted),
|
|
2174
|
+
color.bold(this.msg),
|
|
2175
|
+
style.delimiter(false),
|
|
2176
|
+
this.renderDoneOrInstructions()
|
|
2177
|
+
].join(" ");
|
|
2178
|
+
if (this.showMinError) {
|
|
2179
|
+
prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
|
|
2180
|
+
this.showMinError = false;
|
|
2181
|
+
}
|
|
2182
|
+
prompt += this.renderOptions(this.filteredOptions);
|
|
2183
|
+
this.out.write(this.clear + prompt);
|
|
2184
|
+
this.clear = clear(prompt, this.out.columns);
|
|
2185
|
+
}
|
|
2186
|
+
};
|
|
2187
|
+
module2.exports = AutocompleteMultiselectPrompt;
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
|
|
2191
|
+
// node_modules/prompts/lib/elements/confirm.js
|
|
2192
|
+
var require_confirm = __commonJS({
|
|
2193
|
+
"node_modules/prompts/lib/elements/confirm.js"(exports2, module2) {
|
|
2194
|
+
var color = require_kleur();
|
|
2195
|
+
var Prompt = require_prompt();
|
|
2196
|
+
var { style, clear } = require_util();
|
|
2197
|
+
var { erase, cursor } = require_src();
|
|
2198
|
+
var ConfirmPrompt = class extends Prompt {
|
|
2199
|
+
constructor(opts = {}) {
|
|
2200
|
+
super(opts);
|
|
2201
|
+
this.msg = opts.message;
|
|
2202
|
+
this.value = opts.initial;
|
|
2203
|
+
this.initialValue = !!opts.initial;
|
|
2204
|
+
this.yesMsg = opts.yes || "yes";
|
|
2205
|
+
this.yesOption = opts.yesOption || "(Y/n)";
|
|
2206
|
+
this.noMsg = opts.no || "no";
|
|
2207
|
+
this.noOption = opts.noOption || "(y/N)";
|
|
2208
|
+
this.render();
|
|
2209
|
+
}
|
|
2210
|
+
reset() {
|
|
2211
|
+
this.value = this.initialValue;
|
|
2212
|
+
this.fire();
|
|
2213
|
+
this.render();
|
|
2214
|
+
}
|
|
2215
|
+
exit() {
|
|
2216
|
+
this.abort();
|
|
2217
|
+
}
|
|
2218
|
+
abort() {
|
|
2219
|
+
this.done = this.aborted = true;
|
|
2220
|
+
this.fire();
|
|
2221
|
+
this.render();
|
|
2222
|
+
this.out.write("\n");
|
|
2223
|
+
this.close();
|
|
2224
|
+
}
|
|
2225
|
+
submit() {
|
|
2226
|
+
this.value = this.value || false;
|
|
2227
|
+
this.done = true;
|
|
2228
|
+
this.aborted = false;
|
|
2229
|
+
this.fire();
|
|
2230
|
+
this.render();
|
|
2231
|
+
this.out.write("\n");
|
|
2232
|
+
this.close();
|
|
2233
|
+
}
|
|
2234
|
+
_(c, key) {
|
|
2235
|
+
if (c.toLowerCase() === "y") {
|
|
2236
|
+
this.value = true;
|
|
2237
|
+
return this.submit();
|
|
2238
|
+
}
|
|
2239
|
+
if (c.toLowerCase() === "n") {
|
|
2240
|
+
this.value = false;
|
|
2241
|
+
return this.submit();
|
|
2242
|
+
}
|
|
2243
|
+
return this.bell();
|
|
2244
|
+
}
|
|
2245
|
+
render() {
|
|
2246
|
+
if (this.closed)
|
|
2247
|
+
return;
|
|
2248
|
+
if (this.firstRender)
|
|
2249
|
+
this.out.write(cursor.hide);
|
|
2250
|
+
else
|
|
2251
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
2252
|
+
super.render();
|
|
2253
|
+
this.outputText = [
|
|
2254
|
+
style.symbol(this.done, this.aborted),
|
|
2255
|
+
color.bold(this.msg),
|
|
2256
|
+
style.delimiter(this.done),
|
|
2257
|
+
this.done ? this.value ? this.yesMsg : this.noMsg : color.gray(this.initialValue ? this.yesOption : this.noOption)
|
|
2258
|
+
].join(" ");
|
|
2259
|
+
this.out.write(erase.line + cursor.to(0) + this.outputText);
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
module2.exports = ConfirmPrompt;
|
|
2263
|
+
}
|
|
2264
|
+
});
|
|
2265
|
+
|
|
2266
|
+
// node_modules/prompts/lib/elements/index.js
|
|
2267
|
+
var require_elements = __commonJS({
|
|
2268
|
+
"node_modules/prompts/lib/elements/index.js"(exports2, module2) {
|
|
2269
|
+
"use strict";
|
|
2270
|
+
module2.exports = {
|
|
2271
|
+
TextPrompt: require_text(),
|
|
2272
|
+
SelectPrompt: require_select(),
|
|
2273
|
+
TogglePrompt: require_toggle(),
|
|
2274
|
+
DatePrompt: require_date(),
|
|
2275
|
+
NumberPrompt: require_number(),
|
|
2276
|
+
MultiselectPrompt: require_multiselect(),
|
|
2277
|
+
AutocompletePrompt: require_autocomplete(),
|
|
2278
|
+
AutocompleteMultiselectPrompt: require_autocompleteMultiselect(),
|
|
2279
|
+
ConfirmPrompt: require_confirm()
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
});
|
|
2283
|
+
|
|
2284
|
+
// node_modules/prompts/lib/prompts.js
|
|
2285
|
+
var require_prompts = __commonJS({
|
|
2286
|
+
"node_modules/prompts/lib/prompts.js"(exports2) {
|
|
2287
|
+
"use strict";
|
|
2288
|
+
var $ = exports2;
|
|
2289
|
+
var el = require_elements();
|
|
2290
|
+
var noop = (v) => v;
|
|
2291
|
+
function toPrompt(type, args, opts = {}) {
|
|
2292
|
+
return new Promise((res, rej) => {
|
|
2293
|
+
const p = new el[type](args);
|
|
2294
|
+
const onAbort = opts.onAbort || noop;
|
|
2295
|
+
const onSubmit = opts.onSubmit || noop;
|
|
2296
|
+
const onExit = opts.onExit || noop;
|
|
2297
|
+
p.on("state", args.onState || noop);
|
|
2298
|
+
p.on("submit", (x) => res(onSubmit(x)));
|
|
2299
|
+
p.on("exit", (x) => res(onExit(x)));
|
|
2300
|
+
p.on("abort", (x) => rej(onAbort(x)));
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
$.text = (args) => toPrompt("TextPrompt", args);
|
|
2304
|
+
$.password = (args) => {
|
|
2305
|
+
args.style = "password";
|
|
2306
|
+
return $.text(args);
|
|
2307
|
+
};
|
|
2308
|
+
$.invisible = (args) => {
|
|
2309
|
+
args.style = "invisible";
|
|
2310
|
+
return $.text(args);
|
|
2311
|
+
};
|
|
2312
|
+
$.number = (args) => toPrompt("NumberPrompt", args);
|
|
2313
|
+
$.date = (args) => toPrompt("DatePrompt", args);
|
|
2314
|
+
$.confirm = (args) => toPrompt("ConfirmPrompt", args);
|
|
2315
|
+
$.list = (args) => {
|
|
2316
|
+
const sep = args.separator || ",";
|
|
2317
|
+
return toPrompt("TextPrompt", args, {
|
|
2318
|
+
onSubmit: (str) => str.split(sep).map((s) => s.trim())
|
|
2319
|
+
});
|
|
2320
|
+
};
|
|
2321
|
+
$.toggle = (args) => toPrompt("TogglePrompt", args);
|
|
2322
|
+
$.select = (args) => toPrompt("SelectPrompt", args);
|
|
2323
|
+
$.multiselect = (args) => {
|
|
2324
|
+
args.choices = [].concat(args.choices || []);
|
|
2325
|
+
const toSelected = (items) => items.filter((item) => item.selected).map((item) => item.value);
|
|
2326
|
+
return toPrompt("MultiselectPrompt", args, {
|
|
2327
|
+
onAbort: toSelected,
|
|
2328
|
+
onSubmit: toSelected
|
|
2329
|
+
});
|
|
2330
|
+
};
|
|
2331
|
+
$.autocompleteMultiselect = (args) => {
|
|
2332
|
+
args.choices = [].concat(args.choices || []);
|
|
2333
|
+
const toSelected = (items) => items.filter((item) => item.selected).map((item) => item.value);
|
|
2334
|
+
return toPrompt("AutocompleteMultiselectPrompt", args, {
|
|
2335
|
+
onAbort: toSelected,
|
|
2336
|
+
onSubmit: toSelected
|
|
2337
|
+
});
|
|
2338
|
+
};
|
|
2339
|
+
var byTitle = (input, choices) => Promise.resolve(
|
|
2340
|
+
choices.filter((item) => item.title.slice(0, input.length).toLowerCase() === input.toLowerCase())
|
|
2341
|
+
);
|
|
2342
|
+
$.autocomplete = (args) => {
|
|
2343
|
+
args.suggest = args.suggest || byTitle;
|
|
2344
|
+
args.choices = [].concat(args.choices || []);
|
|
2345
|
+
return toPrompt("AutocompletePrompt", args);
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
|
|
2350
|
+
// node_modules/prompts/lib/index.js
|
|
2351
|
+
var require_lib = __commonJS({
|
|
2352
|
+
"node_modules/prompts/lib/index.js"(exports2, module2) {
|
|
2353
|
+
"use strict";
|
|
2354
|
+
var prompts = require_prompts();
|
|
2355
|
+
var passOn = ["suggest", "format", "onState", "validate", "onRender", "type"];
|
|
2356
|
+
var noop = () => {
|
|
2357
|
+
};
|
|
2358
|
+
async function prompt(questions = [], { onSubmit = noop, onCancel = noop } = {}) {
|
|
2359
|
+
const answers = {};
|
|
2360
|
+
const override2 = prompt._override || {};
|
|
2361
|
+
questions = [].concat(questions);
|
|
2362
|
+
let answer, question, quit, name, type, lastPrompt;
|
|
2363
|
+
const getFormattedAnswer = async (question2, answer2, skipValidation = false) => {
|
|
2364
|
+
if (!skipValidation && question2.validate && question2.validate(answer2) !== true) {
|
|
2365
|
+
return;
|
|
2366
|
+
}
|
|
2367
|
+
return question2.format ? await question2.format(answer2, answers) : answer2;
|
|
2368
|
+
};
|
|
2369
|
+
for (question of questions) {
|
|
2370
|
+
({ name, type } = question);
|
|
2371
|
+
if (typeof type === "function") {
|
|
2372
|
+
type = await type(answer, { ...answers }, question);
|
|
2373
|
+
question["type"] = type;
|
|
2374
|
+
}
|
|
2375
|
+
if (!type)
|
|
2376
|
+
continue;
|
|
2377
|
+
for (let key in question) {
|
|
2378
|
+
if (passOn.includes(key))
|
|
2379
|
+
continue;
|
|
2380
|
+
let value = question[key];
|
|
2381
|
+
question[key] = typeof value === "function" ? await value(answer, { ...answers }, lastPrompt) : value;
|
|
2382
|
+
}
|
|
2383
|
+
lastPrompt = question;
|
|
2384
|
+
if (typeof question.message !== "string") {
|
|
2385
|
+
throw new Error("prompt message is required");
|
|
2386
|
+
}
|
|
2387
|
+
({ name, type } = question);
|
|
2388
|
+
if (prompts[type] === void 0) {
|
|
2389
|
+
throw new Error(`prompt type (${type}) is not defined`);
|
|
2390
|
+
}
|
|
2391
|
+
if (override2[question.name] !== void 0) {
|
|
2392
|
+
answer = await getFormattedAnswer(question, override2[question.name]);
|
|
2393
|
+
if (answer !== void 0) {
|
|
2394
|
+
answers[name] = answer;
|
|
2395
|
+
continue;
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
try {
|
|
2399
|
+
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts[type](question);
|
|
2400
|
+
answers[name] = answer = await getFormattedAnswer(question, answer, true);
|
|
2401
|
+
quit = await onSubmit(question, answer, answers);
|
|
2402
|
+
} catch (err2) {
|
|
2403
|
+
quit = !await onCancel(question, answers);
|
|
2404
|
+
}
|
|
2405
|
+
if (quit)
|
|
2406
|
+
return answers;
|
|
2407
|
+
}
|
|
2408
|
+
return answers;
|
|
2409
|
+
}
|
|
2410
|
+
function getInjectedAnswer(injected, deafultValue) {
|
|
2411
|
+
const answer = injected.shift();
|
|
2412
|
+
if (answer instanceof Error) {
|
|
2413
|
+
throw answer;
|
|
2414
|
+
}
|
|
2415
|
+
return answer === void 0 ? deafultValue : answer;
|
|
2416
|
+
}
|
|
2417
|
+
function inject(answers) {
|
|
2418
|
+
prompt._injected = (prompt._injected || []).concat(answers);
|
|
2419
|
+
}
|
|
2420
|
+
function override(answers) {
|
|
2421
|
+
prompt._override = Object.assign({}, answers);
|
|
2422
|
+
}
|
|
2423
|
+
module2.exports = Object.assign(prompt, { prompt, prompts, inject, override });
|
|
2424
|
+
}
|
|
2425
|
+
});
|
|
2426
|
+
|
|
33
2427
|
// src/cli/index.ts
|
|
34
2428
|
var cli_exports = {};
|
|
35
2429
|
__export(cli_exports, {
|
|
@@ -1312,7 +3706,7 @@ var taskGenerate = async (config) => {
|
|
|
1312
3706
|
config.logger.error(`Stencil's srcDir was not specified.`);
|
|
1313
3707
|
return config.sys.exit(1);
|
|
1314
3708
|
}
|
|
1315
|
-
const { prompt } = await
|
|
3709
|
+
const { prompt } = await Promise.resolve().then(() => __toESM(require_lib()));
|
|
1316
3710
|
const input = config.flags.unknownArgs.find((arg) => !arg.startsWith("-")) || (await prompt({ name: "tagName", type: "text", message: "Component tag name (dash-case):" })).tagName;
|
|
1317
3711
|
if (void 0 === input) {
|
|
1318
3712
|
return;
|
|
@@ -1352,7 +3746,7 @@ var taskGenerate = async (config) => {
|
|
|
1352
3746
|
writtenFiles.map((file) => console.log(` - ${(0, import_path2.relative)(absoluteRootDir, file)}`));
|
|
1353
3747
|
};
|
|
1354
3748
|
var chooseFilesToGenerate = async () => {
|
|
1355
|
-
const { prompt } = await
|
|
3749
|
+
const { prompt } = await Promise.resolve().then(() => __toESM(require_lib()));
|
|
1356
3750
|
return (await prompt({
|
|
1357
3751
|
name: "filesToGenerate",
|
|
1358
3752
|
type: "multiselect",
|