@elizaos/cli 1.0.6 → 1.0.8

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