@jannael/glinter 1.2.4 → 1.2.6
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/README.md +102 -102
- package/dist/index.js +914 -693
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -174,10 +174,10 @@ function errorHandler(error) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
// node_modules/@clack/core/dist/index.mjs
|
|
177
|
-
import { styleText
|
|
178
|
-
import { stdout
|
|
179
|
-
import * as
|
|
180
|
-
import
|
|
177
|
+
import { styleText } from "util";
|
|
178
|
+
import { stdout, stdin } from "process";
|
|
179
|
+
import * as l from "readline";
|
|
180
|
+
import l__default from "readline";
|
|
181
181
|
|
|
182
182
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
183
183
|
var getCodePointsLength = (() => {
|
|
@@ -522,96 +522,162 @@ function wrapAnsi(string, columns, options) {
|
|
|
522
522
|
|
|
523
523
|
// node_modules/@clack/core/dist/index.mjs
|
|
524
524
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
525
|
-
import { ReadStream
|
|
526
|
-
function
|
|
527
|
-
if (!
|
|
528
|
-
return
|
|
529
|
-
const
|
|
530
|
-
return
|
|
531
|
-
}
|
|
532
|
-
function
|
|
533
|
-
const
|
|
525
|
+
import { ReadStream } from "tty";
|
|
526
|
+
function findCursor(s, o, l2) {
|
|
527
|
+
if (!l2.some((r) => !r.disabled))
|
|
528
|
+
return s;
|
|
529
|
+
const t = s + o, n = Math.max(l2.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
530
|
+
return l2[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l2) : e;
|
|
531
|
+
}
|
|
532
|
+
function findTextCursor(s, o, l2, i) {
|
|
533
|
+
const t = i.split(`
|
|
534
534
|
`);
|
|
535
|
-
let n = 0,
|
|
536
|
-
for (const
|
|
537
|
-
if (
|
|
535
|
+
let n = 0, e = s;
|
|
536
|
+
for (const r of t) {
|
|
537
|
+
if (e <= r.length)
|
|
538
538
|
break;
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
for (n = Math.max(0, Math.min(
|
|
542
|
-
n--,
|
|
543
|
-
for (;
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
let
|
|
547
|
-
for (let
|
|
548
|
-
|
|
549
|
-
return
|
|
550
|
-
}
|
|
551
|
-
var
|
|
552
|
-
var
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
539
|
+
e -= r.length + 1, n++;
|
|
540
|
+
}
|
|
541
|
+
for (n = Math.max(0, Math.min(t.length - 1, n + l2)), e = Math.min(e, t[n].length) + o;e < 0 && n > 0; )
|
|
542
|
+
n--, e += t[n].length + 1;
|
|
543
|
+
for (;e > t[n].length && n < t.length - 1; )
|
|
544
|
+
e -= t[n].length + 1, n++;
|
|
545
|
+
e = Math.max(0, Math.min(t[n].length, e));
|
|
546
|
+
let h = 0;
|
|
547
|
+
for (let r = 0;r < n; r++)
|
|
548
|
+
h += t[r].length + 1;
|
|
549
|
+
return h + e;
|
|
550
|
+
}
|
|
551
|
+
var a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
552
|
+
var t = [
|
|
553
|
+
"January",
|
|
554
|
+
"February",
|
|
555
|
+
"March",
|
|
556
|
+
"April",
|
|
557
|
+
"May",
|
|
558
|
+
"June",
|
|
559
|
+
"July",
|
|
560
|
+
"August",
|
|
561
|
+
"September",
|
|
562
|
+
"October",
|
|
563
|
+
"November",
|
|
564
|
+
"December"
|
|
565
|
+
];
|
|
566
|
+
var settings = {
|
|
567
|
+
actions: new Set(a$2),
|
|
568
|
+
aliases: /* @__PURE__ */ new Map([
|
|
569
|
+
["k", "up"],
|
|
570
|
+
["j", "down"],
|
|
571
|
+
["h", "left"],
|
|
572
|
+
["l", "right"],
|
|
573
|
+
["\x03", "cancel"],
|
|
574
|
+
["escape", "cancel"]
|
|
575
|
+
]),
|
|
576
|
+
messages: {
|
|
577
|
+
cancel: "Canceled",
|
|
578
|
+
error: "Something went wrong"
|
|
579
|
+
},
|
|
580
|
+
withGuide: true,
|
|
581
|
+
date: {
|
|
582
|
+
monthNames: [...t],
|
|
583
|
+
messages: {
|
|
584
|
+
required: "Please enter a valid date",
|
|
585
|
+
invalidMonth: "There are only 12 months in a year",
|
|
586
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
587
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
588
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
function isActionKey(n, e) {
|
|
593
|
+
if (typeof n == "string")
|
|
594
|
+
return settings.aliases.get(n) === e;
|
|
595
|
+
for (const s of n)
|
|
596
|
+
if (s !== undefined && isActionKey(s, e))
|
|
559
597
|
return true;
|
|
560
598
|
return false;
|
|
561
599
|
}
|
|
562
|
-
function
|
|
563
|
-
if (
|
|
600
|
+
function diffLines(i, s) {
|
|
601
|
+
if (i === s)
|
|
564
602
|
return;
|
|
565
|
-
const
|
|
566
|
-
`),
|
|
567
|
-
`),
|
|
568
|
-
for (let
|
|
569
|
-
|
|
570
|
-
return {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
603
|
+
const e = i.split(`
|
|
604
|
+
`), t2 = s.split(`
|
|
605
|
+
`), r = Math.max(e.length, t2.length), f = [];
|
|
606
|
+
for (let n = 0;n < r; n++)
|
|
607
|
+
e[n] !== t2[n] && f.push(n);
|
|
608
|
+
return {
|
|
609
|
+
lines: f,
|
|
610
|
+
numLinesBefore: e.length,
|
|
611
|
+
numLinesAfter: t2.length,
|
|
612
|
+
numLines: r
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
var R = globalThis.process.platform.startsWith("win");
|
|
616
|
+
var CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
617
|
+
function isCancel(e) {
|
|
618
|
+
return e === CANCEL_SYMBOL;
|
|
619
|
+
}
|
|
620
|
+
function setRawMode(e, r) {
|
|
621
|
+
const o = e;
|
|
622
|
+
o.isTTY && o.setRawMode(r);
|
|
623
|
+
}
|
|
624
|
+
function block({
|
|
625
|
+
input: e = stdin,
|
|
626
|
+
output: r = stdout,
|
|
627
|
+
overwrite: o = true,
|
|
628
|
+
hideCursor: t2 = true
|
|
629
|
+
} = {}) {
|
|
630
|
+
const s = l.createInterface({
|
|
631
|
+
input: e,
|
|
632
|
+
output: r,
|
|
633
|
+
prompt: "",
|
|
634
|
+
tabSize: 1
|
|
635
|
+
});
|
|
636
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
637
|
+
const n = (f, { name: a, sequence: p }) => {
|
|
638
|
+
const c = String(f);
|
|
639
|
+
if (isActionKey([c, a, p], "cancel")) {
|
|
640
|
+
t2 && r.write(import_sisteransi.cursor.show), process.exit(0);
|
|
588
641
|
return;
|
|
589
642
|
}
|
|
590
|
-
if (!
|
|
643
|
+
if (!o)
|
|
591
644
|
return;
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
645
|
+
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
646
|
+
l.moveCursor(r, i, m, () => {
|
|
647
|
+
l.clearLine(r, 1, () => {
|
|
648
|
+
e.once("keypress", n);
|
|
596
649
|
});
|
|
597
650
|
});
|
|
598
651
|
};
|
|
599
|
-
return
|
|
600
|
-
|
|
652
|
+
return t2 && r.write(import_sisteransi.cursor.hide), e.once("keypress", n), () => {
|
|
653
|
+
e.off("keypress", n), t2 && r.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
601
654
|
};
|
|
602
655
|
}
|
|
603
|
-
var
|
|
604
|
-
var
|
|
605
|
-
function
|
|
606
|
-
const
|
|
607
|
-
return wrapAnsi(
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
656
|
+
var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
|
|
657
|
+
var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
|
|
658
|
+
function wrapTextWithPrefix(e, r, o, t2 = o, s = o, n) {
|
|
659
|
+
const f = getColumns(e ?? stdout);
|
|
660
|
+
return wrapAnsi(r, f - o.length, {
|
|
661
|
+
hard: true,
|
|
662
|
+
trim: false
|
|
663
|
+
}).split(`
|
|
664
|
+
`).map((c, i, m) => {
|
|
665
|
+
const d = n ? n(c, i) : c;
|
|
666
|
+
return i === 0 ? `${t2}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
611
667
|
}).join(`
|
|
612
668
|
`);
|
|
613
669
|
}
|
|
614
|
-
|
|
670
|
+
function runValidation(e, n) {
|
|
671
|
+
if ("~standard" in e) {
|
|
672
|
+
const a = e["~standard"].validate(n);
|
|
673
|
+
if (a instanceof Promise)
|
|
674
|
+
throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
675
|
+
return a.issues?.at(0)?.message;
|
|
676
|
+
}
|
|
677
|
+
return e(n);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
class V {
|
|
615
681
|
input;
|
|
616
682
|
output;
|
|
617
683
|
_abortSignal;
|
|
@@ -620,270 +686,305 @@ var m = class {
|
|
|
620
686
|
_render;
|
|
621
687
|
_track = false;
|
|
622
688
|
_prevFrame = "";
|
|
623
|
-
_subscribers = new Map;
|
|
689
|
+
_subscribers = /* @__PURE__ */ new Map;
|
|
624
690
|
_cursor = 0;
|
|
625
691
|
state = "initial";
|
|
626
692
|
error = "";
|
|
627
693
|
value;
|
|
628
694
|
userInput = "";
|
|
629
|
-
constructor(
|
|
630
|
-
const { input:
|
|
631
|
-
this.opts =
|
|
695
|
+
constructor(t2, e = true) {
|
|
696
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t2;
|
|
697
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
632
698
|
}
|
|
633
699
|
unsubscribe() {
|
|
634
700
|
this._subscribers.clear();
|
|
635
701
|
}
|
|
636
|
-
setSubscriber(
|
|
637
|
-
const
|
|
638
|
-
|
|
702
|
+
setSubscriber(t2, e) {
|
|
703
|
+
const i = this._subscribers.get(t2) ?? [];
|
|
704
|
+
i.push(e), this._subscribers.set(t2, i);
|
|
639
705
|
}
|
|
640
|
-
on(
|
|
641
|
-
this.setSubscriber(
|
|
706
|
+
on(t2, e) {
|
|
707
|
+
this.setSubscriber(t2, { cb: e });
|
|
642
708
|
}
|
|
643
|
-
once(
|
|
644
|
-
this.setSubscriber(
|
|
709
|
+
once(t2, e) {
|
|
710
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
645
711
|
}
|
|
646
|
-
emit(
|
|
647
|
-
const
|
|
648
|
-
for (const
|
|
649
|
-
|
|
650
|
-
for (const
|
|
651
|
-
|
|
712
|
+
emit(t2, ...e) {
|
|
713
|
+
const i = this._subscribers.get(t2) ?? [], n = [];
|
|
714
|
+
for (const s of i)
|
|
715
|
+
s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
716
|
+
for (const s of n)
|
|
717
|
+
s();
|
|
652
718
|
}
|
|
653
719
|
prompt() {
|
|
654
|
-
return new Promise((
|
|
720
|
+
return new Promise((t2) => {
|
|
655
721
|
if (this._abortSignal) {
|
|
656
722
|
if (this._abortSignal.aborted)
|
|
657
|
-
return this.state = "cancel", this.close(),
|
|
723
|
+
return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
|
|
658
724
|
this._abortSignal.addEventListener("abort", () => {
|
|
659
725
|
this.state = "cancel", this.close();
|
|
660
726
|
}, { once: true });
|
|
661
727
|
}
|
|
662
|
-
this.rl =
|
|
663
|
-
|
|
728
|
+
this.rl = l__default.createInterface({
|
|
729
|
+
input: this.input,
|
|
730
|
+
tabSize: 2,
|
|
731
|
+
prompt: "",
|
|
732
|
+
escapeCodeTimeout: 50,
|
|
733
|
+
terminal: true
|
|
734
|
+
}), 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", () => {
|
|
735
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
664
736
|
}), this.once("cancel", () => {
|
|
665
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render),
|
|
737
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
666
738
|
});
|
|
667
739
|
});
|
|
668
740
|
}
|
|
669
|
-
_isActionKey(
|
|
670
|
-
return
|
|
741
|
+
_isActionKey(t2, e) {
|
|
742
|
+
return t2 === "\t";
|
|
671
743
|
}
|
|
672
|
-
_shouldSubmit(
|
|
744
|
+
_shouldSubmit(t2, e) {
|
|
673
745
|
return true;
|
|
674
746
|
}
|
|
675
|
-
_setValue(
|
|
676
|
-
this.value =
|
|
747
|
+
_setValue(t2) {
|
|
748
|
+
this.value = t2, this.emit("value", this.value);
|
|
677
749
|
}
|
|
678
|
-
_setUserInput(
|
|
679
|
-
this.userInput =
|
|
750
|
+
_setUserInput(t2, e) {
|
|
751
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
680
752
|
}
|
|
681
753
|
_clearUserInput() {
|
|
682
754
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
683
755
|
}
|
|
684
|
-
onKeypress(
|
|
685
|
-
if (this._track &&
|
|
756
|
+
onKeypress(t2, e) {
|
|
757
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, 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)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
|
|
686
758
|
if (this.opts.validate) {
|
|
687
|
-
const
|
|
688
|
-
|
|
759
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
760
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
689
761
|
}
|
|
690
762
|
this.state !== "error" && (this.state = "submit");
|
|
691
763
|
}
|
|
692
|
-
|
|
764
|
+
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();
|
|
693
765
|
}
|
|
694
766
|
close() {
|
|
695
767
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
696
|
-
`),
|
|
768
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
697
769
|
}
|
|
698
770
|
restoreCursor() {
|
|
699
|
-
const
|
|
771
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
700
772
|
`).length - 1;
|
|
701
|
-
this.output.write(import_sisteransi.cursor.move(-999,
|
|
773
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
702
774
|
}
|
|
703
775
|
render() {
|
|
704
|
-
const
|
|
705
|
-
|
|
776
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
777
|
+
hard: true,
|
|
778
|
+
trim: false
|
|
779
|
+
});
|
|
780
|
+
if (t2 !== this._prevFrame) {
|
|
706
781
|
if (this.state === "initial")
|
|
707
782
|
this.output.write(import_sisteransi.cursor.hide);
|
|
708
783
|
else {
|
|
709
|
-
const
|
|
710
|
-
if (this.restoreCursor(),
|
|
711
|
-
const
|
|
712
|
-
let
|
|
713
|
-
if (
|
|
714
|
-
this._prevFrame =
|
|
784
|
+
const e = diffLines(this._prevFrame, t2), i = getRows(this.output);
|
|
785
|
+
if (this.restoreCursor(), e) {
|
|
786
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
787
|
+
let r = e.lines.find((o) => o >= n);
|
|
788
|
+
if (r === undefined) {
|
|
789
|
+
this._prevFrame = t2;
|
|
715
790
|
return;
|
|
716
791
|
}
|
|
717
|
-
if (
|
|
718
|
-
this.output.write(import_sisteransi.cursor.move(0,
|
|
719
|
-
const
|
|
792
|
+
if (e.lines.length === 1) {
|
|
793
|
+
this.output.write(import_sisteransi.cursor.move(0, r - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
794
|
+
const o = t2.split(`
|
|
720
795
|
`);
|
|
721
|
-
this.output.write(
|
|
796
|
+
this.output.write(o[r]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - r - 1));
|
|
722
797
|
return;
|
|
723
|
-
} else if (
|
|
724
|
-
if (
|
|
725
|
-
|
|
798
|
+
} else if (e.lines.length > 1) {
|
|
799
|
+
if (n < s)
|
|
800
|
+
r = n;
|
|
726
801
|
else {
|
|
727
|
-
const
|
|
728
|
-
|
|
802
|
+
const h = r - s;
|
|
803
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
729
804
|
}
|
|
730
805
|
this.output.write(import_sisteransi.erase.down());
|
|
731
|
-
const
|
|
732
|
-
`).slice(
|
|
733
|
-
this.output.write(
|
|
734
|
-
`)), this._prevFrame =
|
|
806
|
+
const f = t2.split(`
|
|
807
|
+
`).slice(r);
|
|
808
|
+
this.output.write(f.join(`
|
|
809
|
+
`)), this._prevFrame = t2;
|
|
735
810
|
return;
|
|
736
811
|
}
|
|
737
812
|
}
|
|
738
813
|
this.output.write(import_sisteransi.erase.down());
|
|
739
814
|
}
|
|
740
|
-
this.output.write(
|
|
815
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
741
816
|
}
|
|
742
817
|
}
|
|
743
|
-
}
|
|
744
|
-
function
|
|
745
|
-
if (
|
|
818
|
+
}
|
|
819
|
+
function p$1(l2, e) {
|
|
820
|
+
if (l2 === undefined || e.length === 0)
|
|
746
821
|
return 0;
|
|
747
|
-
const
|
|
748
|
-
return
|
|
822
|
+
const i = e.findIndex((s) => s.value === l2);
|
|
823
|
+
return i !== -1 ? i : 0;
|
|
749
824
|
}
|
|
750
|
-
function
|
|
751
|
-
return (
|
|
825
|
+
function g(l2, e) {
|
|
826
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l2.toLowerCase());
|
|
752
827
|
}
|
|
753
|
-
function
|
|
754
|
-
if (
|
|
755
|
-
return
|
|
828
|
+
function m(l2, e) {
|
|
829
|
+
if (e)
|
|
830
|
+
return l2 ? e : e[0];
|
|
756
831
|
}
|
|
757
|
-
var
|
|
832
|
+
var T$1 = class T extends V {
|
|
758
833
|
filteredOptions;
|
|
759
834
|
multiple;
|
|
760
835
|
isNavigating = false;
|
|
761
836
|
selectedValues = [];
|
|
762
837
|
focusedValue;
|
|
763
|
-
#
|
|
764
|
-
#
|
|
838
|
+
#e = 0;
|
|
839
|
+
#s = "";
|
|
765
840
|
#t;
|
|
841
|
+
#i;
|
|
766
842
|
#n;
|
|
767
|
-
#u;
|
|
768
843
|
get cursor() {
|
|
769
|
-
return this.#
|
|
844
|
+
return this.#e;
|
|
770
845
|
}
|
|
771
846
|
get userInputWithCursor() {
|
|
772
847
|
if (!this.userInput)
|
|
773
|
-
return
|
|
848
|
+
return styleText(["inverse", "hidden"], "_");
|
|
774
849
|
if (this._cursor >= this.userInput.length)
|
|
775
850
|
return `${this.userInput}\u2588`;
|
|
776
|
-
const
|
|
777
|
-
return `${
|
|
851
|
+
const e = this.userInput.slice(0, this._cursor), [t2, ...i] = this.userInput.slice(this._cursor);
|
|
852
|
+
return `${e}${styleText("inverse", t2)}${i.join("")}`;
|
|
778
853
|
}
|
|
779
854
|
get options() {
|
|
780
|
-
return typeof this.#
|
|
781
|
-
}
|
|
782
|
-
constructor(
|
|
783
|
-
super(
|
|
784
|
-
const
|
|
785
|
-
this.filteredOptions = [...
|
|
786
|
-
let
|
|
787
|
-
if (
|
|
788
|
-
for (const
|
|
789
|
-
const n =
|
|
790
|
-
n !== -1 && (this.toggleSelected(
|
|
855
|
+
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
856
|
+
}
|
|
857
|
+
constructor(e) {
|
|
858
|
+
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
859
|
+
const t2 = this.options;
|
|
860
|
+
this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
|
|
861
|
+
let i;
|
|
862
|
+
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)
|
|
863
|
+
for (const s of i) {
|
|
864
|
+
const n = t2.findIndex((o) => o.value === s);
|
|
865
|
+
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
791
866
|
}
|
|
792
|
-
this.focusedValue = this.options[this.#
|
|
867
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
793
868
|
}
|
|
794
|
-
_isActionKey(
|
|
795
|
-
return
|
|
869
|
+
_isActionKey(e, t2) {
|
|
870
|
+
return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
|
|
796
871
|
}
|
|
797
|
-
#e
|
|
798
|
-
const
|
|
799
|
-
if (
|
|
872
|
+
#l(e, t2) {
|
|
873
|
+
const i = t2.name === "up", s = t2.name === "down", n = t2.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#n, h = this.options, f = u !== undefined && u !== "" && h.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
|
|
874
|
+
if (t2.name === "tab" && o && f) {
|
|
800
875
|
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
801
876
|
return;
|
|
802
877
|
}
|
|
803
|
-
|
|
878
|
+
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);
|
|
804
879
|
}
|
|
805
880
|
deselectAll() {
|
|
806
881
|
this.selectedValues = [];
|
|
807
882
|
}
|
|
808
|
-
toggleSelected(
|
|
809
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(
|
|
810
|
-
}
|
|
811
|
-
#
|
|
812
|
-
if (
|
|
813
|
-
this.#
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
this.#
|
|
818
|
-
const
|
|
819
|
-
|
|
883
|
+
toggleSelected(e) {
|
|
884
|
+
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]);
|
|
885
|
+
}
|
|
886
|
+
#u(e) {
|
|
887
|
+
if (e !== this.#s) {
|
|
888
|
+
this.#s = e;
|
|
889
|
+
const t2 = this.options;
|
|
890
|
+
e && this.#t ? this.filteredOptions = t2.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t2];
|
|
891
|
+
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
892
|
+
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
893
|
+
const s = this.filteredOptions[this.#e];
|
|
894
|
+
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
820
895
|
}
|
|
821
896
|
}
|
|
822
897
|
};
|
|
823
898
|
|
|
824
|
-
class
|
|
899
|
+
class r extends V {
|
|
825
900
|
get cursor() {
|
|
826
901
|
return this.value ? 0 : 1;
|
|
827
902
|
}
|
|
828
903
|
get _value() {
|
|
829
904
|
return this.cursor === 0;
|
|
830
905
|
}
|
|
831
|
-
constructor(
|
|
832
|
-
super(
|
|
906
|
+
constructor(t2) {
|
|
907
|
+
super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
|
|
833
908
|
this.value = this._value;
|
|
834
|
-
}), this.on("confirm", (
|
|
835
|
-
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value =
|
|
909
|
+
}), this.on("confirm", (i) => {
|
|
910
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
836
911
|
}), this.on("cursor", () => {
|
|
837
912
|
this.value = !this.value;
|
|
838
913
|
});
|
|
839
914
|
}
|
|
840
915
|
}
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
|
|
916
|
+
var _ = {
|
|
917
|
+
Y: { type: "year", len: 4 },
|
|
918
|
+
M: { type: "month", len: 2 },
|
|
919
|
+
D: { type: "day", len: 2 }
|
|
920
|
+
};
|
|
921
|
+
function M(r2) {
|
|
922
|
+
return [...r2].map((t2) => _[t2]);
|
|
844
923
|
}
|
|
845
|
-
function
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
924
|
+
function P(r2) {
|
|
925
|
+
const i = new Intl.DateTimeFormat(r2, {
|
|
926
|
+
year: "numeric",
|
|
927
|
+
month: "2-digit",
|
|
928
|
+
day: "2-digit"
|
|
929
|
+
}).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
930
|
+
let n = "/";
|
|
931
|
+
for (const e of i)
|
|
932
|
+
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 });
|
|
933
|
+
return { segments: s, separator: n };
|
|
851
934
|
}
|
|
852
|
-
function
|
|
853
|
-
return Number.parseInt((
|
|
935
|
+
function p(r2) {
|
|
936
|
+
return Number.parseInt((r2 || "0").replace(/_/g, "0"), 10) || 0;
|
|
854
937
|
}
|
|
855
|
-
function
|
|
856
|
-
return {
|
|
938
|
+
function f(r2) {
|
|
939
|
+
return {
|
|
940
|
+
year: p(r2.year),
|
|
941
|
+
month: p(r2.month),
|
|
942
|
+
day: p(r2.day)
|
|
943
|
+
};
|
|
857
944
|
}
|
|
858
|
-
function
|
|
859
|
-
return new Date(
|
|
945
|
+
function c(r2, t2) {
|
|
946
|
+
return new Date(r2 || 2001, t2 || 1, 0).getDate();
|
|
860
947
|
}
|
|
861
|
-
function
|
|
862
|
-
const { year:
|
|
863
|
-
if (!
|
|
948
|
+
function b(r2) {
|
|
949
|
+
const { year: t2, month: i, day: s } = f(r2);
|
|
950
|
+
if (!t2 || t2 < 0 || t2 > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
|
|
864
951
|
return;
|
|
865
|
-
const
|
|
866
|
-
if (!(
|
|
867
|
-
return { year:
|
|
952
|
+
const n = new Date(Date.UTC(t2, i - 1, s));
|
|
953
|
+
if (!(n.getUTCFullYear() !== t2 || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
954
|
+
return { year: t2, month: i, day: s };
|
|
868
955
|
}
|
|
869
|
-
function
|
|
870
|
-
const
|
|
871
|
-
return
|
|
956
|
+
function C(r2) {
|
|
957
|
+
const t2 = b(r2);
|
|
958
|
+
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
|
|
872
959
|
}
|
|
873
|
-
function
|
|
874
|
-
const
|
|
875
|
-
|
|
960
|
+
function T2(r2, t2, i, s) {
|
|
961
|
+
const n = i ? {
|
|
962
|
+
year: i.getUTCFullYear(),
|
|
963
|
+
month: i.getUTCMonth() + 1,
|
|
964
|
+
day: i.getUTCDate()
|
|
965
|
+
} : null, e = s ? {
|
|
966
|
+
year: s.getUTCFullYear(),
|
|
967
|
+
month: s.getUTCMonth() + 1,
|
|
968
|
+
day: s.getUTCDate()
|
|
969
|
+
} : null;
|
|
970
|
+
return r2 === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r2 === "month" ? {
|
|
971
|
+
min: n && t2.year === n.year ? n.month : 1,
|
|
972
|
+
max: e && t2.year === e.year ? e.month : 12
|
|
973
|
+
} : {
|
|
974
|
+
min: n && t2.year === n.year && t2.month === n.month ? n.day : 1,
|
|
975
|
+
max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
|
|
976
|
+
};
|
|
876
977
|
}
|
|
877
978
|
|
|
878
|
-
class
|
|
879
|
-
#
|
|
880
|
-
#
|
|
979
|
+
class U extends V {
|
|
980
|
+
#i;
|
|
981
|
+
#o;
|
|
881
982
|
#t;
|
|
882
|
-
#
|
|
983
|
+
#h;
|
|
883
984
|
#u;
|
|
884
985
|
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
885
|
-
#
|
|
886
|
-
#
|
|
986
|
+
#n = true;
|
|
987
|
+
#s = null;
|
|
887
988
|
inlineError = "";
|
|
888
989
|
get segmentCursor() {
|
|
889
990
|
return { ...this.#e };
|
|
@@ -892,173 +993,189 @@ class et extends m {
|
|
|
892
993
|
return { ...this.#t };
|
|
893
994
|
}
|
|
894
995
|
get segments() {
|
|
895
|
-
return this.#
|
|
996
|
+
return this.#i;
|
|
896
997
|
}
|
|
897
998
|
get separator() {
|
|
898
|
-
return this.#
|
|
999
|
+
return this.#o;
|
|
899
1000
|
}
|
|
900
1001
|
get formattedValue() {
|
|
901
|
-
return this.#
|
|
902
|
-
}
|
|
903
|
-
#c(t) {
|
|
904
|
-
return this.#s.map((s) => t[s.type]).join(this.#r);
|
|
905
|
-
}
|
|
906
|
-
#a() {
|
|
907
|
-
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
|
|
1002
|
+
return this.#l(this.#t);
|
|
908
1003
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
super({ ...t, initialUserInput: u }, false), this.#s = i, this.#r = e, this.#t = o, this.#n = t.minDate, this.#u = t.maxDate, this.#a(), this.on("cursor", (a) => this.#d(a)), this.on("key", (a, l) => this.#f(a, l)), this.on("finalize", () => this.#g(t));
|
|
1004
|
+
#l(t2) {
|
|
1005
|
+
return this.#i.map((i) => t2[i.type]).join(this.#o);
|
|
912
1006
|
}
|
|
913
|
-
#
|
|
914
|
-
|
|
915
|
-
if (s)
|
|
916
|
-
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
|
|
1007
|
+
#r() {
|
|
1008
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
|
|
917
1009
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1010
|
+
constructor(t2) {
|
|
1011
|
+
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 ? {
|
|
1012
|
+
year: String(e.getUTCFullYear()).padStart(4, "0"),
|
|
1013
|
+
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
1014
|
+
day: String(e.getUTCDate()).padStart(2, "0")
|
|
1015
|
+
} : { year: "____", month: "__", day: "__" }, o = n.map((a) => m2[a.type]).join(s);
|
|
1016
|
+
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));
|
|
922
1017
|
}
|
|
923
|
-
#
|
|
924
|
-
const
|
|
925
|
-
if (
|
|
1018
|
+
#a() {
|
|
1019
|
+
const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t2];
|
|
1020
|
+
if (i)
|
|
1021
|
+
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), { segment: i, index: t2 };
|
|
1022
|
+
}
|
|
1023
|
+
#m(t2) {
|
|
1024
|
+
this.inlineError = "", this.#s = null;
|
|
1025
|
+
const i = this.#a();
|
|
1026
|
+
i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
|
|
1027
|
+
}
|
|
1028
|
+
#d(t2) {
|
|
1029
|
+
const i = this.#a();
|
|
1030
|
+
if (!i)
|
|
926
1031
|
return;
|
|
927
|
-
const { segment:
|
|
1032
|
+
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);
|
|
928
1033
|
let a;
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1034
|
+
e ? a = t2 === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m2 + t2), o.min), this.#t = {
|
|
1035
|
+
...this.#t,
|
|
1036
|
+
[s.type]: a.toString().padStart(s.len, "0")
|
|
1037
|
+
}, this.#n = true, this.#s = null, this.#r();
|
|
1038
|
+
}
|
|
1039
|
+
#f(t2) {
|
|
1040
|
+
if (t2)
|
|
1041
|
+
switch (t2) {
|
|
934
1042
|
case "right":
|
|
935
|
-
return this.#
|
|
1043
|
+
return this.#m(1);
|
|
936
1044
|
case "left":
|
|
937
|
-
return this.#
|
|
1045
|
+
return this.#m(-1);
|
|
938
1046
|
case "up":
|
|
939
|
-
return this.#
|
|
1047
|
+
return this.#d(1);
|
|
940
1048
|
case "down":
|
|
941
|
-
return this.#
|
|
1049
|
+
return this.#d(-1);
|
|
942
1050
|
}
|
|
943
1051
|
}
|
|
944
|
-
#
|
|
945
|
-
if (
|
|
1052
|
+
#y(t2, i) {
|
|
1053
|
+
if (i?.name === "backspace" || i?.sequence === "\x7F" || i?.sequence === "\b" || t2 === "\x7F" || t2 === "\b") {
|
|
946
1054
|
this.inlineError = "";
|
|
947
|
-
const
|
|
948
|
-
if (!
|
|
1055
|
+
const n = this.#a();
|
|
1056
|
+
if (!n)
|
|
949
1057
|
return;
|
|
950
|
-
if (!this.#t[
|
|
951
|
-
this.#
|
|
1058
|
+
if (!this.#t[n.segment.type].replace(/_/g, "")) {
|
|
1059
|
+
this.#m(-1);
|
|
952
1060
|
return;
|
|
953
1061
|
}
|
|
954
|
-
this.#t[
|
|
1062
|
+
this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
|
|
955
1063
|
return;
|
|
956
1064
|
}
|
|
957
|
-
if (
|
|
1065
|
+
if (i?.name === "tab") {
|
|
958
1066
|
this.inlineError = "";
|
|
959
|
-
const
|
|
960
|
-
if (!
|
|
1067
|
+
const n = this.#a();
|
|
1068
|
+
if (!n)
|
|
961
1069
|
return;
|
|
962
|
-
const
|
|
963
|
-
|
|
1070
|
+
const e = i.shift ? -1 : 1, m2 = n.index + e;
|
|
1071
|
+
m2 >= 0 && m2 < this.#i.length && (this.#e.segmentIndex = m2, this.#e.positionInSegment = 0, this.#n = true);
|
|
964
1072
|
return;
|
|
965
1073
|
}
|
|
966
|
-
if (
|
|
967
|
-
const
|
|
968
|
-
if (!
|
|
1074
|
+
if (t2 && /^[0-9]$/.test(t2)) {
|
|
1075
|
+
const n = this.#a();
|
|
1076
|
+
if (!n)
|
|
969
1077
|
return;
|
|
970
|
-
const { segment:
|
|
971
|
-
if (this.#
|
|
972
|
-
const
|
|
973
|
-
if (
|
|
974
|
-
this.inlineError =
|
|
1078
|
+
const { segment: e } = n, m2 = !this.#t[e.type].replace(/_/g, "");
|
|
1079
|
+
if (this.#n && this.#s !== null && !m2) {
|
|
1080
|
+
const h = this.#s + t2, d = { ...this.#t, [e.type]: h }, g2 = this.#g(d, e);
|
|
1081
|
+
if (g2) {
|
|
1082
|
+
this.inlineError = g2, this.#s = null, this.#n = false;
|
|
975
1083
|
return;
|
|
976
1084
|
}
|
|
977
|
-
this.inlineError = "", this.#t[
|
|
1085
|
+
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);
|
|
978
1086
|
return;
|
|
979
1087
|
}
|
|
980
|
-
this.#
|
|
981
|
-
const o = this.#t[
|
|
982
|
-
if (
|
|
1088
|
+
this.#n && !m2 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
1089
|
+
const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
|
|
1090
|
+
if (u < 0 || u >= e.len)
|
|
983
1091
|
return;
|
|
984
|
-
let
|
|
985
|
-
if (
|
|
986
|
-
const
|
|
987
|
-
|
|
1092
|
+
let l2 = o.slice(0, u) + t2 + o.slice(u + 1), D = false;
|
|
1093
|
+
if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
|
|
1094
|
+
const h = Number.parseInt(t2, 10);
|
|
1095
|
+
l2 = `0${t2}`, D = h <= (e.type === "month" ? 1 : 2);
|
|
988
1096
|
}
|
|
989
|
-
if (
|
|
990
|
-
const
|
|
991
|
-
if (
|
|
992
|
-
this.inlineError =
|
|
1097
|
+
if (e.type === "year" && (l2 = (o.replace(/_/g, "") + t2).padStart(e.len, "_")), !l2.includes("_")) {
|
|
1098
|
+
const h = { ...this.#t, [e.type]: l2 }, d = this.#g(h, e);
|
|
1099
|
+
if (d) {
|
|
1100
|
+
this.inlineError = d;
|
|
993
1101
|
return;
|
|
994
1102
|
}
|
|
995
1103
|
}
|
|
996
|
-
this.inlineError = "", this.#t[
|
|
997
|
-
const y =
|
|
1104
|
+
this.inlineError = "", this.#t[e.type] = l2;
|
|
1105
|
+
const y = l2.includes("_") ? undefined : b(this.#t);
|
|
998
1106
|
if (y) {
|
|
999
|
-
const { year:
|
|
1000
|
-
this.#t = {
|
|
1107
|
+
const { year: h, month: d } = y, g2 = c(h, d);
|
|
1108
|
+
this.#t = {
|
|
1109
|
+
year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
|
|
1110
|
+
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
1111
|
+
day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
|
|
1112
|
+
};
|
|
1001
1113
|
}
|
|
1002
|
-
this.#
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1114
|
+
this.#r();
|
|
1115
|
+
const S = l2.indexOf("_");
|
|
1116
|
+
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);
|
|
1005
1117
|
}
|
|
1006
1118
|
}
|
|
1007
|
-
#
|
|
1008
|
-
const { month:
|
|
1009
|
-
if (
|
|
1010
|
-
return
|
|
1011
|
-
if (
|
|
1012
|
-
return
|
|
1013
|
-
}
|
|
1014
|
-
#
|
|
1015
|
-
const { year:
|
|
1016
|
-
if (
|
|
1017
|
-
const
|
|
1018
|
-
this.#t = {
|
|
1119
|
+
#g(t2, i) {
|
|
1120
|
+
const { month: s, day: n } = f(t2);
|
|
1121
|
+
if (i.type === "month" && (s < 0 || s > 12))
|
|
1122
|
+
return settings.date.messages.invalidMonth;
|
|
1123
|
+
if (i.type === "day" && (n < 0 || n > 31))
|
|
1124
|
+
return settings.date.messages.invalidDay(31, "any month");
|
|
1125
|
+
}
|
|
1126
|
+
#p(t2) {
|
|
1127
|
+
const { year: i, month: s, day: n } = f(this.#t);
|
|
1128
|
+
if (i && s && n) {
|
|
1129
|
+
const e = c(i, s);
|
|
1130
|
+
this.#t = {
|
|
1131
|
+
...this.#t,
|
|
1132
|
+
day: String(Math.min(n, e)).padStart(2, "0")
|
|
1133
|
+
};
|
|
1019
1134
|
}
|
|
1020
|
-
this.value =
|
|
1135
|
+
this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
|
|
1021
1136
|
}
|
|
1022
1137
|
}
|
|
1023
|
-
|
|
1024
|
-
class it extends m {
|
|
1138
|
+
var u$1 = class u extends V {
|
|
1025
1139
|
options;
|
|
1026
1140
|
cursor = 0;
|
|
1027
|
-
#
|
|
1028
|
-
getGroupItems(
|
|
1029
|
-
return this.options.filter((
|
|
1141
|
+
#t;
|
|
1142
|
+
getGroupItems(t2) {
|
|
1143
|
+
return this.options.filter((r2) => r2.group === t2);
|
|
1030
1144
|
}
|
|
1031
|
-
isGroupSelected(
|
|
1032
|
-
const
|
|
1033
|
-
return e === undefined ? false :
|
|
1145
|
+
isGroupSelected(t2) {
|
|
1146
|
+
const r2 = this.getGroupItems(t2), e = this.value;
|
|
1147
|
+
return e === undefined ? false : r2.every((s) => e.includes(s.value));
|
|
1034
1148
|
}
|
|
1035
1149
|
toggleValue() {
|
|
1036
|
-
const
|
|
1037
|
-
if (this.value === undefined && (this.value = []),
|
|
1038
|
-
const
|
|
1039
|
-
this.isGroupSelected(
|
|
1150
|
+
const t2 = this.options[this.cursor];
|
|
1151
|
+
if (this.value === undefined && (this.value = []), t2.group === true) {
|
|
1152
|
+
const r2 = t2.value, e = this.getGroupItems(r2);
|
|
1153
|
+
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));
|
|
1040
1154
|
} else {
|
|
1041
|
-
const
|
|
1042
|
-
this.value =
|
|
1155
|
+
const r2 = this.value.includes(t2.value);
|
|
1156
|
+
this.value = r2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
|
|
1043
1157
|
}
|
|
1044
1158
|
}
|
|
1045
|
-
constructor(
|
|
1046
|
-
super(
|
|
1047
|
-
const { options:
|
|
1048
|
-
this.#
|
|
1159
|
+
constructor(t2) {
|
|
1160
|
+
super(t2, false);
|
|
1161
|
+
const { options: r2 } = t2;
|
|
1162
|
+
this.#t = t2.selectableGroups !== false, this.options = Object.entries(r2).flatMap(([e, s]) => [
|
|
1163
|
+
{ value: e, group: true, label: e },
|
|
1164
|
+
...s.map((i) => ({ ...i, group: e }))
|
|
1165
|
+
]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
|
|
1049
1166
|
switch (e) {
|
|
1050
1167
|
case "left":
|
|
1051
1168
|
case "up": {
|
|
1052
1169
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1053
|
-
const
|
|
1054
|
-
!this.#
|
|
1170
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1171
|
+
!this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1055
1172
|
break;
|
|
1056
1173
|
}
|
|
1057
1174
|
case "down":
|
|
1058
1175
|
case "right": {
|
|
1059
1176
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1060
|
-
const
|
|
1061
|
-
!this.#
|
|
1177
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1178
|
+
!this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1062
1179
|
break;
|
|
1063
1180
|
}
|
|
1064
1181
|
case "space":
|
|
@@ -1067,126 +1184,127 @@ class it extends m {
|
|
|
1067
1184
|
}
|
|
1068
1185
|
});
|
|
1069
1186
|
}
|
|
1070
|
-
}
|
|
1187
|
+
};
|
|
1188
|
+
var o$1 = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
1071
1189
|
|
|
1072
|
-
class
|
|
1190
|
+
class h extends V {
|
|
1073
1191
|
#s = false;
|
|
1074
|
-
#
|
|
1192
|
+
#t;
|
|
1075
1193
|
focused = "editor";
|
|
1076
1194
|
get userInputWithCursor() {
|
|
1077
1195
|
if (this.state === "submit")
|
|
1078
1196
|
return this.userInput;
|
|
1079
|
-
const
|
|
1080
|
-
if (this.cursor >=
|
|
1081
|
-
return `${
|
|
1082
|
-
const s =
|
|
1083
|
-
return
|
|
1197
|
+
const t2 = this.userInput;
|
|
1198
|
+
if (this.cursor >= t2.length)
|
|
1199
|
+
return `${t2}\u2588`;
|
|
1200
|
+
const s = t2.slice(0, this.cursor), r2 = t2[this.cursor], e = t2.slice(this.cursor + 1);
|
|
1201
|
+
return r2 === `
|
|
1084
1202
|
` ? `${s}\u2588
|
|
1085
|
-
${
|
|
1203
|
+
${e}` : `${s}${styleText("inverse", r2)}${e}`;
|
|
1086
1204
|
}
|
|
1087
1205
|
get cursor() {
|
|
1088
1206
|
return this._cursor;
|
|
1089
1207
|
}
|
|
1090
|
-
#
|
|
1208
|
+
#r(t2) {
|
|
1091
1209
|
if (this.userInput.length === 0) {
|
|
1092
|
-
this._setUserInput(
|
|
1210
|
+
this._setUserInput(t2);
|
|
1093
1211
|
return;
|
|
1094
1212
|
}
|
|
1095
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) +
|
|
1213
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
|
|
1096
1214
|
}
|
|
1097
|
-
#
|
|
1215
|
+
#i(t2) {
|
|
1098
1216
|
const s = this.value ?? "";
|
|
1099
|
-
switch (
|
|
1217
|
+
switch (t2) {
|
|
1100
1218
|
case "up":
|
|
1101
|
-
this._cursor =
|
|
1219
|
+
this._cursor = findTextCursor(this._cursor, 0, -1, s);
|
|
1102
1220
|
return;
|
|
1103
1221
|
case "down":
|
|
1104
|
-
this._cursor =
|
|
1222
|
+
this._cursor = findTextCursor(this._cursor, 0, 1, s);
|
|
1105
1223
|
return;
|
|
1106
1224
|
case "left":
|
|
1107
|
-
this._cursor =
|
|
1225
|
+
this._cursor = findTextCursor(this._cursor, -1, 0, s);
|
|
1108
1226
|
return;
|
|
1109
1227
|
case "right":
|
|
1110
|
-
this._cursor =
|
|
1228
|
+
this._cursor = findTextCursor(this._cursor, 1, 0, s);
|
|
1111
1229
|
return;
|
|
1112
1230
|
}
|
|
1113
1231
|
}
|
|
1114
|
-
_shouldSubmit(
|
|
1115
|
-
if (this.#
|
|
1116
|
-
return this.focused === "submit" ? true : (this.#
|
|
1232
|
+
_shouldSubmit(t2, s) {
|
|
1233
|
+
if (this.#t)
|
|
1234
|
+
return this.focused === "submit" ? true : (this.#r(`
|
|
1117
1235
|
`), this._cursor++, false);
|
|
1118
|
-
const
|
|
1119
|
-
return this.#s = true,
|
|
1120
|
-
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#
|
|
1236
|
+
const r2 = this.#s;
|
|
1237
|
+
return this.#s = true, r2 ? (this.userInput[this.cursor - 1] === `
|
|
1238
|
+
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
|
|
1121
1239
|
`), this._cursor++, false);
|
|
1122
1240
|
}
|
|
1123
|
-
constructor(
|
|
1124
|
-
super(
|
|
1125
|
-
if (
|
|
1126
|
-
this.#
|
|
1241
|
+
constructor(t2) {
|
|
1242
|
+
super(t2, false), this.#t = t2.showSubmit ?? false, this.on("key", (s, r2) => {
|
|
1243
|
+
if (r2?.name && o$1.has(r2.name)) {
|
|
1244
|
+
this.#i(r2.name);
|
|
1127
1245
|
return;
|
|
1128
1246
|
}
|
|
1129
|
-
if (s === "\t" && this.#
|
|
1247
|
+
if (s === "\t" && this.#t) {
|
|
1130
1248
|
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
1131
1249
|
return;
|
|
1132
1250
|
}
|
|
1133
|
-
if (
|
|
1134
|
-
if (this.#s = false,
|
|
1251
|
+
if (r2?.name !== "return") {
|
|
1252
|
+
if (this.#s = false, r2?.name === "backspace" && this.cursor > 0) {
|
|
1135
1253
|
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
1136
1254
|
return;
|
|
1137
1255
|
}
|
|
1138
|
-
if (
|
|
1256
|
+
if (r2?.name === "delete" && this.cursor < this.userInput.length) {
|
|
1139
1257
|
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
1140
1258
|
return;
|
|
1141
1259
|
}
|
|
1142
|
-
s && (this.#
|
|
1260
|
+
s && (this.#t && this.focused === "submit" && (this.focused = "editor"), this.#r(s ?? ""), this._cursor++);
|
|
1143
1261
|
}
|
|
1144
1262
|
}), this.on("userInput", (s) => {
|
|
1145
1263
|
this._setValue(s);
|
|
1146
1264
|
}), this.on("finalize", () => {
|
|
1147
|
-
this.value || (this.value =
|
|
1265
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
1148
1266
|
});
|
|
1149
1267
|
}
|
|
1150
1268
|
}
|
|
1151
|
-
var
|
|
1269
|
+
var a$1 = class a extends V {
|
|
1152
1270
|
options;
|
|
1153
1271
|
cursor = 0;
|
|
1154
1272
|
get _value() {
|
|
1155
1273
|
return this.options[this.cursor].value;
|
|
1156
1274
|
}
|
|
1157
1275
|
get _enabledOptions() {
|
|
1158
|
-
return this.options.filter((
|
|
1276
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
1159
1277
|
}
|
|
1160
1278
|
toggleAll() {
|
|
1161
|
-
const
|
|
1162
|
-
this.value =
|
|
1279
|
+
const e = this._enabledOptions, i = this.value !== undefined && this.value.length === e.length;
|
|
1280
|
+
this.value = i ? [] : e.map((t2) => t2.value);
|
|
1163
1281
|
}
|
|
1164
1282
|
toggleInvert() {
|
|
1165
|
-
const
|
|
1166
|
-
if (!
|
|
1283
|
+
const e = this.value;
|
|
1284
|
+
if (!e)
|
|
1167
1285
|
return;
|
|
1168
|
-
const
|
|
1169
|
-
this.value =
|
|
1286
|
+
const i = this._enabledOptions.filter((t2) => !e.includes(t2.value));
|
|
1287
|
+
this.value = i.map((t2) => t2.value);
|
|
1170
1288
|
}
|
|
1171
1289
|
toggleValue() {
|
|
1172
1290
|
this.value === undefined && (this.value = []);
|
|
1173
|
-
const
|
|
1174
|
-
this.value =
|
|
1175
|
-
}
|
|
1176
|
-
constructor(
|
|
1177
|
-
super(
|
|
1178
|
-
const
|
|
1179
|
-
this.cursor = this.options[
|
|
1180
|
-
|
|
1181
|
-
}), this.on("cursor", (
|
|
1182
|
-
switch (
|
|
1291
|
+
const e = this.value.includes(this._value);
|
|
1292
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
1293
|
+
}
|
|
1294
|
+
constructor(e) {
|
|
1295
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
1296
|
+
const i = Math.max(this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt), 0);
|
|
1297
|
+
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t2, l2) => {
|
|
1298
|
+
l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
|
|
1299
|
+
}), this.on("cursor", (t2) => {
|
|
1300
|
+
switch (t2) {
|
|
1183
1301
|
case "left":
|
|
1184
1302
|
case "up":
|
|
1185
|
-
this.cursor =
|
|
1303
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1186
1304
|
break;
|
|
1187
1305
|
case "down":
|
|
1188
1306
|
case "right":
|
|
1189
|
-
this.cursor =
|
|
1307
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1190
1308
|
break;
|
|
1191
1309
|
case "space":
|
|
1192
1310
|
this.toggleValue();
|
|
@@ -1195,7 +1313,7 @@ var nt = class extends m {
|
|
|
1195
1313
|
});
|
|
1196
1314
|
}
|
|
1197
1315
|
};
|
|
1198
|
-
class
|
|
1316
|
+
class a2 extends V {
|
|
1199
1317
|
options;
|
|
1200
1318
|
cursor = 0;
|
|
1201
1319
|
get _selectedValue() {
|
|
@@ -1204,393 +1322,496 @@ class ut extends m {
|
|
|
1204
1322
|
changeValue() {
|
|
1205
1323
|
this.value = this._selectedValue.value;
|
|
1206
1324
|
}
|
|
1207
|
-
constructor(
|
|
1208
|
-
super(
|
|
1209
|
-
const
|
|
1210
|
-
this.cursor = this.options[e].disabled ?
|
|
1211
|
-
switch (
|
|
1325
|
+
constructor(t2) {
|
|
1326
|
+
super(t2, false), this.options = t2.options;
|
|
1327
|
+
const i = this.options.findIndex(({ value: s }) => s === t2.initialValue), e = i === -1 ? 0 : i;
|
|
1328
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
1329
|
+
switch (s) {
|
|
1212
1330
|
case "left":
|
|
1213
1331
|
case "up":
|
|
1214
|
-
this.cursor =
|
|
1332
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1215
1333
|
break;
|
|
1216
1334
|
case "down":
|
|
1217
1335
|
case "right":
|
|
1218
|
-
this.cursor =
|
|
1336
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1219
1337
|
break;
|
|
1220
1338
|
}
|
|
1221
1339
|
this.changeValue();
|
|
1222
1340
|
});
|
|
1223
1341
|
}
|
|
1224
1342
|
}
|
|
1225
|
-
class
|
|
1343
|
+
class n extends V {
|
|
1226
1344
|
get userInputWithCursor() {
|
|
1227
1345
|
if (this.state === "submit")
|
|
1228
1346
|
return this.userInput;
|
|
1229
|
-
const
|
|
1230
|
-
if (this.cursor >=
|
|
1347
|
+
const t2 = this.userInput;
|
|
1348
|
+
if (this.cursor >= t2.length)
|
|
1231
1349
|
return `${this.userInput}\u2588`;
|
|
1232
|
-
const
|
|
1233
|
-
return `${
|
|
1350
|
+
const e = t2.slice(0, this.cursor), [s, ...r2] = t2.slice(this.cursor);
|
|
1351
|
+
return `${e}${styleText("inverse", s)}${r2.join("")}`;
|
|
1234
1352
|
}
|
|
1235
1353
|
get cursor() {
|
|
1236
1354
|
return this._cursor;
|
|
1237
1355
|
}
|
|
1238
|
-
constructor(
|
|
1239
|
-
super({
|
|
1240
|
-
|
|
1356
|
+
constructor(t2) {
|
|
1357
|
+
super({
|
|
1358
|
+
...t2,
|
|
1359
|
+
initialUserInput: t2.initialUserInput ?? t2.initialValue
|
|
1360
|
+
}), this.on("userInput", (e) => {
|
|
1361
|
+
this._setValue(e);
|
|
1241
1362
|
}), this.on("finalize", () => {
|
|
1242
|
-
this.value || (this.value =
|
|
1363
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
1243
1364
|
});
|
|
1244
1365
|
}
|
|
1245
1366
|
}
|
|
1246
1367
|
|
|
1247
1368
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
1248
|
-
import { styleText as
|
|
1249
|
-
import
|
|
1369
|
+
import { styleText as styleText2, stripVTControlCharacters } from "util";
|
|
1370
|
+
import process$1 from "process";
|
|
1250
1371
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
1251
|
-
function
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
var
|
|
1258
|
-
var
|
|
1259
|
-
var
|
|
1260
|
-
var
|
|
1261
|
-
var
|
|
1262
|
-
var
|
|
1263
|
-
var
|
|
1264
|
-
var
|
|
1265
|
-
var
|
|
1266
|
-
var
|
|
1267
|
-
var
|
|
1268
|
-
var
|
|
1269
|
-
var
|
|
1270
|
-
var
|
|
1271
|
-
var
|
|
1272
|
-
var
|
|
1273
|
-
var
|
|
1274
|
-
var
|
|
1275
|
-
var
|
|
1276
|
-
var
|
|
1277
|
-
var
|
|
1278
|
-
var
|
|
1279
|
-
var
|
|
1280
|
-
var
|
|
1281
|
-
var
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1372
|
+
function isUnicodeSupported() {
|
|
1373
|
+
if (process$1.platform !== "win32") {
|
|
1374
|
+
return process$1.env.TERM !== "linux";
|
|
1375
|
+
}
|
|
1376
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1377
|
+
}
|
|
1378
|
+
var unicode = isUnicodeSupported();
|
|
1379
|
+
var isCI = () => process.env.CI === "true";
|
|
1380
|
+
var unicodeOr = (e, o2) => unicode ? e : o2;
|
|
1381
|
+
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
1382
|
+
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
1383
|
+
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
1384
|
+
var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
|
|
1385
|
+
var S_BAR_START = unicodeOr("\u250C", "T");
|
|
1386
|
+
var S_BAR = unicodeOr("\u2502", "|");
|
|
1387
|
+
var S_BAR_END = unicodeOr("\u2514", "\u2014");
|
|
1388
|
+
var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
|
|
1389
|
+
var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
|
|
1390
|
+
var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
|
|
1391
|
+
var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
|
|
1392
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
|
|
1393
|
+
var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
|
|
1394
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
|
|
1395
|
+
var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
|
|
1396
|
+
var S_BAR_H = unicodeOr("\u2500", "-");
|
|
1397
|
+
var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
|
|
1398
|
+
var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
|
|
1399
|
+
var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
|
|
1400
|
+
var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
|
|
1401
|
+
var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
|
|
1402
|
+
var S_INFO = unicodeOr("\u25CF", "\u2022");
|
|
1403
|
+
var S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
1404
|
+
var S_WARN = unicodeOr("\u25B2", "!");
|
|
1405
|
+
var S_ERROR = unicodeOr("\u25A0", "x");
|
|
1406
|
+
var symbol = (e) => {
|
|
1407
|
+
switch (e) {
|
|
1284
1408
|
case "initial":
|
|
1285
1409
|
case "active":
|
|
1286
|
-
return
|
|
1410
|
+
return styleText2("cyan", S_STEP_ACTIVE);
|
|
1287
1411
|
case "cancel":
|
|
1288
|
-
return
|
|
1412
|
+
return styleText2("red", S_STEP_CANCEL);
|
|
1289
1413
|
case "error":
|
|
1290
|
-
return
|
|
1414
|
+
return styleText2("yellow", S_STEP_ERROR);
|
|
1291
1415
|
case "submit":
|
|
1292
|
-
return
|
|
1416
|
+
return styleText2("green", S_STEP_SUBMIT);
|
|
1293
1417
|
}
|
|
1294
1418
|
};
|
|
1295
|
-
var
|
|
1296
|
-
switch (
|
|
1419
|
+
var symbolBar = (e) => {
|
|
1420
|
+
switch (e) {
|
|
1297
1421
|
case "initial":
|
|
1298
1422
|
case "active":
|
|
1299
|
-
return
|
|
1423
|
+
return styleText2("cyan", S_BAR);
|
|
1300
1424
|
case "cancel":
|
|
1301
|
-
return
|
|
1425
|
+
return styleText2("red", S_BAR);
|
|
1302
1426
|
case "error":
|
|
1303
|
-
return
|
|
1427
|
+
return styleText2("yellow", S_BAR);
|
|
1304
1428
|
case "submit":
|
|
1305
|
-
return
|
|
1429
|
+
return styleText2("green", S_BAR);
|
|
1306
1430
|
}
|
|
1307
1431
|
};
|
|
1308
|
-
var
|
|
1309
|
-
let
|
|
1310
|
-
if (
|
|
1311
|
-
for (let
|
|
1432
|
+
var E$1 = (l2, o2, g2, c2, h2, O = false) => {
|
|
1433
|
+
let r2 = o2, w = 0;
|
|
1434
|
+
if (O)
|
|
1435
|
+
for (let i = c2 - 1;i >= g2 && (r2 -= l2[i].length, w++, !(r2 <= h2)); i--)
|
|
1312
1436
|
;
|
|
1313
1437
|
else
|
|
1314
|
-
for (let
|
|
1438
|
+
for (let i = g2;i < c2 && (r2 -= l2[i].length, w++, !(r2 <= h2)); i++)
|
|
1315
1439
|
;
|
|
1316
|
-
return { lineCount:
|
|
1440
|
+
return { lineCount: r2, removals: w };
|
|
1317
1441
|
};
|
|
1318
|
-
var
|
|
1319
|
-
|
|
1442
|
+
var limitOptions = ({
|
|
1443
|
+
cursor: l2,
|
|
1444
|
+
options: o2,
|
|
1445
|
+
style: g2,
|
|
1446
|
+
output: c2 = process.stdout,
|
|
1447
|
+
maxItems: h2 = Number.POSITIVE_INFINITY,
|
|
1448
|
+
columnPadding: O = 0,
|
|
1449
|
+
rowPadding: r2 = 4
|
|
1450
|
+
}) => {
|
|
1451
|
+
const i = getColumns(c2) - O, I = getRows(c2), C2 = styleText2("dim", "..."), x = Math.max(I - r2, 0), m2 = Math.max(Math.min(h2, x), 5);
|
|
1320
1452
|
let p2 = 0;
|
|
1321
|
-
|
|
1322
|
-
let f2 =
|
|
1323
|
-
const
|
|
1324
|
-
let
|
|
1325
|
-
f2 &&
|
|
1326
|
-
const
|
|
1327
|
-
for (let
|
|
1328
|
-
const
|
|
1453
|
+
l2 >= m2 - 3 && (p2 = Math.max(Math.min(l2 - m2 + 3, o2.length - m2), 0));
|
|
1454
|
+
let f2 = m2 < o2.length && p2 > 0, u3 = m2 < o2.length && p2 + m2 < o2.length;
|
|
1455
|
+
const W = Math.min(p2 + m2, o2.length), e = [];
|
|
1456
|
+
let d = 0;
|
|
1457
|
+
f2 && d++, u3 && d++;
|
|
1458
|
+
const v = p2 + (f2 ? 1 : 0), P2 = W - (u3 ? 1 : 0);
|
|
1459
|
+
for (let t2 = v;t2 < P2; t2++) {
|
|
1460
|
+
const n2 = wrapAnsi(g2(o2[t2], t2 === l2), i, {
|
|
1461
|
+
hard: true,
|
|
1462
|
+
trim: false
|
|
1463
|
+
}).split(`
|
|
1329
1464
|
`);
|
|
1330
|
-
|
|
1331
|
-
}
|
|
1332
|
-
if (
|
|
1333
|
-
let
|
|
1334
|
-
const
|
|
1335
|
-
let
|
|
1336
|
-
const
|
|
1337
|
-
f2 ? ({ lineCount:
|
|
1338
|
-
}
|
|
1339
|
-
const
|
|
1340
|
-
f2 &&
|
|
1341
|
-
for (const
|
|
1342
|
-
for (const
|
|
1343
|
-
|
|
1344
|
-
return
|
|
1465
|
+
e.push(n2), d += n2.length;
|
|
1466
|
+
}
|
|
1467
|
+
if (d > x) {
|
|
1468
|
+
let t2 = 0, n2 = 0, s = d;
|
|
1469
|
+
const M2 = l2 - v;
|
|
1470
|
+
let a3 = x;
|
|
1471
|
+
const T3 = () => E$1(e, s, 0, M2, a3), L = () => E$1(e, s, M2 + 1, e.length, a3, true);
|
|
1472
|
+
f2 ? ({ lineCount: s, removals: t2 } = T3(), s > a3 && (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L())) : (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L(), s > a3 && (a3 -= 1, { lineCount: s, removals: t2 } = T3())), t2 > 0 && (f2 = true, e.splice(0, t2)), n2 > 0 && (u3 = true, e.splice(e.length - n2, n2));
|
|
1473
|
+
}
|
|
1474
|
+
const b2 = [];
|
|
1475
|
+
f2 && b2.push(C2);
|
|
1476
|
+
for (const t2 of e)
|
|
1477
|
+
for (const n2 of t2)
|
|
1478
|
+
b2.push(n2);
|
|
1479
|
+
return u3 && b2.push(C2), b2;
|
|
1345
1480
|
};
|
|
1346
|
-
var
|
|
1347
|
-
const
|
|
1348
|
-
return new
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
${
|
|
1481
|
+
var confirm = (i) => {
|
|
1482
|
+
const a3 = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
1483
|
+
return new r({
|
|
1484
|
+
active: a3,
|
|
1485
|
+
inactive: s,
|
|
1486
|
+
signal: i.signal,
|
|
1487
|
+
input: i.input,
|
|
1488
|
+
output: i.output,
|
|
1489
|
+
initialValue: i.initialValue ?? true,
|
|
1490
|
+
render() {
|
|
1491
|
+
const e = i.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l2 = e ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(i.output, i.message, l2, u3), o2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
1492
|
+
` : ""}${f2}
|
|
1493
|
+
`, c2 = this.value ? a3 : s;
|
|
1494
|
+
switch (this.state) {
|
|
1495
|
+
case "submit": {
|
|
1496
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1497
|
+
return `${o2}${r2}${styleText2("dim", c2)}`;
|
|
1498
|
+
}
|
|
1499
|
+
case "cancel": {
|
|
1500
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1501
|
+
return `${o2}${r2}${styleText2(["strikethrough", "dim"], c2)}${e ? `
|
|
1502
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1503
|
+
}
|
|
1504
|
+
default: {
|
|
1505
|
+
const r2 = e ? `${styleText2("cyan", S_BAR)} ` : "", g2 = e ? styleText2("cyan", S_BAR_END) : "";
|
|
1506
|
+
return `${o2}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a3}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a3)}`}${i.vertical ? e ? `
|
|
1507
|
+
${styleText2("cyan", S_BAR)} ` : `
|
|
1508
|
+
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", s)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${s}`}
|
|
1509
|
+
${g2}
|
|
1368
1510
|
`;
|
|
1511
|
+
}
|
|
1369
1512
|
}
|
|
1370
1513
|
}
|
|
1371
|
-
}
|
|
1514
|
+
}).prompt();
|
|
1372
1515
|
};
|
|
1373
|
-
var
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1516
|
+
var cancel = (o2 = "", t2) => {
|
|
1517
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
1518
|
+
i.write(`${e}${styleText2("red", o2)}
|
|
1376
1519
|
|
|
1377
1520
|
`);
|
|
1378
1521
|
};
|
|
1379
|
-
var
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1522
|
+
var intro = (o2 = "", t2) => {
|
|
1523
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
1524
|
+
i.write(`${e}${o2}
|
|
1382
1525
|
`);
|
|
1383
1526
|
};
|
|
1384
|
-
var
|
|
1385
|
-
const
|
|
1386
|
-
${
|
|
1387
|
-
|
|
1527
|
+
var outro = (o2 = "", t2) => {
|
|
1528
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
1529
|
+
${styleText2("gray", S_BAR_END)} ` : "";
|
|
1530
|
+
i.write(`${e}${o2}
|
|
1388
1531
|
|
|
1389
1532
|
`);
|
|
1390
1533
|
};
|
|
1391
|
-
var
|
|
1392
|
-
`).map((
|
|
1534
|
+
var d = (n2, a3) => n2.split(`
|
|
1535
|
+
`).map((m2) => a3(m2)).join(`
|
|
1393
1536
|
`);
|
|
1394
|
-
var
|
|
1395
|
-
const
|
|
1396
|
-
const
|
|
1397
|
-
return
|
|
1398
|
-
},
|
|
1399
|
-
return new
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1537
|
+
var multiselect = (n2) => {
|
|
1538
|
+
const a3 = (t2, o2) => {
|
|
1539
|
+
const r2 = t2.label ?? String(t2.value);
|
|
1540
|
+
return o2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${d(r2, (l2) => styleText2(["strikethrough", "gray"], l2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : o2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${d(r2, (l2) => styleText2("dim", l2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "cancelled" ? `${d(r2, (l2) => styleText2(["strikethrough", "dim"], l2))}` : o2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "submitted" ? `${d(r2, (l2) => styleText2("dim", l2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${d(r2, (l2) => styleText2("dim", l2))}`;
|
|
1541
|
+
}, m2 = n2.required ?? true;
|
|
1542
|
+
return new a$1({
|
|
1543
|
+
options: n2.options,
|
|
1544
|
+
signal: n2.signal,
|
|
1545
|
+
input: n2.input,
|
|
1546
|
+
output: n2.output,
|
|
1547
|
+
initialValues: n2.initialValues,
|
|
1548
|
+
required: m2,
|
|
1549
|
+
cursorAt: n2.cursorAt,
|
|
1550
|
+
validate(t2) {
|
|
1551
|
+
if (m2 && (t2 === undefined || t2.length === 0))
|
|
1552
|
+
return `Please select at least one option.
|
|
1553
|
+
${styleText2("reset", styleText2("dim", `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2("gray", styleText2("bgWhite", styleText2("inverse", " enter ")))} to submit`))}`;
|
|
1554
|
+
},
|
|
1555
|
+
render() {
|
|
1556
|
+
const t2 = n2.withGuide ?? settings.withGuide, o2 = wrapTextWithPrefix(n2.output, n2.message, t2 ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1557
|
+
` : ""}${o2}
|
|
1558
|
+
`, l2 = this.value ?? [], g2 = (i, u3) => {
|
|
1559
|
+
if (i.disabled)
|
|
1560
|
+
return a3(i, "disabled");
|
|
1561
|
+
const s = l2.includes(i.value);
|
|
1562
|
+
return u3 && s ? a3(i, "active-selected") : s ? a3(i, "selected") : a3(i, u3 ? "active" : "inactive");
|
|
1563
|
+
};
|
|
1564
|
+
switch (this.state) {
|
|
1565
|
+
case "submit": {
|
|
1566
|
+
const i = this.options.filter(({ value: s }) => l2.includes(s)).map((s) => a3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), u3 = wrapTextWithPrefix(n2.output, i, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
1567
|
+
return `${r2}${u3}`;
|
|
1568
|
+
}
|
|
1569
|
+
case "cancel": {
|
|
1570
|
+
const i = this.options.filter(({ value: s }) => l2.includes(s)).map((s) => a3(s, "cancelled")).join(styleText2("dim", ", "));
|
|
1571
|
+
if (i.trim() === "")
|
|
1572
|
+
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
1573
|
+
const u3 = wrapTextWithPrefix(n2.output, i, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
1574
|
+
return `${r2}${u3}${t2 ? `
|
|
1575
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1576
|
+
}
|
|
1577
|
+
case "error": {
|
|
1578
|
+
const i = t2 ? `${styleText2("yellow", S_BAR)} ` : "", u3 = this.error.split(`
|
|
1579
|
+
`).map((h2, x) => x === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", h2)}` : ` ${h2}`).join(`
|
|
1580
|
+
`), s = r2.split(`
|
|
1581
|
+
`).length, v = u3.split(`
|
|
1430
1582
|
`).length + 1;
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1583
|
+
return `${r2}${i}${limitOptions({
|
|
1584
|
+
output: n2.output,
|
|
1585
|
+
options: this.options,
|
|
1586
|
+
cursor: this.cursor,
|
|
1587
|
+
maxItems: n2.maxItems,
|
|
1588
|
+
columnPadding: i.length,
|
|
1589
|
+
rowPadding: s + v,
|
|
1590
|
+
style: g2
|
|
1591
|
+
}).join(`
|
|
1592
|
+
${i}`)}
|
|
1593
|
+
${u3}
|
|
1434
1594
|
`;
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
`).length,
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1595
|
+
}
|
|
1596
|
+
default: {
|
|
1597
|
+
const i = t2 ? `${styleText2("cyan", S_BAR)} ` : "", u3 = r2.split(`
|
|
1598
|
+
`).length, s = t2 ? 2 : 1;
|
|
1599
|
+
return `${r2}${i}${limitOptions({
|
|
1600
|
+
output: n2.output,
|
|
1601
|
+
options: this.options,
|
|
1602
|
+
cursor: this.cursor,
|
|
1603
|
+
maxItems: n2.maxItems,
|
|
1604
|
+
columnPadding: i.length,
|
|
1605
|
+
rowPadding: u3 + s,
|
|
1606
|
+
style: g2
|
|
1607
|
+
}).join(`
|
|
1608
|
+
${i}`)}
|
|
1609
|
+
${t2 ? styleText2("cyan", S_BAR_END) : ""}
|
|
1442
1610
|
`;
|
|
1611
|
+
}
|
|
1443
1612
|
}
|
|
1444
1613
|
}
|
|
1445
|
-
}
|
|
1614
|
+
}).prompt();
|
|
1446
1615
|
};
|
|
1447
|
-
var
|
|
1448
|
-
var
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1616
|
+
var W = (l2) => styleText2("magenta", l2);
|
|
1617
|
+
var spinner = ({
|
|
1618
|
+
indicator: l2 = "dots",
|
|
1619
|
+
onCancel: h2,
|
|
1620
|
+
output: n2 = process.stdout,
|
|
1621
|
+
cancelMessage: G,
|
|
1622
|
+
errorMessage: O,
|
|
1623
|
+
frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
1624
|
+
delay: F = unicode ? 80 : 120,
|
|
1625
|
+
signal: m2,
|
|
1626
|
+
...I
|
|
1627
|
+
} = {}) => {
|
|
1628
|
+
const u3 = isCI();
|
|
1629
|
+
let M2, T3, d2 = false, S = false, s = "", p2, w = performance.now();
|
|
1630
|
+
const x = getColumns(n2), k = I?.styleFrame ?? W, g2 = (e) => {
|
|
1631
|
+
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1632
|
+
S = e === 1, d2 && (a3(r2, e), S && typeof h2 == "function" && h2());
|
|
1633
|
+
}, f2 = () => g2(2), i = () => g2(1), A = () => {
|
|
1634
|
+
process.on("uncaughtExceptionMonitor", f2), process.on("unhandledRejection", f2), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g2), m2 && m2.addEventListener("abort", i);
|
|
1635
|
+
}, H = () => {
|
|
1636
|
+
process.removeListener("uncaughtExceptionMonitor", f2), process.removeListener("unhandledRejection", f2), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g2), m2 && m2.removeEventListener("abort", i);
|
|
1637
|
+
}, y = () => {
|
|
1638
|
+
if (p2 === undefined)
|
|
1460
1639
|
return;
|
|
1461
|
-
|
|
1640
|
+
u3 && n2.write(`
|
|
1462
1641
|
`);
|
|
1463
|
-
const
|
|
1642
|
+
const r2 = wrapAnsi(p2, x, {
|
|
1643
|
+
hard: true,
|
|
1644
|
+
trim: false
|
|
1645
|
+
}).split(`
|
|
1464
1646
|
`);
|
|
1465
|
-
|
|
1466
|
-
},
|
|
1467
|
-
const
|
|
1468
|
-
return
|
|
1469
|
-
},
|
|
1470
|
-
|
|
1647
|
+
r2.length > 1 && n2.write(import_sisteransi2.cursor.up(r2.length - 1)), n2.write(import_sisteransi2.cursor.to(0)), n2.write(import_sisteransi2.erase.down());
|
|
1648
|
+
}, C2 = (e) => e.replace(/\.+$/, ""), _2 = (e) => {
|
|
1649
|
+
const r2 = (performance.now() - e) / 1000, t2 = Math.floor(r2 / 60), o2 = Math.floor(r2 % 60);
|
|
1650
|
+
return t2 > 0 ? `[${t2}m ${o2}s]` : `[${o2}s]`;
|
|
1651
|
+
}, N = I.withGuide ?? settings.withGuide, P2 = (e = "") => {
|
|
1652
|
+
d2 = true, M2 = block({ output: n2 }), s = C2(e), w = performance.now(), N && n2.write(`${styleText2("gray", S_BAR)}
|
|
1471
1653
|
`);
|
|
1472
|
-
let
|
|
1473
|
-
|
|
1474
|
-
if (
|
|
1654
|
+
let r2 = 0, t2 = 0;
|
|
1655
|
+
A(), T3 = setInterval(() => {
|
|
1656
|
+
if (u3 && s === p2)
|
|
1475
1657
|
return;
|
|
1476
|
-
|
|
1477
|
-
const
|
|
1478
|
-
let
|
|
1479
|
-
if (
|
|
1480
|
-
|
|
1481
|
-
else if (
|
|
1482
|
-
|
|
1658
|
+
y(), p2 = s;
|
|
1659
|
+
const o2 = k(E[r2]);
|
|
1660
|
+
let v;
|
|
1661
|
+
if (u3)
|
|
1662
|
+
v = `${o2} ${s}...`;
|
|
1663
|
+
else if (l2 === "timer")
|
|
1664
|
+
v = `${o2} ${s} ${_2(w)}`;
|
|
1483
1665
|
else {
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1666
|
+
const B = ".".repeat(Math.floor(t2)).slice(0, 3);
|
|
1667
|
+
v = `${o2} ${s}${B}`;
|
|
1486
1668
|
}
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1669
|
+
const j = wrapAnsi(v, x, {
|
|
1670
|
+
hard: true,
|
|
1671
|
+
trim: false
|
|
1672
|
+
});
|
|
1673
|
+
n2.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
|
|
1674
|
+
}, F);
|
|
1675
|
+
}, a3 = (e = "", r2 = 0, t2 = false) => {
|
|
1676
|
+
if (!d2)
|
|
1492
1677
|
return;
|
|
1493
|
-
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
`) :
|
|
1497
|
-
`)),
|
|
1678
|
+
d2 = false, clearInterval(T3), y();
|
|
1679
|
+
const o2 = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
1680
|
+
s = e ?? s, t2 || (l2 === "timer" ? n2.write(`${o2} ${s} ${_2(w)}
|
|
1681
|
+
`) : n2.write(`${o2} ${s}
|
|
1682
|
+
`)), H(), M2();
|
|
1683
|
+
};
|
|
1684
|
+
return {
|
|
1685
|
+
start: P2,
|
|
1686
|
+
stop: (e = "") => a3(e, 0),
|
|
1687
|
+
message: (e = "") => {
|
|
1688
|
+
s = C2(e ?? s);
|
|
1689
|
+
},
|
|
1690
|
+
cancel: (e = "") => a3(e, 1),
|
|
1691
|
+
error: (e = "") => a3(e, 2),
|
|
1692
|
+
clear: () => a3("", 0, true),
|
|
1693
|
+
get isCancelled() {
|
|
1694
|
+
return S;
|
|
1695
|
+
}
|
|
1498
1696
|
};
|
|
1499
|
-
return { start: rt2, stop: (_ = "") => W2(_, 0), message: (_ = "") => {
|
|
1500
|
-
h2 = O2(_ ?? h2);
|
|
1501
|
-
}, cancel: (_ = "") => W2(_, 1), error: (_ = "") => W2(_, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
1502
|
-
return f2;
|
|
1503
|
-
} };
|
|
1504
1697
|
};
|
|
1505
|
-
var
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
var
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1698
|
+
var u3 = {
|
|
1699
|
+
light: unicodeOr("\u2500", "-"),
|
|
1700
|
+
heavy: unicodeOr("\u2501", "="),
|
|
1701
|
+
block: unicodeOr("\u2588", "#")
|
|
1702
|
+
};
|
|
1703
|
+
var c2 = (e, a3) => e.includes(`
|
|
1704
|
+
`) ? e.split(`
|
|
1705
|
+
`).map((t2) => a3(t2)).join(`
|
|
1706
|
+
`) : a3(e);
|
|
1707
|
+
var select = (e) => {
|
|
1708
|
+
const a3 = (t2, d2) => {
|
|
1709
|
+
const s = t2.label ?? String(t2.value);
|
|
1710
|
+
switch (d2) {
|
|
1514
1711
|
case "disabled":
|
|
1515
|
-
return `${
|
|
1712
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("gray", n2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}`;
|
|
1516
1713
|
case "selected":
|
|
1517
|
-
return `${
|
|
1714
|
+
return `${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
1518
1715
|
case "active":
|
|
1519
|
-
return `${
|
|
1716
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}`;
|
|
1520
1717
|
case "cancelled":
|
|
1521
|
-
return `${
|
|
1718
|
+
return `${c2(s, (n2) => styleText2(["strikethrough", "dim"], n2))}`;
|
|
1522
1719
|
default:
|
|
1523
|
-
return `${
|
|
1720
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
1524
1721
|
}
|
|
1525
1722
|
};
|
|
1526
|
-
return new
|
|
1527
|
-
|
|
1528
|
-
|
|
1723
|
+
return new a2({
|
|
1724
|
+
options: e.options,
|
|
1725
|
+
signal: e.signal,
|
|
1726
|
+
input: e.input,
|
|
1727
|
+
output: e.output,
|
|
1728
|
+
initialValue: e.initialValue,
|
|
1729
|
+
render() {
|
|
1730
|
+
const t2 = e.withGuide ?? settings.withGuide, d2 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n2 = wrapTextWithPrefix(e.output, e.message, s, d2), u4 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1731
|
+
` : ""}${n2}
|
|
1732
|
+
`;
|
|
1733
|
+
switch (this.state) {
|
|
1734
|
+
case "submit": {
|
|
1735
|
+
const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(e.output, a3(this.options[this.cursor], "selected"), r2);
|
|
1736
|
+
return `${u4}${l2}`;
|
|
1737
|
+
}
|
|
1738
|
+
case "cancel": {
|
|
1739
|
+
const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(e.output, a3(this.options[this.cursor], "cancelled"), r2);
|
|
1740
|
+
return `${u4}${l2}${t2 ? `
|
|
1741
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1742
|
+
}
|
|
1743
|
+
default: {
|
|
1744
|
+
const r2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = t2 ? styleText2("cyan", S_BAR_END) : "", g2 = u4.split(`
|
|
1745
|
+
`).length, h2 = t2 ? 2 : 1;
|
|
1746
|
+
return `${u4}${r2}${limitOptions({
|
|
1747
|
+
output: e.output,
|
|
1748
|
+
cursor: this.cursor,
|
|
1749
|
+
options: this.options,
|
|
1750
|
+
maxItems: e.maxItems,
|
|
1751
|
+
columnPadding: r2.length,
|
|
1752
|
+
rowPadding: g2 + h2,
|
|
1753
|
+
style: (p2, b2) => a3(p2, p2.disabled ? "disabled" : b2 ? "active" : "inactive")
|
|
1754
|
+
}).join(`
|
|
1755
|
+
${r2}`)}
|
|
1756
|
+
${l2}
|
|
1529
1757
|
`;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}).prompt();
|
|
1762
|
+
};
|
|
1763
|
+
var i = `${styleText2("gray", S_BAR)} `;
|
|
1764
|
+
var text = (t2) => new n({
|
|
1765
|
+
validate: t2.validate,
|
|
1766
|
+
placeholder: t2.placeholder,
|
|
1767
|
+
defaultValue: t2.defaultValue,
|
|
1768
|
+
initialValue: t2.initialValue,
|
|
1769
|
+
output: t2.output,
|
|
1770
|
+
signal: t2.signal,
|
|
1771
|
+
input: t2.input,
|
|
1772
|
+
render() {
|
|
1773
|
+
const i2 = t2?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${styleText2("gray", S_BAR)}
|
|
1774
|
+
` : ""}${symbol(this.state)} `}${t2.message}
|
|
1775
|
+
`, c3 = t2.placeholder ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : c3, a3 = this.value ?? "";
|
|
1530
1776
|
switch (this.state) {
|
|
1777
|
+
case "error": {
|
|
1778
|
+
const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i2 ? `${styleText2("yellow", S_BAR)} ` : "", d2 = i2 ? styleText2("yellow", S_BAR_END) : "";
|
|
1779
|
+
return `${s.trim()}
|
|
1780
|
+
${r2}${o2}
|
|
1781
|
+
${d2}${n2}
|
|
1782
|
+
`;
|
|
1783
|
+
}
|
|
1531
1784
|
case "submit": {
|
|
1532
|
-
const
|
|
1533
|
-
return `${
|
|
1785
|
+
const n2 = a3 ? ` ${styleText2("dim", a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1786
|
+
return `${s}${r2}${n2}`;
|
|
1534
1787
|
}
|
|
1535
1788
|
case "cancel": {
|
|
1536
|
-
const
|
|
1537
|
-
return `${
|
|
1538
|
-
${
|
|
1789
|
+
const n2 = a3 ? ` ${styleText2(["strikethrough", "dim"], a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1790
|
+
return `${s}${r2}${n2}${a3.trim() ? `
|
|
1791
|
+
${r2}` : ""}`;
|
|
1539
1792
|
}
|
|
1540
1793
|
default: {
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
${c}`)}
|
|
1545
|
-
${o}
|
|
1794
|
+
const n2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "";
|
|
1795
|
+
return `${s}${n2}${o2}
|
|
1796
|
+
${r2}
|
|
1546
1797
|
`;
|
|
1547
1798
|
}
|
|
1548
1799
|
}
|
|
1549
|
-
} }).prompt();
|
|
1550
|
-
};
|
|
1551
|
-
var Nt = `${e("gray", $2)} `;
|
|
1552
|
-
var Pe = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
1553
|
-
const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${e("gray", $2)}
|
|
1554
|
-
` : ""}${P2(this.state)} `}${t.message}
|
|
1555
|
-
`, r = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
1556
|
-
switch (this.state) {
|
|
1557
|
-
case "error": {
|
|
1558
|
-
const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $2)} ` : "", o = i ? e("yellow", x2) : "";
|
|
1559
|
-
return `${s.trim()}
|
|
1560
|
-
${c}${u}
|
|
1561
|
-
${o}${a}
|
|
1562
|
-
`;
|
|
1563
|
-
}
|
|
1564
|
-
case "submit": {
|
|
1565
|
-
const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $2) : "";
|
|
1566
|
-
return `${s}${c}${a}`;
|
|
1567
|
-
}
|
|
1568
|
-
case "cancel": {
|
|
1569
|
-
const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $2) : "";
|
|
1570
|
-
return `${s}${c}${a}${n.trim() ? `
|
|
1571
|
-
${c}` : ""}`;
|
|
1572
|
-
}
|
|
1573
|
-
default: {
|
|
1574
|
-
const a = i ? `${e("cyan", $2)} ` : "", c = i ? e("cyan", x2) : "";
|
|
1575
|
-
return `${s}${a}${u}
|
|
1576
|
-
${c}
|
|
1577
|
-
`;
|
|
1578
|
-
}
|
|
1579
1800
|
}
|
|
1580
|
-
}
|
|
1801
|
+
}).prompt();
|
|
1581
1802
|
|
|
1582
1803
|
// apps/cli/utils/multiselect.ts
|
|
1583
1804
|
async function MultiSelect({
|
|
1584
1805
|
message,
|
|
1585
1806
|
options
|
|
1586
1807
|
}) {
|
|
1587
|
-
const selected = await
|
|
1808
|
+
const selected = await multiselect({
|
|
1588
1809
|
message,
|
|
1589
1810
|
options,
|
|
1590
1811
|
required: true
|
|
1591
1812
|
});
|
|
1592
|
-
if (
|
|
1593
|
-
|
|
1813
|
+
if (isCancel(selected)) {
|
|
1814
|
+
cancel("Operation cancelled.");
|
|
1594
1815
|
process.exit(0);
|
|
1595
1816
|
}
|
|
1596
1817
|
return selected;
|
|
@@ -1611,7 +1832,7 @@ class AddCommand {
|
|
|
1611
1832
|
console.log(`${CHECK({ text: "All changes are either staged or sensitive (like .env)." })}`);
|
|
1612
1833
|
return;
|
|
1613
1834
|
}
|
|
1614
|
-
const options = changes.map((
|
|
1835
|
+
const options = changes.map((c3) => ({ value: c3.value, label: c3.label }));
|
|
1615
1836
|
const selectedChanges = await MultiSelect({
|
|
1616
1837
|
message: `Select the changes you want to commit.
|
|
1617
1838
|
` + BLUE({ text: "[space] to select" }) + `
|
|
@@ -1623,7 +1844,7 @@ class AddCommand {
|
|
|
1623
1844
|
});
|
|
1624
1845
|
let selected = selectedChanges.map((file) => file.trim());
|
|
1625
1846
|
if (selected.includes("all")) {
|
|
1626
|
-
selected = changes.map((
|
|
1847
|
+
selected = changes.map((c3) => c3.value);
|
|
1627
1848
|
}
|
|
1628
1849
|
if (selected.length > 0) {
|
|
1629
1850
|
await this.stageChangesUseCase.execute(selected);
|
|
@@ -1688,8 +1909,8 @@ class Change {
|
|
|
1688
1909
|
}
|
|
1689
1910
|
static fromPorcelain(entries) {
|
|
1690
1911
|
const changes = [];
|
|
1691
|
-
for (let
|
|
1692
|
-
const entry = entries[
|
|
1912
|
+
for (let i2 = 0;i2 < entries.length; i2++) {
|
|
1913
|
+
const entry = entries[i2];
|
|
1693
1914
|
if (!entry)
|
|
1694
1915
|
continue;
|
|
1695
1916
|
const status = entry.slice(0, 2);
|
|
@@ -1700,7 +1921,7 @@ class Change {
|
|
|
1700
1921
|
let displayPath = file;
|
|
1701
1922
|
const value = file;
|
|
1702
1923
|
if (status.startsWith("R") || status.startsWith("C")) {
|
|
1703
|
-
const source = entries[++
|
|
1924
|
+
const source = entries[++i2];
|
|
1704
1925
|
displayPath = `${source} -> ${file}`;
|
|
1705
1926
|
}
|
|
1706
1927
|
changes.push(new Change({ value, status, displayPath }));
|
|
@@ -1750,11 +1971,11 @@ class StageChangesUseCase {
|
|
|
1750
1971
|
}
|
|
1751
1972
|
|
|
1752
1973
|
// apps/cli/modules/add/infra/bun-git.repository.ts
|
|
1753
|
-
var {
|
|
1974
|
+
var {$ } = globalThis.Bun;
|
|
1754
1975
|
class BunGitRepository {
|
|
1755
1976
|
async getEntries() {
|
|
1756
1977
|
try {
|
|
1757
|
-
const output = await
|
|
1978
|
+
const output = await $`git status --porcelain -z`.quiet().text();
|
|
1758
1979
|
if (!output.trim()) {
|
|
1759
1980
|
return [];
|
|
1760
1981
|
}
|
|
@@ -1891,7 +2112,7 @@ async function Input({
|
|
|
1891
2112
|
message,
|
|
1892
2113
|
placeholder
|
|
1893
2114
|
}) {
|
|
1894
|
-
const value = await
|
|
2115
|
+
const value = await text({
|
|
1895
2116
|
message,
|
|
1896
2117
|
placeholder,
|
|
1897
2118
|
validate(input) {
|
|
@@ -1900,8 +2121,8 @@ async function Input({
|
|
|
1900
2121
|
}
|
|
1901
2122
|
}
|
|
1902
2123
|
});
|
|
1903
|
-
if (
|
|
1904
|
-
|
|
2124
|
+
if (isCancel(value)) {
|
|
2125
|
+
cancel("Operation cancelled.");
|
|
1905
2126
|
process.exit(0);
|
|
1906
2127
|
}
|
|
1907
2128
|
return value.trim();
|
|
@@ -1912,12 +2133,12 @@ async function Select({
|
|
|
1912
2133
|
message,
|
|
1913
2134
|
options
|
|
1914
2135
|
}) {
|
|
1915
|
-
const selected = await
|
|
2136
|
+
const selected = await select({
|
|
1916
2137
|
message,
|
|
1917
2138
|
options
|
|
1918
2139
|
});
|
|
1919
|
-
if (
|
|
1920
|
-
|
|
2140
|
+
if (isCancel(selected)) {
|
|
2141
|
+
cancel("Operation cancelled.");
|
|
1921
2142
|
process.exit(0);
|
|
1922
2143
|
}
|
|
1923
2144
|
return selected;
|
|
@@ -1994,12 +2215,12 @@ async function Confirm({
|
|
|
1994
2215
|
cancelMessage,
|
|
1995
2216
|
exitOnCancel = true
|
|
1996
2217
|
}) {
|
|
1997
|
-
const confirmed = await
|
|
2218
|
+
const confirmed = await confirm({
|
|
1998
2219
|
message
|
|
1999
2220
|
});
|
|
2000
|
-
if (
|
|
2221
|
+
if (isCancel(confirmed)) {
|
|
2001
2222
|
if (exitOnCancel) {
|
|
2002
|
-
|
|
2223
|
+
cancel(cancelMessage ?? "Operation cancelled.");
|
|
2003
2224
|
process.exit(0);
|
|
2004
2225
|
}
|
|
2005
2226
|
return null;
|
|
@@ -2009,17 +2230,17 @@ async function Confirm({
|
|
|
2009
2230
|
|
|
2010
2231
|
// apps/cli/utils/intro.ts
|
|
2011
2232
|
function Intro(message) {
|
|
2012
|
-
|
|
2233
|
+
intro(message);
|
|
2013
2234
|
}
|
|
2014
2235
|
|
|
2015
2236
|
// apps/cli/utils/outro.ts
|
|
2016
2237
|
function Outro(message) {
|
|
2017
|
-
|
|
2238
|
+
outro(message);
|
|
2018
2239
|
}
|
|
2019
2240
|
|
|
2020
2241
|
// apps/cli/utils/spinner.ts
|
|
2021
2242
|
function Spinner() {
|
|
2022
|
-
return
|
|
2243
|
+
return spinner();
|
|
2023
2244
|
}
|
|
2024
2245
|
|
|
2025
2246
|
// apps/cli/modules/setup/app/setup-command.ts
|
|
@@ -2040,11 +2261,11 @@ class SetupCommand {
|
|
|
2040
2261
|
Outro("Setup cancelled.");
|
|
2041
2262
|
return;
|
|
2042
2263
|
}
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2264
|
+
const spinner2 = Spinner();
|
|
2265
|
+
spinner2.start("Writing aliases...");
|
|
2045
2266
|
const { total } = await this.setupAliasesUseCase.execute();
|
|
2046
2267
|
console.log("");
|
|
2047
|
-
|
|
2268
|
+
spinner2.stop(`${CHECK({ text: `${total} aliases configured successfully.` })}`);
|
|
2048
2269
|
Outro(`${GREEN({ text: "GLINTER" })}, if you like the project, give a star on github: https://github.com/jannael/glinter`);
|
|
2049
2270
|
console.log("");
|
|
2050
2271
|
console.log(MAGENTA({ text: "To use the aliases, please restart your terminal." }));
|
|
@@ -2203,8 +2424,8 @@ class Branch {
|
|
|
2203
2424
|
}
|
|
2204
2425
|
static fromGitBranch(entries) {
|
|
2205
2426
|
const branches = [];
|
|
2206
|
-
for (let
|
|
2207
|
-
const entry = entries[
|
|
2427
|
+
for (let i2 = 0;i2 < entries?.length; i2++) {
|
|
2428
|
+
const entry = entries[i2];
|
|
2208
2429
|
if (!entry)
|
|
2209
2430
|
continue;
|
|
2210
2431
|
const current = entry.includes("*");
|
|
@@ -2289,11 +2510,11 @@ class SwitchCommand {
|
|
|
2289
2510
|
}
|
|
2290
2511
|
|
|
2291
2512
|
// apps/cli/modules/switch/infra/bun-switch-repository.ts
|
|
2292
|
-
var {$: $
|
|
2513
|
+
var {$: $2 } = globalThis.Bun;
|
|
2293
2514
|
class BunSwitchRepository {
|
|
2294
2515
|
async getBranches() {
|
|
2295
2516
|
try {
|
|
2296
|
-
const output = await $
|
|
2517
|
+
const output = await $2`git branch -a`.quiet().text();
|
|
2297
2518
|
if (!output.trim()) {
|
|
2298
2519
|
return [];
|
|
2299
2520
|
}
|