create-ts-monorepo-starter 0.1.0 → 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/README.md +2 -2
- package/dist/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/cli.js +455 -345
- 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
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { isAbsolute, dirname, basename, resolve,
|
|
2
|
+
import { mkdtemp, writeFile, rm, access, cp, rename, readdir, rmdir, readFile, open, stat, mkdir, realpath, lstat } from 'node:fs/promises';
|
|
3
|
+
import { join, isAbsolute, dirname, basename, resolve, relative, sep } from 'node:path';
|
|
4
4
|
import { parseArgs, styleText, stripVTControlCharacters } from 'node:util';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
6
|
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
|
|
|
@@ -64,6 +64,7 @@ function parseArgv(argv) {
|
|
|
64
64
|
yes: values.yes ?? false,
|
|
65
65
|
help: values.help ?? false,
|
|
66
66
|
version: values.version ?? false,
|
|
67
|
+
check: values.check ?? false,
|
|
67
68
|
};
|
|
68
69
|
if (positionals[0] !== undefined)
|
|
69
70
|
options.folder = positionals[0];
|
|
@@ -92,6 +93,7 @@ function parse(argv) {
|
|
|
92
93
|
yes: { type: 'boolean', short: 'y' },
|
|
93
94
|
help: { type: 'boolean', short: 'h' },
|
|
94
95
|
version: { type: 'boolean', short: 'v' },
|
|
96
|
+
check: { type: 'boolean' },
|
|
95
97
|
},
|
|
96
98
|
});
|
|
97
99
|
}
|
|
@@ -286,6 +288,61 @@ async function detectPnpm(exec = defaultExec, cwd = tmpdir()) {
|
|
|
286
288
|
const [major, minor] = [Number(match[1]), Number(match[2])];
|
|
287
289
|
return { kind: major < 10 || (major === 10 && minor < 26) ? 'old' : 'ok', version };
|
|
288
290
|
}
|
|
291
|
+
/** A toolchain problem the user has to fix before anything is created; `lines` say how. */
|
|
292
|
+
class ToolchainError extends Error {
|
|
293
|
+
lines;
|
|
294
|
+
constructor(message, lines) {
|
|
295
|
+
super(message);
|
|
296
|
+
this.lines = lines;
|
|
297
|
+
this.name = 'ToolchainError';
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const PNPM_HELP = 'https://github.com/prosdevlab/create-ts-monorepo-starter#pnpm';
|
|
301
|
+
const fileExists = (path) => access(path).then(() => true, () => false);
|
|
302
|
+
/**
|
|
303
|
+
* Runs `pnpm --version` in an empty folder pinned to `spec` (`pnpm@12.15.0`), where pnpm switches
|
|
304
|
+
* itself to that version as the install will. Throws a ToolchainError when the switch fails.
|
|
305
|
+
*/
|
|
306
|
+
async function checkSwitch(spec, found, exec = defaultExec, root = tmpdir(), exists = fileExists) {
|
|
307
|
+
const dir = await mkdtemp(join(root, 'ctms-pnpm-'));
|
|
308
|
+
try {
|
|
309
|
+
await writeFile(join(dir, 'package.json'), `${JSON.stringify({ packageManager: spec })}\n`);
|
|
310
|
+
const result = await exec('pnpm', ['--version'], { cwd: dir }).catch(() => null);
|
|
311
|
+
if (result?.code === 0)
|
|
312
|
+
return;
|
|
313
|
+
const output = result ? `${result.stdout}\n${result.stderr}` : '';
|
|
314
|
+
const installer = switchInstaller(output);
|
|
315
|
+
const runnable = installer !== undefined && (await exists(installer));
|
|
316
|
+
throw switchFailure(spec, found, output, runnable ? installer : undefined);
|
|
317
|
+
}
|
|
318
|
+
finally {
|
|
319
|
+
await rm(dir, { recursive: true, force: true });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* The install script of the pnpm a failed switch downloaded, read from pnpm's error: it says the CLI
|
|
324
|
+
* "is missing at <tools>/bin" when the script that puts the binary there never ran.
|
|
325
|
+
*/
|
|
326
|
+
function switchInstaller(output) {
|
|
327
|
+
const tools = /missing at "([^"]+?)[\\/]bin"/.exec(output)?.[1];
|
|
328
|
+
return tools === undefined ? undefined : join(tools, 'node_modules', 'pnpm', 'install.js');
|
|
329
|
+
}
|
|
330
|
+
/** The stop for a failed switch: pnpm's words, the fix (`installer`, or the README), and a retry. */
|
|
331
|
+
function switchFailure(spec, found, output, installer) {
|
|
332
|
+
const version = spec.slice('pnpm@'.length);
|
|
333
|
+
const said = output
|
|
334
|
+
.split(/\r?\n/)
|
|
335
|
+
.map((line) => line.trim())
|
|
336
|
+
.filter(Boolean)
|
|
337
|
+
.slice(0, 2);
|
|
338
|
+
return new ToolchainError(`pnpm ${found} couldn't switch to pnpm ${version}, which this project needs`, [
|
|
339
|
+
...said.map((line) => `pnpm: ${line}`),
|
|
340
|
+
installer
|
|
341
|
+
? `Fix: node ${installer}`
|
|
342
|
+
: `Fix your pnpm so it can switch to ${version}: ${PNPM_HELP}`,
|
|
343
|
+
'Then run this command again. Nothing was created.',
|
|
344
|
+
]);
|
|
345
|
+
}
|
|
289
346
|
/** The install command for `dir`, or null when pnpm is too old to use. */
|
|
290
347
|
function installCommand(status, dir, lockfileOnly) {
|
|
291
348
|
if (!isAbsolute(dir))
|
|
@@ -739,8 +796,8 @@ const fastStringWidth = (input, options = {}) => {
|
|
|
739
796
|
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
740
797
|
};
|
|
741
798
|
|
|
742
|
-
const ESC = '\x1B';
|
|
743
|
-
const CSI = '\x9B';
|
|
799
|
+
const ESC$1 = '\x1B';
|
|
800
|
+
const CSI$1 = '\x9B';
|
|
744
801
|
const END_CODE = 39;
|
|
745
802
|
const ANSI_ESCAPE_BELL = '\u0007';
|
|
746
803
|
const ANSI_CSI = '[';
|
|
@@ -773,8 +830,8 @@ const getClosingCode = (openingCode) => {
|
|
|
773
830
|
return 0;
|
|
774
831
|
return undefined;
|
|
775
832
|
};
|
|
776
|
-
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
777
|
-
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}`;
|
|
778
835
|
const wrapWord = (rows, word, columns) => {
|
|
779
836
|
const characters = word[Symbol.iterator]();
|
|
780
837
|
let isInsideEscape = false;
|
|
@@ -794,7 +851,7 @@ const wrapWord = (rows, word, columns) => {
|
|
|
794
851
|
rows.push(character);
|
|
795
852
|
visible = 0;
|
|
796
853
|
}
|
|
797
|
-
if (character === ESC || character === CSI) {
|
|
854
|
+
if (character === ESC$1 || character === CSI$1) {
|
|
798
855
|
isInsideEscape = true;
|
|
799
856
|
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
800
857
|
}
|
|
@@ -916,7 +973,7 @@ const exec = (string, columns, options = {}) => {
|
|
|
916
973
|
else {
|
|
917
974
|
inSurrogate = false;
|
|
918
975
|
}
|
|
919
|
-
if (character === ESC || character === CSI) {
|
|
976
|
+
if (character === ESC$1 || character === CSI$1) {
|
|
920
977
|
GROUP_REGEX.lastIndex = i + 1;
|
|
921
978
|
const groupsResult = GROUP_REGEX.exec(preString);
|
|
922
979
|
const groups = groupsResult?.groups;
|
|
@@ -957,90 +1014,71 @@ function wrapAnsi(string, columns, options) {
|
|
|
957
1014
|
.join('\n');
|
|
958
1015
|
}
|
|
959
1016
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
1009
|
-
line: `${CSI}2K`,
|
|
1010
|
-
lineEnd: `${CSI}K`,
|
|
1011
|
-
lineStart: `${CSI}1K`,
|
|
1012
|
-
lines(count) {
|
|
1013
|
-
let clear = '';
|
|
1014
|
-
for (let i = 0; i < count; i++)
|
|
1015
|
-
clear += this.line + (i < count - 1 ? cursor.up() : '');
|
|
1016
|
-
if (count)
|
|
1017
|
-
clear += cursor.left;
|
|
1018
|
-
return clear;
|
|
1019
|
-
}
|
|
1020
|
-
};
|
|
1021
|
-
|
|
1022
|
-
src = { cursor, scroll, erase, beep };
|
|
1023
|
-
return src;
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
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
|
+
};
|
|
1027
1065
|
|
|
1028
|
-
function findCursor(
|
|
1066
|
+
function findCursor(o, s, l) {
|
|
1029
1067
|
if (!l.some((r) => !r.disabled))
|
|
1030
|
-
return
|
|
1031
|
-
const t =
|
|
1032
|
-
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;
|
|
1033
1071
|
}
|
|
1034
|
-
function findTextCursor(
|
|
1072
|
+
function findTextCursor(o, s, l, i) {
|
|
1035
1073
|
const t = i.split(`
|
|
1036
1074
|
`);
|
|
1037
|
-
let n = 0, e =
|
|
1075
|
+
let n = 0, e = o;
|
|
1038
1076
|
for (const r of t) {
|
|
1039
1077
|
if (e <= r.length)
|
|
1040
1078
|
break;
|
|
1041
1079
|
e -= r.length + 1, n++;
|
|
1042
1080
|
}
|
|
1043
|
-
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; )
|
|
1044
1082
|
n--, e += t[n].length + 1;
|
|
1045
1083
|
for (; e > t[n].length && n < t.length - 1; )
|
|
1046
1084
|
e -= t[n].length + 1, n++;
|
|
@@ -1157,41 +1195,41 @@ function block({
|
|
|
1157
1195
|
overwrite: o = true,
|
|
1158
1196
|
hideCursor: n = true
|
|
1159
1197
|
} = {}) {
|
|
1160
|
-
const s =
|
|
1198
|
+
const s = f$1.createInterface({
|
|
1161
1199
|
input: e,
|
|
1162
1200
|
output: r,
|
|
1163
1201
|
prompt: "",
|
|
1164
1202
|
tabSize: 1
|
|
1165
1203
|
});
|
|
1166
|
-
|
|
1167
|
-
const t = (
|
|
1168
|
-
const
|
|
1169
|
-
if (isActionKey([
|
|
1170
|
-
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);
|
|
1171
1209
|
return;
|
|
1172
1210
|
}
|
|
1173
1211
|
if (!o) return;
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
|
|
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, () => {
|
|
1177
1215
|
e.once("keypress", t);
|
|
1178
1216
|
});
|
|
1179
1217
|
});
|
|
1180
1218
|
};
|
|
1181
|
-
return n && r.write(
|
|
1182
|
-
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();
|
|
1183
1221
|
};
|
|
1184
1222
|
}
|
|
1185
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;
|
|
1186
1224
|
function wrapTextWithPrefix(e, r, o, n = o, s = o, t) {
|
|
1187
|
-
const
|
|
1188
|
-
return wrapAnsi(r,
|
|
1225
|
+
const l = getColumns(e ?? stdout), i = fastStringWidth(o);
|
|
1226
|
+
return wrapAnsi(r, l - i, {
|
|
1189
1227
|
hard: true,
|
|
1190
1228
|
trim: false
|
|
1191
1229
|
}).split(`
|
|
1192
|
-
`).map((c,
|
|
1193
|
-
const
|
|
1194
|
-
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}`;
|
|
1195
1233
|
}).join(`
|
|
1196
1234
|
`);
|
|
1197
1235
|
}
|
|
@@ -1204,7 +1242,7 @@ function runValidation(e, a) {
|
|
|
1204
1242
|
return e(a);
|
|
1205
1243
|
}
|
|
1206
1244
|
|
|
1207
|
-
class
|
|
1245
|
+
let C$1 = class C {
|
|
1208
1246
|
input;
|
|
1209
1247
|
output;
|
|
1210
1248
|
_abortSignal;
|
|
@@ -1286,16 +1324,16 @@ class y {
|
|
|
1286
1324
|
{ once: true }
|
|
1287
1325
|
);
|
|
1288
1326
|
}
|
|
1289
|
-
this.rl =
|
|
1327
|
+
this.rl = f$1__default.createInterface({
|
|
1290
1328
|
input: this.input,
|
|
1291
1329
|
tabSize: 2,
|
|
1292
1330
|
prompt: "",
|
|
1293
1331
|
escapeCodeTimeout: 50,
|
|
1294
1332
|
terminal: true
|
|
1295
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", () => {
|
|
1296
|
-
this.output.write(
|
|
1334
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
1297
1335
|
}), this.once("cancel", () => {
|
|
1298
|
-
this.output.write(
|
|
1336
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
1299
1337
|
});
|
|
1300
1338
|
});
|
|
1301
1339
|
}
|
|
@@ -1332,18 +1370,18 @@ class y {
|
|
|
1332
1370
|
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
1333
1371
|
}
|
|
1334
1372
|
restoreCursor() {
|
|
1335
|
-
const t = wrapAnsi(this._prevFrame,
|
|
1373
|
+
const t = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
|
|
1336
1374
|
`).length - 1;
|
|
1337
|
-
this.output.write(
|
|
1375
|
+
this.output.write(cursor.move(-999, t * -1));
|
|
1338
1376
|
}
|
|
1339
1377
|
render() {
|
|
1340
|
-
const t = wrapAnsi(this._render(this) ?? "",
|
|
1378
|
+
const t = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
|
|
1341
1379
|
hard: true,
|
|
1342
1380
|
trim: false
|
|
1343
1381
|
});
|
|
1344
1382
|
if (t !== this._prevFrame) {
|
|
1345
1383
|
if (this.state === "initial")
|
|
1346
|
-
this.output.write(
|
|
1384
|
+
this.output.write(cursor.hide);
|
|
1347
1385
|
else {
|
|
1348
1386
|
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
1349
1387
|
if (this.restoreCursor(), e) {
|
|
@@ -1354,32 +1392,32 @@ class y {
|
|
|
1354
1392
|
return;
|
|
1355
1393
|
}
|
|
1356
1394
|
if (e.lines.length === 1) {
|
|
1357
|
-
this.output.write(
|
|
1395
|
+
this.output.write(cursor.move(0, n - r)), this.output.write(erase.lines(1));
|
|
1358
1396
|
const o = t.split(`
|
|
1359
1397
|
`);
|
|
1360
|
-
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));
|
|
1361
1399
|
return;
|
|
1362
1400
|
} else if (e.lines.length > 1) {
|
|
1363
1401
|
if (s < r)
|
|
1364
1402
|
n = s;
|
|
1365
1403
|
else {
|
|
1366
1404
|
const h = n - r;
|
|
1367
|
-
h > 0 && this.output.write(
|
|
1405
|
+
h > 0 && this.output.write(cursor.move(0, h));
|
|
1368
1406
|
}
|
|
1369
|
-
this.output.write(
|
|
1370
|
-
const
|
|
1407
|
+
this.output.write(erase.down());
|
|
1408
|
+
const m = t.split(`
|
|
1371
1409
|
`).slice(n);
|
|
1372
|
-
this.output.write(
|
|
1410
|
+
this.output.write(m.join(`
|
|
1373
1411
|
`)), this._prevFrame = t;
|
|
1374
1412
|
return;
|
|
1375
1413
|
}
|
|
1376
1414
|
}
|
|
1377
|
-
this.output.write(
|
|
1415
|
+
this.output.write(erase.down());
|
|
1378
1416
|
}
|
|
1379
1417
|
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
1380
1418
|
}
|
|
1381
1419
|
}
|
|
1382
|
-
}
|
|
1420
|
+
};
|
|
1383
1421
|
|
|
1384
1422
|
function p$1$1(l, e) {
|
|
1385
1423
|
if (l === void 0 || e.length === 0)
|
|
@@ -1394,7 +1432,7 @@ function g(l, e) {
|
|
|
1394
1432
|
if (e)
|
|
1395
1433
|
return l ? e : e[0];
|
|
1396
1434
|
}
|
|
1397
|
-
let T$1 = class T extends
|
|
1435
|
+
let T$1 = class T extends C$1 {
|
|
1398
1436
|
filteredOptions;
|
|
1399
1437
|
multiple;
|
|
1400
1438
|
isNavigating = false;
|
|
@@ -1469,7 +1507,7 @@ let T$1 = class T extends y {
|
|
|
1469
1507
|
}
|
|
1470
1508
|
};
|
|
1471
1509
|
|
|
1472
|
-
class r extends
|
|
1510
|
+
class r extends C$1 {
|
|
1473
1511
|
get cursor() {
|
|
1474
1512
|
return this.value ? 0 : 1;
|
|
1475
1513
|
}
|
|
@@ -1480,7 +1518,7 @@ class r extends y {
|
|
|
1480
1518
|
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
1481
1519
|
this.value = this._value;
|
|
1482
1520
|
}), this.on("confirm", (i) => {
|
|
1483
|
-
this.output.write(
|
|
1521
|
+
this.output.write(cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
1484
1522
|
}), this.on("cursor", () => {
|
|
1485
1523
|
this.value = !this.value;
|
|
1486
1524
|
});
|
|
@@ -1526,7 +1564,7 @@ function b$1(r) {
|
|
|
1526
1564
|
if (!(n.getUTCFullYear() !== t || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
1527
1565
|
return { year: t, month: i, day: s };
|
|
1528
1566
|
}
|
|
1529
|
-
function C$
|
|
1567
|
+
function C$2(r) {
|
|
1530
1568
|
const t = b$1(r);
|
|
1531
1569
|
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
|
|
1532
1570
|
}
|
|
@@ -1548,7 +1586,7 @@ function T(r, t, i, s) {
|
|
|
1548
1586
|
max: e && t.year === e.year && t.month === e.month ? e.day : c$1(t.year, t.month)
|
|
1549
1587
|
};
|
|
1550
1588
|
}
|
|
1551
|
-
let U$1 = class U extends
|
|
1589
|
+
let U$1 = class U extends C$1 {
|
|
1552
1590
|
#i;
|
|
1553
1591
|
#o;
|
|
1554
1592
|
#t;
|
|
@@ -1577,7 +1615,7 @@ let U$1 = class U extends y {
|
|
|
1577
1615
|
return this.#i.map((i) => t[i.type]).join(this.#o);
|
|
1578
1616
|
}
|
|
1579
1617
|
#r() {
|
|
1580
|
-
this._setUserInput(this.#l(this.#t)), this._setValue(C$
|
|
1618
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C$2(this.#t) ?? void 0);
|
|
1581
1619
|
}
|
|
1582
1620
|
constructor(t) {
|
|
1583
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 ? {
|
|
@@ -1710,57 +1748,59 @@ let U$1 = class U extends y {
|
|
|
1710
1748
|
day: String(Math.min(n, e)).padStart(2, "0")
|
|
1711
1749
|
};
|
|
1712
1750
|
}
|
|
1713
|
-
this.value = C$
|
|
1751
|
+
this.value = C$2(this.#t) ?? t.defaultValue ?? void 0;
|
|
1714
1752
|
}
|
|
1715
1753
|
};
|
|
1716
1754
|
|
|
1717
|
-
let u$
|
|
1755
|
+
let u$1 = class u extends C$1 {
|
|
1718
1756
|
options;
|
|
1719
1757
|
cursor = 0;
|
|
1720
|
-
#
|
|
1758
|
+
#e;
|
|
1721
1759
|
getGroupItems(t) {
|
|
1722
|
-
return this.options.filter((
|
|
1760
|
+
return this.options.filter((i) => i.group === t);
|
|
1723
1761
|
}
|
|
1724
1762
|
isGroupSelected(t) {
|
|
1725
|
-
const
|
|
1726
|
-
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));
|
|
1727
1765
|
}
|
|
1728
1766
|
toggleValue() {
|
|
1729
1767
|
const t = this.options[this.cursor];
|
|
1730
1768
|
if (t !== void 0)
|
|
1731
1769
|
if (this.value === void 0 && (this.value = []), t.group === true) {
|
|
1732
|
-
const
|
|
1733
|
-
this.isGroupSelected(
|
|
1734
|
-
(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
|
|
1735
1773
|
) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
1736
1774
|
} else {
|
|
1737
|
-
const
|
|
1738
|
-
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];
|
|
1739
1777
|
}
|
|
1740
1778
|
}
|
|
1741
1779
|
constructor(t) {
|
|
1742
1780
|
super(t, false);
|
|
1743
|
-
const { options:
|
|
1744
|
-
this.#
|
|
1781
|
+
const { options: i } = t;
|
|
1782
|
+
this.#e = t.selectableGroups !== false, this.options = Object.entries(i).flatMap(([e, s]) => [
|
|
1745
1783
|
{ value: e, group: true, label: e },
|
|
1746
|
-
...s.map((
|
|
1784
|
+
...s.map((r) => ({ ...r, group: e }))
|
|
1747
1785
|
]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(
|
|
1748
1786
|
this.options.findIndex(({ value: e }) => e === t.cursorAt),
|
|
1749
|
-
this.#
|
|
1750
|
-
), 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) => {
|
|
1751
1791
|
switch (e) {
|
|
1752
1792
|
case "left":
|
|
1753
1793
|
case "up": {
|
|
1754
1794
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1755
1795
|
const s = this.options[this.cursor]?.group === true;
|
|
1756
|
-
!this.#
|
|
1796
|
+
!this.#e && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1757
1797
|
break;
|
|
1758
1798
|
}
|
|
1759
1799
|
case "down":
|
|
1760
1800
|
case "right": {
|
|
1761
1801
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1762
1802
|
const s = this.options[this.cursor]?.group === true;
|
|
1763
|
-
!this.#
|
|
1803
|
+
!this.#e && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1764
1804
|
break;
|
|
1765
1805
|
}
|
|
1766
1806
|
case "space":
|
|
@@ -1772,7 +1812,7 @@ let u$2 = class u extends y {
|
|
|
1772
1812
|
};
|
|
1773
1813
|
|
|
1774
1814
|
const o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
1775
|
-
class h extends
|
|
1815
|
+
class h extends C$1 {
|
|
1776
1816
|
#t = false;
|
|
1777
1817
|
#s;
|
|
1778
1818
|
focused = "editor";
|
|
@@ -1867,7 +1907,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
|
|
|
1867
1907
|
}
|
|
1868
1908
|
}
|
|
1869
1909
|
|
|
1870
|
-
class a extends
|
|
1910
|
+
class a extends C$1 {
|
|
1871
1911
|
options;
|
|
1872
1912
|
cursor = 0;
|
|
1873
1913
|
get _value() {
|
|
@@ -1898,8 +1938,8 @@ class a extends y {
|
|
|
1898
1938
|
this.options.findIndex(({ value: t }) => t === e.cursorAt),
|
|
1899
1939
|
0
|
|
1900
1940
|
);
|
|
1901
|
-
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t,
|
|
1902
|
-
|
|
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();
|
|
1903
1943
|
}), this.on("cursor", (t) => {
|
|
1904
1944
|
switch (t) {
|
|
1905
1945
|
case "left":
|
|
@@ -1918,7 +1958,7 @@ class a extends y {
|
|
|
1918
1958
|
}
|
|
1919
1959
|
}
|
|
1920
1960
|
|
|
1921
|
-
let u$
|
|
1961
|
+
let u$2 = class u extends C$1 {
|
|
1922
1962
|
_mask = "\u2022";
|
|
1923
1963
|
get cursor() {
|
|
1924
1964
|
return this._cursor;
|
|
@@ -1947,7 +1987,7 @@ let u$1 = class u extends y {
|
|
|
1947
1987
|
}
|
|
1948
1988
|
};
|
|
1949
1989
|
|
|
1950
|
-
let n$1 = class n extends
|
|
1990
|
+
let n$1 = class n extends C$1 {
|
|
1951
1991
|
options;
|
|
1952
1992
|
cursor = 0;
|
|
1953
1993
|
get _selectedValue() {
|
|
@@ -1976,25 +2016,25 @@ let n$1 = class n extends y {
|
|
|
1976
2016
|
}
|
|
1977
2017
|
};
|
|
1978
2018
|
|
|
1979
|
-
let
|
|
2019
|
+
let c$2 = class c extends C$1 {
|
|
1980
2020
|
options;
|
|
1981
2021
|
cursor = 0;
|
|
1982
2022
|
constructor(t) {
|
|
1983
2023
|
super(t, false), this.options = t.options;
|
|
1984
|
-
const s = t.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
|
|
1985
|
-
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) => {
|
|
1986
2026
|
if (!e)
|
|
1987
2027
|
return;
|
|
1988
2028
|
const o = s ? e : e.toLowerCase();
|
|
1989
2029
|
if (!i.includes(o))
|
|
1990
2030
|
return;
|
|
1991
|
-
const
|
|
1992
|
-
|
|
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"));
|
|
1993
2033
|
});
|
|
1994
2034
|
}
|
|
1995
2035
|
};
|
|
1996
2036
|
|
|
1997
|
-
class n extends
|
|
2037
|
+
class n extends C$1 {
|
|
1998
2038
|
get userInputWithCursor() {
|
|
1999
2039
|
if (this.state === "submit")
|
|
2000
2040
|
return this.userInput;
|
|
@@ -2035,8 +2075,8 @@ function isUnicodeSupported() {
|
|
|
2035
2075
|
|| process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
2036
2076
|
}
|
|
2037
2077
|
|
|
2038
|
-
const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", isTTY = (
|
|
2039
|
-
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) {
|
|
2040
2080
|
case "initial":
|
|
2041
2081
|
case "active":
|
|
2042
2082
|
return styleText("cyan", S_STEP_ACTIVE);
|
|
@@ -2049,8 +2089,8 @@ const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", is
|
|
|
2049
2089
|
case "validating":
|
|
2050
2090
|
return styleText("dim", S_STEP_ACTIVE);
|
|
2051
2091
|
}
|
|
2052
|
-
}, symbolBar = (
|
|
2053
|
-
switch (
|
|
2092
|
+
}, symbolBar = (e) => {
|
|
2093
|
+
switch (e) {
|
|
2054
2094
|
case "initial":
|
|
2055
2095
|
case "active":
|
|
2056
2096
|
return styleText("cyan", S_BAR);
|
|
@@ -2062,12 +2102,13 @@ const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", is
|
|
|
2062
2102
|
return styleText("green", S_BAR);
|
|
2063
2103
|
}
|
|
2064
2104
|
};
|
|
2065
|
-
function formatInstructionFooter(o,
|
|
2066
|
-
const
|
|
2067
|
-
|
|
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;
|
|
2068
2109
|
}
|
|
2069
2110
|
|
|
2070
|
-
const
|
|
2111
|
+
const E$1 = (l, e, w, p, b, C = false) => {
|
|
2071
2112
|
let r = e, O = 0;
|
|
2072
2113
|
if (C)
|
|
2073
2114
|
for (let i = p - 1; i >= w; i--) {
|
|
@@ -2097,15 +2138,15 @@ const limitOptions = ({
|
|
|
2097
2138
|
0
|
|
2098
2139
|
));
|
|
2099
2140
|
let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
|
|
2100
|
-
const
|
|
2141
|
+
const I = Math.min(
|
|
2101
2142
|
f + a,
|
|
2102
2143
|
e.length
|
|
2103
2144
|
), s = [];
|
|
2104
2145
|
let g = 0;
|
|
2105
2146
|
d && g++, c && g++;
|
|
2106
|
-
const T = f + (d ? 1 : 0),
|
|
2107
|
-
for (let t = T; t <
|
|
2108
|
-
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, {
|
|
2109
2150
|
hard: true,
|
|
2110
2151
|
trim: false
|
|
2111
2152
|
}).split(`
|
|
@@ -2116,7 +2157,7 @@ const limitOptions = ({
|
|
|
2116
2157
|
let t = 0, n = 0, o = g;
|
|
2117
2158
|
const h = l - T;
|
|
2118
2159
|
let u = v;
|
|
2119
|
-
const L = () =>
|
|
2160
|
+
const L = () => E$1(s, o, 0, h, u), y = () => E$1(
|
|
2120
2161
|
s,
|
|
2121
2162
|
o,
|
|
2122
2163
|
h + 1,
|
|
@@ -2124,7 +2165,7 @@ const limitOptions = ({
|
|
|
2124
2165
|
u,
|
|
2125
2166
|
true
|
|
2126
2167
|
);
|
|
2127
|
-
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));
|
|
2128
2169
|
}
|
|
2129
2170
|
const x = [];
|
|
2130
2171
|
d && x.push(M);
|
|
@@ -2151,7 +2192,7 @@ function j(t, c) {
|
|
|
2151
2192
|
}
|
|
2152
2193
|
const autocomplete = (t) => new T$1({
|
|
2153
2194
|
options: t.options,
|
|
2154
|
-
initialValue: t.initialValue ? [t.initialValue] : void 0,
|
|
2195
|
+
initialValue: t.initialValue !== void 0 ? [t.initialValue] : void 0,
|
|
2155
2196
|
initialUserInput: t.initialUserInput,
|
|
2156
2197
|
placeholder: t.placeholder,
|
|
2157
2198
|
completeOnTab: t.completeOnTab,
|
|
@@ -2481,22 +2522,22 @@ const MULTISELECT_INSTRUCTIONS = [
|
|
|
2481
2522
|
`${styleText("dim", "Space:")} select`,
|
|
2482
2523
|
`${styleText("dim", "Enter:")} confirm`
|
|
2483
2524
|
];
|
|
2484
|
-
const m = (
|
|
2525
|
+
const m = (n, u) => n.split(`
|
|
2485
2526
|
`).map((d) => u(d)).join(`
|
|
2486
2527
|
`);
|
|
2487
|
-
const multiselect = (
|
|
2528
|
+
const multiselect = (n) => {
|
|
2488
2529
|
const u = (t, a) => {
|
|
2489
2530
|
const r = t.label ?? String(t.value);
|
|
2490
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))}`;
|
|
2491
|
-
}, d =
|
|
2532
|
+
}, d = n.required ?? true, x = n.showInstructions ?? true;
|
|
2492
2533
|
return new a({
|
|
2493
|
-
options:
|
|
2494
|
-
signal:
|
|
2495
|
-
input:
|
|
2496
|
-
output:
|
|
2497
|
-
initialValues:
|
|
2534
|
+
options: n.options,
|
|
2535
|
+
signal: n.signal,
|
|
2536
|
+
input: n.input,
|
|
2537
|
+
output: n.output,
|
|
2538
|
+
initialValues: n.initialValues,
|
|
2498
2539
|
required: d,
|
|
2499
|
-
cursorAt:
|
|
2540
|
+
cursorAt: n.cursorAt,
|
|
2500
2541
|
validate(t) {
|
|
2501
2542
|
if (d && (t === void 0 || t.length === 0))
|
|
2502
2543
|
return `Please select at least one option.
|
|
@@ -2512,75 +2553,75 @@ ${styleText(
|
|
|
2512
2553
|
)}`;
|
|
2513
2554
|
},
|
|
2514
2555
|
render() {
|
|
2515
|
-
const t =
|
|
2516
|
-
|
|
2517
|
-
|
|
2556
|
+
const t = n.withGuide ?? settings.withGuide, a = wrapTextWithPrefix(
|
|
2557
|
+
n.output,
|
|
2558
|
+
n.message,
|
|
2518
2559
|
t ? `${symbolBar(this.state)} ` : "",
|
|
2519
2560
|
`${symbol(this.state)} `
|
|
2520
2561
|
), r = `${t ? `${styleText("gray", S_BAR)}
|
|
2521
2562
|
` : ""}${a}
|
|
2522
|
-
`, o = this.value ?? [], g = (
|
|
2523
|
-
if (
|
|
2524
|
-
return u(
|
|
2525
|
-
const s = o.includes(
|
|
2526
|
-
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");
|
|
2527
2568
|
};
|
|
2528
2569
|
switch (this.state) {
|
|
2529
2570
|
case "submit": {
|
|
2530
|
-
const
|
|
2531
|
-
|
|
2532
|
-
|
|
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,
|
|
2533
2574
|
t ? `${styleText("gray", S_BAR)} ` : ""
|
|
2534
2575
|
);
|
|
2535
2576
|
return `${r}${l}`;
|
|
2536
2577
|
}
|
|
2537
2578
|
case "cancel": {
|
|
2538
|
-
const
|
|
2539
|
-
if (
|
|
2579
|
+
const i = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "cancelled")).join(styleText("dim", ", "));
|
|
2580
|
+
if (i.trim() === "")
|
|
2540
2581
|
return `${r}${styleText("gray", S_BAR)}`;
|
|
2541
2582
|
const l = wrapTextWithPrefix(
|
|
2542
|
-
|
|
2543
|
-
|
|
2583
|
+
n.output,
|
|
2584
|
+
i,
|
|
2544
2585
|
t ? `${styleText("gray", S_BAR)} ` : ""
|
|
2545
2586
|
);
|
|
2546
2587
|
return `${r}${l}${t ? `
|
|
2547
2588
|
${styleText("gray", S_BAR)}` : ""}`;
|
|
2548
2589
|
}
|
|
2549
2590
|
case "error": {
|
|
2550
|
-
const
|
|
2591
|
+
const i = t ? `${styleText("yellow", S_BAR)} ` : "", l = this.error.split(`
|
|
2551
2592
|
`).map(
|
|
2552
2593
|
($, v) => v === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", $)}` : ` ${$}`
|
|
2553
2594
|
).join(`
|
|
2554
2595
|
`), s = r.split(`
|
|
2555
2596
|
`).length, h = l.split(`
|
|
2556
2597
|
`).length + 1;
|
|
2557
|
-
return `${r}${
|
|
2558
|
-
output:
|
|
2598
|
+
return `${r}${i}${limitOptions({
|
|
2599
|
+
output: n.output,
|
|
2559
2600
|
options: this.options,
|
|
2560
2601
|
cursor: this.cursor,
|
|
2561
|
-
maxItems:
|
|
2562
|
-
columnPadding:
|
|
2602
|
+
maxItems: n.maxItems,
|
|
2603
|
+
columnPadding: i.length,
|
|
2563
2604
|
rowPadding: s + h,
|
|
2564
2605
|
style: g
|
|
2565
2606
|
}).join(`
|
|
2566
|
-
${
|
|
2607
|
+
${i}`)}
|
|
2567
2608
|
${l}
|
|
2568
2609
|
`;
|
|
2569
2610
|
}
|
|
2570
2611
|
default: {
|
|
2571
|
-
const
|
|
2572
|
-
`).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(`
|
|
2573
2614
|
`), $ = s.length + 1;
|
|
2574
|
-
return `${r}${
|
|
2575
|
-
output:
|
|
2615
|
+
return `${r}${i}${limitOptions({
|
|
2616
|
+
output: n.output,
|
|
2576
2617
|
options: this.options,
|
|
2577
2618
|
cursor: this.cursor,
|
|
2578
|
-
maxItems:
|
|
2579
|
-
columnPadding:
|
|
2619
|
+
maxItems: n.maxItems,
|
|
2620
|
+
columnPadding: i.length,
|
|
2580
2621
|
rowPadding: l + $,
|
|
2581
2622
|
style: g
|
|
2582
2623
|
}).join(`
|
|
2583
|
-
${
|
|
2624
|
+
${i}`)}
|
|
2584
2625
|
${h}
|
|
2585
2626
|
`;
|
|
2586
2627
|
}
|
|
@@ -2589,46 +2630,46 @@ ${h}
|
|
|
2589
2630
|
}).prompt();
|
|
2590
2631
|
};
|
|
2591
2632
|
|
|
2592
|
-
const groupMultiselect = (
|
|
2593
|
-
const { selectableGroups: f = true, groupSpacing: x = 0 } =
|
|
2594
|
-
const a = n.label ?? String(n.value), t = typeof n.group == "string",
|
|
2595
|
-
let
|
|
2596
|
-
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 = " ");
|
|
2597
2638
|
let i = "";
|
|
2598
2639
|
if (x > 0 && !t && (i = `
|
|
2599
2640
|
`.repeat(x)), l === "active")
|
|
2600
2641
|
return wrapTextWithPrefix(
|
|
2601
|
-
|
|
2642
|
+
r.output,
|
|
2602
2643
|
`${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
|
|
2603
|
-
`${i}${styleText("dim",
|
|
2604
|
-
`${i}${styleText("dim",
|
|
2644
|
+
`${i}${styleText("dim", o)} `,
|
|
2645
|
+
`${i}${styleText("dim", o)}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
2605
2646
|
`${i}${styleText("dim", c)} `
|
|
2606
2647
|
);
|
|
2607
2648
|
if (l === "group-active")
|
|
2608
2649
|
return wrapTextWithPrefix(
|
|
2609
|
-
|
|
2650
|
+
r.output,
|
|
2610
2651
|
a,
|
|
2611
|
-
`${i}${
|
|
2612
|
-
`${i}${
|
|
2652
|
+
`${i}${o} `,
|
|
2653
|
+
`${i}${o}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
2613
2654
|
`${i}${c} `,
|
|
2614
2655
|
(m) => styleText("dim", m)
|
|
2615
2656
|
);
|
|
2616
2657
|
if (l === "group-active-selected")
|
|
2617
2658
|
return wrapTextWithPrefix(
|
|
2618
|
-
|
|
2659
|
+
r.output,
|
|
2619
2660
|
a,
|
|
2620
|
-
`${i}${
|
|
2621
|
-
`${i}${
|
|
2661
|
+
`${i}${o} `,
|
|
2662
|
+
`${i}${o}${styleText("green", S_CHECKBOX_SELECTED)} `,
|
|
2622
2663
|
`${i}${c} `,
|
|
2623
2664
|
(m) => styleText("dim", m)
|
|
2624
2665
|
);
|
|
2625
2666
|
if (l === "selected") {
|
|
2626
2667
|
const m = t || f ? styleText("green", S_CHECKBOX_SELECTED) : "";
|
|
2627
2668
|
return wrapTextWithPrefix(
|
|
2628
|
-
|
|
2669
|
+
r.output,
|
|
2629
2670
|
`${a}${n.hint ? ` (${n.hint})` : ""}`,
|
|
2630
|
-
`${i}${styleText("dim",
|
|
2631
|
-
`${i}${styleText("dim",
|
|
2671
|
+
`${i}${styleText("dim", o)} `,
|
|
2672
|
+
`${i}${styleText("dim", o)}${m} `,
|
|
2632
2673
|
`${i}${styleText("dim", c)} `,
|
|
2633
2674
|
(I) => styleText("dim", I)
|
|
2634
2675
|
);
|
|
@@ -2637,32 +2678,32 @@ const groupMultiselect = (o) => {
|
|
|
2637
2678
|
return `${styleText(["strikethrough", "dim"], a)}`;
|
|
2638
2679
|
if (l === "active-selected")
|
|
2639
2680
|
return wrapTextWithPrefix(
|
|
2640
|
-
|
|
2681
|
+
r.output,
|
|
2641
2682
|
`${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
|
|
2642
|
-
`${i}${styleText("dim",
|
|
2643
|
-
`${i}${styleText("dim",
|
|
2683
|
+
`${i}${styleText("dim", o)} `,
|
|
2684
|
+
`${i}${styleText("dim", o)}${styleText("green", S_CHECKBOX_SELECTED)} `,
|
|
2644
2685
|
`${i}${styleText("dim", c)} `
|
|
2645
2686
|
);
|
|
2646
2687
|
if (l === "submitted")
|
|
2647
2688
|
return `${styleText("dim", a)}`;
|
|
2648
2689
|
const h = t || f ? styleText("dim", S_CHECKBOX_INACTIVE) : "";
|
|
2649
2690
|
return wrapTextWithPrefix(
|
|
2650
|
-
|
|
2691
|
+
r.output,
|
|
2651
2692
|
a,
|
|
2652
|
-
`${i}${styleText("dim",
|
|
2653
|
-
`${i}${styleText("dim",
|
|
2693
|
+
`${i}${styleText("dim", o)} `,
|
|
2694
|
+
`${i}${styleText("dim", o)}${h} `,
|
|
2654
2695
|
`${i}${styleText("dim", c)} `,
|
|
2655
2696
|
(m) => styleText("dim", m)
|
|
2656
2697
|
);
|
|
2657
|
-
}, y =
|
|
2658
|
-
return new u$
|
|
2659
|
-
options:
|
|
2660
|
-
signal:
|
|
2661
|
-
input:
|
|
2662
|
-
output:
|
|
2663
|
-
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,
|
|
2664
2705
|
required: y,
|
|
2665
|
-
cursorAt:
|
|
2706
|
+
cursorAt: r.cursorAt,
|
|
2666
2707
|
selectableGroups: f,
|
|
2667
2708
|
validate(n) {
|
|
2668
2709
|
if (y && (n === void 0 || n.length === 0))
|
|
@@ -2679,58 +2720,58 @@ ${styleText(
|
|
|
2679
2720
|
)}`;
|
|
2680
2721
|
},
|
|
2681
2722
|
render() {
|
|
2682
|
-
const n =
|
|
2683
|
-
` : ""}${symbol(this.state)} ${
|
|
2684
|
-
`, p = this.value ?? [], a = (t,
|
|
2685
|
-
const
|
|
2686
|
-
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);
|
|
2687
2728
|
};
|
|
2688
2729
|
switch (this.state) {
|
|
2689
2730
|
case "submit": {
|
|
2690
|
-
const t = this.options.filter(({ value:
|
|
2691
|
-
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}`;
|
|
2692
2733
|
}
|
|
2693
2734
|
case "cancel": {
|
|
2694
|
-
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", ", "));
|
|
2695
2736
|
return `${l}${n ? `${styleText("gray", S_BAR)} ` : ""}${t.trim() ? `${t}${n ? `
|
|
2696
2737
|
${styleText("gray", S_BAR)}` : ""}` : ""}`;
|
|
2697
2738
|
}
|
|
2698
2739
|
case "error": {
|
|
2699
|
-
const t = n ? `${styleText("yellow", S_BAR)} ` : "",
|
|
2740
|
+
const t = n ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
|
|
2700
2741
|
`).map(
|
|
2701
2742
|
(i, h) => h === 0 ? `${n ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", i)}` : ` ${i}`
|
|
2702
2743
|
).join(`
|
|
2703
|
-
`),
|
|
2704
|
-
`).length,
|
|
2744
|
+
`), s = l.split(`
|
|
2745
|
+
`).length, o = u.split(`
|
|
2705
2746
|
`).length + 1, c = limitOptions({
|
|
2706
|
-
output:
|
|
2747
|
+
output: r.output,
|
|
2707
2748
|
options: this.options,
|
|
2708
2749
|
cursor: this.cursor,
|
|
2709
|
-
maxItems:
|
|
2750
|
+
maxItems: r.maxItems,
|
|
2710
2751
|
columnPadding: t.length,
|
|
2711
|
-
rowPadding:
|
|
2752
|
+
rowPadding: s + o,
|
|
2712
2753
|
style: a
|
|
2713
2754
|
}).join(`
|
|
2714
2755
|
${t}`);
|
|
2715
2756
|
return `${l}${t}${c}
|
|
2716
|
-
${
|
|
2757
|
+
${u}
|
|
2717
2758
|
`;
|
|
2718
2759
|
}
|
|
2719
2760
|
default: {
|
|
2720
|
-
const t = n ? `${styleText("cyan", S_BAR)} ` : "",
|
|
2721
|
-
`).length,
|
|
2722
|
-
`), c =
|
|
2723
|
-
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,
|
|
2724
2765
|
options: this.options,
|
|
2725
2766
|
cursor: this.cursor,
|
|
2726
|
-
maxItems:
|
|
2767
|
+
maxItems: r.maxItems,
|
|
2727
2768
|
columnPadding: t.length,
|
|
2728
|
-
rowPadding:
|
|
2769
|
+
rowPadding: u + c,
|
|
2729
2770
|
style: a
|
|
2730
2771
|
}).join(`
|
|
2731
2772
|
${t}`);
|
|
2732
2773
|
return `${l}${t}${i}
|
|
2733
|
-
${
|
|
2774
|
+
${o}
|
|
2734
2775
|
`;
|
|
2735
2776
|
}
|
|
2736
2777
|
}
|
|
@@ -2855,7 +2896,7 @@ ${r}${d}
|
|
|
2855
2896
|
}
|
|
2856
2897
|
}).prompt();
|
|
2857
2898
|
|
|
2858
|
-
const W
|
|
2899
|
+
const W = (o) => o, C = (o, e, s) => {
|
|
2859
2900
|
const a = {
|
|
2860
2901
|
hard: true,
|
|
2861
2902
|
trim: false
|
|
@@ -2864,7 +2905,7 @@ const W$1 = (o) => o, C = (o, e, s) => {
|
|
|
2864
2905
|
return wrapAnsi(o, g, a);
|
|
2865
2906
|
};
|
|
2866
2907
|
const note = (o = "", e = "", s) => {
|
|
2867
|
-
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(`
|
|
2868
2909
|
`).map(c), ""], n = fastStringWidth(e), t = Math.max(
|
|
2869
2910
|
g.reduce((m, F) => {
|
|
2870
2911
|
const O = fastStringWidth(F);
|
|
@@ -2887,7 +2928,7 @@ ${styleText("gray", l$1 + S_BAR_H.repeat(t + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
|
2887
2928
|
);
|
|
2888
2929
|
};
|
|
2889
2930
|
|
|
2890
|
-
const password = (e) => new u$
|
|
2931
|
+
const password = (e) => new u$2({
|
|
2891
2932
|
validate: e.validate,
|
|
2892
2933
|
mask: e.mask ?? S_PASSWORD_MASK,
|
|
2893
2934
|
signal: e.signal,
|
|
@@ -2945,17 +2986,18 @@ const path = (e) => {
|
|
|
2945
2986
|
return [];
|
|
2946
2987
|
try {
|
|
2947
2988
|
let i;
|
|
2948
|
-
|
|
2949
|
-
|
|
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;
|
|
2950
2992
|
return readdirSync(i).map((r) => {
|
|
2951
|
-
const n = join(i, r),
|
|
2993
|
+
const n = join(i, r), l = lstatSync(n);
|
|
2952
2994
|
return {
|
|
2953
2995
|
name: r,
|
|
2954
2996
|
path: n,
|
|
2955
|
-
isDirectory:
|
|
2997
|
+
isDirectory: l.isDirectory()
|
|
2956
2998
|
};
|
|
2957
2999
|
}).filter(
|
|
2958
|
-
({ path: r, isDirectory: n }) => r.startsWith(
|
|
3000
|
+
({ path: r, isDirectory: n }) => r.startsWith(m) && (n || !e.directory)
|
|
2959
3001
|
).map((r) => ({
|
|
2960
3002
|
value: r.path
|
|
2961
3003
|
}));
|
|
@@ -2966,83 +3008,101 @@ const path = (e) => {
|
|
|
2966
3008
|
});
|
|
2967
3009
|
};
|
|
2968
3010
|
|
|
2969
|
-
const
|
|
3011
|
+
const Y = 3e4, Z = (c) => styleText("magenta", c);
|
|
2970
3012
|
const spinner = ({
|
|
2971
|
-
indicator:
|
|
2972
|
-
onCancel:
|
|
3013
|
+
indicator: c = "dots",
|
|
3014
|
+
onCancel: b,
|
|
2973
3015
|
output: n = process.stdout,
|
|
2974
|
-
cancelMessage:
|
|
2975
|
-
errorMessage:
|
|
2976
|
-
frames:
|
|
2977
|
-
delay:
|
|
2978
|
-
signal:
|
|
2979
|
-
...
|
|
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
|
|
2980
3022
|
} = {}) => {
|
|
2981
|
-
const u = isCI();
|
|
2982
|
-
let
|
|
2983
|
-
const
|
|
2984
|
-
const
|
|
2985
|
-
|
|
2986
|
-
},
|
|
2987
|
-
process.on("uncaughtExceptionMonitor",
|
|
2988
|
-
},
|
|
2989
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
2990
|
-
},
|
|
2991
|
-
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;
|
|
2992
3034
|
u && n.write(`
|
|
2993
3035
|
`);
|
|
2994
|
-
const
|
|
3036
|
+
const s = wrapAnsi(v, y, {
|
|
2995
3037
|
hard: true,
|
|
2996
3038
|
trim: false
|
|
2997
3039
|
}).split(`
|
|
2998
3040
|
`);
|
|
2999
|
-
|
|
3000
|
-
},
|
|
3001
|
-
const
|
|
3002
|
-
return
|
|
3003
|
-
}, N =
|
|
3004
|
-
|
|
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}
|
|
3005
3051
|
`);
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3052
|
+
}, Y);
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3055
|
+
x = block({ output: n }), N && n.write(`${styleText("gray", S_BAR)}
|
|
3056
|
+
`);
|
|
3057
|
+
let s = 0, i = 0;
|
|
3058
|
+
I = setInterval(() => {
|
|
3059
|
+
if (u && r === v)
|
|
3009
3060
|
return;
|
|
3010
|
-
|
|
3011
|
-
const
|
|
3012
|
-
let
|
|
3061
|
+
R(), v = r;
|
|
3062
|
+
const t = F(M[s]);
|
|
3063
|
+
let o;
|
|
3013
3064
|
if (u)
|
|
3014
|
-
|
|
3015
|
-
else if (
|
|
3016
|
-
|
|
3065
|
+
o = `${t} ${r}...`;
|
|
3066
|
+
else if (c === "timer")
|
|
3067
|
+
o = `${t} ${r} ${T(w)}`;
|
|
3017
3068
|
else {
|
|
3018
|
-
const
|
|
3019
|
-
|
|
3069
|
+
const j = ".".repeat(Math.floor(i)).slice(0, 3);
|
|
3070
|
+
o = `${t} ${r}${j}`;
|
|
3020
3071
|
}
|
|
3021
|
-
const
|
|
3072
|
+
const D = wrapAnsi(o, y, {
|
|
3022
3073
|
hard: true,
|
|
3023
3074
|
trim: false
|
|
3024
3075
|
});
|
|
3025
|
-
n.write(
|
|
3026
|
-
},
|
|
3027
|
-
},
|
|
3028
|
-
if (
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
`)
|
|
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
|
+
}
|
|
3034
3094
|
};
|
|
3035
3095
|
return {
|
|
3036
3096
|
start: P,
|
|
3037
|
-
stop: (e = "") =>
|
|
3097
|
+
stop: (e = "") => m(e, 0),
|
|
3038
3098
|
message: (e = "") => {
|
|
3039
|
-
|
|
3099
|
+
r = L(e ?? r);
|
|
3040
3100
|
},
|
|
3041
|
-
cancel: (e = "") =>
|
|
3042
|
-
error: (e = "") =>
|
|
3043
|
-
clear: () =>
|
|
3101
|
+
cancel: (e = "") => m(e, 1),
|
|
3102
|
+
error: (e = "") => m(e, 2),
|
|
3103
|
+
clear: () => m("", 0, true),
|
|
3044
3104
|
get isCancelled() {
|
|
3045
|
-
return
|
|
3105
|
+
return l;
|
|
3046
3106
|
}
|
|
3047
3107
|
};
|
|
3048
3108
|
};
|
|
@@ -3088,7 +3148,9 @@ function progress({
|
|
|
3088
3148
|
error: r.error,
|
|
3089
3149
|
clear: r.clear,
|
|
3090
3150
|
advance: g,
|
|
3091
|
-
isCancelled
|
|
3151
|
+
get isCancelled() {
|
|
3152
|
+
return r.isCancelled;
|
|
3153
|
+
},
|
|
3092
3154
|
message: (t) => g(0, t)
|
|
3093
3155
|
};
|
|
3094
3156
|
}
|
|
@@ -3154,7 +3216,7 @@ ${styleText("gray", S_BAR)}` : ""}`;
|
|
|
3154
3216
|
}
|
|
3155
3217
|
default: {
|
|
3156
3218
|
const r = n ? `${styleText("cyan", S_BAR)} ` : "", a = u.split(`
|
|
3157
|
-
`).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(`
|
|
3158
3220
|
`), b = p.length + 1;
|
|
3159
3221
|
return `${u}${r}${limitOptions({
|
|
3160
3222
|
output: t.output,
|
|
@@ -3174,36 +3236,36 @@ ${f}
|
|
|
3174
3236
|
}).prompt();
|
|
3175
3237
|
};
|
|
3176
3238
|
|
|
3177
|
-
const selectKey = (
|
|
3239
|
+
const selectKey = (i) => {
|
|
3178
3240
|
const c = (e, a = "inactive") => {
|
|
3179
3241
|
if (e === void 0)
|
|
3180
3242
|
return "";
|
|
3181
3243
|
const n = e.label ?? String(e.value);
|
|
3182
|
-
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})`)}` : ""}`;
|
|
3183
3245
|
};
|
|
3184
|
-
return new
|
|
3185
|
-
options:
|
|
3186
|
-
signal:
|
|
3187
|
-
input:
|
|
3188
|
-
output:
|
|
3189
|
-
initialValue:
|
|
3190
|
-
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,
|
|
3191
3253
|
render() {
|
|
3192
|
-
const e =
|
|
3193
|
-
` : ""}${symbol(this.state)} ${
|
|
3254
|
+
const e = i.withGuide ?? settings.withGuide, a = `${e ? `${styleText("gray", S_BAR)}
|
|
3255
|
+
` : ""}${symbol(this.state)} ${i.message}
|
|
3194
3256
|
`;
|
|
3195
3257
|
switch (this.state) {
|
|
3196
3258
|
case "submit": {
|
|
3197
|
-
const n = e ? `${styleText("gray", S_BAR)} ` : "", r = this.options.find((
|
|
3198
|
-
|
|
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,
|
|
3199
3261
|
c(r, "selected"),
|
|
3200
3262
|
n
|
|
3201
3263
|
);
|
|
3202
|
-
return `${a}${
|
|
3264
|
+
return `${a}${u}`;
|
|
3203
3265
|
}
|
|
3204
3266
|
case "cancel": {
|
|
3205
3267
|
const n = e ? `${styleText("gray", S_BAR)} ` : "", r = wrapTextWithPrefix(
|
|
3206
|
-
|
|
3268
|
+
i.output,
|
|
3207
3269
|
c(this.options[0], "cancelled"),
|
|
3208
3270
|
n
|
|
3209
3271
|
);
|
|
@@ -3211,15 +3273,18 @@ const selectKey = (t) => {
|
|
|
3211
3273
|
${styleText("gray", S_BAR)}` : ""}`;
|
|
3212
3274
|
}
|
|
3213
3275
|
default: {
|
|
3214
|
-
const n = e ? `${styleText("cyan", S_BAR)} ` : "", r = e ? styleText("cyan", S_BAR_END) : "",
|
|
3215
|
-
(
|
|
3216
|
-
|
|
3217
|
-
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
|
+
),
|
|
3218
3283
|
n
|
|
3219
3284
|
)
|
|
3220
3285
|
).join(`
|
|
3221
3286
|
`);
|
|
3222
|
-
return `${a}${
|
|
3287
|
+
return `${a}${u}
|
|
3223
3288
|
${r}
|
|
3224
3289
|
`;
|
|
3225
3290
|
}
|
|
@@ -3297,7 +3362,7 @@ ${t.header}`);
|
|
|
3297
3362
|
`).reduce((b, w) => w === "" ? b + 1 : b + Math.ceil((w.length + k) / O), 0);
|
|
3298
3363
|
s += E;
|
|
3299
3364
|
}
|
|
3300
|
-
s > 0 && (s += 1, r.write(
|
|
3365
|
+
s > 0 && (s += 1, r.write(erase.lines(s)));
|
|
3301
3366
|
}, h = (e, s, t) => {
|
|
3302
3367
|
const o = t ? `${e.full}
|
|
3303
3368
|
${e.value}` : e.value;
|
|
@@ -3528,6 +3593,7 @@ Options
|
|
|
3528
3593
|
--no-install don't install dependencies
|
|
3529
3594
|
--force move a non-empty folder aside first
|
|
3530
3595
|
-y, --yes accept every default, ask nothing
|
|
3596
|
+
--check check that pnpm is ready, create nothing
|
|
3531
3597
|
-h, --help show this help
|
|
3532
3598
|
-v, --version show the CLI and template versions
|
|
3533
3599
|
|
|
@@ -4040,6 +4106,12 @@ async function run(plan, ui, deps = {}) {
|
|
|
4040
4106
|
},
|
|
4041
4107
|
});
|
|
4042
4108
|
try {
|
|
4109
|
+
// pnpm first: a pnpm that can't switch to the template's version stops the run before any file.
|
|
4110
|
+
const spec = pnpmSpec(await readFile(join(from, 'package.json'), 'utf8'));
|
|
4111
|
+
const pin = spec.slice('pnpm@'.length);
|
|
4112
|
+
const pnpm = await detectPnpm(exec);
|
|
4113
|
+
if (pnpm.kind === 'ok')
|
|
4114
|
+
await checkSwitch(spec, pnpm.version, exec);
|
|
4043
4115
|
await (deps.generate ?? generate)({
|
|
4044
4116
|
from,
|
|
4045
4117
|
to: temp,
|
|
@@ -4075,8 +4147,6 @@ async function run(plan, ui, deps = {}) {
|
|
|
4075
4147
|
}
|
|
4076
4148
|
}
|
|
4077
4149
|
}
|
|
4078
|
-
const pin = pnpmSpec(await readFile(join(from, 'package.json'), 'utf8')).slice('pnpm@'.length);
|
|
4079
|
-
const pnpm = await detectPnpm(exec);
|
|
4080
4150
|
const command = installCommand(pnpm, temp, !plan.install);
|
|
4081
4151
|
let installed = false;
|
|
4082
4152
|
let seconds = 0;
|
|
@@ -4120,7 +4190,7 @@ async function run(plan, ui, deps = {}) {
|
|
|
4120
4190
|
outcome = await initAndCommit(temp, message, exec);
|
|
4121
4191
|
}
|
|
4122
4192
|
catch (error) {
|
|
4123
|
-
//
|
|
4193
|
+
// The files are generated and correct, so a failed commit only warns.
|
|
4124
4194
|
outcome = 'failed';
|
|
4125
4195
|
ui.warn("Couldn't make the first commit", [
|
|
4126
4196
|
firstLine(error),
|
|
@@ -4175,6 +4245,8 @@ async function run(plan, ui, deps = {}) {
|
|
|
4175
4245
|
|
|
4176
4246
|
const USAGE = 2;
|
|
4177
4247
|
const FAILURE = 1;
|
|
4248
|
+
/** The machine needs fixing first (pnpm can't switch versions, or is too old); nothing was created. */
|
|
4249
|
+
const TOOLCHAIN = 3;
|
|
4178
4250
|
const INTERRUPTED = 130;
|
|
4179
4251
|
const usage = (message) => {
|
|
4180
4252
|
process.stderr.write(`${message}\n`);
|
|
@@ -4237,6 +4309,10 @@ function report(ui, error) {
|
|
|
4237
4309
|
ui.fail(CANCELLED, []);
|
|
4238
4310
|
return INTERRUPTED;
|
|
4239
4311
|
}
|
|
4312
|
+
if (error instanceof ToolchainError) {
|
|
4313
|
+
ui.fail(error.message, error.lines);
|
|
4314
|
+
return TOOLCHAIN;
|
|
4315
|
+
}
|
|
4240
4316
|
if (error instanceof RunError) {
|
|
4241
4317
|
ui.fail(error.message, error.lines);
|
|
4242
4318
|
return FAILURE;
|
|
@@ -4245,6 +4321,38 @@ function report(ui, error) {
|
|
|
4245
4321
|
ui.fail(title, lines);
|
|
4246
4322
|
return FAILURE;
|
|
4247
4323
|
}
|
|
4324
|
+
/** `--check`: is this machine's pnpm ready for the template's? Creates nothing. */
|
|
4325
|
+
async function check(ui, exec) {
|
|
4326
|
+
const spec = pnpmSpec();
|
|
4327
|
+
const version = spec.slice('pnpm@'.length);
|
|
4328
|
+
ui.intro();
|
|
4329
|
+
const pnpm = await detectPnpm(exec);
|
|
4330
|
+
if (pnpm.kind === 'none') {
|
|
4331
|
+
ui.warn("pnpm isn't installed", [
|
|
4332
|
+
`Creating works: the install uses a temporary pnpm ${version} (npm exec).`,
|
|
4333
|
+
`Working in the project needs pnpm 10.26 or newer: https://pnpm.io/installation`,
|
|
4334
|
+
]);
|
|
4335
|
+
return 0;
|
|
4336
|
+
}
|
|
4337
|
+
if (pnpm.kind === 'old') {
|
|
4338
|
+
ui.fail(`pnpm ${pnpm.version} is too old for this project`, [
|
|
4339
|
+
`This project needs pnpm 10.26 or newer, which switches itself to pnpm ${version}.`,
|
|
4340
|
+
'Upgrade pnpm (https://pnpm.io/installation), then run --check again.',
|
|
4341
|
+
]);
|
|
4342
|
+
return TOOLCHAIN;
|
|
4343
|
+
}
|
|
4344
|
+
try {
|
|
4345
|
+
await checkSwitch(spec, pnpm.version, exec);
|
|
4346
|
+
}
|
|
4347
|
+
catch (error) {
|
|
4348
|
+
if (!(error instanceof ToolchainError))
|
|
4349
|
+
throw error;
|
|
4350
|
+
ui.fail(error.message, error.lines);
|
|
4351
|
+
return TOOLCHAIN;
|
|
4352
|
+
}
|
|
4353
|
+
ui.step(`Ready: pnpm ${pnpm.version} switches to pnpm ${version} for this project`);
|
|
4354
|
+
return 0;
|
|
4355
|
+
}
|
|
4248
4356
|
/** Runs the command and resolves with its exit code. */
|
|
4249
4357
|
async function main(argv, io = {}) {
|
|
4250
4358
|
const parsed = parseArgv(argv);
|
|
@@ -4259,6 +4367,8 @@ async function main(argv, io = {}) {
|
|
|
4259
4367
|
process.stdout.write(`${versionText()}\n`);
|
|
4260
4368
|
return 0;
|
|
4261
4369
|
}
|
|
4370
|
+
if (options.check)
|
|
4371
|
+
return check(io.ui ?? plainUi(), io.exec);
|
|
4262
4372
|
const cwd = io.cwd ?? process.cwd();
|
|
4263
4373
|
const interactive = !options.yes && (io.interactive ?? Boolean(process.stdin.isTTY && process.stdout.isTTY));
|
|
4264
4374
|
// A bad flag fails at once, before any question.
|