armory-cli 0.1.2 → 0.2.1

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