proxitor 0.8.0 → 0.9.0-beta.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/README.md +57 -4
- package/dist/add.mjs +26 -26
- package/dist/add.mjs.map +1 -1
- package/dist/browse.mjs +20 -20
- package/dist/browse.mjs.map +1 -1
- package/dist/cli.mjs +482 -233
- package/dist/cli.mjs.map +1 -1
- package/dist/config.mjs.map +1 -1
- package/dist/config2.mjs +5 -5
- package/dist/config2.mjs.map +1 -1
- package/dist/dist.mjs +558 -548
- package/dist/dist.mjs.map +1 -1
- package/dist/dist2.mjs.map +1 -1
- package/dist/edit.mjs +17 -17
- package/dist/edit.mjs.map +1 -1
- package/dist/list.mjs +4 -4
- package/dist/list.mjs.map +1 -1
- package/dist/prompt.mjs +9 -9
- package/dist/prompt.mjs.map +1 -1
- package/dist/providers.mjs +15 -15
- package/dist/providers.mjs.map +1 -1
- package/dist/remove.mjs +10 -10
- package/dist/remove.mjs.map +1 -1
- package/dist/validate.mjs +8 -8
- package/dist/validate.mjs.map +1 -1
- package/dist/wizard.mjs +31 -31
- package/dist/wizard.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dist.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { o as __commonJSMin } from "./cli.mjs";
|
|
2
|
-
import
|
|
2
|
+
import process$1, { stdin, stdout } from "node:process";
|
|
3
3
|
import { ReadStream } from "node:tty";
|
|
4
|
-
import {
|
|
4
|
+
import { styleText } from "node:util";
|
|
5
5
|
import "node:fs";
|
|
6
6
|
import "node:path";
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
7
|
+
import * as l from "node:readline";
|
|
8
|
+
import f from "node:readline";
|
|
9
9
|
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
10
10
|
const getCodePointsLength = (() => {
|
|
11
11
|
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
@@ -288,7 +288,7 @@ function wrapAnsi(string, columns, options) {
|
|
|
288
288
|
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
289
289
|
}
|
|
290
290
|
//#endregion
|
|
291
|
-
//#region node_modules/.pnpm/@clack+core@1.4.
|
|
291
|
+
//#region node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
|
|
292
292
|
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
293
293
|
const ESC = "\x1B";
|
|
294
294
|
const CSI = `${ESC}[`;
|
|
@@ -341,12 +341,12 @@ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
341
341
|
beep
|
|
342
342
|
};
|
|
343
343
|
})))();
|
|
344
|
-
function
|
|
345
|
-
if (!
|
|
346
|
-
const
|
|
347
|
-
return
|
|
344
|
+
function findCursor(s, o, l) {
|
|
345
|
+
if (!l.some((r) => !r.disabled)) return s;
|
|
346
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
347
|
+
return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
348
348
|
}
|
|
349
|
-
const
|
|
349
|
+
const settings = {
|
|
350
350
|
actions: new Set([
|
|
351
351
|
"up",
|
|
352
352
|
"down",
|
|
@@ -356,7 +356,7 @@ const h = {
|
|
|
356
356
|
"enter",
|
|
357
357
|
"cancel"
|
|
358
358
|
]),
|
|
359
|
-
aliases: new Map([
|
|
359
|
+
aliases: /* @__PURE__ */ new Map([
|
|
360
360
|
["k", "up"],
|
|
361
361
|
["j", "down"],
|
|
362
362
|
["h", "left"],
|
|
@@ -368,7 +368,7 @@ const h = {
|
|
|
368
368
|
cancel: "Canceled",
|
|
369
369
|
error: "Something went wrong"
|
|
370
370
|
},
|
|
371
|
-
withGuide:
|
|
371
|
+
withGuide: true,
|
|
372
372
|
date: {
|
|
373
373
|
monthNames: [...[
|
|
374
374
|
"January",
|
|
@@ -387,95 +387,96 @@ const h = {
|
|
|
387
387
|
messages: {
|
|
388
388
|
required: "Please enter a valid date",
|
|
389
389
|
invalidMonth: "There are only 12 months in a year",
|
|
390
|
-
invalidDay: (
|
|
391
|
-
afterMin: (
|
|
392
|
-
beforeMax: (
|
|
390
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
391
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
392
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
|
-
function
|
|
397
|
-
if (typeof
|
|
398
|
-
for (const s of
|
|
399
|
-
return
|
|
396
|
+
function isActionKey(n, e) {
|
|
397
|
+
if (typeof n == "string") return settings.aliases.get(n) === e;
|
|
398
|
+
for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
|
|
399
|
+
return false;
|
|
400
400
|
}
|
|
401
|
-
function
|
|
402
|
-
if (
|
|
403
|
-
const
|
|
404
|
-
`),
|
|
405
|
-
`),
|
|
406
|
-
for (let
|
|
401
|
+
function diffLines(i, s) {
|
|
402
|
+
if (i === s) return;
|
|
403
|
+
const e = i.split(`
|
|
404
|
+
`), t = s.split(`
|
|
405
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
406
|
+
for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
|
|
407
407
|
return {
|
|
408
|
-
lines:
|
|
409
|
-
numLinesBefore:
|
|
410
|
-
numLinesAfter:
|
|
411
|
-
numLines:
|
|
408
|
+
lines: f,
|
|
409
|
+
numLinesBefore: e.length,
|
|
410
|
+
numLinesAfter: t.length,
|
|
411
|
+
numLines: r
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
const R = globalThis.process.platform.startsWith("win");
|
|
415
|
+
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
416
|
+
function isCancel(e) {
|
|
417
|
+
return e === CANCEL_SYMBOL;
|
|
417
418
|
}
|
|
418
|
-
function
|
|
419
|
-
const
|
|
420
|
-
|
|
419
|
+
function setRawMode(e, r) {
|
|
420
|
+
const o = e;
|
|
421
|
+
o.isTTY && o.setRawMode(r);
|
|
421
422
|
}
|
|
422
|
-
function
|
|
423
|
-
const
|
|
424
|
-
input:
|
|
425
|
-
output:
|
|
423
|
+
function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: t = true } = {}) {
|
|
424
|
+
const s = l.createInterface({
|
|
425
|
+
input: e,
|
|
426
|
+
output: r,
|
|
426
427
|
prompt: "",
|
|
427
428
|
tabSize: 1
|
|
428
429
|
});
|
|
429
|
-
|
|
430
|
-
const n = (
|
|
431
|
-
if (
|
|
432
|
-
String(
|
|
433
|
-
|
|
434
|
-
|
|
430
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
431
|
+
const n = (f, { name: a, sequence: p }) => {
|
|
432
|
+
if (isActionKey([
|
|
433
|
+
String(f),
|
|
434
|
+
a,
|
|
435
|
+
p
|
|
435
436
|
], "cancel")) {
|
|
436
|
-
|
|
437
|
+
t && r.write(import_src.cursor.show), process.exit(0);
|
|
437
438
|
return;
|
|
438
439
|
}
|
|
439
|
-
if (!
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
440
|
+
if (!o) return;
|
|
441
|
+
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
442
|
+
l.moveCursor(r, i, m, () => {
|
|
443
|
+
l.clearLine(r, 1, () => {
|
|
444
|
+
e.once("keypress", n);
|
|
444
445
|
});
|
|
445
446
|
});
|
|
446
447
|
};
|
|
447
|
-
return
|
|
448
|
-
|
|
448
|
+
return t && r.write(import_src.cursor.hide), e.once("keypress", n), () => {
|
|
449
|
+
e.off("keypress", n), t && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
449
450
|
};
|
|
450
451
|
}
|
|
451
|
-
const
|
|
452
|
-
function
|
|
453
|
-
return wrapAnsi(
|
|
454
|
-
hard:
|
|
455
|
-
trim:
|
|
452
|
+
const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
453
|
+
function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
454
|
+
return wrapAnsi(r, getColumns(e ?? stdout) - o.length, {
|
|
455
|
+
hard: true,
|
|
456
|
+
trim: false
|
|
456
457
|
}).split(`
|
|
457
|
-
`).map((
|
|
458
|
-
const
|
|
459
|
-
return
|
|
458
|
+
`).map((c, i, m) => {
|
|
459
|
+
const d = n ? n(c, i) : c;
|
|
460
|
+
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
460
461
|
}).join(`
|
|
461
462
|
`);
|
|
462
463
|
}
|
|
463
|
-
function
|
|
464
|
-
if ("~standard" in
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
467
|
-
return
|
|
464
|
+
function runValidation(e, n) {
|
|
465
|
+
if ("~standard" in e) {
|
|
466
|
+
const a = e["~standard"].validate(n);
|
|
467
|
+
if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
468
|
+
return a.issues?.at(0)?.message;
|
|
468
469
|
}
|
|
469
|
-
return
|
|
470
|
+
return e(n);
|
|
470
471
|
}
|
|
471
|
-
var
|
|
472
|
+
var V = class {
|
|
472
473
|
input;
|
|
473
474
|
output;
|
|
474
475
|
_abortSignal;
|
|
475
476
|
rl;
|
|
476
477
|
opts;
|
|
477
478
|
_render;
|
|
478
|
-
_track =
|
|
479
|
+
_track = false;
|
|
479
480
|
_prevFrame = "";
|
|
480
481
|
_subscribers = /* @__PURE__ */ new Map();
|
|
481
482
|
_cursor = 0;
|
|
@@ -483,131 +484,153 @@ var m = class {
|
|
|
483
484
|
error = "";
|
|
484
485
|
value;
|
|
485
486
|
userInput = "";
|
|
486
|
-
constructor(t,
|
|
487
|
-
const { input:
|
|
488
|
-
this.opts =
|
|
487
|
+
constructor(t, e = true) {
|
|
488
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
489
|
+
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;
|
|
489
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Unsubscribe all listeners
|
|
493
|
+
*/
|
|
490
494
|
unsubscribe() {
|
|
491
495
|
this._subscribers.clear();
|
|
492
496
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
497
|
+
/**
|
|
498
|
+
* Set a subscriber with opts
|
|
499
|
+
* @param event - The event name
|
|
500
|
+
*/
|
|
501
|
+
setSubscriber(t, e) {
|
|
502
|
+
const i = this._subscribers.get(t) ?? [];
|
|
503
|
+
i.push(e), this._subscribers.set(t, i);
|
|
496
504
|
}
|
|
497
|
-
|
|
498
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Subscribe to an event
|
|
507
|
+
* @param event - The event name
|
|
508
|
+
* @param cb - The callback
|
|
509
|
+
*/
|
|
510
|
+
on(t, e) {
|
|
511
|
+
this.setSubscriber(t, { cb: e });
|
|
499
512
|
}
|
|
500
|
-
|
|
513
|
+
/**
|
|
514
|
+
* Subscribe to an event once
|
|
515
|
+
* @param event - The event name
|
|
516
|
+
* @param cb - The callback
|
|
517
|
+
*/
|
|
518
|
+
once(t, e) {
|
|
501
519
|
this.setSubscriber(t, {
|
|
502
|
-
cb:
|
|
503
|
-
once:
|
|
520
|
+
cb: e,
|
|
521
|
+
once: true
|
|
504
522
|
});
|
|
505
523
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
524
|
+
/**
|
|
525
|
+
* Emit an event with data
|
|
526
|
+
* @param event - The event name
|
|
527
|
+
* @param data - The data to pass to the callback
|
|
528
|
+
*/
|
|
529
|
+
emit(t, ...e) {
|
|
530
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
531
|
+
for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
532
|
+
for (const s of n) s();
|
|
510
533
|
}
|
|
511
534
|
prompt() {
|
|
512
535
|
return new Promise((t) => {
|
|
513
536
|
if (this._abortSignal) {
|
|
514
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(
|
|
537
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
515
538
|
this._abortSignal.addEventListener("abort", () => {
|
|
516
539
|
this.state = "cancel", this.close();
|
|
517
|
-
}, { once:
|
|
540
|
+
}, { once: true });
|
|
518
541
|
}
|
|
519
|
-
this.rl =
|
|
542
|
+
this.rl = f.createInterface({
|
|
520
543
|
input: this.input,
|
|
521
544
|
tabSize: 2,
|
|
522
545
|
prompt: "",
|
|
523
546
|
escapeCodeTimeout: 50,
|
|
524
|
-
terminal:
|
|
525
|
-
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput,
|
|
526
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
547
|
+
terminal: true
|
|
548
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && 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", () => {
|
|
549
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
527
550
|
}), this.once("cancel", () => {
|
|
528
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
551
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
529
552
|
});
|
|
530
553
|
});
|
|
531
554
|
}
|
|
532
|
-
_isActionKey(t,
|
|
555
|
+
_isActionKey(t, e) {
|
|
533
556
|
return t === " ";
|
|
534
557
|
}
|
|
535
|
-
_shouldSubmit(t,
|
|
536
|
-
return
|
|
558
|
+
_shouldSubmit(t, e) {
|
|
559
|
+
return true;
|
|
537
560
|
}
|
|
538
561
|
_setValue(t) {
|
|
539
562
|
this.value = t, this.emit("value", this.value);
|
|
540
563
|
}
|
|
541
|
-
_setUserInput(t,
|
|
542
|
-
this.userInput = t ?? "", this.emit("userInput", this.userInput),
|
|
564
|
+
_setUserInput(t, e) {
|
|
565
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
543
566
|
}
|
|
544
567
|
_clearUserInput() {
|
|
545
568
|
this.rl?.write(null, {
|
|
546
|
-
ctrl:
|
|
569
|
+
ctrl: true,
|
|
547
570
|
name: "u"
|
|
548
571
|
}), this._setUserInput("");
|
|
549
572
|
}
|
|
550
|
-
onKeypress(t,
|
|
551
|
-
if (this._track &&
|
|
552
|
-
ctrl:
|
|
573
|
+
onKeypress(t, e) {
|
|
574
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
575
|
+
ctrl: true,
|
|
553
576
|
name: "h"
|
|
554
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"),
|
|
577
|
+
}), 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)) {
|
|
555
578
|
if (this.opts.validate) {
|
|
556
|
-
const
|
|
557
|
-
|
|
579
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
580
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
558
581
|
}
|
|
559
582
|
this.state !== "error" && (this.state = "submit");
|
|
560
583
|
}
|
|
561
|
-
|
|
584
|
+
isActionKey([
|
|
562
585
|
t,
|
|
563
|
-
|
|
564
|
-
|
|
586
|
+
e?.name,
|
|
587
|
+
e?.sequence
|
|
565
588
|
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
566
589
|
}
|
|
567
590
|
close() {
|
|
568
591
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
569
|
-
`),
|
|
592
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
570
593
|
}
|
|
571
594
|
restoreCursor() {
|
|
572
595
|
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
573
|
-
hard:
|
|
574
|
-
trim:
|
|
596
|
+
hard: true,
|
|
597
|
+
trim: false
|
|
575
598
|
}).split(`
|
|
576
599
|
`).length - 1;
|
|
577
600
|
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
578
601
|
}
|
|
579
602
|
render() {
|
|
580
603
|
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
581
|
-
hard:
|
|
582
|
-
trim:
|
|
604
|
+
hard: true,
|
|
605
|
+
trim: false
|
|
583
606
|
});
|
|
584
607
|
if (t !== this._prevFrame) {
|
|
585
608
|
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
586
609
|
else {
|
|
587
|
-
const
|
|
588
|
-
if (this.restoreCursor(),
|
|
589
|
-
const
|
|
590
|
-
let
|
|
591
|
-
if (
|
|
610
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
611
|
+
if (this.restoreCursor(), e) {
|
|
612
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
613
|
+
let r = e.lines.find((o) => o >= n);
|
|
614
|
+
if (r === void 0) {
|
|
592
615
|
this._prevFrame = t;
|
|
593
616
|
return;
|
|
594
617
|
}
|
|
595
|
-
if (
|
|
596
|
-
this.output.write(import_src.cursor.move(0,
|
|
597
|
-
const
|
|
618
|
+
if (e.lines.length === 1) {
|
|
619
|
+
this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
|
|
620
|
+
const o = t.split(`
|
|
598
621
|
`);
|
|
599
|
-
this.output.write(
|
|
622
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
|
|
600
623
|
return;
|
|
601
|
-
} else if (
|
|
602
|
-
if (
|
|
624
|
+
} else if (e.lines.length > 1) {
|
|
625
|
+
if (n < s) r = n;
|
|
603
626
|
else {
|
|
604
|
-
const
|
|
605
|
-
|
|
627
|
+
const h = r - s;
|
|
628
|
+
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
606
629
|
}
|
|
607
630
|
this.output.write(import_src.erase.down());
|
|
608
|
-
const
|
|
609
|
-
`).slice(
|
|
610
|
-
this.output.write(
|
|
631
|
+
const f = t.split(`
|
|
632
|
+
`).slice(r);
|
|
633
|
+
this.output.write(f.join(`
|
|
611
634
|
`)), this._prevFrame = t;
|
|
612
635
|
return;
|
|
613
636
|
}
|
|
@@ -618,81 +641,81 @@ var m = class {
|
|
|
618
641
|
}
|
|
619
642
|
}
|
|
620
643
|
};
|
|
621
|
-
function
|
|
622
|
-
if (
|
|
623
|
-
const
|
|
624
|
-
return
|
|
644
|
+
function p$1(l, e) {
|
|
645
|
+
if (l === void 0 || e.length === 0) return 0;
|
|
646
|
+
const i = e.findIndex((s) => s.value === l);
|
|
647
|
+
return i !== -1 ? i : 0;
|
|
625
648
|
}
|
|
626
|
-
function
|
|
627
|
-
return (
|
|
649
|
+
function g(l, e) {
|
|
650
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
|
|
628
651
|
}
|
|
629
|
-
function
|
|
630
|
-
if (
|
|
652
|
+
function m(l, e) {
|
|
653
|
+
if (e) return l ? e : e[0];
|
|
631
654
|
}
|
|
632
|
-
let
|
|
655
|
+
let T$1 = class T extends V {
|
|
633
656
|
filteredOptions;
|
|
634
657
|
multiple;
|
|
635
|
-
isNavigating =
|
|
658
|
+
isNavigating = false;
|
|
636
659
|
selectedValues = [];
|
|
637
660
|
focusedValue;
|
|
638
|
-
#
|
|
639
|
-
#
|
|
661
|
+
#e = 0;
|
|
662
|
+
#s = "";
|
|
640
663
|
#t;
|
|
664
|
+
#i;
|
|
641
665
|
#n;
|
|
642
|
-
#u;
|
|
643
666
|
get cursor() {
|
|
644
|
-
return this.#
|
|
667
|
+
return this.#e;
|
|
645
668
|
}
|
|
646
669
|
get userInputWithCursor() {
|
|
647
670
|
if (!this.userInput) return styleText(["inverse", "hidden"], "_");
|
|
648
671
|
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
649
|
-
const
|
|
650
|
-
return `${
|
|
672
|
+
const e = this.userInput.slice(0, this._cursor), [t, ...i] = this.userInput.slice(this._cursor);
|
|
673
|
+
return `${e}${styleText("inverse", t)}${i.join("")}`;
|
|
651
674
|
}
|
|
652
675
|
get options() {
|
|
653
|
-
return typeof this.#
|
|
676
|
+
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
654
677
|
}
|
|
655
|
-
constructor(
|
|
656
|
-
super(
|
|
657
|
-
const
|
|
658
|
-
this.filteredOptions = [...
|
|
659
|
-
let
|
|
660
|
-
if (
|
|
661
|
-
const n =
|
|
662
|
-
n !== -1 && (this.toggleSelected(
|
|
678
|
+
constructor(e) {
|
|
679
|
+
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
680
|
+
const t = this.options;
|
|
681
|
+
this.filteredOptions = [...t], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
|
|
682
|
+
let i;
|
|
683
|
+
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) for (const s of i) {
|
|
684
|
+
const n = t.findIndex((o) => o.value === s);
|
|
685
|
+
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
663
686
|
}
|
|
664
|
-
this.focusedValue = this.options[this.#
|
|
687
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
665
688
|
}
|
|
666
|
-
_isActionKey(
|
|
667
|
-
return
|
|
689
|
+
_isActionKey(e, t) {
|
|
690
|
+
return e === " " || this.multiple && this.isNavigating && t.name === "space" && e !== void 0 && e !== "";
|
|
668
691
|
}
|
|
669
|
-
#e
|
|
670
|
-
const
|
|
671
|
-
if (
|
|
672
|
-
this.userInput === " " && this._clearUserInput(), this._setUserInput(u,
|
|
692
|
+
#l(e, t) {
|
|
693
|
+
const i = t.name === "up", s = t.name === "down", n = t.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#n, h = this.options, f = u !== void 0 && u !== "" && h.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
|
|
694
|
+
if (t.name === "tab" && o && f) {
|
|
695
|
+
this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
673
696
|
return;
|
|
674
697
|
}
|
|
675
|
-
|
|
698
|
+
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 !== void 0 && (t.name === "tab" || this.isNavigating && t.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
676
699
|
}
|
|
677
700
|
deselectAll() {
|
|
678
701
|
this.selectedValues = [];
|
|
679
702
|
}
|
|
680
|
-
toggleSelected(
|
|
681
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(
|
|
703
|
+
toggleSelected(e) {
|
|
704
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t) => t !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
682
705
|
}
|
|
683
|
-
#
|
|
684
|
-
if (
|
|
685
|
-
this.#
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
const
|
|
689
|
-
this.#
|
|
690
|
-
const
|
|
691
|
-
|
|
706
|
+
#u(e) {
|
|
707
|
+
if (e !== this.#s) {
|
|
708
|
+
this.#s = e;
|
|
709
|
+
const t = this.options;
|
|
710
|
+
e && this.#t ? this.filteredOptions = t.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t];
|
|
711
|
+
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
712
|
+
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
713
|
+
const s = this.filteredOptions[this.#e];
|
|
714
|
+
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
692
715
|
}
|
|
693
716
|
}
|
|
694
717
|
};
|
|
695
|
-
var
|
|
718
|
+
var r = class extends V {
|
|
696
719
|
get cursor() {
|
|
697
720
|
return this.value ? 0 : 1;
|
|
698
721
|
}
|
|
@@ -700,59 +723,53 @@ var Z = class extends m {
|
|
|
700
723
|
return this.cursor === 0;
|
|
701
724
|
}
|
|
702
725
|
constructor(t) {
|
|
703
|
-
super(t,
|
|
726
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
704
727
|
this.value = this._value;
|
|
705
|
-
}), this.on("confirm", (
|
|
706
|
-
this.output.write(import_src.cursor.move(0, -1)), this.value =
|
|
728
|
+
}), this.on("confirm", (i) => {
|
|
729
|
+
this.output.write(import_src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
707
730
|
}), this.on("cursor", () => {
|
|
708
731
|
this.value = !this.value;
|
|
709
732
|
});
|
|
710
733
|
}
|
|
711
734
|
};
|
|
712
|
-
|
|
713
|
-
"up",
|
|
714
|
-
"down",
|
|
715
|
-
"left",
|
|
716
|
-
"right"
|
|
717
|
-
]);
|
|
718
|
-
let ut$1 = class extends m {
|
|
735
|
+
let a$1 = class a extends V {
|
|
719
736
|
options;
|
|
720
737
|
cursor = 0;
|
|
721
738
|
get _value() {
|
|
722
739
|
return this.options[this.cursor].value;
|
|
723
740
|
}
|
|
724
741
|
get _enabledOptions() {
|
|
725
|
-
return this.options.filter((
|
|
742
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
726
743
|
}
|
|
727
744
|
toggleAll() {
|
|
728
|
-
const
|
|
729
|
-
this.value =
|
|
745
|
+
const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
|
|
746
|
+
this.value = i ? [] : e.map((t) => t.value);
|
|
730
747
|
}
|
|
731
748
|
toggleInvert() {
|
|
732
|
-
const
|
|
733
|
-
if (!
|
|
734
|
-
const
|
|
735
|
-
this.value =
|
|
749
|
+
const e = this.value;
|
|
750
|
+
if (!e) return;
|
|
751
|
+
const i = this._enabledOptions.filter((t) => !e.includes(t.value));
|
|
752
|
+
this.value = i.map((t) => t.value);
|
|
736
753
|
}
|
|
737
754
|
toggleValue() {
|
|
738
755
|
this.value === void 0 && (this.value = []);
|
|
739
|
-
const
|
|
740
|
-
this.value =
|
|
756
|
+
const e = this.value.includes(this._value);
|
|
757
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
741
758
|
}
|
|
742
|
-
constructor(
|
|
743
|
-
super(
|
|
744
|
-
const
|
|
745
|
-
this.cursor = this.options[
|
|
746
|
-
|
|
747
|
-
}), this.on("cursor", (
|
|
748
|
-
switch (
|
|
759
|
+
constructor(e) {
|
|
760
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
761
|
+
const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
|
|
762
|
+
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
|
|
763
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
764
|
+
}), this.on("cursor", (t) => {
|
|
765
|
+
switch (t) {
|
|
749
766
|
case "left":
|
|
750
767
|
case "up":
|
|
751
|
-
this.cursor =
|
|
768
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
752
769
|
break;
|
|
753
770
|
case "down":
|
|
754
771
|
case "right":
|
|
755
|
-
this.cursor =
|
|
772
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
756
773
|
break;
|
|
757
774
|
case "space":
|
|
758
775
|
this.toggleValue();
|
|
@@ -761,7 +778,7 @@ let ut$1 = class extends m {
|
|
|
761
778
|
});
|
|
762
779
|
}
|
|
763
780
|
};
|
|
764
|
-
var
|
|
781
|
+
var a = class extends V {
|
|
765
782
|
options;
|
|
766
783
|
cursor = 0;
|
|
767
784
|
get _selectedValue() {
|
|
@@ -771,30 +788,30 @@ var ht$1 = class extends m {
|
|
|
771
788
|
this.value = this._selectedValue.value;
|
|
772
789
|
}
|
|
773
790
|
constructor(t) {
|
|
774
|
-
super(t,
|
|
775
|
-
const
|
|
776
|
-
this.cursor = this.options[e].disabled ?
|
|
777
|
-
switch (
|
|
791
|
+
super(t, false), this.options = t.options;
|
|
792
|
+
const i = this.options.findIndex(({ value: s }) => s === t.initialValue), e = i === -1 ? 0 : i;
|
|
793
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
794
|
+
switch (s) {
|
|
778
795
|
case "left":
|
|
779
796
|
case "up":
|
|
780
|
-
this.cursor =
|
|
797
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
781
798
|
break;
|
|
782
799
|
case "down":
|
|
783
800
|
case "right":
|
|
784
|
-
this.cursor =
|
|
801
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
785
802
|
break;
|
|
786
803
|
}
|
|
787
804
|
this.changeValue();
|
|
788
805
|
});
|
|
789
806
|
}
|
|
790
807
|
};
|
|
791
|
-
var
|
|
808
|
+
var n = class extends V {
|
|
792
809
|
get userInputWithCursor() {
|
|
793
810
|
if (this.state === "submit") return this.userInput;
|
|
794
811
|
const t = this.userInput;
|
|
795
812
|
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
796
|
-
const
|
|
797
|
-
return `${
|
|
813
|
+
const e = t.slice(0, this.cursor), [s, ...r] = t.slice(this.cursor);
|
|
814
|
+
return `${e}${styleText("inverse", s)}${r.join("")}`;
|
|
798
815
|
}
|
|
799
816
|
get cursor() {
|
|
800
817
|
return this._cursor;
|
|
@@ -803,250 +820,258 @@ var ct$1 = class extends m {
|
|
|
803
820
|
super({
|
|
804
821
|
...t,
|
|
805
822
|
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
806
|
-
}), this.on("userInput", (
|
|
807
|
-
this._setValue(
|
|
823
|
+
}), this.on("userInput", (e) => {
|
|
824
|
+
this._setValue(e);
|
|
808
825
|
}), this.on("finalize", () => {
|
|
809
826
|
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
810
827
|
});
|
|
811
828
|
}
|
|
812
829
|
};
|
|
813
830
|
//#endregion
|
|
814
|
-
//#region node_modules/.pnpm/@clack+prompts@1.5.
|
|
815
|
-
function
|
|
816
|
-
|
|
831
|
+
//#region node_modules/.pnpm/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
|
|
832
|
+
function isUnicodeSupported() {
|
|
833
|
+
if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
|
|
834
|
+
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";
|
|
817
835
|
}
|
|
818
|
-
const
|
|
819
|
-
switch (
|
|
836
|
+
const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", unicodeOr = (e, o) => unicode ? e : o, S_STEP_ACTIVE = unicodeOr("◆", "*"), S_STEP_CANCEL = unicodeOr("■", "x"), S_STEP_ERROR = unicodeOr("▲", "x"), S_STEP_SUBMIT = unicodeOr("◇", "o"), S_BAR_START = unicodeOr("┌", "T"), S_BAR = unicodeOr("│", "|"), S_BAR_END = unicodeOr("└", "—"), S_RADIO_ACTIVE = unicodeOr("●", ">"), S_RADIO_INACTIVE = unicodeOr("○", " "), S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]"), S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]"), S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]"), S_BAR_H = unicodeOr("─", "-"), S_CORNER_TOP_RIGHT = unicodeOr("╮", "+"), S_CONNECT_LEFT = unicodeOr("├", "+"), S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+"), S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+"), S_INFO = unicodeOr("●", "•"), S_SUCCESS = unicodeOr("◆", "*"), S_WARN = unicodeOr("▲", "!"), S_ERROR = unicodeOr("■", "x"), symbol = (e) => {
|
|
837
|
+
switch (e) {
|
|
820
838
|
case "initial":
|
|
821
|
-
case "active": return styleText("cyan",
|
|
822
|
-
case "cancel": return styleText("red",
|
|
823
|
-
case "error": return styleText("yellow",
|
|
824
|
-
case "submit": return styleText("green",
|
|
839
|
+
case "active": return styleText("cyan", S_STEP_ACTIVE);
|
|
840
|
+
case "cancel": return styleText("red", S_STEP_CANCEL);
|
|
841
|
+
case "error": return styleText("yellow", S_STEP_ERROR);
|
|
842
|
+
case "submit": return styleText("green", S_STEP_SUBMIT);
|
|
825
843
|
}
|
|
826
|
-
},
|
|
827
|
-
switch (
|
|
844
|
+
}, symbolBar = (e) => {
|
|
845
|
+
switch (e) {
|
|
828
846
|
case "initial":
|
|
829
|
-
case "active": return styleText("cyan",
|
|
830
|
-
case "cancel": return styleText("red",
|
|
831
|
-
case "error": return styleText("yellow",
|
|
832
|
-
case "submit": return styleText("green",
|
|
847
|
+
case "active": return styleText("cyan", S_BAR);
|
|
848
|
+
case "cancel": return styleText("red", S_BAR);
|
|
849
|
+
case "error": return styleText("yellow", S_BAR);
|
|
850
|
+
case "submit": return styleText("green", S_BAR);
|
|
833
851
|
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
852
|
+
};
|
|
853
|
+
const E$1 = (l, o, g, c, h, O = false) => {
|
|
854
|
+
let r = o, w = 0;
|
|
855
|
+
if (O) for (let i = c - 1; i >= g && (r -= l[i].length, w++, !(r <= h)); i--);
|
|
856
|
+
else for (let i = g; i < c && (r -= l[i].length, w++, !(r <= h)); i++);
|
|
838
857
|
return {
|
|
839
|
-
lineCount:
|
|
840
|
-
removals:
|
|
858
|
+
lineCount: r,
|
|
859
|
+
removals: w
|
|
841
860
|
};
|
|
842
|
-
}
|
|
843
|
-
|
|
861
|
+
};
|
|
862
|
+
const limitOptions = ({ cursor: l, options: o, style: g, output: c = process.stdout, maxItems: h = Number.POSITIVE_INFINITY, columnPadding: O = 0, rowPadding: r = 4 }) => {
|
|
863
|
+
const i = getColumns(c) - O, I = getRows(c), C = styleText("dim", "..."), x = Math.max(I - r, 0), m = Math.max(Math.min(h, x), 5);
|
|
844
864
|
let p = 0;
|
|
845
|
-
|
|
846
|
-
let f =
|
|
847
|
-
const
|
|
848
|
-
let
|
|
849
|
-
f &&
|
|
850
|
-
const v = p + (f ? 1 : 0),
|
|
851
|
-
for (let
|
|
852
|
-
const
|
|
853
|
-
hard:
|
|
854
|
-
trim:
|
|
865
|
+
l >= m - 3 && (p = Math.max(Math.min(l - m + 3, o.length - m), 0));
|
|
866
|
+
let f = m < o.length && p > 0, u = m < o.length && p + m < o.length;
|
|
867
|
+
const W = Math.min(p + m, o.length), e = [];
|
|
868
|
+
let d = 0;
|
|
869
|
+
f && d++, u && d++;
|
|
870
|
+
const v = p + (f ? 1 : 0), P = W - (u ? 1 : 0);
|
|
871
|
+
for (let t = v; t < P; t++) {
|
|
872
|
+
const n = wrapAnsi(g(o[t], t === l), i, {
|
|
873
|
+
hard: true,
|
|
874
|
+
trim: false
|
|
855
875
|
}).split(`
|
|
856
876
|
`);
|
|
857
|
-
|
|
877
|
+
e.push(n), d += n.length;
|
|
858
878
|
}
|
|
859
|
-
if (
|
|
860
|
-
let
|
|
861
|
-
const
|
|
862
|
-
let
|
|
863
|
-
const
|
|
864
|
-
f ? ({lineCount:
|
|
879
|
+
if (d > x) {
|
|
880
|
+
let t = 0, n = 0, s = d;
|
|
881
|
+
const M = l - v;
|
|
882
|
+
let a = x;
|
|
883
|
+
const T = () => E$1(e, s, 0, M, a), L = () => E$1(e, s, M + 1, e.length, a, true);
|
|
884
|
+
f ? ({lineCount: s, removals: t} = T(), s > a && (u || (a -= 1), {lineCount: s, removals: n} = L())) : (u || (a -= 1), {lineCount: s, removals: n} = L(), s > a && (a -= 1, {lineCount: s, removals: t} = T())), t > 0 && (f = true, e.splice(0, t)), n > 0 && (u = true, e.splice(e.length - n, n));
|
|
865
885
|
}
|
|
866
|
-
const
|
|
867
|
-
f &&
|
|
868
|
-
for (const
|
|
869
|
-
return
|
|
886
|
+
const b = [];
|
|
887
|
+
f && b.push(C);
|
|
888
|
+
for (const t of e) for (const n of t) b.push(n);
|
|
889
|
+
return u && b.push(C), b;
|
|
870
890
|
};
|
|
871
|
-
function
|
|
891
|
+
function P(t) {
|
|
872
892
|
return t.label ?? String(t.value ?? "");
|
|
873
893
|
}
|
|
874
|
-
function
|
|
875
|
-
if (!t) return
|
|
876
|
-
const
|
|
877
|
-
return
|
|
894
|
+
function E(t, c) {
|
|
895
|
+
if (!t) return true;
|
|
896
|
+
const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), l = String(c.value).toLowerCase(), o = t.toLowerCase();
|
|
897
|
+
return n.includes(o) || i.includes(o) || l.includes(o);
|
|
878
898
|
}
|
|
879
|
-
function
|
|
880
|
-
const
|
|
881
|
-
for (const
|
|
882
|
-
return
|
|
899
|
+
function N(t, c) {
|
|
900
|
+
const n = [];
|
|
901
|
+
for (const i of c) t.includes(i.value) && n.push(i);
|
|
902
|
+
return n;
|
|
883
903
|
}
|
|
884
|
-
const
|
|
904
|
+
const autocomplete = (t) => new T$1({
|
|
885
905
|
options: t.options,
|
|
886
906
|
initialValue: t.initialValue ? [t.initialValue] : void 0,
|
|
887
907
|
initialUserInput: t.initialUserInput,
|
|
888
908
|
placeholder: t.placeholder,
|
|
889
|
-
filter: t.filter ?? ((
|
|
909
|
+
filter: t.filter ?? ((n, i) => E(n, i)),
|
|
890
910
|
signal: t.signal,
|
|
891
911
|
input: t.input,
|
|
892
912
|
output: t.output,
|
|
893
913
|
validate: t.validate,
|
|
894
914
|
render() {
|
|
895
|
-
const
|
|
896
|
-
const
|
|
897
|
-
switch (
|
|
898
|
-
case "active": return `${styleText("green",
|
|
899
|
-
case "inactive": return `${styleText("dim",
|
|
900
|
-
case "disabled": return `${styleText("gray",
|
|
915
|
+
const n = t.withGuide ?? settings.withGuide, i = n ? [`${styleText("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], l = this.userInput, o = this.options, m = t.placeholder, p = l === "" && m !== void 0, $ = (r, s) => {
|
|
916
|
+
const a = P(r), u = r.hint && r.value === this.focusedValue ? styleText("dim", ` (${r.hint})`) : "";
|
|
917
|
+
switch (s) {
|
|
918
|
+
case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${a}${u}`;
|
|
919
|
+
case "inactive": return `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`;
|
|
920
|
+
case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${styleText(["strikethrough", "gray"], a)}`;
|
|
901
921
|
}
|
|
902
922
|
};
|
|
903
923
|
switch (this.state) {
|
|
904
924
|
case "submit": {
|
|
905
|
-
const
|
|
906
|
-
return `${
|
|
925
|
+
const r = N(this.selectedValues, o), s = r.length > 0 ? ` ${styleText("dim", r.map(P).join(", "))}` : "", a = n ? styleText("gray", S_BAR) : "";
|
|
926
|
+
return `${i.join(`
|
|
907
927
|
`)}
|
|
908
|
-
${
|
|
928
|
+
${a}${s}`;
|
|
909
929
|
}
|
|
910
930
|
case "cancel": {
|
|
911
|
-
const
|
|
912
|
-
return `${
|
|
931
|
+
const r = l ? ` ${styleText(["strikethrough", "dim"], l)}` : "", s = n ? styleText("gray", S_BAR) : "";
|
|
932
|
+
return `${i.join(`
|
|
913
933
|
`)}
|
|
914
|
-
${
|
|
934
|
+
${s}${r}`;
|
|
915
935
|
}
|
|
916
936
|
default: {
|
|
917
|
-
const
|
|
918
|
-
let
|
|
919
|
-
if (this.isNavigating ||
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
} else
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
const
|
|
937
|
+
const r = this.state === "error" ? "yellow" : "cyan", s = n ? `${styleText(r, S_BAR)} ` : "", a = n ? styleText(r, S_BAR_END) : "";
|
|
938
|
+
let u = "";
|
|
939
|
+
if (this.isNavigating || p) {
|
|
940
|
+
const d = p ? m : l;
|
|
941
|
+
u = d !== "" ? ` ${styleText("dim", d)}` : "";
|
|
942
|
+
} else u = ` ${this.userInputWithCursor}`;
|
|
943
|
+
const V = this.filteredOptions.length !== o.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", y = this.filteredOptions.length === 0 && l ? [`${s}${styleText("yellow", "No matches found")}`] : [], b = this.state === "error" ? [`${s}${styleText("yellow", this.error)}`] : [];
|
|
944
|
+
n && i.push(`${s.trimEnd()}`), i.push(`${s}${styleText("dim", "Search:")}${u}${V}`, ...y, ...b);
|
|
945
|
+
const g = [`${s}${[
|
|
926
946
|
`${styleText("dim", "↑/↓")} to select`,
|
|
927
947
|
`${styleText("dim", "Enter:")} confirm`,
|
|
928
948
|
`${styleText("dim", "Type:")} to search`
|
|
929
|
-
].join(" • ")}`,
|
|
949
|
+
].join(" • ")}`, a], O = this.filteredOptions.length === 0 ? [] : limitOptions({
|
|
930
950
|
cursor: this.cursor,
|
|
931
951
|
options: this.filteredOptions,
|
|
932
|
-
columnPadding:
|
|
933
|
-
rowPadding:
|
|
934
|
-
style: (
|
|
952
|
+
columnPadding: n ? 3 : 0,
|
|
953
|
+
rowPadding: i.length + g.length,
|
|
954
|
+
style: (d, f) => $(d, d.disabled ? "disabled" : f ? "active" : "inactive"),
|
|
935
955
|
maxItems: t.maxItems,
|
|
936
956
|
output: t.output
|
|
937
957
|
});
|
|
938
958
|
return [
|
|
939
|
-
...
|
|
940
|
-
...
|
|
941
|
-
...
|
|
959
|
+
...i,
|
|
960
|
+
...O.map((d) => `${s}${d}`),
|
|
961
|
+
...g
|
|
942
962
|
].join(`
|
|
943
963
|
`);
|
|
944
964
|
}
|
|
945
965
|
}
|
|
946
966
|
}
|
|
947
|
-
}).prompt()
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
967
|
+
}).prompt();
|
|
968
|
+
const confirm = (i) => {
|
|
969
|
+
const a = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
970
|
+
return new r({
|
|
971
|
+
active: a,
|
|
951
972
|
inactive: s,
|
|
952
|
-
signal:
|
|
953
|
-
input:
|
|
954
|
-
output:
|
|
955
|
-
initialValue:
|
|
973
|
+
signal: i.signal,
|
|
974
|
+
input: i.input,
|
|
975
|
+
output: i.output,
|
|
976
|
+
initialValue: i.initialValue ?? true,
|
|
956
977
|
render() {
|
|
957
|
-
const
|
|
958
|
-
` : ""}${
|
|
959
|
-
`,
|
|
978
|
+
const e = i.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(i.output, i.message, l, u), o = `${e ? `${styleText("gray", S_BAR)}
|
|
979
|
+
` : ""}${f}
|
|
980
|
+
`, c = this.value ? a : s;
|
|
960
981
|
switch (this.state) {
|
|
961
|
-
case "submit": return `${
|
|
962
|
-
case "cancel": return `${
|
|
963
|
-
${styleText("gray",
|
|
982
|
+
case "submit": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText("dim", c)}`;
|
|
983
|
+
case "cancel": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText(["strikethrough", "dim"], c)}${e ? `
|
|
984
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
964
985
|
default: {
|
|
965
|
-
const
|
|
966
|
-
return `${
|
|
967
|
-
${styleText("cyan",
|
|
968
|
-
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim",
|
|
969
|
-
${
|
|
986
|
+
const r = e ? `${styleText("cyan", S_BAR)} ` : "", g = e ? styleText("cyan", S_BAR_END) : "";
|
|
987
|
+
return `${o}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${i.vertical ? e ? `
|
|
988
|
+
${styleText("cyan", S_BAR)} ` : `
|
|
989
|
+
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", s)}` : `${styleText("green", S_RADIO_ACTIVE)} ${s}`}
|
|
990
|
+
${g}
|
|
970
991
|
`;
|
|
971
992
|
}
|
|
972
993
|
}
|
|
973
994
|
}
|
|
974
995
|
}).prompt();
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
996
|
+
};
|
|
997
|
+
const log = {
|
|
998
|
+
message: (s = [], { symbol: e = styleText("gray", S_BAR), secondarySymbol: r = styleText("gray", S_BAR), output: m = process.stdout, spacing: l = 1, withGuide: c } = {}) => {
|
|
999
|
+
const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
|
|
1000
|
+
for (let i = 0; i < l; i++) t.push(f);
|
|
1001
|
+
const g = Array.isArray(s) ? s : s.split(`
|
|
980
1002
|
`);
|
|
981
1003
|
if (g.length > 0) {
|
|
982
|
-
const [
|
|
983
|
-
|
|
984
|
-
for (const
|
|
1004
|
+
const [i, ...y] = g;
|
|
1005
|
+
i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
|
|
1006
|
+
for (const p of y) p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
|
|
985
1007
|
}
|
|
986
|
-
|
|
1008
|
+
m.write(`${t.join(`
|
|
987
1009
|
`)}
|
|
988
1010
|
`);
|
|
989
1011
|
},
|
|
990
|
-
info: (
|
|
991
|
-
|
|
992
|
-
...
|
|
993
|
-
symbol: styleText("blue",
|
|
1012
|
+
info: (s, e) => {
|
|
1013
|
+
log.message(s, {
|
|
1014
|
+
...e,
|
|
1015
|
+
symbol: styleText("blue", S_INFO)
|
|
994
1016
|
});
|
|
995
1017
|
},
|
|
996
|
-
success: (
|
|
997
|
-
|
|
998
|
-
...
|
|
999
|
-
symbol: styleText("green",
|
|
1018
|
+
success: (s, e) => {
|
|
1019
|
+
log.message(s, {
|
|
1020
|
+
...e,
|
|
1021
|
+
symbol: styleText("green", S_SUCCESS)
|
|
1000
1022
|
});
|
|
1001
1023
|
},
|
|
1002
|
-
step: (
|
|
1003
|
-
|
|
1004
|
-
...
|
|
1005
|
-
symbol: styleText("green",
|
|
1024
|
+
step: (s, e) => {
|
|
1025
|
+
log.message(s, {
|
|
1026
|
+
...e,
|
|
1027
|
+
symbol: styleText("green", S_STEP_SUBMIT)
|
|
1006
1028
|
});
|
|
1007
1029
|
},
|
|
1008
|
-
warn: (
|
|
1009
|
-
|
|
1010
|
-
...
|
|
1011
|
-
symbol: styleText("yellow",
|
|
1030
|
+
warn: (s, e) => {
|
|
1031
|
+
log.message(s, {
|
|
1032
|
+
...e,
|
|
1033
|
+
symbol: styleText("yellow", S_WARN)
|
|
1012
1034
|
});
|
|
1013
1035
|
},
|
|
1014
|
-
|
|
1015
|
-
|
|
1036
|
+
/** alias for `log.warn()`. */
|
|
1037
|
+
warning: (s, e) => {
|
|
1038
|
+
log.warn(s, e);
|
|
1016
1039
|
},
|
|
1017
|
-
error: (
|
|
1018
|
-
|
|
1019
|
-
...
|
|
1020
|
-
symbol: styleText("red",
|
|
1040
|
+
error: (s, e) => {
|
|
1041
|
+
log.message(s, {
|
|
1042
|
+
...e,
|
|
1043
|
+
symbol: styleText("red", S_ERROR)
|
|
1021
1044
|
});
|
|
1022
1045
|
}
|
|
1023
|
-
},
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1046
|
+
}, intro = (o = "", t) => {
|
|
1047
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
|
|
1048
|
+
i.write(`${e}${o}
|
|
1026
1049
|
`);
|
|
1027
|
-
},
|
|
1028
|
-
const
|
|
1029
|
-
${styleText("gray",
|
|
1030
|
-
|
|
1050
|
+
}, outro = (o = "", t) => {
|
|
1051
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
|
|
1052
|
+
${styleText("gray", S_BAR_END)} ` : "";
|
|
1053
|
+
i.write(`${e}${o}
|
|
1031
1054
|
|
|
1032
1055
|
`);
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
`)
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1056
|
+
};
|
|
1057
|
+
const d = (n, a) => n.split(`
|
|
1058
|
+
`).map((m) => a(m)).join(`
|
|
1059
|
+
`);
|
|
1060
|
+
const multiselect = (n) => {
|
|
1061
|
+
const a = (t, o) => {
|
|
1062
|
+
const r = t.label ?? String(t.value);
|
|
1063
|
+
return o === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText(["strikethrough", "gray"], l))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : o === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${d(r, (l) => styleText("dim", l))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "cancelled" ? `${d(r, (l) => styleText(["strikethrough", "dim"], l))}` : o === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "submitted" ? `${d(r, (l) => styleText("dim", l))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText("dim", l))}`;
|
|
1064
|
+
}, m = n.required ?? true;
|
|
1065
|
+
return new a$1({
|
|
1066
|
+
options: n.options,
|
|
1067
|
+
signal: n.signal,
|
|
1068
|
+
input: n.input,
|
|
1069
|
+
output: n.output,
|
|
1070
|
+
initialValues: n.initialValues,
|
|
1071
|
+
required: m,
|
|
1072
|
+
cursorAt: n.cursorAt,
|
|
1073
|
+
validate(t) {
|
|
1074
|
+
if (m && (t === void 0 || t.length === 0)) return `Please select at least one option.
|
|
1050
1075
|
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1051
1076
|
"gray",
|
|
1052
1077
|
"bgWhite",
|
|
@@ -1054,86 +1079,90 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
|
|
|
1054
1079
|
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
1055
1080
|
},
|
|
1056
1081
|
render() {
|
|
1057
|
-
const
|
|
1058
|
-
` : ""}${
|
|
1059
|
-
`,
|
|
1060
|
-
if (
|
|
1061
|
-
const
|
|
1062
|
-
return
|
|
1082
|
+
const t = n.withGuide ?? settings.withGuide, o = wrapTextWithPrefix(n.output, n.message, t ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r = `${t ? `${styleText("gray", S_BAR)}
|
|
1083
|
+
` : ""}${o}
|
|
1084
|
+
`, l = this.value ?? [], g = (i, u) => {
|
|
1085
|
+
if (i.disabled) return a(i, "disabled");
|
|
1086
|
+
const s = l.includes(i.value);
|
|
1087
|
+
return u && s ? a(i, "active-selected") : s ? a(i, "selected") : a(i, u ? "active" : "inactive");
|
|
1063
1088
|
};
|
|
1064
1089
|
switch (this.state) {
|
|
1065
1090
|
case "submit": {
|
|
1066
|
-
const
|
|
1067
|
-
return `${
|
|
1091
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
|
|
1092
|
+
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}`;
|
|
1068
1093
|
}
|
|
1069
1094
|
case "cancel": {
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1072
|
-
return `${
|
|
1073
|
-
${styleText("gray",
|
|
1095
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "cancelled")).join(styleText("dim", ", "));
|
|
1096
|
+
if (i.trim() === "") return `${r}${styleText("gray", S_BAR)}`;
|
|
1097
|
+
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}${t ? `
|
|
1098
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
1074
1099
|
}
|
|
1075
1100
|
case "error": {
|
|
1076
|
-
const
|
|
1077
|
-
`).map((
|
|
1078
|
-
`),
|
|
1079
|
-
`).length,
|
|
1101
|
+
const i = t ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
|
|
1102
|
+
`).map((h, x) => x === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", h)}` : ` ${h}`).join(`
|
|
1103
|
+
`), s = r.split(`
|
|
1104
|
+
`).length, v = u.split(`
|
|
1080
1105
|
`).length + 1;
|
|
1081
|
-
return `${
|
|
1082
|
-
output:
|
|
1106
|
+
return `${r}${i}${limitOptions({
|
|
1107
|
+
output: n.output,
|
|
1083
1108
|
options: this.options,
|
|
1084
1109
|
cursor: this.cursor,
|
|
1085
|
-
maxItems:
|
|
1086
|
-
columnPadding:
|
|
1087
|
-
rowPadding:
|
|
1088
|
-
style:
|
|
1110
|
+
maxItems: n.maxItems,
|
|
1111
|
+
columnPadding: i.length,
|
|
1112
|
+
rowPadding: s + v,
|
|
1113
|
+
style: g
|
|
1089
1114
|
}).join(`
|
|
1090
|
-
${
|
|
1091
|
-
${
|
|
1115
|
+
${i}`)}
|
|
1116
|
+
${u}
|
|
1092
1117
|
`;
|
|
1093
1118
|
}
|
|
1094
1119
|
default: {
|
|
1095
|
-
const
|
|
1096
|
-
`).length,
|
|
1097
|
-
return `${
|
|
1098
|
-
output:
|
|
1120
|
+
const i = t ? `${styleText("cyan", S_BAR)} ` : "", u = r.split(`
|
|
1121
|
+
`).length, s = t ? 2 : 1;
|
|
1122
|
+
return `${r}${i}${limitOptions({
|
|
1123
|
+
output: n.output,
|
|
1099
1124
|
options: this.options,
|
|
1100
1125
|
cursor: this.cursor,
|
|
1101
|
-
maxItems:
|
|
1102
|
-
columnPadding:
|
|
1103
|
-
rowPadding:
|
|
1104
|
-
style:
|
|
1126
|
+
maxItems: n.maxItems,
|
|
1127
|
+
columnPadding: i.length,
|
|
1128
|
+
rowPadding: u + s,
|
|
1129
|
+
style: g
|
|
1105
1130
|
}).join(`
|
|
1106
|
-
${
|
|
1107
|
-
${
|
|
1131
|
+
${i}`)}
|
|
1132
|
+
${t ? styleText("cyan", S_BAR_END) : ""}
|
|
1108
1133
|
`;
|
|
1109
1134
|
}
|
|
1110
1135
|
}
|
|
1111
1136
|
}
|
|
1112
1137
|
}).prompt();
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1138
|
+
};
|
|
1139
|
+
const W$1 = (o) => styleText("dim", o), C = (o, e, s) => {
|
|
1140
|
+
const a = {
|
|
1141
|
+
hard: true,
|
|
1142
|
+
trim: false
|
|
1143
|
+
}, i = wrapAnsi(o, e, a).split(`
|
|
1144
|
+
`), c = i.reduce((n, r) => Math.max(fastStringWidth(r), n), 0);
|
|
1145
|
+
return wrapAnsi(o, e - (i.map(s).reduce((n, r) => Math.max(fastStringWidth(r), n), 0) - c), a);
|
|
1146
|
+
};
|
|
1147
|
+
const note = (o = "", e = "", s) => {
|
|
1148
|
+
const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W$1, g = [
|
|
1122
1149
|
"",
|
|
1123
|
-
...
|
|
1124
|
-
`).map(
|
|
1150
|
+
...C(o, getColumns(a) - 6, c).split(`
|
|
1151
|
+
`).map(c),
|
|
1125
1152
|
""
|
|
1126
|
-
],
|
|
1127
|
-
const
|
|
1128
|
-
return
|
|
1129
|
-
}, 0),
|
|
1130
|
-
`),
|
|
1131
|
-
` : "",
|
|
1132
|
-
|
|
1133
|
-
${
|
|
1134
|
-
${styleText("gray",
|
|
1153
|
+
], n = fastStringWidth(e), r = Math.max(g.reduce((m, F) => {
|
|
1154
|
+
const O = fastStringWidth(F);
|
|
1155
|
+
return O > m ? O : m;
|
|
1156
|
+
}, 0), n) + 2, h = g.map((m) => `${styleText("gray", S_BAR)} ${m}${" ".repeat(r - fastStringWidth(m))}${styleText("gray", S_BAR)}`).join(`
|
|
1157
|
+
`), T = i ? `${styleText("gray", S_BAR)}
|
|
1158
|
+
` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
1159
|
+
a.write(`${T}${styleText("green", S_STEP_SUBMIT)} ${styleText("reset", e)} ${styleText("gray", S_BAR_H.repeat(Math.max(r - n - 1, 1)) + S_CORNER_TOP_RIGHT)}
|
|
1160
|
+
${h}
|
|
1161
|
+
${styleText("gray", l$1 + S_BAR_H.repeat(r + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
1135
1162
|
`);
|
|
1136
|
-
}
|
|
1163
|
+
};
|
|
1164
|
+
const W = (l) => styleText("magenta", l);
|
|
1165
|
+
const spinner = ({ indicator: l = "dots", onCancel: h, output: n = process.stdout, cancelMessage: G, errorMessage: O, frames: E = unicode ? [
|
|
1137
1166
|
"◒",
|
|
1138
1167
|
"◐",
|
|
1139
1168
|
"◓",
|
|
@@ -1143,148 +1172,129 @@ ${styleText("gray", g + st.repeat(o + 2) + dt)}
|
|
|
1143
1172
|
"o",
|
|
1144
1173
|
"O",
|
|
1145
1174
|
"0"
|
|
1146
|
-
], delay:
|
|
1147
|
-
const
|
|
1148
|
-
let
|
|
1149
|
-
const
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
},
|
|
1153
|
-
process.on("uncaughtExceptionMonitor",
|
|
1154
|
-
},
|
|
1155
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1156
|
-
},
|
|
1157
|
-
if (
|
|
1158
|
-
|
|
1175
|
+
], delay: F = unicode ? 80 : 120, signal: m, ...I } = {}) => {
|
|
1176
|
+
const u = isCI();
|
|
1177
|
+
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
1178
|
+
const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
|
|
1179
|
+
const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1180
|
+
S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
|
|
1181
|
+
}, f = () => g(2), i = () => g(1), A = () => {
|
|
1182
|
+
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);
|
|
1183
|
+
}, H = () => {
|
|
1184
|
+
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);
|
|
1185
|
+
}, y = () => {
|
|
1186
|
+
if (p === void 0) return;
|
|
1187
|
+
u && n.write(`
|
|
1159
1188
|
`);
|
|
1160
|
-
const
|
|
1161
|
-
hard:
|
|
1162
|
-
trim:
|
|
1189
|
+
const r = wrapAnsi(p, x, {
|
|
1190
|
+
hard: true,
|
|
1191
|
+
trim: false
|
|
1163
1192
|
}).split(`
|
|
1164
1193
|
`);
|
|
1165
|
-
|
|
1166
|
-
},
|
|
1167
|
-
const
|
|
1168
|
-
return
|
|
1169
|
-
},
|
|
1170
|
-
|
|
1194
|
+
r.length > 1 && n.write(import_src.cursor.up(r.length - 1)), n.write(import_src.cursor.to(0)), n.write(import_src.erase.down());
|
|
1195
|
+
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1196
|
+
const r = (performance.now() - e) / 1e3, t = Math.floor(r / 60), o = Math.floor(r % 60);
|
|
1197
|
+
return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
|
|
1198
|
+
}, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1199
|
+
d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText("gray", S_BAR)}
|
|
1171
1200
|
`);
|
|
1172
|
-
let
|
|
1173
|
-
|
|
1174
|
-
if (
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
let
|
|
1178
|
-
if (
|
|
1179
|
-
else if (
|
|
1201
|
+
let r = 0, t = 0;
|
|
1202
|
+
A(), T = setInterval(() => {
|
|
1203
|
+
if (u && s === p) return;
|
|
1204
|
+
y(), p = s;
|
|
1205
|
+
const o = k(E[r]);
|
|
1206
|
+
let v;
|
|
1207
|
+
if (u) v = `${o} ${s}...`;
|
|
1208
|
+
else if (l === "timer") v = `${o} ${s} ${_(w)}`;
|
|
1180
1209
|
else {
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1210
|
+
const B = ".".repeat(Math.floor(t)).slice(0, 3);
|
|
1211
|
+
v = `${o} ${s}${B}`;
|
|
1183
1212
|
}
|
|
1184
|
-
const
|
|
1185
|
-
hard:
|
|
1186
|
-
trim:
|
|
1213
|
+
const j = wrapAnsi(v, x, {
|
|
1214
|
+
hard: true,
|
|
1215
|
+
trim: false
|
|
1187
1216
|
});
|
|
1188
|
-
|
|
1189
|
-
},
|
|
1190
|
-
},
|
|
1191
|
-
if (!
|
|
1192
|
-
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
`) :
|
|
1196
|
-
`)),
|
|
1217
|
+
n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + .125 : 0;
|
|
1218
|
+
}, F);
|
|
1219
|
+
}, a = (e = "", r = 0, t = false) => {
|
|
1220
|
+
if (!d) return;
|
|
1221
|
+
d = false, clearInterval(T), y();
|
|
1222
|
+
const o = r === 0 ? styleText("green", S_STEP_SUBMIT) : r === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
|
|
1223
|
+
s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
|
|
1224
|
+
`) : n.write(`${o} ${s}
|
|
1225
|
+
`)), H(), M();
|
|
1197
1226
|
};
|
|
1198
1227
|
return {
|
|
1199
|
-
start:
|
|
1200
|
-
stop: (
|
|
1201
|
-
message: (
|
|
1202
|
-
|
|
1228
|
+
start: P,
|
|
1229
|
+
stop: (e = "") => a(e, 0),
|
|
1230
|
+
message: (e = "") => {
|
|
1231
|
+
s = C(e ?? s);
|
|
1203
1232
|
},
|
|
1204
|
-
cancel: (
|
|
1205
|
-
error: (
|
|
1206
|
-
clear: () =>
|
|
1233
|
+
cancel: (e = "") => a(e, 1),
|
|
1234
|
+
error: (e = "") => a(e, 2),
|
|
1235
|
+
clear: () => a("", 0, true),
|
|
1207
1236
|
get isCancelled() {
|
|
1208
|
-
return
|
|
1237
|
+
return S;
|
|
1209
1238
|
}
|
|
1210
1239
|
};
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
`)
|
|
1214
|
-
`)
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
case "
|
|
1221
|
-
case "
|
|
1222
|
-
|
|
1240
|
+
};
|
|
1241
|
+
const c = (e, a) => e.includes(`
|
|
1242
|
+
`) ? e.split(`
|
|
1243
|
+
`).map((t) => a(t)).join(`
|
|
1244
|
+
`) : a(e);
|
|
1245
|
+
const select = (e) => {
|
|
1246
|
+
const a$2 = (t, d) => {
|
|
1247
|
+
const s = t.label ?? String(t.value);
|
|
1248
|
+
switch (d) {
|
|
1249
|
+
case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("gray", n))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}`;
|
|
1250
|
+
case "selected": return `${c(s, (n) => styleText("dim", n))}`;
|
|
1251
|
+
case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${s}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}`;
|
|
1252
|
+
case "cancelled": return `${c(s, (n) => styleText(["strikethrough", "dim"], n))}`;
|
|
1253
|
+
default: return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("dim", n))}`;
|
|
1223
1254
|
}
|
|
1224
1255
|
};
|
|
1225
|
-
return new
|
|
1226
|
-
options:
|
|
1227
|
-
signal:
|
|
1228
|
-
input:
|
|
1229
|
-
output:
|
|
1230
|
-
initialValue:
|
|
1256
|
+
return new a({
|
|
1257
|
+
options: e.options,
|
|
1258
|
+
signal: e.signal,
|
|
1259
|
+
input: e.input,
|
|
1260
|
+
output: e.output,
|
|
1261
|
+
initialValue: e.initialValue,
|
|
1231
1262
|
render() {
|
|
1232
|
-
const
|
|
1263
|
+
const t = e.withGuide ?? settings.withGuide, d = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n = wrapTextWithPrefix(e.output, e.message, s, d), u = `${t ? `${styleText("gray", S_BAR)}
|
|
1233
1264
|
` : ""}${n}
|
|
1234
1265
|
`;
|
|
1235
1266
|
switch (this.state) {
|
|
1236
1267
|
case "submit": {
|
|
1237
|
-
const
|
|
1238
|
-
return `${
|
|
1268
|
+
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
1269
|
+
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "selected"), r)}`;
|
|
1239
1270
|
}
|
|
1240
1271
|
case "cancel": {
|
|
1241
|
-
const
|
|
1242
|
-
return `${
|
|
1243
|
-
${styleText("gray",
|
|
1272
|
+
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
1273
|
+
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "cancelled"), r)}${t ? `
|
|
1274
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
1244
1275
|
}
|
|
1245
1276
|
default: {
|
|
1246
|
-
const
|
|
1247
|
-
`).length,
|
|
1248
|
-
return `${
|
|
1249
|
-
output:
|
|
1277
|
+
const r = t ? `${styleText("cyan", S_BAR)} ` : "", l = t ? styleText("cyan", S_BAR_END) : "", g = u.split(`
|
|
1278
|
+
`).length, h = t ? 2 : 1;
|
|
1279
|
+
return `${u}${r}${limitOptions({
|
|
1280
|
+
output: e.output,
|
|
1250
1281
|
cursor: this.cursor,
|
|
1251
1282
|
options: this.options,
|
|
1252
|
-
maxItems:
|
|
1253
|
-
columnPadding:
|
|
1254
|
-
rowPadding:
|
|
1255
|
-
style: (
|
|
1283
|
+
maxItems: e.maxItems,
|
|
1284
|
+
columnPadding: r.length,
|
|
1285
|
+
rowPadding: g + h,
|
|
1286
|
+
style: (p, b) => a$2(p, p.disabled ? "disabled" : b ? "active" : "inactive")
|
|
1256
1287
|
}).join(`
|
|
1257
|
-
${
|
|
1258
|
-
${
|
|
1288
|
+
${r}`)}
|
|
1289
|
+
${l}
|
|
1259
1290
|
`;
|
|
1260
1291
|
}
|
|
1261
1292
|
}
|
|
1262
1293
|
}
|
|
1263
1294
|
}).prompt();
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
${i} `);
|
|
1268
|
-
let s = 3;
|
|
1269
|
-
for await (let r of t) {
|
|
1270
|
-
r = r.replace(/\n/g, `
|
|
1271
|
-
${Bt}`), r.includes(`
|
|
1272
|
-
`) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
|
|
1273
|
-
`))).length);
|
|
1274
|
-
const u = stripVTControlCharacters(r).length;
|
|
1275
|
-
s + u < process.stdout.columns ? (s += u, process.stdout.write(r)) : (process.stdout.write(`
|
|
1276
|
-
${Bt}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
|
|
1277
|
-
}
|
|
1278
|
-
process.stdout.write(`
|
|
1279
|
-
`);
|
|
1280
|
-
},
|
|
1281
|
-
info: (t) => q.message(t, { symbol: styleText("blue", pt) }),
|
|
1282
|
-
success: (t) => q.message(t, { symbol: styleText("green", mt) }),
|
|
1283
|
-
step: (t) => q.message(t, { symbol: styleText("green", H) }),
|
|
1284
|
-
warn: (t) => q.message(t, { symbol: styleText("yellow", gt) }),
|
|
1285
|
-
warning: (t) => q.warn(t),
|
|
1286
|
-
error: (t) => q.message(t, { symbol: styleText("red", yt) })
|
|
1287
|
-
}, Re = (t) => new ct$1({
|
|
1295
|
+
};
|
|
1296
|
+
`${styleText("gray", S_BAR)}`;
|
|
1297
|
+
const text = (t) => new n({
|
|
1288
1298
|
validate: t.validate,
|
|
1289
1299
|
placeholder: t.placeholder,
|
|
1290
1300
|
defaultValue: t.defaultValue,
|
|
@@ -1293,33 +1303,33 @@ ${Bt}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length)
|
|
|
1293
1303
|
signal: t.signal,
|
|
1294
1304
|
input: t.input,
|
|
1295
1305
|
render() {
|
|
1296
|
-
const i = t?.withGuide ??
|
|
1297
|
-
` : ""}${
|
|
1298
|
-
`,
|
|
1306
|
+
const i = t?.withGuide ?? settings.withGuide, s = `${`${i ? `${styleText("gray", S_BAR)}
|
|
1307
|
+
` : ""}${symbol(this.state)} `}${t.message}
|
|
1308
|
+
`, c = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, a = this.value ?? "";
|
|
1299
1309
|
switch (this.state) {
|
|
1300
1310
|
case "error": {
|
|
1301
|
-
const
|
|
1311
|
+
const n = this.error ? ` ${styleText("yellow", this.error)}` : "", r = i ? `${styleText("yellow", S_BAR)} ` : "", d = i ? styleText("yellow", S_BAR_END) : "";
|
|
1302
1312
|
return `${s.trim()}
|
|
1303
|
-
${
|
|
1304
|
-
${
|
|
1313
|
+
${r}${o}
|
|
1314
|
+
${d}${n}
|
|
1305
1315
|
`;
|
|
1306
1316
|
}
|
|
1307
1317
|
case "submit": {
|
|
1308
|
-
const
|
|
1309
|
-
return `${s}${i ? styleText("gray",
|
|
1318
|
+
const n = a ? ` ${styleText("dim", a)}` : "";
|
|
1319
|
+
return `${s}${i ? styleText("gray", S_BAR) : ""}${n}`;
|
|
1310
1320
|
}
|
|
1311
1321
|
case "cancel": {
|
|
1312
|
-
const
|
|
1313
|
-
return `${s}${
|
|
1314
|
-
${
|
|
1322
|
+
const n = a ? ` ${styleText(["strikethrough", "dim"], a)}` : "", r = i ? styleText("gray", S_BAR) : "";
|
|
1323
|
+
return `${s}${r}${n}${a.trim() ? `
|
|
1324
|
+
${r}` : ""}`;
|
|
1315
1325
|
}
|
|
1316
|
-
default: return `${s}${i ? `${styleText("cyan",
|
|
1317
|
-
${i ? styleText("cyan",
|
|
1326
|
+
default: return `${s}${i ? `${styleText("cyan", S_BAR)} ` : ""}${o}
|
|
1327
|
+
${i ? styleText("cyan", S_BAR_END) : ""}
|
|
1318
1328
|
`;
|
|
1319
1329
|
}
|
|
1320
1330
|
}
|
|
1321
1331
|
}).prompt();
|
|
1322
1332
|
//#endregion
|
|
1323
|
-
export {
|
|
1333
|
+
export { autocomplete, confirm, intro, isCancel, log, multiselect, note, outro, select, spinner, text };
|
|
1324
1334
|
|
|
1325
1335
|
//# sourceMappingURL=dist.mjs.map
|