superslate 0.8.0 → 0.8.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.
- package/dist/cli.js +610 -1037
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -19,13 +19,15 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
return cached;
|
|
20
20
|
}
|
|
21
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(mod))
|
|
25
|
+
if (!__hasOwnProp.call(to, key))
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: __accessProp.bind(mod, key),
|
|
28
|
+
enumerable: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
29
31
|
if (canCache)
|
|
30
32
|
cache.set(mod, to);
|
|
31
33
|
return to;
|
|
@@ -33,51 +35,51 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
33
35
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
36
|
|
|
35
37
|
// node_modules/sisteransi/src/index.js
|
|
36
|
-
var require_src = __commonJS((exports, module)
|
|
37
|
-
var
|
|
38
|
-
var
|
|
38
|
+
var require_src = __commonJS(function(exports, module) {
|
|
39
|
+
var ESC = "\x1B";
|
|
40
|
+
var CSI = `${ESC}[`;
|
|
39
41
|
var beep = "\x07";
|
|
40
42
|
var cursor = {
|
|
41
43
|
to(x, y) {
|
|
42
44
|
if (!y)
|
|
43
|
-
return `${
|
|
44
|
-
return `${
|
|
45
|
+
return `${CSI}${x + 1}G`;
|
|
46
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
45
47
|
},
|
|
46
48
|
move(x, y) {
|
|
47
49
|
let ret = "";
|
|
48
50
|
if (x < 0)
|
|
49
|
-
ret += `${
|
|
51
|
+
ret += `${CSI}${-x}D`;
|
|
50
52
|
else if (x > 0)
|
|
51
|
-
ret += `${
|
|
53
|
+
ret += `${CSI}${x}C`;
|
|
52
54
|
if (y < 0)
|
|
53
|
-
ret += `${
|
|
55
|
+
ret += `${CSI}${-y}A`;
|
|
54
56
|
else if (y > 0)
|
|
55
|
-
ret += `${
|
|
57
|
+
ret += `${CSI}${y}B`;
|
|
56
58
|
return ret;
|
|
57
59
|
},
|
|
58
|
-
up: (count = 1) => `${
|
|
59
|
-
down: (count = 1) => `${
|
|
60
|
-
forward: (count = 1) => `${
|
|
61
|
-
backward: (count = 1) => `${
|
|
62
|
-
nextLine: (count = 1) => `${
|
|
63
|
-
prevLine: (count = 1) => `${
|
|
64
|
-
left: `${
|
|
65
|
-
hide: `${
|
|
66
|
-
show: `${
|
|
67
|
-
save: `${
|
|
68
|
-
restore: `${
|
|
60
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
61
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
62
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
63
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
64
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
65
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
66
|
+
left: `${CSI}G`,
|
|
67
|
+
hide: `${CSI}?25l`,
|
|
68
|
+
show: `${CSI}?25h`,
|
|
69
|
+
save: `${ESC}7`,
|
|
70
|
+
restore: `${ESC}8`
|
|
69
71
|
};
|
|
70
72
|
var scroll = {
|
|
71
|
-
up: (count = 1) => `${
|
|
72
|
-
down: (count = 1) => `${
|
|
73
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
74
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
73
75
|
};
|
|
74
76
|
var erase = {
|
|
75
|
-
screen: `${
|
|
76
|
-
up: (count = 1) => `${
|
|
77
|
-
down: (count = 1) => `${
|
|
78
|
-
line: `${
|
|
79
|
-
lineEnd: `${
|
|
80
|
-
lineStart: `${
|
|
77
|
+
screen: `${CSI}2J`,
|
|
78
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
79
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
80
|
+
line: `${CSI}2K`,
|
|
81
|
+
lineEnd: `${CSI}K`,
|
|
82
|
+
lineStart: `${CSI}1K`,
|
|
81
83
|
lines(count) {
|
|
82
84
|
let clear = "";
|
|
83
85
|
for (let i = 0;i < count; i++)
|
|
@@ -440,30 +442,11 @@ function wrapAnsi(string, columns, options) {
|
|
|
440
442
|
// node_modules/@clack/core/dist/index.mjs
|
|
441
443
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
442
444
|
import { ReadStream } from "node:tty";
|
|
443
|
-
function findCursor(s, o,
|
|
444
|
-
if (!
|
|
445
|
+
function findCursor(s, o, l) {
|
|
446
|
+
if (!l.some((r) => !r.disabled))
|
|
445
447
|
return s;
|
|
446
|
-
const t = s + o, n = Math.max(
|
|
447
|
-
return
|
|
448
|
-
}
|
|
449
|
-
function findTextCursor(s, o, l2, i) {
|
|
450
|
-
const t = i.split(`
|
|
451
|
-
`);
|
|
452
|
-
let n = 0, e = s;
|
|
453
|
-
for (const r of t) {
|
|
454
|
-
if (e <= r.length)
|
|
455
|
-
break;
|
|
456
|
-
e -= r.length + 1, n++;
|
|
457
|
-
}
|
|
458
|
-
for (n = Math.max(0, Math.min(t.length - 1, n + l2)), e = Math.min(e, t[n].length) + o;e < 0 && n > 0; )
|
|
459
|
-
n--, e += t[n].length + 1;
|
|
460
|
-
for (;e > t[n].length && n < t.length - 1; )
|
|
461
|
-
e -= t[n].length + 1, n++;
|
|
462
|
-
e = Math.max(0, Math.min(t[n].length, e));
|
|
463
|
-
let h = 0;
|
|
464
|
-
for (let r = 0;r < n; r++)
|
|
465
|
-
h += t[r].length + 1;
|
|
466
|
-
return h + e;
|
|
448
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
449
|
+
return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
467
450
|
}
|
|
468
451
|
var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
469
452
|
var t = [
|
|
@@ -495,6 +478,7 @@ var settings = {
|
|
|
495
478
|
error: "Something went wrong"
|
|
496
479
|
},
|
|
497
480
|
withGuide: true,
|
|
481
|
+
accessible: undefined,
|
|
498
482
|
date: {
|
|
499
483
|
monthNames: [...t],
|
|
500
484
|
messages: {
|
|
@@ -506,6 +490,14 @@ var settings = {
|
|
|
506
490
|
}
|
|
507
491
|
}
|
|
508
492
|
};
|
|
493
|
+
function isAccessible(n) {
|
|
494
|
+
if (n !== undefined)
|
|
495
|
+
return n;
|
|
496
|
+
if (settings.accessible !== undefined)
|
|
497
|
+
return settings.accessible;
|
|
498
|
+
const e = process.env.ACCESSIBLE;
|
|
499
|
+
return e !== undefined && e !== "" && e !== "0" && e !== "false";
|
|
500
|
+
}
|
|
509
501
|
function isActionKey(n, e) {
|
|
510
502
|
if (typeof n == "string")
|
|
511
503
|
return settings.aliases.get(n) === e;
|
|
@@ -518,14 +510,14 @@ function diffLines(i, s) {
|
|
|
518
510
|
if (i === s)
|
|
519
511
|
return;
|
|
520
512
|
const e = i.split(`
|
|
521
|
-
`),
|
|
522
|
-
`), r = Math.max(e.length,
|
|
513
|
+
`), t = s.split(`
|
|
514
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
523
515
|
for (let n = 0;n < r; n++)
|
|
524
|
-
e[n] !==
|
|
516
|
+
e[n] !== t[n] && f.push(n);
|
|
525
517
|
return {
|
|
526
518
|
lines: f,
|
|
527
519
|
numLinesBefore: e.length,
|
|
528
|
-
numLinesAfter:
|
|
520
|
+
numLinesAfter: t.length,
|
|
529
521
|
numLines: r
|
|
530
522
|
};
|
|
531
523
|
}
|
|
@@ -542,7 +534,7 @@ function block({
|
|
|
542
534
|
input: e = stdin,
|
|
543
535
|
output: r = stdout,
|
|
544
536
|
overwrite: o = true,
|
|
545
|
-
hideCursor:
|
|
537
|
+
hideCursor: n = true
|
|
546
538
|
} = {}) {
|
|
547
539
|
const s = l.createInterface({
|
|
548
540
|
input: e,
|
|
@@ -551,10 +543,10 @@ function block({
|
|
|
551
543
|
tabSize: 1
|
|
552
544
|
});
|
|
553
545
|
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
554
|
-
const
|
|
546
|
+
const t = (f, { name: a, sequence: w }) => {
|
|
555
547
|
const c = String(f);
|
|
556
|
-
if (isActionKey([c, a,
|
|
557
|
-
|
|
548
|
+
if (isActionKey([c, a, w], "cancel")) {
|
|
549
|
+
n && r.write(import_sisteransi.cursor.show), process.exit(0);
|
|
558
550
|
return;
|
|
559
551
|
}
|
|
560
552
|
if (!o)
|
|
@@ -562,39 +554,37 @@ function block({
|
|
|
562
554
|
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
563
555
|
l.moveCursor(r, i, m, () => {
|
|
564
556
|
l.clearLine(r, 1, () => {
|
|
565
|
-
e.once("keypress",
|
|
557
|
+
e.once("keypress", t);
|
|
566
558
|
});
|
|
567
559
|
});
|
|
568
560
|
};
|
|
569
|
-
return
|
|
570
|
-
e.off("keypress",
|
|
561
|
+
return n && r.write(import_sisteransi.cursor.hide), e.once("keypress", t), () => {
|
|
562
|
+
e.off("keypress", t), n && r.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
571
563
|
};
|
|
572
564
|
}
|
|
573
565
|
var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
|
|
574
566
|
var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
|
|
575
|
-
function wrapTextWithPrefix(e, r, o,
|
|
567
|
+
function wrapTextWithPrefix(e, r, o, n = o, s = o, t) {
|
|
576
568
|
const f = getColumns(e ?? stdout);
|
|
577
569
|
return wrapAnsi(r, f - o.length, {
|
|
578
570
|
hard: true,
|
|
579
571
|
trim: false
|
|
580
572
|
}).split(`
|
|
581
573
|
`).map((c, i, m) => {
|
|
582
|
-
const d =
|
|
583
|
-
return i === 0 ? `${
|
|
574
|
+
const d = t ? t(c, i) : c;
|
|
575
|
+
return i === 0 ? `${n}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
584
576
|
}).join(`
|
|
585
577
|
`);
|
|
586
578
|
}
|
|
587
|
-
function runValidation(e,
|
|
579
|
+
function runValidation(e, a) {
|
|
588
580
|
if ("~standard" in e) {
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
592
|
-
return a.issues?.at(0)?.message;
|
|
581
|
+
const n = e["~standard"].validate(a);
|
|
582
|
+
return n instanceof Promise ? n.then((r) => r.issues?.at(0)?.message) : n.issues?.at(0)?.message;
|
|
593
583
|
}
|
|
594
|
-
return e(
|
|
584
|
+
return e(a);
|
|
595
585
|
}
|
|
596
586
|
|
|
597
|
-
class
|
|
587
|
+
class y {
|
|
598
588
|
input;
|
|
599
589
|
output;
|
|
600
590
|
_abortSignal;
|
|
@@ -609,35 +599,38 @@ class V {
|
|
|
609
599
|
error = "";
|
|
610
600
|
value;
|
|
611
601
|
userInput = "";
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
602
|
+
get accessible() {
|
|
603
|
+
return isAccessible(this.opts.accessible);
|
|
604
|
+
}
|
|
605
|
+
constructor(t, e = true) {
|
|
606
|
+
const { input: i = stdin, output: s = stdout, render: r, signal: n, ...o } = t;
|
|
607
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r.bind(this), this._track = e, this._abortSignal = n, this.input = i, this.output = s;
|
|
615
608
|
}
|
|
616
609
|
unsubscribe() {
|
|
617
610
|
this._subscribers.clear();
|
|
618
611
|
}
|
|
619
|
-
setSubscriber(
|
|
620
|
-
const i = this._subscribers.get(
|
|
621
|
-
i.push(e), this._subscribers.set(
|
|
612
|
+
setSubscriber(t, e) {
|
|
613
|
+
const i = this._subscribers.get(t) ?? [];
|
|
614
|
+
i.push(e), this._subscribers.set(t, i);
|
|
622
615
|
}
|
|
623
|
-
on(
|
|
624
|
-
this.setSubscriber(
|
|
616
|
+
on(t, e) {
|
|
617
|
+
this.setSubscriber(t, { cb: e });
|
|
625
618
|
}
|
|
626
|
-
once(
|
|
627
|
-
this.setSubscriber(
|
|
619
|
+
once(t, e) {
|
|
620
|
+
this.setSubscriber(t, { cb: e, once: true });
|
|
628
621
|
}
|
|
629
|
-
emit(
|
|
630
|
-
const i = this._subscribers.get(
|
|
631
|
-
for (const
|
|
632
|
-
|
|
633
|
-
for (const
|
|
634
|
-
|
|
622
|
+
emit(t, ...e) {
|
|
623
|
+
const i = this._subscribers.get(t) ?? [], s = [];
|
|
624
|
+
for (const r of i)
|
|
625
|
+
r.cb(...e), r.once && s.push(() => i.splice(i.indexOf(r), 1));
|
|
626
|
+
for (const r of s)
|
|
627
|
+
r();
|
|
635
628
|
}
|
|
636
629
|
prompt() {
|
|
637
|
-
return new Promise((
|
|
630
|
+
return new Promise((t) => {
|
|
638
631
|
if (this._abortSignal) {
|
|
639
632
|
if (this._abortSignal.aborted)
|
|
640
|
-
return this.state = "cancel", this.close(),
|
|
633
|
+
return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
641
634
|
this._abortSignal.addEventListener("abort", () => {
|
|
642
635
|
this.state = "cancel", this.close();
|
|
643
636
|
}, { once: true });
|
|
@@ -649,179 +642,102 @@ class V {
|
|
|
649
642
|
escapeCodeTimeout: 50,
|
|
650
643
|
terminal: true
|
|
651
644
|
}), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
652
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false),
|
|
645
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
653
646
|
}), this.once("cancel", () => {
|
|
654
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false),
|
|
647
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
655
648
|
});
|
|
656
649
|
});
|
|
657
650
|
}
|
|
658
|
-
_isActionKey(
|
|
659
|
-
return
|
|
651
|
+
_isActionKey(t, e) {
|
|
652
|
+
return t === "\t";
|
|
660
653
|
}
|
|
661
|
-
_shouldSubmit(
|
|
654
|
+
_shouldSubmit(t, e) {
|
|
662
655
|
return true;
|
|
663
656
|
}
|
|
664
|
-
_setValue(
|
|
665
|
-
this.value =
|
|
657
|
+
_setValue(t) {
|
|
658
|
+
this.value = t, this.emit("value", this.value);
|
|
666
659
|
}
|
|
667
|
-
_setUserInput(
|
|
668
|
-
this.userInput =
|
|
660
|
+
_setUserInput(t, e) {
|
|
661
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
669
662
|
}
|
|
670
663
|
_clearUserInput() {
|
|
671
664
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
672
665
|
}
|
|
673
|
-
onKeypress(
|
|
674
|
-
if (this.
|
|
675
|
-
if (this.
|
|
676
|
-
|
|
677
|
-
|
|
666
|
+
async onKeypress(t, e) {
|
|
667
|
+
if (this.state !== "validating") {
|
|
668
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
669
|
+
if (this.opts.validate) {
|
|
670
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
671
|
+
let s;
|
|
672
|
+
i instanceof Promise ? (this.state = "validating", this.render(), s = await i) : s = i, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
|
|
673
|
+
}
|
|
674
|
+
this.state !== "error" && (this.state = "submit");
|
|
678
675
|
}
|
|
679
|
-
this.state
|
|
676
|
+
isActionKey([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
680
677
|
}
|
|
681
|
-
isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
682
678
|
}
|
|
683
679
|
close() {
|
|
684
680
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
685
681
|
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
686
682
|
}
|
|
687
683
|
restoreCursor() {
|
|
688
|
-
const
|
|
684
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
689
685
|
`).length - 1;
|
|
690
|
-
this.output.write(import_sisteransi.cursor.move(-999,
|
|
686
|
+
this.output.write(import_sisteransi.cursor.move(-999, t * -1));
|
|
691
687
|
}
|
|
692
688
|
render() {
|
|
693
|
-
const
|
|
689
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
694
690
|
hard: true,
|
|
695
691
|
trim: false
|
|
696
692
|
});
|
|
697
|
-
if (
|
|
693
|
+
if (t !== this._prevFrame) {
|
|
698
694
|
if (this.state === "initial")
|
|
699
695
|
this.output.write(import_sisteransi.cursor.hide);
|
|
700
696
|
else {
|
|
701
|
-
const e = diffLines(this._prevFrame,
|
|
697
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
702
698
|
if (this.restoreCursor(), e) {
|
|
703
|
-
const
|
|
704
|
-
let
|
|
705
|
-
if (
|
|
706
|
-
this._prevFrame =
|
|
699
|
+
const s = Math.max(0, e.numLinesAfter - i), r = Math.max(0, e.numLinesBefore - i);
|
|
700
|
+
let n = e.lines.find((o) => o >= s);
|
|
701
|
+
if (n === undefined) {
|
|
702
|
+
this._prevFrame = t;
|
|
707
703
|
return;
|
|
708
704
|
}
|
|
709
705
|
if (e.lines.length === 1) {
|
|
710
|
-
this.output.write(import_sisteransi.cursor.move(0,
|
|
711
|
-
const o =
|
|
706
|
+
this.output.write(import_sisteransi.cursor.move(0, n - r)), this.output.write(import_sisteransi.erase.lines(1));
|
|
707
|
+
const o = t.split(`
|
|
712
708
|
`);
|
|
713
|
-
this.output.write(o[
|
|
709
|
+
this.output.write(o[n]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, o.length - n - 1));
|
|
714
710
|
return;
|
|
715
711
|
} else if (e.lines.length > 1) {
|
|
716
|
-
if (
|
|
717
|
-
|
|
712
|
+
if (s < r)
|
|
713
|
+
n = s;
|
|
718
714
|
else {
|
|
719
|
-
const h =
|
|
715
|
+
const h = n - r;
|
|
720
716
|
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
721
717
|
}
|
|
722
718
|
this.output.write(import_sisteransi.erase.down());
|
|
723
|
-
const f =
|
|
724
|
-
`).slice(
|
|
719
|
+
const f = t.split(`
|
|
720
|
+
`).slice(n);
|
|
725
721
|
this.output.write(f.join(`
|
|
726
|
-
`)), this._prevFrame =
|
|
722
|
+
`)), this._prevFrame = t;
|
|
727
723
|
return;
|
|
728
724
|
}
|
|
729
725
|
}
|
|
730
726
|
this.output.write(import_sisteransi.erase.down());
|
|
731
727
|
}
|
|
732
|
-
this.output.write(
|
|
728
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
733
729
|
}
|
|
734
730
|
}
|
|
735
731
|
}
|
|
736
|
-
|
|
737
|
-
if (l2 === undefined || e.length === 0)
|
|
738
|
-
return 0;
|
|
739
|
-
const i = e.findIndex((s) => s.value === l2);
|
|
740
|
-
return i !== -1 ? i : 0;
|
|
741
|
-
}
|
|
742
|
-
function g(l2, e) {
|
|
743
|
-
return (e.label ?? String(e.value)).toLowerCase().includes(l2.toLowerCase());
|
|
744
|
-
}
|
|
745
|
-
function m(l2, e) {
|
|
746
|
-
if (e)
|
|
747
|
-
return l2 ? e : e[0];
|
|
748
|
-
}
|
|
749
|
-
var T$1 = class T extends V {
|
|
750
|
-
filteredOptions;
|
|
751
|
-
multiple;
|
|
752
|
-
isNavigating = false;
|
|
753
|
-
selectedValues = [];
|
|
754
|
-
focusedValue;
|
|
755
|
-
#e = 0;
|
|
756
|
-
#s = "";
|
|
757
|
-
#t;
|
|
758
|
-
#i;
|
|
759
|
-
#n;
|
|
760
|
-
get cursor() {
|
|
761
|
-
return this.#e;
|
|
762
|
-
}
|
|
763
|
-
get userInputWithCursor() {
|
|
764
|
-
if (!this.userInput)
|
|
765
|
-
return styleText(["inverse", "hidden"], "_");
|
|
766
|
-
if (this._cursor >= this.userInput.length)
|
|
767
|
-
return `${this.userInput}█`;
|
|
768
|
-
const e = this.userInput.slice(0, this.cursor), t2 = this.userInput.slice(this.cursor, this.cursor + 1), i = this.userInput.slice(this.cursor + 1);
|
|
769
|
-
return `${e}${styleText("inverse", t2)}${i}`;
|
|
770
|
-
}
|
|
771
|
-
get options() {
|
|
772
|
-
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
773
|
-
}
|
|
774
|
-
constructor(e) {
|
|
775
|
-
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
776
|
-
const t2 = this.options;
|
|
777
|
-
this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
|
|
778
|
-
let i;
|
|
779
|
-
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0]?.value]), i)
|
|
780
|
-
for (const s of i) {
|
|
781
|
-
const n = t2.findIndex((o) => o.value === s);
|
|
782
|
-
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
783
|
-
}
|
|
784
|
-
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
785
|
-
}
|
|
786
|
-
_isActionKey(e, t2) {
|
|
787
|
-
return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
|
|
788
|
-
}
|
|
789
|
-
#l(e, t2) {
|
|
790
|
-
const i = t2.name === "up", s = t2.name === "down", n = t2.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#n, a = this.options, f = u !== undefined && u !== "" && a.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
|
|
791
|
-
if (t2.name === "tab" && o && f) {
|
|
792
|
-
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
796
|
-
}
|
|
797
|
-
deselectAll() {
|
|
798
|
-
this.selectedValues = [];
|
|
799
|
-
}
|
|
800
|
-
toggleSelected(e) {
|
|
801
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
802
|
-
}
|
|
803
|
-
#u(e) {
|
|
804
|
-
if (e !== this.#s) {
|
|
805
|
-
this.#s = e;
|
|
806
|
-
const t2 = this.options;
|
|
807
|
-
e && this.#t ? this.filteredOptions = t2.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t2];
|
|
808
|
-
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
809
|
-
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
810
|
-
const s = this.filteredOptions[this.#e];
|
|
811
|
-
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
};
|
|
815
|
-
|
|
816
|
-
class r extends V {
|
|
732
|
+
class r extends y {
|
|
817
733
|
get cursor() {
|
|
818
734
|
return this.value ? 0 : 1;
|
|
819
735
|
}
|
|
820
736
|
get _value() {
|
|
821
737
|
return this.cursor === 0;
|
|
822
738
|
}
|
|
823
|
-
constructor(
|
|
824
|
-
super(
|
|
739
|
+
constructor(t) {
|
|
740
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
825
741
|
this.value = this._value;
|
|
826
742
|
}), this.on("confirm", (i) => {
|
|
827
743
|
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
@@ -830,366 +746,7 @@ class r extends V {
|
|
|
830
746
|
});
|
|
831
747
|
}
|
|
832
748
|
}
|
|
833
|
-
|
|
834
|
-
Y: { type: "year", len: 4 },
|
|
835
|
-
M: { type: "month", len: 2 },
|
|
836
|
-
D: { type: "day", len: 2 }
|
|
837
|
-
};
|
|
838
|
-
function M(r2) {
|
|
839
|
-
return [...r2].map((t2) => _[t2]);
|
|
840
|
-
}
|
|
841
|
-
function P(r2) {
|
|
842
|
-
const i = new Intl.DateTimeFormat(r2, {
|
|
843
|
-
year: "numeric",
|
|
844
|
-
month: "2-digit",
|
|
845
|
-
day: "2-digit"
|
|
846
|
-
}).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
847
|
-
let n = "/";
|
|
848
|
-
for (const e of i)
|
|
849
|
-
e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
|
|
850
|
-
return { segments: s, separator: n };
|
|
851
|
-
}
|
|
852
|
-
function p(r2) {
|
|
853
|
-
return Number.parseInt((r2 || "0").replace(/_/g, "0"), 10) || 0;
|
|
854
|
-
}
|
|
855
|
-
function f(r2) {
|
|
856
|
-
return {
|
|
857
|
-
year: p(r2.year),
|
|
858
|
-
month: p(r2.month),
|
|
859
|
-
day: p(r2.day)
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
function c(r2, t2) {
|
|
863
|
-
return new Date(r2 || 2001, t2 || 1, 0).getDate();
|
|
864
|
-
}
|
|
865
|
-
function b(r2) {
|
|
866
|
-
const { year: t2, month: i, day: s } = f(r2);
|
|
867
|
-
if (!t2 || t2 < 0 || t2 > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
|
|
868
|
-
return;
|
|
869
|
-
const n = new Date(Date.UTC(t2, i - 1, s));
|
|
870
|
-
if (!(n.getUTCFullYear() !== t2 || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
871
|
-
return { year: t2, month: i, day: s };
|
|
872
|
-
}
|
|
873
|
-
function C(r2) {
|
|
874
|
-
const t2 = b(r2);
|
|
875
|
-
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
|
|
876
|
-
}
|
|
877
|
-
function T2(r2, t2, i, s) {
|
|
878
|
-
const n = i ? {
|
|
879
|
-
year: i.getUTCFullYear(),
|
|
880
|
-
month: i.getUTCMonth() + 1,
|
|
881
|
-
day: i.getUTCDate()
|
|
882
|
-
} : null, e = s ? {
|
|
883
|
-
year: s.getUTCFullYear(),
|
|
884
|
-
month: s.getUTCMonth() + 1,
|
|
885
|
-
day: s.getUTCDate()
|
|
886
|
-
} : null;
|
|
887
|
-
return r2 === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r2 === "month" ? {
|
|
888
|
-
min: n && t2.year === n.year ? n.month : 1,
|
|
889
|
-
max: e && t2.year === e.year ? e.month : 12
|
|
890
|
-
} : {
|
|
891
|
-
min: n && t2.year === n.year && t2.month === n.month ? n.day : 1,
|
|
892
|
-
max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
class U extends V {
|
|
897
|
-
#i;
|
|
898
|
-
#o;
|
|
899
|
-
#t;
|
|
900
|
-
#h;
|
|
901
|
-
#u;
|
|
902
|
-
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
903
|
-
#n = true;
|
|
904
|
-
#s = null;
|
|
905
|
-
inlineError = "";
|
|
906
|
-
get segmentCursor() {
|
|
907
|
-
return { ...this.#e };
|
|
908
|
-
}
|
|
909
|
-
get segmentValues() {
|
|
910
|
-
return { ...this.#t };
|
|
911
|
-
}
|
|
912
|
-
get segments() {
|
|
913
|
-
return this.#i;
|
|
914
|
-
}
|
|
915
|
-
get separator() {
|
|
916
|
-
return this.#o;
|
|
917
|
-
}
|
|
918
|
-
get formattedValue() {
|
|
919
|
-
return this.#l(this.#t);
|
|
920
|
-
}
|
|
921
|
-
#l(t2) {
|
|
922
|
-
return this.#i.map((i) => t2[i.type]).join(this.#o);
|
|
923
|
-
}
|
|
924
|
-
#r() {
|
|
925
|
-
this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
|
|
926
|
-
}
|
|
927
|
-
constructor(t2) {
|
|
928
|
-
const i = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i.separator, n = t2.format ? M(t2.format) : i.segments, e = t2.initialValue ?? t2.defaultValue, m2 = e ? {
|
|
929
|
-
year: String(e.getUTCFullYear()).padStart(4, "0"),
|
|
930
|
-
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
931
|
-
day: String(e.getUTCDate()).padStart(2, "0")
|
|
932
|
-
} : { year: "____", month: "__", day: "__" }, o = n.map((a) => m2[a.type]).join(s);
|
|
933
|
-
super({ ...t2, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m2, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t2));
|
|
934
|
-
}
|
|
935
|
-
#a() {
|
|
936
|
-
const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t2];
|
|
937
|
-
if (i)
|
|
938
|
-
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), { segment: i, index: t2 };
|
|
939
|
-
}
|
|
940
|
-
#m(t2) {
|
|
941
|
-
this.inlineError = "", this.#s = null;
|
|
942
|
-
const i = this.#a();
|
|
943
|
-
i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
|
|
944
|
-
}
|
|
945
|
-
#d(t2) {
|
|
946
|
-
const i = this.#a();
|
|
947
|
-
if (!i)
|
|
948
|
-
return;
|
|
949
|
-
const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m2 = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f(this.#t), this.#h, this.#u);
|
|
950
|
-
let a;
|
|
951
|
-
e ? a = t2 === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m2 + t2), o.min), this.#t = {
|
|
952
|
-
...this.#t,
|
|
953
|
-
[s.type]: a.toString().padStart(s.len, "0")
|
|
954
|
-
}, this.#n = true, this.#s = null, this.#r();
|
|
955
|
-
}
|
|
956
|
-
#f(t2) {
|
|
957
|
-
if (t2)
|
|
958
|
-
switch (t2) {
|
|
959
|
-
case "right":
|
|
960
|
-
return this.#m(1);
|
|
961
|
-
case "left":
|
|
962
|
-
return this.#m(-1);
|
|
963
|
-
case "up":
|
|
964
|
-
return this.#d(1);
|
|
965
|
-
case "down":
|
|
966
|
-
return this.#d(-1);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
#y(t2, i) {
|
|
970
|
-
if (i?.name === "backspace" || i?.sequence === "" || i?.sequence === "\b" || t2 === "" || t2 === "\b") {
|
|
971
|
-
this.inlineError = "";
|
|
972
|
-
const n = this.#a();
|
|
973
|
-
if (!n)
|
|
974
|
-
return;
|
|
975
|
-
if (!this.#t[n.segment.type].replace(/_/g, "")) {
|
|
976
|
-
this.#m(-1);
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
if (i?.name === "tab") {
|
|
983
|
-
this.inlineError = "";
|
|
984
|
-
const n = this.#a();
|
|
985
|
-
if (!n)
|
|
986
|
-
return;
|
|
987
|
-
const e = i.shift ? -1 : 1, m2 = n.index + e;
|
|
988
|
-
m2 >= 0 && m2 < this.#i.length && (this.#e.segmentIndex = m2, this.#e.positionInSegment = 0, this.#n = true);
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
if (t2 && /^[0-9]$/.test(t2)) {
|
|
992
|
-
const n = this.#a();
|
|
993
|
-
if (!n)
|
|
994
|
-
return;
|
|
995
|
-
const { segment: e } = n, m2 = !this.#t[e.type].replace(/_/g, "");
|
|
996
|
-
if (this.#n && this.#s !== null && !m2) {
|
|
997
|
-
const h = this.#s + t2, d = { ...this.#t, [e.type]: h }, g2 = this.#g(d, e);
|
|
998
|
-
if (g2) {
|
|
999
|
-
this.inlineError = g2, this.#s = null, this.#n = false;
|
|
1000
|
-
return;
|
|
1001
|
-
}
|
|
1002
|
-
this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
this.#n && !m2 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
1006
|
-
const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
|
|
1007
|
-
if (u < 0 || u >= e.len)
|
|
1008
|
-
return;
|
|
1009
|
-
let l2 = o.slice(0, u) + t2 + o.slice(u + 1), D = false;
|
|
1010
|
-
if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
|
|
1011
|
-
const h = Number.parseInt(t2, 10);
|
|
1012
|
-
l2 = `0${t2}`, D = h <= (e.type === "month" ? 1 : 2);
|
|
1013
|
-
}
|
|
1014
|
-
if (e.type === "year" && (l2 = (o.replace(/_/g, "") + t2).padStart(e.len, "_")), !l2.includes("_")) {
|
|
1015
|
-
const h = { ...this.#t, [e.type]: l2 }, d = this.#g(h, e);
|
|
1016
|
-
if (d) {
|
|
1017
|
-
this.inlineError = d;
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
this.inlineError = "", this.#t[e.type] = l2;
|
|
1022
|
-
const y = l2.includes("_") ? undefined : b(this.#t);
|
|
1023
|
-
if (y) {
|
|
1024
|
-
const { year: h, month: d } = y, g2 = c(h, d);
|
|
1025
|
-
this.#t = {
|
|
1026
|
-
year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
|
|
1027
|
-
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
1028
|
-
day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
this.#r();
|
|
1032
|
-
const S = l2.indexOf("_");
|
|
1033
|
-
D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
#g(t2, i) {
|
|
1037
|
-
const { month: s, day: n } = f(t2);
|
|
1038
|
-
if (i.type === "month" && (s < 0 || s > 12))
|
|
1039
|
-
return settings.date.messages.invalidMonth;
|
|
1040
|
-
if (i.type === "day" && (n < 0 || n > 31))
|
|
1041
|
-
return settings.date.messages.invalidDay(31, "any month");
|
|
1042
|
-
}
|
|
1043
|
-
#p(t2) {
|
|
1044
|
-
const { year: i, month: s, day: n } = f(this.#t);
|
|
1045
|
-
if (i && s && n) {
|
|
1046
|
-
const e = c(i, s);
|
|
1047
|
-
this.#t = {
|
|
1048
|
-
...this.#t,
|
|
1049
|
-
day: String(Math.min(n, e)).padStart(2, "0")
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
var u$2 = class u extends V {
|
|
1056
|
-
options;
|
|
1057
|
-
cursor = 0;
|
|
1058
|
-
#t;
|
|
1059
|
-
getGroupItems(t2) {
|
|
1060
|
-
return this.options.filter((r2) => r2.group === t2);
|
|
1061
|
-
}
|
|
1062
|
-
isGroupSelected(t2) {
|
|
1063
|
-
const r2 = this.getGroupItems(t2), e = this.value;
|
|
1064
|
-
return e === undefined ? false : r2.every((s) => e.includes(s.value));
|
|
1065
|
-
}
|
|
1066
|
-
toggleValue() {
|
|
1067
|
-
const t2 = this.options[this.cursor];
|
|
1068
|
-
if (t2 !== undefined)
|
|
1069
|
-
if (this.value === undefined && (this.value = []), t2.group === true) {
|
|
1070
|
-
const r2 = t2.value, e = this.getGroupItems(r2);
|
|
1071
|
-
this.isGroupSelected(r2) ? this.value = this.value.filter((s) => e.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
1072
|
-
} else {
|
|
1073
|
-
const r2 = this.value.includes(t2.value);
|
|
1074
|
-
this.value = r2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
constructor(t2) {
|
|
1078
|
-
super(t2, false);
|
|
1079
|
-
const { options: r2 } = t2;
|
|
1080
|
-
this.#t = t2.selectableGroups !== false, this.options = Object.entries(r2).flatMap(([e, s]) => [
|
|
1081
|
-
{ value: e, group: true, label: e },
|
|
1082
|
-
...s.map((i) => ({ ...i, group: e }))
|
|
1083
|
-
]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
|
|
1084
|
-
switch (e) {
|
|
1085
|
-
case "left":
|
|
1086
|
-
case "up": {
|
|
1087
|
-
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1088
|
-
const s = this.options[this.cursor]?.group === true;
|
|
1089
|
-
!this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1090
|
-
break;
|
|
1091
|
-
}
|
|
1092
|
-
case "down":
|
|
1093
|
-
case "right": {
|
|
1094
|
-
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1095
|
-
const s = this.options[this.cursor]?.group === true;
|
|
1096
|
-
!this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1097
|
-
break;
|
|
1098
|
-
}
|
|
1099
|
-
case "space":
|
|
1100
|
-
this.toggleValue();
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
var o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
1107
|
-
|
|
1108
|
-
class h extends V {
|
|
1109
|
-
#t = false;
|
|
1110
|
-
#s;
|
|
1111
|
-
focused = "editor";
|
|
1112
|
-
get userInputWithCursor() {
|
|
1113
|
-
if (this.state === "submit")
|
|
1114
|
-
return this.userInput;
|
|
1115
|
-
const t2 = this.userInput;
|
|
1116
|
-
if (this.cursor >= t2.length)
|
|
1117
|
-
return `${t2}█`;
|
|
1118
|
-
const s = t2.slice(0, this.cursor), r2 = t2.slice(this.cursor, this.cursor + 1), i = t2.slice(this.cursor + 1);
|
|
1119
|
-
return r2 === `
|
|
1120
|
-
` ? `${s}█
|
|
1121
|
-
${i}` : `${s}${styleText("inverse", r2)}${i}`;
|
|
1122
|
-
}
|
|
1123
|
-
get cursor() {
|
|
1124
|
-
return this._cursor;
|
|
1125
|
-
}
|
|
1126
|
-
#r(t2) {
|
|
1127
|
-
if (this.userInput.length === 0) {
|
|
1128
|
-
this._setUserInput(t2);
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
|
|
1132
|
-
}
|
|
1133
|
-
#i(t2) {
|
|
1134
|
-
const s = this.value ?? "";
|
|
1135
|
-
switch (t2) {
|
|
1136
|
-
case "up":
|
|
1137
|
-
this._cursor = findTextCursor(this._cursor, 0, -1, s);
|
|
1138
|
-
return;
|
|
1139
|
-
case "down":
|
|
1140
|
-
this._cursor = findTextCursor(this._cursor, 0, 1, s);
|
|
1141
|
-
return;
|
|
1142
|
-
case "left":
|
|
1143
|
-
this._cursor = findTextCursor(this._cursor, -1, 0, s);
|
|
1144
|
-
return;
|
|
1145
|
-
case "right":
|
|
1146
|
-
this._cursor = findTextCursor(this._cursor, 1, 0, s);
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
_shouldSubmit(t2, s) {
|
|
1151
|
-
if (this.#s)
|
|
1152
|
-
return this.focused === "submit" ? true : (this.#r(`
|
|
1153
|
-
`), this._cursor++, false);
|
|
1154
|
-
const r2 = this.#t;
|
|
1155
|
-
return this.#t = true, r2 && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
|
|
1156
|
-
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
|
|
1157
|
-
`), this._cursor++, false);
|
|
1158
|
-
}
|
|
1159
|
-
constructor(t2) {
|
|
1160
|
-
const s = t2.initialUserInput ?? t2.initialValue;
|
|
1161
|
-
super({
|
|
1162
|
-
...t2,
|
|
1163
|
-
initialUserInput: s
|
|
1164
|
-
}, false), s !== undefined && (this._cursor = s.length), this.#s = t2.showSubmit ?? false, this.on("key", (r2, i) => {
|
|
1165
|
-
if (i?.name && o.has(i.name)) {
|
|
1166
|
-
this.#t = false, this.#i(i.name);
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
if (r2 === "\t" && this.#s) {
|
|
1170
|
-
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
1171
|
-
return;
|
|
1172
|
-
}
|
|
1173
|
-
if (i?.name !== "return") {
|
|
1174
|
-
if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
|
|
1175
|
-
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
1176
|
-
return;
|
|
1177
|
-
}
|
|
1178
|
-
if (i?.name === "delete" && this.cursor < this.userInput.length) {
|
|
1179
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
1180
|
-
return;
|
|
1181
|
-
}
|
|
1182
|
-
r2 && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r2 ?? ""), this._cursor++);
|
|
1183
|
-
}
|
|
1184
|
-
}), this.on("userInput", (r2) => {
|
|
1185
|
-
this._setValue(r2);
|
|
1186
|
-
}), this.on("finalize", () => {
|
|
1187
|
-
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
class a extends V {
|
|
749
|
+
class a extends y {
|
|
1193
750
|
options;
|
|
1194
751
|
cursor = 0;
|
|
1195
752
|
get _value() {
|
|
@@ -1200,14 +757,14 @@ class a extends V {
|
|
|
1200
757
|
}
|
|
1201
758
|
toggleAll() {
|
|
1202
759
|
const e = this._enabledOptions, i = this.value !== undefined && this.value.length === e.length;
|
|
1203
|
-
this.value = i ? [] : e.map((
|
|
760
|
+
this.value = i ? [] : e.map((t) => t.value);
|
|
1204
761
|
}
|
|
1205
762
|
toggleInvert() {
|
|
1206
763
|
const e = this.value;
|
|
1207
764
|
if (!e)
|
|
1208
765
|
return;
|
|
1209
|
-
const i = this._enabledOptions.filter((
|
|
1210
|
-
this.value = i.map((
|
|
766
|
+
const i = this._enabledOptions.filter((t) => !e.includes(t.value));
|
|
767
|
+
this.value = i.map((t) => t.value);
|
|
1211
768
|
}
|
|
1212
769
|
toggleValue() {
|
|
1213
770
|
this.value === undefined && (this.value = []);
|
|
@@ -1216,11 +773,11 @@ class a extends V {
|
|
|
1216
773
|
}
|
|
1217
774
|
constructor(e) {
|
|
1218
775
|
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
1219
|
-
const i = Math.max(this.options.findIndex(({ value:
|
|
1220
|
-
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (
|
|
1221
|
-
|
|
1222
|
-
}), this.on("cursor", (
|
|
1223
|
-
switch (
|
|
776
|
+
const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
|
|
777
|
+
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
|
|
778
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
779
|
+
}), this.on("cursor", (t) => {
|
|
780
|
+
switch (t) {
|
|
1224
781
|
case "left":
|
|
1225
782
|
case "up":
|
|
1226
783
|
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
@@ -1236,7 +793,7 @@ class a extends V {
|
|
|
1236
793
|
});
|
|
1237
794
|
}
|
|
1238
795
|
}
|
|
1239
|
-
var u$1 = class
|
|
796
|
+
var u$1 = class u extends y {
|
|
1240
797
|
_mask = "•";
|
|
1241
798
|
get cursor() {
|
|
1242
799
|
return this._cursor;
|
|
@@ -1247,24 +804,24 @@ var u$1 = class u2 extends V {
|
|
|
1247
804
|
get userInputWithCursor() {
|
|
1248
805
|
if (this.state === "submit" || this.state === "cancel")
|
|
1249
806
|
return this.masked;
|
|
1250
|
-
const
|
|
1251
|
-
if (this.cursor >=
|
|
807
|
+
const t = this.userInput;
|
|
808
|
+
if (this.cursor >= t.length)
|
|
1252
809
|
return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
|
|
1253
|
-
const s = this.masked,
|
|
1254
|
-
return `${
|
|
810
|
+
const s = this.masked, r = s.slice(0, this.cursor), i = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
|
|
811
|
+
return `${r}${styleText("inverse", i)}${o}`;
|
|
1255
812
|
}
|
|
1256
813
|
clear() {
|
|
1257
814
|
this._clearUserInput();
|
|
1258
815
|
}
|
|
1259
|
-
constructor({ mask:
|
|
1260
|
-
super(s), this._mask =
|
|
1261
|
-
this._setValue(
|
|
816
|
+
constructor({ mask: t, ...s }) {
|
|
817
|
+
super(s), this._mask = t ?? "•", this.on("userInput", (r) => {
|
|
818
|
+
this._setValue(r);
|
|
1262
819
|
}), this.on("finalize", () => {
|
|
1263
820
|
this.value === undefined && (this.value = "");
|
|
1264
821
|
});
|
|
1265
822
|
}
|
|
1266
823
|
};
|
|
1267
|
-
var n$1 = class n extends
|
|
824
|
+
var n$1 = class n extends y {
|
|
1268
825
|
options;
|
|
1269
826
|
cursor = 0;
|
|
1270
827
|
get _selectedValue() {
|
|
@@ -1276,8 +833,8 @@ var n$1 = class n extends V {
|
|
|
1276
833
|
}
|
|
1277
834
|
constructor(e) {
|
|
1278
835
|
super(e, false), this.options = e.options;
|
|
1279
|
-
const
|
|
1280
|
-
this.cursor = this.options[
|
|
836
|
+
const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t = o === -1 ? 0 : o;
|
|
837
|
+
this.cursor = this.options[t]?.disabled ? findCursor(t, 1, this.options) : t, this.changeValue(), this.on("cursor", (s) => {
|
|
1281
838
|
switch (s) {
|
|
1282
839
|
case "left":
|
|
1283
840
|
case "up":
|
|
@@ -1292,27 +849,27 @@ var n$1 = class n extends V {
|
|
|
1292
849
|
});
|
|
1293
850
|
}
|
|
1294
851
|
};
|
|
1295
|
-
class
|
|
852
|
+
class n extends y {
|
|
1296
853
|
get userInputWithCursor() {
|
|
1297
854
|
if (this.state === "submit")
|
|
1298
855
|
return this.userInput;
|
|
1299
|
-
const
|
|
1300
|
-
if (this.cursor >=
|
|
856
|
+
const t = this.userInput;
|
|
857
|
+
if (this.cursor >= t.length)
|
|
1301
858
|
return `${this.userInput}█`;
|
|
1302
|
-
const
|
|
1303
|
-
return `${
|
|
859
|
+
const r = t.slice(0, this.cursor), s = t.slice(this.cursor, this.cursor + 1), e = t.slice(this.cursor + 1);
|
|
860
|
+
return `${r}${styleText("inverse", s)}${e}`;
|
|
1304
861
|
}
|
|
1305
862
|
get cursor() {
|
|
1306
863
|
return this._cursor;
|
|
1307
864
|
}
|
|
1308
|
-
constructor(
|
|
865
|
+
constructor(t) {
|
|
1309
866
|
super({
|
|
1310
|
-
...
|
|
1311
|
-
initialUserInput:
|
|
1312
|
-
}), this.on("userInput", (
|
|
1313
|
-
this._setValue(
|
|
867
|
+
...t,
|
|
868
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
869
|
+
}), this.on("userInput", (r) => {
|
|
870
|
+
this._setValue(r);
|
|
1314
871
|
}), this.on("finalize", () => {
|
|
1315
|
-
this.value || (this.value =
|
|
872
|
+
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
1316
873
|
});
|
|
1317
874
|
}
|
|
1318
875
|
}
|
|
@@ -1329,8 +886,8 @@ function isUnicodeSupported() {
|
|
|
1329
886
|
}
|
|
1330
887
|
var unicode = isUnicodeSupported();
|
|
1331
888
|
var isCI = () => process.env.CI === "true";
|
|
1332
|
-
var isTTY = (
|
|
1333
|
-
var unicodeOr = (
|
|
889
|
+
var isTTY = (o) => o.isTTY === true;
|
|
890
|
+
var unicodeOr = (o, e) => unicode ? o : e;
|
|
1334
891
|
var S_STEP_ACTIVE = unicodeOr("◆", "*");
|
|
1335
892
|
var S_STEP_CANCEL = unicodeOr("■", "x");
|
|
1336
893
|
var S_STEP_ERROR = unicodeOr("▲", "x");
|
|
@@ -1356,8 +913,8 @@ var S_INFO = unicodeOr("●", "•");
|
|
|
1356
913
|
var S_SUCCESS = unicodeOr("◆", "*");
|
|
1357
914
|
var S_WARN = unicodeOr("▲", "!");
|
|
1358
915
|
var S_ERROR = unicodeOr("■", "x");
|
|
1359
|
-
var symbol = (
|
|
1360
|
-
switch (
|
|
916
|
+
var symbol = (o) => {
|
|
917
|
+
switch (o) {
|
|
1361
918
|
case "initial":
|
|
1362
919
|
case "active":
|
|
1363
920
|
return styleText2("cyan", S_STEP_ACTIVE);
|
|
@@ -1367,37 +924,39 @@ var symbol = (o2) => {
|
|
|
1367
924
|
return styleText2("yellow", S_STEP_ERROR);
|
|
1368
925
|
case "submit":
|
|
1369
926
|
return styleText2("green", S_STEP_SUBMIT);
|
|
927
|
+
case "validating":
|
|
928
|
+
return styleText2("dim", S_STEP_ACTIVE);
|
|
1370
929
|
}
|
|
1371
930
|
};
|
|
1372
|
-
var confirm = (
|
|
1373
|
-
const
|
|
931
|
+
var confirm = (e) => {
|
|
932
|
+
const a = e.active ?? "Yes", o = e.inactive ?? "No";
|
|
1374
933
|
return new r({
|
|
1375
|
-
active:
|
|
1376
|
-
inactive:
|
|
1377
|
-
signal:
|
|
1378
|
-
input:
|
|
1379
|
-
output:
|
|
1380
|
-
initialValue:
|
|
934
|
+
active: a,
|
|
935
|
+
inactive: o,
|
|
936
|
+
signal: e.signal,
|
|
937
|
+
input: e.input,
|
|
938
|
+
output: e.output,
|
|
939
|
+
initialValue: e.initialValue ?? true,
|
|
1381
940
|
render() {
|
|
1382
|
-
const
|
|
1383
|
-
` : ""}${
|
|
1384
|
-
`,
|
|
941
|
+
const i = e.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = i ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(e.output, e.message, l, u), s = `${i ? `${styleText2("gray", S_BAR)}
|
|
942
|
+
` : ""}${f}
|
|
943
|
+
`, c = this.value ? a : o;
|
|
1385
944
|
switch (this.state) {
|
|
1386
945
|
case "submit": {
|
|
1387
|
-
const
|
|
1388
|
-
return `${
|
|
946
|
+
const r = i ? `${styleText2("gray", S_BAR)} ` : "";
|
|
947
|
+
return `${s}${r}${styleText2("dim", c)}`;
|
|
1389
948
|
}
|
|
1390
949
|
case "cancel": {
|
|
1391
|
-
const
|
|
1392
|
-
return `${
|
|
950
|
+
const r = i ? `${styleText2("gray", S_BAR)} ` : "";
|
|
951
|
+
return `${s}${r}${styleText2(["strikethrough", "dim"], c)}${i ? `
|
|
1393
952
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1394
953
|
}
|
|
1395
954
|
default: {
|
|
1396
|
-
const
|
|
1397
|
-
return `${
|
|
955
|
+
const r = i ? `${styleText2("cyan", S_BAR)} ` : "", g = i ? styleText2("cyan", S_BAR_END) : "";
|
|
956
|
+
return `${s}${r}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a)}`}${e.vertical ? i ? `
|
|
1398
957
|
${styleText2("cyan", S_BAR)} ` : `
|
|
1399
|
-
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim",
|
|
1400
|
-
${
|
|
958
|
+
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", o)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${o}`}
|
|
959
|
+
${g}
|
|
1401
960
|
`;
|
|
1402
961
|
}
|
|
1403
962
|
}
|
|
@@ -1412,23 +971,23 @@ var MULTISELECT_INSTRUCTIONS = [
|
|
|
1412
971
|
var log = {
|
|
1413
972
|
message: (s = [], {
|
|
1414
973
|
symbol: e = styleText2("gray", S_BAR),
|
|
1415
|
-
secondarySymbol:
|
|
1416
|
-
output:
|
|
1417
|
-
spacing:
|
|
1418
|
-
withGuide:
|
|
974
|
+
secondarySymbol: r = styleText2("gray", S_BAR),
|
|
975
|
+
output: m = process.stdout,
|
|
976
|
+
spacing: l = 1,
|
|
977
|
+
withGuide: c
|
|
1419
978
|
} = {}) => {
|
|
1420
|
-
const
|
|
1421
|
-
for (let i = 0;i <
|
|
1422
|
-
|
|
1423
|
-
const
|
|
979
|
+
const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
|
|
980
|
+
for (let i = 0;i < l; i++)
|
|
981
|
+
t.push(f);
|
|
982
|
+
const g = Array.isArray(s) ? s : s.split(`
|
|
1424
983
|
`);
|
|
1425
|
-
if (
|
|
1426
|
-
const [i, ...y] =
|
|
1427
|
-
i.length > 0 ?
|
|
1428
|
-
for (const
|
|
1429
|
-
|
|
984
|
+
if (g.length > 0) {
|
|
985
|
+
const [i, ...y] = g;
|
|
986
|
+
i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
|
|
987
|
+
for (const p of y)
|
|
988
|
+
p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
|
|
1430
989
|
}
|
|
1431
|
-
|
|
990
|
+
m.write(`${t.join(`
|
|
1432
991
|
`)}
|
|
1433
992
|
`);
|
|
1434
993
|
},
|
|
@@ -1451,157 +1010,157 @@ var log = {
|
|
|
1451
1010
|
log.message(s, { ...e, symbol: styleText2("red", S_ERROR) });
|
|
1452
1011
|
}
|
|
1453
1012
|
};
|
|
1454
|
-
var cancel = (
|
|
1455
|
-
const i =
|
|
1456
|
-
i.write(`${e}${styleText2("red",
|
|
1013
|
+
var cancel = (o = "", t) => {
|
|
1014
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
1015
|
+
i.write(`${e}${styleText2("red", o)}
|
|
1457
1016
|
|
|
1458
1017
|
`);
|
|
1459
1018
|
};
|
|
1460
|
-
var intro = (
|
|
1461
|
-
const i =
|
|
1462
|
-
i.write(`${e}${
|
|
1019
|
+
var intro = (o = "", t) => {
|
|
1020
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
1021
|
+
i.write(`${e}${o}
|
|
1463
1022
|
`);
|
|
1464
1023
|
};
|
|
1465
|
-
var outro = (
|
|
1466
|
-
const i =
|
|
1024
|
+
var outro = (o = "", t) => {
|
|
1025
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
1467
1026
|
${styleText2("gray", S_BAR_END)} ` : "";
|
|
1468
|
-
i.write(`${e}${
|
|
1027
|
+
i.write(`${e}${o}
|
|
1469
1028
|
|
|
1470
1029
|
`);
|
|
1471
1030
|
};
|
|
1472
|
-
var password = (
|
|
1473
|
-
validate:
|
|
1474
|
-
mask:
|
|
1475
|
-
signal:
|
|
1476
|
-
input:
|
|
1477
|
-
output:
|
|
1031
|
+
var password = (e) => new u$1({
|
|
1032
|
+
validate: e.validate,
|
|
1033
|
+
mask: e.mask ?? S_PASSWORD_MASK,
|
|
1034
|
+
signal: e.signal,
|
|
1035
|
+
input: e.input,
|
|
1036
|
+
output: e.output,
|
|
1478
1037
|
render() {
|
|
1479
|
-
const
|
|
1480
|
-
` : ""}${symbol(this.state)} ${
|
|
1481
|
-
`,
|
|
1038
|
+
const r = e.withGuide ?? settings.withGuide, o = `${r ? `${styleText2("gray", S_BAR)}
|
|
1039
|
+
` : ""}${symbol(this.state)} ${e.message}
|
|
1040
|
+
`, m = this.userInputWithCursor, i = this.masked;
|
|
1482
1041
|
switch (this.state) {
|
|
1483
1042
|
case "error": {
|
|
1484
|
-
const s =
|
|
1485
|
-
return
|
|
1486
|
-
${s}${
|
|
1487
|
-
${
|
|
1043
|
+
const s = r ? `${styleText2("yellow", S_BAR)} ` : "", n = r ? `${styleText2("yellow", S_BAR_END)} ` : "", d = i ?? "";
|
|
1044
|
+
return e.clearOnError && this.clear(), `${o.trim()}
|
|
1045
|
+
${s}${d}
|
|
1046
|
+
${n}${styleText2("yellow", this.error)}
|
|
1488
1047
|
`;
|
|
1489
1048
|
}
|
|
1490
1049
|
case "submit": {
|
|
1491
|
-
const s =
|
|
1492
|
-
return `${
|
|
1050
|
+
const s = r ? `${styleText2("gray", S_BAR)} ` : "", n = i ? styleText2("dim", i) : "";
|
|
1051
|
+
return `${o}${s}${n}`;
|
|
1493
1052
|
}
|
|
1494
1053
|
case "cancel": {
|
|
1495
|
-
const s =
|
|
1496
|
-
return `${
|
|
1054
|
+
const s = r ? `${styleText2("gray", S_BAR)} ` : "", n = i ? styleText2(["strikethrough", "dim"], i) : "";
|
|
1055
|
+
return `${o}${s}${n}${i && r ? `
|
|
1497
1056
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1498
1057
|
}
|
|
1499
1058
|
default: {
|
|
1500
|
-
const s =
|
|
1501
|
-
return `${
|
|
1502
|
-
${
|
|
1059
|
+
const s = r ? `${styleText2("cyan", S_BAR)} ` : "", n = r ? styleText2("cyan", S_BAR_END) : "";
|
|
1060
|
+
return `${o}${s}${m}
|
|
1061
|
+
${n}
|
|
1503
1062
|
`;
|
|
1504
1063
|
}
|
|
1505
1064
|
}
|
|
1506
1065
|
}
|
|
1507
1066
|
}).prompt();
|
|
1508
|
-
var W = (
|
|
1067
|
+
var W = (l) => styleText2("magenta", l);
|
|
1509
1068
|
var spinner = ({
|
|
1510
|
-
indicator:
|
|
1511
|
-
onCancel:
|
|
1512
|
-
output:
|
|
1069
|
+
indicator: l = "dots",
|
|
1070
|
+
onCancel: h,
|
|
1071
|
+
output: n = process.stdout,
|
|
1513
1072
|
cancelMessage: G,
|
|
1514
1073
|
errorMessage: O,
|
|
1515
1074
|
frames: E = unicode ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"],
|
|
1516
1075
|
delay: F = unicode ? 80 : 120,
|
|
1517
|
-
signal:
|
|
1076
|
+
signal: m,
|
|
1518
1077
|
...I
|
|
1519
1078
|
} = {}) => {
|
|
1520
|
-
const
|
|
1521
|
-
let
|
|
1522
|
-
const x = getColumns(
|
|
1523
|
-
const
|
|
1524
|
-
S = e === 1, d && (
|
|
1525
|
-
},
|
|
1526
|
-
process.on("uncaughtExceptionMonitor",
|
|
1079
|
+
const u = isCI();
|
|
1080
|
+
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
1081
|
+
const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
|
|
1082
|
+
const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1083
|
+
S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
|
|
1084
|
+
}, f = () => g(2), i = () => g(1), A = () => {
|
|
1085
|
+
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
|
|
1527
1086
|
}, H = () => {
|
|
1528
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1087
|
+
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
|
|
1529
1088
|
}, y = () => {
|
|
1530
|
-
if (
|
|
1089
|
+
if (p === undefined)
|
|
1531
1090
|
return;
|
|
1532
|
-
|
|
1091
|
+
u && n.write(`
|
|
1533
1092
|
`);
|
|
1534
|
-
const
|
|
1093
|
+
const r = wrapAnsi(p, x, {
|
|
1535
1094
|
hard: true,
|
|
1536
1095
|
trim: false
|
|
1537
1096
|
}).split(`
|
|
1538
1097
|
`);
|
|
1539
|
-
|
|
1540
|
-
},
|
|
1541
|
-
const
|
|
1542
|
-
return
|
|
1543
|
-
}, N = I.withGuide ?? settings.withGuide,
|
|
1544
|
-
d = true,
|
|
1098
|
+
r.length > 1 && n.write(import_sisteransi2.cursor.up(r.length - 1)), n.write(import_sisteransi2.cursor.to(0)), n.write(import_sisteransi2.erase.down());
|
|
1099
|
+
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1100
|
+
const r = (performance.now() - e) / 1000, t = Math.floor(r / 60), o = Math.floor(r % 60);
|
|
1101
|
+
return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
|
|
1102
|
+
}, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1103
|
+
d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText2("gray", S_BAR)}
|
|
1545
1104
|
`);
|
|
1546
|
-
let
|
|
1547
|
-
A(),
|
|
1548
|
-
if (
|
|
1105
|
+
let r = 0, t = 0;
|
|
1106
|
+
A(), T = setInterval(() => {
|
|
1107
|
+
if (u && s === p)
|
|
1549
1108
|
return;
|
|
1550
|
-
y(),
|
|
1551
|
-
const
|
|
1109
|
+
y(), p = s;
|
|
1110
|
+
const o = k(E[r]);
|
|
1552
1111
|
let v;
|
|
1553
|
-
if (
|
|
1554
|
-
v = `${
|
|
1555
|
-
else if (
|
|
1556
|
-
v = `${
|
|
1112
|
+
if (u)
|
|
1113
|
+
v = `${o} ${s}...`;
|
|
1114
|
+
else if (l === "timer")
|
|
1115
|
+
v = `${o} ${s} ${_(w)}`;
|
|
1557
1116
|
else {
|
|
1558
|
-
const B = ".".repeat(Math.floor(
|
|
1559
|
-
v = `${
|
|
1117
|
+
const B = ".".repeat(Math.floor(t)).slice(0, 3);
|
|
1118
|
+
v = `${o} ${s}${B}`;
|
|
1560
1119
|
}
|
|
1561
1120
|
const j = wrapAnsi(v, x, {
|
|
1562
1121
|
hard: true,
|
|
1563
1122
|
trim: false
|
|
1564
1123
|
});
|
|
1565
|
-
|
|
1124
|
+
n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + 0.125 : 0;
|
|
1566
1125
|
}, F);
|
|
1567
|
-
},
|
|
1126
|
+
}, a = (e = "", r = 0, t = false) => {
|
|
1568
1127
|
if (!d)
|
|
1569
1128
|
return;
|
|
1570
|
-
d = false, clearInterval(
|
|
1571
|
-
const
|
|
1572
|
-
s = e ?? s,
|
|
1573
|
-
`) :
|
|
1574
|
-
`)), H(),
|
|
1129
|
+
d = false, clearInterval(T), y();
|
|
1130
|
+
const o = r === 0 ? styleText2("green", S_STEP_SUBMIT) : r === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
1131
|
+
s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
|
|
1132
|
+
`) : n.write(`${o} ${s}
|
|
1133
|
+
`)), H(), M();
|
|
1575
1134
|
};
|
|
1576
1135
|
return {
|
|
1577
|
-
start:
|
|
1578
|
-
stop: (e = "") =>
|
|
1136
|
+
start: P,
|
|
1137
|
+
stop: (e = "") => a(e, 0),
|
|
1579
1138
|
message: (e = "") => {
|
|
1580
|
-
s =
|
|
1139
|
+
s = C(e ?? s);
|
|
1581
1140
|
},
|
|
1582
|
-
cancel: (e = "") =>
|
|
1583
|
-
error: (e = "") =>
|
|
1584
|
-
clear: () =>
|
|
1141
|
+
cancel: (e = "") => a(e, 1),
|
|
1142
|
+
error: (e = "") => a(e, 2),
|
|
1143
|
+
clear: () => a("", 0, true),
|
|
1585
1144
|
get isCancelled() {
|
|
1586
1145
|
return S;
|
|
1587
1146
|
}
|
|
1588
1147
|
};
|
|
1589
1148
|
};
|
|
1590
|
-
var
|
|
1149
|
+
var u2 = {
|
|
1591
1150
|
light: unicodeOr("─", "-"),
|
|
1592
1151
|
heavy: unicodeOr("━", "="),
|
|
1593
1152
|
block: unicodeOr("█", "#")
|
|
1594
1153
|
};
|
|
1595
1154
|
function progress({
|
|
1596
|
-
style:
|
|
1155
|
+
style: o = "heavy",
|
|
1597
1156
|
max: d = 100,
|
|
1598
1157
|
size: v = 40,
|
|
1599
1158
|
...x
|
|
1600
1159
|
} = {}) {
|
|
1601
|
-
const
|
|
1602
|
-
let
|
|
1603
|
-
const
|
|
1604
|
-
switch (
|
|
1160
|
+
const r = spinner(x);
|
|
1161
|
+
let a = 0, n = "";
|
|
1162
|
+
const c = Math.max(1, d), l = Math.max(1, v), S = (t) => {
|
|
1163
|
+
switch (t) {
|
|
1605
1164
|
case "initial":
|
|
1606
1165
|
case "active":
|
|
1607
1166
|
return (e) => styleText2("magenta", e);
|
|
@@ -1613,23 +1172,23 @@ function progress({
|
|
|
1613
1172
|
default:
|
|
1614
1173
|
return (e) => styleText2("magenta", e);
|
|
1615
1174
|
}
|
|
1616
|
-
},
|
|
1617
|
-
const
|
|
1618
|
-
return `${S(
|
|
1619
|
-
},
|
|
1620
|
-
|
|
1621
|
-
},
|
|
1622
|
-
|
|
1175
|
+
}, p = (t, e) => {
|
|
1176
|
+
const m = Math.floor(a / c * l);
|
|
1177
|
+
return `${S(t)(u2[o].repeat(m))}${styleText2("dim", u2[o].repeat(l - m))} ${e}`;
|
|
1178
|
+
}, h = (t = "") => {
|
|
1179
|
+
n = t, r.start(p("initial", t));
|
|
1180
|
+
}, g = (t = 1, e) => {
|
|
1181
|
+
a = Math.min(c, t + a), r.message(p("active", e ?? n)), n = e ?? n;
|
|
1623
1182
|
};
|
|
1624
1183
|
return {
|
|
1625
|
-
start:
|
|
1626
|
-
stop:
|
|
1627
|
-
cancel:
|
|
1628
|
-
error:
|
|
1629
|
-
clear:
|
|
1630
|
-
advance:
|
|
1631
|
-
isCancelled:
|
|
1632
|
-
message: (
|
|
1184
|
+
start: h,
|
|
1185
|
+
stop: r.stop,
|
|
1186
|
+
cancel: r.cancel,
|
|
1187
|
+
error: r.error,
|
|
1188
|
+
clear: r.clear,
|
|
1189
|
+
advance: g,
|
|
1190
|
+
isCancelled: r.isCancelled,
|
|
1191
|
+
message: (t) => g(0, t)
|
|
1633
1192
|
};
|
|
1634
1193
|
}
|
|
1635
1194
|
var SELECT_INSTRUCTIONS = [
|
|
@@ -1637,39 +1196,45 @@ var SELECT_INSTRUCTIONS = [
|
|
|
1637
1196
|
`${styleText2("dim", "Enter:")} confirm`
|
|
1638
1197
|
];
|
|
1639
1198
|
var i = `${styleText2("gray", S_BAR)} `;
|
|
1640
|
-
var text = (
|
|
1641
|
-
validate:
|
|
1642
|
-
placeholder:
|
|
1643
|
-
defaultValue:
|
|
1644
|
-
initialValue:
|
|
1645
|
-
output:
|
|
1646
|
-
signal:
|
|
1647
|
-
input:
|
|
1199
|
+
var text = (t) => new n({
|
|
1200
|
+
validate: t.validate,
|
|
1201
|
+
placeholder: t.placeholder,
|
|
1202
|
+
defaultValue: t.defaultValue,
|
|
1203
|
+
initialValue: t.initialValue,
|
|
1204
|
+
output: t.output,
|
|
1205
|
+
signal: t.signal,
|
|
1206
|
+
input: t.input,
|
|
1648
1207
|
render() {
|
|
1649
|
-
const
|
|
1650
|
-
` : ""}${symbol(this.state)} `}${
|
|
1651
|
-
`,
|
|
1208
|
+
const r = t?.withGuide ?? settings.withGuide, l = `${`${r ? `${styleText2("gray", S_BAR)}
|
|
1209
|
+
` : ""}${symbol(this.state)} `}${t.message}
|
|
1210
|
+
`, d = t.placeholder && t.placeholder.length > 0 ? styleText2("inverse", t.placeholder[0]) + styleText2("dim", t.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
|
|
1652
1211
|
switch (this.state) {
|
|
1212
|
+
case "validating": {
|
|
1213
|
+
const n = r ? `${styleText2("cyan", S_BAR)} ` : "", i = r ? styleText2("cyan", S_BAR_END) : "", c = styleText2("dim", o), $ = styleText2("dim", "Validating...");
|
|
1214
|
+
return `${l}${n}${c}
|
|
1215
|
+
${i} ${$}
|
|
1216
|
+
`;
|
|
1217
|
+
}
|
|
1653
1218
|
case "error": {
|
|
1654
|
-
const
|
|
1655
|
-
return `${
|
|
1656
|
-
${
|
|
1657
|
-
${
|
|
1219
|
+
const n = this.error ? ` ${styleText2("yellow", this.error)}` : "", i = r ? `${styleText2("yellow", S_BAR)} ` : "", c = r ? styleText2("yellow", S_BAR_END) : "";
|
|
1220
|
+
return `${l.trim()}
|
|
1221
|
+
${i}${o}
|
|
1222
|
+
${c}${n}
|
|
1658
1223
|
`;
|
|
1659
1224
|
}
|
|
1660
1225
|
case "submit": {
|
|
1661
|
-
const
|
|
1662
|
-
return `${
|
|
1226
|
+
const n = s ? `${r ? " " : ""}${styleText2("dim", s)}` : "", i = r ? styleText2("gray", S_BAR) : "";
|
|
1227
|
+
return `${l}${i}${n}`;
|
|
1663
1228
|
}
|
|
1664
1229
|
case "cancel": {
|
|
1665
|
-
const
|
|
1666
|
-
return `${
|
|
1667
|
-
${
|
|
1230
|
+
const n = s ? ` ${styleText2(["strikethrough", "dim"], s)}` : "", i = r ? styleText2("gray", S_BAR) : "";
|
|
1231
|
+
return `${l}${i}${n}${s.trim() ? `
|
|
1232
|
+
${i}` : ""}`;
|
|
1668
1233
|
}
|
|
1669
1234
|
default: {
|
|
1670
|
-
const
|
|
1671
|
-
return `${
|
|
1672
|
-
${
|
|
1235
|
+
const n = r ? `${styleText2("cyan", S_BAR)} ` : "", i = r ? styleText2("cyan", S_BAR_END) : "";
|
|
1236
|
+
return `${l}${n}${o}
|
|
1237
|
+
${i}
|
|
1673
1238
|
`;
|
|
1674
1239
|
}
|
|
1675
1240
|
}
|
|
@@ -1772,7 +1337,7 @@ function isUnicodeSupported2() {
|
|
|
1772
1337
|
}
|
|
1773
1338
|
var unicode2 = isUnicodeSupported2();
|
|
1774
1339
|
var isCI2 = () => process.env.CI === "true";
|
|
1775
|
-
var unicodeOr2 = (
|
|
1340
|
+
var unicodeOr2 = (o, e) => unicode2 ? o : e;
|
|
1776
1341
|
var S_STEP_ACTIVE2 = unicodeOr2("◆", "*");
|
|
1777
1342
|
var S_STEP_CANCEL2 = unicodeOr2("■", "x");
|
|
1778
1343
|
var S_STEP_ERROR2 = unicodeOr2("▲", "x");
|
|
@@ -1798,8 +1363,8 @@ var S_INFO2 = unicodeOr2("●", "•");
|
|
|
1798
1363
|
var S_SUCCESS2 = unicodeOr2("◆", "*");
|
|
1799
1364
|
var S_WARN2 = unicodeOr2("▲", "!");
|
|
1800
1365
|
var S_ERROR2 = unicodeOr2("■", "x");
|
|
1801
|
-
var symbol2 = (
|
|
1802
|
-
switch (
|
|
1366
|
+
var symbol2 = (o) => {
|
|
1367
|
+
switch (o) {
|
|
1803
1368
|
case "initial":
|
|
1804
1369
|
case "active":
|
|
1805
1370
|
return styleText3("cyan", S_STEP_ACTIVE2);
|
|
@@ -1809,10 +1374,12 @@ var symbol2 = (o2) => {
|
|
|
1809
1374
|
return styleText3("yellow", S_STEP_ERROR2);
|
|
1810
1375
|
case "submit":
|
|
1811
1376
|
return styleText3("green", S_STEP_SUBMIT2);
|
|
1377
|
+
case "validating":
|
|
1378
|
+
return styleText3("dim", S_STEP_ACTIVE2);
|
|
1812
1379
|
}
|
|
1813
1380
|
};
|
|
1814
|
-
var symbolBar = (
|
|
1815
|
-
switch (
|
|
1381
|
+
var symbolBar = (o) => {
|
|
1382
|
+
switch (o) {
|
|
1816
1383
|
case "initial":
|
|
1817
1384
|
case "active":
|
|
1818
1385
|
return styleText3("cyan", S_BAR2);
|
|
@@ -1824,94 +1391,94 @@ var symbolBar = (o2) => {
|
|
|
1824
1391
|
return styleText3("green", S_BAR2);
|
|
1825
1392
|
}
|
|
1826
1393
|
};
|
|
1827
|
-
function formatInstructionFooter(
|
|
1828
|
-
const
|
|
1829
|
-
return e &&
|
|
1830
|
-
}
|
|
1831
|
-
var I = (
|
|
1832
|
-
let
|
|
1833
|
-
if (
|
|
1834
|
-
for (let
|
|
1835
|
-
const
|
|
1836
|
-
if (
|
|
1394
|
+
function formatInstructionFooter(o, e) {
|
|
1395
|
+
const r = [`${e ? `${styleText3("cyan", S_BAR2)} ` : ""}${o.join(" • ")}`];
|
|
1396
|
+
return e && r.push(styleText3("cyan", S_BAR_END2)), r;
|
|
1397
|
+
}
|
|
1398
|
+
var I = (l, e, w, p, b, C = false) => {
|
|
1399
|
+
let r = e, O = 0;
|
|
1400
|
+
if (C)
|
|
1401
|
+
for (let i = p - 1;i >= w; i--) {
|
|
1402
|
+
const m = l[i];
|
|
1403
|
+
if (m && (r -= m.length), O++, r <= b)
|
|
1837
1404
|
break;
|
|
1838
1405
|
}
|
|
1839
1406
|
else
|
|
1840
|
-
for (let
|
|
1841
|
-
const
|
|
1842
|
-
if (
|
|
1407
|
+
for (let i = w;i < p; i++) {
|
|
1408
|
+
const m = l[i];
|
|
1409
|
+
if (m && (r -= m.length), O++, r <= b)
|
|
1843
1410
|
break;
|
|
1844
1411
|
}
|
|
1845
|
-
return { lineCount:
|
|
1412
|
+
return { lineCount: r, removals: O };
|
|
1846
1413
|
};
|
|
1847
1414
|
var limitOptions = ({
|
|
1848
|
-
cursor:
|
|
1415
|
+
cursor: l,
|
|
1849
1416
|
options: e,
|
|
1850
1417
|
style: w,
|
|
1851
|
-
output:
|
|
1852
|
-
maxItems:
|
|
1853
|
-
columnPadding:
|
|
1854
|
-
rowPadding:
|
|
1418
|
+
output: p = process.stdout,
|
|
1419
|
+
maxItems: b = Number.POSITIVE_INFINITY,
|
|
1420
|
+
columnPadding: C = 0,
|
|
1421
|
+
rowPadding: r = 4
|
|
1855
1422
|
}) => {
|
|
1856
|
-
const
|
|
1857
|
-
let
|
|
1858
|
-
|
|
1859
|
-
let d =
|
|
1860
|
-
const
|
|
1861
|
-
let
|
|
1862
|
-
d &&
|
|
1863
|
-
const
|
|
1864
|
-
for (let
|
|
1865
|
-
const
|
|
1423
|
+
const i = getColumns(p) - C, m = getRows(p), M = styleText3("dim", "..."), v = Math.max(m - r, 0), a = Math.max(Math.min(b, v), 5);
|
|
1424
|
+
let f = 0;
|
|
1425
|
+
l >= a - 3 && (f = Math.max(Math.min(l - a + 3, e.length - a), 0));
|
|
1426
|
+
let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
|
|
1427
|
+
const W = Math.min(f + a, e.length), s = [];
|
|
1428
|
+
let g = 0;
|
|
1429
|
+
d && g++, c && g++;
|
|
1430
|
+
const T = f + (d ? 1 : 0), y = W - (c ? 1 : 0);
|
|
1431
|
+
for (let t = T;t < y; t++) {
|
|
1432
|
+
const n = e[t], o = n ? w(n, t === l) : "", h = wrapAnsi(o, i, {
|
|
1866
1433
|
hard: true,
|
|
1867
1434
|
trim: false
|
|
1868
1435
|
}).split(`
|
|
1869
1436
|
`);
|
|
1870
|
-
s.push(
|
|
1437
|
+
s.push(h), g += h.length;
|
|
1871
1438
|
}
|
|
1872
|
-
if (
|
|
1873
|
-
let
|
|
1874
|
-
const
|
|
1875
|
-
let
|
|
1876
|
-
const L = () => I(s,
|
|
1877
|
-
d ? ({ lineCount:
|
|
1439
|
+
if (g > v) {
|
|
1440
|
+
let t = 0, n = 0, o = g;
|
|
1441
|
+
const h = l - T;
|
|
1442
|
+
let u = v;
|
|
1443
|
+
const L = () => I(s, o, 0, h, u), E = () => I(s, o, h + 1, s.length, u, true);
|
|
1444
|
+
d ? ({ lineCount: o, removals: t } = L(), o > u && (c || (u -= 1), { lineCount: o, removals: n } = E())) : (c || (u -= 1), { lineCount: o, removals: n } = E(), o > u && (u -= 1, { lineCount: o, removals: t } = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
|
|
1878
1445
|
}
|
|
1879
1446
|
const x = [];
|
|
1880
|
-
d && x.push(
|
|
1881
|
-
for (const
|
|
1882
|
-
for (const
|
|
1883
|
-
x.push(
|
|
1884
|
-
return
|
|
1447
|
+
d && x.push(M);
|
|
1448
|
+
for (const t of s)
|
|
1449
|
+
for (const n of t)
|
|
1450
|
+
x.push(n);
|
|
1451
|
+
return c && x.push(M), x;
|
|
1885
1452
|
};
|
|
1886
|
-
var confirm2 = (
|
|
1887
|
-
const
|
|
1453
|
+
var confirm2 = (e) => {
|
|
1454
|
+
const a = e.active ?? "Yes", o = e.inactive ?? "No";
|
|
1888
1455
|
return new r({
|
|
1889
|
-
active:
|
|
1890
|
-
inactive:
|
|
1891
|
-
signal:
|
|
1892
|
-
input:
|
|
1893
|
-
output:
|
|
1894
|
-
initialValue:
|
|
1456
|
+
active: a,
|
|
1457
|
+
inactive: o,
|
|
1458
|
+
signal: e.signal,
|
|
1459
|
+
input: e.input,
|
|
1460
|
+
output: e.output,
|
|
1461
|
+
initialValue: e.initialValue ?? true,
|
|
1895
1462
|
render() {
|
|
1896
|
-
const
|
|
1897
|
-
` : ""}${
|
|
1898
|
-
`,
|
|
1463
|
+
const i = e.withGuide ?? settings.withGuide, u = `${symbol2(this.state)} `, l = i ? `${styleText3("gray", S_BAR2)} ` : "", f = wrapTextWithPrefix(e.output, e.message, l, u), s = `${i ? `${styleText3("gray", S_BAR2)}
|
|
1464
|
+
` : ""}${f}
|
|
1465
|
+
`, c = this.value ? a : o;
|
|
1899
1466
|
switch (this.state) {
|
|
1900
1467
|
case "submit": {
|
|
1901
|
-
const
|
|
1902
|
-
return `${
|
|
1468
|
+
const r = i ? `${styleText3("gray", S_BAR2)} ` : "";
|
|
1469
|
+
return `${s}${r}${styleText3("dim", c)}`;
|
|
1903
1470
|
}
|
|
1904
1471
|
case "cancel": {
|
|
1905
|
-
const
|
|
1906
|
-
return `${
|
|
1472
|
+
const r = i ? `${styleText3("gray", S_BAR2)} ` : "";
|
|
1473
|
+
return `${s}${r}${styleText3(["strikethrough", "dim"], c)}${i ? `
|
|
1907
1474
|
${styleText3("gray", S_BAR2)}` : ""}`;
|
|
1908
1475
|
}
|
|
1909
1476
|
default: {
|
|
1910
|
-
const
|
|
1911
|
-
return `${
|
|
1477
|
+
const r = i ? `${styleText3("cyan", S_BAR2)} ` : "", g = i ? styleText3("cyan", S_BAR_END2) : "";
|
|
1478
|
+
return `${s}${r}${this.value ? `${styleText3("green", S_RADIO_ACTIVE2)} ${a}` : `${styleText3("dim", S_RADIO_INACTIVE2)} ${styleText3("dim", a)}`}${e.vertical ? i ? `
|
|
1912
1479
|
${styleText3("cyan", S_BAR2)} ` : `
|
|
1913
|
-
` : ` ${styleText3("dim", "/")} `}${this.value ? `${styleText3("dim", S_RADIO_INACTIVE2)} ${styleText3("dim",
|
|
1914
|
-
${
|
|
1480
|
+
` : ` ${styleText3("dim", "/")} `}${this.value ? `${styleText3("dim", S_RADIO_INACTIVE2)} ${styleText3("dim", o)}` : `${styleText3("green", S_RADIO_ACTIVE2)} ${o}`}
|
|
1481
|
+
${g}
|
|
1915
1482
|
`;
|
|
1916
1483
|
}
|
|
1917
1484
|
}
|
|
@@ -1923,83 +1490,83 @@ var MULTISELECT_INSTRUCTIONS2 = [
|
|
|
1923
1490
|
`${styleText3("dim", "Space:")} select`,
|
|
1924
1491
|
`${styleText3("dim", "Enter:")} confirm`
|
|
1925
1492
|
];
|
|
1926
|
-
var
|
|
1927
|
-
`).map((d) =>
|
|
1493
|
+
var m = (i, u) => i.split(`
|
|
1494
|
+
`).map((d) => u(d)).join(`
|
|
1928
1495
|
`);
|
|
1929
|
-
var multiselect = (
|
|
1930
|
-
const
|
|
1931
|
-
const
|
|
1932
|
-
return
|
|
1933
|
-
}, d =
|
|
1496
|
+
var multiselect = (i) => {
|
|
1497
|
+
const u = (t, a) => {
|
|
1498
|
+
const r = t.label ?? String(t.value);
|
|
1499
|
+
return a === "disabled" ? `${styleText3("gray", S_CHECKBOX_INACTIVE2)} ${m(r, (o) => styleText3(["strikethrough", "gray"], o))}${t.hint ? ` ${styleText3("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${styleText3("cyan", S_CHECKBOX_ACTIVE2)} ${r}${t.hint ? ` ${styleText3("dim", `(${t.hint})`)}` : ""}` : a === "selected" ? `${styleText3("green", S_CHECKBOX_SELECTED2)} ${m(r, (o) => styleText3("dim", o))}${t.hint ? ` ${styleText3("dim", `(${t.hint})`)}` : ""}` : a === "cancelled" ? `${m(r, (o) => styleText3(["strikethrough", "dim"], o))}` : a === "active-selected" ? `${styleText3("green", S_CHECKBOX_SELECTED2)} ${r}${t.hint ? ` ${styleText3("dim", `(${t.hint})`)}` : ""}` : a === "submitted" ? `${m(r, (o) => styleText3("dim", o))}` : `${styleText3("dim", S_CHECKBOX_INACTIVE2)} ${m(r, (o) => styleText3("dim", o))}`;
|
|
1500
|
+
}, d = i.required ?? true, x = i.showInstructions ?? true;
|
|
1934
1501
|
return new a({
|
|
1935
|
-
options:
|
|
1936
|
-
signal:
|
|
1937
|
-
input:
|
|
1938
|
-
output:
|
|
1939
|
-
initialValues:
|
|
1502
|
+
options: i.options,
|
|
1503
|
+
signal: i.signal,
|
|
1504
|
+
input: i.input,
|
|
1505
|
+
output: i.output,
|
|
1506
|
+
initialValues: i.initialValues,
|
|
1940
1507
|
required: d,
|
|
1941
|
-
cursorAt:
|
|
1942
|
-
validate(
|
|
1943
|
-
if (d && (
|
|
1508
|
+
cursorAt: i.cursorAt,
|
|
1509
|
+
validate(t) {
|
|
1510
|
+
if (d && (t === undefined || t.length === 0))
|
|
1944
1511
|
return `Please select at least one option.
|
|
1945
1512
|
${styleText3("reset", styleText3("dim", `Press ${styleText3(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText3("gray", styleText3("bgWhite", styleText3("inverse", " enter ")))} to submit`))}`;
|
|
1946
1513
|
},
|
|
1947
1514
|
render() {
|
|
1948
|
-
const
|
|
1949
|
-
` : ""}${
|
|
1950
|
-
`,
|
|
1951
|
-
if (
|
|
1952
|
-
return
|
|
1953
|
-
const s =
|
|
1954
|
-
return
|
|
1515
|
+
const t = i.withGuide ?? settings.withGuide, a = wrapTextWithPrefix(i.output, i.message, t ? `${symbolBar(this.state)} ` : "", `${symbol2(this.state)} `), r = `${t ? `${styleText3("gray", S_BAR2)}
|
|
1516
|
+
` : ""}${a}
|
|
1517
|
+
`, o = this.value ?? [], g = (n, l) => {
|
|
1518
|
+
if (n.disabled)
|
|
1519
|
+
return u(n, "disabled");
|
|
1520
|
+
const s = o.includes(n.value);
|
|
1521
|
+
return l && s ? u(n, "active-selected") : s ? u(n, "selected") : u(n, l ? "active" : "inactive");
|
|
1955
1522
|
};
|
|
1956
1523
|
switch (this.state) {
|
|
1957
1524
|
case "submit": {
|
|
1958
|
-
const
|
|
1959
|
-
return `${
|
|
1525
|
+
const n = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "submitted")).join(styleText3("dim", ", ")) || styleText3("dim", "none"), l = wrapTextWithPrefix(i.output, n, t ? `${styleText3("gray", S_BAR2)} ` : "");
|
|
1526
|
+
return `${r}${l}`;
|
|
1960
1527
|
}
|
|
1961
1528
|
case "cancel": {
|
|
1962
|
-
const
|
|
1963
|
-
if (
|
|
1964
|
-
return `${
|
|
1965
|
-
const
|
|
1966
|
-
return `${
|
|
1529
|
+
const n = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "cancelled")).join(styleText3("dim", ", "));
|
|
1530
|
+
if (n.trim() === "")
|
|
1531
|
+
return `${r}${styleText3("gray", S_BAR2)}`;
|
|
1532
|
+
const l = wrapTextWithPrefix(i.output, n, t ? `${styleText3("gray", S_BAR2)} ` : "");
|
|
1533
|
+
return `${r}${l}${t ? `
|
|
1967
1534
|
${styleText3("gray", S_BAR2)}` : ""}`;
|
|
1968
1535
|
}
|
|
1969
1536
|
case "error": {
|
|
1970
|
-
const
|
|
1971
|
-
`).map(($,
|
|
1972
|
-
`), s =
|
|
1973
|
-
`).length,
|
|
1537
|
+
const n = t ? `${styleText3("yellow", S_BAR2)} ` : "", l = this.error.split(`
|
|
1538
|
+
`).map(($, v) => v === 0 ? `${t ? `${styleText3("yellow", S_BAR_END2)} ` : ""}${styleText3("yellow", $)}` : ` ${$}`).join(`
|
|
1539
|
+
`), s = r.split(`
|
|
1540
|
+
`).length, h = l.split(`
|
|
1974
1541
|
`).length + 1;
|
|
1975
|
-
return `${
|
|
1976
|
-
output:
|
|
1542
|
+
return `${r}${n}${limitOptions({
|
|
1543
|
+
output: i.output,
|
|
1977
1544
|
options: this.options,
|
|
1978
1545
|
cursor: this.cursor,
|
|
1979
|
-
maxItems:
|
|
1980
|
-
columnPadding:
|
|
1981
|
-
rowPadding: s +
|
|
1982
|
-
style:
|
|
1546
|
+
maxItems: i.maxItems,
|
|
1547
|
+
columnPadding: n.length,
|
|
1548
|
+
rowPadding: s + h,
|
|
1549
|
+
style: g
|
|
1983
1550
|
}).join(`
|
|
1984
|
-
${
|
|
1985
|
-
${
|
|
1551
|
+
${n}`)}
|
|
1552
|
+
${l}
|
|
1986
1553
|
`;
|
|
1987
1554
|
}
|
|
1988
1555
|
default: {
|
|
1989
|
-
const
|
|
1990
|
-
`).length, s =
|
|
1556
|
+
const n = t ? `${styleText3("cyan", S_BAR2)} ` : "", l = r.split(`
|
|
1557
|
+
`).length, s = x ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS2, t) : t ? [styleText3("cyan", S_BAR_END2)] : [], h = s.join(`
|
|
1991
1558
|
`), $ = s.length + 1;
|
|
1992
|
-
return `${
|
|
1993
|
-
output:
|
|
1559
|
+
return `${r}${n}${limitOptions({
|
|
1560
|
+
output: i.output,
|
|
1994
1561
|
options: this.options,
|
|
1995
1562
|
cursor: this.cursor,
|
|
1996
|
-
maxItems:
|
|
1997
|
-
columnPadding:
|
|
1998
|
-
rowPadding:
|
|
1999
|
-
style:
|
|
1563
|
+
maxItems: i.maxItems,
|
|
1564
|
+
columnPadding: n.length,
|
|
1565
|
+
rowPadding: l + $,
|
|
1566
|
+
style: g
|
|
2000
1567
|
}).join(`
|
|
2001
|
-
${
|
|
2002
|
-
${
|
|
1568
|
+
${n}`)}
|
|
1569
|
+
${h}
|
|
2003
1570
|
`;
|
|
2004
1571
|
}
|
|
2005
1572
|
}
|
|
@@ -2009,23 +1576,23 @@ ${h2}
|
|
|
2009
1576
|
var log2 = {
|
|
2010
1577
|
message: (s = [], {
|
|
2011
1578
|
symbol: e = styleText3("gray", S_BAR2),
|
|
2012
|
-
secondarySymbol:
|
|
2013
|
-
output:
|
|
2014
|
-
spacing:
|
|
2015
|
-
withGuide:
|
|
1579
|
+
secondarySymbol: r = styleText3("gray", S_BAR2),
|
|
1580
|
+
output: m = process.stdout,
|
|
1581
|
+
spacing: l = 1,
|
|
1582
|
+
withGuide: c
|
|
2016
1583
|
} = {}) => {
|
|
2017
|
-
const
|
|
2018
|
-
for (let
|
|
2019
|
-
|
|
2020
|
-
const
|
|
1584
|
+
const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
|
|
1585
|
+
for (let i = 0;i < l; i++)
|
|
1586
|
+
t.push(f);
|
|
1587
|
+
const g = Array.isArray(s) ? s : s.split(`
|
|
2021
1588
|
`);
|
|
2022
|
-
if (
|
|
2023
|
-
const [
|
|
2024
|
-
|
|
2025
|
-
for (const
|
|
2026
|
-
|
|
1589
|
+
if (g.length > 0) {
|
|
1590
|
+
const [i, ...y] = g;
|
|
1591
|
+
i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
|
|
1592
|
+
for (const p of y)
|
|
1593
|
+
p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
|
|
2027
1594
|
}
|
|
2028
|
-
|
|
1595
|
+
m.write(`${t.join(`
|
|
2029
1596
|
`)}
|
|
2030
1597
|
`);
|
|
2031
1598
|
},
|
|
@@ -2048,107 +1615,107 @@ var log2 = {
|
|
|
2048
1615
|
log2.message(s, { ...e, symbol: styleText3("red", S_ERROR2) });
|
|
2049
1616
|
}
|
|
2050
1617
|
};
|
|
2051
|
-
var cancel2 = (
|
|
2052
|
-
const
|
|
2053
|
-
|
|
1618
|
+
var cancel2 = (o = "", t) => {
|
|
1619
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText3("gray", S_BAR_END2)} ` : "";
|
|
1620
|
+
i.write(`${e}${styleText3("red", o)}
|
|
2054
1621
|
|
|
2055
1622
|
`);
|
|
2056
1623
|
};
|
|
2057
|
-
var intro2 = (
|
|
2058
|
-
const
|
|
2059
|
-
|
|
1624
|
+
var intro2 = (o = "", t) => {
|
|
1625
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText3("gray", S_BAR_START2)} ` : "";
|
|
1626
|
+
i.write(`${e}${o}
|
|
2060
1627
|
`);
|
|
2061
1628
|
};
|
|
2062
|
-
var outro2 = (
|
|
2063
|
-
const
|
|
1629
|
+
var outro2 = (o = "", t) => {
|
|
1630
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText3("gray", S_BAR2)}
|
|
2064
1631
|
${styleText3("gray", S_BAR_END2)} ` : "";
|
|
2065
|
-
|
|
1632
|
+
i.write(`${e}${o}
|
|
2066
1633
|
|
|
2067
1634
|
`);
|
|
2068
1635
|
};
|
|
2069
|
-
var W2 = (
|
|
1636
|
+
var W2 = (l) => styleText3("magenta", l);
|
|
2070
1637
|
var spinner2 = ({
|
|
2071
|
-
indicator:
|
|
2072
|
-
onCancel:
|
|
2073
|
-
output:
|
|
1638
|
+
indicator: l = "dots",
|
|
1639
|
+
onCancel: h,
|
|
1640
|
+
output: n = process.stdout,
|
|
2074
1641
|
cancelMessage: G,
|
|
2075
1642
|
errorMessage: O,
|
|
2076
1643
|
frames: E = unicode2 ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"],
|
|
2077
1644
|
delay: F = unicode2 ? 80 : 120,
|
|
2078
|
-
signal:
|
|
2079
|
-
...
|
|
1645
|
+
signal: m,
|
|
1646
|
+
...I
|
|
2080
1647
|
} = {}) => {
|
|
2081
|
-
const
|
|
2082
|
-
let
|
|
2083
|
-
const x = getColumns(
|
|
2084
|
-
const
|
|
2085
|
-
S = e === 1, d && (
|
|
2086
|
-
},
|
|
2087
|
-
process.on("uncaughtExceptionMonitor",
|
|
1648
|
+
const u = isCI2();
|
|
1649
|
+
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
1650
|
+
const x = getColumns(n), k = I?.styleFrame ?? W2, g = (e) => {
|
|
1651
|
+
const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1652
|
+
S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
|
|
1653
|
+
}, f = () => g(2), i = () => g(1), A = () => {
|
|
1654
|
+
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
|
|
2088
1655
|
}, H = () => {
|
|
2089
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1656
|
+
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
|
|
2090
1657
|
}, y = () => {
|
|
2091
|
-
if (
|
|
1658
|
+
if (p === undefined)
|
|
2092
1659
|
return;
|
|
2093
|
-
|
|
1660
|
+
u && n.write(`
|
|
2094
1661
|
`);
|
|
2095
|
-
const
|
|
1662
|
+
const r = wrapAnsi(p, x, {
|
|
2096
1663
|
hard: true,
|
|
2097
1664
|
trim: false
|
|
2098
1665
|
}).split(`
|
|
2099
1666
|
`);
|
|
2100
|
-
|
|
2101
|
-
},
|
|
2102
|
-
const
|
|
2103
|
-
return
|
|
2104
|
-
}, N =
|
|
2105
|
-
d = true,
|
|
1667
|
+
r.length > 1 && n.write(import_sisteransi3.cursor.up(r.length - 1)), n.write(import_sisteransi3.cursor.to(0)), n.write(import_sisteransi3.erase.down());
|
|
1668
|
+
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1669
|
+
const r = (performance.now() - e) / 1000, t = Math.floor(r / 60), o = Math.floor(r % 60);
|
|
1670
|
+
return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
|
|
1671
|
+
}, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1672
|
+
d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText3("gray", S_BAR2)}
|
|
2106
1673
|
`);
|
|
2107
|
-
let
|
|
2108
|
-
A(),
|
|
2109
|
-
if (
|
|
1674
|
+
let r = 0, t = 0;
|
|
1675
|
+
A(), T = setInterval(() => {
|
|
1676
|
+
if (u && s === p)
|
|
2110
1677
|
return;
|
|
2111
|
-
y(),
|
|
2112
|
-
const
|
|
1678
|
+
y(), p = s;
|
|
1679
|
+
const o = k(E[r]);
|
|
2113
1680
|
let v;
|
|
2114
|
-
if (
|
|
2115
|
-
v = `${
|
|
2116
|
-
else if (
|
|
2117
|
-
v = `${
|
|
1681
|
+
if (u)
|
|
1682
|
+
v = `${o} ${s}...`;
|
|
1683
|
+
else if (l === "timer")
|
|
1684
|
+
v = `${o} ${s} ${_(w)}`;
|
|
2118
1685
|
else {
|
|
2119
|
-
const B = ".".repeat(Math.floor(
|
|
2120
|
-
v = `${
|
|
1686
|
+
const B = ".".repeat(Math.floor(t)).slice(0, 3);
|
|
1687
|
+
v = `${o} ${s}${B}`;
|
|
2121
1688
|
}
|
|
2122
1689
|
const j = wrapAnsi(v, x, {
|
|
2123
1690
|
hard: true,
|
|
2124
1691
|
trim: false
|
|
2125
1692
|
});
|
|
2126
|
-
|
|
1693
|
+
n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + 0.125 : 0;
|
|
2127
1694
|
}, F);
|
|
2128
|
-
},
|
|
1695
|
+
}, a = (e = "", r = 0, t = false) => {
|
|
2129
1696
|
if (!d)
|
|
2130
1697
|
return;
|
|
2131
|
-
d = false, clearInterval(
|
|
2132
|
-
const
|
|
2133
|
-
s = e ?? s,
|
|
2134
|
-
`) :
|
|
2135
|
-
`)), H(),
|
|
1698
|
+
d = false, clearInterval(T), y();
|
|
1699
|
+
const o = r === 0 ? styleText3("green", S_STEP_SUBMIT2) : r === 1 ? styleText3("red", S_STEP_CANCEL2) : styleText3("red", S_STEP_ERROR2);
|
|
1700
|
+
s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
|
|
1701
|
+
`) : n.write(`${o} ${s}
|
|
1702
|
+
`)), H(), M();
|
|
2136
1703
|
};
|
|
2137
1704
|
return {
|
|
2138
|
-
start:
|
|
2139
|
-
stop: (e = "") =>
|
|
1705
|
+
start: P,
|
|
1706
|
+
stop: (e = "") => a(e, 0),
|
|
2140
1707
|
message: (e = "") => {
|
|
2141
|
-
s =
|
|
1708
|
+
s = C(e ?? s);
|
|
2142
1709
|
},
|
|
2143
|
-
cancel: (e = "") =>
|
|
2144
|
-
error: (e = "") =>
|
|
2145
|
-
clear: () =>
|
|
1710
|
+
cancel: (e = "") => a(e, 1),
|
|
1711
|
+
error: (e = "") => a(e, 2),
|
|
1712
|
+
clear: () => a("", 0, true),
|
|
2146
1713
|
get isCancelled() {
|
|
2147
1714
|
return S;
|
|
2148
1715
|
}
|
|
2149
1716
|
};
|
|
2150
1717
|
};
|
|
2151
|
-
var
|
|
1718
|
+
var u3 = {
|
|
2152
1719
|
light: unicodeOr2("─", "-"),
|
|
2153
1720
|
heavy: unicodeOr2("━", "="),
|
|
2154
1721
|
block: unicodeOr2("█", "#")
|
|
@@ -2157,63 +1724,63 @@ var SELECT_INSTRUCTIONS2 = [
|
|
|
2157
1724
|
`${styleText3("dim", "↑/↓")} to navigate`,
|
|
2158
1725
|
`${styleText3("dim", "Enter:")} confirm`
|
|
2159
1726
|
];
|
|
2160
|
-
var
|
|
2161
|
-
`) ?
|
|
2162
|
-
`).map((d) =>
|
|
2163
|
-
`) :
|
|
2164
|
-
var select = (
|
|
2165
|
-
const
|
|
2166
|
-
if (
|
|
1727
|
+
var c = (t, o) => t.includes(`
|
|
1728
|
+
`) ? t.split(`
|
|
1729
|
+
`).map((d) => o(d)).join(`
|
|
1730
|
+
`) : o(t);
|
|
1731
|
+
var select = (t) => {
|
|
1732
|
+
const o = (n, m) => {
|
|
1733
|
+
if (n === undefined)
|
|
2167
1734
|
return "";
|
|
2168
|
-
const s =
|
|
2169
|
-
switch (
|
|
1735
|
+
const s = n.label ?? String(n.value);
|
|
1736
|
+
switch (m) {
|
|
2170
1737
|
case "disabled":
|
|
2171
|
-
return `${styleText3("gray", S_RADIO_INACTIVE2)} ${
|
|
1738
|
+
return `${styleText3("gray", S_RADIO_INACTIVE2)} ${c(s, (i) => styleText3("gray", i))}${n.hint ? ` ${styleText3("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
|
|
2172
1739
|
case "selected":
|
|
2173
|
-
return `${
|
|
1740
|
+
return `${c(s, (i) => styleText3("dim", i))}`;
|
|
2174
1741
|
case "active":
|
|
2175
|
-
return `${styleText3("green", S_RADIO_ACTIVE2)} ${s}${
|
|
1742
|
+
return `${styleText3("green", S_RADIO_ACTIVE2)} ${s}${n.hint ? ` ${styleText3("dim", `(${n.hint})`)}` : ""}`;
|
|
2176
1743
|
case "cancelled":
|
|
2177
|
-
return `${
|
|
1744
|
+
return `${c(s, (i) => styleText3(["strikethrough", "dim"], i))}`;
|
|
2178
1745
|
default:
|
|
2179
|
-
return `${styleText3("dim", S_RADIO_INACTIVE2)} ${
|
|
1746
|
+
return `${styleText3("dim", S_RADIO_INACTIVE2)} ${c(s, (i) => styleText3("dim", i))}`;
|
|
2180
1747
|
}
|
|
2181
|
-
}, d =
|
|
1748
|
+
}, d = t.showInstructions ?? true;
|
|
2182
1749
|
return new n$1({
|
|
2183
|
-
options:
|
|
2184
|
-
signal:
|
|
2185
|
-
input:
|
|
2186
|
-
output:
|
|
2187
|
-
initialValue:
|
|
1750
|
+
options: t.options,
|
|
1751
|
+
signal: t.signal,
|
|
1752
|
+
input: t.input,
|
|
1753
|
+
output: t.output,
|
|
1754
|
+
initialValue: t.initialValue,
|
|
2188
1755
|
render() {
|
|
2189
|
-
const
|
|
2190
|
-
` : ""}${
|
|
1756
|
+
const n = t.withGuide ?? settings.withGuide, m = `${symbol2(this.state)} `, s = `${symbolBar(this.state)} `, i = wrapTextWithPrefix(t.output, t.message, s, m), u = `${n ? `${styleText3("gray", S_BAR2)}
|
|
1757
|
+
` : ""}${i}
|
|
2191
1758
|
`;
|
|
2192
1759
|
switch (this.state) {
|
|
2193
1760
|
case "submit": {
|
|
2194
|
-
const
|
|
2195
|
-
return `${
|
|
1761
|
+
const r = n ? `${styleText3("gray", S_BAR2)} ` : "", a = wrapTextWithPrefix(t.output, o(this.options[this.cursor], "selected"), r);
|
|
1762
|
+
return `${u}${a}`;
|
|
2196
1763
|
}
|
|
2197
1764
|
case "cancel": {
|
|
2198
|
-
const
|
|
2199
|
-
return `${
|
|
1765
|
+
const r = n ? `${styleText3("gray", S_BAR2)} ` : "", a = wrapTextWithPrefix(t.output, o(this.options[this.cursor], "cancelled"), r);
|
|
1766
|
+
return `${u}${a}${n ? `
|
|
2200
1767
|
${styleText3("gray", S_BAR2)}` : ""}`;
|
|
2201
1768
|
}
|
|
2202
1769
|
default: {
|
|
2203
|
-
const
|
|
2204
|
-
`).length,
|
|
2205
|
-
`),
|
|
2206
|
-
return `${
|
|
2207
|
-
output:
|
|
1770
|
+
const r = n ? `${styleText3("cyan", S_BAR2)} ` : "", a = u.split(`
|
|
1771
|
+
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS2, n) : n ? [styleText3("cyan", S_BAR_END2)] : [], f = p.join(`
|
|
1772
|
+
`), b = p.length + 1;
|
|
1773
|
+
return `${u}${r}${limitOptions({
|
|
1774
|
+
output: t.output,
|
|
2208
1775
|
cursor: this.cursor,
|
|
2209
1776
|
options: this.options,
|
|
2210
|
-
maxItems:
|
|
2211
|
-
columnPadding:
|
|
2212
|
-
rowPadding:
|
|
2213
|
-
style: (
|
|
1777
|
+
maxItems: t.maxItems,
|
|
1778
|
+
columnPadding: r.length,
|
|
1779
|
+
rowPadding: a + b,
|
|
1780
|
+
style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
|
|
2214
1781
|
}).join(`
|
|
2215
|
-
${
|
|
2216
|
-
${
|
|
1782
|
+
${r}`)}
|
|
1783
|
+
${f}
|
|
2217
1784
|
`;
|
|
2218
1785
|
}
|
|
2219
1786
|
}
|
|
@@ -2221,39 +1788,45 @@ ${b2}
|
|
|
2221
1788
|
}).prompt();
|
|
2222
1789
|
};
|
|
2223
1790
|
var i2 = `${styleText3("gray", S_BAR2)} `;
|
|
2224
|
-
var text2 = (
|
|
2225
|
-
validate:
|
|
2226
|
-
placeholder:
|
|
2227
|
-
defaultValue:
|
|
2228
|
-
initialValue:
|
|
2229
|
-
output:
|
|
2230
|
-
signal:
|
|
2231
|
-
input:
|
|
1791
|
+
var text2 = (t) => new n({
|
|
1792
|
+
validate: t.validate,
|
|
1793
|
+
placeholder: t.placeholder,
|
|
1794
|
+
defaultValue: t.defaultValue,
|
|
1795
|
+
initialValue: t.initialValue,
|
|
1796
|
+
output: t.output,
|
|
1797
|
+
signal: t.signal,
|
|
1798
|
+
input: t.input,
|
|
2232
1799
|
render() {
|
|
2233
|
-
const
|
|
2234
|
-
` : ""}${symbol2(this.state)} `}${
|
|
2235
|
-
`,
|
|
1800
|
+
const r = t?.withGuide ?? settings.withGuide, l = `${`${r ? `${styleText3("gray", S_BAR2)}
|
|
1801
|
+
` : ""}${symbol2(this.state)} `}${t.message}
|
|
1802
|
+
`, d = t.placeholder && t.placeholder.length > 0 ? styleText3("inverse", t.placeholder[0]) + styleText3("dim", t.placeholder.slice(1)) : styleText3(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
|
|
2236
1803
|
switch (this.state) {
|
|
1804
|
+
case "validating": {
|
|
1805
|
+
const n = r ? `${styleText3("cyan", S_BAR2)} ` : "", i = r ? styleText3("cyan", S_BAR_END2) : "", c = styleText3("dim", o), $ = styleText3("dim", "Validating...");
|
|
1806
|
+
return `${l}${n}${c}
|
|
1807
|
+
${i} ${$}
|
|
1808
|
+
`;
|
|
1809
|
+
}
|
|
2237
1810
|
case "error": {
|
|
2238
|
-
const
|
|
2239
|
-
return `${
|
|
2240
|
-
${
|
|
2241
|
-
${
|
|
1811
|
+
const n = this.error ? ` ${styleText3("yellow", this.error)}` : "", i = r ? `${styleText3("yellow", S_BAR2)} ` : "", c = r ? styleText3("yellow", S_BAR_END2) : "";
|
|
1812
|
+
return `${l.trim()}
|
|
1813
|
+
${i}${o}
|
|
1814
|
+
${c}${n}
|
|
2242
1815
|
`;
|
|
2243
1816
|
}
|
|
2244
1817
|
case "submit": {
|
|
2245
|
-
const
|
|
2246
|
-
return `${
|
|
1818
|
+
const n = s ? `${r ? " " : ""}${styleText3("dim", s)}` : "", i = r ? styleText3("gray", S_BAR2) : "";
|
|
1819
|
+
return `${l}${i}${n}`;
|
|
2247
1820
|
}
|
|
2248
1821
|
case "cancel": {
|
|
2249
|
-
const
|
|
2250
|
-
return `${
|
|
2251
|
-
${
|
|
1822
|
+
const n = s ? ` ${styleText3(["strikethrough", "dim"], s)}` : "", i = r ? styleText3("gray", S_BAR2) : "";
|
|
1823
|
+
return `${l}${i}${n}${s.trim() ? `
|
|
1824
|
+
${i}` : ""}`;
|
|
2252
1825
|
}
|
|
2253
1826
|
default: {
|
|
2254
|
-
const
|
|
2255
|
-
return `${
|
|
2256
|
-
${
|
|
1827
|
+
const n = r ? `${styleText3("cyan", S_BAR2)} ` : "", i = r ? styleText3("cyan", S_BAR_END2) : "";
|
|
1828
|
+
return `${l}${n}${o}
|
|
1829
|
+
${i}
|
|
2257
1830
|
`;
|
|
2258
1831
|
}
|
|
2259
1832
|
}
|
|
@@ -2278,19 +1851,19 @@ function runCaptured(command, options) {
|
|
|
2278
1851
|
env: options.env ?? process.env,
|
|
2279
1852
|
stdio: ["ignore", "pipe", "pipe"]
|
|
2280
1853
|
});
|
|
2281
|
-
let
|
|
1854
|
+
let stdout = "";
|
|
2282
1855
|
let stderr = "";
|
|
2283
1856
|
child.stdout.setEncoding("utf8");
|
|
2284
1857
|
child.stderr.setEncoding("utf8");
|
|
2285
1858
|
child.stdout.on("data", (chunk) => {
|
|
2286
|
-
|
|
1859
|
+
stdout += chunk;
|
|
2287
1860
|
});
|
|
2288
1861
|
child.stderr.on("data", (chunk) => {
|
|
2289
1862
|
stderr += chunk;
|
|
2290
1863
|
});
|
|
2291
1864
|
child.on("error", reject);
|
|
2292
1865
|
child.on("close", (code, signal) => {
|
|
2293
|
-
resolve({ exitCode: code ?? (signal ? 1 : 0), stdout
|
|
1866
|
+
resolve({ exitCode: code ?? (signal ? 1 : 0), stdout, stderr });
|
|
2294
1867
|
});
|
|
2295
1868
|
});
|
|
2296
1869
|
}
|
|
@@ -2601,10 +2174,10 @@ ${dryRunDescription(client, root)}`);
|
|
|
2601
2174
|
outro2("Dry run complete. No client configuration was changed.");
|
|
2602
2175
|
return;
|
|
2603
2176
|
}
|
|
2604
|
-
const
|
|
2605
|
-
|
|
2177
|
+
const progress = spinner2();
|
|
2178
|
+
progress.start("Testing the local MCP server");
|
|
2606
2179
|
await smokeServer(root);
|
|
2607
|
-
|
|
2180
|
+
progress.stop("Local MCP server passed its protocol self-check");
|
|
2608
2181
|
for (const client of clients) {
|
|
2609
2182
|
const result = client === "codex" ? await configureCodex(root) : client === "cursor" ? await configureCursor(root) : await configureClaude(root);
|
|
2610
2183
|
log2.success(`${client}: ${result}`);
|
|
@@ -2989,25 +2562,25 @@ function runCaptured2(command, options) {
|
|
|
2989
2562
|
const [file, ...args] = command;
|
|
2990
2563
|
if (!file)
|
|
2991
2564
|
throw new Error("runCaptured requires a command");
|
|
2992
|
-
return new Promise((
|
|
2565
|
+
return new Promise((resolve, reject) => {
|
|
2993
2566
|
const child = spawn2(file, args, {
|
|
2994
2567
|
cwd: options.cwd,
|
|
2995
2568
|
env: options.env ?? process.env,
|
|
2996
2569
|
stdio: ["ignore", "pipe", "pipe"]
|
|
2997
2570
|
});
|
|
2998
|
-
let
|
|
2571
|
+
let stdout = "";
|
|
2999
2572
|
let stderr = "";
|
|
3000
2573
|
child.stdout.setEncoding("utf8");
|
|
3001
2574
|
child.stderr.setEncoding("utf8");
|
|
3002
2575
|
child.stdout.on("data", (chunk) => {
|
|
3003
|
-
|
|
2576
|
+
stdout += chunk;
|
|
3004
2577
|
});
|
|
3005
2578
|
child.stderr.on("data", (chunk) => {
|
|
3006
2579
|
stderr += chunk;
|
|
3007
2580
|
});
|
|
3008
2581
|
child.on("error", reject);
|
|
3009
2582
|
child.on("close", (code, signal) => {
|
|
3010
|
-
|
|
2583
|
+
resolve({ exitCode: code ?? (signal ? 1 : 0), stdout, stderr });
|
|
3011
2584
|
});
|
|
3012
2585
|
});
|
|
3013
2586
|
}
|
|
@@ -3015,7 +2588,7 @@ function runInherited(command, options) {
|
|
|
3015
2588
|
const [file, ...args] = command;
|
|
3016
2589
|
if (!file)
|
|
3017
2590
|
throw new Error("runInherited requires a command");
|
|
3018
|
-
return new Promise((
|
|
2591
|
+
return new Promise((resolve, reject) => {
|
|
3019
2592
|
const child = spawn2(file, args, {
|
|
3020
2593
|
cwd: options.cwd,
|
|
3021
2594
|
env: options.env ?? process.env,
|
|
@@ -3023,7 +2596,7 @@ function runInherited(command, options) {
|
|
|
3023
2596
|
});
|
|
3024
2597
|
child.on("error", reject);
|
|
3025
2598
|
child.on("close", (code, signal) => {
|
|
3026
|
-
|
|
2599
|
+
resolve(code ?? (signal === "SIGINT" ? 130 : 1));
|
|
3027
2600
|
});
|
|
3028
2601
|
});
|
|
3029
2602
|
}
|
|
@@ -3583,8 +3156,8 @@ function wrapBrandedJsxText(content, brandName, width = 100) {
|
|
|
3583
3156
|
const output = [];
|
|
3584
3157
|
for (let index = 0;index < lines.length; ) {
|
|
3585
3158
|
const line = lines[index] ?? "";
|
|
3586
|
-
const
|
|
3587
|
-
if (!
|
|
3159
|
+
const text = line.trim();
|
|
3160
|
+
if (!text || text.startsWith("<") || text.startsWith("{") || text.startsWith("//") || text.includes("<") || text.includes(">")) {
|
|
3588
3161
|
output.push(line);
|
|
3589
3162
|
index += 1;
|
|
3590
3163
|
continue;
|
|
@@ -3877,12 +3450,12 @@ async function trackedTemplatePaths(sourceDirectory) {
|
|
|
3877
3450
|
});
|
|
3878
3451
|
if (topLevel !== sourceDirectory)
|
|
3879
3452
|
return;
|
|
3880
|
-
const { stdout
|
|
3453
|
+
const { stdout } = await execFileAsync("git", ["ls-files", "-z"], {
|
|
3881
3454
|
cwd: sourceDirectory,
|
|
3882
3455
|
maxBuffer: 64 * 1024 * 1024
|
|
3883
3456
|
});
|
|
3884
3457
|
const tracked = new Set;
|
|
3885
|
-
for (const path of
|
|
3458
|
+
for (const path of stdout.split("\x00")) {
|
|
3886
3459
|
if (!path)
|
|
3887
3460
|
continue;
|
|
3888
3461
|
tracked.add(path);
|
|
@@ -4428,8 +4001,8 @@ function assertSiblingTarget(source, target) {
|
|
|
4428
4001
|
throw new Error(`Create the new app beside the ${CLI_NAME} source checkout, not inside it.`);
|
|
4429
4002
|
}
|
|
4430
4003
|
}
|
|
4431
|
-
function commandFailureOutput(
|
|
4432
|
-
const output = (stderr.trim() ||
|
|
4004
|
+
function commandFailureOutput(stdout, stderr) {
|
|
4005
|
+
const output = (stderr.trim() || stdout.trim()).split(`
|
|
4433
4006
|
`).slice(-12).join(`
|
|
4434
4007
|
`);
|
|
4435
4008
|
return output ? `
|
|
@@ -4437,12 +4010,12 @@ function commandFailureOutput(stdout2, stderr) {
|
|
|
4437
4010
|
${output}` : "";
|
|
4438
4011
|
}
|
|
4439
4012
|
async function installDependencies(target) {
|
|
4440
|
-
const { stdout
|
|
4013
|
+
const { stdout, stderr, exitCode } = await runCaptured2(["pnpm", "install", "--frozen-lockfile"], {
|
|
4441
4014
|
cwd: target,
|
|
4442
4015
|
env: { ...process.env, CI: "1" }
|
|
4443
4016
|
});
|
|
4444
4017
|
if (exitCode !== 0) {
|
|
4445
|
-
throw new Error(`Dependency installation failed.${commandFailureOutput(
|
|
4018
|
+
throw new Error(`Dependency installation failed.${commandFailureOutput(stdout, stderr)}`);
|
|
4446
4019
|
}
|
|
4447
4020
|
}
|
|
4448
4021
|
async function occupiedDevelopmentPorts() {
|
|
@@ -4638,14 +4211,14 @@ if (isEntrypoint(import.meta.url)) {
|
|
|
4638
4211
|
});
|
|
4639
4212
|
}
|
|
4640
4213
|
export {
|
|
4641
|
-
|
|
4642
|
-
suggestScope,
|
|
4643
|
-
suggestBrandName,
|
|
4644
|
-
printRunnableCommands,
|
|
4645
|
-
parseArguments,
|
|
4646
|
-
occupiedDevelopmentPorts,
|
|
4647
|
-
formatBytes,
|
|
4648
|
-
findAvailablePort,
|
|
4214
|
+
collectLicenseKey,
|
|
4649
4215
|
describeTargetConflict,
|
|
4650
|
-
|
|
4216
|
+
findAvailablePort,
|
|
4217
|
+
formatBytes,
|
|
4218
|
+
occupiedDevelopmentPorts,
|
|
4219
|
+
parseArguments,
|
|
4220
|
+
printRunnableCommands,
|
|
4221
|
+
suggestBrandName,
|
|
4222
|
+
suggestScope,
|
|
4223
|
+
usage
|
|
4651
4224
|
};
|