team-toon-tack 1.0.11 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4923 +0,0 @@
1
- import {
2
- __commonJS,
3
- __require
4
- } from "./cli-pyanjjwn.js";
5
-
6
- // node_modules/kleur/index.js
7
- var require_kleur = __commonJS((exports, module) => {
8
- var { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
9
- var $ = {
10
- enabled: !NODE_DISABLE_COLORS && TERM !== "dumb" && FORCE_COLOR !== "0",
11
- reset: init(0, 0),
12
- bold: init(1, 22),
13
- dim: init(2, 22),
14
- italic: init(3, 23),
15
- underline: init(4, 24),
16
- inverse: init(7, 27),
17
- hidden: init(8, 28),
18
- strikethrough: init(9, 29),
19
- black: init(30, 39),
20
- red: init(31, 39),
21
- green: init(32, 39),
22
- yellow: init(33, 39),
23
- blue: init(34, 39),
24
- magenta: init(35, 39),
25
- cyan: init(36, 39),
26
- white: init(37, 39),
27
- gray: init(90, 39),
28
- grey: init(90, 39),
29
- bgBlack: init(40, 49),
30
- bgRed: init(41, 49),
31
- bgGreen: init(42, 49),
32
- bgYellow: init(43, 49),
33
- bgBlue: init(44, 49),
34
- bgMagenta: init(45, 49),
35
- bgCyan: init(46, 49),
36
- bgWhite: init(47, 49)
37
- };
38
- function run(arr, str) {
39
- let i = 0, tmp, beg = "", end = "";
40
- for (;i < arr.length; i++) {
41
- tmp = arr[i];
42
- beg += tmp.open;
43
- end += tmp.close;
44
- if (str.includes(tmp.close)) {
45
- str = str.replace(tmp.rgx, tmp.close + tmp.open);
46
- }
47
- }
48
- return beg + str + end;
49
- }
50
- function chain(has, keys) {
51
- let ctx = { has, keys };
52
- ctx.reset = $.reset.bind(ctx);
53
- ctx.bold = $.bold.bind(ctx);
54
- ctx.dim = $.dim.bind(ctx);
55
- ctx.italic = $.italic.bind(ctx);
56
- ctx.underline = $.underline.bind(ctx);
57
- ctx.inverse = $.inverse.bind(ctx);
58
- ctx.hidden = $.hidden.bind(ctx);
59
- ctx.strikethrough = $.strikethrough.bind(ctx);
60
- ctx.black = $.black.bind(ctx);
61
- ctx.red = $.red.bind(ctx);
62
- ctx.green = $.green.bind(ctx);
63
- ctx.yellow = $.yellow.bind(ctx);
64
- ctx.blue = $.blue.bind(ctx);
65
- ctx.magenta = $.magenta.bind(ctx);
66
- ctx.cyan = $.cyan.bind(ctx);
67
- ctx.white = $.white.bind(ctx);
68
- ctx.gray = $.gray.bind(ctx);
69
- ctx.grey = $.grey.bind(ctx);
70
- ctx.bgBlack = $.bgBlack.bind(ctx);
71
- ctx.bgRed = $.bgRed.bind(ctx);
72
- ctx.bgGreen = $.bgGreen.bind(ctx);
73
- ctx.bgYellow = $.bgYellow.bind(ctx);
74
- ctx.bgBlue = $.bgBlue.bind(ctx);
75
- ctx.bgMagenta = $.bgMagenta.bind(ctx);
76
- ctx.bgCyan = $.bgCyan.bind(ctx);
77
- ctx.bgWhite = $.bgWhite.bind(ctx);
78
- return ctx;
79
- }
80
- function init(open, close) {
81
- let blk = {
82
- open: `\x1B[${open}m`,
83
- close: `\x1B[${close}m`,
84
- rgx: new RegExp(`\\x1b\\[${close}m`, "g")
85
- };
86
- return function(txt) {
87
- if (this !== undefined && this.has !== undefined) {
88
- this.has.includes(open) || (this.has.push(open), this.keys.push(blk));
89
- return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
90
- }
91
- return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
92
- };
93
- }
94
- module.exports = $;
95
- });
96
-
97
- // node_modules/prompts/dist/util/action.js
98
- var require_action = __commonJS((exports, module) => {
99
- module.exports = (key, isSelect) => {
100
- if (key.meta && key.name !== "escape")
101
- return;
102
- if (key.ctrl) {
103
- if (key.name === "a")
104
- return "first";
105
- if (key.name === "c")
106
- return "abort";
107
- if (key.name === "d")
108
- return "abort";
109
- if (key.name === "e")
110
- return "last";
111
- if (key.name === "g")
112
- return "reset";
113
- }
114
- if (isSelect) {
115
- if (key.name === "j")
116
- return "down";
117
- if (key.name === "k")
118
- return "up";
119
- }
120
- if (key.name === "return")
121
- return "submit";
122
- if (key.name === "enter")
123
- return "submit";
124
- if (key.name === "backspace")
125
- return "delete";
126
- if (key.name === "delete")
127
- return "deleteForward";
128
- if (key.name === "abort")
129
- return "abort";
130
- if (key.name === "escape")
131
- return "exit";
132
- if (key.name === "tab")
133
- return "next";
134
- if (key.name === "pagedown")
135
- return "nextPage";
136
- if (key.name === "pageup")
137
- return "prevPage";
138
- if (key.name === "home")
139
- return "home";
140
- if (key.name === "end")
141
- return "end";
142
- if (key.name === "up")
143
- return "up";
144
- if (key.name === "down")
145
- return "down";
146
- if (key.name === "right")
147
- return "right";
148
- if (key.name === "left")
149
- return "left";
150
- return false;
151
- };
152
- });
153
-
154
- // node_modules/prompts/dist/util/strip.js
155
- var require_strip = __commonJS((exports, module) => {
156
- module.exports = (str) => {
157
- const pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|");
158
- const RGX = new RegExp(pattern, "g");
159
- return typeof str === "string" ? str.replace(RGX, "") : str;
160
- };
161
- });
162
-
163
- // node_modules/sisteransi/src/index.js
164
- var require_src = __commonJS((exports, module) => {
165
- var ESC = "\x1B";
166
- var CSI = `${ESC}[`;
167
- var beep = "\x07";
168
- var cursor = {
169
- to(x, y) {
170
- if (!y)
171
- return `${CSI}${x + 1}G`;
172
- return `${CSI}${y + 1};${x + 1}H`;
173
- },
174
- move(x, y) {
175
- let ret = "";
176
- if (x < 0)
177
- ret += `${CSI}${-x}D`;
178
- else if (x > 0)
179
- ret += `${CSI}${x}C`;
180
- if (y < 0)
181
- ret += `${CSI}${-y}A`;
182
- else if (y > 0)
183
- ret += `${CSI}${y}B`;
184
- return ret;
185
- },
186
- up: (count = 1) => `${CSI}${count}A`,
187
- down: (count = 1) => `${CSI}${count}B`,
188
- forward: (count = 1) => `${CSI}${count}C`,
189
- backward: (count = 1) => `${CSI}${count}D`,
190
- nextLine: (count = 1) => `${CSI}E`.repeat(count),
191
- prevLine: (count = 1) => `${CSI}F`.repeat(count),
192
- left: `${CSI}G`,
193
- hide: `${CSI}?25l`,
194
- show: `${CSI}?25h`,
195
- save: `${ESC}7`,
196
- restore: `${ESC}8`
197
- };
198
- var scroll = {
199
- up: (count = 1) => `${CSI}S`.repeat(count),
200
- down: (count = 1) => `${CSI}T`.repeat(count)
201
- };
202
- var erase = {
203
- screen: `${CSI}2J`,
204
- up: (count = 1) => `${CSI}1J`.repeat(count),
205
- down: (count = 1) => `${CSI}J`.repeat(count),
206
- line: `${CSI}2K`,
207
- lineEnd: `${CSI}K`,
208
- lineStart: `${CSI}1K`,
209
- lines(count) {
210
- let clear = "";
211
- for (let i = 0;i < count; i++)
212
- clear += this.line + (i < count - 1 ? cursor.up() : "");
213
- if (count)
214
- clear += cursor.left;
215
- return clear;
216
- }
217
- };
218
- module.exports = { cursor, scroll, erase, beep };
219
- });
220
-
221
- // node_modules/prompts/dist/util/clear.js
222
- var require_clear = __commonJS((exports, module) => {
223
- function _createForOfIteratorHelper(o, allowArrayLike) {
224
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
225
- if (!it) {
226
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
227
- if (it)
228
- o = it;
229
- var i = 0;
230
- var F = function F() {};
231
- return { s: F, n: function n() {
232
- if (i >= o.length)
233
- return { done: true };
234
- return { done: false, value: o[i++] };
235
- }, e: function e(_e) {
236
- throw _e;
237
- }, f: F };
238
- }
239
- throw new TypeError(`Invalid attempt to iterate non-iterable instance.
240
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
241
- }
242
- var normalCompletion = true, didErr = false, err;
243
- return { s: function s() {
244
- it = it.call(o);
245
- }, n: function n() {
246
- var step = it.next();
247
- normalCompletion = step.done;
248
- return step;
249
- }, e: function e(_e2) {
250
- didErr = true;
251
- err = _e2;
252
- }, f: function f() {
253
- try {
254
- if (!normalCompletion && it.return != null)
255
- it.return();
256
- } finally {
257
- if (didErr)
258
- throw err;
259
- }
260
- } };
261
- }
262
- function _unsupportedIterableToArray(o, minLen) {
263
- if (!o)
264
- return;
265
- if (typeof o === "string")
266
- return _arrayLikeToArray(o, minLen);
267
- var n = Object.prototype.toString.call(o).slice(8, -1);
268
- if (n === "Object" && o.constructor)
269
- n = o.constructor.name;
270
- if (n === "Map" || n === "Set")
271
- return Array.from(o);
272
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
273
- return _arrayLikeToArray(o, minLen);
274
- }
275
- function _arrayLikeToArray(arr, len) {
276
- if (len == null || len > arr.length)
277
- len = arr.length;
278
- for (var i = 0, arr2 = new Array(len);i < len; i++)
279
- arr2[i] = arr[i];
280
- return arr2;
281
- }
282
- var strip = require_strip();
283
- var _require = require_src();
284
- var erase = _require.erase;
285
- var cursor = _require.cursor;
286
- var width = (str) => [...strip(str)].length;
287
- module.exports = function(prompt, perLine) {
288
- if (!perLine)
289
- return erase.line + cursor.to(0);
290
- let rows = 0;
291
- const lines = prompt.split(/\r?\n/);
292
- var _iterator = _createForOfIteratorHelper(lines), _step;
293
- try {
294
- for (_iterator.s();!(_step = _iterator.n()).done; ) {
295
- let line = _step.value;
296
- rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
297
- }
298
- } catch (err) {
299
- _iterator.e(err);
300
- } finally {
301
- _iterator.f();
302
- }
303
- return erase.lines(rows);
304
- };
305
- });
306
-
307
- // node_modules/prompts/dist/util/figures.js
308
- var require_figures = __commonJS((exports, module) => {
309
- var main = {
310
- arrowUp: "↑",
311
- arrowDown: "↓",
312
- arrowLeft: "←",
313
- arrowRight: "→",
314
- radioOn: "◉",
315
- radioOff: "◯",
316
- tick: "✔",
317
- cross: "✖",
318
- ellipsis: "…",
319
- pointerSmall: "›",
320
- line: "─",
321
- pointer: "❯"
322
- };
323
- var win = {
324
- arrowUp: main.arrowUp,
325
- arrowDown: main.arrowDown,
326
- arrowLeft: main.arrowLeft,
327
- arrowRight: main.arrowRight,
328
- radioOn: "(*)",
329
- radioOff: "( )",
330
- tick: "√",
331
- cross: "×",
332
- ellipsis: "...",
333
- pointerSmall: "»",
334
- line: "─",
335
- pointer: ">"
336
- };
337
- var figures = process.platform === "win32" ? win : main;
338
- module.exports = figures;
339
- });
340
-
341
- // node_modules/prompts/dist/util/style.js
342
- var require_style = __commonJS((exports, module) => {
343
- var c = require_kleur();
344
- var figures = require_figures();
345
- var styles = Object.freeze({
346
- password: {
347
- scale: 1,
348
- render: (input) => "*".repeat(input.length)
349
- },
350
- emoji: {
351
- scale: 2,
352
- render: (input) => "\uD83D\uDE03".repeat(input.length)
353
- },
354
- invisible: {
355
- scale: 0,
356
- render: (input) => ""
357
- },
358
- default: {
359
- scale: 1,
360
- render: (input) => `${input}`
361
- }
362
- });
363
- var render = (type) => styles[type] || styles.default;
364
- var symbols = Object.freeze({
365
- aborted: c.red(figures.cross),
366
- done: c.green(figures.tick),
367
- exited: c.yellow(figures.cross),
368
- default: c.cyan("?")
369
- });
370
- var symbol = (done, aborted, exited) => aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default;
371
- var delimiter = (completing) => c.gray(completing ? figures.ellipsis : figures.pointerSmall);
372
- var item = (expandable, expanded) => c.gray(expandable ? expanded ? figures.pointerSmall : "+" : figures.line);
373
- module.exports = {
374
- styles,
375
- render,
376
- symbols,
377
- symbol,
378
- delimiter,
379
- item
380
- };
381
- });
382
-
383
- // node_modules/prompts/dist/util/lines.js
384
- var require_lines = __commonJS((exports, module) => {
385
- var strip = require_strip();
386
- module.exports = function(msg, perLine) {
387
- let lines = String(strip(msg) || "").split(/\r?\n/);
388
- if (!perLine)
389
- return lines.length;
390
- return lines.map((l) => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
391
- };
392
- });
393
-
394
- // node_modules/prompts/dist/util/wrap.js
395
- var require_wrap = __commonJS((exports, module) => {
396
- module.exports = (msg, opts = {}) => {
397
- const tab = Number.isSafeInteger(parseInt(opts.margin)) ? new Array(parseInt(opts.margin)).fill(" ").join("") : opts.margin || "";
398
- const width = opts.width;
399
- return (msg || "").split(/\r?\n/g).map((line) => line.split(/\s+/g).reduce((arr, w) => {
400
- if (w.length + tab.length >= width || arr[arr.length - 1].length + w.length + 1 < width)
401
- arr[arr.length - 1] += ` ${w}`;
402
- else
403
- arr.push(`${tab}${w}`);
404
- return arr;
405
- }, [tab]).join(`
406
- `)).join(`
407
- `);
408
- };
409
- });
410
-
411
- // node_modules/prompts/dist/util/entriesToDisplay.js
412
- var require_entriesToDisplay = __commonJS((exports, module) => {
413
- module.exports = (cursor, total, maxVisible) => {
414
- maxVisible = maxVisible || total;
415
- let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2));
416
- if (startIndex < 0)
417
- startIndex = 0;
418
- let endIndex = Math.min(startIndex + maxVisible, total);
419
- return {
420
- startIndex,
421
- endIndex
422
- };
423
- };
424
- });
425
-
426
- // node_modules/prompts/dist/util/index.js
427
- var require_util = __commonJS((exports, module) => {
428
- module.exports = {
429
- action: require_action(),
430
- clear: require_clear(),
431
- style: require_style(),
432
- strip: require_strip(),
433
- figures: require_figures(),
434
- lines: require_lines(),
435
- wrap: require_wrap(),
436
- entriesToDisplay: require_entriesToDisplay()
437
- };
438
- });
439
-
440
- // node_modules/prompts/dist/elements/prompt.js
441
- var require_prompt = __commonJS((exports, module) => {
442
- var readline = __require("readline");
443
- var _require = require_util();
444
- var action = _require.action;
445
- var EventEmitter = __require("events");
446
- var _require2 = require_src();
447
- var beep = _require2.beep;
448
- var cursor = _require2.cursor;
449
- var color = require_kleur();
450
-
451
- class Prompt extends EventEmitter {
452
- constructor(opts = {}) {
453
- super();
454
- this.firstRender = true;
455
- this.in = opts.stdin || process.stdin;
456
- this.out = opts.stdout || process.stdout;
457
- this.onRender = (opts.onRender || (() => {
458
- return;
459
- })).bind(this);
460
- const rl = readline.createInterface({
461
- input: this.in,
462
- escapeCodeTimeout: 50
463
- });
464
- readline.emitKeypressEvents(this.in, rl);
465
- if (this.in.isTTY)
466
- this.in.setRawMode(true);
467
- const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
468
- const keypress = (str, key) => {
469
- let a = action(key, isSelect);
470
- if (a === false) {
471
- this._ && this._(str, key);
472
- } else if (typeof this[a] === "function") {
473
- this[a](key);
474
- } else {
475
- this.bell();
476
- }
477
- };
478
- this.close = () => {
479
- this.out.write(cursor.show);
480
- this.in.removeListener("keypress", keypress);
481
- if (this.in.isTTY)
482
- this.in.setRawMode(false);
483
- rl.close();
484
- this.emit(this.aborted ? "abort" : this.exited ? "exit" : "submit", this.value);
485
- this.closed = true;
486
- };
487
- this.in.on("keypress", keypress);
488
- }
489
- fire() {
490
- this.emit("state", {
491
- value: this.value,
492
- aborted: !!this.aborted,
493
- exited: !!this.exited
494
- });
495
- }
496
- bell() {
497
- this.out.write(beep);
498
- }
499
- render() {
500
- this.onRender(color);
501
- if (this.firstRender)
502
- this.firstRender = false;
503
- }
504
- }
505
- module.exports = Prompt;
506
- });
507
-
508
- // node_modules/prompts/dist/elements/text.js
509
- var require_text = __commonJS((exports, module) => {
510
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
511
- try {
512
- var info = gen[key](arg);
513
- var value = info.value;
514
- } catch (error) {
515
- reject(error);
516
- return;
517
- }
518
- if (info.done) {
519
- resolve(value);
520
- } else {
521
- Promise.resolve(value).then(_next, _throw);
522
- }
523
- }
524
- function _asyncToGenerator(fn) {
525
- return function() {
526
- var self = this, args = arguments;
527
- return new Promise(function(resolve, reject) {
528
- var gen = fn.apply(self, args);
529
- function _next(value) {
530
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
531
- }
532
- function _throw(err) {
533
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
534
- }
535
- _next(undefined);
536
- });
537
- };
538
- }
539
- var color = require_kleur();
540
- var Prompt = require_prompt();
541
- var _require = require_src();
542
- var erase = _require.erase;
543
- var cursor = _require.cursor;
544
- var _require2 = require_util();
545
- var style = _require2.style;
546
- var clear = _require2.clear;
547
- var lines = _require2.lines;
548
- var figures = _require2.figures;
549
-
550
- class TextPrompt extends Prompt {
551
- constructor(opts = {}) {
552
- super(opts);
553
- this.transform = style.render(opts.style);
554
- this.scale = this.transform.scale;
555
- this.msg = opts.message;
556
- this.initial = opts.initial || ``;
557
- this.validator = opts.validate || (() => true);
558
- this.value = ``;
559
- this.errorMsg = opts.error || `Please Enter A Valid Value`;
560
- this.cursor = Number(!!this.initial);
561
- this.cursorOffset = 0;
562
- this.clear = clear(``, this.out.columns);
563
- this.render();
564
- }
565
- set value(v) {
566
- if (!v && this.initial) {
567
- this.placeholder = true;
568
- this.rendered = color.gray(this.transform.render(this.initial));
569
- } else {
570
- this.placeholder = false;
571
- this.rendered = this.transform.render(v);
572
- }
573
- this._value = v;
574
- this.fire();
575
- }
576
- get value() {
577
- return this._value;
578
- }
579
- reset() {
580
- this.value = ``;
581
- this.cursor = Number(!!this.initial);
582
- this.cursorOffset = 0;
583
- this.fire();
584
- this.render();
585
- }
586
- exit() {
587
- this.abort();
588
- }
589
- abort() {
590
- this.value = this.value || this.initial;
591
- this.done = this.aborted = true;
592
- this.error = false;
593
- this.red = false;
594
- this.fire();
595
- this.render();
596
- this.out.write(`
597
- `);
598
- this.close();
599
- }
600
- validate() {
601
- var _this = this;
602
- return _asyncToGenerator(function* () {
603
- let valid = yield _this.validator(_this.value);
604
- if (typeof valid === `string`) {
605
- _this.errorMsg = valid;
606
- valid = false;
607
- }
608
- _this.error = !valid;
609
- })();
610
- }
611
- submit() {
612
- var _this2 = this;
613
- return _asyncToGenerator(function* () {
614
- _this2.value = _this2.value || _this2.initial;
615
- _this2.cursorOffset = 0;
616
- _this2.cursor = _this2.rendered.length;
617
- yield _this2.validate();
618
- if (_this2.error) {
619
- _this2.red = true;
620
- _this2.fire();
621
- _this2.render();
622
- return;
623
- }
624
- _this2.done = true;
625
- _this2.aborted = false;
626
- _this2.fire();
627
- _this2.render();
628
- _this2.out.write(`
629
- `);
630
- _this2.close();
631
- })();
632
- }
633
- next() {
634
- if (!this.placeholder)
635
- return this.bell();
636
- this.value = this.initial;
637
- this.cursor = this.rendered.length;
638
- this.fire();
639
- this.render();
640
- }
641
- moveCursor(n) {
642
- if (this.placeholder)
643
- return;
644
- this.cursor = this.cursor + n;
645
- this.cursorOffset += n;
646
- }
647
- _(c, key) {
648
- let s1 = this.value.slice(0, this.cursor);
649
- let s2 = this.value.slice(this.cursor);
650
- this.value = `${s1}${c}${s2}`;
651
- this.red = false;
652
- this.cursor = this.placeholder ? 0 : s1.length + 1;
653
- this.render();
654
- }
655
- delete() {
656
- if (this.isCursorAtStart())
657
- return this.bell();
658
- let s1 = this.value.slice(0, this.cursor - 1);
659
- let s2 = this.value.slice(this.cursor);
660
- this.value = `${s1}${s2}`;
661
- this.red = false;
662
- if (this.isCursorAtStart()) {
663
- this.cursorOffset = 0;
664
- } else {
665
- this.cursorOffset++;
666
- this.moveCursor(-1);
667
- }
668
- this.render();
669
- }
670
- deleteForward() {
671
- if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
672
- return this.bell();
673
- let s1 = this.value.slice(0, this.cursor);
674
- let s2 = this.value.slice(this.cursor + 1);
675
- this.value = `${s1}${s2}`;
676
- this.red = false;
677
- if (this.isCursorAtEnd()) {
678
- this.cursorOffset = 0;
679
- } else {
680
- this.cursorOffset++;
681
- }
682
- this.render();
683
- }
684
- first() {
685
- this.cursor = 0;
686
- this.render();
687
- }
688
- last() {
689
- this.cursor = this.value.length;
690
- this.render();
691
- }
692
- left() {
693
- if (this.cursor <= 0 || this.placeholder)
694
- return this.bell();
695
- this.moveCursor(-1);
696
- this.render();
697
- }
698
- right() {
699
- if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
700
- return this.bell();
701
- this.moveCursor(1);
702
- this.render();
703
- }
704
- isCursorAtStart() {
705
- return this.cursor === 0 || this.placeholder && this.cursor === 1;
706
- }
707
- isCursorAtEnd() {
708
- return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
709
- }
710
- render() {
711
- if (this.closed)
712
- return;
713
- if (!this.firstRender) {
714
- if (this.outputError)
715
- this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
716
- this.out.write(clear(this.outputText, this.out.columns));
717
- }
718
- super.render();
719
- this.outputError = "";
720
- this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.red ? color.red(this.rendered) : this.rendered].join(` `);
721
- if (this.error) {
722
- this.outputError += this.errorMsg.split(`
723
- `).reduce((a, l, i) => a + `
724
- ${i ? " " : figures.pointerSmall} ${color.red().italic(l)}`, ``);
725
- }
726
- this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0));
727
- }
728
- }
729
- module.exports = TextPrompt;
730
- });
731
-
732
- // node_modules/prompts/dist/elements/select.js
733
- var require_select = __commonJS((exports, module) => {
734
- var color = require_kleur();
735
- var Prompt = require_prompt();
736
- var _require = require_util();
737
- var style = _require.style;
738
- var clear = _require.clear;
739
- var figures = _require.figures;
740
- var wrap = _require.wrap;
741
- var entriesToDisplay = _require.entriesToDisplay;
742
- var _require2 = require_src();
743
- var cursor = _require2.cursor;
744
-
745
- class SelectPrompt extends Prompt {
746
- constructor(opts = {}) {
747
- super(opts);
748
- this.msg = opts.message;
749
- this.hint = opts.hint || "- Use arrow-keys. Return to submit.";
750
- this.warn = opts.warn || "- This option is disabled";
751
- this.cursor = opts.initial || 0;
752
- this.choices = opts.choices.map((ch, idx) => {
753
- if (typeof ch === "string")
754
- ch = {
755
- title: ch,
756
- value: idx
757
- };
758
- return {
759
- title: ch && (ch.title || ch.value || ch),
760
- value: ch && (ch.value === undefined ? idx : ch.value),
761
- description: ch && ch.description,
762
- selected: ch && ch.selected,
763
- disabled: ch && ch.disabled
764
- };
765
- });
766
- this.optionsPerPage = opts.optionsPerPage || 10;
767
- this.value = (this.choices[this.cursor] || {}).value;
768
- this.clear = clear("", this.out.columns);
769
- this.render();
770
- }
771
- moveCursor(n) {
772
- this.cursor = n;
773
- this.value = this.choices[n].value;
774
- this.fire();
775
- }
776
- reset() {
777
- this.moveCursor(0);
778
- this.fire();
779
- this.render();
780
- }
781
- exit() {
782
- this.abort();
783
- }
784
- abort() {
785
- this.done = this.aborted = true;
786
- this.fire();
787
- this.render();
788
- this.out.write(`
789
- `);
790
- this.close();
791
- }
792
- submit() {
793
- if (!this.selection.disabled) {
794
- this.done = true;
795
- this.aborted = false;
796
- this.fire();
797
- this.render();
798
- this.out.write(`
799
- `);
800
- this.close();
801
- } else
802
- this.bell();
803
- }
804
- first() {
805
- this.moveCursor(0);
806
- this.render();
807
- }
808
- last() {
809
- this.moveCursor(this.choices.length - 1);
810
- this.render();
811
- }
812
- up() {
813
- if (this.cursor === 0) {
814
- this.moveCursor(this.choices.length - 1);
815
- } else {
816
- this.moveCursor(this.cursor - 1);
817
- }
818
- this.render();
819
- }
820
- down() {
821
- if (this.cursor === this.choices.length - 1) {
822
- this.moveCursor(0);
823
- } else {
824
- this.moveCursor(this.cursor + 1);
825
- }
826
- this.render();
827
- }
828
- next() {
829
- this.moveCursor((this.cursor + 1) % this.choices.length);
830
- this.render();
831
- }
832
- _(c, key) {
833
- if (c === " ")
834
- return this.submit();
835
- }
836
- get selection() {
837
- return this.choices[this.cursor];
838
- }
839
- render() {
840
- if (this.closed)
841
- return;
842
- if (this.firstRender)
843
- this.out.write(cursor.hide);
844
- else
845
- this.out.write(clear(this.outputText, this.out.columns));
846
- super.render();
847
- let _entriesToDisplay = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage), startIndex = _entriesToDisplay.startIndex, endIndex = _entriesToDisplay.endIndex;
848
- this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.done ? this.selection.title : this.selection.disabled ? color.yellow(this.warn) : color.gray(this.hint)].join(" ");
849
- if (!this.done) {
850
- this.outputText += `
851
- `;
852
- for (let i = startIndex;i < endIndex; i++) {
853
- let title, prefix, desc = "", v = this.choices[i];
854
- if (i === startIndex && startIndex > 0) {
855
- prefix = figures.arrowUp;
856
- } else if (i === endIndex - 1 && endIndex < this.choices.length) {
857
- prefix = figures.arrowDown;
858
- } else {
859
- prefix = " ";
860
- }
861
- if (v.disabled) {
862
- title = this.cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
863
- prefix = (this.cursor === i ? color.bold().gray(figures.pointer) + " " : " ") + prefix;
864
- } else {
865
- title = this.cursor === i ? color.cyan().underline(v.title) : v.title;
866
- prefix = (this.cursor === i ? color.cyan(figures.pointer) + " " : " ") + prefix;
867
- if (v.description && this.cursor === i) {
868
- desc = ` - ${v.description}`;
869
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
870
- desc = `
871
- ` + wrap(v.description, {
872
- margin: 3,
873
- width: this.out.columns
874
- });
875
- }
876
- }
877
- }
878
- this.outputText += `${prefix} ${title}${color.gray(desc)}
879
- `;
880
- }
881
- }
882
- this.out.write(this.outputText);
883
- }
884
- }
885
- module.exports = SelectPrompt;
886
- });
887
-
888
- // node_modules/prompts/dist/elements/toggle.js
889
- var require_toggle = __commonJS((exports, module) => {
890
- var color = require_kleur();
891
- var Prompt = require_prompt();
892
- var _require = require_util();
893
- var style = _require.style;
894
- var clear = _require.clear;
895
- var _require2 = require_src();
896
- var cursor = _require2.cursor;
897
- var erase = _require2.erase;
898
-
899
- class TogglePrompt extends Prompt {
900
- constructor(opts = {}) {
901
- super(opts);
902
- this.msg = opts.message;
903
- this.value = !!opts.initial;
904
- this.active = opts.active || "on";
905
- this.inactive = opts.inactive || "off";
906
- this.initialValue = this.value;
907
- this.render();
908
- }
909
- reset() {
910
- this.value = this.initialValue;
911
- this.fire();
912
- this.render();
913
- }
914
- exit() {
915
- this.abort();
916
- }
917
- abort() {
918
- this.done = this.aborted = true;
919
- this.fire();
920
- this.render();
921
- this.out.write(`
922
- `);
923
- this.close();
924
- }
925
- submit() {
926
- this.done = true;
927
- this.aborted = false;
928
- this.fire();
929
- this.render();
930
- this.out.write(`
931
- `);
932
- this.close();
933
- }
934
- deactivate() {
935
- if (this.value === false)
936
- return this.bell();
937
- this.value = false;
938
- this.render();
939
- }
940
- activate() {
941
- if (this.value === true)
942
- return this.bell();
943
- this.value = true;
944
- this.render();
945
- }
946
- delete() {
947
- this.deactivate();
948
- }
949
- left() {
950
- this.deactivate();
951
- }
952
- right() {
953
- this.activate();
954
- }
955
- down() {
956
- this.deactivate();
957
- }
958
- up() {
959
- this.activate();
960
- }
961
- next() {
962
- this.value = !this.value;
963
- this.fire();
964
- this.render();
965
- }
966
- _(c, key) {
967
- if (c === " ") {
968
- this.value = !this.value;
969
- } else if (c === "1") {
970
- this.value = true;
971
- } else if (c === "0") {
972
- this.value = false;
973
- } else
974
- return this.bell();
975
- this.render();
976
- }
977
- render() {
978
- if (this.closed)
979
- return;
980
- if (this.firstRender)
981
- this.out.write(cursor.hide);
982
- else
983
- this.out.write(clear(this.outputText, this.out.columns));
984
- super.render();
985
- this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.value ? this.inactive : color.cyan().underline(this.inactive), color.gray("/"), this.value ? color.cyan().underline(this.active) : this.active].join(" ");
986
- this.out.write(erase.line + cursor.to(0) + this.outputText);
987
- }
988
- }
989
- module.exports = TogglePrompt;
990
- });
991
-
992
- // node_modules/prompts/dist/dateparts/datepart.js
993
- var require_datepart = __commonJS((exports, module) => {
994
- class DatePart {
995
- constructor({
996
- token,
997
- date,
998
- parts,
999
- locales
1000
- }) {
1001
- this.token = token;
1002
- this.date = date || new Date;
1003
- this.parts = parts || [this];
1004
- this.locales = locales || {};
1005
- }
1006
- up() {}
1007
- down() {}
1008
- next() {
1009
- const currentIdx = this.parts.indexOf(this);
1010
- return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
1011
- }
1012
- setTo(val) {}
1013
- prev() {
1014
- let parts = [].concat(this.parts).reverse();
1015
- const currentIdx = parts.indexOf(this);
1016
- return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
1017
- }
1018
- toString() {
1019
- return String(this.date);
1020
- }
1021
- }
1022
- module.exports = DatePart;
1023
- });
1024
-
1025
- // node_modules/prompts/dist/dateparts/meridiem.js
1026
- var require_meridiem = __commonJS((exports, module) => {
1027
- var DatePart = require_datepart();
1028
-
1029
- class Meridiem extends DatePart {
1030
- constructor(opts = {}) {
1031
- super(opts);
1032
- }
1033
- up() {
1034
- this.date.setHours((this.date.getHours() + 12) % 24);
1035
- }
1036
- down() {
1037
- this.up();
1038
- }
1039
- toString() {
1040
- let meridiem = this.date.getHours() > 12 ? "pm" : "am";
1041
- return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
1042
- }
1043
- }
1044
- module.exports = Meridiem;
1045
- });
1046
-
1047
- // node_modules/prompts/dist/dateparts/day.js
1048
- var require_day = __commonJS((exports, module) => {
1049
- var DatePart = require_datepart();
1050
- var pos = (n) => {
1051
- n = n % 10;
1052
- return n === 1 ? "st" : n === 2 ? "nd" : n === 3 ? "rd" : "th";
1053
- };
1054
-
1055
- class Day extends DatePart {
1056
- constructor(opts = {}) {
1057
- super(opts);
1058
- }
1059
- up() {
1060
- this.date.setDate(this.date.getDate() + 1);
1061
- }
1062
- down() {
1063
- this.date.setDate(this.date.getDate() - 1);
1064
- }
1065
- setTo(val) {
1066
- this.date.setDate(parseInt(val.substr(-2)));
1067
- }
1068
- toString() {
1069
- let date = this.date.getDate();
1070
- let day = this.date.getDay();
1071
- 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;
1072
- }
1073
- }
1074
- module.exports = Day;
1075
- });
1076
-
1077
- // node_modules/prompts/dist/dateparts/hours.js
1078
- var require_hours = __commonJS((exports, module) => {
1079
- var DatePart = require_datepart();
1080
-
1081
- class Hours extends DatePart {
1082
- constructor(opts = {}) {
1083
- super(opts);
1084
- }
1085
- up() {
1086
- this.date.setHours(this.date.getHours() + 1);
1087
- }
1088
- down() {
1089
- this.date.setHours(this.date.getHours() - 1);
1090
- }
1091
- setTo(val) {
1092
- this.date.setHours(parseInt(val.substr(-2)));
1093
- }
1094
- toString() {
1095
- let hours = this.date.getHours();
1096
- if (/h/.test(this.token))
1097
- hours = hours % 12 || 12;
1098
- return this.token.length > 1 ? String(hours).padStart(2, "0") : hours;
1099
- }
1100
- }
1101
- module.exports = Hours;
1102
- });
1103
-
1104
- // node_modules/prompts/dist/dateparts/milliseconds.js
1105
- var require_milliseconds = __commonJS((exports, module) => {
1106
- var DatePart = require_datepart();
1107
-
1108
- class Milliseconds extends DatePart {
1109
- constructor(opts = {}) {
1110
- super(opts);
1111
- }
1112
- up() {
1113
- this.date.setMilliseconds(this.date.getMilliseconds() + 1);
1114
- }
1115
- down() {
1116
- this.date.setMilliseconds(this.date.getMilliseconds() - 1);
1117
- }
1118
- setTo(val) {
1119
- this.date.setMilliseconds(parseInt(val.substr(-this.token.length)));
1120
- }
1121
- toString() {
1122
- return String(this.date.getMilliseconds()).padStart(4, "0").substr(0, this.token.length);
1123
- }
1124
- }
1125
- module.exports = Milliseconds;
1126
- });
1127
-
1128
- // node_modules/prompts/dist/dateparts/minutes.js
1129
- var require_minutes = __commonJS((exports, module) => {
1130
- var DatePart = require_datepart();
1131
-
1132
- class Minutes extends DatePart {
1133
- constructor(opts = {}) {
1134
- super(opts);
1135
- }
1136
- up() {
1137
- this.date.setMinutes(this.date.getMinutes() + 1);
1138
- }
1139
- down() {
1140
- this.date.setMinutes(this.date.getMinutes() - 1);
1141
- }
1142
- setTo(val) {
1143
- this.date.setMinutes(parseInt(val.substr(-2)));
1144
- }
1145
- toString() {
1146
- let m = this.date.getMinutes();
1147
- return this.token.length > 1 ? String(m).padStart(2, "0") : m;
1148
- }
1149
- }
1150
- module.exports = Minutes;
1151
- });
1152
-
1153
- // node_modules/prompts/dist/dateparts/month.js
1154
- var require_month = __commonJS((exports, module) => {
1155
- var DatePart = require_datepart();
1156
-
1157
- class Month extends DatePart {
1158
- constructor(opts = {}) {
1159
- super(opts);
1160
- }
1161
- up() {
1162
- this.date.setMonth(this.date.getMonth() + 1);
1163
- }
1164
- down() {
1165
- this.date.setMonth(this.date.getMonth() - 1);
1166
- }
1167
- setTo(val) {
1168
- val = parseInt(val.substr(-2)) - 1;
1169
- this.date.setMonth(val < 0 ? 0 : val);
1170
- }
1171
- toString() {
1172
- let month = this.date.getMonth();
1173
- let tl = this.token.length;
1174
- return tl === 2 ? String(month + 1).padStart(2, "0") : tl === 3 ? this.locales.monthsShort[month] : tl === 4 ? this.locales.months[month] : String(month + 1);
1175
- }
1176
- }
1177
- module.exports = Month;
1178
- });
1179
-
1180
- // node_modules/prompts/dist/dateparts/seconds.js
1181
- var require_seconds = __commonJS((exports, module) => {
1182
- var DatePart = require_datepart();
1183
-
1184
- class Seconds extends DatePart {
1185
- constructor(opts = {}) {
1186
- super(opts);
1187
- }
1188
- up() {
1189
- this.date.setSeconds(this.date.getSeconds() + 1);
1190
- }
1191
- down() {
1192
- this.date.setSeconds(this.date.getSeconds() - 1);
1193
- }
1194
- setTo(val) {
1195
- this.date.setSeconds(parseInt(val.substr(-2)));
1196
- }
1197
- toString() {
1198
- let s = this.date.getSeconds();
1199
- return this.token.length > 1 ? String(s).padStart(2, "0") : s;
1200
- }
1201
- }
1202
- module.exports = Seconds;
1203
- });
1204
-
1205
- // node_modules/prompts/dist/dateparts/year.js
1206
- var require_year = __commonJS((exports, module) => {
1207
- var DatePart = require_datepart();
1208
-
1209
- class Year extends DatePart {
1210
- constructor(opts = {}) {
1211
- super(opts);
1212
- }
1213
- up() {
1214
- this.date.setFullYear(this.date.getFullYear() + 1);
1215
- }
1216
- down() {
1217
- this.date.setFullYear(this.date.getFullYear() - 1);
1218
- }
1219
- setTo(val) {
1220
- this.date.setFullYear(val.substr(-4));
1221
- }
1222
- toString() {
1223
- let year = String(this.date.getFullYear()).padStart(4, "0");
1224
- return this.token.length === 2 ? year.substr(-2) : year;
1225
- }
1226
- }
1227
- module.exports = Year;
1228
- });
1229
-
1230
- // node_modules/prompts/dist/dateparts/index.js
1231
- var require_dateparts = __commonJS((exports, module) => {
1232
- module.exports = {
1233
- DatePart: require_datepart(),
1234
- Meridiem: require_meridiem(),
1235
- Day: require_day(),
1236
- Hours: require_hours(),
1237
- Milliseconds: require_milliseconds(),
1238
- Minutes: require_minutes(),
1239
- Month: require_month(),
1240
- Seconds: require_seconds(),
1241
- Year: require_year()
1242
- };
1243
- });
1244
-
1245
- // node_modules/prompts/dist/elements/date.js
1246
- var require_date = __commonJS((exports, module) => {
1247
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1248
- try {
1249
- var info = gen[key](arg);
1250
- var value = info.value;
1251
- } catch (error) {
1252
- reject(error);
1253
- return;
1254
- }
1255
- if (info.done) {
1256
- resolve(value);
1257
- } else {
1258
- Promise.resolve(value).then(_next, _throw);
1259
- }
1260
- }
1261
- function _asyncToGenerator(fn) {
1262
- return function() {
1263
- var self = this, args = arguments;
1264
- return new Promise(function(resolve, reject) {
1265
- var gen = fn.apply(self, args);
1266
- function _next(value) {
1267
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1268
- }
1269
- function _throw(err) {
1270
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1271
- }
1272
- _next(undefined);
1273
- });
1274
- };
1275
- }
1276
- var color = require_kleur();
1277
- var Prompt = require_prompt();
1278
- var _require = require_util();
1279
- var style = _require.style;
1280
- var clear = _require.clear;
1281
- var figures = _require.figures;
1282
- var _require2 = require_src();
1283
- var erase = _require2.erase;
1284
- var cursor = _require2.cursor;
1285
- var _require3 = require_dateparts();
1286
- var DatePart = _require3.DatePart;
1287
- var Meridiem = _require3.Meridiem;
1288
- var Day = _require3.Day;
1289
- var Hours = _require3.Hours;
1290
- var Milliseconds = _require3.Milliseconds;
1291
- var Minutes = _require3.Minutes;
1292
- var Month = _require3.Month;
1293
- var Seconds = _require3.Seconds;
1294
- var Year = _require3.Year;
1295
- 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;
1296
- var regexGroups = {
1297
- 1: ({
1298
- token
1299
- }) => token.replace(/\\(.)/g, "$1"),
1300
- 2: (opts) => new Day(opts),
1301
- 3: (opts) => new Month(opts),
1302
- 4: (opts) => new Year(opts),
1303
- 5: (opts) => new Meridiem(opts),
1304
- 6: (opts) => new Hours(opts),
1305
- 7: (opts) => new Minutes(opts),
1306
- 8: (opts) => new Seconds(opts),
1307
- 9: (opts) => new Milliseconds(opts)
1308
- };
1309
- var dfltLocales = {
1310
- months: "January,February,March,April,May,June,July,August,September,October,November,December".split(","),
1311
- monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),
1312
- weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
1313
- weekdaysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")
1314
- };
1315
-
1316
- class DatePrompt extends Prompt {
1317
- constructor(opts = {}) {
1318
- super(opts);
1319
- this.msg = opts.message;
1320
- this.cursor = 0;
1321
- this.typed = "";
1322
- this.locales = Object.assign(dfltLocales, opts.locales);
1323
- this._date = opts.initial || new Date;
1324
- this.errorMsg = opts.error || "Please Enter A Valid Value";
1325
- this.validator = opts.validate || (() => true);
1326
- this.mask = opts.mask || "YYYY-MM-DD HH:mm:ss";
1327
- this.clear = clear("", this.out.columns);
1328
- this.render();
1329
- }
1330
- get value() {
1331
- return this.date;
1332
- }
1333
- get date() {
1334
- return this._date;
1335
- }
1336
- set date(date) {
1337
- if (date)
1338
- this._date.setTime(date.getTime());
1339
- }
1340
- set mask(mask) {
1341
- let result;
1342
- this.parts = [];
1343
- while (result = regex.exec(mask)) {
1344
- let match = result.shift();
1345
- let idx = result.findIndex((gr) => gr != null);
1346
- this.parts.push(idx in regexGroups ? regexGroups[idx]({
1347
- token: result[idx] || match,
1348
- date: this.date,
1349
- parts: this.parts,
1350
- locales: this.locales
1351
- }) : result[idx] || match);
1352
- }
1353
- let parts = this.parts.reduce((arr, i) => {
1354
- if (typeof i === "string" && typeof arr[arr.length - 1] === "string")
1355
- arr[arr.length - 1] += i;
1356
- else
1357
- arr.push(i);
1358
- return arr;
1359
- }, []);
1360
- this.parts.splice(0);
1361
- this.parts.push(...parts);
1362
- this.reset();
1363
- }
1364
- moveCursor(n) {
1365
- this.typed = "";
1366
- this.cursor = n;
1367
- this.fire();
1368
- }
1369
- reset() {
1370
- this.moveCursor(this.parts.findIndex((p) => p instanceof DatePart));
1371
- this.fire();
1372
- this.render();
1373
- }
1374
- exit() {
1375
- this.abort();
1376
- }
1377
- abort() {
1378
- this.done = this.aborted = true;
1379
- this.error = false;
1380
- this.fire();
1381
- this.render();
1382
- this.out.write(`
1383
- `);
1384
- this.close();
1385
- }
1386
- validate() {
1387
- var _this = this;
1388
- return _asyncToGenerator(function* () {
1389
- let valid = yield _this.validator(_this.value);
1390
- if (typeof valid === "string") {
1391
- _this.errorMsg = valid;
1392
- valid = false;
1393
- }
1394
- _this.error = !valid;
1395
- })();
1396
- }
1397
- submit() {
1398
- var _this2 = this;
1399
- return _asyncToGenerator(function* () {
1400
- yield _this2.validate();
1401
- if (_this2.error) {
1402
- _this2.color = "red";
1403
- _this2.fire();
1404
- _this2.render();
1405
- return;
1406
- }
1407
- _this2.done = true;
1408
- _this2.aborted = false;
1409
- _this2.fire();
1410
- _this2.render();
1411
- _this2.out.write(`
1412
- `);
1413
- _this2.close();
1414
- })();
1415
- }
1416
- up() {
1417
- this.typed = "";
1418
- this.parts[this.cursor].up();
1419
- this.render();
1420
- }
1421
- down() {
1422
- this.typed = "";
1423
- this.parts[this.cursor].down();
1424
- this.render();
1425
- }
1426
- left() {
1427
- let prev = this.parts[this.cursor].prev();
1428
- if (prev == null)
1429
- return this.bell();
1430
- this.moveCursor(this.parts.indexOf(prev));
1431
- this.render();
1432
- }
1433
- right() {
1434
- let next = this.parts[this.cursor].next();
1435
- if (next == null)
1436
- return this.bell();
1437
- this.moveCursor(this.parts.indexOf(next));
1438
- this.render();
1439
- }
1440
- next() {
1441
- let next = this.parts[this.cursor].next();
1442
- this.moveCursor(next ? this.parts.indexOf(next) : this.parts.findIndex((part) => part instanceof DatePart));
1443
- this.render();
1444
- }
1445
- _(c) {
1446
- if (/\d/.test(c)) {
1447
- this.typed += c;
1448
- this.parts[this.cursor].setTo(this.typed);
1449
- this.render();
1450
- }
1451
- }
1452
- render() {
1453
- if (this.closed)
1454
- return;
1455
- if (this.firstRender)
1456
- this.out.write(cursor.hide);
1457
- else
1458
- this.out.write(clear(this.outputText, this.out.columns));
1459
- super.render();
1460
- this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []).join("")].join(" ");
1461
- if (this.error) {
1462
- this.outputText += this.errorMsg.split(`
1463
- `).reduce((a, l, i) => a + `
1464
- ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
1465
- }
1466
- this.out.write(erase.line + cursor.to(0) + this.outputText);
1467
- }
1468
- }
1469
- module.exports = DatePrompt;
1470
- });
1471
-
1472
- // node_modules/prompts/dist/elements/number.js
1473
- var require_number = __commonJS((exports, module) => {
1474
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1475
- try {
1476
- var info = gen[key](arg);
1477
- var value = info.value;
1478
- } catch (error) {
1479
- reject(error);
1480
- return;
1481
- }
1482
- if (info.done) {
1483
- resolve(value);
1484
- } else {
1485
- Promise.resolve(value).then(_next, _throw);
1486
- }
1487
- }
1488
- function _asyncToGenerator(fn) {
1489
- return function() {
1490
- var self = this, args = arguments;
1491
- return new Promise(function(resolve, reject) {
1492
- var gen = fn.apply(self, args);
1493
- function _next(value) {
1494
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1495
- }
1496
- function _throw(err) {
1497
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1498
- }
1499
- _next(undefined);
1500
- });
1501
- };
1502
- }
1503
- var color = require_kleur();
1504
- var Prompt = require_prompt();
1505
- var _require = require_src();
1506
- var cursor = _require.cursor;
1507
- var erase = _require.erase;
1508
- var _require2 = require_util();
1509
- var style = _require2.style;
1510
- var figures = _require2.figures;
1511
- var clear = _require2.clear;
1512
- var lines = _require2.lines;
1513
- var isNumber = /[0-9]/;
1514
- var isDef = (any) => any !== undefined;
1515
- var round = (number, precision) => {
1516
- let factor = Math.pow(10, precision);
1517
- return Math.round(number * factor) / factor;
1518
- };
1519
-
1520
- class NumberPrompt extends Prompt {
1521
- constructor(opts = {}) {
1522
- super(opts);
1523
- this.transform = style.render(opts.style);
1524
- this.msg = opts.message;
1525
- this.initial = isDef(opts.initial) ? opts.initial : "";
1526
- this.float = !!opts.float;
1527
- this.round = opts.round || 2;
1528
- this.inc = opts.increment || 1;
1529
- this.min = isDef(opts.min) ? opts.min : -Infinity;
1530
- this.max = isDef(opts.max) ? opts.max : Infinity;
1531
- this.errorMsg = opts.error || `Please Enter A Valid Value`;
1532
- this.validator = opts.validate || (() => true);
1533
- this.color = `cyan`;
1534
- this.value = ``;
1535
- this.typed = ``;
1536
- this.lastHit = 0;
1537
- this.render();
1538
- }
1539
- set value(v) {
1540
- if (!v && v !== 0) {
1541
- this.placeholder = true;
1542
- this.rendered = color.gray(this.transform.render(`${this.initial}`));
1543
- this._value = ``;
1544
- } else {
1545
- this.placeholder = false;
1546
- this.rendered = this.transform.render(`${round(v, this.round)}`);
1547
- this._value = round(v, this.round);
1548
- }
1549
- this.fire();
1550
- }
1551
- get value() {
1552
- return this._value;
1553
- }
1554
- parse(x) {
1555
- return this.float ? parseFloat(x) : parseInt(x);
1556
- }
1557
- valid(c) {
1558
- return c === `-` || c === `.` && this.float || isNumber.test(c);
1559
- }
1560
- reset() {
1561
- this.typed = ``;
1562
- this.value = ``;
1563
- this.fire();
1564
- this.render();
1565
- }
1566
- exit() {
1567
- this.abort();
1568
- }
1569
- abort() {
1570
- let x = this.value;
1571
- this.value = x !== `` ? x : this.initial;
1572
- this.done = this.aborted = true;
1573
- this.error = false;
1574
- this.fire();
1575
- this.render();
1576
- this.out.write(`
1577
- `);
1578
- this.close();
1579
- }
1580
- validate() {
1581
- var _this = this;
1582
- return _asyncToGenerator(function* () {
1583
- let valid = yield _this.validator(_this.value);
1584
- if (typeof valid === `string`) {
1585
- _this.errorMsg = valid;
1586
- valid = false;
1587
- }
1588
- _this.error = !valid;
1589
- })();
1590
- }
1591
- submit() {
1592
- var _this2 = this;
1593
- return _asyncToGenerator(function* () {
1594
- yield _this2.validate();
1595
- if (_this2.error) {
1596
- _this2.color = `red`;
1597
- _this2.fire();
1598
- _this2.render();
1599
- return;
1600
- }
1601
- let x = _this2.value;
1602
- _this2.value = x !== `` ? x : _this2.initial;
1603
- _this2.done = true;
1604
- _this2.aborted = false;
1605
- _this2.error = false;
1606
- _this2.fire();
1607
- _this2.render();
1608
- _this2.out.write(`
1609
- `);
1610
- _this2.close();
1611
- })();
1612
- }
1613
- up() {
1614
- this.typed = ``;
1615
- if (this.value === "") {
1616
- this.value = this.min - this.inc;
1617
- }
1618
- if (this.value >= this.max)
1619
- return this.bell();
1620
- this.value += this.inc;
1621
- this.color = `cyan`;
1622
- this.fire();
1623
- this.render();
1624
- }
1625
- down() {
1626
- this.typed = ``;
1627
- if (this.value === "") {
1628
- this.value = this.min + this.inc;
1629
- }
1630
- if (this.value <= this.min)
1631
- return this.bell();
1632
- this.value -= this.inc;
1633
- this.color = `cyan`;
1634
- this.fire();
1635
- this.render();
1636
- }
1637
- delete() {
1638
- let val = this.value.toString();
1639
- if (val.length === 0)
1640
- return this.bell();
1641
- this.value = this.parse(val = val.slice(0, -1)) || ``;
1642
- if (this.value !== "" && this.value < this.min) {
1643
- this.value = this.min;
1644
- }
1645
- this.color = `cyan`;
1646
- this.fire();
1647
- this.render();
1648
- }
1649
- next() {
1650
- this.value = this.initial;
1651
- this.fire();
1652
- this.render();
1653
- }
1654
- _(c, key) {
1655
- if (!this.valid(c))
1656
- return this.bell();
1657
- const now = Date.now();
1658
- if (now - this.lastHit > 1000)
1659
- this.typed = ``;
1660
- this.typed += c;
1661
- this.lastHit = now;
1662
- this.color = `cyan`;
1663
- if (c === `.`)
1664
- return this.fire();
1665
- this.value = Math.min(this.parse(this.typed), this.max);
1666
- if (this.value > this.max)
1667
- this.value = this.max;
1668
- if (this.value < this.min)
1669
- this.value = this.min;
1670
- this.fire();
1671
- this.render();
1672
- }
1673
- render() {
1674
- if (this.closed)
1675
- return;
1676
- if (!this.firstRender) {
1677
- if (this.outputError)
1678
- this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
1679
- this.out.write(clear(this.outputText, this.out.columns));
1680
- }
1681
- super.render();
1682
- this.outputError = "";
1683
- this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), !this.done || !this.done && !this.placeholder ? color[this.color]().underline(this.rendered) : this.rendered].join(` `);
1684
- if (this.error) {
1685
- this.outputError += this.errorMsg.split(`
1686
- `).reduce((a, l, i) => a + `
1687
- ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
1688
- }
1689
- this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
1690
- }
1691
- }
1692
- module.exports = NumberPrompt;
1693
- });
1694
-
1695
- // node_modules/prompts/dist/elements/multiselect.js
1696
- var require_multiselect = __commonJS((exports, module) => {
1697
- var color = require_kleur();
1698
- var _require = require_src();
1699
- var cursor = _require.cursor;
1700
- var Prompt = require_prompt();
1701
- var _require2 = require_util();
1702
- var clear = _require2.clear;
1703
- var figures = _require2.figures;
1704
- var style = _require2.style;
1705
- var wrap = _require2.wrap;
1706
- var entriesToDisplay = _require2.entriesToDisplay;
1707
-
1708
- class MultiselectPrompt extends Prompt {
1709
- constructor(opts = {}) {
1710
- super(opts);
1711
- this.msg = opts.message;
1712
- this.cursor = opts.cursor || 0;
1713
- this.scrollIndex = opts.cursor || 0;
1714
- this.hint = opts.hint || "";
1715
- this.warn = opts.warn || "- This option is disabled -";
1716
- this.minSelected = opts.min;
1717
- this.showMinError = false;
1718
- this.maxChoices = opts.max;
1719
- this.instructions = opts.instructions;
1720
- this.optionsPerPage = opts.optionsPerPage || 10;
1721
- this.value = opts.choices.map((ch, idx) => {
1722
- if (typeof ch === "string")
1723
- ch = {
1724
- title: ch,
1725
- value: idx
1726
- };
1727
- return {
1728
- title: ch && (ch.title || ch.value || ch),
1729
- description: ch && ch.description,
1730
- value: ch && (ch.value === undefined ? idx : ch.value),
1731
- selected: ch && ch.selected,
1732
- disabled: ch && ch.disabled
1733
- };
1734
- });
1735
- this.clear = clear("", this.out.columns);
1736
- if (!opts.overrideRender) {
1737
- this.render();
1738
- }
1739
- }
1740
- reset() {
1741
- this.value.map((v) => !v.selected);
1742
- this.cursor = 0;
1743
- this.fire();
1744
- this.render();
1745
- }
1746
- selected() {
1747
- return this.value.filter((v) => v.selected);
1748
- }
1749
- exit() {
1750
- this.abort();
1751
- }
1752
- abort() {
1753
- this.done = this.aborted = true;
1754
- this.fire();
1755
- this.render();
1756
- this.out.write(`
1757
- `);
1758
- this.close();
1759
- }
1760
- submit() {
1761
- const selected = this.value.filter((e) => e.selected);
1762
- if (this.minSelected && selected.length < this.minSelected) {
1763
- this.showMinError = true;
1764
- this.render();
1765
- } else {
1766
- this.done = true;
1767
- this.aborted = false;
1768
- this.fire();
1769
- this.render();
1770
- this.out.write(`
1771
- `);
1772
- this.close();
1773
- }
1774
- }
1775
- first() {
1776
- this.cursor = 0;
1777
- this.render();
1778
- }
1779
- last() {
1780
- this.cursor = this.value.length - 1;
1781
- this.render();
1782
- }
1783
- next() {
1784
- this.cursor = (this.cursor + 1) % this.value.length;
1785
- this.render();
1786
- }
1787
- up() {
1788
- if (this.cursor === 0) {
1789
- this.cursor = this.value.length - 1;
1790
- } else {
1791
- this.cursor--;
1792
- }
1793
- this.render();
1794
- }
1795
- down() {
1796
- if (this.cursor === this.value.length - 1) {
1797
- this.cursor = 0;
1798
- } else {
1799
- this.cursor++;
1800
- }
1801
- this.render();
1802
- }
1803
- left() {
1804
- this.value[this.cursor].selected = false;
1805
- this.render();
1806
- }
1807
- right() {
1808
- if (this.value.filter((e) => e.selected).length >= this.maxChoices)
1809
- return this.bell();
1810
- this.value[this.cursor].selected = true;
1811
- this.render();
1812
- }
1813
- handleSpaceToggle() {
1814
- const v = this.value[this.cursor];
1815
- if (v.selected) {
1816
- v.selected = false;
1817
- this.render();
1818
- } else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
1819
- return this.bell();
1820
- } else {
1821
- v.selected = true;
1822
- this.render();
1823
- }
1824
- }
1825
- toggleAll() {
1826
- if (this.maxChoices !== undefined || this.value[this.cursor].disabled) {
1827
- return this.bell();
1828
- }
1829
- const newSelected = !this.value[this.cursor].selected;
1830
- this.value.filter((v) => !v.disabled).forEach((v) => v.selected = newSelected);
1831
- this.render();
1832
- }
1833
- _(c, key) {
1834
- if (c === " ") {
1835
- this.handleSpaceToggle();
1836
- } else if (c === "a") {
1837
- this.toggleAll();
1838
- } else {
1839
- return this.bell();
1840
- }
1841
- }
1842
- renderInstructions() {
1843
- if (this.instructions === undefined || this.instructions) {
1844
- if (typeof this.instructions === "string") {
1845
- return this.instructions;
1846
- }
1847
- return `
1848
- Instructions:
1849
- ` + ` ${figures.arrowUp}/${figures.arrowDown}: Highlight option
1850
- ` + ` ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
1851
- ` + (this.maxChoices === undefined ? ` a: Toggle all
1852
- ` : "") + ` enter/return: Complete answer`;
1853
- }
1854
- return "";
1855
- }
1856
- renderOption(cursor2, v, i, arrowIndicator) {
1857
- const prefix = (v.selected ? color.green(figures.radioOn) : figures.radioOff) + " " + arrowIndicator + " ";
1858
- let title, desc;
1859
- if (v.disabled) {
1860
- title = cursor2 === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
1861
- } else {
1862
- title = cursor2 === i ? color.cyan().underline(v.title) : v.title;
1863
- if (cursor2 === i && v.description) {
1864
- desc = ` - ${v.description}`;
1865
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
1866
- desc = `
1867
- ` + wrap(v.description, {
1868
- margin: prefix.length,
1869
- width: this.out.columns
1870
- });
1871
- }
1872
- }
1873
- }
1874
- return prefix + title + color.gray(desc || "");
1875
- }
1876
- paginateOptions(options) {
1877
- if (options.length === 0) {
1878
- return color.red("No matches for this query.");
1879
- }
1880
- let _entriesToDisplay = entriesToDisplay(this.cursor, options.length, this.optionsPerPage), startIndex = _entriesToDisplay.startIndex, endIndex = _entriesToDisplay.endIndex;
1881
- let prefix, styledOptions = [];
1882
- for (let i = startIndex;i < endIndex; i++) {
1883
- if (i === startIndex && startIndex > 0) {
1884
- prefix = figures.arrowUp;
1885
- } else if (i === endIndex - 1 && endIndex < options.length) {
1886
- prefix = figures.arrowDown;
1887
- } else {
1888
- prefix = " ";
1889
- }
1890
- styledOptions.push(this.renderOption(this.cursor, options[i], i, prefix));
1891
- }
1892
- return `
1893
- ` + styledOptions.join(`
1894
- `);
1895
- }
1896
- renderOptions(options) {
1897
- if (!this.done) {
1898
- return this.paginateOptions(options);
1899
- }
1900
- return "";
1901
- }
1902
- renderDoneOrInstructions() {
1903
- if (this.done) {
1904
- return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
1905
- }
1906
- const output = [color.gray(this.hint), this.renderInstructions()];
1907
- if (this.value[this.cursor].disabled) {
1908
- output.push(color.yellow(this.warn));
1909
- }
1910
- return output.join(" ");
1911
- }
1912
- render() {
1913
- if (this.closed)
1914
- return;
1915
- if (this.firstRender)
1916
- this.out.write(cursor.hide);
1917
- super.render();
1918
- let prompt = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.renderDoneOrInstructions()].join(" ");
1919
- if (this.showMinError) {
1920
- prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
1921
- this.showMinError = false;
1922
- }
1923
- prompt += this.renderOptions(this.value);
1924
- this.out.write(this.clear + prompt);
1925
- this.clear = clear(prompt, this.out.columns);
1926
- }
1927
- }
1928
- module.exports = MultiselectPrompt;
1929
- });
1930
-
1931
- // node_modules/prompts/dist/elements/autocomplete.js
1932
- var require_autocomplete = __commonJS((exports, module) => {
1933
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1934
- try {
1935
- var info = gen[key](arg);
1936
- var value = info.value;
1937
- } catch (error) {
1938
- reject(error);
1939
- return;
1940
- }
1941
- if (info.done) {
1942
- resolve(value);
1943
- } else {
1944
- Promise.resolve(value).then(_next, _throw);
1945
- }
1946
- }
1947
- function _asyncToGenerator(fn) {
1948
- return function() {
1949
- var self = this, args = arguments;
1950
- return new Promise(function(resolve, reject) {
1951
- var gen = fn.apply(self, args);
1952
- function _next(value) {
1953
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1954
- }
1955
- function _throw(err) {
1956
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1957
- }
1958
- _next(undefined);
1959
- });
1960
- };
1961
- }
1962
- var color = require_kleur();
1963
- var Prompt = require_prompt();
1964
- var _require = require_src();
1965
- var erase = _require.erase;
1966
- var cursor = _require.cursor;
1967
- var _require2 = require_util();
1968
- var style = _require2.style;
1969
- var clear = _require2.clear;
1970
- var figures = _require2.figures;
1971
- var wrap = _require2.wrap;
1972
- var entriesToDisplay = _require2.entriesToDisplay;
1973
- var getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
1974
- var getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
1975
- var getIndex = (arr, valOrTitle) => {
1976
- const index = arr.findIndex((el) => el.value === valOrTitle || el.title === valOrTitle);
1977
- return index > -1 ? index : undefined;
1978
- };
1979
-
1980
- class AutocompletePrompt extends Prompt {
1981
- constructor(opts = {}) {
1982
- super(opts);
1983
- this.msg = opts.message;
1984
- this.suggest = opts.suggest;
1985
- this.choices = opts.choices;
1986
- this.initial = typeof opts.initial === "number" ? opts.initial : getIndex(opts.choices, opts.initial);
1987
- this.select = this.initial || opts.cursor || 0;
1988
- this.i18n = {
1989
- noMatches: opts.noMatches || "no matches found"
1990
- };
1991
- this.fallback = opts.fallback || this.initial;
1992
- this.clearFirst = opts.clearFirst || false;
1993
- this.suggestions = [];
1994
- this.input = "";
1995
- this.limit = opts.limit || 10;
1996
- this.cursor = 0;
1997
- this.transform = style.render(opts.style);
1998
- this.scale = this.transform.scale;
1999
- this.render = this.render.bind(this);
2000
- this.complete = this.complete.bind(this);
2001
- this.clear = clear("", this.out.columns);
2002
- this.complete(this.render);
2003
- this.render();
2004
- }
2005
- set fallback(fb) {
2006
- this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
2007
- }
2008
- get fallback() {
2009
- let choice;
2010
- if (typeof this._fb === "number")
2011
- choice = this.choices[this._fb];
2012
- else if (typeof this._fb === "string")
2013
- choice = {
2014
- title: this._fb
2015
- };
2016
- return choice || this._fb || {
2017
- title: this.i18n.noMatches
2018
- };
2019
- }
2020
- moveSelect(i) {
2021
- this.select = i;
2022
- if (this.suggestions.length > 0)
2023
- this.value = getVal(this.suggestions, i);
2024
- else
2025
- this.value = this.fallback.value;
2026
- this.fire();
2027
- }
2028
- complete(cb) {
2029
- var _this = this;
2030
- return _asyncToGenerator(function* () {
2031
- const p = _this.completing = _this.suggest(_this.input, _this.choices);
2032
- const suggestions = yield p;
2033
- if (_this.completing !== p)
2034
- return;
2035
- _this.suggestions = suggestions.map((s, i, arr) => ({
2036
- title: getTitle(arr, i),
2037
- value: getVal(arr, i),
2038
- description: s.description
2039
- }));
2040
- _this.completing = false;
2041
- const l = Math.max(suggestions.length - 1, 0);
2042
- _this.moveSelect(Math.min(l, _this.select));
2043
- cb && cb();
2044
- })();
2045
- }
2046
- reset() {
2047
- this.input = "";
2048
- this.complete(() => {
2049
- this.moveSelect(this.initial !== undefined ? this.initial : 0);
2050
- this.render();
2051
- });
2052
- this.render();
2053
- }
2054
- exit() {
2055
- if (this.clearFirst && this.input.length > 0) {
2056
- this.reset();
2057
- } else {
2058
- this.done = this.exited = true;
2059
- this.aborted = false;
2060
- this.fire();
2061
- this.render();
2062
- this.out.write(`
2063
- `);
2064
- this.close();
2065
- }
2066
- }
2067
- abort() {
2068
- this.done = this.aborted = true;
2069
- this.exited = false;
2070
- this.fire();
2071
- this.render();
2072
- this.out.write(`
2073
- `);
2074
- this.close();
2075
- }
2076
- submit() {
2077
- this.done = true;
2078
- this.aborted = this.exited = false;
2079
- this.fire();
2080
- this.render();
2081
- this.out.write(`
2082
- `);
2083
- this.close();
2084
- }
2085
- _(c, key) {
2086
- let s1 = this.input.slice(0, this.cursor);
2087
- let s2 = this.input.slice(this.cursor);
2088
- this.input = `${s1}${c}${s2}`;
2089
- this.cursor = s1.length + 1;
2090
- this.complete(this.render);
2091
- this.render();
2092
- }
2093
- delete() {
2094
- if (this.cursor === 0)
2095
- return this.bell();
2096
- let s1 = this.input.slice(0, this.cursor - 1);
2097
- let s2 = this.input.slice(this.cursor);
2098
- this.input = `${s1}${s2}`;
2099
- this.complete(this.render);
2100
- this.cursor = this.cursor - 1;
2101
- this.render();
2102
- }
2103
- deleteForward() {
2104
- if (this.cursor * this.scale >= this.rendered.length)
2105
- return this.bell();
2106
- let s1 = this.input.slice(0, this.cursor);
2107
- let s2 = this.input.slice(this.cursor + 1);
2108
- this.input = `${s1}${s2}`;
2109
- this.complete(this.render);
2110
- this.render();
2111
- }
2112
- first() {
2113
- this.moveSelect(0);
2114
- this.render();
2115
- }
2116
- last() {
2117
- this.moveSelect(this.suggestions.length - 1);
2118
- this.render();
2119
- }
2120
- up() {
2121
- if (this.select === 0) {
2122
- this.moveSelect(this.suggestions.length - 1);
2123
- } else {
2124
- this.moveSelect(this.select - 1);
2125
- }
2126
- this.render();
2127
- }
2128
- down() {
2129
- if (this.select === this.suggestions.length - 1) {
2130
- this.moveSelect(0);
2131
- } else {
2132
- this.moveSelect(this.select + 1);
2133
- }
2134
- this.render();
2135
- }
2136
- next() {
2137
- if (this.select === this.suggestions.length - 1) {
2138
- this.moveSelect(0);
2139
- } else
2140
- this.moveSelect(this.select + 1);
2141
- this.render();
2142
- }
2143
- nextPage() {
2144
- this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
2145
- this.render();
2146
- }
2147
- prevPage() {
2148
- this.moveSelect(Math.max(this.select - this.limit, 0));
2149
- this.render();
2150
- }
2151
- left() {
2152
- if (this.cursor <= 0)
2153
- return this.bell();
2154
- this.cursor = this.cursor - 1;
2155
- this.render();
2156
- }
2157
- right() {
2158
- if (this.cursor * this.scale >= this.rendered.length)
2159
- return this.bell();
2160
- this.cursor = this.cursor + 1;
2161
- this.render();
2162
- }
2163
- renderOption(v, hovered, isStart, isEnd) {
2164
- let desc;
2165
- let prefix = isStart ? figures.arrowUp : isEnd ? figures.arrowDown : " ";
2166
- let title = hovered ? color.cyan().underline(v.title) : v.title;
2167
- prefix = (hovered ? color.cyan(figures.pointer) + " " : " ") + prefix;
2168
- if (v.description) {
2169
- desc = ` - ${v.description}`;
2170
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
2171
- desc = `
2172
- ` + wrap(v.description, {
2173
- margin: 3,
2174
- width: this.out.columns
2175
- });
2176
- }
2177
- }
2178
- return prefix + " " + title + color.gray(desc || "");
2179
- }
2180
- render() {
2181
- if (this.closed)
2182
- return;
2183
- if (this.firstRender)
2184
- this.out.write(cursor.hide);
2185
- else
2186
- this.out.write(clear(this.outputText, this.out.columns));
2187
- super.render();
2188
- let _entriesToDisplay = entriesToDisplay(this.select, this.choices.length, this.limit), startIndex = _entriesToDisplay.startIndex, endIndex = _entriesToDisplay.endIndex;
2189
- this.outputText = [style.symbol(this.done, this.aborted, this.exited), color.bold(this.msg), style.delimiter(this.completing), this.done && this.suggestions[this.select] ? this.suggestions[this.select].title : this.rendered = this.transform.render(this.input)].join(" ");
2190
- if (!this.done) {
2191
- const suggestions = this.suggestions.slice(startIndex, endIndex).map((item, i) => this.renderOption(item, this.select === i + startIndex, i === 0 && startIndex > 0, i + startIndex === endIndex - 1 && endIndex < this.choices.length)).join(`
2192
- `);
2193
- this.outputText += `
2194
- ` + (suggestions || color.gray(this.fallback.title));
2195
- }
2196
- this.out.write(erase.line + cursor.to(0) + this.outputText);
2197
- }
2198
- }
2199
- module.exports = AutocompletePrompt;
2200
- });
2201
-
2202
- // node_modules/prompts/dist/elements/autocompleteMultiselect.js
2203
- var require_autocompleteMultiselect = __commonJS((exports, module) => {
2204
- var color = require_kleur();
2205
- var _require = require_src();
2206
- var cursor = _require.cursor;
2207
- var MultiselectPrompt = require_multiselect();
2208
- var _require2 = require_util();
2209
- var clear = _require2.clear;
2210
- var style = _require2.style;
2211
- var figures = _require2.figures;
2212
-
2213
- class AutocompleteMultiselectPrompt extends MultiselectPrompt {
2214
- constructor(opts = {}) {
2215
- opts.overrideRender = true;
2216
- super(opts);
2217
- this.inputValue = "";
2218
- this.clear = clear("", this.out.columns);
2219
- this.filteredOptions = this.value;
2220
- this.render();
2221
- }
2222
- last() {
2223
- this.cursor = this.filteredOptions.length - 1;
2224
- this.render();
2225
- }
2226
- next() {
2227
- this.cursor = (this.cursor + 1) % this.filteredOptions.length;
2228
- this.render();
2229
- }
2230
- up() {
2231
- if (this.cursor === 0) {
2232
- this.cursor = this.filteredOptions.length - 1;
2233
- } else {
2234
- this.cursor--;
2235
- }
2236
- this.render();
2237
- }
2238
- down() {
2239
- if (this.cursor === this.filteredOptions.length - 1) {
2240
- this.cursor = 0;
2241
- } else {
2242
- this.cursor++;
2243
- }
2244
- this.render();
2245
- }
2246
- left() {
2247
- this.filteredOptions[this.cursor].selected = false;
2248
- this.render();
2249
- }
2250
- right() {
2251
- if (this.value.filter((e) => e.selected).length >= this.maxChoices)
2252
- return this.bell();
2253
- this.filteredOptions[this.cursor].selected = true;
2254
- this.render();
2255
- }
2256
- delete() {
2257
- if (this.inputValue.length) {
2258
- this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
2259
- this.updateFilteredOptions();
2260
- }
2261
- }
2262
- updateFilteredOptions() {
2263
- const currentHighlight = this.filteredOptions[this.cursor];
2264
- this.filteredOptions = this.value.filter((v) => {
2265
- if (this.inputValue) {
2266
- if (typeof v.title === "string") {
2267
- if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
2268
- return true;
2269
- }
2270
- }
2271
- if (typeof v.value === "string") {
2272
- if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
2273
- return true;
2274
- }
2275
- }
2276
- return false;
2277
- }
2278
- return true;
2279
- });
2280
- const newHighlightIndex = this.filteredOptions.findIndex((v) => v === currentHighlight);
2281
- this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
2282
- this.render();
2283
- }
2284
- handleSpaceToggle() {
2285
- const v = this.filteredOptions[this.cursor];
2286
- if (v.selected) {
2287
- v.selected = false;
2288
- this.render();
2289
- } else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
2290
- return this.bell();
2291
- } else {
2292
- v.selected = true;
2293
- this.render();
2294
- }
2295
- }
2296
- handleInputChange(c) {
2297
- this.inputValue = this.inputValue + c;
2298
- this.updateFilteredOptions();
2299
- }
2300
- _(c, key) {
2301
- if (c === " ") {
2302
- this.handleSpaceToggle();
2303
- } else {
2304
- this.handleInputChange(c);
2305
- }
2306
- }
2307
- renderInstructions() {
2308
- if (this.instructions === undefined || this.instructions) {
2309
- if (typeof this.instructions === "string") {
2310
- return this.instructions;
2311
- }
2312
- return `
2313
- Instructions:
2314
- ${figures.arrowUp}/${figures.arrowDown}: Highlight option
2315
- ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
2316
- [a,b,c]/delete: Filter choices
2317
- enter/return: Complete answer
2318
- `;
2319
- }
2320
- return "";
2321
- }
2322
- renderCurrentInput() {
2323
- return `
2324
- Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter something to filter")}
2325
- `;
2326
- }
2327
- renderOption(cursor2, v, i) {
2328
- let title;
2329
- if (v.disabled)
2330
- title = cursor2 === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
2331
- else
2332
- title = cursor2 === i ? color.cyan().underline(v.title) : v.title;
2333
- return (v.selected ? color.green(figures.radioOn) : figures.radioOff) + " " + title;
2334
- }
2335
- renderDoneOrInstructions() {
2336
- if (this.done) {
2337
- return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
2338
- }
2339
- const output = [color.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
2340
- if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
2341
- output.push(color.yellow(this.warn));
2342
- }
2343
- return output.join(" ");
2344
- }
2345
- render() {
2346
- if (this.closed)
2347
- return;
2348
- if (this.firstRender)
2349
- this.out.write(cursor.hide);
2350
- super.render();
2351
- let prompt = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.renderDoneOrInstructions()].join(" ");
2352
- if (this.showMinError) {
2353
- prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
2354
- this.showMinError = false;
2355
- }
2356
- prompt += this.renderOptions(this.filteredOptions);
2357
- this.out.write(this.clear + prompt);
2358
- this.clear = clear(prompt, this.out.columns);
2359
- }
2360
- }
2361
- module.exports = AutocompleteMultiselectPrompt;
2362
- });
2363
-
2364
- // node_modules/prompts/dist/elements/confirm.js
2365
- var require_confirm = __commonJS((exports, module) => {
2366
- var color = require_kleur();
2367
- var Prompt = require_prompt();
2368
- var _require = require_util();
2369
- var style = _require.style;
2370
- var clear = _require.clear;
2371
- var _require2 = require_src();
2372
- var erase = _require2.erase;
2373
- var cursor = _require2.cursor;
2374
-
2375
- class ConfirmPrompt extends Prompt {
2376
- constructor(opts = {}) {
2377
- super(opts);
2378
- this.msg = opts.message;
2379
- this.value = opts.initial;
2380
- this.initialValue = !!opts.initial;
2381
- this.yesMsg = opts.yes || "yes";
2382
- this.yesOption = opts.yesOption || "(Y/n)";
2383
- this.noMsg = opts.no || "no";
2384
- this.noOption = opts.noOption || "(y/N)";
2385
- this.render();
2386
- }
2387
- reset() {
2388
- this.value = this.initialValue;
2389
- this.fire();
2390
- this.render();
2391
- }
2392
- exit() {
2393
- this.abort();
2394
- }
2395
- abort() {
2396
- this.done = this.aborted = true;
2397
- this.fire();
2398
- this.render();
2399
- this.out.write(`
2400
- `);
2401
- this.close();
2402
- }
2403
- submit() {
2404
- this.value = this.value || false;
2405
- this.done = true;
2406
- this.aborted = false;
2407
- this.fire();
2408
- this.render();
2409
- this.out.write(`
2410
- `);
2411
- this.close();
2412
- }
2413
- _(c, key) {
2414
- if (c.toLowerCase() === "y") {
2415
- this.value = true;
2416
- return this.submit();
2417
- }
2418
- if (c.toLowerCase() === "n") {
2419
- this.value = false;
2420
- return this.submit();
2421
- }
2422
- return this.bell();
2423
- }
2424
- render() {
2425
- if (this.closed)
2426
- return;
2427
- if (this.firstRender)
2428
- this.out.write(cursor.hide);
2429
- else
2430
- this.out.write(clear(this.outputText, this.out.columns));
2431
- super.render();
2432
- this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.done ? this.value ? this.yesMsg : this.noMsg : color.gray(this.initialValue ? this.yesOption : this.noOption)].join(" ");
2433
- this.out.write(erase.line + cursor.to(0) + this.outputText);
2434
- }
2435
- }
2436
- module.exports = ConfirmPrompt;
2437
- });
2438
-
2439
- // node_modules/prompts/dist/elements/index.js
2440
- var require_elements = __commonJS((exports, module) => {
2441
- module.exports = {
2442
- TextPrompt: require_text(),
2443
- SelectPrompt: require_select(),
2444
- TogglePrompt: require_toggle(),
2445
- DatePrompt: require_date(),
2446
- NumberPrompt: require_number(),
2447
- MultiselectPrompt: require_multiselect(),
2448
- AutocompletePrompt: require_autocomplete(),
2449
- AutocompleteMultiselectPrompt: require_autocompleteMultiselect(),
2450
- ConfirmPrompt: require_confirm()
2451
- };
2452
- });
2453
-
2454
- // node_modules/prompts/dist/prompts.js
2455
- var require_prompts = __commonJS((exports) => {
2456
- var $ = exports;
2457
- var el = require_elements();
2458
- var noop = (v) => v;
2459
- function toPrompt(type, args, opts = {}) {
2460
- return new Promise((res, rej) => {
2461
- const p = new el[type](args);
2462
- const onAbort = opts.onAbort || noop;
2463
- const onSubmit = opts.onSubmit || noop;
2464
- const onExit = opts.onExit || noop;
2465
- p.on("state", args.onState || noop);
2466
- p.on("submit", (x) => res(onSubmit(x)));
2467
- p.on("exit", (x) => res(onExit(x)));
2468
- p.on("abort", (x) => rej(onAbort(x)));
2469
- });
2470
- }
2471
- $.text = (args) => toPrompt("TextPrompt", args);
2472
- $.password = (args) => {
2473
- args.style = "password";
2474
- return $.text(args);
2475
- };
2476
- $.invisible = (args) => {
2477
- args.style = "invisible";
2478
- return $.text(args);
2479
- };
2480
- $.number = (args) => toPrompt("NumberPrompt", args);
2481
- $.date = (args) => toPrompt("DatePrompt", args);
2482
- $.confirm = (args) => toPrompt("ConfirmPrompt", args);
2483
- $.list = (args) => {
2484
- const sep = args.separator || ",";
2485
- return toPrompt("TextPrompt", args, {
2486
- onSubmit: (str) => str.split(sep).map((s) => s.trim())
2487
- });
2488
- };
2489
- $.toggle = (args) => toPrompt("TogglePrompt", args);
2490
- $.select = (args) => toPrompt("SelectPrompt", args);
2491
- $.multiselect = (args) => {
2492
- args.choices = [].concat(args.choices || []);
2493
- const toSelected = (items) => items.filter((item) => item.selected).map((item) => item.value);
2494
- return toPrompt("MultiselectPrompt", args, {
2495
- onAbort: toSelected,
2496
- onSubmit: toSelected
2497
- });
2498
- };
2499
- $.autocompleteMultiselect = (args) => {
2500
- args.choices = [].concat(args.choices || []);
2501
- const toSelected = (items) => items.filter((item) => item.selected).map((item) => item.value);
2502
- return toPrompt("AutocompleteMultiselectPrompt", args, {
2503
- onAbort: toSelected,
2504
- onSubmit: toSelected
2505
- });
2506
- };
2507
- var byTitle = (input, choices) => Promise.resolve(choices.filter((item) => item.title.slice(0, input.length).toLowerCase() === input.toLowerCase()));
2508
- $.autocomplete = (args) => {
2509
- args.suggest = args.suggest || byTitle;
2510
- args.choices = [].concat(args.choices || []);
2511
- return toPrompt("AutocompletePrompt", args);
2512
- };
2513
- });
2514
-
2515
- // node_modules/prompts/dist/index.js
2516
- var require_dist = __commonJS((exports, module) => {
2517
- function ownKeys(object, enumerableOnly) {
2518
- var keys = Object.keys(object);
2519
- if (Object.getOwnPropertySymbols) {
2520
- var symbols = Object.getOwnPropertySymbols(object);
2521
- if (enumerableOnly) {
2522
- symbols = symbols.filter(function(sym) {
2523
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2524
- });
2525
- }
2526
- keys.push.apply(keys, symbols);
2527
- }
2528
- return keys;
2529
- }
2530
- function _objectSpread(target) {
2531
- for (var i = 1;i < arguments.length; i++) {
2532
- var source = arguments[i] != null ? arguments[i] : {};
2533
- if (i % 2) {
2534
- ownKeys(Object(source), true).forEach(function(key) {
2535
- _defineProperty(target, key, source[key]);
2536
- });
2537
- } else if (Object.getOwnPropertyDescriptors) {
2538
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2539
- } else {
2540
- ownKeys(Object(source)).forEach(function(key) {
2541
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2542
- });
2543
- }
2544
- }
2545
- return target;
2546
- }
2547
- function _defineProperty(obj, key, value) {
2548
- if (key in obj) {
2549
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
2550
- } else {
2551
- obj[key] = value;
2552
- }
2553
- return obj;
2554
- }
2555
- function _createForOfIteratorHelper(o, allowArrayLike) {
2556
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
2557
- if (!it) {
2558
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
2559
- if (it)
2560
- o = it;
2561
- var i = 0;
2562
- var F = function F() {};
2563
- return { s: F, n: function n() {
2564
- if (i >= o.length)
2565
- return { done: true };
2566
- return { done: false, value: o[i++] };
2567
- }, e: function e(_e) {
2568
- throw _e;
2569
- }, f: F };
2570
- }
2571
- throw new TypeError(`Invalid attempt to iterate non-iterable instance.
2572
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
2573
- }
2574
- var normalCompletion = true, didErr = false, err;
2575
- return { s: function s() {
2576
- it = it.call(o);
2577
- }, n: function n() {
2578
- var step = it.next();
2579
- normalCompletion = step.done;
2580
- return step;
2581
- }, e: function e(_e2) {
2582
- didErr = true;
2583
- err = _e2;
2584
- }, f: function f() {
2585
- try {
2586
- if (!normalCompletion && it.return != null)
2587
- it.return();
2588
- } finally {
2589
- if (didErr)
2590
- throw err;
2591
- }
2592
- } };
2593
- }
2594
- function _unsupportedIterableToArray(o, minLen) {
2595
- if (!o)
2596
- return;
2597
- if (typeof o === "string")
2598
- return _arrayLikeToArray(o, minLen);
2599
- var n = Object.prototype.toString.call(o).slice(8, -1);
2600
- if (n === "Object" && o.constructor)
2601
- n = o.constructor.name;
2602
- if (n === "Map" || n === "Set")
2603
- return Array.from(o);
2604
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
2605
- return _arrayLikeToArray(o, minLen);
2606
- }
2607
- function _arrayLikeToArray(arr, len) {
2608
- if (len == null || len > arr.length)
2609
- len = arr.length;
2610
- for (var i = 0, arr2 = new Array(len);i < len; i++)
2611
- arr2[i] = arr[i];
2612
- return arr2;
2613
- }
2614
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2615
- try {
2616
- var info = gen[key](arg);
2617
- var value = info.value;
2618
- } catch (error) {
2619
- reject(error);
2620
- return;
2621
- }
2622
- if (info.done) {
2623
- resolve(value);
2624
- } else {
2625
- Promise.resolve(value).then(_next, _throw);
2626
- }
2627
- }
2628
- function _asyncToGenerator(fn) {
2629
- return function() {
2630
- var self = this, args = arguments;
2631
- return new Promise(function(resolve, reject) {
2632
- var gen = fn.apply(self, args);
2633
- function _next(value) {
2634
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2635
- }
2636
- function _throw(err) {
2637
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2638
- }
2639
- _next(undefined);
2640
- });
2641
- };
2642
- }
2643
- var prompts = require_prompts();
2644
- var passOn = ["suggest", "format", "onState", "validate", "onRender", "type"];
2645
- var noop = () => {};
2646
- function prompt() {
2647
- return _prompt.apply(this, arguments);
2648
- }
2649
- function _prompt() {
2650
- _prompt = _asyncToGenerator(function* (questions = [], {
2651
- onSubmit = noop,
2652
- onCancel = noop
2653
- } = {}) {
2654
- const answers = {};
2655
- const override2 = prompt._override || {};
2656
- questions = [].concat(questions);
2657
- let answer, question, quit, name, type, lastPrompt;
2658
- const getFormattedAnswer = /* @__PURE__ */ function() {
2659
- var _ref = _asyncToGenerator(function* (question2, answer2, skipValidation = false) {
2660
- if (!skipValidation && question2.validate && question2.validate(answer2) !== true) {
2661
- return;
2662
- }
2663
- return question2.format ? yield question2.format(answer2, answers) : answer2;
2664
- });
2665
- return function getFormattedAnswer(_x, _x2) {
2666
- return _ref.apply(this, arguments);
2667
- };
2668
- }();
2669
- var _iterator = _createForOfIteratorHelper(questions), _step;
2670
- try {
2671
- for (_iterator.s();!(_step = _iterator.n()).done; ) {
2672
- question = _step.value;
2673
- var _question = question;
2674
- name = _question.name;
2675
- type = _question.type;
2676
- if (typeof type === "function") {
2677
- type = yield type(answer, _objectSpread({}, answers), question);
2678
- question["type"] = type;
2679
- }
2680
- if (!type)
2681
- continue;
2682
- for (let key in question) {
2683
- if (passOn.includes(key))
2684
- continue;
2685
- let value = question[key];
2686
- question[key] = typeof value === "function" ? yield value(answer, _objectSpread({}, answers), lastPrompt) : value;
2687
- }
2688
- lastPrompt = question;
2689
- if (typeof question.message !== "string") {
2690
- throw new Error("prompt message is required");
2691
- }
2692
- var _question2 = question;
2693
- name = _question2.name;
2694
- type = _question2.type;
2695
- if (prompts[type] === undefined) {
2696
- throw new Error(`prompt type (${type}) is not defined`);
2697
- }
2698
- if (override2[question.name] !== undefined) {
2699
- answer = yield getFormattedAnswer(question, override2[question.name]);
2700
- if (answer !== undefined) {
2701
- answers[name] = answer;
2702
- continue;
2703
- }
2704
- }
2705
- try {
2706
- answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : yield prompts[type](question);
2707
- answers[name] = answer = yield getFormattedAnswer(question, answer, true);
2708
- quit = yield onSubmit(question, answer, answers);
2709
- } catch (err) {
2710
- quit = !(yield onCancel(question, answers));
2711
- }
2712
- if (quit)
2713
- return answers;
2714
- }
2715
- } catch (err) {
2716
- _iterator.e(err);
2717
- } finally {
2718
- _iterator.f();
2719
- }
2720
- return answers;
2721
- });
2722
- return _prompt.apply(this, arguments);
2723
- }
2724
- function getInjectedAnswer(injected, deafultValue) {
2725
- const answer = injected.shift();
2726
- if (answer instanceof Error) {
2727
- throw answer;
2728
- }
2729
- return answer === undefined ? deafultValue : answer;
2730
- }
2731
- function inject(answers) {
2732
- prompt._injected = (prompt._injected || []).concat(answers);
2733
- }
2734
- function override(answers) {
2735
- prompt._override = Object.assign({}, answers);
2736
- }
2737
- module.exports = Object.assign(prompt, {
2738
- prompt,
2739
- prompts,
2740
- inject,
2741
- override
2742
- });
2743
- });
2744
-
2745
- // node_modules/prompts/lib/util/action.js
2746
- var require_action2 = __commonJS((exports, module) => {
2747
- module.exports = (key, isSelect) => {
2748
- if (key.meta && key.name !== "escape")
2749
- return;
2750
- if (key.ctrl) {
2751
- if (key.name === "a")
2752
- return "first";
2753
- if (key.name === "c")
2754
- return "abort";
2755
- if (key.name === "d")
2756
- return "abort";
2757
- if (key.name === "e")
2758
- return "last";
2759
- if (key.name === "g")
2760
- return "reset";
2761
- }
2762
- if (isSelect) {
2763
- if (key.name === "j")
2764
- return "down";
2765
- if (key.name === "k")
2766
- return "up";
2767
- }
2768
- if (key.name === "return")
2769
- return "submit";
2770
- if (key.name === "enter")
2771
- return "submit";
2772
- if (key.name === "backspace")
2773
- return "delete";
2774
- if (key.name === "delete")
2775
- return "deleteForward";
2776
- if (key.name === "abort")
2777
- return "abort";
2778
- if (key.name === "escape")
2779
- return "exit";
2780
- if (key.name === "tab")
2781
- return "next";
2782
- if (key.name === "pagedown")
2783
- return "nextPage";
2784
- if (key.name === "pageup")
2785
- return "prevPage";
2786
- if (key.name === "home")
2787
- return "home";
2788
- if (key.name === "end")
2789
- return "end";
2790
- if (key.name === "up")
2791
- return "up";
2792
- if (key.name === "down")
2793
- return "down";
2794
- if (key.name === "right")
2795
- return "right";
2796
- if (key.name === "left")
2797
- return "left";
2798
- return false;
2799
- };
2800
- });
2801
-
2802
- // node_modules/prompts/lib/util/strip.js
2803
- var require_strip2 = __commonJS((exports, module) => {
2804
- module.exports = (str) => {
2805
- const pattern = [
2806
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
2807
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
2808
- ].join("|");
2809
- const RGX = new RegExp(pattern, "g");
2810
- return typeof str === "string" ? str.replace(RGX, "") : str;
2811
- };
2812
- });
2813
-
2814
- // node_modules/prompts/lib/util/clear.js
2815
- var require_clear2 = __commonJS((exports, module) => {
2816
- var strip = require_strip2();
2817
- var { erase, cursor } = require_src();
2818
- var width = (str) => [...strip(str)].length;
2819
- module.exports = function(prompt, perLine) {
2820
- if (!perLine)
2821
- return erase.line + cursor.to(0);
2822
- let rows = 0;
2823
- const lines = prompt.split(/\r?\n/);
2824
- for (let line of lines) {
2825
- rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
2826
- }
2827
- return erase.lines(rows);
2828
- };
2829
- });
2830
-
2831
- // node_modules/prompts/lib/util/figures.js
2832
- var require_figures2 = __commonJS((exports, module) => {
2833
- var main = {
2834
- arrowUp: "↑",
2835
- arrowDown: "↓",
2836
- arrowLeft: "←",
2837
- arrowRight: "→",
2838
- radioOn: "◉",
2839
- radioOff: "◯",
2840
- tick: "✔",
2841
- cross: "✖",
2842
- ellipsis: "…",
2843
- pointerSmall: "›",
2844
- line: "─",
2845
- pointer: "❯"
2846
- };
2847
- var win = {
2848
- arrowUp: main.arrowUp,
2849
- arrowDown: main.arrowDown,
2850
- arrowLeft: main.arrowLeft,
2851
- arrowRight: main.arrowRight,
2852
- radioOn: "(*)",
2853
- radioOff: "( )",
2854
- tick: "√",
2855
- cross: "×",
2856
- ellipsis: "...",
2857
- pointerSmall: "»",
2858
- line: "─",
2859
- pointer: ">"
2860
- };
2861
- var figures = process.platform === "win32" ? win : main;
2862
- module.exports = figures;
2863
- });
2864
-
2865
- // node_modules/prompts/lib/util/style.js
2866
- var require_style2 = __commonJS((exports, module) => {
2867
- var c = require_kleur();
2868
- var figures = require_figures2();
2869
- var styles = Object.freeze({
2870
- password: { scale: 1, render: (input) => "*".repeat(input.length) },
2871
- emoji: { scale: 2, render: (input) => "\uD83D\uDE03".repeat(input.length) },
2872
- invisible: { scale: 0, render: (input) => "" },
2873
- default: { scale: 1, render: (input) => `${input}` }
2874
- });
2875
- var render = (type) => styles[type] || styles.default;
2876
- var symbols = Object.freeze({
2877
- aborted: c.red(figures.cross),
2878
- done: c.green(figures.tick),
2879
- exited: c.yellow(figures.cross),
2880
- default: c.cyan("?")
2881
- });
2882
- var symbol = (done, aborted, exited) => aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default;
2883
- var delimiter = (completing) => c.gray(completing ? figures.ellipsis : figures.pointerSmall);
2884
- var item = (expandable, expanded) => c.gray(expandable ? expanded ? figures.pointerSmall : "+" : figures.line);
2885
- module.exports = {
2886
- styles,
2887
- render,
2888
- symbols,
2889
- symbol,
2890
- delimiter,
2891
- item
2892
- };
2893
- });
2894
-
2895
- // node_modules/prompts/lib/util/lines.js
2896
- var require_lines2 = __commonJS((exports, module) => {
2897
- var strip = require_strip2();
2898
- module.exports = function(msg, perLine) {
2899
- let lines = String(strip(msg) || "").split(/\r?\n/);
2900
- if (!perLine)
2901
- return lines.length;
2902
- return lines.map((l) => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
2903
- };
2904
- });
2905
-
2906
- // node_modules/prompts/lib/util/wrap.js
2907
- var require_wrap2 = __commonJS((exports, module) => {
2908
- module.exports = (msg, opts = {}) => {
2909
- const tab = Number.isSafeInteger(parseInt(opts.margin)) ? new Array(parseInt(opts.margin)).fill(" ").join("") : opts.margin || "";
2910
- const width = opts.width;
2911
- return (msg || "").split(/\r?\n/g).map((line) => line.split(/\s+/g).reduce((arr, w) => {
2912
- if (w.length + tab.length >= width || arr[arr.length - 1].length + w.length + 1 < width)
2913
- arr[arr.length - 1] += ` ${w}`;
2914
- else
2915
- arr.push(`${tab}${w}`);
2916
- return arr;
2917
- }, [tab]).join(`
2918
- `)).join(`
2919
- `);
2920
- };
2921
- });
2922
-
2923
- // node_modules/prompts/lib/util/entriesToDisplay.js
2924
- var require_entriesToDisplay2 = __commonJS((exports, module) => {
2925
- module.exports = (cursor, total, maxVisible) => {
2926
- maxVisible = maxVisible || total;
2927
- let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2));
2928
- if (startIndex < 0)
2929
- startIndex = 0;
2930
- let endIndex = Math.min(startIndex + maxVisible, total);
2931
- return { startIndex, endIndex };
2932
- };
2933
- });
2934
-
2935
- // node_modules/prompts/lib/util/index.js
2936
- var require_util2 = __commonJS((exports, module) => {
2937
- module.exports = {
2938
- action: require_action2(),
2939
- clear: require_clear2(),
2940
- style: require_style2(),
2941
- strip: require_strip2(),
2942
- figures: require_figures2(),
2943
- lines: require_lines2(),
2944
- wrap: require_wrap2(),
2945
- entriesToDisplay: require_entriesToDisplay2()
2946
- };
2947
- });
2948
-
2949
- // node_modules/prompts/lib/elements/prompt.js
2950
- var require_prompt2 = __commonJS((exports, module) => {
2951
- var readline = __require("readline");
2952
- var { action } = require_util2();
2953
- var EventEmitter = __require("events");
2954
- var { beep, cursor } = require_src();
2955
- var color = require_kleur();
2956
-
2957
- class Prompt extends EventEmitter {
2958
- constructor(opts = {}) {
2959
- super();
2960
- this.firstRender = true;
2961
- this.in = opts.stdin || process.stdin;
2962
- this.out = opts.stdout || process.stdout;
2963
- this.onRender = (opts.onRender || (() => {
2964
- return;
2965
- })).bind(this);
2966
- const rl = readline.createInterface({ input: this.in, escapeCodeTimeout: 50 });
2967
- readline.emitKeypressEvents(this.in, rl);
2968
- if (this.in.isTTY)
2969
- this.in.setRawMode(true);
2970
- const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
2971
- const keypress = (str, key) => {
2972
- let a = action(key, isSelect);
2973
- if (a === false) {
2974
- this._ && this._(str, key);
2975
- } else if (typeof this[a] === "function") {
2976
- this[a](key);
2977
- } else {
2978
- this.bell();
2979
- }
2980
- };
2981
- this.close = () => {
2982
- this.out.write(cursor.show);
2983
- this.in.removeListener("keypress", keypress);
2984
- if (this.in.isTTY)
2985
- this.in.setRawMode(false);
2986
- rl.close();
2987
- this.emit(this.aborted ? "abort" : this.exited ? "exit" : "submit", this.value);
2988
- this.closed = true;
2989
- };
2990
- this.in.on("keypress", keypress);
2991
- }
2992
- fire() {
2993
- this.emit("state", {
2994
- value: this.value,
2995
- aborted: !!this.aborted,
2996
- exited: !!this.exited
2997
- });
2998
- }
2999
- bell() {
3000
- this.out.write(beep);
3001
- }
3002
- render() {
3003
- this.onRender(color);
3004
- if (this.firstRender)
3005
- this.firstRender = false;
3006
- }
3007
- }
3008
- module.exports = Prompt;
3009
- });
3010
-
3011
- // node_modules/prompts/lib/elements/text.js
3012
- var require_text2 = __commonJS((exports, module) => {
3013
- var color = require_kleur();
3014
- var Prompt = require_prompt2();
3015
- var { erase, cursor } = require_src();
3016
- var { style, clear, lines, figures } = require_util2();
3017
-
3018
- class TextPrompt extends Prompt {
3019
- constructor(opts = {}) {
3020
- super(opts);
3021
- this.transform = style.render(opts.style);
3022
- this.scale = this.transform.scale;
3023
- this.msg = opts.message;
3024
- this.initial = opts.initial || ``;
3025
- this.validator = opts.validate || (() => true);
3026
- this.value = ``;
3027
- this.errorMsg = opts.error || `Please Enter A Valid Value`;
3028
- this.cursor = Number(!!this.initial);
3029
- this.cursorOffset = 0;
3030
- this.clear = clear(``, this.out.columns);
3031
- this.render();
3032
- }
3033
- set value(v) {
3034
- if (!v && this.initial) {
3035
- this.placeholder = true;
3036
- this.rendered = color.gray(this.transform.render(this.initial));
3037
- } else {
3038
- this.placeholder = false;
3039
- this.rendered = this.transform.render(v);
3040
- }
3041
- this._value = v;
3042
- this.fire();
3043
- }
3044
- get value() {
3045
- return this._value;
3046
- }
3047
- reset() {
3048
- this.value = ``;
3049
- this.cursor = Number(!!this.initial);
3050
- this.cursorOffset = 0;
3051
- this.fire();
3052
- this.render();
3053
- }
3054
- exit() {
3055
- this.abort();
3056
- }
3057
- abort() {
3058
- this.value = this.value || this.initial;
3059
- this.done = this.aborted = true;
3060
- this.error = false;
3061
- this.red = false;
3062
- this.fire();
3063
- this.render();
3064
- this.out.write(`
3065
- `);
3066
- this.close();
3067
- }
3068
- async validate() {
3069
- let valid = await this.validator(this.value);
3070
- if (typeof valid === `string`) {
3071
- this.errorMsg = valid;
3072
- valid = false;
3073
- }
3074
- this.error = !valid;
3075
- }
3076
- async submit() {
3077
- this.value = this.value || this.initial;
3078
- this.cursorOffset = 0;
3079
- this.cursor = this.rendered.length;
3080
- await this.validate();
3081
- if (this.error) {
3082
- this.red = true;
3083
- this.fire();
3084
- this.render();
3085
- return;
3086
- }
3087
- this.done = true;
3088
- this.aborted = false;
3089
- this.fire();
3090
- this.render();
3091
- this.out.write(`
3092
- `);
3093
- this.close();
3094
- }
3095
- next() {
3096
- if (!this.placeholder)
3097
- return this.bell();
3098
- this.value = this.initial;
3099
- this.cursor = this.rendered.length;
3100
- this.fire();
3101
- this.render();
3102
- }
3103
- moveCursor(n) {
3104
- if (this.placeholder)
3105
- return;
3106
- this.cursor = this.cursor + n;
3107
- this.cursorOffset += n;
3108
- }
3109
- _(c, key) {
3110
- let s1 = this.value.slice(0, this.cursor);
3111
- let s2 = this.value.slice(this.cursor);
3112
- this.value = `${s1}${c}${s2}`;
3113
- this.red = false;
3114
- this.cursor = this.placeholder ? 0 : s1.length + 1;
3115
- this.render();
3116
- }
3117
- delete() {
3118
- if (this.isCursorAtStart())
3119
- return this.bell();
3120
- let s1 = this.value.slice(0, this.cursor - 1);
3121
- let s2 = this.value.slice(this.cursor);
3122
- this.value = `${s1}${s2}`;
3123
- this.red = false;
3124
- if (this.isCursorAtStart()) {
3125
- this.cursorOffset = 0;
3126
- } else {
3127
- this.cursorOffset++;
3128
- this.moveCursor(-1);
3129
- }
3130
- this.render();
3131
- }
3132
- deleteForward() {
3133
- if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
3134
- return this.bell();
3135
- let s1 = this.value.slice(0, this.cursor);
3136
- let s2 = this.value.slice(this.cursor + 1);
3137
- this.value = `${s1}${s2}`;
3138
- this.red = false;
3139
- if (this.isCursorAtEnd()) {
3140
- this.cursorOffset = 0;
3141
- } else {
3142
- this.cursorOffset++;
3143
- }
3144
- this.render();
3145
- }
3146
- first() {
3147
- this.cursor = 0;
3148
- this.render();
3149
- }
3150
- last() {
3151
- this.cursor = this.value.length;
3152
- this.render();
3153
- }
3154
- left() {
3155
- if (this.cursor <= 0 || this.placeholder)
3156
- return this.bell();
3157
- this.moveCursor(-1);
3158
- this.render();
3159
- }
3160
- right() {
3161
- if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
3162
- return this.bell();
3163
- this.moveCursor(1);
3164
- this.render();
3165
- }
3166
- isCursorAtStart() {
3167
- return this.cursor === 0 || this.placeholder && this.cursor === 1;
3168
- }
3169
- isCursorAtEnd() {
3170
- return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
3171
- }
3172
- render() {
3173
- if (this.closed)
3174
- return;
3175
- if (!this.firstRender) {
3176
- if (this.outputError)
3177
- this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
3178
- this.out.write(clear(this.outputText, this.out.columns));
3179
- }
3180
- super.render();
3181
- this.outputError = "";
3182
- this.outputText = [
3183
- style.symbol(this.done, this.aborted),
3184
- color.bold(this.msg),
3185
- style.delimiter(this.done),
3186
- this.red ? color.red(this.rendered) : this.rendered
3187
- ].join(` `);
3188
- if (this.error) {
3189
- this.outputError += this.errorMsg.split(`
3190
- `).reduce((a, l, i) => a + `
3191
- ${i ? " " : figures.pointerSmall} ${color.red().italic(l)}`, ``);
3192
- }
3193
- this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0));
3194
- }
3195
- }
3196
- module.exports = TextPrompt;
3197
- });
3198
-
3199
- // node_modules/prompts/lib/elements/select.js
3200
- var require_select2 = __commonJS((exports, module) => {
3201
- var color = require_kleur();
3202
- var Prompt = require_prompt2();
3203
- var { style, clear, figures, wrap, entriesToDisplay } = require_util2();
3204
- var { cursor } = require_src();
3205
-
3206
- class SelectPrompt extends Prompt {
3207
- constructor(opts = {}) {
3208
- super(opts);
3209
- this.msg = opts.message;
3210
- this.hint = opts.hint || "- Use arrow-keys. Return to submit.";
3211
- this.warn = opts.warn || "- This option is disabled";
3212
- this.cursor = opts.initial || 0;
3213
- this.choices = opts.choices.map((ch, idx) => {
3214
- if (typeof ch === "string")
3215
- ch = { title: ch, value: idx };
3216
- return {
3217
- title: ch && (ch.title || ch.value || ch),
3218
- value: ch && (ch.value === undefined ? idx : ch.value),
3219
- description: ch && ch.description,
3220
- selected: ch && ch.selected,
3221
- disabled: ch && ch.disabled
3222
- };
3223
- });
3224
- this.optionsPerPage = opts.optionsPerPage || 10;
3225
- this.value = (this.choices[this.cursor] || {}).value;
3226
- this.clear = clear("", this.out.columns);
3227
- this.render();
3228
- }
3229
- moveCursor(n) {
3230
- this.cursor = n;
3231
- this.value = this.choices[n].value;
3232
- this.fire();
3233
- }
3234
- reset() {
3235
- this.moveCursor(0);
3236
- this.fire();
3237
- this.render();
3238
- }
3239
- exit() {
3240
- this.abort();
3241
- }
3242
- abort() {
3243
- this.done = this.aborted = true;
3244
- this.fire();
3245
- this.render();
3246
- this.out.write(`
3247
- `);
3248
- this.close();
3249
- }
3250
- submit() {
3251
- if (!this.selection.disabled) {
3252
- this.done = true;
3253
- this.aborted = false;
3254
- this.fire();
3255
- this.render();
3256
- this.out.write(`
3257
- `);
3258
- this.close();
3259
- } else
3260
- this.bell();
3261
- }
3262
- first() {
3263
- this.moveCursor(0);
3264
- this.render();
3265
- }
3266
- last() {
3267
- this.moveCursor(this.choices.length - 1);
3268
- this.render();
3269
- }
3270
- up() {
3271
- if (this.cursor === 0) {
3272
- this.moveCursor(this.choices.length - 1);
3273
- } else {
3274
- this.moveCursor(this.cursor - 1);
3275
- }
3276
- this.render();
3277
- }
3278
- down() {
3279
- if (this.cursor === this.choices.length - 1) {
3280
- this.moveCursor(0);
3281
- } else {
3282
- this.moveCursor(this.cursor + 1);
3283
- }
3284
- this.render();
3285
- }
3286
- next() {
3287
- this.moveCursor((this.cursor + 1) % this.choices.length);
3288
- this.render();
3289
- }
3290
- _(c, key) {
3291
- if (c === " ")
3292
- return this.submit();
3293
- }
3294
- get selection() {
3295
- return this.choices[this.cursor];
3296
- }
3297
- render() {
3298
- if (this.closed)
3299
- return;
3300
- if (this.firstRender)
3301
- this.out.write(cursor.hide);
3302
- else
3303
- this.out.write(clear(this.outputText, this.out.columns));
3304
- super.render();
3305
- let { startIndex, endIndex } = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage);
3306
- this.outputText = [
3307
- style.symbol(this.done, this.aborted),
3308
- color.bold(this.msg),
3309
- style.delimiter(false),
3310
- this.done ? this.selection.title : this.selection.disabled ? color.yellow(this.warn) : color.gray(this.hint)
3311
- ].join(" ");
3312
- if (!this.done) {
3313
- this.outputText += `
3314
- `;
3315
- for (let i = startIndex;i < endIndex; i++) {
3316
- let title, prefix, desc = "", v = this.choices[i];
3317
- if (i === startIndex && startIndex > 0) {
3318
- prefix = figures.arrowUp;
3319
- } else if (i === endIndex - 1 && endIndex < this.choices.length) {
3320
- prefix = figures.arrowDown;
3321
- } else {
3322
- prefix = " ";
3323
- }
3324
- if (v.disabled) {
3325
- title = this.cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
3326
- prefix = (this.cursor === i ? color.bold().gray(figures.pointer) + " " : " ") + prefix;
3327
- } else {
3328
- title = this.cursor === i ? color.cyan().underline(v.title) : v.title;
3329
- prefix = (this.cursor === i ? color.cyan(figures.pointer) + " " : " ") + prefix;
3330
- if (v.description && this.cursor === i) {
3331
- desc = ` - ${v.description}`;
3332
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
3333
- desc = `
3334
- ` + wrap(v.description, { margin: 3, width: this.out.columns });
3335
- }
3336
- }
3337
- }
3338
- this.outputText += `${prefix} ${title}${color.gray(desc)}
3339
- `;
3340
- }
3341
- }
3342
- this.out.write(this.outputText);
3343
- }
3344
- }
3345
- module.exports = SelectPrompt;
3346
- });
3347
-
3348
- // node_modules/prompts/lib/elements/toggle.js
3349
- var require_toggle2 = __commonJS((exports, module) => {
3350
- var color = require_kleur();
3351
- var Prompt = require_prompt2();
3352
- var { style, clear } = require_util2();
3353
- var { cursor, erase } = require_src();
3354
-
3355
- class TogglePrompt extends Prompt {
3356
- constructor(opts = {}) {
3357
- super(opts);
3358
- this.msg = opts.message;
3359
- this.value = !!opts.initial;
3360
- this.active = opts.active || "on";
3361
- this.inactive = opts.inactive || "off";
3362
- this.initialValue = this.value;
3363
- this.render();
3364
- }
3365
- reset() {
3366
- this.value = this.initialValue;
3367
- this.fire();
3368
- this.render();
3369
- }
3370
- exit() {
3371
- this.abort();
3372
- }
3373
- abort() {
3374
- this.done = this.aborted = true;
3375
- this.fire();
3376
- this.render();
3377
- this.out.write(`
3378
- `);
3379
- this.close();
3380
- }
3381
- submit() {
3382
- this.done = true;
3383
- this.aborted = false;
3384
- this.fire();
3385
- this.render();
3386
- this.out.write(`
3387
- `);
3388
- this.close();
3389
- }
3390
- deactivate() {
3391
- if (this.value === false)
3392
- return this.bell();
3393
- this.value = false;
3394
- this.render();
3395
- }
3396
- activate() {
3397
- if (this.value === true)
3398
- return this.bell();
3399
- this.value = true;
3400
- this.render();
3401
- }
3402
- delete() {
3403
- this.deactivate();
3404
- }
3405
- left() {
3406
- this.deactivate();
3407
- }
3408
- right() {
3409
- this.activate();
3410
- }
3411
- down() {
3412
- this.deactivate();
3413
- }
3414
- up() {
3415
- this.activate();
3416
- }
3417
- next() {
3418
- this.value = !this.value;
3419
- this.fire();
3420
- this.render();
3421
- }
3422
- _(c, key) {
3423
- if (c === " ") {
3424
- this.value = !this.value;
3425
- } else if (c === "1") {
3426
- this.value = true;
3427
- } else if (c === "0") {
3428
- this.value = false;
3429
- } else
3430
- return this.bell();
3431
- this.render();
3432
- }
3433
- render() {
3434
- if (this.closed)
3435
- return;
3436
- if (this.firstRender)
3437
- this.out.write(cursor.hide);
3438
- else
3439
- this.out.write(clear(this.outputText, this.out.columns));
3440
- super.render();
3441
- this.outputText = [
3442
- style.symbol(this.done, this.aborted),
3443
- color.bold(this.msg),
3444
- style.delimiter(this.done),
3445
- this.value ? this.inactive : color.cyan().underline(this.inactive),
3446
- color.gray("/"),
3447
- this.value ? color.cyan().underline(this.active) : this.active
3448
- ].join(" ");
3449
- this.out.write(erase.line + cursor.to(0) + this.outputText);
3450
- }
3451
- }
3452
- module.exports = TogglePrompt;
3453
- });
3454
-
3455
- // node_modules/prompts/lib/dateparts/datepart.js
3456
- var require_datepart2 = __commonJS((exports, module) => {
3457
- class DatePart {
3458
- constructor({ token, date, parts, locales }) {
3459
- this.token = token;
3460
- this.date = date || new Date;
3461
- this.parts = parts || [this];
3462
- this.locales = locales || {};
3463
- }
3464
- up() {}
3465
- down() {}
3466
- next() {
3467
- const currentIdx = this.parts.indexOf(this);
3468
- return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
3469
- }
3470
- setTo(val) {}
3471
- prev() {
3472
- let parts = [].concat(this.parts).reverse();
3473
- const currentIdx = parts.indexOf(this);
3474
- return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
3475
- }
3476
- toString() {
3477
- return String(this.date);
3478
- }
3479
- }
3480
- module.exports = DatePart;
3481
- });
3482
-
3483
- // node_modules/prompts/lib/dateparts/meridiem.js
3484
- var require_meridiem2 = __commonJS((exports, module) => {
3485
- var DatePart = require_datepart2();
3486
-
3487
- class Meridiem extends DatePart {
3488
- constructor(opts = {}) {
3489
- super(opts);
3490
- }
3491
- up() {
3492
- this.date.setHours((this.date.getHours() + 12) % 24);
3493
- }
3494
- down() {
3495
- this.up();
3496
- }
3497
- toString() {
3498
- let meridiem = this.date.getHours() > 12 ? "pm" : "am";
3499
- return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
3500
- }
3501
- }
3502
- module.exports = Meridiem;
3503
- });
3504
-
3505
- // node_modules/prompts/lib/dateparts/day.js
3506
- var require_day2 = __commonJS((exports, module) => {
3507
- var DatePart = require_datepart2();
3508
- var pos = (n) => {
3509
- n = n % 10;
3510
- return n === 1 ? "st" : n === 2 ? "nd" : n === 3 ? "rd" : "th";
3511
- };
3512
-
3513
- class Day extends DatePart {
3514
- constructor(opts = {}) {
3515
- super(opts);
3516
- }
3517
- up() {
3518
- this.date.setDate(this.date.getDate() + 1);
3519
- }
3520
- down() {
3521
- this.date.setDate(this.date.getDate() - 1);
3522
- }
3523
- setTo(val) {
3524
- this.date.setDate(parseInt(val.substr(-2)));
3525
- }
3526
- toString() {
3527
- let date = this.date.getDate();
3528
- let day = this.date.getDay();
3529
- 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;
3530
- }
3531
- }
3532
- module.exports = Day;
3533
- });
3534
-
3535
- // node_modules/prompts/lib/dateparts/hours.js
3536
- var require_hours2 = __commonJS((exports, module) => {
3537
- var DatePart = require_datepart2();
3538
-
3539
- class Hours extends DatePart {
3540
- constructor(opts = {}) {
3541
- super(opts);
3542
- }
3543
- up() {
3544
- this.date.setHours(this.date.getHours() + 1);
3545
- }
3546
- down() {
3547
- this.date.setHours(this.date.getHours() - 1);
3548
- }
3549
- setTo(val) {
3550
- this.date.setHours(parseInt(val.substr(-2)));
3551
- }
3552
- toString() {
3553
- let hours = this.date.getHours();
3554
- if (/h/.test(this.token))
3555
- hours = hours % 12 || 12;
3556
- return this.token.length > 1 ? String(hours).padStart(2, "0") : hours;
3557
- }
3558
- }
3559
- module.exports = Hours;
3560
- });
3561
-
3562
- // node_modules/prompts/lib/dateparts/milliseconds.js
3563
- var require_milliseconds2 = __commonJS((exports, module) => {
3564
- var DatePart = require_datepart2();
3565
-
3566
- class Milliseconds extends DatePart {
3567
- constructor(opts = {}) {
3568
- super(opts);
3569
- }
3570
- up() {
3571
- this.date.setMilliseconds(this.date.getMilliseconds() + 1);
3572
- }
3573
- down() {
3574
- this.date.setMilliseconds(this.date.getMilliseconds() - 1);
3575
- }
3576
- setTo(val) {
3577
- this.date.setMilliseconds(parseInt(val.substr(-this.token.length)));
3578
- }
3579
- toString() {
3580
- return String(this.date.getMilliseconds()).padStart(4, "0").substr(0, this.token.length);
3581
- }
3582
- }
3583
- module.exports = Milliseconds;
3584
- });
3585
-
3586
- // node_modules/prompts/lib/dateparts/minutes.js
3587
- var require_minutes2 = __commonJS((exports, module) => {
3588
- var DatePart = require_datepart2();
3589
-
3590
- class Minutes extends DatePart {
3591
- constructor(opts = {}) {
3592
- super(opts);
3593
- }
3594
- up() {
3595
- this.date.setMinutes(this.date.getMinutes() + 1);
3596
- }
3597
- down() {
3598
- this.date.setMinutes(this.date.getMinutes() - 1);
3599
- }
3600
- setTo(val) {
3601
- this.date.setMinutes(parseInt(val.substr(-2)));
3602
- }
3603
- toString() {
3604
- let m = this.date.getMinutes();
3605
- return this.token.length > 1 ? String(m).padStart(2, "0") : m;
3606
- }
3607
- }
3608
- module.exports = Minutes;
3609
- });
3610
-
3611
- // node_modules/prompts/lib/dateparts/month.js
3612
- var require_month2 = __commonJS((exports, module) => {
3613
- var DatePart = require_datepart2();
3614
-
3615
- class Month extends DatePart {
3616
- constructor(opts = {}) {
3617
- super(opts);
3618
- }
3619
- up() {
3620
- this.date.setMonth(this.date.getMonth() + 1);
3621
- }
3622
- down() {
3623
- this.date.setMonth(this.date.getMonth() - 1);
3624
- }
3625
- setTo(val) {
3626
- val = parseInt(val.substr(-2)) - 1;
3627
- this.date.setMonth(val < 0 ? 0 : val);
3628
- }
3629
- toString() {
3630
- let month = this.date.getMonth();
3631
- let tl = this.token.length;
3632
- return tl === 2 ? String(month + 1).padStart(2, "0") : tl === 3 ? this.locales.monthsShort[month] : tl === 4 ? this.locales.months[month] : String(month + 1);
3633
- }
3634
- }
3635
- module.exports = Month;
3636
- });
3637
-
3638
- // node_modules/prompts/lib/dateparts/seconds.js
3639
- var require_seconds2 = __commonJS((exports, module) => {
3640
- var DatePart = require_datepart2();
3641
-
3642
- class Seconds extends DatePart {
3643
- constructor(opts = {}) {
3644
- super(opts);
3645
- }
3646
- up() {
3647
- this.date.setSeconds(this.date.getSeconds() + 1);
3648
- }
3649
- down() {
3650
- this.date.setSeconds(this.date.getSeconds() - 1);
3651
- }
3652
- setTo(val) {
3653
- this.date.setSeconds(parseInt(val.substr(-2)));
3654
- }
3655
- toString() {
3656
- let s = this.date.getSeconds();
3657
- return this.token.length > 1 ? String(s).padStart(2, "0") : s;
3658
- }
3659
- }
3660
- module.exports = Seconds;
3661
- });
3662
-
3663
- // node_modules/prompts/lib/dateparts/year.js
3664
- var require_year2 = __commonJS((exports, module) => {
3665
- var DatePart = require_datepart2();
3666
-
3667
- class Year extends DatePart {
3668
- constructor(opts = {}) {
3669
- super(opts);
3670
- }
3671
- up() {
3672
- this.date.setFullYear(this.date.getFullYear() + 1);
3673
- }
3674
- down() {
3675
- this.date.setFullYear(this.date.getFullYear() - 1);
3676
- }
3677
- setTo(val) {
3678
- this.date.setFullYear(val.substr(-4));
3679
- }
3680
- toString() {
3681
- let year = String(this.date.getFullYear()).padStart(4, "0");
3682
- return this.token.length === 2 ? year.substr(-2) : year;
3683
- }
3684
- }
3685
- module.exports = Year;
3686
- });
3687
-
3688
- // node_modules/prompts/lib/dateparts/index.js
3689
- var require_dateparts2 = __commonJS((exports, module) => {
3690
- module.exports = {
3691
- DatePart: require_datepart2(),
3692
- Meridiem: require_meridiem2(),
3693
- Day: require_day2(),
3694
- Hours: require_hours2(),
3695
- Milliseconds: require_milliseconds2(),
3696
- Minutes: require_minutes2(),
3697
- Month: require_month2(),
3698
- Seconds: require_seconds2(),
3699
- Year: require_year2()
3700
- };
3701
- });
3702
-
3703
- // node_modules/prompts/lib/elements/date.js
3704
- var require_date2 = __commonJS((exports, module) => {
3705
- var color = require_kleur();
3706
- var Prompt = require_prompt2();
3707
- var { style, clear, figures } = require_util2();
3708
- var { erase, cursor } = require_src();
3709
- var { DatePart, Meridiem, Day, Hours, Milliseconds, Minutes, Month, Seconds, Year } = require_dateparts2();
3710
- 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;
3711
- var regexGroups = {
3712
- 1: ({ token }) => token.replace(/\\(.)/g, "$1"),
3713
- 2: (opts) => new Day(opts),
3714
- 3: (opts) => new Month(opts),
3715
- 4: (opts) => new Year(opts),
3716
- 5: (opts) => new Meridiem(opts),
3717
- 6: (opts) => new Hours(opts),
3718
- 7: (opts) => new Minutes(opts),
3719
- 8: (opts) => new Seconds(opts),
3720
- 9: (opts) => new Milliseconds(opts)
3721
- };
3722
- var dfltLocales = {
3723
- months: "January,February,March,April,May,June,July,August,September,October,November,December".split(","),
3724
- monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),
3725
- weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
3726
- weekdaysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")
3727
- };
3728
-
3729
- class DatePrompt extends Prompt {
3730
- constructor(opts = {}) {
3731
- super(opts);
3732
- this.msg = opts.message;
3733
- this.cursor = 0;
3734
- this.typed = "";
3735
- this.locales = Object.assign(dfltLocales, opts.locales);
3736
- this._date = opts.initial || new Date;
3737
- this.errorMsg = opts.error || "Please Enter A Valid Value";
3738
- this.validator = opts.validate || (() => true);
3739
- this.mask = opts.mask || "YYYY-MM-DD HH:mm:ss";
3740
- this.clear = clear("", this.out.columns);
3741
- this.render();
3742
- }
3743
- get value() {
3744
- return this.date;
3745
- }
3746
- get date() {
3747
- return this._date;
3748
- }
3749
- set date(date) {
3750
- if (date)
3751
- this._date.setTime(date.getTime());
3752
- }
3753
- set mask(mask) {
3754
- let result;
3755
- this.parts = [];
3756
- while (result = regex.exec(mask)) {
3757
- let match = result.shift();
3758
- let idx = result.findIndex((gr) => gr != null);
3759
- this.parts.push(idx in regexGroups ? regexGroups[idx]({ token: result[idx] || match, date: this.date, parts: this.parts, locales: this.locales }) : result[idx] || match);
3760
- }
3761
- let parts = this.parts.reduce((arr, i) => {
3762
- if (typeof i === "string" && typeof arr[arr.length - 1] === "string")
3763
- arr[arr.length - 1] += i;
3764
- else
3765
- arr.push(i);
3766
- return arr;
3767
- }, []);
3768
- this.parts.splice(0);
3769
- this.parts.push(...parts);
3770
- this.reset();
3771
- }
3772
- moveCursor(n) {
3773
- this.typed = "";
3774
- this.cursor = n;
3775
- this.fire();
3776
- }
3777
- reset() {
3778
- this.moveCursor(this.parts.findIndex((p) => p instanceof DatePart));
3779
- this.fire();
3780
- this.render();
3781
- }
3782
- exit() {
3783
- this.abort();
3784
- }
3785
- abort() {
3786
- this.done = this.aborted = true;
3787
- this.error = false;
3788
- this.fire();
3789
- this.render();
3790
- this.out.write(`
3791
- `);
3792
- this.close();
3793
- }
3794
- async validate() {
3795
- let valid = await this.validator(this.value);
3796
- if (typeof valid === "string") {
3797
- this.errorMsg = valid;
3798
- valid = false;
3799
- }
3800
- this.error = !valid;
3801
- }
3802
- async submit() {
3803
- await this.validate();
3804
- if (this.error) {
3805
- this.color = "red";
3806
- this.fire();
3807
- this.render();
3808
- return;
3809
- }
3810
- this.done = true;
3811
- this.aborted = false;
3812
- this.fire();
3813
- this.render();
3814
- this.out.write(`
3815
- `);
3816
- this.close();
3817
- }
3818
- up() {
3819
- this.typed = "";
3820
- this.parts[this.cursor].up();
3821
- this.render();
3822
- }
3823
- down() {
3824
- this.typed = "";
3825
- this.parts[this.cursor].down();
3826
- this.render();
3827
- }
3828
- left() {
3829
- let prev = this.parts[this.cursor].prev();
3830
- if (prev == null)
3831
- return this.bell();
3832
- this.moveCursor(this.parts.indexOf(prev));
3833
- this.render();
3834
- }
3835
- right() {
3836
- let next = this.parts[this.cursor].next();
3837
- if (next == null)
3838
- return this.bell();
3839
- this.moveCursor(this.parts.indexOf(next));
3840
- this.render();
3841
- }
3842
- next() {
3843
- let next = this.parts[this.cursor].next();
3844
- this.moveCursor(next ? this.parts.indexOf(next) : this.parts.findIndex((part) => part instanceof DatePart));
3845
- this.render();
3846
- }
3847
- _(c) {
3848
- if (/\d/.test(c)) {
3849
- this.typed += c;
3850
- this.parts[this.cursor].setTo(this.typed);
3851
- this.render();
3852
- }
3853
- }
3854
- render() {
3855
- if (this.closed)
3856
- return;
3857
- if (this.firstRender)
3858
- this.out.write(cursor.hide);
3859
- else
3860
- this.out.write(clear(this.outputText, this.out.columns));
3861
- super.render();
3862
- this.outputText = [
3863
- style.symbol(this.done, this.aborted),
3864
- color.bold(this.msg),
3865
- style.delimiter(false),
3866
- this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []).join("")
3867
- ].join(" ");
3868
- if (this.error) {
3869
- this.outputText += this.errorMsg.split(`
3870
- `).reduce((a, l, i) => a + `
3871
- ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
3872
- }
3873
- this.out.write(erase.line + cursor.to(0) + this.outputText);
3874
- }
3875
- }
3876
- module.exports = DatePrompt;
3877
- });
3878
-
3879
- // node_modules/prompts/lib/elements/number.js
3880
- var require_number2 = __commonJS((exports, module) => {
3881
- var color = require_kleur();
3882
- var Prompt = require_prompt2();
3883
- var { cursor, erase } = require_src();
3884
- var { style, figures, clear, lines } = require_util2();
3885
- var isNumber = /[0-9]/;
3886
- var isDef = (any) => any !== undefined;
3887
- var round = (number, precision) => {
3888
- let factor = Math.pow(10, precision);
3889
- return Math.round(number * factor) / factor;
3890
- };
3891
-
3892
- class NumberPrompt extends Prompt {
3893
- constructor(opts = {}) {
3894
- super(opts);
3895
- this.transform = style.render(opts.style);
3896
- this.msg = opts.message;
3897
- this.initial = isDef(opts.initial) ? opts.initial : "";
3898
- this.float = !!opts.float;
3899
- this.round = opts.round || 2;
3900
- this.inc = opts.increment || 1;
3901
- this.min = isDef(opts.min) ? opts.min : -Infinity;
3902
- this.max = isDef(opts.max) ? opts.max : Infinity;
3903
- this.errorMsg = opts.error || `Please Enter A Valid Value`;
3904
- this.validator = opts.validate || (() => true);
3905
- this.color = `cyan`;
3906
- this.value = ``;
3907
- this.typed = ``;
3908
- this.lastHit = 0;
3909
- this.render();
3910
- }
3911
- set value(v) {
3912
- if (!v && v !== 0) {
3913
- this.placeholder = true;
3914
- this.rendered = color.gray(this.transform.render(`${this.initial}`));
3915
- this._value = ``;
3916
- } else {
3917
- this.placeholder = false;
3918
- this.rendered = this.transform.render(`${round(v, this.round)}`);
3919
- this._value = round(v, this.round);
3920
- }
3921
- this.fire();
3922
- }
3923
- get value() {
3924
- return this._value;
3925
- }
3926
- parse(x) {
3927
- return this.float ? parseFloat(x) : parseInt(x);
3928
- }
3929
- valid(c) {
3930
- return c === `-` || c === `.` && this.float || isNumber.test(c);
3931
- }
3932
- reset() {
3933
- this.typed = ``;
3934
- this.value = ``;
3935
- this.fire();
3936
- this.render();
3937
- }
3938
- exit() {
3939
- this.abort();
3940
- }
3941
- abort() {
3942
- let x = this.value;
3943
- this.value = x !== `` ? x : this.initial;
3944
- this.done = this.aborted = true;
3945
- this.error = false;
3946
- this.fire();
3947
- this.render();
3948
- this.out.write(`
3949
- `);
3950
- this.close();
3951
- }
3952
- async validate() {
3953
- let valid = await this.validator(this.value);
3954
- if (typeof valid === `string`) {
3955
- this.errorMsg = valid;
3956
- valid = false;
3957
- }
3958
- this.error = !valid;
3959
- }
3960
- async submit() {
3961
- await this.validate();
3962
- if (this.error) {
3963
- this.color = `red`;
3964
- this.fire();
3965
- this.render();
3966
- return;
3967
- }
3968
- let x = this.value;
3969
- this.value = x !== `` ? x : this.initial;
3970
- this.done = true;
3971
- this.aborted = false;
3972
- this.error = false;
3973
- this.fire();
3974
- this.render();
3975
- this.out.write(`
3976
- `);
3977
- this.close();
3978
- }
3979
- up() {
3980
- this.typed = ``;
3981
- if (this.value === "") {
3982
- this.value = this.min - this.inc;
3983
- }
3984
- if (this.value >= this.max)
3985
- return this.bell();
3986
- this.value += this.inc;
3987
- this.color = `cyan`;
3988
- this.fire();
3989
- this.render();
3990
- }
3991
- down() {
3992
- this.typed = ``;
3993
- if (this.value === "") {
3994
- this.value = this.min + this.inc;
3995
- }
3996
- if (this.value <= this.min)
3997
- return this.bell();
3998
- this.value -= this.inc;
3999
- this.color = `cyan`;
4000
- this.fire();
4001
- this.render();
4002
- }
4003
- delete() {
4004
- let val = this.value.toString();
4005
- if (val.length === 0)
4006
- return this.bell();
4007
- this.value = this.parse(val = val.slice(0, -1)) || ``;
4008
- if (this.value !== "" && this.value < this.min) {
4009
- this.value = this.min;
4010
- }
4011
- this.color = `cyan`;
4012
- this.fire();
4013
- this.render();
4014
- }
4015
- next() {
4016
- this.value = this.initial;
4017
- this.fire();
4018
- this.render();
4019
- }
4020
- _(c, key) {
4021
- if (!this.valid(c))
4022
- return this.bell();
4023
- const now = Date.now();
4024
- if (now - this.lastHit > 1000)
4025
- this.typed = ``;
4026
- this.typed += c;
4027
- this.lastHit = now;
4028
- this.color = `cyan`;
4029
- if (c === `.`)
4030
- return this.fire();
4031
- this.value = Math.min(this.parse(this.typed), this.max);
4032
- if (this.value > this.max)
4033
- this.value = this.max;
4034
- if (this.value < this.min)
4035
- this.value = this.min;
4036
- this.fire();
4037
- this.render();
4038
- }
4039
- render() {
4040
- if (this.closed)
4041
- return;
4042
- if (!this.firstRender) {
4043
- if (this.outputError)
4044
- this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
4045
- this.out.write(clear(this.outputText, this.out.columns));
4046
- }
4047
- super.render();
4048
- this.outputError = "";
4049
- this.outputText = [
4050
- style.symbol(this.done, this.aborted),
4051
- color.bold(this.msg),
4052
- style.delimiter(this.done),
4053
- !this.done || !this.done && !this.placeholder ? color[this.color]().underline(this.rendered) : this.rendered
4054
- ].join(` `);
4055
- if (this.error) {
4056
- this.outputError += this.errorMsg.split(`
4057
- `).reduce((a, l, i) => a + `
4058
- ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
4059
- }
4060
- this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
4061
- }
4062
- }
4063
- module.exports = NumberPrompt;
4064
- });
4065
-
4066
- // node_modules/prompts/lib/elements/multiselect.js
4067
- var require_multiselect2 = __commonJS((exports, module) => {
4068
- var color = require_kleur();
4069
- var { cursor } = require_src();
4070
- var Prompt = require_prompt2();
4071
- var { clear, figures, style, wrap, entriesToDisplay } = require_util2();
4072
-
4073
- class MultiselectPrompt extends Prompt {
4074
- constructor(opts = {}) {
4075
- super(opts);
4076
- this.msg = opts.message;
4077
- this.cursor = opts.cursor || 0;
4078
- this.scrollIndex = opts.cursor || 0;
4079
- this.hint = opts.hint || "";
4080
- this.warn = opts.warn || "- This option is disabled -";
4081
- this.minSelected = opts.min;
4082
- this.showMinError = false;
4083
- this.maxChoices = opts.max;
4084
- this.instructions = opts.instructions;
4085
- this.optionsPerPage = opts.optionsPerPage || 10;
4086
- this.value = opts.choices.map((ch, idx) => {
4087
- if (typeof ch === "string")
4088
- ch = { title: ch, value: idx };
4089
- return {
4090
- title: ch && (ch.title || ch.value || ch),
4091
- description: ch && ch.description,
4092
- value: ch && (ch.value === undefined ? idx : ch.value),
4093
- selected: ch && ch.selected,
4094
- disabled: ch && ch.disabled
4095
- };
4096
- });
4097
- this.clear = clear("", this.out.columns);
4098
- if (!opts.overrideRender) {
4099
- this.render();
4100
- }
4101
- }
4102
- reset() {
4103
- this.value.map((v) => !v.selected);
4104
- this.cursor = 0;
4105
- this.fire();
4106
- this.render();
4107
- }
4108
- selected() {
4109
- return this.value.filter((v) => v.selected);
4110
- }
4111
- exit() {
4112
- this.abort();
4113
- }
4114
- abort() {
4115
- this.done = this.aborted = true;
4116
- this.fire();
4117
- this.render();
4118
- this.out.write(`
4119
- `);
4120
- this.close();
4121
- }
4122
- submit() {
4123
- const selected = this.value.filter((e) => e.selected);
4124
- if (this.minSelected && selected.length < this.minSelected) {
4125
- this.showMinError = true;
4126
- this.render();
4127
- } else {
4128
- this.done = true;
4129
- this.aborted = false;
4130
- this.fire();
4131
- this.render();
4132
- this.out.write(`
4133
- `);
4134
- this.close();
4135
- }
4136
- }
4137
- first() {
4138
- this.cursor = 0;
4139
- this.render();
4140
- }
4141
- last() {
4142
- this.cursor = this.value.length - 1;
4143
- this.render();
4144
- }
4145
- next() {
4146
- this.cursor = (this.cursor + 1) % this.value.length;
4147
- this.render();
4148
- }
4149
- up() {
4150
- if (this.cursor === 0) {
4151
- this.cursor = this.value.length - 1;
4152
- } else {
4153
- this.cursor--;
4154
- }
4155
- this.render();
4156
- }
4157
- down() {
4158
- if (this.cursor === this.value.length - 1) {
4159
- this.cursor = 0;
4160
- } else {
4161
- this.cursor++;
4162
- }
4163
- this.render();
4164
- }
4165
- left() {
4166
- this.value[this.cursor].selected = false;
4167
- this.render();
4168
- }
4169
- right() {
4170
- if (this.value.filter((e) => e.selected).length >= this.maxChoices)
4171
- return this.bell();
4172
- this.value[this.cursor].selected = true;
4173
- this.render();
4174
- }
4175
- handleSpaceToggle() {
4176
- const v = this.value[this.cursor];
4177
- if (v.selected) {
4178
- v.selected = false;
4179
- this.render();
4180
- } else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
4181
- return this.bell();
4182
- } else {
4183
- v.selected = true;
4184
- this.render();
4185
- }
4186
- }
4187
- toggleAll() {
4188
- if (this.maxChoices !== undefined || this.value[this.cursor].disabled) {
4189
- return this.bell();
4190
- }
4191
- const newSelected = !this.value[this.cursor].selected;
4192
- this.value.filter((v) => !v.disabled).forEach((v) => v.selected = newSelected);
4193
- this.render();
4194
- }
4195
- _(c, key) {
4196
- if (c === " ") {
4197
- this.handleSpaceToggle();
4198
- } else if (c === "a") {
4199
- this.toggleAll();
4200
- } else {
4201
- return this.bell();
4202
- }
4203
- }
4204
- renderInstructions() {
4205
- if (this.instructions === undefined || this.instructions) {
4206
- if (typeof this.instructions === "string") {
4207
- return this.instructions;
4208
- }
4209
- return `
4210
- Instructions:
4211
- ` + ` ${figures.arrowUp}/${figures.arrowDown}: Highlight option
4212
- ` + ` ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
4213
- ` + (this.maxChoices === undefined ? ` a: Toggle all
4214
- ` : "") + ` enter/return: Complete answer`;
4215
- }
4216
- return "";
4217
- }
4218
- renderOption(cursor2, v, i, arrowIndicator) {
4219
- const prefix = (v.selected ? color.green(figures.radioOn) : figures.radioOff) + " " + arrowIndicator + " ";
4220
- let title, desc;
4221
- if (v.disabled) {
4222
- title = cursor2 === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
4223
- } else {
4224
- title = cursor2 === i ? color.cyan().underline(v.title) : v.title;
4225
- if (cursor2 === i && v.description) {
4226
- desc = ` - ${v.description}`;
4227
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
4228
- desc = `
4229
- ` + wrap(v.description, { margin: prefix.length, width: this.out.columns });
4230
- }
4231
- }
4232
- }
4233
- return prefix + title + color.gray(desc || "");
4234
- }
4235
- paginateOptions(options) {
4236
- if (options.length === 0) {
4237
- return color.red("No matches for this query.");
4238
- }
4239
- let { startIndex, endIndex } = entriesToDisplay(this.cursor, options.length, this.optionsPerPage);
4240
- let prefix, styledOptions = [];
4241
- for (let i = startIndex;i < endIndex; i++) {
4242
- if (i === startIndex && startIndex > 0) {
4243
- prefix = figures.arrowUp;
4244
- } else if (i === endIndex - 1 && endIndex < options.length) {
4245
- prefix = figures.arrowDown;
4246
- } else {
4247
- prefix = " ";
4248
- }
4249
- styledOptions.push(this.renderOption(this.cursor, options[i], i, prefix));
4250
- }
4251
- return `
4252
- ` + styledOptions.join(`
4253
- `);
4254
- }
4255
- renderOptions(options) {
4256
- if (!this.done) {
4257
- return this.paginateOptions(options);
4258
- }
4259
- return "";
4260
- }
4261
- renderDoneOrInstructions() {
4262
- if (this.done) {
4263
- return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
4264
- }
4265
- const output = [color.gray(this.hint), this.renderInstructions()];
4266
- if (this.value[this.cursor].disabled) {
4267
- output.push(color.yellow(this.warn));
4268
- }
4269
- return output.join(" ");
4270
- }
4271
- render() {
4272
- if (this.closed)
4273
- return;
4274
- if (this.firstRender)
4275
- this.out.write(cursor.hide);
4276
- super.render();
4277
- let prompt = [
4278
- style.symbol(this.done, this.aborted),
4279
- color.bold(this.msg),
4280
- style.delimiter(false),
4281
- this.renderDoneOrInstructions()
4282
- ].join(" ");
4283
- if (this.showMinError) {
4284
- prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
4285
- this.showMinError = false;
4286
- }
4287
- prompt += this.renderOptions(this.value);
4288
- this.out.write(this.clear + prompt);
4289
- this.clear = clear(prompt, this.out.columns);
4290
- }
4291
- }
4292
- module.exports = MultiselectPrompt;
4293
- });
4294
-
4295
- // node_modules/prompts/lib/elements/autocomplete.js
4296
- var require_autocomplete2 = __commonJS((exports, module) => {
4297
- var color = require_kleur();
4298
- var Prompt = require_prompt2();
4299
- var { erase, cursor } = require_src();
4300
- var { style, clear, figures, wrap, entriesToDisplay } = require_util2();
4301
- var getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
4302
- var getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
4303
- var getIndex = (arr, valOrTitle) => {
4304
- const index = arr.findIndex((el) => el.value === valOrTitle || el.title === valOrTitle);
4305
- return index > -1 ? index : undefined;
4306
- };
4307
-
4308
- class AutocompletePrompt extends Prompt {
4309
- constructor(opts = {}) {
4310
- super(opts);
4311
- this.msg = opts.message;
4312
- this.suggest = opts.suggest;
4313
- this.choices = opts.choices;
4314
- this.initial = typeof opts.initial === "number" ? opts.initial : getIndex(opts.choices, opts.initial);
4315
- this.select = this.initial || opts.cursor || 0;
4316
- this.i18n = { noMatches: opts.noMatches || "no matches found" };
4317
- this.fallback = opts.fallback || this.initial;
4318
- this.clearFirst = opts.clearFirst || false;
4319
- this.suggestions = [];
4320
- this.input = "";
4321
- this.limit = opts.limit || 10;
4322
- this.cursor = 0;
4323
- this.transform = style.render(opts.style);
4324
- this.scale = this.transform.scale;
4325
- this.render = this.render.bind(this);
4326
- this.complete = this.complete.bind(this);
4327
- this.clear = clear("", this.out.columns);
4328
- this.complete(this.render);
4329
- this.render();
4330
- }
4331
- set fallback(fb) {
4332
- this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
4333
- }
4334
- get fallback() {
4335
- let choice;
4336
- if (typeof this._fb === "number")
4337
- choice = this.choices[this._fb];
4338
- else if (typeof this._fb === "string")
4339
- choice = { title: this._fb };
4340
- return choice || this._fb || { title: this.i18n.noMatches };
4341
- }
4342
- moveSelect(i) {
4343
- this.select = i;
4344
- if (this.suggestions.length > 0)
4345
- this.value = getVal(this.suggestions, i);
4346
- else
4347
- this.value = this.fallback.value;
4348
- this.fire();
4349
- }
4350
- async complete(cb) {
4351
- const p = this.completing = this.suggest(this.input, this.choices);
4352
- const suggestions = await p;
4353
- if (this.completing !== p)
4354
- return;
4355
- this.suggestions = suggestions.map((s, i, arr) => ({ title: getTitle(arr, i), value: getVal(arr, i), description: s.description }));
4356
- this.completing = false;
4357
- const l = Math.max(suggestions.length - 1, 0);
4358
- this.moveSelect(Math.min(l, this.select));
4359
- cb && cb();
4360
- }
4361
- reset() {
4362
- this.input = "";
4363
- this.complete(() => {
4364
- this.moveSelect(this.initial !== undefined ? this.initial : 0);
4365
- this.render();
4366
- });
4367
- this.render();
4368
- }
4369
- exit() {
4370
- if (this.clearFirst && this.input.length > 0) {
4371
- this.reset();
4372
- } else {
4373
- this.done = this.exited = true;
4374
- this.aborted = false;
4375
- this.fire();
4376
- this.render();
4377
- this.out.write(`
4378
- `);
4379
- this.close();
4380
- }
4381
- }
4382
- abort() {
4383
- this.done = this.aborted = true;
4384
- this.exited = false;
4385
- this.fire();
4386
- this.render();
4387
- this.out.write(`
4388
- `);
4389
- this.close();
4390
- }
4391
- submit() {
4392
- this.done = true;
4393
- this.aborted = this.exited = false;
4394
- this.fire();
4395
- this.render();
4396
- this.out.write(`
4397
- `);
4398
- this.close();
4399
- }
4400
- _(c, key) {
4401
- let s1 = this.input.slice(0, this.cursor);
4402
- let s2 = this.input.slice(this.cursor);
4403
- this.input = `${s1}${c}${s2}`;
4404
- this.cursor = s1.length + 1;
4405
- this.complete(this.render);
4406
- this.render();
4407
- }
4408
- delete() {
4409
- if (this.cursor === 0)
4410
- return this.bell();
4411
- let s1 = this.input.slice(0, this.cursor - 1);
4412
- let s2 = this.input.slice(this.cursor);
4413
- this.input = `${s1}${s2}`;
4414
- this.complete(this.render);
4415
- this.cursor = this.cursor - 1;
4416
- this.render();
4417
- }
4418
- deleteForward() {
4419
- if (this.cursor * this.scale >= this.rendered.length)
4420
- return this.bell();
4421
- let s1 = this.input.slice(0, this.cursor);
4422
- let s2 = this.input.slice(this.cursor + 1);
4423
- this.input = `${s1}${s2}`;
4424
- this.complete(this.render);
4425
- this.render();
4426
- }
4427
- first() {
4428
- this.moveSelect(0);
4429
- this.render();
4430
- }
4431
- last() {
4432
- this.moveSelect(this.suggestions.length - 1);
4433
- this.render();
4434
- }
4435
- up() {
4436
- if (this.select === 0) {
4437
- this.moveSelect(this.suggestions.length - 1);
4438
- } else {
4439
- this.moveSelect(this.select - 1);
4440
- }
4441
- this.render();
4442
- }
4443
- down() {
4444
- if (this.select === this.suggestions.length - 1) {
4445
- this.moveSelect(0);
4446
- } else {
4447
- this.moveSelect(this.select + 1);
4448
- }
4449
- this.render();
4450
- }
4451
- next() {
4452
- if (this.select === this.suggestions.length - 1) {
4453
- this.moveSelect(0);
4454
- } else
4455
- this.moveSelect(this.select + 1);
4456
- this.render();
4457
- }
4458
- nextPage() {
4459
- this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
4460
- this.render();
4461
- }
4462
- prevPage() {
4463
- this.moveSelect(Math.max(this.select - this.limit, 0));
4464
- this.render();
4465
- }
4466
- left() {
4467
- if (this.cursor <= 0)
4468
- return this.bell();
4469
- this.cursor = this.cursor - 1;
4470
- this.render();
4471
- }
4472
- right() {
4473
- if (this.cursor * this.scale >= this.rendered.length)
4474
- return this.bell();
4475
- this.cursor = this.cursor + 1;
4476
- this.render();
4477
- }
4478
- renderOption(v, hovered, isStart, isEnd) {
4479
- let desc;
4480
- let prefix = isStart ? figures.arrowUp : isEnd ? figures.arrowDown : " ";
4481
- let title = hovered ? color.cyan().underline(v.title) : v.title;
4482
- prefix = (hovered ? color.cyan(figures.pointer) + " " : " ") + prefix;
4483
- if (v.description) {
4484
- desc = ` - ${v.description}`;
4485
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
4486
- desc = `
4487
- ` + wrap(v.description, { margin: 3, width: this.out.columns });
4488
- }
4489
- }
4490
- return prefix + " " + title + color.gray(desc || "");
4491
- }
4492
- render() {
4493
- if (this.closed)
4494
- return;
4495
- if (this.firstRender)
4496
- this.out.write(cursor.hide);
4497
- else
4498
- this.out.write(clear(this.outputText, this.out.columns));
4499
- super.render();
4500
- let { startIndex, endIndex } = entriesToDisplay(this.select, this.choices.length, this.limit);
4501
- this.outputText = [
4502
- style.symbol(this.done, this.aborted, this.exited),
4503
- color.bold(this.msg),
4504
- style.delimiter(this.completing),
4505
- this.done && this.suggestions[this.select] ? this.suggestions[this.select].title : this.rendered = this.transform.render(this.input)
4506
- ].join(" ");
4507
- if (!this.done) {
4508
- const suggestions = this.suggestions.slice(startIndex, endIndex).map((item, i) => this.renderOption(item, this.select === i + startIndex, i === 0 && startIndex > 0, i + startIndex === endIndex - 1 && endIndex < this.choices.length)).join(`
4509
- `);
4510
- this.outputText += `
4511
- ` + (suggestions || color.gray(this.fallback.title));
4512
- }
4513
- this.out.write(erase.line + cursor.to(0) + this.outputText);
4514
- }
4515
- }
4516
- module.exports = AutocompletePrompt;
4517
- });
4518
-
4519
- // node_modules/prompts/lib/elements/autocompleteMultiselect.js
4520
- var require_autocompleteMultiselect2 = __commonJS((exports, module) => {
4521
- var color = require_kleur();
4522
- var { cursor } = require_src();
4523
- var MultiselectPrompt = require_multiselect2();
4524
- var { clear, style, figures } = require_util2();
4525
-
4526
- class AutocompleteMultiselectPrompt extends MultiselectPrompt {
4527
- constructor(opts = {}) {
4528
- opts.overrideRender = true;
4529
- super(opts);
4530
- this.inputValue = "";
4531
- this.clear = clear("", this.out.columns);
4532
- this.filteredOptions = this.value;
4533
- this.render();
4534
- }
4535
- last() {
4536
- this.cursor = this.filteredOptions.length - 1;
4537
- this.render();
4538
- }
4539
- next() {
4540
- this.cursor = (this.cursor + 1) % this.filteredOptions.length;
4541
- this.render();
4542
- }
4543
- up() {
4544
- if (this.cursor === 0) {
4545
- this.cursor = this.filteredOptions.length - 1;
4546
- } else {
4547
- this.cursor--;
4548
- }
4549
- this.render();
4550
- }
4551
- down() {
4552
- if (this.cursor === this.filteredOptions.length - 1) {
4553
- this.cursor = 0;
4554
- } else {
4555
- this.cursor++;
4556
- }
4557
- this.render();
4558
- }
4559
- left() {
4560
- this.filteredOptions[this.cursor].selected = false;
4561
- this.render();
4562
- }
4563
- right() {
4564
- if (this.value.filter((e) => e.selected).length >= this.maxChoices)
4565
- return this.bell();
4566
- this.filteredOptions[this.cursor].selected = true;
4567
- this.render();
4568
- }
4569
- delete() {
4570
- if (this.inputValue.length) {
4571
- this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
4572
- this.updateFilteredOptions();
4573
- }
4574
- }
4575
- updateFilteredOptions() {
4576
- const currentHighlight = this.filteredOptions[this.cursor];
4577
- this.filteredOptions = this.value.filter((v) => {
4578
- if (this.inputValue) {
4579
- if (typeof v.title === "string") {
4580
- if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
4581
- return true;
4582
- }
4583
- }
4584
- if (typeof v.value === "string") {
4585
- if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
4586
- return true;
4587
- }
4588
- }
4589
- return false;
4590
- }
4591
- return true;
4592
- });
4593
- const newHighlightIndex = this.filteredOptions.findIndex((v) => v === currentHighlight);
4594
- this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
4595
- this.render();
4596
- }
4597
- handleSpaceToggle() {
4598
- const v = this.filteredOptions[this.cursor];
4599
- if (v.selected) {
4600
- v.selected = false;
4601
- this.render();
4602
- } else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
4603
- return this.bell();
4604
- } else {
4605
- v.selected = true;
4606
- this.render();
4607
- }
4608
- }
4609
- handleInputChange(c) {
4610
- this.inputValue = this.inputValue + c;
4611
- this.updateFilteredOptions();
4612
- }
4613
- _(c, key) {
4614
- if (c === " ") {
4615
- this.handleSpaceToggle();
4616
- } else {
4617
- this.handleInputChange(c);
4618
- }
4619
- }
4620
- renderInstructions() {
4621
- if (this.instructions === undefined || this.instructions) {
4622
- if (typeof this.instructions === "string") {
4623
- return this.instructions;
4624
- }
4625
- return `
4626
- Instructions:
4627
- ${figures.arrowUp}/${figures.arrowDown}: Highlight option
4628
- ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
4629
- [a,b,c]/delete: Filter choices
4630
- enter/return: Complete answer
4631
- `;
4632
- }
4633
- return "";
4634
- }
4635
- renderCurrentInput() {
4636
- return `
4637
- Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter something to filter")}
4638
- `;
4639
- }
4640
- renderOption(cursor2, v, i) {
4641
- let title;
4642
- if (v.disabled)
4643
- title = cursor2 === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
4644
- else
4645
- title = cursor2 === i ? color.cyan().underline(v.title) : v.title;
4646
- return (v.selected ? color.green(figures.radioOn) : figures.radioOff) + " " + title;
4647
- }
4648
- renderDoneOrInstructions() {
4649
- if (this.done) {
4650
- return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
4651
- }
4652
- const output = [color.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
4653
- if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
4654
- output.push(color.yellow(this.warn));
4655
- }
4656
- return output.join(" ");
4657
- }
4658
- render() {
4659
- if (this.closed)
4660
- return;
4661
- if (this.firstRender)
4662
- this.out.write(cursor.hide);
4663
- super.render();
4664
- let prompt = [
4665
- style.symbol(this.done, this.aborted),
4666
- color.bold(this.msg),
4667
- style.delimiter(false),
4668
- this.renderDoneOrInstructions()
4669
- ].join(" ");
4670
- if (this.showMinError) {
4671
- prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
4672
- this.showMinError = false;
4673
- }
4674
- prompt += this.renderOptions(this.filteredOptions);
4675
- this.out.write(this.clear + prompt);
4676
- this.clear = clear(prompt, this.out.columns);
4677
- }
4678
- }
4679
- module.exports = AutocompleteMultiselectPrompt;
4680
- });
4681
-
4682
- // node_modules/prompts/lib/elements/confirm.js
4683
- var require_confirm2 = __commonJS((exports, module) => {
4684
- var color = require_kleur();
4685
- var Prompt = require_prompt2();
4686
- var { style, clear } = require_util2();
4687
- var { erase, cursor } = require_src();
4688
-
4689
- class ConfirmPrompt extends Prompt {
4690
- constructor(opts = {}) {
4691
- super(opts);
4692
- this.msg = opts.message;
4693
- this.value = opts.initial;
4694
- this.initialValue = !!opts.initial;
4695
- this.yesMsg = opts.yes || "yes";
4696
- this.yesOption = opts.yesOption || "(Y/n)";
4697
- this.noMsg = opts.no || "no";
4698
- this.noOption = opts.noOption || "(y/N)";
4699
- this.render();
4700
- }
4701
- reset() {
4702
- this.value = this.initialValue;
4703
- this.fire();
4704
- this.render();
4705
- }
4706
- exit() {
4707
- this.abort();
4708
- }
4709
- abort() {
4710
- this.done = this.aborted = true;
4711
- this.fire();
4712
- this.render();
4713
- this.out.write(`
4714
- `);
4715
- this.close();
4716
- }
4717
- submit() {
4718
- this.value = this.value || false;
4719
- this.done = true;
4720
- this.aborted = false;
4721
- this.fire();
4722
- this.render();
4723
- this.out.write(`
4724
- `);
4725
- this.close();
4726
- }
4727
- _(c, key) {
4728
- if (c.toLowerCase() === "y") {
4729
- this.value = true;
4730
- return this.submit();
4731
- }
4732
- if (c.toLowerCase() === "n") {
4733
- this.value = false;
4734
- return this.submit();
4735
- }
4736
- return this.bell();
4737
- }
4738
- render() {
4739
- if (this.closed)
4740
- return;
4741
- if (this.firstRender)
4742
- this.out.write(cursor.hide);
4743
- else
4744
- this.out.write(clear(this.outputText, this.out.columns));
4745
- super.render();
4746
- this.outputText = [
4747
- style.symbol(this.done, this.aborted),
4748
- color.bold(this.msg),
4749
- style.delimiter(this.done),
4750
- this.done ? this.value ? this.yesMsg : this.noMsg : color.gray(this.initialValue ? this.yesOption : this.noOption)
4751
- ].join(" ");
4752
- this.out.write(erase.line + cursor.to(0) + this.outputText);
4753
- }
4754
- }
4755
- module.exports = ConfirmPrompt;
4756
- });
4757
-
4758
- // node_modules/prompts/lib/elements/index.js
4759
- var require_elements2 = __commonJS((exports, module) => {
4760
- module.exports = {
4761
- TextPrompt: require_text2(),
4762
- SelectPrompt: require_select2(),
4763
- TogglePrompt: require_toggle2(),
4764
- DatePrompt: require_date2(),
4765
- NumberPrompt: require_number2(),
4766
- MultiselectPrompt: require_multiselect2(),
4767
- AutocompletePrompt: require_autocomplete2(),
4768
- AutocompleteMultiselectPrompt: require_autocompleteMultiselect2(),
4769
- ConfirmPrompt: require_confirm2()
4770
- };
4771
- });
4772
-
4773
- // node_modules/prompts/lib/prompts.js
4774
- var require_prompts2 = __commonJS((exports) => {
4775
- var $ = exports;
4776
- var el = require_elements2();
4777
- var noop = (v) => v;
4778
- function toPrompt(type, args, opts = {}) {
4779
- return new Promise((res, rej) => {
4780
- const p = new el[type](args);
4781
- const onAbort = opts.onAbort || noop;
4782
- const onSubmit = opts.onSubmit || noop;
4783
- const onExit = opts.onExit || noop;
4784
- p.on("state", args.onState || noop);
4785
- p.on("submit", (x) => res(onSubmit(x)));
4786
- p.on("exit", (x) => res(onExit(x)));
4787
- p.on("abort", (x) => rej(onAbort(x)));
4788
- });
4789
- }
4790
- $.text = (args) => toPrompt("TextPrompt", args);
4791
- $.password = (args) => {
4792
- args.style = "password";
4793
- return $.text(args);
4794
- };
4795
- $.invisible = (args) => {
4796
- args.style = "invisible";
4797
- return $.text(args);
4798
- };
4799
- $.number = (args) => toPrompt("NumberPrompt", args);
4800
- $.date = (args) => toPrompt("DatePrompt", args);
4801
- $.confirm = (args) => toPrompt("ConfirmPrompt", args);
4802
- $.list = (args) => {
4803
- const sep = args.separator || ",";
4804
- return toPrompt("TextPrompt", args, {
4805
- onSubmit: (str) => str.split(sep).map((s) => s.trim())
4806
- });
4807
- };
4808
- $.toggle = (args) => toPrompt("TogglePrompt", args);
4809
- $.select = (args) => toPrompt("SelectPrompt", args);
4810
- $.multiselect = (args) => {
4811
- args.choices = [].concat(args.choices || []);
4812
- const toSelected = (items) => items.filter((item) => item.selected).map((item) => item.value);
4813
- return toPrompt("MultiselectPrompt", args, {
4814
- onAbort: toSelected,
4815
- onSubmit: toSelected
4816
- });
4817
- };
4818
- $.autocompleteMultiselect = (args) => {
4819
- args.choices = [].concat(args.choices || []);
4820
- const toSelected = (items) => items.filter((item) => item.selected).map((item) => item.value);
4821
- return toPrompt("AutocompleteMultiselectPrompt", args, {
4822
- onAbort: toSelected,
4823
- onSubmit: toSelected
4824
- });
4825
- };
4826
- var byTitle = (input, choices) => Promise.resolve(choices.filter((item) => item.title.slice(0, input.length).toLowerCase() === input.toLowerCase()));
4827
- $.autocomplete = (args) => {
4828
- args.suggest = args.suggest || byTitle;
4829
- args.choices = [].concat(args.choices || []);
4830
- return toPrompt("AutocompletePrompt", args);
4831
- };
4832
- });
4833
-
4834
- // node_modules/prompts/lib/index.js
4835
- var require_lib = __commonJS((exports, module) => {
4836
- var prompts = require_prompts2();
4837
- var passOn = ["suggest", "format", "onState", "validate", "onRender", "type"];
4838
- var noop = () => {};
4839
- async function prompt(questions = [], { onSubmit = noop, onCancel = noop } = {}) {
4840
- const answers = {};
4841
- const override2 = prompt._override || {};
4842
- questions = [].concat(questions);
4843
- let answer, question, quit, name, type, lastPrompt;
4844
- const getFormattedAnswer = async (question2, answer2, skipValidation = false) => {
4845
- if (!skipValidation && question2.validate && question2.validate(answer2) !== true) {
4846
- return;
4847
- }
4848
- return question2.format ? await question2.format(answer2, answers) : answer2;
4849
- };
4850
- for (question of questions) {
4851
- ({ name, type } = question);
4852
- if (typeof type === "function") {
4853
- type = await type(answer, { ...answers }, question);
4854
- question["type"] = type;
4855
- }
4856
- if (!type)
4857
- continue;
4858
- for (let key in question) {
4859
- if (passOn.includes(key))
4860
- continue;
4861
- let value = question[key];
4862
- question[key] = typeof value === "function" ? await value(answer, { ...answers }, lastPrompt) : value;
4863
- }
4864
- lastPrompt = question;
4865
- if (typeof question.message !== "string") {
4866
- throw new Error("prompt message is required");
4867
- }
4868
- ({ name, type } = question);
4869
- if (prompts[type] === undefined) {
4870
- throw new Error(`prompt type (${type}) is not defined`);
4871
- }
4872
- if (override2[question.name] !== undefined) {
4873
- answer = await getFormattedAnswer(question, override2[question.name]);
4874
- if (answer !== undefined) {
4875
- answers[name] = answer;
4876
- continue;
4877
- }
4878
- }
4879
- try {
4880
- answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts[type](question);
4881
- answers[name] = answer = await getFormattedAnswer(question, answer, true);
4882
- quit = await onSubmit(question, answer, answers);
4883
- } catch (err) {
4884
- quit = !await onCancel(question, answers);
4885
- }
4886
- if (quit)
4887
- return answers;
4888
- }
4889
- return answers;
4890
- }
4891
- function getInjectedAnswer(injected, deafultValue) {
4892
- const answer = injected.shift();
4893
- if (answer instanceof Error) {
4894
- throw answer;
4895
- }
4896
- return answer === undefined ? deafultValue : answer;
4897
- }
4898
- function inject(answers) {
4899
- prompt._injected = (prompt._injected || []).concat(answers);
4900
- }
4901
- function override(answers) {
4902
- prompt._override = Object.assign({}, answers);
4903
- }
4904
- module.exports = Object.assign(prompt, { prompt, prompts, inject, override });
4905
- });
4906
-
4907
- // node_modules/prompts/index.js
4908
- var require_prompts3 = __commonJS((exports, module) => {
4909
- function isNodeLT(tar) {
4910
- tar = (Array.isArray(tar) ? tar : tar.split(".")).map(Number);
4911
- let i = 0, src = process.versions.node.split(".").map(Number);
4912
- for (;i < tar.length; i++) {
4913
- if (src[i] > tar[i])
4914
- return false;
4915
- if (tar[i] > src[i])
4916
- return true;
4917
- }
4918
- return false;
4919
- }
4920
- module.exports = isNodeLT("8.6.0") ? require_dist() : require_lib();
4921
- });
4922
-
4923
- export { require_prompts3 as require_prompts };