create-ts-monorepo-starter 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/cli.js +348 -340
- package/dist/template/.github/workflows/ci.yml +8 -4
- package/dist/template/.github/workflows/release.yml +4 -4
- package/dist/template/AGENTS.md +4 -0
- package/dist/template/README.md +15 -0
- package/dist/template/biome.json +1 -1
- package/dist/template/package.json +9 -7
- package/dist/template/packages/web/package.json +2 -2
- package/dist/template/pnpm-lock.yaml +355 -355
- package/dist/template/scripts/check-changesets.mjs +44 -0
- package/dist/template/scripts/check-changesets.test.ts +50 -0
- package/dist/template-manifest.json +2 -0
- package/dist/template-version.json +2 -2
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -7,8 +7,8 @@ import { constants, tmpdir } from 'node:os';
|
|
|
7
7
|
import { readFileSync, existsSync, lstatSync, readdirSync, rmSync } from 'node:fs';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
9
|
import process$1, { stdout, stdin } from 'node:process';
|
|
10
|
-
import * as
|
|
11
|
-
import
|
|
10
|
+
import * as f$1 from 'node:readline';
|
|
11
|
+
import f$1__default from 'node:readline';
|
|
12
12
|
import { ReadStream } from 'node:tty';
|
|
13
13
|
import { randomBytes } from 'node:crypto';
|
|
14
14
|
|
|
@@ -796,8 +796,8 @@ const fastStringWidth = (input, options = {}) => {
|
|
|
796
796
|
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
797
797
|
};
|
|
798
798
|
|
|
799
|
-
const ESC = '\x1B';
|
|
800
|
-
const CSI = '\x9B';
|
|
799
|
+
const ESC$1 = '\x1B';
|
|
800
|
+
const CSI$1 = '\x9B';
|
|
801
801
|
const END_CODE = 39;
|
|
802
802
|
const ANSI_ESCAPE_BELL = '\u0007';
|
|
803
803
|
const ANSI_CSI = '[';
|
|
@@ -830,8 +830,8 @@ const getClosingCode = (openingCode) => {
|
|
|
830
830
|
return 0;
|
|
831
831
|
return undefined;
|
|
832
832
|
};
|
|
833
|
-
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
834
|
-
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
833
|
+
const wrapAnsiCode = (code) => `${ESC$1}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
834
|
+
const wrapAnsiHyperlink = (url) => `${ESC$1}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
835
835
|
const wrapWord = (rows, word, columns) => {
|
|
836
836
|
const characters = word[Symbol.iterator]();
|
|
837
837
|
let isInsideEscape = false;
|
|
@@ -851,7 +851,7 @@ const wrapWord = (rows, word, columns) => {
|
|
|
851
851
|
rows.push(character);
|
|
852
852
|
visible = 0;
|
|
853
853
|
}
|
|
854
|
-
if (character === ESC || character === CSI) {
|
|
854
|
+
if (character === ESC$1 || character === CSI$1) {
|
|
855
855
|
isInsideEscape = true;
|
|
856
856
|
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
857
857
|
}
|
|
@@ -973,7 +973,7 @@ const exec = (string, columns, options = {}) => {
|
|
|
973
973
|
else {
|
|
974
974
|
inSurrogate = false;
|
|
975
975
|
}
|
|
976
|
-
if (character === ESC || character === CSI) {
|
|
976
|
+
if (character === ESC$1 || character === CSI$1) {
|
|
977
977
|
GROUP_REGEX.lastIndex = i + 1;
|
|
978
978
|
const groupsResult = GROUP_REGEX.exec(preString);
|
|
979
979
|
const groups = groupsResult?.groups;
|
|
@@ -1014,90 +1014,71 @@ function wrapAnsi(string, columns, options) {
|
|
|
1014
1014
|
.join('\n');
|
|
1015
1015
|
}
|
|
1016
1016
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
1066
|
-
line: `${CSI}2K`,
|
|
1067
|
-
lineEnd: `${CSI}K`,
|
|
1068
|
-
lineStart: `${CSI}1K`,
|
|
1069
|
-
lines(count) {
|
|
1070
|
-
let clear = '';
|
|
1071
|
-
for (let i = 0; i < count; i++)
|
|
1072
|
-
clear += this.line + (i < count - 1 ? cursor.up() : '');
|
|
1073
|
-
if (count)
|
|
1074
|
-
clear += cursor.left;
|
|
1075
|
-
return clear;
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
|
|
1079
|
-
src = { cursor, scroll, erase, beep };
|
|
1080
|
-
return src;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
var srcExports = requireSrc();
|
|
1017
|
+
const ESC = '\x1B';
|
|
1018
|
+
const CSI = `${ESC}[`;
|
|
1019
|
+
const cursor = {
|
|
1020
|
+
to(x, y) {
|
|
1021
|
+
if (!y)
|
|
1022
|
+
return `${CSI}${x + 1}G`;
|
|
1023
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
1024
|
+
},
|
|
1025
|
+
move(x, y) {
|
|
1026
|
+
let ret = '';
|
|
1027
|
+
if (x < 0)
|
|
1028
|
+
ret += `${CSI}${-x}D`;
|
|
1029
|
+
else if (x > 0)
|
|
1030
|
+
ret += `${CSI}${x}C`;
|
|
1031
|
+
if (y < 0)
|
|
1032
|
+
ret += `${CSI}${-y}A`;
|
|
1033
|
+
else if (y > 0)
|
|
1034
|
+
ret += `${CSI}${y}B`;
|
|
1035
|
+
return ret;
|
|
1036
|
+
},
|
|
1037
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
1038
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
1039
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
1040
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
1041
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
1042
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
1043
|
+
left: `${CSI}G`,
|
|
1044
|
+
hide: `${CSI}?25l`,
|
|
1045
|
+
show: `${CSI}?25h`,
|
|
1046
|
+
save: `${ESC}7`,
|
|
1047
|
+
restore: `${ESC}8`
|
|
1048
|
+
};
|
|
1049
|
+
const erase = {
|
|
1050
|
+
screen: `${CSI}2J`,
|
|
1051
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
1052
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
1053
|
+
line: `${CSI}2K`,
|
|
1054
|
+
lineEnd: `${CSI}K`,
|
|
1055
|
+
lineStart: `${CSI}1K`,
|
|
1056
|
+
lines(count) {
|
|
1057
|
+
let clear = '';
|
|
1058
|
+
for (let i = 0; i < count; i++)
|
|
1059
|
+
clear += this.line + (i < count - 1 ? cursor.up() : '');
|
|
1060
|
+
if (count)
|
|
1061
|
+
clear += cursor.left;
|
|
1062
|
+
return clear;
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1084
1065
|
|
|
1085
|
-
function findCursor(
|
|
1066
|
+
function findCursor(o, s, l) {
|
|
1086
1067
|
if (!l.some((r) => !r.disabled))
|
|
1087
|
-
return
|
|
1088
|
-
const t =
|
|
1089
|
-
return l[e]?.disabled ? findCursor(e,
|
|
1068
|
+
return o;
|
|
1069
|
+
const t = o + s, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
1070
|
+
return l[e]?.disabled ? findCursor(e, s < 0 ? -1 : 1, l) : e;
|
|
1090
1071
|
}
|
|
1091
|
-
function findTextCursor(
|
|
1072
|
+
function findTextCursor(o, s, l, i) {
|
|
1092
1073
|
const t = i.split(`
|
|
1093
1074
|
`);
|
|
1094
|
-
let n = 0, e =
|
|
1075
|
+
let n = 0, e = o;
|
|
1095
1076
|
for (const r of t) {
|
|
1096
1077
|
if (e <= r.length)
|
|
1097
1078
|
break;
|
|
1098
1079
|
e -= r.length + 1, n++;
|
|
1099
1080
|
}
|
|
1100
|
-
for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) +
|
|
1081
|
+
for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + s; e < 0 && n > 0; )
|
|
1101
1082
|
n--, e += t[n].length + 1;
|
|
1102
1083
|
for (; e > t[n].length && n < t.length - 1; )
|
|
1103
1084
|
e -= t[n].length + 1, n++;
|
|
@@ -1214,41 +1195,41 @@ function block({
|
|
|
1214
1195
|
overwrite: o = true,
|
|
1215
1196
|
hideCursor: n = true
|
|
1216
1197
|
} = {}) {
|
|
1217
|
-
const s =
|
|
1198
|
+
const s = f$1.createInterface({
|
|
1218
1199
|
input: e,
|
|
1219
1200
|
output: r,
|
|
1220
1201
|
prompt: "",
|
|
1221
1202
|
tabSize: 1
|
|
1222
1203
|
});
|
|
1223
|
-
|
|
1224
|
-
const t = (
|
|
1225
|
-
const
|
|
1226
|
-
if (isActionKey([
|
|
1227
|
-
n && r.write(
|
|
1204
|
+
f$1.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
1205
|
+
const t = (l, { name: i, sequence: p }) => {
|
|
1206
|
+
const w = String(l);
|
|
1207
|
+
if (isActionKey([w, i, p], "cancel")) {
|
|
1208
|
+
n && r.write(cursor.show), process.exit(0);
|
|
1228
1209
|
return;
|
|
1229
1210
|
}
|
|
1230
1211
|
if (!o) return;
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1233
|
-
|
|
1212
|
+
const c = i === "return" ? 0 : -1, a = i === "return" ? -1 : 0;
|
|
1213
|
+
f$1.moveCursor(r, c, a, () => {
|
|
1214
|
+
f$1.clearLine(r, 1, () => {
|
|
1234
1215
|
e.once("keypress", t);
|
|
1235
1216
|
});
|
|
1236
1217
|
});
|
|
1237
1218
|
};
|
|
1238
|
-
return n && r.write(
|
|
1239
|
-
e.off("keypress", t), n && r.write(
|
|
1219
|
+
return n && r.write(cursor.hide), e.once("keypress", t), () => {
|
|
1220
|
+
e.off("keypress", t), n && r.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
1240
1221
|
};
|
|
1241
1222
|
}
|
|
1242
1223
|
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;
|
|
1243
1224
|
function wrapTextWithPrefix(e, r, o, n = o, s = o, t) {
|
|
1244
|
-
const
|
|
1245
|
-
return wrapAnsi(r,
|
|
1225
|
+
const l = getColumns(e ?? stdout), i = fastStringWidth(o);
|
|
1226
|
+
return wrapAnsi(r, l - i, {
|
|
1246
1227
|
hard: true,
|
|
1247
1228
|
trim: false
|
|
1248
1229
|
}).split(`
|
|
1249
|
-
`).map((c,
|
|
1250
|
-
const
|
|
1251
|
-
return
|
|
1230
|
+
`).map((c, a, g) => {
|
|
1231
|
+
const m = t ? t(c, a) : c;
|
|
1232
|
+
return a === 0 ? `${n}${m}` : a === g.length - 1 ? `${s}${m}` : `${o}${m}`;
|
|
1252
1233
|
}).join(`
|
|
1253
1234
|
`);
|
|
1254
1235
|
}
|
|
@@ -1261,7 +1242,7 @@ function runValidation(e, a) {
|
|
|
1261
1242
|
return e(a);
|
|
1262
1243
|
}
|
|
1263
1244
|
|
|
1264
|
-
class
|
|
1245
|
+
let C$1 = class C {
|
|
1265
1246
|
input;
|
|
1266
1247
|
output;
|
|
1267
1248
|
_abortSignal;
|
|
@@ -1343,16 +1324,16 @@ class y {
|
|
|
1343
1324
|
{ once: true }
|
|
1344
1325
|
);
|
|
1345
1326
|
}
|
|
1346
|
-
this.rl =
|
|
1327
|
+
this.rl = f$1__default.createInterface({
|
|
1347
1328
|
input: this.input,
|
|
1348
1329
|
tabSize: 2,
|
|
1349
1330
|
prompt: "",
|
|
1350
1331
|
escapeCodeTimeout: 50,
|
|
1351
1332
|
terminal: true
|
|
1352
1333
|
}), 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", () => {
|
|
1353
|
-
this.output.write(
|
|
1334
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
1354
1335
|
}), this.once("cancel", () => {
|
|
1355
|
-
this.output.write(
|
|
1336
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
1356
1337
|
});
|
|
1357
1338
|
});
|
|
1358
1339
|
}
|
|
@@ -1389,18 +1370,18 @@ class y {
|
|
|
1389
1370
|
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
1390
1371
|
}
|
|
1391
1372
|
restoreCursor() {
|
|
1392
|
-
const t = wrapAnsi(this._prevFrame,
|
|
1373
|
+
const t = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
|
|
1393
1374
|
`).length - 1;
|
|
1394
|
-
this.output.write(
|
|
1375
|
+
this.output.write(cursor.move(-999, t * -1));
|
|
1395
1376
|
}
|
|
1396
1377
|
render() {
|
|
1397
|
-
const t = wrapAnsi(this._render(this) ?? "",
|
|
1378
|
+
const t = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
|
|
1398
1379
|
hard: true,
|
|
1399
1380
|
trim: false
|
|
1400
1381
|
});
|
|
1401
1382
|
if (t !== this._prevFrame) {
|
|
1402
1383
|
if (this.state === "initial")
|
|
1403
|
-
this.output.write(
|
|
1384
|
+
this.output.write(cursor.hide);
|
|
1404
1385
|
else {
|
|
1405
1386
|
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
1406
1387
|
if (this.restoreCursor(), e) {
|
|
@@ -1411,32 +1392,32 @@ class y {
|
|
|
1411
1392
|
return;
|
|
1412
1393
|
}
|
|
1413
1394
|
if (e.lines.length === 1) {
|
|
1414
|
-
this.output.write(
|
|
1395
|
+
this.output.write(cursor.move(0, n - r)), this.output.write(erase.lines(1));
|
|
1415
1396
|
const o = t.split(`
|
|
1416
1397
|
`);
|
|
1417
|
-
this.output.write(o[n]), this._prevFrame = t, this.output.write(
|
|
1398
|
+
this.output.write(o[n]), this._prevFrame = t, this.output.write(cursor.move(0, o.length - n - 1));
|
|
1418
1399
|
return;
|
|
1419
1400
|
} else if (e.lines.length > 1) {
|
|
1420
1401
|
if (s < r)
|
|
1421
1402
|
n = s;
|
|
1422
1403
|
else {
|
|
1423
1404
|
const h = n - r;
|
|
1424
|
-
h > 0 && this.output.write(
|
|
1405
|
+
h > 0 && this.output.write(cursor.move(0, h));
|
|
1425
1406
|
}
|
|
1426
|
-
this.output.write(
|
|
1427
|
-
const
|
|
1407
|
+
this.output.write(erase.down());
|
|
1408
|
+
const m = t.split(`
|
|
1428
1409
|
`).slice(n);
|
|
1429
|
-
this.output.write(
|
|
1410
|
+
this.output.write(m.join(`
|
|
1430
1411
|
`)), this._prevFrame = t;
|
|
1431
1412
|
return;
|
|
1432
1413
|
}
|
|
1433
1414
|
}
|
|
1434
|
-
this.output.write(
|
|
1415
|
+
this.output.write(erase.down());
|
|
1435
1416
|
}
|
|
1436
1417
|
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
1437
1418
|
}
|
|
1438
1419
|
}
|
|
1439
|
-
}
|
|
1420
|
+
};
|
|
1440
1421
|
|
|
1441
1422
|
function p$1$1(l, e) {
|
|
1442
1423
|
if (l === void 0 || e.length === 0)
|
|
@@ -1451,7 +1432,7 @@ function g(l, e) {
|
|
|
1451
1432
|
if (e)
|
|
1452
1433
|
return l ? e : e[0];
|
|
1453
1434
|
}
|
|
1454
|
-
let T$1 = class T extends
|
|
1435
|
+
let T$1 = class T extends C$1 {
|
|
1455
1436
|
filteredOptions;
|
|
1456
1437
|
multiple;
|
|
1457
1438
|
isNavigating = false;
|
|
@@ -1526,7 +1507,7 @@ let T$1 = class T extends y {
|
|
|
1526
1507
|
}
|
|
1527
1508
|
};
|
|
1528
1509
|
|
|
1529
|
-
class r extends
|
|
1510
|
+
class r extends C$1 {
|
|
1530
1511
|
get cursor() {
|
|
1531
1512
|
return this.value ? 0 : 1;
|
|
1532
1513
|
}
|
|
@@ -1537,7 +1518,7 @@ class r extends y {
|
|
|
1537
1518
|
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
1538
1519
|
this.value = this._value;
|
|
1539
1520
|
}), this.on("confirm", (i) => {
|
|
1540
|
-
this.output.write(
|
|
1521
|
+
this.output.write(cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
1541
1522
|
}), this.on("cursor", () => {
|
|
1542
1523
|
this.value = !this.value;
|
|
1543
1524
|
});
|
|
@@ -1583,7 +1564,7 @@ function b$1(r) {
|
|
|
1583
1564
|
if (!(n.getUTCFullYear() !== t || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
1584
1565
|
return { year: t, month: i, day: s };
|
|
1585
1566
|
}
|
|
1586
|
-
function C$
|
|
1567
|
+
function C$2(r) {
|
|
1587
1568
|
const t = b$1(r);
|
|
1588
1569
|
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
|
|
1589
1570
|
}
|
|
@@ -1605,7 +1586,7 @@ function T(r, t, i, s) {
|
|
|
1605
1586
|
max: e && t.year === e.year && t.month === e.month ? e.day : c$1(t.year, t.month)
|
|
1606
1587
|
};
|
|
1607
1588
|
}
|
|
1608
|
-
let U$1 = class U extends
|
|
1589
|
+
let U$1 = class U extends C$1 {
|
|
1609
1590
|
#i;
|
|
1610
1591
|
#o;
|
|
1611
1592
|
#t;
|
|
@@ -1634,7 +1615,7 @@ let U$1 = class U extends y {
|
|
|
1634
1615
|
return this.#i.map((i) => t[i.type]).join(this.#o);
|
|
1635
1616
|
}
|
|
1636
1617
|
#r() {
|
|
1637
|
-
this._setUserInput(this.#l(this.#t)), this._setValue(C$
|
|
1618
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C$2(this.#t) ?? void 0);
|
|
1638
1619
|
}
|
|
1639
1620
|
constructor(t) {
|
|
1640
1621
|
const i = t.format ? { segments: M(t.format), separator: t.separator ?? "/" } : P$1(t.locale), s = t.separator ?? i.separator, n = t.format ? M(t.format) : i.segments, e = t.initialValue ?? t.defaultValue, m = e ? {
|
|
@@ -1767,57 +1748,59 @@ let U$1 = class U extends y {
|
|
|
1767
1748
|
day: String(Math.min(n, e)).padStart(2, "0")
|
|
1768
1749
|
};
|
|
1769
1750
|
}
|
|
1770
|
-
this.value = C$
|
|
1751
|
+
this.value = C$2(this.#t) ?? t.defaultValue ?? void 0;
|
|
1771
1752
|
}
|
|
1772
1753
|
};
|
|
1773
1754
|
|
|
1774
|
-
let u$
|
|
1755
|
+
let u$1 = class u extends C$1 {
|
|
1775
1756
|
options;
|
|
1776
1757
|
cursor = 0;
|
|
1777
|
-
#
|
|
1758
|
+
#e;
|
|
1778
1759
|
getGroupItems(t) {
|
|
1779
|
-
return this.options.filter((
|
|
1760
|
+
return this.options.filter((i) => i.group === t);
|
|
1780
1761
|
}
|
|
1781
1762
|
isGroupSelected(t) {
|
|
1782
|
-
const
|
|
1783
|
-
return e === void 0 ? false :
|
|
1763
|
+
const i = this.getGroupItems(t), e = this.value;
|
|
1764
|
+
return e === void 0 ? false : i.every((s) => e.includes(s.value));
|
|
1784
1765
|
}
|
|
1785
1766
|
toggleValue() {
|
|
1786
1767
|
const t = this.options[this.cursor];
|
|
1787
1768
|
if (t !== void 0)
|
|
1788
1769
|
if (this.value === void 0 && (this.value = []), t.group === true) {
|
|
1789
|
-
const
|
|
1790
|
-
this.isGroupSelected(
|
|
1791
|
-
(s) => e.findIndex((
|
|
1770
|
+
const i = t.value, e = this.getGroupItems(i);
|
|
1771
|
+
this.isGroupSelected(i) ? this.value = this.value.filter(
|
|
1772
|
+
(s) => e.findIndex((r) => r.value === s) === -1
|
|
1792
1773
|
) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
1793
1774
|
} else {
|
|
1794
|
-
const
|
|
1795
|
-
this.value =
|
|
1775
|
+
const i = this.value.includes(t.value);
|
|
1776
|
+
this.value = i ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
|
|
1796
1777
|
}
|
|
1797
1778
|
}
|
|
1798
1779
|
constructor(t) {
|
|
1799
1780
|
super(t, false);
|
|
1800
|
-
const { options:
|
|
1801
|
-
this.#
|
|
1781
|
+
const { options: i } = t;
|
|
1782
|
+
this.#e = t.selectableGroups !== false, this.options = Object.entries(i).flatMap(([e, s]) => [
|
|
1802
1783
|
{ value: e, group: true, label: e },
|
|
1803
|
-
...s.map((
|
|
1784
|
+
...s.map((r) => ({ ...r, group: e }))
|
|
1804
1785
|
]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(
|
|
1805
1786
|
this.options.findIndex(({ value: e }) => e === t.cursorAt),
|
|
1806
|
-
this.#
|
|
1807
|
-
), this.on("
|
|
1787
|
+
this.#e ? 0 : 1
|
|
1788
|
+
), this.on("key", (e, s) => {
|
|
1789
|
+
s.name === void 0 && e === "\u3000" && this.toggleValue();
|
|
1790
|
+
}), this.on("cursor", (e) => {
|
|
1808
1791
|
switch (e) {
|
|
1809
1792
|
case "left":
|
|
1810
1793
|
case "up": {
|
|
1811
1794
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1812
1795
|
const s = this.options[this.cursor]?.group === true;
|
|
1813
|
-
!this.#
|
|
1796
|
+
!this.#e && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1814
1797
|
break;
|
|
1815
1798
|
}
|
|
1816
1799
|
case "down":
|
|
1817
1800
|
case "right": {
|
|
1818
1801
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1819
1802
|
const s = this.options[this.cursor]?.group === true;
|
|
1820
|
-
!this.#
|
|
1803
|
+
!this.#e && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1821
1804
|
break;
|
|
1822
1805
|
}
|
|
1823
1806
|
case "space":
|
|
@@ -1829,7 +1812,7 @@ let u$2 = class u extends y {
|
|
|
1829
1812
|
};
|
|
1830
1813
|
|
|
1831
1814
|
const o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
1832
|
-
class h extends
|
|
1815
|
+
class h extends C$1 {
|
|
1833
1816
|
#t = false;
|
|
1834
1817
|
#s;
|
|
1835
1818
|
focused = "editor";
|
|
@@ -1924,7 +1907,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
|
|
|
1924
1907
|
}
|
|
1925
1908
|
}
|
|
1926
1909
|
|
|
1927
|
-
class a extends
|
|
1910
|
+
class a extends C$1 {
|
|
1928
1911
|
options;
|
|
1929
1912
|
cursor = 0;
|
|
1930
1913
|
get _value() {
|
|
@@ -1955,8 +1938,8 @@ class a extends y {
|
|
|
1955
1938
|
this.options.findIndex(({ value: t }) => t === e.cursorAt),
|
|
1956
1939
|
0
|
|
1957
1940
|
);
|
|
1958
|
-
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t,
|
|
1959
|
-
|
|
1941
|
+
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, s) => {
|
|
1942
|
+
s.name === "a" && this.toggleAll(), s.name === "i" && this.toggleInvert(), s.name === void 0 && t === "\u3000" && this.toggleValue();
|
|
1960
1943
|
}), this.on("cursor", (t) => {
|
|
1961
1944
|
switch (t) {
|
|
1962
1945
|
case "left":
|
|
@@ -1975,7 +1958,7 @@ class a extends y {
|
|
|
1975
1958
|
}
|
|
1976
1959
|
}
|
|
1977
1960
|
|
|
1978
|
-
let u$
|
|
1961
|
+
let u$2 = class u extends C$1 {
|
|
1979
1962
|
_mask = "\u2022";
|
|
1980
1963
|
get cursor() {
|
|
1981
1964
|
return this._cursor;
|
|
@@ -2004,7 +1987,7 @@ let u$1 = class u extends y {
|
|
|
2004
1987
|
}
|
|
2005
1988
|
};
|
|
2006
1989
|
|
|
2007
|
-
let n$1 = class n extends
|
|
1990
|
+
let n$1 = class n extends C$1 {
|
|
2008
1991
|
options;
|
|
2009
1992
|
cursor = 0;
|
|
2010
1993
|
get _selectedValue() {
|
|
@@ -2033,25 +2016,25 @@ let n$1 = class n extends y {
|
|
|
2033
2016
|
}
|
|
2034
2017
|
};
|
|
2035
2018
|
|
|
2036
|
-
let
|
|
2019
|
+
let c$2 = class c extends C$1 {
|
|
2037
2020
|
options;
|
|
2038
2021
|
cursor = 0;
|
|
2039
2022
|
constructor(t) {
|
|
2040
2023
|
super(t, false), this.options = t.options;
|
|
2041
|
-
const s = t.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
|
|
2042
|
-
this.cursor =
|
|
2024
|
+
const s = t.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase()), n = Math.max(i.indexOf(t.initialValue), 0);
|
|
2025
|
+
this.cursor = this.options[n]?.disabled ? 0 : n, this.on("key", (e) => {
|
|
2043
2026
|
if (!e)
|
|
2044
2027
|
return;
|
|
2045
2028
|
const o = s ? e : e.toLowerCase();
|
|
2046
2029
|
if (!i.includes(o))
|
|
2047
2030
|
return;
|
|
2048
|
-
const
|
|
2049
|
-
|
|
2031
|
+
const r = this.options.find(({ value: [a], disabled: u }) => u ? false : s ? a === o : a?.toLowerCase() === o);
|
|
2032
|
+
r && (this.value = r.value, this.state = "submit", this.emit("submit"));
|
|
2050
2033
|
});
|
|
2051
2034
|
}
|
|
2052
2035
|
};
|
|
2053
2036
|
|
|
2054
|
-
class n extends
|
|
2037
|
+
class n extends C$1 {
|
|
2055
2038
|
get userInputWithCursor() {
|
|
2056
2039
|
if (this.state === "submit")
|
|
2057
2040
|
return this.userInput;
|
|
@@ -2092,8 +2075,8 @@ function isUnicodeSupported() {
|
|
|
2092
2075
|
|| process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
2093
2076
|
}
|
|
2094
2077
|
|
|
2095
|
-
const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", isTTY = (
|
|
2096
|
-
switch (
|
|
2078
|
+
const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", isTTY = (e) => e.isTTY === true, unicodeOr = (e, o) => unicode ? e : o, S_STEP_ACTIVE = unicodeOr("\u25C6", "*"), S_STEP_CANCEL = unicodeOr("\u25A0", "x"), S_STEP_ERROR = unicodeOr("\u25B2", "x"), S_STEP_SUBMIT = unicodeOr("\u25C7", "o"), S_BAR_START = unicodeOr("\u250C", "T"), S_BAR = unicodeOr("\u2502", "|"), S_BAR_END = unicodeOr("\u2514", "\u2014"), S_BAR_START_RIGHT = unicodeOr("\u2510", "T"), S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014"), S_RADIO_ACTIVE = unicodeOr("\u25CF", ">"), S_RADIO_INACTIVE = unicodeOr("\u25CB", " "), S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]"), S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]"), S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]"), S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022"), S_BAR_H = unicodeOr("\u2500", "-"), S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+"), S_CONNECT_LEFT = unicodeOr("\u251C", "+"), S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+"), S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+"), S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+"), S_INFO = unicodeOr("\u25CF", "\u2022"), S_SUCCESS = unicodeOr("\u25C6", "*"), S_WARN = unicodeOr("\u25B2", "!"), S_ERROR = unicodeOr("\u25A0", "x"), symbol = (e) => {
|
|
2079
|
+
switch (e) {
|
|
2097
2080
|
case "initial":
|
|
2098
2081
|
case "active":
|
|
2099
2082
|
return styleText("cyan", S_STEP_ACTIVE);
|
|
@@ -2106,8 +2089,8 @@ const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", is
|
|
|
2106
2089
|
case "validating":
|
|
2107
2090
|
return styleText("dim", S_STEP_ACTIVE);
|
|
2108
2091
|
}
|
|
2109
|
-
}, symbolBar = (
|
|
2110
|
-
switch (
|
|
2092
|
+
}, symbolBar = (e) => {
|
|
2093
|
+
switch (e) {
|
|
2111
2094
|
case "initial":
|
|
2112
2095
|
case "active":
|
|
2113
2096
|
return styleText("cyan", S_BAR);
|
|
@@ -2119,12 +2102,13 @@ const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", is
|
|
|
2119
2102
|
return styleText("green", S_BAR);
|
|
2120
2103
|
}
|
|
2121
2104
|
};
|
|
2122
|
-
function formatInstructionFooter(o,
|
|
2123
|
-
const
|
|
2124
|
-
|
|
2105
|
+
function formatInstructionFooter(e, o, r) {
|
|
2106
|
+
const s = r ? `${styleText("cyan", S_BAR)} ` : "", n = wrapTextWithPrefix(e, o.join(" \u2022 "), s).split(`
|
|
2107
|
+
`);
|
|
2108
|
+
return r && n.push(styleText("cyan", S_BAR_END)), n;
|
|
2125
2109
|
}
|
|
2126
2110
|
|
|
2127
|
-
const
|
|
2111
|
+
const E$1 = (l, e, w, p, b, C = false) => {
|
|
2128
2112
|
let r = e, O = 0;
|
|
2129
2113
|
if (C)
|
|
2130
2114
|
for (let i = p - 1; i >= w; i--) {
|
|
@@ -2154,15 +2138,15 @@ const limitOptions = ({
|
|
|
2154
2138
|
0
|
|
2155
2139
|
));
|
|
2156
2140
|
let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
|
|
2157
|
-
const
|
|
2141
|
+
const I = Math.min(
|
|
2158
2142
|
f + a,
|
|
2159
2143
|
e.length
|
|
2160
2144
|
), s = [];
|
|
2161
2145
|
let g = 0;
|
|
2162
2146
|
d && g++, c && g++;
|
|
2163
|
-
const T = f + (d ? 1 : 0),
|
|
2164
|
-
for (let t = T; t <
|
|
2165
|
-
const n = e[t], o = n ? w(n, t === l) : "", h = wrapAnsi(o, i, {
|
|
2147
|
+
const T = f + (d ? 1 : 0), W = I - (c ? 1 : 0);
|
|
2148
|
+
for (let t = T; t < W; t++) {
|
|
2149
|
+
const n = e[t], o = n !== void 0 ? w(n, t === l) : "", h = wrapAnsi(o, i, {
|
|
2166
2150
|
hard: true,
|
|
2167
2151
|
trim: false
|
|
2168
2152
|
}).split(`
|
|
@@ -2173,7 +2157,7 @@ const limitOptions = ({
|
|
|
2173
2157
|
let t = 0, n = 0, o = g;
|
|
2174
2158
|
const h = l - T;
|
|
2175
2159
|
let u = v;
|
|
2176
|
-
const L = () =>
|
|
2160
|
+
const L = () => E$1(s, o, 0, h, u), y = () => E$1(
|
|
2177
2161
|
s,
|
|
2178
2162
|
o,
|
|
2179
2163
|
h + 1,
|
|
@@ -2181,7 +2165,7 @@ const limitOptions = ({
|
|
|
2181
2165
|
u,
|
|
2182
2166
|
true
|
|
2183
2167
|
);
|
|
2184
|
-
d ? ({ lineCount: o, removals: t } = L(), o > u && (c || (u -= 1), { lineCount: o, removals: n } =
|
|
2168
|
+
d ? ({ lineCount: o, removals: t } = L(), o > u && (c || (u -= 1), { lineCount: o, removals: n } = y())) : (c || (u -= 1), { lineCount: o, removals: n } = y(), o > u && (u -= 1, { lineCount: o, removals: t } = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
|
|
2185
2169
|
}
|
|
2186
2170
|
const x = [];
|
|
2187
2171
|
d && x.push(M);
|
|
@@ -2208,7 +2192,7 @@ function j(t, c) {
|
|
|
2208
2192
|
}
|
|
2209
2193
|
const autocomplete = (t) => new T$1({
|
|
2210
2194
|
options: t.options,
|
|
2211
|
-
initialValue: t.initialValue ? [t.initialValue] : void 0,
|
|
2195
|
+
initialValue: t.initialValue !== void 0 ? [t.initialValue] : void 0,
|
|
2212
2196
|
initialUserInput: t.initialUserInput,
|
|
2213
2197
|
placeholder: t.placeholder,
|
|
2214
2198
|
completeOnTab: t.completeOnTab,
|
|
@@ -2538,22 +2522,22 @@ const MULTISELECT_INSTRUCTIONS = [
|
|
|
2538
2522
|
`${styleText("dim", "Space:")} select`,
|
|
2539
2523
|
`${styleText("dim", "Enter:")} confirm`
|
|
2540
2524
|
];
|
|
2541
|
-
const m = (
|
|
2525
|
+
const m = (n, u) => n.split(`
|
|
2542
2526
|
`).map((d) => u(d)).join(`
|
|
2543
2527
|
`);
|
|
2544
|
-
const multiselect = (
|
|
2528
|
+
const multiselect = (n) => {
|
|
2545
2529
|
const u = (t, a) => {
|
|
2546
2530
|
const r = t.label ?? String(t.value);
|
|
2547
2531
|
return a === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${m(r, (o) => styleText(["strikethrough", "gray"], o))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${m(r, (o) => styleText("dim", o))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "cancelled" ? `${m(r, (o) => styleText(["strikethrough", "dim"], o))}` : a === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "submitted" ? `${m(r, (o) => styleText("dim", o))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${m(r, (o) => styleText("dim", o))}`;
|
|
2548
|
-
}, d =
|
|
2532
|
+
}, d = n.required ?? true, x = n.showInstructions ?? true;
|
|
2549
2533
|
return new a({
|
|
2550
|
-
options:
|
|
2551
|
-
signal:
|
|
2552
|
-
input:
|
|
2553
|
-
output:
|
|
2554
|
-
initialValues:
|
|
2534
|
+
options: n.options,
|
|
2535
|
+
signal: n.signal,
|
|
2536
|
+
input: n.input,
|
|
2537
|
+
output: n.output,
|
|
2538
|
+
initialValues: n.initialValues,
|
|
2555
2539
|
required: d,
|
|
2556
|
-
cursorAt:
|
|
2540
|
+
cursorAt: n.cursorAt,
|
|
2557
2541
|
validate(t) {
|
|
2558
2542
|
if (d && (t === void 0 || t.length === 0))
|
|
2559
2543
|
return `Please select at least one option.
|
|
@@ -2569,75 +2553,75 @@ ${styleText(
|
|
|
2569
2553
|
)}`;
|
|
2570
2554
|
},
|
|
2571
2555
|
render() {
|
|
2572
|
-
const t =
|
|
2573
|
-
|
|
2574
|
-
|
|
2556
|
+
const t = n.withGuide ?? settings.withGuide, a = wrapTextWithPrefix(
|
|
2557
|
+
n.output,
|
|
2558
|
+
n.message,
|
|
2575
2559
|
t ? `${symbolBar(this.state)} ` : "",
|
|
2576
2560
|
`${symbol(this.state)} `
|
|
2577
2561
|
), r = `${t ? `${styleText("gray", S_BAR)}
|
|
2578
2562
|
` : ""}${a}
|
|
2579
|
-
`, o = this.value ?? [], g = (
|
|
2580
|
-
if (
|
|
2581
|
-
return u(
|
|
2582
|
-
const s = o.includes(
|
|
2583
|
-
return l && s ? u(
|
|
2563
|
+
`, o = this.value ?? [], g = (i, l) => {
|
|
2564
|
+
if (i.disabled)
|
|
2565
|
+
return u(i, "disabled");
|
|
2566
|
+
const s = o.includes(i.value);
|
|
2567
|
+
return l && s ? u(i, "active-selected") : s ? u(i, "selected") : u(i, l ? "active" : "inactive");
|
|
2584
2568
|
};
|
|
2585
2569
|
switch (this.state) {
|
|
2586
2570
|
case "submit": {
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
|
|
2571
|
+
const i = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = wrapTextWithPrefix(
|
|
2572
|
+
n.output,
|
|
2573
|
+
i,
|
|
2590
2574
|
t ? `${styleText("gray", S_BAR)} ` : ""
|
|
2591
2575
|
);
|
|
2592
2576
|
return `${r}${l}`;
|
|
2593
2577
|
}
|
|
2594
2578
|
case "cancel": {
|
|
2595
|
-
const
|
|
2596
|
-
if (
|
|
2579
|
+
const i = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "cancelled")).join(styleText("dim", ", "));
|
|
2580
|
+
if (i.trim() === "")
|
|
2597
2581
|
return `${r}${styleText("gray", S_BAR)}`;
|
|
2598
2582
|
const l = wrapTextWithPrefix(
|
|
2599
|
-
|
|
2600
|
-
|
|
2583
|
+
n.output,
|
|
2584
|
+
i,
|
|
2601
2585
|
t ? `${styleText("gray", S_BAR)} ` : ""
|
|
2602
2586
|
);
|
|
2603
2587
|
return `${r}${l}${t ? `
|
|
2604
2588
|
${styleText("gray", S_BAR)}` : ""}`;
|
|
2605
2589
|
}
|
|
2606
2590
|
case "error": {
|
|
2607
|
-
const
|
|
2591
|
+
const i = t ? `${styleText("yellow", S_BAR)} ` : "", l = this.error.split(`
|
|
2608
2592
|
`).map(
|
|
2609
2593
|
($, v) => v === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", $)}` : ` ${$}`
|
|
2610
2594
|
).join(`
|
|
2611
2595
|
`), s = r.split(`
|
|
2612
2596
|
`).length, h = l.split(`
|
|
2613
2597
|
`).length + 1;
|
|
2614
|
-
return `${r}${
|
|
2615
|
-
output:
|
|
2598
|
+
return `${r}${i}${limitOptions({
|
|
2599
|
+
output: n.output,
|
|
2616
2600
|
options: this.options,
|
|
2617
2601
|
cursor: this.cursor,
|
|
2618
|
-
maxItems:
|
|
2619
|
-
columnPadding:
|
|
2602
|
+
maxItems: n.maxItems,
|
|
2603
|
+
columnPadding: i.length,
|
|
2620
2604
|
rowPadding: s + h,
|
|
2621
2605
|
style: g
|
|
2622
2606
|
}).join(`
|
|
2623
|
-
${
|
|
2607
|
+
${i}`)}
|
|
2624
2608
|
${l}
|
|
2625
2609
|
`;
|
|
2626
2610
|
}
|
|
2627
2611
|
default: {
|
|
2628
|
-
const
|
|
2629
|
-
`).length, s = x ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t) : t ? [styleText("cyan", S_BAR_END)] : [], h = s.join(`
|
|
2612
|
+
const i = t ? `${styleText("cyan", S_BAR)} ` : "", l = r.split(`
|
|
2613
|
+
`).length, s = x ? formatInstructionFooter(n.output, MULTISELECT_INSTRUCTIONS, t) : t ? [styleText("cyan", S_BAR_END)] : [], h = s.join(`
|
|
2630
2614
|
`), $ = s.length + 1;
|
|
2631
|
-
return `${r}${
|
|
2632
|
-
output:
|
|
2615
|
+
return `${r}${i}${limitOptions({
|
|
2616
|
+
output: n.output,
|
|
2633
2617
|
options: this.options,
|
|
2634
2618
|
cursor: this.cursor,
|
|
2635
|
-
maxItems:
|
|
2636
|
-
columnPadding:
|
|
2619
|
+
maxItems: n.maxItems,
|
|
2620
|
+
columnPadding: i.length,
|
|
2637
2621
|
rowPadding: l + $,
|
|
2638
2622
|
style: g
|
|
2639
2623
|
}).join(`
|
|
2640
|
-
${
|
|
2624
|
+
${i}`)}
|
|
2641
2625
|
${h}
|
|
2642
2626
|
`;
|
|
2643
2627
|
}
|
|
@@ -2646,46 +2630,46 @@ ${h}
|
|
|
2646
2630
|
}).prompt();
|
|
2647
2631
|
};
|
|
2648
2632
|
|
|
2649
|
-
const groupMultiselect = (
|
|
2650
|
-
const { selectableGroups: f = true, groupSpacing: x = 0 } =
|
|
2651
|
-
const a = n.label ?? String(n.value), t = typeof n.group == "string",
|
|
2652
|
-
let
|
|
2653
|
-
t && (f ? (
|
|
2633
|
+
const groupMultiselect = (r) => {
|
|
2634
|
+
const { selectableGroups: f = true, groupSpacing: x = 0 } = r, d = (n, l, p = []) => {
|
|
2635
|
+
const a = n.label ?? String(n.value), t = typeof n.group == "string", u = t && (p[p.indexOf(n) + 1] ?? { group: true }), s = t && u && u.group === true;
|
|
2636
|
+
let o = "", c = "";
|
|
2637
|
+
t && (f ? (o = s ? `${S_BAR_END} ` : `${S_BAR} `, c = s ? " " : `${S_BAR} `) : o = " ");
|
|
2654
2638
|
let i = "";
|
|
2655
2639
|
if (x > 0 && !t && (i = `
|
|
2656
2640
|
`.repeat(x)), l === "active")
|
|
2657
2641
|
return wrapTextWithPrefix(
|
|
2658
|
-
|
|
2642
|
+
r.output,
|
|
2659
2643
|
`${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
|
|
2660
|
-
`${i}${styleText("dim",
|
|
2661
|
-
`${i}${styleText("dim",
|
|
2644
|
+
`${i}${styleText("dim", o)} `,
|
|
2645
|
+
`${i}${styleText("dim", o)}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
2662
2646
|
`${i}${styleText("dim", c)} `
|
|
2663
2647
|
);
|
|
2664
2648
|
if (l === "group-active")
|
|
2665
2649
|
return wrapTextWithPrefix(
|
|
2666
|
-
|
|
2650
|
+
r.output,
|
|
2667
2651
|
a,
|
|
2668
|
-
`${i}${
|
|
2669
|
-
`${i}${
|
|
2652
|
+
`${i}${o} `,
|
|
2653
|
+
`${i}${o}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
2670
2654
|
`${i}${c} `,
|
|
2671
2655
|
(m) => styleText("dim", m)
|
|
2672
2656
|
);
|
|
2673
2657
|
if (l === "group-active-selected")
|
|
2674
2658
|
return wrapTextWithPrefix(
|
|
2675
|
-
|
|
2659
|
+
r.output,
|
|
2676
2660
|
a,
|
|
2677
|
-
`${i}${
|
|
2678
|
-
`${i}${
|
|
2661
|
+
`${i}${o} `,
|
|
2662
|
+
`${i}${o}${styleText("green", S_CHECKBOX_SELECTED)} `,
|
|
2679
2663
|
`${i}${c} `,
|
|
2680
2664
|
(m) => styleText("dim", m)
|
|
2681
2665
|
);
|
|
2682
2666
|
if (l === "selected") {
|
|
2683
2667
|
const m = t || f ? styleText("green", S_CHECKBOX_SELECTED) : "";
|
|
2684
2668
|
return wrapTextWithPrefix(
|
|
2685
|
-
|
|
2669
|
+
r.output,
|
|
2686
2670
|
`${a}${n.hint ? ` (${n.hint})` : ""}`,
|
|
2687
|
-
`${i}${styleText("dim",
|
|
2688
|
-
`${i}${styleText("dim",
|
|
2671
|
+
`${i}${styleText("dim", o)} `,
|
|
2672
|
+
`${i}${styleText("dim", o)}${m} `,
|
|
2689
2673
|
`${i}${styleText("dim", c)} `,
|
|
2690
2674
|
(I) => styleText("dim", I)
|
|
2691
2675
|
);
|
|
@@ -2694,32 +2678,32 @@ const groupMultiselect = (o) => {
|
|
|
2694
2678
|
return `${styleText(["strikethrough", "dim"], a)}`;
|
|
2695
2679
|
if (l === "active-selected")
|
|
2696
2680
|
return wrapTextWithPrefix(
|
|
2697
|
-
|
|
2681
|
+
r.output,
|
|
2698
2682
|
`${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
|
|
2699
|
-
`${i}${styleText("dim",
|
|
2700
|
-
`${i}${styleText("dim",
|
|
2683
|
+
`${i}${styleText("dim", o)} `,
|
|
2684
|
+
`${i}${styleText("dim", o)}${styleText("green", S_CHECKBOX_SELECTED)} `,
|
|
2701
2685
|
`${i}${styleText("dim", c)} `
|
|
2702
2686
|
);
|
|
2703
2687
|
if (l === "submitted")
|
|
2704
2688
|
return `${styleText("dim", a)}`;
|
|
2705
2689
|
const h = t || f ? styleText("dim", S_CHECKBOX_INACTIVE) : "";
|
|
2706
2690
|
return wrapTextWithPrefix(
|
|
2707
|
-
|
|
2691
|
+
r.output,
|
|
2708
2692
|
a,
|
|
2709
|
-
`${i}${styleText("dim",
|
|
2710
|
-
`${i}${styleText("dim",
|
|
2693
|
+
`${i}${styleText("dim", o)} `,
|
|
2694
|
+
`${i}${styleText("dim", o)}${h} `,
|
|
2711
2695
|
`${i}${styleText("dim", c)} `,
|
|
2712
2696
|
(m) => styleText("dim", m)
|
|
2713
2697
|
);
|
|
2714
|
-
}, y =
|
|
2715
|
-
return new u$
|
|
2716
|
-
options:
|
|
2717
|
-
signal:
|
|
2718
|
-
input:
|
|
2719
|
-
output:
|
|
2720
|
-
initialValues:
|
|
2698
|
+
}, y = r.required ?? true, S = r.showInstructions ?? true;
|
|
2699
|
+
return new u$1({
|
|
2700
|
+
options: r.options,
|
|
2701
|
+
signal: r.signal,
|
|
2702
|
+
input: r.input,
|
|
2703
|
+
output: r.output,
|
|
2704
|
+
initialValues: r.initialValues,
|
|
2721
2705
|
required: y,
|
|
2722
|
-
cursorAt:
|
|
2706
|
+
cursorAt: r.cursorAt,
|
|
2723
2707
|
selectableGroups: f,
|
|
2724
2708
|
validate(n) {
|
|
2725
2709
|
if (y && (n === void 0 || n.length === 0))
|
|
@@ -2736,58 +2720,58 @@ ${styleText(
|
|
|
2736
2720
|
)}`;
|
|
2737
2721
|
},
|
|
2738
2722
|
render() {
|
|
2739
|
-
const n =
|
|
2740
|
-
` : ""}${symbol(this.state)} ${
|
|
2741
|
-
`, p = this.value ?? [], a = (t,
|
|
2742
|
-
const
|
|
2743
|
-
return !
|
|
2723
|
+
const n = r.withGuide ?? settings.withGuide, l = `${n ? `${styleText("gray", S_BAR)}
|
|
2724
|
+
` : ""}${symbol(this.state)} ${r.message}
|
|
2725
|
+
`, p = this.value ?? [], a = (t, u) => {
|
|
2726
|
+
const s = this.options, o = p.includes(t.value) || t.group === true && this.isGroupSelected(`${t.value}`);
|
|
2727
|
+
return !u && typeof t.group == "string" && this.options[this.cursor]?.value === t.group ? d(t, o ? "group-active-selected" : "group-active", s) : u && o ? d(t, "active-selected", s) : o ? d(t, "selected", s) : d(t, u ? "active" : "inactive", s);
|
|
2744
2728
|
};
|
|
2745
2729
|
switch (this.state) {
|
|
2746
2730
|
case "submit": {
|
|
2747
|
-
const t = this.options.filter(({ value:
|
|
2748
|
-
return `${l}${n ? styleText("gray", S_BAR) : ""}${
|
|
2731
|
+
const t = this.options.filter(({ value: s }) => p.includes(s)).map((s) => d(s, "submitted")), u = t.length === 0 ? "" : ` ${t.join(styleText("dim", ", "))}`;
|
|
2732
|
+
return `${l}${n ? styleText("gray", S_BAR) : ""}${u}`;
|
|
2749
2733
|
}
|
|
2750
2734
|
case "cancel": {
|
|
2751
|
-
const t = this.options.filter(({ value:
|
|
2735
|
+
const t = this.options.filter(({ value: u }) => p.includes(u)).map((u) => d(u, "cancelled")).join(styleText("dim", ", "));
|
|
2752
2736
|
return `${l}${n ? `${styleText("gray", S_BAR)} ` : ""}${t.trim() ? `${t}${n ? `
|
|
2753
2737
|
${styleText("gray", S_BAR)}` : ""}` : ""}`;
|
|
2754
2738
|
}
|
|
2755
2739
|
case "error": {
|
|
2756
|
-
const t = n ? `${styleText("yellow", S_BAR)} ` : "",
|
|
2740
|
+
const t = n ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
|
|
2757
2741
|
`).map(
|
|
2758
2742
|
(i, h) => h === 0 ? `${n ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", i)}` : ` ${i}`
|
|
2759
2743
|
).join(`
|
|
2760
|
-
`),
|
|
2761
|
-
`).length,
|
|
2744
|
+
`), s = l.split(`
|
|
2745
|
+
`).length, o = u.split(`
|
|
2762
2746
|
`).length + 1, c = limitOptions({
|
|
2763
|
-
output:
|
|
2747
|
+
output: r.output,
|
|
2764
2748
|
options: this.options,
|
|
2765
2749
|
cursor: this.cursor,
|
|
2766
|
-
maxItems:
|
|
2750
|
+
maxItems: r.maxItems,
|
|
2767
2751
|
columnPadding: t.length,
|
|
2768
|
-
rowPadding:
|
|
2752
|
+
rowPadding: s + o,
|
|
2769
2753
|
style: a
|
|
2770
2754
|
}).join(`
|
|
2771
2755
|
${t}`);
|
|
2772
2756
|
return `${l}${t}${c}
|
|
2773
|
-
${
|
|
2757
|
+
${u}
|
|
2774
2758
|
`;
|
|
2775
2759
|
}
|
|
2776
2760
|
default: {
|
|
2777
|
-
const t = n ? `${styleText("cyan", S_BAR)} ` : "",
|
|
2778
|
-
`).length,
|
|
2779
|
-
`), c =
|
|
2780
|
-
output:
|
|
2761
|
+
const t = n ? `${styleText("cyan", S_BAR)} ` : "", u = l.split(`
|
|
2762
|
+
`).length, s = S ? formatInstructionFooter(r.output, MULTISELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], o = s.join(`
|
|
2763
|
+
`), c = s.length + 1, i = limitOptions({
|
|
2764
|
+
output: r.output,
|
|
2781
2765
|
options: this.options,
|
|
2782
2766
|
cursor: this.cursor,
|
|
2783
|
-
maxItems:
|
|
2767
|
+
maxItems: r.maxItems,
|
|
2784
2768
|
columnPadding: t.length,
|
|
2785
|
-
rowPadding:
|
|
2769
|
+
rowPadding: u + c,
|
|
2786
2770
|
style: a
|
|
2787
2771
|
}).join(`
|
|
2788
2772
|
${t}`);
|
|
2789
2773
|
return `${l}${t}${i}
|
|
2790
|
-
${
|
|
2774
|
+
${o}
|
|
2791
2775
|
`;
|
|
2792
2776
|
}
|
|
2793
2777
|
}
|
|
@@ -2912,7 +2896,7 @@ ${r}${d}
|
|
|
2912
2896
|
}
|
|
2913
2897
|
}).prompt();
|
|
2914
2898
|
|
|
2915
|
-
const W
|
|
2899
|
+
const W = (o) => o, C = (o, e, s) => {
|
|
2916
2900
|
const a = {
|
|
2917
2901
|
hard: true,
|
|
2918
2902
|
trim: false
|
|
@@ -2921,7 +2905,7 @@ const W$1 = (o) => o, C = (o, e, s) => {
|
|
|
2921
2905
|
return wrapAnsi(o, g, a);
|
|
2922
2906
|
};
|
|
2923
2907
|
const note = (o = "", e = "", s) => {
|
|
2924
|
-
const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W
|
|
2908
|
+
const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W, g = ["", ...C(o, getColumns(a) - 6, c).split(`
|
|
2925
2909
|
`).map(c), ""], n = fastStringWidth(e), t = Math.max(
|
|
2926
2910
|
g.reduce((m, F) => {
|
|
2927
2911
|
const O = fastStringWidth(F);
|
|
@@ -2944,7 +2928,7 @@ ${styleText("gray", l$1 + S_BAR_H.repeat(t + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
|
2944
2928
|
);
|
|
2945
2929
|
};
|
|
2946
2930
|
|
|
2947
|
-
const password = (e) => new u$
|
|
2931
|
+
const password = (e) => new u$2({
|
|
2948
2932
|
validate: e.validate,
|
|
2949
2933
|
mask: e.mask ?? S_PASSWORD_MASK,
|
|
2950
2934
|
signal: e.signal,
|
|
@@ -3002,17 +2986,18 @@ const path = (e) => {
|
|
|
3002
2986
|
return [];
|
|
3003
2987
|
try {
|
|
3004
2988
|
let i;
|
|
3005
|
-
|
|
3006
|
-
|
|
2989
|
+
const o = t.endsWith("/") || t.endsWith("\\");
|
|
2990
|
+
existsSync(t) ? lstatSync(t).isDirectory() && (!e.directory || o) ? i = t : i = dirname(t) : i = dirname(t);
|
|
2991
|
+
const m = t.length > 1 && o ? t.slice(0, -1) : t;
|
|
3007
2992
|
return readdirSync(i).map((r) => {
|
|
3008
|
-
const n = join(i, r),
|
|
2993
|
+
const n = join(i, r), l = lstatSync(n);
|
|
3009
2994
|
return {
|
|
3010
2995
|
name: r,
|
|
3011
2996
|
path: n,
|
|
3012
|
-
isDirectory:
|
|
2997
|
+
isDirectory: l.isDirectory()
|
|
3013
2998
|
};
|
|
3014
2999
|
}).filter(
|
|
3015
|
-
({ path: r, isDirectory: n }) => r.startsWith(
|
|
3000
|
+
({ path: r, isDirectory: n }) => r.startsWith(m) && (n || !e.directory)
|
|
3016
3001
|
).map((r) => ({
|
|
3017
3002
|
value: r.path
|
|
3018
3003
|
}));
|
|
@@ -3023,83 +3008,101 @@ const path = (e) => {
|
|
|
3023
3008
|
});
|
|
3024
3009
|
};
|
|
3025
3010
|
|
|
3026
|
-
const
|
|
3011
|
+
const Y = 3e4, Z = (c) => styleText("magenta", c);
|
|
3027
3012
|
const spinner = ({
|
|
3028
|
-
indicator:
|
|
3029
|
-
onCancel:
|
|
3013
|
+
indicator: c = "dots",
|
|
3014
|
+
onCancel: b,
|
|
3030
3015
|
output: n = process.stdout,
|
|
3031
|
-
cancelMessage:
|
|
3032
|
-
errorMessage:
|
|
3033
|
-
frames:
|
|
3034
|
-
delay:
|
|
3035
|
-
signal:
|
|
3036
|
-
...
|
|
3016
|
+
cancelMessage: _,
|
|
3017
|
+
errorMessage: C,
|
|
3018
|
+
frames: M = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
3019
|
+
delay: O = unicode ? 80 : 120,
|
|
3020
|
+
signal: g,
|
|
3021
|
+
...E
|
|
3037
3022
|
} = {}) => {
|
|
3038
|
-
const u = isCI();
|
|
3039
|
-
let
|
|
3040
|
-
const
|
|
3041
|
-
const
|
|
3042
|
-
|
|
3043
|
-
},
|
|
3044
|
-
process.on("uncaughtExceptionMonitor",
|
|
3045
|
-
},
|
|
3046
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
3047
|
-
},
|
|
3048
|
-
if (
|
|
3023
|
+
const u = isCI(), h = isAccessible(E.accessible);
|
|
3024
|
+
let x, I, p = false, l = false, r = "", v, w = performance.now();
|
|
3025
|
+
const y = getColumns(n), F = E?.styleFrame ?? Z, S = (e) => {
|
|
3026
|
+
const s = e > 1 ? C ?? settings.messages.error : _ ?? settings.messages.cancel;
|
|
3027
|
+
l = e === 1, p && (m(s, e), l && typeof b == "function" && b());
|
|
3028
|
+
}, $ = () => S(2), a = () => S(1), H = () => {
|
|
3029
|
+
process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a), process.on("SIGTERM", a), process.on("exit", S), g && g.addEventListener("abort", a);
|
|
3030
|
+
}, B = () => {
|
|
3031
|
+
process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a), process.removeListener("SIGTERM", a), process.removeListener("exit", S), g && g.removeEventListener("abort", a);
|
|
3032
|
+
}, R = () => {
|
|
3033
|
+
if (v === void 0) return;
|
|
3049
3034
|
u && n.write(`
|
|
3050
3035
|
`);
|
|
3051
|
-
const
|
|
3036
|
+
const s = wrapAnsi(v, y, {
|
|
3052
3037
|
hard: true,
|
|
3053
3038
|
trim: false
|
|
3054
3039
|
}).split(`
|
|
3055
3040
|
`);
|
|
3056
|
-
|
|
3057
|
-
},
|
|
3058
|
-
const
|
|
3059
|
-
return
|
|
3060
|
-
}, N =
|
|
3061
|
-
|
|
3041
|
+
s.length > 1 && n.write(cursor.up(s.length - 1)), n.write(cursor.to(0)), n.write(erase.down());
|
|
3042
|
+
}, L = (e) => e.replace(/\.+$/, ""), T = (e) => {
|
|
3043
|
+
const s = (performance.now() - e) / 1e3, i = Math.floor(s / 60), t = Math.floor(s % 60);
|
|
3044
|
+
return i > 0 ? `[${i}m ${t}s]` : `[${t}s]`;
|
|
3045
|
+
}, N = E.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
3046
|
+
if (p = true, l = false, r = L(e), w = performance.now(), H(), h) {
|
|
3047
|
+
r !== "" && n.write(`${r}
|
|
3048
|
+
`), I = setInterval(() => {
|
|
3049
|
+
n.write(r === "" ? `still working
|
|
3050
|
+
` : `still working: ${r}
|
|
3051
|
+
`);
|
|
3052
|
+
}, Y);
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3055
|
+
x = block({ output: n }), N && n.write(`${styleText("gray", S_BAR)}
|
|
3062
3056
|
`);
|
|
3063
|
-
let
|
|
3064
|
-
|
|
3065
|
-
if (u &&
|
|
3057
|
+
let s = 0, i = 0;
|
|
3058
|
+
I = setInterval(() => {
|
|
3059
|
+
if (u && r === v)
|
|
3066
3060
|
return;
|
|
3067
|
-
|
|
3068
|
-
const
|
|
3069
|
-
let
|
|
3061
|
+
R(), v = r;
|
|
3062
|
+
const t = F(M[s]);
|
|
3063
|
+
let o;
|
|
3070
3064
|
if (u)
|
|
3071
|
-
|
|
3072
|
-
else if (
|
|
3073
|
-
|
|
3065
|
+
o = `${t} ${r}...`;
|
|
3066
|
+
else if (c === "timer")
|
|
3067
|
+
o = `${t} ${r} ${T(w)}`;
|
|
3074
3068
|
else {
|
|
3075
|
-
const
|
|
3076
|
-
|
|
3069
|
+
const j = ".".repeat(Math.floor(i)).slice(0, 3);
|
|
3070
|
+
o = `${t} ${r}${j}`;
|
|
3077
3071
|
}
|
|
3078
|
-
const
|
|
3072
|
+
const D = wrapAnsi(o, y, {
|
|
3079
3073
|
hard: true,
|
|
3080
3074
|
trim: false
|
|
3081
3075
|
});
|
|
3082
|
-
n.write(
|
|
3083
|
-
},
|
|
3084
|
-
},
|
|
3085
|
-
if (
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
`)
|
|
3076
|
+
n.write(D), s = s + 1 < M.length ? s + 1 : 0, i = i < 4 ? i + 0.125 : 0;
|
|
3077
|
+
}, O);
|
|
3078
|
+
}, m = (e = "", s = 0, i = false) => {
|
|
3079
|
+
if (p) {
|
|
3080
|
+
if (p = false, l = s === 1, clearInterval(I), h || R(), r = e ?? r, !i)
|
|
3081
|
+
if (h) {
|
|
3082
|
+
const t = s === 1 ? _ ?? settings.messages.cancel : s === 2 ? C ?? settings.messages.error : "Done", o = r || t;
|
|
3083
|
+
c === "timer" ? n.write(`${o} ${T(w)}
|
|
3084
|
+
`) : n.write(`${o}
|
|
3085
|
+
`);
|
|
3086
|
+
} else {
|
|
3087
|
+
const t = s === 0 ? styleText("green", S_STEP_SUBMIT) : s === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
|
|
3088
|
+
c === "timer" ? n.write(`${t} ${r} ${T(w)}
|
|
3089
|
+
`) : n.write(`${t} ${r}
|
|
3090
|
+
`);
|
|
3091
|
+
}
|
|
3092
|
+
B(), x?.();
|
|
3093
|
+
}
|
|
3091
3094
|
};
|
|
3092
3095
|
return {
|
|
3093
3096
|
start: P,
|
|
3094
|
-
stop: (e = "") =>
|
|
3097
|
+
stop: (e = "") => m(e, 0),
|
|
3095
3098
|
message: (e = "") => {
|
|
3096
|
-
|
|
3099
|
+
r = L(e ?? r);
|
|
3097
3100
|
},
|
|
3098
|
-
cancel: (e = "") =>
|
|
3099
|
-
error: (e = "") =>
|
|
3100
|
-
clear: () =>
|
|
3101
|
+
cancel: (e = "") => m(e, 1),
|
|
3102
|
+
error: (e = "") => m(e, 2),
|
|
3103
|
+
clear: () => m("", 0, true),
|
|
3101
3104
|
get isCancelled() {
|
|
3102
|
-
return
|
|
3105
|
+
return l;
|
|
3103
3106
|
}
|
|
3104
3107
|
};
|
|
3105
3108
|
};
|
|
@@ -3145,7 +3148,9 @@ function progress({
|
|
|
3145
3148
|
error: r.error,
|
|
3146
3149
|
clear: r.clear,
|
|
3147
3150
|
advance: g,
|
|
3148
|
-
isCancelled
|
|
3151
|
+
get isCancelled() {
|
|
3152
|
+
return r.isCancelled;
|
|
3153
|
+
},
|
|
3149
3154
|
message: (t) => g(0, t)
|
|
3150
3155
|
};
|
|
3151
3156
|
}
|
|
@@ -3211,7 +3216,7 @@ ${styleText("gray", S_BAR)}` : ""}`;
|
|
|
3211
3216
|
}
|
|
3212
3217
|
default: {
|
|
3213
3218
|
const r = n ? `${styleText("cyan", S_BAR)} ` : "", a = u.split(`
|
|
3214
|
-
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], f = p.join(`
|
|
3219
|
+
`).length, p = d ? formatInstructionFooter(t.output, SELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], f = p.join(`
|
|
3215
3220
|
`), b = p.length + 1;
|
|
3216
3221
|
return `${u}${r}${limitOptions({
|
|
3217
3222
|
output: t.output,
|
|
@@ -3231,36 +3236,36 @@ ${f}
|
|
|
3231
3236
|
}).prompt();
|
|
3232
3237
|
};
|
|
3233
3238
|
|
|
3234
|
-
const selectKey = (
|
|
3239
|
+
const selectKey = (i) => {
|
|
3235
3240
|
const c = (e, a = "inactive") => {
|
|
3236
3241
|
if (e === void 0)
|
|
3237
3242
|
return "";
|
|
3238
3243
|
const n = e.label ?? String(e.value);
|
|
3239
|
-
return a === "selected" ? `${styleText("dim", n)}` : a === "cancelled" ? `${styleText(["strikethrough", "dim"], n)}` : a === "active" ? `${styleText(["bgCyan", "gray"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : `${styleText(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}`;
|
|
3244
|
+
return a === "disabled" ? `${styleText("dim", ` ${e.value} `)} ${styleText("gray", n)}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : a === "selected" ? `${styleText("dim", n)}` : a === "cancelled" ? `${styleText(["strikethrough", "dim"], n)}` : a === "active" ? `${styleText(["bgCyan", "gray"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : `${styleText(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}`;
|
|
3240
3245
|
};
|
|
3241
|
-
return new
|
|
3242
|
-
options:
|
|
3243
|
-
signal:
|
|
3244
|
-
input:
|
|
3245
|
-
output:
|
|
3246
|
-
initialValue:
|
|
3247
|
-
caseSensitive:
|
|
3246
|
+
return new c$2({
|
|
3247
|
+
options: i.options,
|
|
3248
|
+
signal: i.signal,
|
|
3249
|
+
input: i.input,
|
|
3250
|
+
output: i.output,
|
|
3251
|
+
initialValue: i.initialValue,
|
|
3252
|
+
caseSensitive: i.caseSensitive,
|
|
3248
3253
|
render() {
|
|
3249
|
-
const e =
|
|
3250
|
-
` : ""}${symbol(this.state)} ${
|
|
3254
|
+
const e = i.withGuide ?? settings.withGuide, a = `${e ? `${styleText("gray", S_BAR)}
|
|
3255
|
+
` : ""}${symbol(this.state)} ${i.message}
|
|
3251
3256
|
`;
|
|
3252
3257
|
switch (this.state) {
|
|
3253
3258
|
case "submit": {
|
|
3254
|
-
const n = e ? `${styleText("gray", S_BAR)} ` : "", r = this.options.find((
|
|
3255
|
-
|
|
3259
|
+
const n = e ? `${styleText("gray", S_BAR)} ` : "", r = this.options.find((l) => l.value === this.value) ?? i.options[0], u = wrapTextWithPrefix(
|
|
3260
|
+
i.output,
|
|
3256
3261
|
c(r, "selected"),
|
|
3257
3262
|
n
|
|
3258
3263
|
);
|
|
3259
|
-
return `${a}${
|
|
3264
|
+
return `${a}${u}`;
|
|
3260
3265
|
}
|
|
3261
3266
|
case "cancel": {
|
|
3262
3267
|
const n = e ? `${styleText("gray", S_BAR)} ` : "", r = wrapTextWithPrefix(
|
|
3263
|
-
|
|
3268
|
+
i.output,
|
|
3264
3269
|
c(this.options[0], "cancelled"),
|
|
3265
3270
|
n
|
|
3266
3271
|
);
|
|
@@ -3268,15 +3273,18 @@ const selectKey = (t) => {
|
|
|
3268
3273
|
${styleText("gray", S_BAR)}` : ""}`;
|
|
3269
3274
|
}
|
|
3270
3275
|
default: {
|
|
3271
|
-
const n = e ? `${styleText("cyan", S_BAR)} ` : "", r = e ? styleText("cyan", S_BAR_END) : "",
|
|
3272
|
-
(
|
|
3273
|
-
|
|
3274
|
-
c(
|
|
3276
|
+
const n = e ? `${styleText("cyan", S_BAR)} ` : "", r = e ? styleText("cyan", S_BAR_END) : "", u = this.options.map(
|
|
3277
|
+
(l, $) => wrapTextWithPrefix(
|
|
3278
|
+
i.output,
|
|
3279
|
+
c(
|
|
3280
|
+
l,
|
|
3281
|
+
l.disabled ? "disabled" : $ === this.cursor ? "active" : "inactive"
|
|
3282
|
+
),
|
|
3275
3283
|
n
|
|
3276
3284
|
)
|
|
3277
3285
|
).join(`
|
|
3278
3286
|
`);
|
|
3279
|
-
return `${a}${
|
|
3287
|
+
return `${a}${u}
|
|
3280
3288
|
${r}
|
|
3281
3289
|
`;
|
|
3282
3290
|
}
|
|
@@ -3354,7 +3362,7 @@ ${t.header}`);
|
|
|
3354
3362
|
`).reduce((b, w) => w === "" ? b + 1 : b + Math.ceil((w.length + k) / O), 0);
|
|
3355
3363
|
s += E;
|
|
3356
3364
|
}
|
|
3357
|
-
s > 0 && (s += 1, r.write(
|
|
3365
|
+
s > 0 && (s += 1, r.write(erase.lines(s)));
|
|
3358
3366
|
}, h = (e, s, t) => {
|
|
3359
3367
|
const o = t ? `${e.full}
|
|
3360
3368
|
${e.value}` : e.value;
|