varlock 0.2.0 → 0.2.2
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 -0
- package/dist/auto-load.js +8 -8
- package/dist/{chunk-RZT65DRA.js → chunk-35SAMS66.js} +4 -4
- package/dist/{chunk-RZT65DRA.js.map → chunk-35SAMS66.js.map} +1 -1
- package/dist/{chunk-XVVLI2E7.js → chunk-3FLO3UFZ.js} +17 -11
- package/dist/chunk-3FLO3UFZ.js.map +1 -0
- package/dist/{chunk-FPQYEKFF.js → chunk-4N3YR2QQ.js} +4 -4
- package/dist/{chunk-FPQYEKFF.js.map → chunk-4N3YR2QQ.js.map} +1 -1
- package/dist/{chunk-XN24GZXQ.js → chunk-6PEHRAEP.js} +3 -8
- package/dist/{chunk-XN24GZXQ.js.map → chunk-6PEHRAEP.js.map} +1 -1
- package/dist/chunk-BHHYQ7SH.js +18 -0
- package/dist/{chunk-7SH6C6WJ.js.map → chunk-BHHYQ7SH.js.map} +1 -1
- package/dist/{chunk-RD44SH5U.js → chunk-FETFVFG5.js} +117 -23
- package/dist/chunk-FETFVFG5.js.map +1 -0
- package/dist/{chunk-RFRTLWK3.js → chunk-HPUQ2CCN.js} +6 -6
- package/dist/{chunk-RFRTLWK3.js.map → chunk-HPUQ2CCN.js.map} +1 -1
- package/dist/{chunk-FGMXIEFA.js → chunk-MIBOBKI4.js} +3 -3
- package/dist/{chunk-FGMXIEFA.js.map → chunk-MIBOBKI4.js.map} +1 -1
- package/dist/chunk-N2HZMIGS.js +1532 -0
- package/dist/chunk-N2HZMIGS.js.map +1 -0
- package/dist/{chunk-NDRSG3XS.js → chunk-N4REMPVX.js} +23 -14
- package/dist/chunk-N4REMPVX.js.map +1 -0
- package/dist/{chunk-FUDH2TTI.js → chunk-TVFOIGJP.js} +3 -3
- package/dist/{chunk-FUDH2TTI.js.map → chunk-TVFOIGJP.js.map} +1 -1
- package/dist/{chunk-5IMCRQTM.js → chunk-TYIS6T2T.js} +4 -4
- package/dist/{chunk-5IMCRQTM.js.map → chunk-TYIS6T2T.js.map} +1 -1
- package/dist/chunk-UDXNNRWI.js +1386 -0
- package/dist/chunk-UDXNNRWI.js.map +1 -0
- package/dist/{chunk-HPNRKYVF.js → chunk-UIOEEWG5.js} +4 -4
- package/dist/{chunk-HPNRKYVF.js.map → chunk-UIOEEWG5.js.map} +1 -1
- package/dist/{chunk-MSRPV5WH.js → chunk-WAMBVZL2.js} +4 -4
- package/dist/{chunk-MSRPV5WH.js.map → chunk-WAMBVZL2.js.map} +1 -1
- package/dist/{chunk-L5REVVXG.js → chunk-ZUNB52KY.js} +9 -4
- package/dist/chunk-ZUNB52KY.js.map +1 -0
- package/dist/{chunk-NSY7JMFV.js → chunk-ZXJ4CEDK.js} +4 -4
- package/dist/{chunk-NSY7JMFV.js.map → chunk-ZXJ4CEDK.js.map} +1 -1
- package/dist/cli/cli-executable.js +18 -18
- package/dist/cli/cli-executable.js.map +1 -1
- package/dist/dotenv-compat.js +8 -8
- package/dist/help.command-MLH2WA5Y.js +5 -0
- package/dist/{help.command-B7VWA53B.js.map → help.command-MLH2WA5Y.js.map} +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -9
- package/dist/init.command-DLPZ3R4T.js +8 -0
- package/dist/{init.command-AVNYY5CK.js.map → init.command-DLPZ3R4T.js.map} +1 -1
- package/dist/lib/exec-sync-varlock.js +2 -2
- package/dist/load.command-4G5POJYR.js +8 -0
- package/dist/{load.command-7CCTFAYS.js.map → load.command-4G5POJYR.js.map} +1 -1
- package/dist/run.command-L5LLHOW3.js +9 -0
- package/dist/{run.command-NGRKCLWP.js.map → run.command-L5LLHOW3.js.map} +1 -1
- package/dist/runtime/env.js +3 -3
- package/dist/runtime/patch-console.js +4 -4
- package/dist/runtime/patch-response.js +4 -4
- package/dist/runtime/patch-server-response.js +4 -4
- package/dist/telemetry.command-JF72FOYJ.js +8 -0
- package/dist/{telemetry.command-756WXWYK.js.map → telemetry.command-JF72FOYJ.js.map} +1 -1
- package/package.json +34 -15
- package/dist/chunk-33ROL4J5.js +0 -1013
- package/dist/chunk-33ROL4J5.js.map +0 -1
- package/dist/chunk-7SH6C6WJ.js +0 -18
- package/dist/chunk-L5REVVXG.js.map +0 -1
- package/dist/chunk-L5USEQO6.js +0 -1281
- package/dist/chunk-L5USEQO6.js.map +0 -1
- package/dist/chunk-NDRSG3XS.js.map +0 -1
- package/dist/chunk-RD44SH5U.js.map +0 -1
- package/dist/chunk-XVVLI2E7.js.map +0 -1
- package/dist/en-US-TSGNDI2P.js +0 -22
- package/dist/en-US-TSGNDI2P.js.map +0 -1
- package/dist/help.command-B7VWA53B.js +0 -5
- package/dist/init.command-AVNYY5CK.js +0 -8
- package/dist/ja-JP-UBPCQAAD.js +0 -22
- package/dist/ja-JP-UBPCQAAD.js.map +0 -1
- package/dist/load.command-7CCTFAYS.js +0 -8
- package/dist/run.command-NGRKCLWP.js +0 -9
- package/dist/telemetry.command-756WXWYK.js +0 -8
|
@@ -0,0 +1,1532 @@
|
|
|
1
|
+
import { detectJsPackageManager, logLines, fmt, installJsDependency } from './chunk-4N3YR2QQ.js';
|
|
2
|
+
import { define } from './chunk-UDXNNRWI.js';
|
|
3
|
+
import { tryCatch, gracefulExit, ansis_default, pathExists } from './chunk-FETFVFG5.js';
|
|
4
|
+
import { __commonJS, __name, __toESM } from './chunk-6PEHRAEP.js';
|
|
5
|
+
import path2, { dirname } from 'path';
|
|
6
|
+
import fs3 from 'fs/promises';
|
|
7
|
+
import P2, { stdin, stdout } from 'process';
|
|
8
|
+
import ot from 'readline';
|
|
9
|
+
import { WriteStream } from 'tty';
|
|
10
|
+
import 'fs';
|
|
11
|
+
import { promisify } from 'util';
|
|
12
|
+
import { envSpecUpdater, ParsedEnvSpecStaticValue, parseEnvSpecDotEnvFile } from '@env-spec/parser';
|
|
13
|
+
import { exec, spawn } from 'child_process';
|
|
14
|
+
|
|
15
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
16
|
+
var require_picocolors = __commonJS({
|
|
17
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
18
|
+
var p = process || {};
|
|
19
|
+
var argv = p.argv || [];
|
|
20
|
+
var env = p.env || {};
|
|
21
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
22
|
+
var formatter = /* @__PURE__ */ __name((open, close, replace = open) => (input) => {
|
|
23
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
24
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
25
|
+
}, "formatter");
|
|
26
|
+
var replaceClose = /* @__PURE__ */ __name((string, close, replace, index) => {
|
|
27
|
+
let result = "", cursor = 0;
|
|
28
|
+
do {
|
|
29
|
+
result += string.substring(cursor, index) + replace;
|
|
30
|
+
cursor = index + close.length;
|
|
31
|
+
index = string.indexOf(close, cursor);
|
|
32
|
+
} while (~index);
|
|
33
|
+
return result + string.substring(cursor);
|
|
34
|
+
}, "replaceClose");
|
|
35
|
+
var createColors = /* @__PURE__ */ __name((enabled = isColorSupported) => {
|
|
36
|
+
let f = enabled ? formatter : () => String;
|
|
37
|
+
return {
|
|
38
|
+
isColorSupported: enabled,
|
|
39
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
40
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
41
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
42
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
43
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
44
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
45
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
46
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
47
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
48
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
49
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
50
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
51
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
52
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
53
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
54
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
55
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
56
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
57
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
58
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
59
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
60
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
61
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
62
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
63
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
64
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
65
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
66
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
67
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
68
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
69
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
70
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
71
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
72
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
73
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
74
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
75
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
76
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
77
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
78
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
79
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
80
|
+
};
|
|
81
|
+
}, "createColors");
|
|
82
|
+
module.exports = createColors();
|
|
83
|
+
module.exports.createColors = createColors;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
88
|
+
var require_src = __commonJS({
|
|
89
|
+
"../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
|
|
90
|
+
var ESC = "\x1B";
|
|
91
|
+
var CSI = `${ESC}[`;
|
|
92
|
+
var beep = "\x07";
|
|
93
|
+
var cursor = {
|
|
94
|
+
to(x3, y2) {
|
|
95
|
+
if (!y2) return `${CSI}${x3 + 1}G`;
|
|
96
|
+
return `${CSI}${y2 + 1};${x3 + 1}H`;
|
|
97
|
+
},
|
|
98
|
+
move(x3, y2) {
|
|
99
|
+
let ret = "";
|
|
100
|
+
if (x3 < 0) ret += `${CSI}${-x3}D`;
|
|
101
|
+
else if (x3 > 0) ret += `${CSI}${x3}C`;
|
|
102
|
+
if (y2 < 0) ret += `${CSI}${-y2}A`;
|
|
103
|
+
else if (y2 > 0) ret += `${CSI}${y2}B`;
|
|
104
|
+
return ret;
|
|
105
|
+
},
|
|
106
|
+
up: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}A`, "up"),
|
|
107
|
+
down: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}B`, "down"),
|
|
108
|
+
forward: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}C`, "forward"),
|
|
109
|
+
backward: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}D`, "backward"),
|
|
110
|
+
nextLine: /* @__PURE__ */ __name((count = 1) => `${CSI}E`.repeat(count), "nextLine"),
|
|
111
|
+
prevLine: /* @__PURE__ */ __name((count = 1) => `${CSI}F`.repeat(count), "prevLine"),
|
|
112
|
+
left: `${CSI}G`,
|
|
113
|
+
hide: `${CSI}?25l`,
|
|
114
|
+
show: `${CSI}?25h`,
|
|
115
|
+
save: `${ESC}7`,
|
|
116
|
+
restore: `${ESC}8`
|
|
117
|
+
};
|
|
118
|
+
var scroll = {
|
|
119
|
+
up: /* @__PURE__ */ __name((count = 1) => `${CSI}S`.repeat(count), "up"),
|
|
120
|
+
down: /* @__PURE__ */ __name((count = 1) => `${CSI}T`.repeat(count), "down")
|
|
121
|
+
};
|
|
122
|
+
var erase = {
|
|
123
|
+
screen: `${CSI}2J`,
|
|
124
|
+
up: /* @__PURE__ */ __name((count = 1) => `${CSI}1J`.repeat(count), "up"),
|
|
125
|
+
down: /* @__PURE__ */ __name((count = 1) => `${CSI}J`.repeat(count), "down"),
|
|
126
|
+
line: `${CSI}2K`,
|
|
127
|
+
lineEnd: `${CSI}K`,
|
|
128
|
+
lineStart: `${CSI}1K`,
|
|
129
|
+
lines(count) {
|
|
130
|
+
let clear = "";
|
|
131
|
+
for (let i = 0; i < count; i++)
|
|
132
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
133
|
+
if (count)
|
|
134
|
+
clear += cursor.left;
|
|
135
|
+
return clear;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// ../../node_modules/.pnpm/@clack+core@1.0.0/node_modules/@clack/core/dist/index.mjs
|
|
143
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
144
|
+
var at = /* @__PURE__ */ __name((t2) => t2 === 161 || t2 === 164 || t2 === 167 || t2 === 168 || t2 === 170 || t2 === 173 || t2 === 174 || t2 >= 176 && t2 <= 180 || t2 >= 182 && t2 <= 186 || t2 >= 188 && t2 <= 191 || t2 === 198 || t2 === 208 || t2 === 215 || t2 === 216 || t2 >= 222 && t2 <= 225 || t2 === 230 || t2 >= 232 && t2 <= 234 || t2 === 236 || t2 === 237 || t2 === 240 || t2 === 242 || t2 === 243 || t2 >= 247 && t2 <= 250 || t2 === 252 || t2 === 254 || t2 === 257 || t2 === 273 || t2 === 275 || t2 === 283 || t2 === 294 || t2 === 295 || t2 === 299 || t2 >= 305 && t2 <= 307 || t2 === 312 || t2 >= 319 && t2 <= 322 || t2 === 324 || t2 >= 328 && t2 <= 331 || t2 === 333 || t2 === 338 || t2 === 339 || t2 === 358 || t2 === 359 || t2 === 363 || t2 === 462 || t2 === 464 || t2 === 466 || t2 === 468 || t2 === 470 || t2 === 472 || t2 === 474 || t2 === 476 || t2 === 593 || t2 === 609 || t2 === 708 || t2 === 711 || t2 >= 713 && t2 <= 715 || t2 === 717 || t2 === 720 || t2 >= 728 && t2 <= 731 || t2 === 733 || t2 === 735 || t2 >= 768 && t2 <= 879 || t2 >= 913 && t2 <= 929 || t2 >= 931 && t2 <= 937 || t2 >= 945 && t2 <= 961 || t2 >= 963 && t2 <= 969 || t2 === 1025 || t2 >= 1040 && t2 <= 1103 || t2 === 1105 || t2 === 8208 || t2 >= 8211 && t2 <= 8214 || t2 === 8216 || t2 === 8217 || t2 === 8220 || t2 === 8221 || t2 >= 8224 && t2 <= 8226 || t2 >= 8228 && t2 <= 8231 || t2 === 8240 || t2 === 8242 || t2 === 8243 || t2 === 8245 || t2 === 8251 || t2 === 8254 || t2 === 8308 || t2 === 8319 || t2 >= 8321 && t2 <= 8324 || t2 === 8364 || t2 === 8451 || t2 === 8453 || t2 === 8457 || t2 === 8467 || t2 === 8470 || t2 === 8481 || t2 === 8482 || t2 === 8486 || t2 === 8491 || t2 === 8531 || t2 === 8532 || t2 >= 8539 && t2 <= 8542 || t2 >= 8544 && t2 <= 8555 || t2 >= 8560 && t2 <= 8569 || t2 === 8585 || t2 >= 8592 && t2 <= 8601 || t2 === 8632 || t2 === 8633 || t2 === 8658 || t2 === 8660 || t2 === 8679 || t2 === 8704 || t2 === 8706 || t2 === 8707 || t2 === 8711 || t2 === 8712 || t2 === 8715 || t2 === 8719 || t2 === 8721 || t2 === 8725 || t2 === 8730 || t2 >= 8733 && t2 <= 8736 || t2 === 8739 || t2 === 8741 || t2 >= 8743 && t2 <= 8748 || t2 === 8750 || t2 >= 8756 && t2 <= 8759 || t2 === 8764 || t2 === 8765 || t2 === 8776 || t2 === 8780 || t2 === 8786 || t2 === 8800 || t2 === 8801 || t2 >= 8804 && t2 <= 8807 || t2 === 8810 || t2 === 8811 || t2 === 8814 || t2 === 8815 || t2 === 8834 || t2 === 8835 || t2 === 8838 || t2 === 8839 || t2 === 8853 || t2 === 8857 || t2 === 8869 || t2 === 8895 || t2 === 8978 || t2 >= 9312 && t2 <= 9449 || t2 >= 9451 && t2 <= 9547 || t2 >= 9552 && t2 <= 9587 || t2 >= 9600 && t2 <= 9615 || t2 >= 9618 && t2 <= 9621 || t2 === 9632 || t2 === 9633 || t2 >= 9635 && t2 <= 9641 || t2 === 9650 || t2 === 9651 || t2 === 9654 || t2 === 9655 || t2 === 9660 || t2 === 9661 || t2 === 9664 || t2 === 9665 || t2 >= 9670 && t2 <= 9672 || t2 === 9675 || t2 >= 9678 && t2 <= 9681 || t2 >= 9698 && t2 <= 9701 || t2 === 9711 || t2 === 9733 || t2 === 9734 || t2 === 9737 || t2 === 9742 || t2 === 9743 || t2 === 9756 || t2 === 9758 || t2 === 9792 || t2 === 9794 || t2 === 9824 || t2 === 9825 || t2 >= 9827 && t2 <= 9829 || t2 >= 9831 && t2 <= 9834 || t2 === 9836 || t2 === 9837 || t2 === 9839 || t2 === 9886 || t2 === 9887 || t2 === 9919 || t2 >= 9926 && t2 <= 9933 || t2 >= 9935 && t2 <= 9939 || t2 >= 9941 && t2 <= 9953 || t2 === 9955 || t2 === 9960 || t2 === 9961 || t2 >= 9963 && t2 <= 9969 || t2 === 9972 || t2 >= 9974 && t2 <= 9977 || t2 === 9979 || t2 === 9980 || t2 === 9982 || t2 === 9983 || t2 === 10045 || t2 >= 10102 && t2 <= 10111 || t2 >= 11094 && t2 <= 11097 || t2 >= 12872 && t2 <= 12879 || t2 >= 57344 && t2 <= 63743 || t2 >= 65024 && t2 <= 65039 || t2 === 65533 || t2 >= 127232 && t2 <= 127242 || t2 >= 127248 && t2 <= 127277 || t2 >= 127280 && t2 <= 127337 || t2 >= 127344 && t2 <= 127373 || t2 === 127375 || t2 === 127376 || t2 >= 127387 && t2 <= 127404 || t2 >= 917760 && t2 <= 917999 || t2 >= 983040 && t2 <= 1048573 || t2 >= 1048576 && t2 <= 1114109, "at");
|
|
145
|
+
var lt = /* @__PURE__ */ __name((t2) => t2 === 12288 || t2 >= 65281 && t2 <= 65376 || t2 >= 65504 && t2 <= 65510, "lt");
|
|
146
|
+
var ht = /* @__PURE__ */ __name((t2) => t2 >= 4352 && t2 <= 4447 || t2 === 8986 || t2 === 8987 || t2 === 9001 || t2 === 9002 || t2 >= 9193 && t2 <= 9196 || t2 === 9200 || t2 === 9203 || t2 === 9725 || t2 === 9726 || t2 === 9748 || t2 === 9749 || t2 >= 9800 && t2 <= 9811 || t2 === 9855 || t2 === 9875 || t2 === 9889 || t2 === 9898 || t2 === 9899 || t2 === 9917 || t2 === 9918 || t2 === 9924 || t2 === 9925 || t2 === 9934 || t2 === 9940 || t2 === 9962 || t2 === 9970 || t2 === 9971 || t2 === 9973 || t2 === 9978 || t2 === 9981 || t2 === 9989 || t2 === 9994 || t2 === 9995 || t2 === 10024 || t2 === 10060 || t2 === 10062 || t2 >= 10067 && t2 <= 10069 || t2 === 10071 || t2 >= 10133 && t2 <= 10135 || t2 === 10160 || t2 === 10175 || t2 === 11035 || t2 === 11036 || t2 === 11088 || t2 === 11093 || t2 >= 11904 && t2 <= 11929 || t2 >= 11931 && t2 <= 12019 || t2 >= 12032 && t2 <= 12245 || t2 >= 12272 && t2 <= 12287 || t2 >= 12289 && t2 <= 12350 || t2 >= 12353 && t2 <= 12438 || t2 >= 12441 && t2 <= 12543 || t2 >= 12549 && t2 <= 12591 || t2 >= 12593 && t2 <= 12686 || t2 >= 12688 && t2 <= 12771 || t2 >= 12783 && t2 <= 12830 || t2 >= 12832 && t2 <= 12871 || t2 >= 12880 && t2 <= 19903 || t2 >= 19968 && t2 <= 42124 || t2 >= 42128 && t2 <= 42182 || t2 >= 43360 && t2 <= 43388 || t2 >= 44032 && t2 <= 55203 || t2 >= 63744 && t2 <= 64255 || t2 >= 65040 && t2 <= 65049 || t2 >= 65072 && t2 <= 65106 || t2 >= 65108 && t2 <= 65126 || t2 >= 65128 && t2 <= 65131 || t2 >= 94176 && t2 <= 94180 || t2 === 94192 || t2 === 94193 || t2 >= 94208 && t2 <= 100343 || t2 >= 100352 && t2 <= 101589 || t2 >= 101632 && t2 <= 101640 || t2 >= 110576 && t2 <= 110579 || t2 >= 110581 && t2 <= 110587 || t2 === 110589 || t2 === 110590 || t2 >= 110592 && t2 <= 110882 || t2 === 110898 || t2 >= 110928 && t2 <= 110930 || t2 === 110933 || t2 >= 110948 && t2 <= 110951 || t2 >= 110960 && t2 <= 111355 || t2 === 126980 || t2 === 127183 || t2 === 127374 || t2 >= 127377 && t2 <= 127386 || t2 >= 127488 && t2 <= 127490 || t2 >= 127504 && t2 <= 127547 || t2 >= 127552 && t2 <= 127560 || t2 === 127568 || t2 === 127569 || t2 >= 127584 && t2 <= 127589 || t2 >= 127744 && t2 <= 127776 || t2 >= 127789 && t2 <= 127797 || t2 >= 127799 && t2 <= 127868 || t2 >= 127870 && t2 <= 127891 || t2 >= 127904 && t2 <= 127946 || t2 >= 127951 && t2 <= 127955 || t2 >= 127968 && t2 <= 127984 || t2 === 127988 || t2 >= 127992 && t2 <= 128062 || t2 === 128064 || t2 >= 128066 && t2 <= 128252 || t2 >= 128255 && t2 <= 128317 || t2 >= 128331 && t2 <= 128334 || t2 >= 128336 && t2 <= 128359 || t2 === 128378 || t2 === 128405 || t2 === 128406 || t2 === 128420 || t2 >= 128507 && t2 <= 128591 || t2 >= 128640 && t2 <= 128709 || t2 === 128716 || t2 >= 128720 && t2 <= 128722 || t2 >= 128725 && t2 <= 128727 || t2 >= 128732 && t2 <= 128735 || t2 === 128747 || t2 === 128748 || t2 >= 128756 && t2 <= 128764 || t2 >= 128992 && t2 <= 129003 || t2 === 129008 || t2 >= 129292 && t2 <= 129338 || t2 >= 129340 && t2 <= 129349 || t2 >= 129351 && t2 <= 129535 || t2 >= 129648 && t2 <= 129660 || t2 >= 129664 && t2 <= 129672 || t2 >= 129680 && t2 <= 129725 || t2 >= 129727 && t2 <= 129733 || t2 >= 129742 && t2 <= 129755 || t2 >= 129760 && t2 <= 129768 || t2 >= 129776 && t2 <= 129784 || t2 >= 131072 && t2 <= 196605 || t2 >= 196608 && t2 <= 262141, "ht");
|
|
147
|
+
var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
148
|
+
var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
149
|
+
var M = /\t{1,1000}/y;
|
|
150
|
+
var P = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
151
|
+
var L = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
152
|
+
var ct = new RegExp("\\p{M}+", "gu");
|
|
153
|
+
var pt = { limit: 1 / 0, ellipsis: "" };
|
|
154
|
+
var X = /* @__PURE__ */ __name((t2, e = {}, s = {}) => {
|
|
155
|
+
const i = e.limit ?? 1 / 0, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, pt, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
|
|
156
|
+
let h2 = 0, o = 0, f = t2.length, v = 0, F = false, d = f, b = Math.max(0, i - n), C = 0, B = 0, c = 0, p = 0;
|
|
157
|
+
t: for (; ; ) {
|
|
158
|
+
if (B > C || o >= f && o > h2) {
|
|
159
|
+
const ut = t2.slice(C, B) || t2.slice(h2, o);
|
|
160
|
+
v = 0;
|
|
161
|
+
for (const Y2 of ut.replaceAll(ct, "")) {
|
|
162
|
+
const $ = Y2.codePointAt(0) || 0;
|
|
163
|
+
if (lt($) ? p = m : ht($) ? p = V : E !== A && at($) ? p = E : p = A, c + p > b && (d = Math.min(d, Math.max(C, h2) + v)), c + p > i) {
|
|
164
|
+
F = true;
|
|
165
|
+
break t;
|
|
166
|
+
}
|
|
167
|
+
v += Y2.length, c += p;
|
|
168
|
+
}
|
|
169
|
+
C = B = 0;
|
|
170
|
+
}
|
|
171
|
+
if (o >= f) break;
|
|
172
|
+
if (L.lastIndex = o, L.test(t2)) {
|
|
173
|
+
if (v = L.lastIndex - o, p = v * A, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + p > i) {
|
|
174
|
+
F = true;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
c += p, C = h2, B = o, o = h2 = L.lastIndex;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (O.lastIndex = o, O.test(t2)) {
|
|
181
|
+
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
|
|
182
|
+
F = true;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
c += u, C = h2, B = o, o = h2 = O.lastIndex;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (y.lastIndex = o, y.test(t2)) {
|
|
189
|
+
if (v = y.lastIndex - o, p = v * a, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + p > i) {
|
|
190
|
+
F = true;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
c += p, C = h2, B = o, o = h2 = y.lastIndex;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (M.lastIndex = o, M.test(t2)) {
|
|
197
|
+
if (v = M.lastIndex - o, p = v * l, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + p > i) {
|
|
198
|
+
F = true;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
c += p, C = h2, B = o, o = h2 = M.lastIndex;
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (P.lastIndex = o, P.test(t2)) {
|
|
205
|
+
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
|
|
206
|
+
F = true;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
c += g, C = h2, B = o, o = h2 = P.lastIndex;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
o += 1;
|
|
213
|
+
}
|
|
214
|
+
return { width: F ? b : c, index: F ? d : f, truncated: F, ellipsed: F && i >= n };
|
|
215
|
+
}, "X");
|
|
216
|
+
var ft = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
217
|
+
var S = /* @__PURE__ */ __name((t2, e = {}) => X(t2, ft, e).width, "S");
|
|
218
|
+
var W = "\x1B";
|
|
219
|
+
var Z = "\x9B";
|
|
220
|
+
var Ft = 39;
|
|
221
|
+
var j = "\x07";
|
|
222
|
+
var Q = "[";
|
|
223
|
+
var dt = "]";
|
|
224
|
+
var tt = "m";
|
|
225
|
+
var U = `${dt}8;;`;
|
|
226
|
+
var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
|
|
227
|
+
var mt = /* @__PURE__ */ __name((t2) => {
|
|
228
|
+
if (t2 >= 30 && t2 <= 37 || t2 >= 90 && t2 <= 97) return 39;
|
|
229
|
+
if (t2 >= 40 && t2 <= 47 || t2 >= 100 && t2 <= 107) return 49;
|
|
230
|
+
if (t2 === 1 || t2 === 2) return 22;
|
|
231
|
+
if (t2 === 3) return 23;
|
|
232
|
+
if (t2 === 4) return 24;
|
|
233
|
+
if (t2 === 7) return 27;
|
|
234
|
+
if (t2 === 8) return 28;
|
|
235
|
+
if (t2 === 9) return 29;
|
|
236
|
+
if (t2 === 0) return 0;
|
|
237
|
+
}, "mt");
|
|
238
|
+
var st = /* @__PURE__ */ __name((t2) => `${W}${Q}${t2}${tt}`, "st");
|
|
239
|
+
var it = /* @__PURE__ */ __name((t2) => `${W}${U}${t2}${j}`, "it");
|
|
240
|
+
var gt = /* @__PURE__ */ __name((t2) => t2.map((e) => S(e)), "gt");
|
|
241
|
+
var G = /* @__PURE__ */ __name((t2, e, s) => {
|
|
242
|
+
const i = e[Symbol.iterator]();
|
|
243
|
+
let r = false, n = false, u = t2.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
244
|
+
for (; !l.done; ) {
|
|
245
|
+
const m = l.value, A = S(m);
|
|
246
|
+
a + A <= s ? t2[t2.length - 1] += m : (t2.push(m), a = 0), (m === W || m === Z) && (r = true, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t2.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
247
|
+
}
|
|
248
|
+
u = t2.at(-1), !a && u !== void 0 && u.length > 0 && t2.length > 1 && (t2[t2.length - 2] += t2.pop());
|
|
249
|
+
}, "G");
|
|
250
|
+
var vt = /* @__PURE__ */ __name((t2) => {
|
|
251
|
+
const e = t2.split(" ");
|
|
252
|
+
let s = e.length;
|
|
253
|
+
for (; s > 0 && !(S(e[s - 1]) > 0); ) s--;
|
|
254
|
+
return s === e.length ? t2 : e.slice(0, s).join(" ") + e.slice(s).join("");
|
|
255
|
+
}, "vt");
|
|
256
|
+
var Et = /* @__PURE__ */ __name((t2, e, s = {}) => {
|
|
257
|
+
if (s.trim !== false && t2.trim() === "") return "";
|
|
258
|
+
let i = "", r, n;
|
|
259
|
+
const u = t2.split(" "), a = gt(u);
|
|
260
|
+
let l = [""];
|
|
261
|
+
for (const [h2, o] of u.entries()) {
|
|
262
|
+
s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
263
|
+
let f = S(l.at(-1) ?? "");
|
|
264
|
+
if (h2 !== 0 && (f >= e && (s.wordWrap === false || s.trim === false) && (l.push(""), f = 0), (f > 0 || s.trim === false) && (l[l.length - 1] += " ", f++)), s.hard && a[h2] > e) {
|
|
265
|
+
const v = e - f, F = 1 + Math.floor((a[h2] - v - 1) / e);
|
|
266
|
+
Math.floor((a[h2] - 1) / e) < F && l.push(""), G(l, o, e);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (f + a[h2] > e && f > 0 && a[h2] > 0) {
|
|
270
|
+
if (s.wordWrap === false && f < e) {
|
|
271
|
+
G(l, o, e);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
l.push("");
|
|
275
|
+
}
|
|
276
|
+
if (f + a[h2] > e && s.wordWrap === false) {
|
|
277
|
+
G(l, o, e);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
l[l.length - 1] += o;
|
|
281
|
+
}
|
|
282
|
+
s.trim !== false && (l = l.map((h2) => vt(h2)));
|
|
283
|
+
const E = l.join(`
|
|
284
|
+
`), g = E[Symbol.iterator]();
|
|
285
|
+
let m = g.next(), A = g.next(), V = 0;
|
|
286
|
+
for (; !m.done; ) {
|
|
287
|
+
const h2 = m.value, o = A.value;
|
|
288
|
+
if (i += h2, h2 === W || h2 === Z) {
|
|
289
|
+
et.lastIndex = V + 1;
|
|
290
|
+
const F = et.exec(E)?.groups;
|
|
291
|
+
if (F?.code !== void 0) {
|
|
292
|
+
const d = Number.parseFloat(F.code);
|
|
293
|
+
r = d === Ft ? void 0 : d;
|
|
294
|
+
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
295
|
+
}
|
|
296
|
+
const f = r ? mt(r) : void 0;
|
|
297
|
+
o === `
|
|
298
|
+
` ? (n && (i += it("")), r && f && (i += st(f))) : h2 === `
|
|
299
|
+
` && (r && f && (i += st(r)), n && (i += it(n))), V += h2.length, m = A, A = g.next();
|
|
300
|
+
}
|
|
301
|
+
return i;
|
|
302
|
+
}, "Et");
|
|
303
|
+
function K(t2, e, s) {
|
|
304
|
+
return String(t2).normalize().replaceAll(`\r
|
|
305
|
+
`, `
|
|
306
|
+
`).split(`
|
|
307
|
+
`).map((i) => Et(i, e, s)).join(`
|
|
308
|
+
`);
|
|
309
|
+
}
|
|
310
|
+
__name(K, "K");
|
|
311
|
+
var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
312
|
+
var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]])};
|
|
313
|
+
function H(t2, e) {
|
|
314
|
+
if (typeof t2 == "string") return _.aliases.get(t2) === e;
|
|
315
|
+
for (const s of t2) if (s !== void 0 && H(s, e)) return true;
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
__name(H, "H");
|
|
319
|
+
function _t(t2, e) {
|
|
320
|
+
if (t2 === e) return;
|
|
321
|
+
const s = t2.split(`
|
|
322
|
+
`), i = e.split(`
|
|
323
|
+
`), r = Math.max(s.length, i.length), n = [];
|
|
324
|
+
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
|
|
325
|
+
return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
|
|
326
|
+
}
|
|
327
|
+
__name(_t, "_t");
|
|
328
|
+
globalThis.process.platform.startsWith("win");
|
|
329
|
+
var z = /* @__PURE__ */ Symbol("clack:cancel");
|
|
330
|
+
function Ct(t2) {
|
|
331
|
+
return t2 === z;
|
|
332
|
+
}
|
|
333
|
+
__name(Ct, "Ct");
|
|
334
|
+
function T(t2, e) {
|
|
335
|
+
const s = t2;
|
|
336
|
+
s.isTTY && s.setRawMode(e);
|
|
337
|
+
}
|
|
338
|
+
__name(T, "T");
|
|
339
|
+
var rt = /* @__PURE__ */ __name((t2) => "columns" in t2 && typeof t2.columns == "number" ? t2.columns : 80, "rt");
|
|
340
|
+
var nt = /* @__PURE__ */ __name((t2) => "rows" in t2 && typeof t2.rows == "number" ? t2.rows : 20, "nt");
|
|
341
|
+
function Bt(t2, e, s, i = s) {
|
|
342
|
+
const r = rt(t2 ?? stdout);
|
|
343
|
+
return K(e, r - s.length, { hard: true, trim: false }).split(`
|
|
344
|
+
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
|
|
345
|
+
`);
|
|
346
|
+
}
|
|
347
|
+
__name(Bt, "Bt");
|
|
348
|
+
var x = class {
|
|
349
|
+
static {
|
|
350
|
+
__name(this, "x");
|
|
351
|
+
}
|
|
352
|
+
input;
|
|
353
|
+
output;
|
|
354
|
+
_abortSignal;
|
|
355
|
+
rl;
|
|
356
|
+
opts;
|
|
357
|
+
_render;
|
|
358
|
+
_track = false;
|
|
359
|
+
_prevFrame = "";
|
|
360
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
361
|
+
_cursor = 0;
|
|
362
|
+
state = "initial";
|
|
363
|
+
error = "";
|
|
364
|
+
value;
|
|
365
|
+
userInput = "";
|
|
366
|
+
constructor(e, s = true) {
|
|
367
|
+
const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
|
|
368
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
|
|
369
|
+
}
|
|
370
|
+
unsubscribe() {
|
|
371
|
+
this._subscribers.clear();
|
|
372
|
+
}
|
|
373
|
+
setSubscriber(e, s) {
|
|
374
|
+
const i = this._subscribers.get(e) ?? [];
|
|
375
|
+
i.push(s), this._subscribers.set(e, i);
|
|
376
|
+
}
|
|
377
|
+
on(e, s) {
|
|
378
|
+
this.setSubscriber(e, { cb: s });
|
|
379
|
+
}
|
|
380
|
+
once(e, s) {
|
|
381
|
+
this.setSubscriber(e, { cb: s, once: true });
|
|
382
|
+
}
|
|
383
|
+
emit(e, ...s) {
|
|
384
|
+
const i = this._subscribers.get(e) ?? [], r = [];
|
|
385
|
+
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
386
|
+
for (const n of r) n();
|
|
387
|
+
}
|
|
388
|
+
prompt() {
|
|
389
|
+
return new Promise((e) => {
|
|
390
|
+
if (this._abortSignal) {
|
|
391
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z);
|
|
392
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
393
|
+
this.state = "cancel", this.close();
|
|
394
|
+
}, { once: true });
|
|
395
|
+
}
|
|
396
|
+
this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), T(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
397
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e(this.value);
|
|
398
|
+
}), this.once("cancel", () => {
|
|
399
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e(z);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
_isActionKey(e, s) {
|
|
404
|
+
return e === " ";
|
|
405
|
+
}
|
|
406
|
+
_setValue(e) {
|
|
407
|
+
this.value = e, this.emit("value", this.value);
|
|
408
|
+
}
|
|
409
|
+
_setUserInput(e, s) {
|
|
410
|
+
this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
411
|
+
}
|
|
412
|
+
_clearUserInput() {
|
|
413
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
414
|
+
}
|
|
415
|
+
onKeypress(e, s) {
|
|
416
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
|
|
417
|
+
if (this.opts.validate) {
|
|
418
|
+
const i = this.opts.validate(this.value);
|
|
419
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
420
|
+
}
|
|
421
|
+
this.state !== "error" && (this.state = "submit");
|
|
422
|
+
}
|
|
423
|
+
H([e, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
424
|
+
}
|
|
425
|
+
close() {
|
|
426
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
427
|
+
`), T(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
428
|
+
}
|
|
429
|
+
restoreCursor() {
|
|
430
|
+
const e = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
431
|
+
`).length - 1;
|
|
432
|
+
this.output.write(import_sisteransi.cursor.move(-999, e * -1));
|
|
433
|
+
}
|
|
434
|
+
render() {
|
|
435
|
+
const e = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
436
|
+
if (e !== this._prevFrame) {
|
|
437
|
+
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
438
|
+
else {
|
|
439
|
+
const s = _t(this._prevFrame, e), i = nt(this.output);
|
|
440
|
+
if (this.restoreCursor(), s) {
|
|
441
|
+
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
|
|
442
|
+
let u = s.lines.find((a) => a >= r);
|
|
443
|
+
if (u === void 0) {
|
|
444
|
+
this._prevFrame = e;
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (s.lines.length === 1) {
|
|
448
|
+
this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
449
|
+
const a = e.split(`
|
|
450
|
+
`);
|
|
451
|
+
this.output.write(a[u]), this._prevFrame = e, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
|
|
452
|
+
return;
|
|
453
|
+
} else if (s.lines.length > 1) {
|
|
454
|
+
if (r < n) u = r;
|
|
455
|
+
else {
|
|
456
|
+
const l = u - n;
|
|
457
|
+
l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
|
|
458
|
+
}
|
|
459
|
+
this.output.write(import_sisteransi.erase.down());
|
|
460
|
+
const a = e.split(`
|
|
461
|
+
`).slice(u);
|
|
462
|
+
this.output.write(a.join(`
|
|
463
|
+
`)), this._prevFrame = e;
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
this.output.write(import_sisteransi.erase.down());
|
|
468
|
+
}
|
|
469
|
+
this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
var kt = class extends x {
|
|
474
|
+
static {
|
|
475
|
+
__name(this, "kt");
|
|
476
|
+
}
|
|
477
|
+
get cursor() {
|
|
478
|
+
return this.value ? 0 : 1;
|
|
479
|
+
}
|
|
480
|
+
get _value() {
|
|
481
|
+
return this.cursor === 0;
|
|
482
|
+
}
|
|
483
|
+
constructor(e) {
|
|
484
|
+
super(e, false), this.value = !!e.initialValue, this.on("userInput", () => {
|
|
485
|
+
this.value = this._value;
|
|
486
|
+
}), this.on("confirm", (s) => {
|
|
487
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
488
|
+
}), this.on("cursor", () => {
|
|
489
|
+
this.value = !this.value;
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
function D(t2, e, s) {
|
|
494
|
+
const i = t2 + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
495
|
+
return s[n].disabled ? D(n, e < 0 ? -1 : 1, s) : n;
|
|
496
|
+
}
|
|
497
|
+
__name(D, "D");
|
|
498
|
+
var Mt = class extends x {
|
|
499
|
+
static {
|
|
500
|
+
__name(this, "Mt");
|
|
501
|
+
}
|
|
502
|
+
options;
|
|
503
|
+
cursor = 0;
|
|
504
|
+
get _value() {
|
|
505
|
+
return this.options[this.cursor].value;
|
|
506
|
+
}
|
|
507
|
+
get _enabledOptions() {
|
|
508
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
509
|
+
}
|
|
510
|
+
toggleAll() {
|
|
511
|
+
const e = this._enabledOptions, s = this.value !== void 0 && this.value.length === e.length;
|
|
512
|
+
this.value = s ? [] : e.map((i) => i.value);
|
|
513
|
+
}
|
|
514
|
+
toggleInvert() {
|
|
515
|
+
const e = this.value;
|
|
516
|
+
if (!e) return;
|
|
517
|
+
const s = this._enabledOptions.filter((i) => !e.includes(i.value));
|
|
518
|
+
this.value = s.map((i) => i.value);
|
|
519
|
+
}
|
|
520
|
+
toggleValue() {
|
|
521
|
+
this.value === void 0 && (this.value = []);
|
|
522
|
+
const e = this.value.includes(this._value);
|
|
523
|
+
this.value = e ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
524
|
+
}
|
|
525
|
+
constructor(e) {
|
|
526
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
527
|
+
const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
|
|
528
|
+
this.cursor = this.options[s].disabled ? D(s, 1, this.options) : s, this.on("key", (i) => {
|
|
529
|
+
i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
|
|
530
|
+
}), this.on("cursor", (i) => {
|
|
531
|
+
switch (i) {
|
|
532
|
+
case "left":
|
|
533
|
+
case "up":
|
|
534
|
+
this.cursor = D(this.cursor, -1, this.options);
|
|
535
|
+
break;
|
|
536
|
+
case "down":
|
|
537
|
+
case "right":
|
|
538
|
+
this.cursor = D(this.cursor, 1, this.options);
|
|
539
|
+
break;
|
|
540
|
+
case "space":
|
|
541
|
+
this.toggleValue();
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
var Wt = class extends x {
|
|
548
|
+
static {
|
|
549
|
+
__name(this, "Wt");
|
|
550
|
+
}
|
|
551
|
+
options;
|
|
552
|
+
cursor = 0;
|
|
553
|
+
get _selectedValue() {
|
|
554
|
+
return this.options[this.cursor];
|
|
555
|
+
}
|
|
556
|
+
changeValue() {
|
|
557
|
+
this.value = this._selectedValue.value;
|
|
558
|
+
}
|
|
559
|
+
constructor(e) {
|
|
560
|
+
super(e, false), this.options = e.options;
|
|
561
|
+
const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
|
|
562
|
+
this.cursor = this.options[i].disabled ? D(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
|
|
563
|
+
switch (r) {
|
|
564
|
+
case "left":
|
|
565
|
+
case "up":
|
|
566
|
+
this.cursor = D(this.cursor, -1, this.options);
|
|
567
|
+
break;
|
|
568
|
+
case "down":
|
|
569
|
+
case "right":
|
|
570
|
+
this.cursor = D(this.cursor, 1, this.options);
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
this.changeValue();
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
// ../../node_modules/.pnpm/@clack+prompts@1.0.0/node_modules/@clack/prompts/dist/index.mjs
|
|
579
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
580
|
+
__toESM(require_src(), 1);
|
|
581
|
+
function ht2() {
|
|
582
|
+
return P2.platform !== "win32" ? P2.env.TERM !== "linux" : !!P2.env.CI || !!P2.env.WT_SESSION || !!P2.env.TERMINUS_SUBLIME || P2.env.ConEmuTask === "{cmd::Cmder}" || P2.env.TERM_PROGRAM === "Terminus-Sublime" || P2.env.TERM_PROGRAM === "vscode" || P2.env.TERM === "xterm-256color" || P2.env.TERM === "alacritty" || P2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
583
|
+
}
|
|
584
|
+
__name(ht2, "ht");
|
|
585
|
+
var ee = ht2();
|
|
586
|
+
var w = /* @__PURE__ */ __name((e, r) => ee ? e : r, "w");
|
|
587
|
+
var Me = w("\u25C6", "*");
|
|
588
|
+
var ce = w("\u25A0", "x");
|
|
589
|
+
var de = w("\u25B2", "x");
|
|
590
|
+
var k2 = w("\u25C7", "o");
|
|
591
|
+
w("\u250C", "T");
|
|
592
|
+
var h = w("\u2502", "|");
|
|
593
|
+
var x2 = w("\u2514", "\u2014");
|
|
594
|
+
w("\u2510", "T");
|
|
595
|
+
w("\u2518", "\u2014");
|
|
596
|
+
var Y = w("\u25CF", ">");
|
|
597
|
+
var K2 = w("\u25CB", " ");
|
|
598
|
+
w("\u25FB", "[\u2022]");
|
|
599
|
+
w("\u25FC", "[+]");
|
|
600
|
+
w("\u25FB", "[ ]");
|
|
601
|
+
w("\u25AA", "\u2022");
|
|
602
|
+
w("\u2500", "-");
|
|
603
|
+
w("\u256E", "+");
|
|
604
|
+
w("\u251C", "+");
|
|
605
|
+
w("\u256F", "+");
|
|
606
|
+
w("\u2570", "+");
|
|
607
|
+
w("\u256D", "+");
|
|
608
|
+
w("\u25CF", "\u2022");
|
|
609
|
+
w("\u25C6", "*");
|
|
610
|
+
w("\u25B2", "!");
|
|
611
|
+
w("\u25A0", "x");
|
|
612
|
+
var N2 = /* @__PURE__ */ __name((e) => {
|
|
613
|
+
switch (e) {
|
|
614
|
+
case "initial":
|
|
615
|
+
case "active":
|
|
616
|
+
return import_picocolors.default.cyan(Me);
|
|
617
|
+
case "cancel":
|
|
618
|
+
return import_picocolors.default.red(ce);
|
|
619
|
+
case "error":
|
|
620
|
+
return import_picocolors.default.yellow(de);
|
|
621
|
+
case "submit":
|
|
622
|
+
return import_picocolors.default.green(k2);
|
|
623
|
+
}
|
|
624
|
+
}, "N");
|
|
625
|
+
var Ee = /* @__PURE__ */ __name((e) => {
|
|
626
|
+
switch (e) {
|
|
627
|
+
case "initial":
|
|
628
|
+
case "active":
|
|
629
|
+
return import_picocolors.default.cyan(h);
|
|
630
|
+
case "cancel":
|
|
631
|
+
return import_picocolors.default.red(h);
|
|
632
|
+
case "error":
|
|
633
|
+
return import_picocolors.default.yellow(h);
|
|
634
|
+
case "submit":
|
|
635
|
+
return import_picocolors.default.green(h);
|
|
636
|
+
}
|
|
637
|
+
}, "Ee");
|
|
638
|
+
var mt2 = /* @__PURE__ */ __name((e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, "mt");
|
|
639
|
+
var pt2 = /* @__PURE__ */ __name((e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, "pt");
|
|
640
|
+
var gt2 = /* @__PURE__ */ __name((e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, "gt");
|
|
641
|
+
var ve = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
642
|
+
var re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
643
|
+
var ie = /\t{1,1000}/y;
|
|
644
|
+
var Ae = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
645
|
+
var ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
646
|
+
var ft2 = new RegExp("\\p{M}+", "gu");
|
|
647
|
+
var Ft2 = { limit: 1 / 0, ellipsis: "" };
|
|
648
|
+
var Le = /* @__PURE__ */ __name((e, r = {}, s = {}) => {
|
|
649
|
+
const i = r.limit ?? 1 / 0, n = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (n ? Le(n, Ft2, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, a = s.tabWidth ?? 8, d = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, E = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, y2 = s.wideWidth ?? 2;
|
|
650
|
+
let $ = 0, c = 0, m = e.length, f = 0, F = false, v = m, S2 = Math.max(0, i - o), B = 0, b = 0, A = 0, C = 0;
|
|
651
|
+
e: for (; ; ) {
|
|
652
|
+
if (b > B || c >= m && c > $) {
|
|
653
|
+
const _3 = e.slice(B, b) || e.slice($, c);
|
|
654
|
+
f = 0;
|
|
655
|
+
for (const D2 of _3.replaceAll(ft2, "")) {
|
|
656
|
+
const T2 = D2.codePointAt(0) || 0;
|
|
657
|
+
if (pt2(T2) ? C = E : gt2(T2) ? C = y2 : d !== p && mt2(T2) ? C = d : C = p, A + C > S2 && (v = Math.min(v, Math.max(B, $) + f)), A + C > i) {
|
|
658
|
+
F = true;
|
|
659
|
+
break e;
|
|
660
|
+
}
|
|
661
|
+
f += D2.length, A += C;
|
|
662
|
+
}
|
|
663
|
+
B = b = 0;
|
|
664
|
+
}
|
|
665
|
+
if (c >= m) break;
|
|
666
|
+
if (ne.lastIndex = c, ne.test(e)) {
|
|
667
|
+
if (f = ne.lastIndex - c, C = f * p, A + C > S2 && (v = Math.min(v, c + Math.floor((S2 - A) / p))), A + C > i) {
|
|
668
|
+
F = true;
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
A += C, B = $, b = c, c = $ = ne.lastIndex;
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
if (ve.lastIndex = c, ve.test(e)) {
|
|
675
|
+
if (A + u > S2 && (v = Math.min(v, c)), A + u > i) {
|
|
676
|
+
F = true;
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
679
|
+
A += u, B = $, b = c, c = $ = ve.lastIndex;
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
if (re.lastIndex = c, re.test(e)) {
|
|
683
|
+
if (f = re.lastIndex - c, C = f * l, A + C > S2 && (v = Math.min(v, c + Math.floor((S2 - A) / l))), A + C > i) {
|
|
684
|
+
F = true;
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
A += C, B = $, b = c, c = $ = re.lastIndex;
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (ie.lastIndex = c, ie.test(e)) {
|
|
691
|
+
if (f = ie.lastIndex - c, C = f * a, A + C > S2 && (v = Math.min(v, c + Math.floor((S2 - A) / a))), A + C > i) {
|
|
692
|
+
F = true;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
A += C, B = $, b = c, c = $ = ie.lastIndex;
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
if (Ae.lastIndex = c, Ae.test(e)) {
|
|
699
|
+
if (A + g > S2 && (v = Math.min(v, c)), A + g > i) {
|
|
700
|
+
F = true;
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
A += g, B = $, b = c, c = $ = Ae.lastIndex;
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
c += 1;
|
|
707
|
+
}
|
|
708
|
+
return { width: F ? S2 : A, index: F ? v : m, truncated: F, ellipsed: F && i >= o };
|
|
709
|
+
}, "Le");
|
|
710
|
+
var yt2 = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
711
|
+
var M2 = /* @__PURE__ */ __name((e, r = {}) => Le(e, yt2, r).width, "M");
|
|
712
|
+
var ae = "\x1B";
|
|
713
|
+
var je = "\x9B";
|
|
714
|
+
var Et2 = 39;
|
|
715
|
+
var Ce = "\x07";
|
|
716
|
+
var Ve = "[";
|
|
717
|
+
var vt2 = "]";
|
|
718
|
+
var ke = "m";
|
|
719
|
+
var we = `${vt2}8;;`;
|
|
720
|
+
var Ge = new RegExp(`(?:\\${Ve}(?<code>\\d+)m|\\${we}(?<uri>.*)${Ce})`, "y");
|
|
721
|
+
var At2 = /* @__PURE__ */ __name((e) => {
|
|
722
|
+
if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
|
|
723
|
+
if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
|
|
724
|
+
if (e === 1 || e === 2) return 22;
|
|
725
|
+
if (e === 3) return 23;
|
|
726
|
+
if (e === 4) return 24;
|
|
727
|
+
if (e === 7) return 27;
|
|
728
|
+
if (e === 8) return 28;
|
|
729
|
+
if (e === 9) return 29;
|
|
730
|
+
if (e === 0) return 0;
|
|
731
|
+
}, "At");
|
|
732
|
+
var He = /* @__PURE__ */ __name((e) => `${ae}${Ve}${e}${ke}`, "He");
|
|
733
|
+
var Ue = /* @__PURE__ */ __name((e) => `${ae}${we}${e}${Ce}`, "Ue");
|
|
734
|
+
var Ct2 = /* @__PURE__ */ __name((e) => e.map((r) => M2(r)), "Ct");
|
|
735
|
+
var Se = /* @__PURE__ */ __name((e, r, s) => {
|
|
736
|
+
const i = r[Symbol.iterator]();
|
|
737
|
+
let n = false, o = false, u = e.at(-1), l = u === void 0 ? 0 : M2(u), a = i.next(), d = i.next(), g = 0;
|
|
738
|
+
for (; !a.done; ) {
|
|
739
|
+
const E = a.value, p = M2(E);
|
|
740
|
+
l + p <= s ? e[e.length - 1] += E : (e.push(E), l = 0), (E === ae || E === je) && (n = true, o = r.startsWith(we, g + 1)), n ? o ? E === Ce && (n = false, o = false) : E === ke && (n = false) : (l += p, l === s && !d.done && (e.push(""), l = 0)), a = d, d = i.next(), g += E.length;
|
|
741
|
+
}
|
|
742
|
+
u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
|
|
743
|
+
}, "Se");
|
|
744
|
+
var wt = /* @__PURE__ */ __name((e) => {
|
|
745
|
+
const r = e.split(" ");
|
|
746
|
+
let s = r.length;
|
|
747
|
+
for (; s > 0 && !(M2(r[s - 1]) > 0); ) s--;
|
|
748
|
+
return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
749
|
+
}, "wt");
|
|
750
|
+
var St = /* @__PURE__ */ __name((e, r, s = {}) => {
|
|
751
|
+
if (s.trim !== false && e.trim() === "") return "";
|
|
752
|
+
let i = "", n, o;
|
|
753
|
+
const u = e.split(" "), l = Ct2(u);
|
|
754
|
+
let a = [""];
|
|
755
|
+
for (const [$, c] of u.entries()) {
|
|
756
|
+
s.trim !== false && (a[a.length - 1] = (a.at(-1) ?? "").trimStart());
|
|
757
|
+
let m = M2(a.at(-1) ?? "");
|
|
758
|
+
if ($ !== 0 && (m >= r && (s.wordWrap === false || s.trim === false) && (a.push(""), m = 0), (m > 0 || s.trim === false) && (a[a.length - 1] += " ", m++)), s.hard && l[$] > r) {
|
|
759
|
+
const f = r - m, F = 1 + Math.floor((l[$] - f - 1) / r);
|
|
760
|
+
Math.floor((l[$] - 1) / r) < F && a.push(""), Se(a, c, r);
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
if (m + l[$] > r && m > 0 && l[$] > 0) {
|
|
764
|
+
if (s.wordWrap === false && m < r) {
|
|
765
|
+
Se(a, c, r);
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
a.push("");
|
|
769
|
+
}
|
|
770
|
+
if (m + l[$] > r && s.wordWrap === false) {
|
|
771
|
+
Se(a, c, r);
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
a[a.length - 1] += c;
|
|
775
|
+
}
|
|
776
|
+
s.trim !== false && (a = a.map(($) => wt($)));
|
|
777
|
+
const d = a.join(`
|
|
778
|
+
`), g = d[Symbol.iterator]();
|
|
779
|
+
let E = g.next(), p = g.next(), y2 = 0;
|
|
780
|
+
for (; !E.done; ) {
|
|
781
|
+
const $ = E.value, c = p.value;
|
|
782
|
+
if (i += $, $ === ae || $ === je) {
|
|
783
|
+
Ge.lastIndex = y2 + 1;
|
|
784
|
+
const F = Ge.exec(d)?.groups;
|
|
785
|
+
if (F?.code !== void 0) {
|
|
786
|
+
const v = Number.parseFloat(F.code);
|
|
787
|
+
n = v === Et2 ? void 0 : v;
|
|
788
|
+
} else F?.uri !== void 0 && (o = F.uri.length === 0 ? void 0 : F.uri);
|
|
789
|
+
}
|
|
790
|
+
const m = n ? At2(n) : void 0;
|
|
791
|
+
c === `
|
|
792
|
+
` ? (o && (i += Ue("")), n && m && (i += He(m))) : $ === `
|
|
793
|
+
` && (n && m && (i += He(n)), o && (i += Ue(o))), y2 += $.length, E = p, p = g.next();
|
|
794
|
+
}
|
|
795
|
+
return i;
|
|
796
|
+
}, "St");
|
|
797
|
+
function q2(e, r, s) {
|
|
798
|
+
return String(e).normalize().replaceAll(`\r
|
|
799
|
+
`, `
|
|
800
|
+
`).split(`
|
|
801
|
+
`).map((i) => St(i, r, s)).join(`
|
|
802
|
+
`);
|
|
803
|
+
}
|
|
804
|
+
__name(q2, "q");
|
|
805
|
+
var It2 = /* @__PURE__ */ __name((e, r, s, i, n) => {
|
|
806
|
+
let o = r, u = 0;
|
|
807
|
+
for (let l = s; l < i; l++) {
|
|
808
|
+
const a = e[l];
|
|
809
|
+
if (o = o - a.length, u++, o <= n) break;
|
|
810
|
+
}
|
|
811
|
+
return { lineCount: o, removals: u };
|
|
812
|
+
}, "It");
|
|
813
|
+
var J2 = /* @__PURE__ */ __name((e) => {
|
|
814
|
+
const { cursor: r, options: s, style: i } = e, n = e.output ?? process.stdout, o = rt(n), u = e.columnPadding ?? 0, l = e.rowPadding ?? 4, a = o - u, d = nt(n), g = import_picocolors.default.dim("..."), E = e.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(d - l, 0), y2 = Math.max(Math.min(E, p), 5);
|
|
815
|
+
let $ = 0;
|
|
816
|
+
r >= y2 - 3 && ($ = Math.max(Math.min(r - y2 + 3, s.length - y2), 0));
|
|
817
|
+
let c = y2 < s.length && $ > 0, m = y2 < s.length && $ + y2 < s.length;
|
|
818
|
+
const f = Math.min($ + y2, s.length), F = [];
|
|
819
|
+
let v = 0;
|
|
820
|
+
c && v++, m && v++;
|
|
821
|
+
const S2 = $ + (c ? 1 : 0), B = f - (m ? 1 : 0);
|
|
822
|
+
for (let A = S2; A < B; A++) {
|
|
823
|
+
const C = q2(i(s[A], A === r), a, { hard: true, trim: false }).split(`
|
|
824
|
+
`);
|
|
825
|
+
F.push(C), v += C.length;
|
|
826
|
+
}
|
|
827
|
+
if (v > p) {
|
|
828
|
+
let A = 0, C = 0, _3 = v;
|
|
829
|
+
const D2 = r - S2, T2 = /* @__PURE__ */ __name((W2, I2) => It2(F, _3, W2, I2, p), "T");
|
|
830
|
+
c ? ({ lineCount: _3, removals: A } = T2(0, D2), _3 > p && ({ lineCount: _3, removals: C } = T2(D2 + 1, F.length))) : ({ lineCount: _3, removals: C } = T2(D2 + 1, F.length), _3 > p && ({ lineCount: _3, removals: A } = T2(0, D2))), A > 0 && (c = true, F.splice(0, A)), C > 0 && (m = true, F.splice(F.length - C, C));
|
|
831
|
+
}
|
|
832
|
+
const b = [];
|
|
833
|
+
c && b.push(g);
|
|
834
|
+
for (const A of F) for (const C of A) b.push(C);
|
|
835
|
+
return m && b.push(g), b;
|
|
836
|
+
}, "J");
|
|
837
|
+
import_picocolors.default.magenta;
|
|
838
|
+
({ light: w("\u2500", "-"), heavy: w("\u2501", "="), block: w("\u2588", "#") });
|
|
839
|
+
var oe = /* @__PURE__ */ __name((e, r) => e.includes(`
|
|
840
|
+
`) ? e.split(`
|
|
841
|
+
`).map((s) => r(s)).join(`
|
|
842
|
+
`) : r(e), "oe");
|
|
843
|
+
var qt = /* @__PURE__ */ __name((e) => {
|
|
844
|
+
const r = /* @__PURE__ */ __name((s, i) => {
|
|
845
|
+
const n = s.label ?? String(s.value);
|
|
846
|
+
switch (i) {
|
|
847
|
+
case "disabled":
|
|
848
|
+
return `${import_picocolors.default.gray(K2)} ${oe(n, import_picocolors.default.gray)}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
849
|
+
case "selected":
|
|
850
|
+
return `${oe(n, import_picocolors.default.dim)}`;
|
|
851
|
+
case "active":
|
|
852
|
+
return `${import_picocolors.default.green(Y)} ${n}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
|
|
853
|
+
case "cancelled":
|
|
854
|
+
return `${oe(n, (o) => import_picocolors.default.strikethrough(import_picocolors.default.dim(o)))}`;
|
|
855
|
+
default:
|
|
856
|
+
return `${import_picocolors.default.dim(K2)} ${oe(n, import_picocolors.default.dim)}`;
|
|
857
|
+
}
|
|
858
|
+
}, "r");
|
|
859
|
+
return new Wt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
|
|
860
|
+
const s = `${N2(this.state)} `, i = `${Ee(this.state)} `, n = Bt(e.output, e.message, i, s), o = `${import_picocolors.default.gray(h)}
|
|
861
|
+
${n}
|
|
862
|
+
`;
|
|
863
|
+
switch (this.state) {
|
|
864
|
+
case "submit": {
|
|
865
|
+
const u = `${import_picocolors.default.gray(h)} `, l = Bt(e.output, r(this.options[this.cursor], "selected"), u);
|
|
866
|
+
return `${o}${l}`;
|
|
867
|
+
}
|
|
868
|
+
case "cancel": {
|
|
869
|
+
const u = `${import_picocolors.default.gray(h)} `, l = Bt(e.output, r(this.options[this.cursor], "cancelled"), u);
|
|
870
|
+
return `${o}${l}
|
|
871
|
+
${import_picocolors.default.gray(h)}`;
|
|
872
|
+
}
|
|
873
|
+
default: {
|
|
874
|
+
const u = `${import_picocolors.default.cyan(h)} `, l = o.split(`
|
|
875
|
+
`).length;
|
|
876
|
+
return `${o}${u}${J2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: u.length, rowPadding: l + 2, style: /* @__PURE__ */ __name((a, d) => r(a, a.disabled ? "disabled" : d ? "active" : "inactive"), "style") }).join(`
|
|
877
|
+
${u}`)}
|
|
878
|
+
${import_picocolors.default.cyan(x2)}
|
|
879
|
+
`;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
} }).prompt();
|
|
883
|
+
}, "qt");
|
|
884
|
+
`${import_picocolors.default.gray(h)} `;
|
|
885
|
+
var ExecError = class extends Error {
|
|
886
|
+
constructor(exitCode, signal, data = "command gave no output") {
|
|
887
|
+
super(data);
|
|
888
|
+
this.exitCode = exitCode;
|
|
889
|
+
this.signal = signal;
|
|
890
|
+
this.data = data;
|
|
891
|
+
}
|
|
892
|
+
static {
|
|
893
|
+
__name(this, "ExecError");
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
function spawnAsyncHelper(command, args, spawnOptions) {
|
|
897
|
+
const childProcess = spawn(command, args, spawnOptions || {});
|
|
898
|
+
const deferred = new Promise((resolve, reject) => {
|
|
899
|
+
let stdoutData = "";
|
|
900
|
+
let stderrData = "";
|
|
901
|
+
childProcess.stdout?.on("data", (data) => {
|
|
902
|
+
stdoutData += data.toString();
|
|
903
|
+
});
|
|
904
|
+
childProcess.stderr?.on("data", (data) => {
|
|
905
|
+
stderrData += data.toString();
|
|
906
|
+
});
|
|
907
|
+
childProcess.stdout?.on("error", (err) => {
|
|
908
|
+
reject(err);
|
|
909
|
+
});
|
|
910
|
+
childProcess.stderr?.on("error", (err) => {
|
|
911
|
+
reject(err);
|
|
912
|
+
});
|
|
913
|
+
childProcess.on("error", (err) => {
|
|
914
|
+
reject(err);
|
|
915
|
+
});
|
|
916
|
+
childProcess.on("exit", (exitCode, signal) => {
|
|
917
|
+
if (!exitCode) {
|
|
918
|
+
resolve(stdoutData);
|
|
919
|
+
} else {
|
|
920
|
+
reject(
|
|
921
|
+
new ExecError(exitCode, signal, stderrData)
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
return { childProcess, execResult: deferred };
|
|
927
|
+
}
|
|
928
|
+
__name(spawnAsyncHelper, "spawnAsyncHelper");
|
|
929
|
+
async function spawnAsync(command, args, opts) {
|
|
930
|
+
const { execResult } = spawnAsyncHelper(command, args, opts);
|
|
931
|
+
return execResult;
|
|
932
|
+
}
|
|
933
|
+
__name(spawnAsync, "spawnAsync");
|
|
934
|
+
promisify(exec);
|
|
935
|
+
async function checkIsFileGitIgnored(path3, warnIfNotGitRepo = false) {
|
|
936
|
+
try {
|
|
937
|
+
await spawnAsync("git", ["check-ignore", path3, "-q"], { cwd: dirname(path3) });
|
|
938
|
+
return true;
|
|
939
|
+
} catch (err) {
|
|
940
|
+
const errorOutput = err.data;
|
|
941
|
+
if (err.exitCode === 127 || errorOutput.includes("not found") || errorOutput.includes("not recognized")) {
|
|
942
|
+
return void 0;
|
|
943
|
+
}
|
|
944
|
+
if (err.code === "ENOENT") return void 0;
|
|
945
|
+
if (errorOutput === "") return false;
|
|
946
|
+
if (errorOutput.includes("not a git repository")) {
|
|
947
|
+
if (warnIfNotGitRepo) {
|
|
948
|
+
console.log("\u{1F536} Your code is not currently in a git repository - run `git init` to initialize a new repo.");
|
|
949
|
+
}
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
if (stderr.includes("is outside repository")) {
|
|
953
|
+
return void 0;
|
|
954
|
+
}
|
|
955
|
+
throw err;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
__name(checkIsFileGitIgnored, "checkIsFileGitIgnored");
|
|
959
|
+
function isUnicodeSupported() {
|
|
960
|
+
const { env } = P2;
|
|
961
|
+
const { TERM, TERM_PROGRAM } = env;
|
|
962
|
+
if (P2.platform !== "win32") {
|
|
963
|
+
return TERM !== "linux";
|
|
964
|
+
}
|
|
965
|
+
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
966
|
+
}
|
|
967
|
+
__name(isUnicodeSupported, "isUnicodeSupported");
|
|
968
|
+
|
|
969
|
+
// src/cli/helpers/prompts.ts
|
|
970
|
+
var unicode = isUnicodeSupported();
|
|
971
|
+
var unicodeOr = /* @__PURE__ */ __name((c, fallback) => unicode ? c : fallback, "unicodeOr");
|
|
972
|
+
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
973
|
+
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
974
|
+
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
975
|
+
var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
|
|
976
|
+
unicodeOr("\u250C", "T");
|
|
977
|
+
var S_BAR = unicodeOr("\u2502", "|");
|
|
978
|
+
var S_BAR_END = unicodeOr("\u2514", "\u2014");
|
|
979
|
+
var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
|
|
980
|
+
var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
|
|
981
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
|
|
982
|
+
var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
|
|
983
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
|
|
984
|
+
unicodeOr("\u25AA", "\u2022");
|
|
985
|
+
unicodeOr("\u2500", "-");
|
|
986
|
+
unicodeOr("\u256E", "+");
|
|
987
|
+
unicodeOr("\u251C", "+");
|
|
988
|
+
unicodeOr("\u256F", "+");
|
|
989
|
+
unicodeOr("\u25CF", "\u2022");
|
|
990
|
+
unicodeOr("\u25C6", "*");
|
|
991
|
+
unicodeOr("\u25B2", "!");
|
|
992
|
+
unicodeOr("\u25A0", "x");
|
|
993
|
+
var symbol = /* @__PURE__ */ __name((state) => {
|
|
994
|
+
switch (state) {
|
|
995
|
+
case "initial":
|
|
996
|
+
case "active":
|
|
997
|
+
return ansis_default.cyan(S_STEP_ACTIVE);
|
|
998
|
+
case "cancel":
|
|
999
|
+
return ansis_default.red(S_STEP_CANCEL);
|
|
1000
|
+
case "error":
|
|
1001
|
+
return ansis_default.yellow(S_STEP_ERROR);
|
|
1002
|
+
case "submit":
|
|
1003
|
+
return ansis_default.green(S_STEP_SUBMIT);
|
|
1004
|
+
}
|
|
1005
|
+
}, "symbol");
|
|
1006
|
+
var limitOptions = /* @__PURE__ */ __name((params) => {
|
|
1007
|
+
const { cursor, options, style } = params;
|
|
1008
|
+
const output = params.output ?? process.stdout;
|
|
1009
|
+
const rows = output instanceof WriteStream && output.rows !== void 0 ? output.rows : 10;
|
|
1010
|
+
const paramMaxItems = params.maxItems ?? Number.POSITIVE_INFINITY;
|
|
1011
|
+
const outputMaxItems = Math.max(rows - 4, 0);
|
|
1012
|
+
const maxItems = Math.min(outputMaxItems, Math.max(paramMaxItems, 5));
|
|
1013
|
+
let slidingWindowLocation = 0;
|
|
1014
|
+
if (cursor >= slidingWindowLocation + maxItems - 3) {
|
|
1015
|
+
slidingWindowLocation = Math.max(Math.min(cursor - maxItems + 3, options.length - maxItems), 0);
|
|
1016
|
+
} else if (cursor < slidingWindowLocation + 2) {
|
|
1017
|
+
slidingWindowLocation = Math.max(cursor - 2, 0);
|
|
1018
|
+
}
|
|
1019
|
+
const shouldRenderTopEllipsis = maxItems < options.length && slidingWindowLocation > 0;
|
|
1020
|
+
const shouldRenderBottomEllipsis = maxItems < options.length && slidingWindowLocation + maxItems < options.length;
|
|
1021
|
+
return options.slice(slidingWindowLocation, slidingWindowLocation + maxItems).map((option, i, arr) => {
|
|
1022
|
+
const isTopLimit = i === 0 && shouldRenderTopEllipsis;
|
|
1023
|
+
const isBottomLimit = i === arr.length - 1 && shouldRenderBottomEllipsis;
|
|
1024
|
+
return isTopLimit || isBottomLimit ? ansis_default.dim("...") : style(option, i + slidingWindowLocation === cursor);
|
|
1025
|
+
});
|
|
1026
|
+
}, "limitOptions");
|
|
1027
|
+
var confirm = /* @__PURE__ */ __name((opts) => {
|
|
1028
|
+
const active = opts.active ?? "Yes";
|
|
1029
|
+
const inactive = opts.inactive ?? "No";
|
|
1030
|
+
return new kt({
|
|
1031
|
+
active,
|
|
1032
|
+
inactive,
|
|
1033
|
+
input: opts.input,
|
|
1034
|
+
output: opts.output,
|
|
1035
|
+
initialValue: opts.initialValue ?? true,
|
|
1036
|
+
render() {
|
|
1037
|
+
const title = `
|
|
1038
|
+
${symbol(this.state)} ${opts.message}
|
|
1039
|
+
`;
|
|
1040
|
+
const value = this.value ? active : inactive;
|
|
1041
|
+
switch (this.state) {
|
|
1042
|
+
case "submit":
|
|
1043
|
+
return `${title}\u200E ${ansis_default.dim(value)}`;
|
|
1044
|
+
case "cancel":
|
|
1045
|
+
return `${title}\u200E ${ansis_default.strikethrough(
|
|
1046
|
+
ansis_default.dim(value)
|
|
1047
|
+
)}
|
|
1048
|
+
`;
|
|
1049
|
+
default: {
|
|
1050
|
+
return `${title}\u200E ${this.value ? `${ansis_default.green(S_RADIO_ACTIVE)} ${active}` : `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(active)}`} ${ansis_default.dim("/")} ${!this.value ? `${ansis_default.green(S_RADIO_ACTIVE)} ${inactive}` : `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(inactive)}`}
|
|
1051
|
+
`;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}).prompt();
|
|
1056
|
+
}, "confirm");
|
|
1057
|
+
var select = /* @__PURE__ */ __name((opts) => {
|
|
1058
|
+
const opt = /* @__PURE__ */ __name((option, state) => {
|
|
1059
|
+
const label = option.label ?? String(option.value);
|
|
1060
|
+
switch (state) {
|
|
1061
|
+
case "selected":
|
|
1062
|
+
return `${ansis_default.dim(label)}`;
|
|
1063
|
+
case "active":
|
|
1064
|
+
return `${ansis_default.green(S_RADIO_ACTIVE)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1065
|
+
case "cancelled":
|
|
1066
|
+
return `${ansis_default.strikethrough(ansis_default.dim(label))}`;
|
|
1067
|
+
default:
|
|
1068
|
+
return `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(label)}`;
|
|
1069
|
+
}
|
|
1070
|
+
}, "opt");
|
|
1071
|
+
return new Wt({
|
|
1072
|
+
options: opts.options,
|
|
1073
|
+
input: opts.input,
|
|
1074
|
+
output: opts.output,
|
|
1075
|
+
initialValue: opts.initialValue,
|
|
1076
|
+
render() {
|
|
1077
|
+
const title = `${ansis_default.gray(S_BAR)}
|
|
1078
|
+
${symbol(this.state)} ${opts.message}
|
|
1079
|
+
`;
|
|
1080
|
+
switch (this.state) {
|
|
1081
|
+
case "submit":
|
|
1082
|
+
return `${title}${ansis_default.gray(S_BAR)} ${opt(this.options[this.cursor], "selected")}`;
|
|
1083
|
+
case "cancel":
|
|
1084
|
+
return `${title}${ansis_default.gray(S_BAR)} ${opt(
|
|
1085
|
+
this.options[this.cursor],
|
|
1086
|
+
"cancelled"
|
|
1087
|
+
)}
|
|
1088
|
+
${ansis_default.gray(S_BAR)}`;
|
|
1089
|
+
default: {
|
|
1090
|
+
return `${title}${ansis_default.cyan(S_BAR)} ${limitOptions({
|
|
1091
|
+
output: opts.output,
|
|
1092
|
+
cursor: this.cursor,
|
|
1093
|
+
options: this.options,
|
|
1094
|
+
maxItems: opts.maxItems,
|
|
1095
|
+
style: /* @__PURE__ */ __name((item, active) => opt(item, active ? "active" : "inactive"), "style")
|
|
1096
|
+
}).join(`
|
|
1097
|
+
${ansis_default.cyan(S_BAR)} `)}
|
|
1098
|
+
${ansis_default.cyan(S_BAR_END)}
|
|
1099
|
+
`;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}).prompt();
|
|
1104
|
+
}, "select");
|
|
1105
|
+
var multiselect = /* @__PURE__ */ __name((opts) => {
|
|
1106
|
+
const opt = /* @__PURE__ */ __name((option, state) => {
|
|
1107
|
+
const label = option.label ?? String(option.value);
|
|
1108
|
+
if (state === "active") {
|
|
1109
|
+
return `${ansis_default.cyan(S_CHECKBOX_ACTIVE)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1110
|
+
}
|
|
1111
|
+
if (state === "selected") {
|
|
1112
|
+
return `${ansis_default.green(S_CHECKBOX_SELECTED)} ${ansis_default.dim(label)} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1113
|
+
}
|
|
1114
|
+
if (state === "cancelled") {
|
|
1115
|
+
return `${ansis_default.strikethrough(ansis_default.dim(label))}`;
|
|
1116
|
+
}
|
|
1117
|
+
if (state === "active-selected") {
|
|
1118
|
+
return `${ansis_default.green(S_CHECKBOX_SELECTED)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1119
|
+
}
|
|
1120
|
+
if (state === "submitted") {
|
|
1121
|
+
return `${ansis_default.dim(label)}`;
|
|
1122
|
+
}
|
|
1123
|
+
return `${ansis_default.dim(S_CHECKBOX_INACTIVE)} ${ansis_default.dim(label)}`;
|
|
1124
|
+
}, "opt");
|
|
1125
|
+
return new Mt({
|
|
1126
|
+
options: opts.options,
|
|
1127
|
+
input: opts.input,
|
|
1128
|
+
output: opts.output,
|
|
1129
|
+
initialValues: opts.initialValues,
|
|
1130
|
+
required: opts.required ?? true,
|
|
1131
|
+
cursorAt: opts.cursorAt,
|
|
1132
|
+
validate(selected) {
|
|
1133
|
+
if (this.required && selected.length === 0) {
|
|
1134
|
+
return `Please select at least one option.
|
|
1135
|
+
${ansis_default.reset(
|
|
1136
|
+
ansis_default.dim(
|
|
1137
|
+
`Press ${ansis_default.gray(ansis_default.bgWhite(ansis_default.inverse(" space ")))} to select, ${ansis_default.gray(
|
|
1138
|
+
ansis_default.bgWhite(ansis_default.inverse(" enter "))
|
|
1139
|
+
)} to submit`
|
|
1140
|
+
)
|
|
1141
|
+
)}`;
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
render() {
|
|
1145
|
+
let title = `${ansis_default.gray(S_BAR)}
|
|
1146
|
+
${symbol(this.state)} ${opts.message}
|
|
1147
|
+
`;
|
|
1148
|
+
if (opts.details) title += `${ansis_default.gray(S_BAR)} ${opts.details}
|
|
1149
|
+
`;
|
|
1150
|
+
const styleOption = /* @__PURE__ */ __name((option, active) => {
|
|
1151
|
+
const selected = this.value.includes(option.value);
|
|
1152
|
+
if (active && selected) {
|
|
1153
|
+
return opt(option, "active-selected");
|
|
1154
|
+
}
|
|
1155
|
+
if (selected) {
|
|
1156
|
+
return opt(option, "selected");
|
|
1157
|
+
}
|
|
1158
|
+
return opt(option, active ? "active" : "inactive");
|
|
1159
|
+
}, "styleOption");
|
|
1160
|
+
switch (this.state) {
|
|
1161
|
+
case "submit": {
|
|
1162
|
+
return `${title}${ansis_default.gray(S_BAR)} ${this.options.filter(({ value }) => this.value.includes(value)).map((option) => opt(option, "submitted")).join(ansis_default.dim(", ")) || ansis_default.dim("none")}`;
|
|
1163
|
+
}
|
|
1164
|
+
case "cancel": {
|
|
1165
|
+
const label = this.options.filter(({ value }) => this.value.includes(value)).map((option) => opt(option, "cancelled")).join(ansis_default.dim(", "));
|
|
1166
|
+
return `${title}${ansis_default.gray(S_BAR)} ${label.trim() ? `${label}
|
|
1167
|
+
${ansis_default.gray(S_BAR)}` : ""}`;
|
|
1168
|
+
}
|
|
1169
|
+
case "error": {
|
|
1170
|
+
const footer = this.error.split("\n").map((ln, i) => i === 0 ? `${ansis_default.yellow(S_BAR_END)} ${ansis_default.yellow(ln)}` : ` ${ln}`).join("\n");
|
|
1171
|
+
return `${title + ansis_default.yellow(S_BAR)} ${limitOptions({
|
|
1172
|
+
output: opts.output,
|
|
1173
|
+
options: this.options,
|
|
1174
|
+
cursor: this.cursor,
|
|
1175
|
+
maxItems: opts.maxItems,
|
|
1176
|
+
style: styleOption
|
|
1177
|
+
}).join(`
|
|
1178
|
+
${ansis_default.yellow(S_BAR)} `)}
|
|
1179
|
+
${footer}
|
|
1180
|
+
`;
|
|
1181
|
+
}
|
|
1182
|
+
default: {
|
|
1183
|
+
return `${title}${ansis_default.cyan(S_BAR)} ${limitOptions({
|
|
1184
|
+
output: opts.output,
|
|
1185
|
+
options: this.options,
|
|
1186
|
+
cursor: this.cursor,
|
|
1187
|
+
maxItems: opts.maxItems,
|
|
1188
|
+
style: styleOption
|
|
1189
|
+
}).join(`
|
|
1190
|
+
${ansis_default.cyan(S_BAR)} `)}
|
|
1191
|
+
${ansis_default.cyan(S_BAR_END)}
|
|
1192
|
+
`;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}).prompt();
|
|
1197
|
+
}, "multiselect");
|
|
1198
|
+
var prompts = {
|
|
1199
|
+
confirm,
|
|
1200
|
+
select,
|
|
1201
|
+
multiselect
|
|
1202
|
+
};
|
|
1203
|
+
var prompts_default = prompts;
|
|
1204
|
+
var PUBLIC_PREFIXES = [
|
|
1205
|
+
"PUBLIC",
|
|
1206
|
+
"VITE",
|
|
1207
|
+
"NEXT_PUBLIC",
|
|
1208
|
+
"NUXT_PUBLIC"
|
|
1209
|
+
];
|
|
1210
|
+
var PUBLIC_KEYWORDS = ["PUBLIC"];
|
|
1211
|
+
var SENSITIVE_KEYWORDS = [
|
|
1212
|
+
"SECRET",
|
|
1213
|
+
"API_KEY",
|
|
1214
|
+
"PASSWORD",
|
|
1215
|
+
"TOKEN",
|
|
1216
|
+
"PRIVATE",
|
|
1217
|
+
"CREDENTIALS"
|
|
1218
|
+
];
|
|
1219
|
+
function isValidUrl(val) {
|
|
1220
|
+
try {
|
|
1221
|
+
const u = new URL(val);
|
|
1222
|
+
return true;
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
return false;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
__name(isValidUrl, "isValidUrl");
|
|
1228
|
+
var EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
1229
|
+
var VALID_NUMBER_REGEX = /^(0|([1-9][0-9]*))?(\.[0-9]+)?$/;
|
|
1230
|
+
function inferItemDecorators(file, itemKey, valueStr) {
|
|
1231
|
+
let itemIsPublic = false;
|
|
1232
|
+
if (PUBLIC_PREFIXES.some((prefix) => itemKey.startsWith(prefix))) itemIsPublic = true;
|
|
1233
|
+
if (PUBLIC_KEYWORDS.some((keyword) => itemKey.includes(keyword))) itemIsPublic = true;
|
|
1234
|
+
let itemIsSensitive = false;
|
|
1235
|
+
if (SENSITIVE_KEYWORDS.some((keyword) => itemKey.includes(keyword))) itemIsSensitive = true;
|
|
1236
|
+
if (itemIsPublic) ; else if (itemIsSensitive) {
|
|
1237
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "sensitive", "true");
|
|
1238
|
+
}
|
|
1239
|
+
if (itemKey === "PORT" || itemKey.endsWith("_PORT")) {
|
|
1240
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "port");
|
|
1241
|
+
} else if (itemKey.endsWith("_EMAIL")) {
|
|
1242
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "email");
|
|
1243
|
+
} else if (itemKey.endsWith("_URL") || itemKey.endsWith("_URI")) {
|
|
1244
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "url");
|
|
1245
|
+
} else if (valueStr) {
|
|
1246
|
+
if (valueStr.startsWith("<") && valueStr.endsWith(">")) {
|
|
1247
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "example", valueStr);
|
|
1248
|
+
}
|
|
1249
|
+
if (valueStr === "true" || valueStr === "false") {
|
|
1250
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "boolean");
|
|
1251
|
+
} else if (EMAIL_REGEX.test(valueStr)) {
|
|
1252
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "email");
|
|
1253
|
+
} else if (valueStr !== "0" && valueStr !== "1" && VALID_NUMBER_REGEX.test(valueStr)) {
|
|
1254
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "number");
|
|
1255
|
+
} else if (isValidUrl(valueStr)) {
|
|
1256
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "url");
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
__name(inferItemDecorators, "inferItemDecorators");
|
|
1261
|
+
function inferSchemaUpdates(file) {
|
|
1262
|
+
for (const item of file.configItems) {
|
|
1263
|
+
const valueStr = item.value instanceof ParsedEnvSpecStaticValue && item.value.value?.toString() || "";
|
|
1264
|
+
inferItemDecorators(file, item.key, valueStr);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
__name(inferSchemaUpdates, "inferSchemaUpdates");
|
|
1268
|
+
function ensureAllItemsExist(schemaFile, otherFiles) {
|
|
1269
|
+
const addedItemKeys = [];
|
|
1270
|
+
for (const otherFile of otherFiles) {
|
|
1271
|
+
for (const item of otherFile.parsedFile.configItems) {
|
|
1272
|
+
const itemInSchema = schemaFile.configItems.find((i) => i.key === item.key);
|
|
1273
|
+
if (itemInSchema) continue;
|
|
1274
|
+
if (addedItemKeys.length === 0) {
|
|
1275
|
+
envSpecUpdater.injectFromStr(schemaFile, [
|
|
1276
|
+
"",
|
|
1277
|
+
"# items added to schema by `varlock init`",
|
|
1278
|
+
"# that were missing in example, but detected in other .env files",
|
|
1279
|
+
"# PLEASE REVIEW THESE!",
|
|
1280
|
+
"# ---",
|
|
1281
|
+
""
|
|
1282
|
+
].join("\n"), { location: "end" });
|
|
1283
|
+
}
|
|
1284
|
+
addedItemKeys.push(item.key);
|
|
1285
|
+
envSpecUpdater.injectFromStr(schemaFile, `${item.key}=`);
|
|
1286
|
+
const itemValue = item.value instanceof ParsedEnvSpecStaticValue && item.value.value?.toString() || "";
|
|
1287
|
+
inferItemDecorators(schemaFile, item.key, String(itemValue));
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
__name(ensureAllItemsExist, "ensureAllItemsExist");
|
|
1292
|
+
async function detectRedundantValues(schemaFile, otherFiles, opts = {}) {
|
|
1293
|
+
const redundantItemsBySourcePath = {};
|
|
1294
|
+
const schemaValues = schemaFile.toSimpleObj();
|
|
1295
|
+
for (const otherFile of Object.values(otherFiles)) {
|
|
1296
|
+
if (otherFile.fileName.startsWith(".env.schema") || otherFile.fileName.startsWith(".env.example") || otherFile.fileName.startsWith(".env.sample") || otherFile.fileName.startsWith(".env.default")) continue;
|
|
1297
|
+
const otherFileValues = otherFile.parsedFile.toSimpleObj();
|
|
1298
|
+
for (const itemKey in otherFileValues) {
|
|
1299
|
+
if (!(itemKey in schemaValues)) continue;
|
|
1300
|
+
if (otherFileValues[itemKey] !== schemaValues[itemKey]) continue;
|
|
1301
|
+
redundantItemsBySourcePath[otherFile.fullPath] ||= [];
|
|
1302
|
+
redundantItemsBySourcePath[otherFile.fullPath].push(itemKey);
|
|
1303
|
+
if (opts.delete) {
|
|
1304
|
+
envSpecUpdater.deleteItem(otherFile.parsedFile, itemKey);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
if (opts.delete) {
|
|
1308
|
+
await fs3.writeFile(otherFile.fullPath, otherFile.parsedFile.toString(), "utf8");
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return redundantItemsBySourcePath;
|
|
1312
|
+
}
|
|
1313
|
+
__name(detectRedundantValues, "detectRedundantValues");
|
|
1314
|
+
var SKIP_FILE_TYPES = [".md", ".d.ts"];
|
|
1315
|
+
async function findEnvFiles(opts) {
|
|
1316
|
+
const cwd = opts?.cwd || process.cwd();
|
|
1317
|
+
const envFiles = [];
|
|
1318
|
+
const filesWithinDir = await fs3.readdir(cwd);
|
|
1319
|
+
for (const fileName of filesWithinDir) {
|
|
1320
|
+
if (fileName === ".env" || fileName.startsWith(".env.")) {
|
|
1321
|
+
let skip = false;
|
|
1322
|
+
for (const fileType of SKIP_FILE_TYPES) {
|
|
1323
|
+
if (fileName.endsWith(fileType)) skip = true;
|
|
1324
|
+
}
|
|
1325
|
+
if (skip) continue;
|
|
1326
|
+
envFiles.push(path2.join(cwd, fileName));
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
return envFiles;
|
|
1330
|
+
}
|
|
1331
|
+
__name(findEnvFiles, "findEnvFiles");
|
|
1332
|
+
|
|
1333
|
+
// src/cli/commands/init.command.ts
|
|
1334
|
+
var commandSpec = define({
|
|
1335
|
+
name: "init",
|
|
1336
|
+
description: "Set up varlock in the current project",
|
|
1337
|
+
args: {},
|
|
1338
|
+
examples: `
|
|
1339
|
+
This command starts an interactive onboarding process to help you get started with Varlock.
|
|
1340
|
+
It will:
|
|
1341
|
+
- Scan for existing .env files in your project
|
|
1342
|
+
- Help create a .env.schema file from your .env.example or .env.sample file
|
|
1343
|
+
- Install varlock as a dependency in package.json (if applicable)
|
|
1344
|
+
|
|
1345
|
+
\u{1F4CD} Run this command in directories that contain .env or .env.* files
|
|
1346
|
+
|
|
1347
|
+
Examples:
|
|
1348
|
+
varlock init # Run in the current directory
|
|
1349
|
+
cd path/to/your/project && varlock init
|
|
1350
|
+
|
|
1351
|
+
For more information, visit https://varlock.dev/getting-started/installation
|
|
1352
|
+
`.trim()
|
|
1353
|
+
});
|
|
1354
|
+
var commandFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
1355
|
+
const jsPackageManager = detectJsPackageManager();
|
|
1356
|
+
console.log("\u{1F9D9} Hello and welcome to Varlock \u{1F512}\u{1F525}\u2728");
|
|
1357
|
+
const envFilePaths = await findEnvFiles();
|
|
1358
|
+
const parsedEnvFiles = {};
|
|
1359
|
+
for (const filePath of envFilePaths) {
|
|
1360
|
+
const fileContents = await fs3.readFile(filePath, "utf-8");
|
|
1361
|
+
const fileName = path2.basename(filePath);
|
|
1362
|
+
const parsedFile = await tryCatch(async () => parseEnvSpecDotEnvFile(fileContents), () => {
|
|
1363
|
+
logLines([
|
|
1364
|
+
"",
|
|
1365
|
+
`Unable to parse ${fmt.filePath(filePath)}`,
|
|
1366
|
+
"This file will be skipped."
|
|
1367
|
+
]);
|
|
1368
|
+
});
|
|
1369
|
+
if (!parsedFile) {
|
|
1370
|
+
continue;
|
|
1371
|
+
}
|
|
1372
|
+
parsedEnvFiles[fileName] = {
|
|
1373
|
+
fileName,
|
|
1374
|
+
fullPath: filePath,
|
|
1375
|
+
parsedFile
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
const existingSchemaFile = parsedEnvFiles[".env.schema"];
|
|
1379
|
+
if (existingSchemaFile) {
|
|
1380
|
+
logLines([
|
|
1381
|
+
`It looks like you already have a ${fmt.fileName(".env.schema")} file \u{1F389}`,
|
|
1382
|
+
"This init helper is meant to help you get a new project set up.",
|
|
1383
|
+
"If you need to make changes to your schema or values, you can update your files directly.",
|
|
1384
|
+
"See more docs at https://varlock.dev/guides/schema"
|
|
1385
|
+
]);
|
|
1386
|
+
} else {
|
|
1387
|
+
const allExampleFileNames = Object.keys(parsedEnvFiles).filter((fileName) => {
|
|
1388
|
+
return fileName.startsWith(".env.example") || fileName.startsWith(".env.sample");
|
|
1389
|
+
});
|
|
1390
|
+
let exampleFileToConvert;
|
|
1391
|
+
if (allExampleFileNames.length === 1) {
|
|
1392
|
+
exampleFileToConvert = parsedEnvFiles[allExampleFileNames[0]];
|
|
1393
|
+
} else if (allExampleFileNames.length > 1) {
|
|
1394
|
+
console.log("");
|
|
1395
|
+
const selectedExample = await qt({
|
|
1396
|
+
message: `We detected more than one example .env file. Which one should we use to create your new ${fmt.fileName(".env.schema")}?`,
|
|
1397
|
+
options: allExampleFileNames.map((fileName) => ({
|
|
1398
|
+
label: fileName,
|
|
1399
|
+
value: parsedEnvFiles[fileName]
|
|
1400
|
+
}))
|
|
1401
|
+
});
|
|
1402
|
+
if (Ct(selectedExample)) return gracefulExit(0);
|
|
1403
|
+
exampleFileToConvert = selectedExample;
|
|
1404
|
+
}
|
|
1405
|
+
const parsedEnvSchemaFile = exampleFileToConvert?.parsedFile || parseEnvSpecDotEnvFile("");
|
|
1406
|
+
if (!parsedEnvSchemaFile) throw new Error("expected parsed .env example file");
|
|
1407
|
+
envSpecUpdater.ensureHeader(parsedEnvSchemaFile, [
|
|
1408
|
+
"This env file uses @env-spec - see https://varlock.dev/env-spec for more info",
|
|
1409
|
+
""
|
|
1410
|
+
// TODO: add env spec version? real links?
|
|
1411
|
+
].join("\n"));
|
|
1412
|
+
envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "defaultRequired", "infer", { explicitTrue: true });
|
|
1413
|
+
envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "defaultSensitive", "false", { explicitTrue: true });
|
|
1414
|
+
envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "generateTypes", "lang=ts, path=env.d.ts", { bareFnArgs: true });
|
|
1415
|
+
envSpecUpdater.injectFromStr(parsedEnvSchemaFile, [
|
|
1416
|
+
"",
|
|
1417
|
+
"# example env variable injected by `varlock init` \u26A0\uFE0F DELETE THIS ITEM! \u26A0\uFE0F",
|
|
1418
|
+
'# @required @sensitive @example="example value"',
|
|
1419
|
+
'EXAMPLE_ITEM="delete me!"',
|
|
1420
|
+
""
|
|
1421
|
+
].join("\n"), { location: "after_header" });
|
|
1422
|
+
inferSchemaUpdates(parsedEnvSchemaFile);
|
|
1423
|
+
ensureAllItemsExist(parsedEnvSchemaFile, Object.values(parsedEnvFiles));
|
|
1424
|
+
const schemaFilePath = path2.join(process.cwd(), ".env.schema");
|
|
1425
|
+
await fs3.writeFile(schemaFilePath, parsedEnvSchemaFile.toString());
|
|
1426
|
+
if (exampleFileToConvert) {
|
|
1427
|
+
logLines([
|
|
1428
|
+
"",
|
|
1429
|
+
`Your ${fmt.fileName(exampleFileToConvert.fileName)} has been used to generate your new ${fmt.fileName(".env.schema")}:`,
|
|
1430
|
+
fmt.filePath(schemaFilePath)
|
|
1431
|
+
]);
|
|
1432
|
+
} else {
|
|
1433
|
+
logLines([
|
|
1434
|
+
"",
|
|
1435
|
+
`Your new ${fmt.fileName(".env.schema")} file has been created:`,
|
|
1436
|
+
fmt.filePath(schemaFilePath)
|
|
1437
|
+
]);
|
|
1438
|
+
}
|
|
1439
|
+
if (await checkIsFileGitIgnored(schemaFilePath)) {
|
|
1440
|
+
logLines([ansis_default.dim(`(and updated ${fmt.fileName(".gitignore")} to ensure it will be tracked by git)`)]);
|
|
1441
|
+
await fs3.appendFile(".gitignore", "\n!.env.schema");
|
|
1442
|
+
}
|
|
1443
|
+
logLines([
|
|
1444
|
+
"",
|
|
1445
|
+
ansis_default.bold(`\u{1F6A7} Please review and update your new ${fmt.fileName(".env.schema")} file! \u{1F6A7}`),
|
|
1446
|
+
`We've done our best to get you started, but you must review and make sure it is correct!`,
|
|
1447
|
+
"",
|
|
1448
|
+
`\u{1F449} Some helpful pointers to get you started:`,
|
|
1449
|
+
`- add a description to each item when the name is not self explanitory - it will come through in generated types`,
|
|
1450
|
+
`- use ${fmt.decorator("@required")} (or ${fmt.decorator("@optional")}) to tag items that should fail validation when empty`,
|
|
1451
|
+
`- use ${fmt.decorator("@sensitive")} to tag items that contain sensitive secrets, and must be handled accordingly`,
|
|
1452
|
+
`- use ${fmt.decorator("@type")} to set an item's data type (if not a basic string), which affects validation and coercion logic`,
|
|
1453
|
+
`- if an item value is a ${ansis_default.italic("useful example")} rather than a default, use ${fmt.decorator("@example")}`,
|
|
1454
|
+
`- if an item value is just a dummy placeholder, delete it`
|
|
1455
|
+
]);
|
|
1456
|
+
const confirmReviewed = await prompts_default.confirm({
|
|
1457
|
+
message: `Have you reviewed and updated your new ${fmt.fileName(".env.schema")} file?`
|
|
1458
|
+
});
|
|
1459
|
+
if (Ct(confirmReviewed)) return gracefulExit(0);
|
|
1460
|
+
const reloadedSchemaFile = await parseEnvSpecDotEnvFile(await fs3.readFile(schemaFilePath, "utf-8"));
|
|
1461
|
+
if (reloadedSchemaFile.configItems.find((i) => i.key === "EXAMPLE_ITEM")) {
|
|
1462
|
+
logLines([
|
|
1463
|
+
"",
|
|
1464
|
+
ansis_default.bold(`\u{1F6A8} Really? ${ansis_default.red("You didn't remove the EXAMPLE_ITEM!")}`),
|
|
1465
|
+
`Please make sure your schema is all correct before using it...`
|
|
1466
|
+
]);
|
|
1467
|
+
}
|
|
1468
|
+
if (exampleFileToConvert) {
|
|
1469
|
+
const confirmDeleteExample = await prompts_default.confirm({
|
|
1470
|
+
message: `Should we delete your ${fmt.fileName(exampleFileToConvert.fileName)} file? ${ansis_default.italic.gray("(you can always do this yourself later)")}`
|
|
1471
|
+
});
|
|
1472
|
+
if (Ct(confirmDeleteExample)) return gracefulExit(0);
|
|
1473
|
+
if (confirmDeleteExample) {
|
|
1474
|
+
await fs3.unlink(exampleFileToConvert.fullPath);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
const defaultsFile = Object.values(parsedEnvFiles).find((f) => {
|
|
1478
|
+
return f.fileName.startsWith(".env.default");
|
|
1479
|
+
});
|
|
1480
|
+
if (defaultsFile) {
|
|
1481
|
+
logLines([
|
|
1482
|
+
"",
|
|
1483
|
+
`\u{1F6A7} We detected a ${fmt.fileName(defaultsFile.fileName)} file in your project`,
|
|
1484
|
+
`You should migrate these default values into ${fmt.fileName(".env.schema")} and delete it.`
|
|
1485
|
+
]);
|
|
1486
|
+
}
|
|
1487
|
+
const redundantInfo = await detectRedundantValues(parsedEnvSchemaFile, parsedEnvFiles);
|
|
1488
|
+
if (Object.keys(redundantInfo).length > 0) {
|
|
1489
|
+
logLines([
|
|
1490
|
+
"",
|
|
1491
|
+
ansis_default.bold("\u203C\uFE0F Now that your schema contains defaults, some values in your other .env files are redundant:")
|
|
1492
|
+
]);
|
|
1493
|
+
for (const [sourcePath, itemKeys] of Object.entries(redundantInfo)) {
|
|
1494
|
+
console.log(fmt.filePath(sourcePath));
|
|
1495
|
+
console.log(" ", itemKeys.map((k3) => ansis_default.italic(k3)).join(", "));
|
|
1496
|
+
}
|
|
1497
|
+
const confirmDeleteRedundant = await prompts_default.confirm({
|
|
1498
|
+
message: "Should we delete these redundant values from your other .env files?"
|
|
1499
|
+
});
|
|
1500
|
+
if (Ct(confirmDeleteRedundant)) return gracefulExit(0);
|
|
1501
|
+
if (confirmDeleteRedundant) {
|
|
1502
|
+
await detectRedundantValues(parsedEnvSchemaFile, parsedEnvFiles, { delete: true });
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
logLines([
|
|
1506
|
+
"",
|
|
1507
|
+
ansis_default.bold("\u{1F389} Great!"),
|
|
1508
|
+
`You can run ${fmt.command("varlock load", { jsPackageManager })} to attempt loading your env vars validate against your new schema.`,
|
|
1509
|
+
"",
|
|
1510
|
+
"Check out our docs for more info about integrating into your application.",
|
|
1511
|
+
"",
|
|
1512
|
+
"\u{1F4D6} https://varlock.dev \u{1F448}",
|
|
1513
|
+
""
|
|
1514
|
+
]);
|
|
1515
|
+
}
|
|
1516
|
+
if (jsPackageManager && await pathExists(path2.join(process.cwd(), "package.json"))) {
|
|
1517
|
+
const installResult = installJsDependency({
|
|
1518
|
+
packageManager: jsPackageManager.name,
|
|
1519
|
+
packageName: "varlock"
|
|
1520
|
+
});
|
|
1521
|
+
if (installResult) {
|
|
1522
|
+
logLines([
|
|
1523
|
+
"",
|
|
1524
|
+
`\u2705 Added ${fmt.packageName("varlock")} as a dependency in your package.json`
|
|
1525
|
+
]);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}, "commandFn");
|
|
1529
|
+
|
|
1530
|
+
export { commandFn, commandSpec };
|
|
1531
|
+
//# sourceMappingURL=chunk-N2HZMIGS.js.map
|
|
1532
|
+
//# sourceMappingURL=chunk-N2HZMIGS.js.map
|