@bryanchu10/create-template-ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1323 -0
- package/package.json +30 -0
- package/template/_gitignore +2 -0
- package/template/_vscode/settings.json +36 -0
- package/template/eslint.config.js +32 -0
- package/template/package.json +10 -0
- package/template/pnpm-workspace.yaml +4 -0
- package/template/rolldown.config.ts +9 -0
- package/template/src/index.ts +2 -0
- package/template/tsconfig.json +8 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1323 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import V, { argv, cwd, exit, stdin, stdout, version } from "node:process";
|
|
5
|
+
import { stripVTControlCharacters, styleText } from "node:util";
|
|
6
|
+
import * as b$1 from "node:readline";
|
|
7
|
+
import E from "node:readline";
|
|
8
|
+
import { ReadStream } from "node:tty";
|
|
9
|
+
//#region \0rolldown/runtime.js
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
13
|
+
const getCodePointsLength = (() => {
|
|
14
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
15
|
+
return (input) => {
|
|
16
|
+
let surrogatePairsNr = 0;
|
|
17
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
18
|
+
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
19
|
+
return input.length - surrogatePairsNr;
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
const isFullWidth = (x) => {
|
|
23
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
24
|
+
};
|
|
25
|
+
const isWideNotCJKTNotEmoji = (x) => {
|
|
26
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
30
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
31
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
32
|
+
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
|
|
33
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
34
|
+
const EMOJI_RE = /[\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?))*/uy;
|
|
35
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
36
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
37
|
+
const NO_TRUNCATION$1 = {
|
|
38
|
+
limit: Infinity,
|
|
39
|
+
ellipsis: ""
|
|
40
|
+
};
|
|
41
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
42
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
43
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
44
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
45
|
+
const ANSI_WIDTH = 0;
|
|
46
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
47
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
48
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
49
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
50
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
51
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
52
|
+
const PARSE_BLOCKS = [
|
|
53
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
54
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
55
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
56
|
+
[TAB_RE, TAB_WIDTH],
|
|
57
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
58
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
59
|
+
];
|
|
60
|
+
let indexPrev = 0;
|
|
61
|
+
let index = 0;
|
|
62
|
+
let length = input.length;
|
|
63
|
+
let lengthExtra = 0;
|
|
64
|
+
let truncationEnabled = false;
|
|
65
|
+
let truncationIndex = length;
|
|
66
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
67
|
+
let unmatchedStart = 0;
|
|
68
|
+
let unmatchedEnd = 0;
|
|
69
|
+
let width = 0;
|
|
70
|
+
let widthExtra = 0;
|
|
71
|
+
outer: while (true) {
|
|
72
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
73
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
74
|
+
lengthExtra = 0;
|
|
75
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
76
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
77
|
+
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
78
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
79
|
+
else widthExtra = REGULAR_WIDTH;
|
|
80
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
81
|
+
if (width + widthExtra > LIMIT) {
|
|
82
|
+
truncationEnabled = true;
|
|
83
|
+
break outer;
|
|
84
|
+
}
|
|
85
|
+
lengthExtra += char.length;
|
|
86
|
+
width += widthExtra;
|
|
87
|
+
}
|
|
88
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
89
|
+
}
|
|
90
|
+
if (index >= length) break outer;
|
|
91
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
92
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
93
|
+
BLOCK_RE.lastIndex = index;
|
|
94
|
+
if (BLOCK_RE.test(input)) {
|
|
95
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
96
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
97
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
98
|
+
if (width + widthExtra > LIMIT) {
|
|
99
|
+
truncationEnabled = true;
|
|
100
|
+
break outer;
|
|
101
|
+
}
|
|
102
|
+
width += widthExtra;
|
|
103
|
+
unmatchedStart = indexPrev;
|
|
104
|
+
unmatchedEnd = index;
|
|
105
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
106
|
+
continue outer;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
index += 1;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
113
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
114
|
+
truncated: truncationEnabled,
|
|
115
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
120
|
+
const NO_TRUNCATION = {
|
|
121
|
+
limit: Infinity,
|
|
122
|
+
ellipsis: "",
|
|
123
|
+
ellipsisWidth: 0
|
|
124
|
+
};
|
|
125
|
+
const fastStringWidth = (input, options = {}) => {
|
|
126
|
+
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
130
|
+
const ESC = "\x1B";
|
|
131
|
+
const CSI = "";
|
|
132
|
+
const END_CODE = 39;
|
|
133
|
+
const ANSI_ESCAPE_BELL = "\x07";
|
|
134
|
+
const ANSI_CSI = "[";
|
|
135
|
+
const ANSI_OSC = "]";
|
|
136
|
+
const ANSI_SGR_TERMINATOR = "m";
|
|
137
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
138
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
139
|
+
const getClosingCode = (openingCode) => {
|
|
140
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
141
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
142
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
143
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
144
|
+
if (openingCode === 1 || openingCode === 2) return 22;
|
|
145
|
+
if (openingCode === 3) return 23;
|
|
146
|
+
if (openingCode === 4) return 24;
|
|
147
|
+
if (openingCode === 7) return 27;
|
|
148
|
+
if (openingCode === 8) return 28;
|
|
149
|
+
if (openingCode === 9) return 29;
|
|
150
|
+
if (openingCode === 0) return 0;
|
|
151
|
+
};
|
|
152
|
+
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
153
|
+
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
154
|
+
const wrapWord = (rows, word, columns) => {
|
|
155
|
+
const characters = word[Symbol.iterator]();
|
|
156
|
+
let isInsideEscape = false;
|
|
157
|
+
let isInsideLinkEscape = false;
|
|
158
|
+
let lastRow = rows.at(-1);
|
|
159
|
+
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
160
|
+
let currentCharacter = characters.next();
|
|
161
|
+
let nextCharacter = characters.next();
|
|
162
|
+
let rawCharacterIndex = 0;
|
|
163
|
+
while (!currentCharacter.done) {
|
|
164
|
+
const character = currentCharacter.value;
|
|
165
|
+
const characterLength = fastStringWidth(character);
|
|
166
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
167
|
+
else {
|
|
168
|
+
rows.push(character);
|
|
169
|
+
visible = 0;
|
|
170
|
+
}
|
|
171
|
+
if (character === ESC || character === CSI) {
|
|
172
|
+
isInsideEscape = true;
|
|
173
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
174
|
+
}
|
|
175
|
+
if (isInsideEscape) {
|
|
176
|
+
if (isInsideLinkEscape) {
|
|
177
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
178
|
+
isInsideEscape = false;
|
|
179
|
+
isInsideLinkEscape = false;
|
|
180
|
+
}
|
|
181
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
182
|
+
} else {
|
|
183
|
+
visible += characterLength;
|
|
184
|
+
if (visible === columns && !nextCharacter.done) {
|
|
185
|
+
rows.push("");
|
|
186
|
+
visible = 0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
currentCharacter = nextCharacter;
|
|
190
|
+
nextCharacter = characters.next();
|
|
191
|
+
rawCharacterIndex += character.length;
|
|
192
|
+
}
|
|
193
|
+
lastRow = rows.at(-1);
|
|
194
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
195
|
+
};
|
|
196
|
+
const stringVisibleTrimSpacesRight = (string) => {
|
|
197
|
+
const words = string.split(" ");
|
|
198
|
+
let last = words.length;
|
|
199
|
+
while (last) {
|
|
200
|
+
if (fastStringWidth(words[last - 1])) break;
|
|
201
|
+
last--;
|
|
202
|
+
}
|
|
203
|
+
if (last === words.length) return string;
|
|
204
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
205
|
+
};
|
|
206
|
+
const exec = (string, columns, options = {}) => {
|
|
207
|
+
if (options.trim !== false && string.trim() === "") return "";
|
|
208
|
+
let returnValue = "";
|
|
209
|
+
let escapeCode;
|
|
210
|
+
let escapeUrl;
|
|
211
|
+
const words = string.split(" ");
|
|
212
|
+
let rows = [""];
|
|
213
|
+
let rowLength = 0;
|
|
214
|
+
for (let index = 0; index < words.length; index++) {
|
|
215
|
+
const word = words[index];
|
|
216
|
+
if (options.trim !== false) {
|
|
217
|
+
const row = rows.at(-1) ?? "";
|
|
218
|
+
const trimmed = row.trimStart();
|
|
219
|
+
if (row.length !== trimmed.length) {
|
|
220
|
+
rows[rows.length - 1] = trimmed;
|
|
221
|
+
rowLength = fastStringWidth(trimmed);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (index !== 0) {
|
|
225
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
226
|
+
rows.push("");
|
|
227
|
+
rowLength = 0;
|
|
228
|
+
}
|
|
229
|
+
if (rowLength || options.trim === false) {
|
|
230
|
+
rows[rows.length - 1] += " ";
|
|
231
|
+
rowLength++;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const wordLength = fastStringWidth(word);
|
|
235
|
+
if (options.hard && wordLength > columns) {
|
|
236
|
+
const remainingColumns = columns - rowLength;
|
|
237
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
238
|
+
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
239
|
+
wrapWord(rows, word, columns);
|
|
240
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
244
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
245
|
+
wrapWord(rows, word, columns);
|
|
246
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
rows.push("");
|
|
250
|
+
rowLength = 0;
|
|
251
|
+
}
|
|
252
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
253
|
+
wrapWord(rows, word, columns);
|
|
254
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
rows[rows.length - 1] += word;
|
|
258
|
+
rowLength += wordLength;
|
|
259
|
+
}
|
|
260
|
+
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
261
|
+
const preString = rows.join("\n");
|
|
262
|
+
let inSurrogate = false;
|
|
263
|
+
for (let i = 0; i < preString.length; i++) {
|
|
264
|
+
const character = preString[i];
|
|
265
|
+
returnValue += character;
|
|
266
|
+
if (!inSurrogate) {
|
|
267
|
+
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
268
|
+
if (inSurrogate) continue;
|
|
269
|
+
} else inSurrogate = false;
|
|
270
|
+
if (character === ESC || character === CSI) {
|
|
271
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
272
|
+
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
273
|
+
if (groups?.code !== void 0) {
|
|
274
|
+
const code = Number.parseFloat(groups.code);
|
|
275
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
276
|
+
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
277
|
+
}
|
|
278
|
+
if (preString[i + 1] === "\n") {
|
|
279
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
280
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
281
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
282
|
+
} else if (character === "\n") {
|
|
283
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
284
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return returnValue;
|
|
288
|
+
};
|
|
289
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
290
|
+
function wrapAnsi(string, columns, options) {
|
|
291
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region node_modules/.pnpm/@clack+core@1.3.1/node_modules/@clack/core/dist/index.mjs
|
|
295
|
+
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
296
|
+
const ESC = "\x1B";
|
|
297
|
+
const CSI = `${ESC}[`;
|
|
298
|
+
const beep = "\x07";
|
|
299
|
+
const cursor = {
|
|
300
|
+
to(x, y) {
|
|
301
|
+
if (!y) return `${CSI}${x + 1}G`;
|
|
302
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
303
|
+
},
|
|
304
|
+
move(x, y) {
|
|
305
|
+
let ret = "";
|
|
306
|
+
if (x < 0) ret += `${CSI}${-x}D`;
|
|
307
|
+
else if (x > 0) ret += `${CSI}${x}C`;
|
|
308
|
+
if (y < 0) ret += `${CSI}${-y}A`;
|
|
309
|
+
else if (y > 0) ret += `${CSI}${y}B`;
|
|
310
|
+
return ret;
|
|
311
|
+
},
|
|
312
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
313
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
314
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
315
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
316
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
317
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
318
|
+
left: `${CSI}G`,
|
|
319
|
+
hide: `${CSI}?25l`,
|
|
320
|
+
show: `${CSI}?25h`,
|
|
321
|
+
save: `${ESC}7`,
|
|
322
|
+
restore: `${ESC}8`
|
|
323
|
+
};
|
|
324
|
+
module.exports = {
|
|
325
|
+
cursor,
|
|
326
|
+
scroll: {
|
|
327
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
328
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
329
|
+
},
|
|
330
|
+
erase: {
|
|
331
|
+
screen: `${CSI}2J`,
|
|
332
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
333
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
334
|
+
line: `${CSI}2K`,
|
|
335
|
+
lineEnd: `${CSI}K`,
|
|
336
|
+
lineStart: `${CSI}1K`,
|
|
337
|
+
lines(count) {
|
|
338
|
+
let clear = "";
|
|
339
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
340
|
+
if (count) clear += cursor.left;
|
|
341
|
+
return clear;
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
beep
|
|
345
|
+
};
|
|
346
|
+
})))();
|
|
347
|
+
function f$1(r, t, s) {
|
|
348
|
+
if (!s.some((o) => !o.disabled)) return r;
|
|
349
|
+
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
|
|
350
|
+
return s[n].disabled ? f$1(n, t < 0 ? -1 : 1, s) : n;
|
|
351
|
+
}
|
|
352
|
+
const h$1 = {
|
|
353
|
+
actions: new Set([
|
|
354
|
+
"up",
|
|
355
|
+
"down",
|
|
356
|
+
"left",
|
|
357
|
+
"right",
|
|
358
|
+
"space",
|
|
359
|
+
"enter",
|
|
360
|
+
"cancel"
|
|
361
|
+
]),
|
|
362
|
+
aliases: new Map([
|
|
363
|
+
["k", "up"],
|
|
364
|
+
["j", "down"],
|
|
365
|
+
["h", "left"],
|
|
366
|
+
["l", "right"],
|
|
367
|
+
["", "cancel"],
|
|
368
|
+
["escape", "cancel"]
|
|
369
|
+
]),
|
|
370
|
+
messages: {
|
|
371
|
+
cancel: "Canceled",
|
|
372
|
+
error: "Something went wrong"
|
|
373
|
+
},
|
|
374
|
+
withGuide: !0,
|
|
375
|
+
date: {
|
|
376
|
+
monthNames: [...[
|
|
377
|
+
"January",
|
|
378
|
+
"February",
|
|
379
|
+
"March",
|
|
380
|
+
"April",
|
|
381
|
+
"May",
|
|
382
|
+
"June",
|
|
383
|
+
"July",
|
|
384
|
+
"August",
|
|
385
|
+
"September",
|
|
386
|
+
"October",
|
|
387
|
+
"November",
|
|
388
|
+
"December"
|
|
389
|
+
]],
|
|
390
|
+
messages: {
|
|
391
|
+
required: "Please enter a valid date",
|
|
392
|
+
invalidMonth: "There are only 12 months in a year",
|
|
393
|
+
invalidDay: (r, t) => `There are only ${r} days in ${t}`,
|
|
394
|
+
afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`,
|
|
395
|
+
beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}`
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
function C(r, t) {
|
|
400
|
+
if (typeof r == "string") return h$1.aliases.get(r) === t;
|
|
401
|
+
for (const s of r) if (s !== void 0 && C(s, t)) return !0;
|
|
402
|
+
return !1;
|
|
403
|
+
}
|
|
404
|
+
function z$2(r, t) {
|
|
405
|
+
if (r === t) return;
|
|
406
|
+
const s = r.split(`
|
|
407
|
+
`), e = t.split(`
|
|
408
|
+
`), i = Math.max(s.length, e.length), n = [];
|
|
409
|
+
for (let o = 0; o < i; o++) s[o] !== e[o] && n.push(o);
|
|
410
|
+
return {
|
|
411
|
+
lines: n,
|
|
412
|
+
numLinesBefore: s.length,
|
|
413
|
+
numLinesAfter: e.length,
|
|
414
|
+
numLines: i
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
const Y$1 = globalThis.process.platform.startsWith("win"), k$1 = Symbol("clack:cancel");
|
|
418
|
+
function q$1(r) {
|
|
419
|
+
return r === k$1;
|
|
420
|
+
}
|
|
421
|
+
function w$2(r, t) {
|
|
422
|
+
const s = r;
|
|
423
|
+
s.isTTY && s.setRawMode(t);
|
|
424
|
+
}
|
|
425
|
+
function R$2({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor: e = !0 } = {}) {
|
|
426
|
+
const i = b$1.createInterface({
|
|
427
|
+
input: r,
|
|
428
|
+
output: t,
|
|
429
|
+
prompt: "",
|
|
430
|
+
tabSize: 1
|
|
431
|
+
});
|
|
432
|
+
b$1.emitKeypressEvents(r, i), r instanceof ReadStream && r.isTTY && r.setRawMode(!0);
|
|
433
|
+
const n = (o, { name: u, sequence: a }) => {
|
|
434
|
+
if (C([
|
|
435
|
+
String(o),
|
|
436
|
+
u,
|
|
437
|
+
a
|
|
438
|
+
], "cancel")) {
|
|
439
|
+
e && t.write(import_src.cursor.show), process.exit(0);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (!s) return;
|
|
443
|
+
const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
|
|
444
|
+
b$1.moveCursor(t, c, y, () => {
|
|
445
|
+
b$1.clearLine(t, 1, () => {
|
|
446
|
+
r.once("keypress", n);
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
};
|
|
450
|
+
return e && t.write(import_src.cursor.hide), r.once("keypress", n), () => {
|
|
451
|
+
r.off("keypress", n), e && t.write(import_src.cursor.show), r instanceof ReadStream && r.isTTY && !Y$1 && r.setRawMode(!1), i.terminal = !1, i.close();
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
const A$1 = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80, L$1 = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
|
|
455
|
+
let m$1 = class {
|
|
456
|
+
input;
|
|
457
|
+
output;
|
|
458
|
+
_abortSignal;
|
|
459
|
+
rl;
|
|
460
|
+
opts;
|
|
461
|
+
_render;
|
|
462
|
+
_track = !1;
|
|
463
|
+
_prevFrame = "";
|
|
464
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
465
|
+
_cursor = 0;
|
|
466
|
+
state = "initial";
|
|
467
|
+
error = "";
|
|
468
|
+
value;
|
|
469
|
+
userInput = "";
|
|
470
|
+
constructor(t, s = !0) {
|
|
471
|
+
const { input: e = stdin, output: i = stdout, render: n, signal: o, ...u } = t;
|
|
472
|
+
this.opts = u, 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 = o, this.input = e, this.output = i;
|
|
473
|
+
}
|
|
474
|
+
unsubscribe() {
|
|
475
|
+
this._subscribers.clear();
|
|
476
|
+
}
|
|
477
|
+
setSubscriber(t, s) {
|
|
478
|
+
const e = this._subscribers.get(t) ?? [];
|
|
479
|
+
e.push(s), this._subscribers.set(t, e);
|
|
480
|
+
}
|
|
481
|
+
on(t, s) {
|
|
482
|
+
this.setSubscriber(t, { cb: s });
|
|
483
|
+
}
|
|
484
|
+
once(t, s) {
|
|
485
|
+
this.setSubscriber(t, {
|
|
486
|
+
cb: s,
|
|
487
|
+
once: !0
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
emit(t, ...s) {
|
|
491
|
+
const e = this._subscribers.get(t) ?? [], i = [];
|
|
492
|
+
for (const n of e) n.cb(...s), n.once && i.push(() => e.splice(e.indexOf(n), 1));
|
|
493
|
+
for (const n of i) n();
|
|
494
|
+
}
|
|
495
|
+
prompt() {
|
|
496
|
+
return new Promise((t) => {
|
|
497
|
+
if (this._abortSignal) {
|
|
498
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k$1);
|
|
499
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
500
|
+
this.state = "cancel", this.close();
|
|
501
|
+
}, { once: !0 });
|
|
502
|
+
}
|
|
503
|
+
this.rl = E.createInterface({
|
|
504
|
+
input: this.input,
|
|
505
|
+
tabSize: 2,
|
|
506
|
+
prompt: "",
|
|
507
|
+
escapeCodeTimeout: 50,
|
|
508
|
+
terminal: !0
|
|
509
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w$2(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
510
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$2(this.input, !1), t(this.value);
|
|
511
|
+
}), this.once("cancel", () => {
|
|
512
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$2(this.input, !1), t(k$1);
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
_isActionKey(t, s) {
|
|
517
|
+
return t === " ";
|
|
518
|
+
}
|
|
519
|
+
_shouldSubmit(t, s) {
|
|
520
|
+
return !0;
|
|
521
|
+
}
|
|
522
|
+
_setValue(t) {
|
|
523
|
+
this.value = t, this.emit("value", this.value);
|
|
524
|
+
}
|
|
525
|
+
_setUserInput(t, s) {
|
|
526
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
527
|
+
}
|
|
528
|
+
_clearUserInput() {
|
|
529
|
+
this.rl?.write(null, {
|
|
530
|
+
ctrl: !0,
|
|
531
|
+
name: "u"
|
|
532
|
+
}), this._setUserInput("");
|
|
533
|
+
}
|
|
534
|
+
onKeypress(t, s) {
|
|
535
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, {
|
|
536
|
+
ctrl: !0,
|
|
537
|
+
name: "h"
|
|
538
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h$1.aliases.has(s.name) && this.emit("cursor", h$1.aliases.get(s.name)), h$1.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
|
|
539
|
+
if (this.opts.validate) {
|
|
540
|
+
const e = this.opts.validate(this.value);
|
|
541
|
+
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
|
|
542
|
+
}
|
|
543
|
+
this.state !== "error" && (this.state = "submit");
|
|
544
|
+
}
|
|
545
|
+
C([
|
|
546
|
+
t,
|
|
547
|
+
s?.name,
|
|
548
|
+
s?.sequence
|
|
549
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
550
|
+
}
|
|
551
|
+
close() {
|
|
552
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
553
|
+
`), w$2(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
554
|
+
}
|
|
555
|
+
restoreCursor() {
|
|
556
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
557
|
+
hard: !0,
|
|
558
|
+
trim: !1
|
|
559
|
+
}).split(`
|
|
560
|
+
`).length - 1;
|
|
561
|
+
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
562
|
+
}
|
|
563
|
+
render() {
|
|
564
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
565
|
+
hard: !0,
|
|
566
|
+
trim: !1
|
|
567
|
+
});
|
|
568
|
+
if (t !== this._prevFrame) {
|
|
569
|
+
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
570
|
+
else {
|
|
571
|
+
const s = z$2(this._prevFrame, t), e = L$1(this.output);
|
|
572
|
+
if (this.restoreCursor(), s) {
|
|
573
|
+
const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
|
|
574
|
+
let o = s.lines.find((u) => u >= i);
|
|
575
|
+
if (o === void 0) {
|
|
576
|
+
this._prevFrame = t;
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (s.lines.length === 1) {
|
|
580
|
+
this.output.write(import_src.cursor.move(0, o - n)), this.output.write(import_src.erase.lines(1));
|
|
581
|
+
const u = t.split(`
|
|
582
|
+
`);
|
|
583
|
+
this.output.write(u[o]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, u.length - o - 1));
|
|
584
|
+
return;
|
|
585
|
+
} else if (s.lines.length > 1) {
|
|
586
|
+
if (i < n) o = i;
|
|
587
|
+
else {
|
|
588
|
+
const a = o - n;
|
|
589
|
+
a > 0 && this.output.write(import_src.cursor.move(0, a));
|
|
590
|
+
}
|
|
591
|
+
this.output.write(import_src.erase.down());
|
|
592
|
+
const u = t.split(`
|
|
593
|
+
`).slice(o);
|
|
594
|
+
this.output.write(u.join(`
|
|
595
|
+
`)), this._prevFrame = t;
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
this.output.write(import_src.erase.down());
|
|
600
|
+
}
|
|
601
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
var ht$1 = class extends m$1 {
|
|
606
|
+
get userInputWithCursor() {
|
|
607
|
+
if (this.state === "submit") return this.userInput;
|
|
608
|
+
const t = this.userInput;
|
|
609
|
+
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
610
|
+
const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
|
|
611
|
+
return `${s}${styleText("inverse", e)}${i.join("")}`;
|
|
612
|
+
}
|
|
613
|
+
get cursor() {
|
|
614
|
+
return this._cursor;
|
|
615
|
+
}
|
|
616
|
+
constructor(t) {
|
|
617
|
+
super({
|
|
618
|
+
...t,
|
|
619
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
620
|
+
}), this.on("userInput", (s) => {
|
|
621
|
+
this._setValue(s);
|
|
622
|
+
}), this.on("finalize", () => {
|
|
623
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region node_modules/.pnpm/@clack+prompts@1.4.0/node_modules/@clack/prompts/dist/index.mjs
|
|
629
|
+
function ee() {
|
|
630
|
+
return V.platform !== "win32" ? V.env.TERM !== "linux" : !!V.env.CI || !!V.env.WT_SESSION || !!V.env.TERMINUS_SUBLIME || V.env.ConEmuTask === "{cmd::Cmder}" || V.env.TERM_PROGRAM === "Terminus-Sublime" || V.env.TERM_PROGRAM === "vscode" || V.env.TERM === "xterm-256color" || V.env.TERM === "alacritty" || V.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
631
|
+
}
|
|
632
|
+
const tt = ee(), ot = () => process.env.CI === "true", w$1 = (t, i) => tt ? t : i, Tt = w$1("◆", "*"), at = w$1("■", "x"), ut = w$1("▲", "x"), H = w$1("◇", "o"), lt = w$1("┌", "T"), $ = w$1("│", "|"), x$1 = w$1("└", "—"), ht = w$1("●", "•"), pt = w$1("◆", "*"), mt = w$1("▲", "!"), gt = w$1("■", "x"), P$1 = (t) => {
|
|
633
|
+
switch (t) {
|
|
634
|
+
case "initial":
|
|
635
|
+
case "active": return styleText("cyan", Tt);
|
|
636
|
+
case "cancel": return styleText("red", at);
|
|
637
|
+
case "error": return styleText("yellow", ut);
|
|
638
|
+
case "submit": return styleText("green", H);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
const R$1 = {
|
|
642
|
+
message: (t = [], { symbol: i = styleText("gray", $), secondarySymbol: s = styleText("gray", $), output: r = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
|
|
643
|
+
const a = [], c = n ?? h$1.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
|
|
644
|
+
for (let p = 0; p < u; p++) a.push(o);
|
|
645
|
+
const g = Array.isArray(t) ? t : t.split(`
|
|
646
|
+
`);
|
|
647
|
+
if (g.length > 0) {
|
|
648
|
+
const [p, ...f] = g;
|
|
649
|
+
p.length > 0 ? a.push(`${l}${p}`) : a.push(c ? i : "");
|
|
650
|
+
for (const h of f) h.length > 0 ? a.push(`${d}${h}`) : a.push(c ? s : "");
|
|
651
|
+
}
|
|
652
|
+
r.write(`${a.join(`
|
|
653
|
+
`)}
|
|
654
|
+
`);
|
|
655
|
+
},
|
|
656
|
+
info: (t, i) => {
|
|
657
|
+
R$1.message(t, {
|
|
658
|
+
...i,
|
|
659
|
+
symbol: styleText("blue", ht)
|
|
660
|
+
});
|
|
661
|
+
},
|
|
662
|
+
success: (t, i) => {
|
|
663
|
+
R$1.message(t, {
|
|
664
|
+
...i,
|
|
665
|
+
symbol: styleText("green", pt)
|
|
666
|
+
});
|
|
667
|
+
},
|
|
668
|
+
step: (t, i) => {
|
|
669
|
+
R$1.message(t, {
|
|
670
|
+
...i,
|
|
671
|
+
symbol: styleText("green", H)
|
|
672
|
+
});
|
|
673
|
+
},
|
|
674
|
+
warn: (t, i) => {
|
|
675
|
+
R$1.message(t, {
|
|
676
|
+
...i,
|
|
677
|
+
symbol: styleText("yellow", mt)
|
|
678
|
+
});
|
|
679
|
+
},
|
|
680
|
+
warning: (t, i) => {
|
|
681
|
+
R$1.warn(t, i);
|
|
682
|
+
},
|
|
683
|
+
error: (t, i) => {
|
|
684
|
+
R$1.message(t, {
|
|
685
|
+
...i,
|
|
686
|
+
symbol: styleText("red", gt)
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
}, me = (t = "", i) => {
|
|
690
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h$1.withGuide ? `${styleText("gray", x$1)} ` : "";
|
|
691
|
+
s.write(`${r}${styleText("red", t)}
|
|
692
|
+
|
|
693
|
+
`);
|
|
694
|
+
}, ge = (t = "", i) => {
|
|
695
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h$1.withGuide ? `${styleText("gray", lt)} ` : "";
|
|
696
|
+
s.write(`${r}${t}
|
|
697
|
+
`);
|
|
698
|
+
}, ye = (t = "", i) => {
|
|
699
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h$1.withGuide ? `${styleText("gray", $)}
|
|
700
|
+
${styleText("gray", x$1)} ` : "";
|
|
701
|
+
s.write(`${r}${t}
|
|
702
|
+
|
|
703
|
+
`);
|
|
704
|
+
}, Te = (t) => styleText("magenta", t), ft = ({ indicator: t = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u, frames: n = tt ? [
|
|
705
|
+
"◒",
|
|
706
|
+
"◐",
|
|
707
|
+
"◓",
|
|
708
|
+
"◑"
|
|
709
|
+
] : [
|
|
710
|
+
"•",
|
|
711
|
+
"o",
|
|
712
|
+
"O",
|
|
713
|
+
"0"
|
|
714
|
+
], delay: a = tt ? 80 : 120, signal: c, ...o } = {}) => {
|
|
715
|
+
const l = ot();
|
|
716
|
+
let d, g, p = !1, f = !1, h = "", I, m = performance.now();
|
|
717
|
+
const y = A$1(s), v = o?.styleFrame ?? Te, C = (_) => {
|
|
718
|
+
const A = _ > 1 ? u ?? h$1.messages.error : r ?? h$1.messages.cancel;
|
|
719
|
+
f = _ === 1, p && (W(A, _), f && typeof i == "function" && i());
|
|
720
|
+
}, S = () => C(2), b = () => C(1), G = () => {
|
|
721
|
+
process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", C), c && c.addEventListener("abort", b);
|
|
722
|
+
}, M = () => {
|
|
723
|
+
process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", C), c && c.removeEventListener("abort", b);
|
|
724
|
+
}, N = () => {
|
|
725
|
+
if (I === void 0) return;
|
|
726
|
+
l && s.write(`
|
|
727
|
+
`);
|
|
728
|
+
const _ = wrapAnsi(I, y, {
|
|
729
|
+
hard: !0,
|
|
730
|
+
trim: !1
|
|
731
|
+
}).split(`
|
|
732
|
+
`);
|
|
733
|
+
_.length > 1 && s.write(import_src.cursor.up(_.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
|
|
734
|
+
}, O = (_) => _.replace(/\.+$/, ""), j = (_) => {
|
|
735
|
+
const A = (performance.now() - _) / 1e3, L = Math.floor(A / 60), D = Math.floor(A % 60);
|
|
736
|
+
return L > 0 ? `[${L}m ${D}s]` : `[${D}s]`;
|
|
737
|
+
}, k = o.withGuide ?? h$1.withGuide, rt = (_ = "") => {
|
|
738
|
+
p = !0, d = R$2({ output: s }), h = O(_), m = performance.now(), k && s.write(`${styleText("gray", $)}
|
|
739
|
+
`);
|
|
740
|
+
let A = 0, L = 0;
|
|
741
|
+
G(), g = setInterval(() => {
|
|
742
|
+
if (l && h === I) return;
|
|
743
|
+
N(), I = h;
|
|
744
|
+
const D = v(n[A]);
|
|
745
|
+
let Z;
|
|
746
|
+
if (l) Z = `${D} ${h}...`;
|
|
747
|
+
else if (t === "timer") Z = `${D} ${h} ${j(m)}`;
|
|
748
|
+
else {
|
|
749
|
+
const kt = ".".repeat(Math.floor(L)).slice(0, 3);
|
|
750
|
+
Z = `${D} ${h}${kt}`;
|
|
751
|
+
}
|
|
752
|
+
const Bt = wrapAnsi(Z, y, {
|
|
753
|
+
hard: !0,
|
|
754
|
+
trim: !1
|
|
755
|
+
});
|
|
756
|
+
s.write(Bt), A = A + 1 < n.length ? A + 1 : 0, L = L < 4 ? L + .125 : 0;
|
|
757
|
+
}, a);
|
|
758
|
+
}, W = (_ = "", A = 0, L = !1) => {
|
|
759
|
+
if (!p) return;
|
|
760
|
+
p = !1, clearInterval(g), N();
|
|
761
|
+
const D = A === 0 ? styleText("green", H) : A === 1 ? styleText("red", at) : styleText("red", ut);
|
|
762
|
+
h = _ ?? h, L || (t === "timer" ? s.write(`${D} ${h} ${j(m)}
|
|
763
|
+
`) : s.write(`${D} ${h}
|
|
764
|
+
`)), M(), d();
|
|
765
|
+
};
|
|
766
|
+
return {
|
|
767
|
+
start: rt,
|
|
768
|
+
stop: (_ = "") => W(_, 0),
|
|
769
|
+
message: (_ = "") => {
|
|
770
|
+
h = O(_ ?? h);
|
|
771
|
+
},
|
|
772
|
+
cancel: (_ = "") => W(_, 1),
|
|
773
|
+
error: (_ = "") => W(_, 2),
|
|
774
|
+
clear: () => W("", 0, !0),
|
|
775
|
+
get isCancelled() {
|
|
776
|
+
return f;
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
}, Nt = `${styleText("gray", $)} `, q = {
|
|
780
|
+
message: async (t, { symbol: i = styleText("gray", $) } = {}) => {
|
|
781
|
+
process.stdout.write(`${styleText("gray", $)}
|
|
782
|
+
${i} `);
|
|
783
|
+
let s = 3;
|
|
784
|
+
for await (let r of t) {
|
|
785
|
+
r = r.replace(/\n/g, `
|
|
786
|
+
${Nt}`), r.includes(`
|
|
787
|
+
`) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
|
|
788
|
+
`))).length);
|
|
789
|
+
const u = stripVTControlCharacters(r).length;
|
|
790
|
+
s + u < process.stdout.columns ? (s += u, process.stdout.write(r)) : (process.stdout.write(`
|
|
791
|
+
${Nt}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
|
|
792
|
+
}
|
|
793
|
+
process.stdout.write(`
|
|
794
|
+
`);
|
|
795
|
+
},
|
|
796
|
+
info: (t) => q.message(t, { symbol: styleText("blue", ht) }),
|
|
797
|
+
success: (t) => q.message(t, { symbol: styleText("green", pt) }),
|
|
798
|
+
step: (t) => q.message(t, { symbol: styleText("green", H) }),
|
|
799
|
+
warn: (t) => q.message(t, { symbol: styleText("yellow", mt) }),
|
|
800
|
+
warning: (t) => q.warn(t),
|
|
801
|
+
error: (t) => q.message(t, { symbol: styleText("red", gt) })
|
|
802
|
+
}, Pe = (t) => new ht$1({
|
|
803
|
+
validate: t.validate,
|
|
804
|
+
placeholder: t.placeholder,
|
|
805
|
+
defaultValue: t.defaultValue,
|
|
806
|
+
initialValue: t.initialValue,
|
|
807
|
+
output: t.output,
|
|
808
|
+
signal: t.signal,
|
|
809
|
+
input: t.input,
|
|
810
|
+
render() {
|
|
811
|
+
const i = t?.withGuide ?? h$1.withGuide, s = `${`${i ? `${styleText("gray", $)}
|
|
812
|
+
` : ""}${P$1(this.state)} `}${t.message}
|
|
813
|
+
`, r = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
814
|
+
switch (this.state) {
|
|
815
|
+
case "error": {
|
|
816
|
+
const a = this.error ? ` ${styleText("yellow", this.error)}` : "", c = i ? `${styleText("yellow", $)} ` : "", o = i ? styleText("yellow", x$1) : "";
|
|
817
|
+
return `${s.trim()}
|
|
818
|
+
${c}${u}
|
|
819
|
+
${o}${a}
|
|
820
|
+
`;
|
|
821
|
+
}
|
|
822
|
+
case "submit": {
|
|
823
|
+
const a = n ? ` ${styleText("dim", n)}` : "";
|
|
824
|
+
return `${s}${i ? styleText("gray", $) : ""}${a}`;
|
|
825
|
+
}
|
|
826
|
+
case "cancel": {
|
|
827
|
+
const a = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c = i ? styleText("gray", $) : "";
|
|
828
|
+
return `${s}${c}${a}${n.trim() ? `
|
|
829
|
+
${c}` : ""}`;
|
|
830
|
+
}
|
|
831
|
+
default: return `${s}${i ? `${styleText("cyan", $)} ` : ""}${u}
|
|
832
|
+
${i ? styleText("cyan", x$1) : ""}
|
|
833
|
+
`;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}).prompt();
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region src/constants/deps.ts
|
|
839
|
+
const DEPS = ["ts-pattern"];
|
|
840
|
+
const DEV_DEPS = [
|
|
841
|
+
"@antfu/eslint-config",
|
|
842
|
+
"eslint",
|
|
843
|
+
"rolldown",
|
|
844
|
+
"tsx",
|
|
845
|
+
"typescript"
|
|
846
|
+
];
|
|
847
|
+
//#endregion
|
|
848
|
+
//#region src/constants/questions.ts
|
|
849
|
+
const DEFAULT_PROJECT_NAME = "ts-start";
|
|
850
|
+
//#endregion
|
|
851
|
+
//#region src/utils/get-latest-ver.ts
|
|
852
|
+
async function getLatestVer(pkg) {
|
|
853
|
+
const encoded = pkg.startsWith("@") ? pkg.replace("/", "%2F") : pkg;
|
|
854
|
+
const res = await fetch(`https://registry.npmjs.org/${encoded}/latest`);
|
|
855
|
+
if (!res.ok) throw new Error(`Failed to fetch version for ${pkg}`);
|
|
856
|
+
const { version } = await res.json();
|
|
857
|
+
return `^${version}`;
|
|
858
|
+
}
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region node_modules/.pnpm/ts-pattern@5.9.0/node_modules/ts-pattern/dist/index.js
|
|
861
|
+
const t = Symbol.for("@ts-pattern/matcher"), e = Symbol.for("@ts-pattern/isVariadic"), n = "@ts-pattern/anonymous-select-key", r = (t) => Boolean(t && "object" == typeof t), i = (e) => e && !!e[t], o = (n, s, c) => {
|
|
862
|
+
if (i(n)) {
|
|
863
|
+
const { matched: r, selections: i } = n[t]().match(s);
|
|
864
|
+
return r && i && Object.keys(i).forEach((t) => c(t, i[t])), r;
|
|
865
|
+
}
|
|
866
|
+
if (r(n)) {
|
|
867
|
+
if (!r(s)) return !1;
|
|
868
|
+
if (Array.isArray(n)) {
|
|
869
|
+
if (!Array.isArray(s)) return !1;
|
|
870
|
+
let t = [], r = [], u = [];
|
|
871
|
+
for (const o of n.keys()) {
|
|
872
|
+
const s = n[o];
|
|
873
|
+
i(s) && s[e] ? u.push(s) : u.length ? r.push(s) : t.push(s);
|
|
874
|
+
}
|
|
875
|
+
if (u.length) {
|
|
876
|
+
if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
877
|
+
if (s.length < t.length + r.length) return !1;
|
|
878
|
+
const e = s.slice(0, t.length), n = 0 === r.length ? [] : s.slice(-r.length), i = s.slice(t.length, 0 === r.length ? Infinity : -r.length);
|
|
879
|
+
return t.every((t, n) => o(t, e[n], c)) && r.every((t, e) => o(t, n[e], c)) && (0 === u.length || o(u[0], i, c));
|
|
880
|
+
}
|
|
881
|
+
return n.length === s.length && n.every((t, e) => o(t, s[e], c));
|
|
882
|
+
}
|
|
883
|
+
return Reflect.ownKeys(n).every((e) => {
|
|
884
|
+
const r = n[e];
|
|
885
|
+
return (e in s || i(u = r) && "optional" === u[t]().matcherType) && o(r, s[e], c);
|
|
886
|
+
var u;
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
return Object.is(s, n);
|
|
890
|
+
}, s = (e) => {
|
|
891
|
+
var n, o, u;
|
|
892
|
+
return r(e) ? i(e) ? null != (n = null == (o = (u = e[t]()).getSelectionKeys) ? void 0 : o.call(u)) ? n : [] : Array.isArray(e) ? c(e, s) : c(Object.values(e), s) : [];
|
|
893
|
+
}, c = (t, e) => t.reduce((t, n) => t.concat(e(n)), []);
|
|
894
|
+
function u(...t) {
|
|
895
|
+
if (1 === t.length) {
|
|
896
|
+
const [e] = t;
|
|
897
|
+
return (t) => o(e, t, () => {});
|
|
898
|
+
}
|
|
899
|
+
if (2 === t.length) {
|
|
900
|
+
const [e, n] = t;
|
|
901
|
+
return o(e, n, () => {});
|
|
902
|
+
}
|
|
903
|
+
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
|
|
904
|
+
}
|
|
905
|
+
function a(t) {
|
|
906
|
+
return Object.assign(t, {
|
|
907
|
+
optional: () => h(t),
|
|
908
|
+
and: (e) => d(t, e),
|
|
909
|
+
or: (e) => y(t, e),
|
|
910
|
+
select: (e) => void 0 === e ? v(t) : v(e, t)
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
function l(t) {
|
|
914
|
+
return Object.assign(((t) => Object.assign(t, { [Symbol.iterator]() {
|
|
915
|
+
let n = 0;
|
|
916
|
+
const r = [{
|
|
917
|
+
value: Object.assign(t, { [e]: !0 }),
|
|
918
|
+
done: !1
|
|
919
|
+
}, {
|
|
920
|
+
done: !0,
|
|
921
|
+
value: void 0
|
|
922
|
+
}];
|
|
923
|
+
return { next: () => {
|
|
924
|
+
var t;
|
|
925
|
+
return null != (t = r[n++]) ? t : r.at(-1);
|
|
926
|
+
} };
|
|
927
|
+
} }))(t), {
|
|
928
|
+
optional: () => l(h(t)),
|
|
929
|
+
select: (e) => l(void 0 === e ? v(t) : v(e, t))
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
function h(e) {
|
|
933
|
+
return a({ [t]: () => ({
|
|
934
|
+
match: (t) => {
|
|
935
|
+
let n = {};
|
|
936
|
+
const r = (t, e) => {
|
|
937
|
+
n[t] = e;
|
|
938
|
+
};
|
|
939
|
+
return void 0 === t ? (s(e).forEach((t) => r(t, void 0)), {
|
|
940
|
+
matched: !0,
|
|
941
|
+
selections: n
|
|
942
|
+
}) : {
|
|
943
|
+
matched: o(e, t, r),
|
|
944
|
+
selections: n
|
|
945
|
+
};
|
|
946
|
+
},
|
|
947
|
+
getSelectionKeys: () => s(e),
|
|
948
|
+
matcherType: "optional"
|
|
949
|
+
}) });
|
|
950
|
+
}
|
|
951
|
+
const f = (t, e) => {
|
|
952
|
+
for (const n of t) if (!e(n)) return !1;
|
|
953
|
+
return !0;
|
|
954
|
+
}, g = (t, e) => {
|
|
955
|
+
for (const [n, r] of t.entries()) if (!e(r, n)) return !1;
|
|
956
|
+
return !0;
|
|
957
|
+
}, m = (t, e) => {
|
|
958
|
+
const n = Reflect.ownKeys(t);
|
|
959
|
+
for (const r of n) if (!e(r, t[r])) return !1;
|
|
960
|
+
return !0;
|
|
961
|
+
};
|
|
962
|
+
function d(...e) {
|
|
963
|
+
return a({ [t]: () => ({
|
|
964
|
+
match: (t) => {
|
|
965
|
+
let n = {};
|
|
966
|
+
const r = (t, e) => {
|
|
967
|
+
n[t] = e;
|
|
968
|
+
};
|
|
969
|
+
return {
|
|
970
|
+
matched: e.every((e) => o(e, t, r)),
|
|
971
|
+
selections: n
|
|
972
|
+
};
|
|
973
|
+
},
|
|
974
|
+
getSelectionKeys: () => c(e, s),
|
|
975
|
+
matcherType: "and"
|
|
976
|
+
}) });
|
|
977
|
+
}
|
|
978
|
+
function y(...e) {
|
|
979
|
+
return a({ [t]: () => ({
|
|
980
|
+
match: (t) => {
|
|
981
|
+
let n = {};
|
|
982
|
+
const r = (t, e) => {
|
|
983
|
+
n[t] = e;
|
|
984
|
+
};
|
|
985
|
+
return c(e, s).forEach((t) => r(t, void 0)), {
|
|
986
|
+
matched: e.some((e) => o(e, t, r)),
|
|
987
|
+
selections: n
|
|
988
|
+
};
|
|
989
|
+
},
|
|
990
|
+
getSelectionKeys: () => c(e, s),
|
|
991
|
+
matcherType: "or"
|
|
992
|
+
}) });
|
|
993
|
+
}
|
|
994
|
+
function p(e) {
|
|
995
|
+
return { [t]: () => ({ match: (t) => ({ matched: Boolean(e(t)) }) }) };
|
|
996
|
+
}
|
|
997
|
+
function v(...e) {
|
|
998
|
+
const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
|
|
999
|
+
return a({ [t]: () => ({
|
|
1000
|
+
match: (t) => {
|
|
1001
|
+
let e = { [null != r ? r : n]: t };
|
|
1002
|
+
return {
|
|
1003
|
+
matched: void 0 === i || o(i, t, (t, n) => {
|
|
1004
|
+
e[t] = n;
|
|
1005
|
+
}),
|
|
1006
|
+
selections: e
|
|
1007
|
+
};
|
|
1008
|
+
},
|
|
1009
|
+
getSelectionKeys: () => [null != r ? r : n].concat(void 0 === i ? [] : s(i))
|
|
1010
|
+
}) });
|
|
1011
|
+
}
|
|
1012
|
+
function b(t) {
|
|
1013
|
+
return !0;
|
|
1014
|
+
}
|
|
1015
|
+
function w(t) {
|
|
1016
|
+
return "number" == typeof t;
|
|
1017
|
+
}
|
|
1018
|
+
function S(t) {
|
|
1019
|
+
return "string" == typeof t;
|
|
1020
|
+
}
|
|
1021
|
+
function j(t) {
|
|
1022
|
+
return "bigint" == typeof t;
|
|
1023
|
+
}
|
|
1024
|
+
const K = a(p(b)), O = a(p(b)), E$1 = K, x = (t) => Object.assign(a(t), {
|
|
1025
|
+
startsWith: (e) => {
|
|
1026
|
+
return x(d(t, (n = e, p((t) => S(t) && t.startsWith(n)))));
|
|
1027
|
+
var n;
|
|
1028
|
+
},
|
|
1029
|
+
endsWith: (e) => {
|
|
1030
|
+
return x(d(t, (n = e, p((t) => S(t) && t.endsWith(n)))));
|
|
1031
|
+
var n;
|
|
1032
|
+
},
|
|
1033
|
+
minLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length >= t))(e))),
|
|
1034
|
+
length: (e) => x(d(t, ((t) => p((e) => S(e) && e.length === t))(e))),
|
|
1035
|
+
maxLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length <= t))(e))),
|
|
1036
|
+
includes: (e) => {
|
|
1037
|
+
return x(d(t, (n = e, p((t) => S(t) && t.includes(n)))));
|
|
1038
|
+
var n;
|
|
1039
|
+
},
|
|
1040
|
+
regex: (e) => {
|
|
1041
|
+
return x(d(t, (n = e, p((t) => S(t) && Boolean(t.match(n))))));
|
|
1042
|
+
var n;
|
|
1043
|
+
}
|
|
1044
|
+
}), A = x(p(S)), N = (t) => Object.assign(a(t), {
|
|
1045
|
+
between: (e, n) => N(d(t, ((t, e) => p((n) => w(n) && t <= n && e >= n))(e, n))),
|
|
1046
|
+
lt: (e) => N(d(t, ((t) => p((e) => w(e) && e < t))(e))),
|
|
1047
|
+
gt: (e) => N(d(t, ((t) => p((e) => w(e) && e > t))(e))),
|
|
1048
|
+
lte: (e) => N(d(t, ((t) => p((e) => w(e) && e <= t))(e))),
|
|
1049
|
+
gte: (e) => N(d(t, ((t) => p((e) => w(e) && e >= t))(e))),
|
|
1050
|
+
int: () => N(d(t, p((t) => w(t) && Number.isInteger(t)))),
|
|
1051
|
+
finite: () => N(d(t, p((t) => w(t) && Number.isFinite(t)))),
|
|
1052
|
+
positive: () => N(d(t, p((t) => w(t) && t > 0))),
|
|
1053
|
+
negative: () => N(d(t, p((t) => w(t) && t < 0)))
|
|
1054
|
+
}), P = N(p(w)), k = (t) => Object.assign(a(t), {
|
|
1055
|
+
between: (e, n) => k(d(t, ((t, e) => p((n) => j(n) && t <= n && e >= n))(e, n))),
|
|
1056
|
+
lt: (e) => k(d(t, ((t) => p((e) => j(e) && e < t))(e))),
|
|
1057
|
+
gt: (e) => k(d(t, ((t) => p((e) => j(e) && e > t))(e))),
|
|
1058
|
+
lte: (e) => k(d(t, ((t) => p((e) => j(e) && e <= t))(e))),
|
|
1059
|
+
gte: (e) => k(d(t, ((t) => p((e) => j(e) && e >= t))(e))),
|
|
1060
|
+
positive: () => k(d(t, p((t) => j(t) && t > 0))),
|
|
1061
|
+
negative: () => k(d(t, p((t) => j(t) && t < 0)))
|
|
1062
|
+
});
|
|
1063
|
+
var z = {
|
|
1064
|
+
__proto__: null,
|
|
1065
|
+
matcher: t,
|
|
1066
|
+
optional: h,
|
|
1067
|
+
array: function(...e) {
|
|
1068
|
+
return l({ [t]: () => ({
|
|
1069
|
+
match: (t) => {
|
|
1070
|
+
if (!Array.isArray(t)) return { matched: !1 };
|
|
1071
|
+
if (0 === e.length) return { matched: !0 };
|
|
1072
|
+
const n = e[0];
|
|
1073
|
+
let r = {};
|
|
1074
|
+
if (0 === t.length) return s(n).forEach((t) => {
|
|
1075
|
+
r[t] = [];
|
|
1076
|
+
}), {
|
|
1077
|
+
matched: !0,
|
|
1078
|
+
selections: r
|
|
1079
|
+
};
|
|
1080
|
+
const i = (t, e) => {
|
|
1081
|
+
r[t] = (r[t] || []).concat([e]);
|
|
1082
|
+
};
|
|
1083
|
+
return {
|
|
1084
|
+
matched: t.every((t) => o(n, t, i)),
|
|
1085
|
+
selections: r
|
|
1086
|
+
};
|
|
1087
|
+
},
|
|
1088
|
+
getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
|
|
1089
|
+
}) });
|
|
1090
|
+
},
|
|
1091
|
+
set: function(...e) {
|
|
1092
|
+
return a({ [t]: () => ({
|
|
1093
|
+
match: (t) => {
|
|
1094
|
+
if (!(t instanceof Set)) return { matched: !1 };
|
|
1095
|
+
let n = {};
|
|
1096
|
+
if (0 === t.size) return {
|
|
1097
|
+
matched: !0,
|
|
1098
|
+
selections: n
|
|
1099
|
+
};
|
|
1100
|
+
if (0 === e.length) return { matched: !0 };
|
|
1101
|
+
const r = (t, e) => {
|
|
1102
|
+
n[t] = (n[t] || []).concat([e]);
|
|
1103
|
+
}, i = e[0];
|
|
1104
|
+
return {
|
|
1105
|
+
matched: f(t, (t) => o(i, t, r)),
|
|
1106
|
+
selections: n
|
|
1107
|
+
};
|
|
1108
|
+
},
|
|
1109
|
+
getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
|
|
1110
|
+
}) });
|
|
1111
|
+
},
|
|
1112
|
+
map: function(...e) {
|
|
1113
|
+
return a({ [t]: () => ({
|
|
1114
|
+
match: (t) => {
|
|
1115
|
+
if (!(t instanceof Map)) return { matched: !1 };
|
|
1116
|
+
let n = {};
|
|
1117
|
+
if (0 === t.size) return {
|
|
1118
|
+
matched: !0,
|
|
1119
|
+
selections: n
|
|
1120
|
+
};
|
|
1121
|
+
const r = (t, e) => {
|
|
1122
|
+
n[t] = (n[t] || []).concat([e]);
|
|
1123
|
+
};
|
|
1124
|
+
if (0 === e.length) return { matched: !0 };
|
|
1125
|
+
var i;
|
|
1126
|
+
if (1 === e.length) throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null == (i = e[0]) ? void 0 : i.toString()}`);
|
|
1127
|
+
const [s, c] = e;
|
|
1128
|
+
return {
|
|
1129
|
+
matched: g(t, (t, e) => {
|
|
1130
|
+
const n = o(s, e, r), i = o(c, t, r);
|
|
1131
|
+
return n && i;
|
|
1132
|
+
}),
|
|
1133
|
+
selections: n
|
|
1134
|
+
};
|
|
1135
|
+
},
|
|
1136
|
+
getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
|
|
1137
|
+
}) });
|
|
1138
|
+
},
|
|
1139
|
+
record: function(...e) {
|
|
1140
|
+
return a({ [t]: () => ({
|
|
1141
|
+
match: (t) => {
|
|
1142
|
+
if (null === t || "object" != typeof t || Array.isArray(t)) return { matched: !1 };
|
|
1143
|
+
var n;
|
|
1144
|
+
if (0 === e.length) throw new Error(`\`P.record\` wasn't given enough arguments. Expected (value) or (key, value), received ${null == (n = e[0]) ? void 0 : n.toString()}`);
|
|
1145
|
+
let r = {};
|
|
1146
|
+
const i = (t, e) => {
|
|
1147
|
+
r[t] = (r[t] || []).concat([e]);
|
|
1148
|
+
}, [s, c] = 1 === e.length ? [A, e[0]] : e;
|
|
1149
|
+
return {
|
|
1150
|
+
matched: m(t, (t, e) => {
|
|
1151
|
+
const n = "string" != typeof t || Number.isNaN(Number(t)) ? null : Number(t), r = null !== n && o(s, n, i), u = o(s, t, i), a = o(c, e, i);
|
|
1152
|
+
return (u || r) && a;
|
|
1153
|
+
}),
|
|
1154
|
+
selections: r
|
|
1155
|
+
};
|
|
1156
|
+
},
|
|
1157
|
+
getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
|
|
1158
|
+
}) });
|
|
1159
|
+
},
|
|
1160
|
+
intersection: d,
|
|
1161
|
+
union: y,
|
|
1162
|
+
not: function(e) {
|
|
1163
|
+
return a({ [t]: () => ({
|
|
1164
|
+
match: (t) => ({ matched: !o(e, t, () => {}) }),
|
|
1165
|
+
getSelectionKeys: () => [],
|
|
1166
|
+
matcherType: "not"
|
|
1167
|
+
}) });
|
|
1168
|
+
},
|
|
1169
|
+
when: p,
|
|
1170
|
+
select: v,
|
|
1171
|
+
any: K,
|
|
1172
|
+
unknown: O,
|
|
1173
|
+
_: E$1,
|
|
1174
|
+
string: A,
|
|
1175
|
+
number: P,
|
|
1176
|
+
bigint: k(p(j)),
|
|
1177
|
+
boolean: a(p(function(t) {
|
|
1178
|
+
return "boolean" == typeof t;
|
|
1179
|
+
})),
|
|
1180
|
+
symbol: a(p(function(t) {
|
|
1181
|
+
return "symbol" == typeof t;
|
|
1182
|
+
})),
|
|
1183
|
+
nullish: a(p(function(t) {
|
|
1184
|
+
return null == t;
|
|
1185
|
+
})),
|
|
1186
|
+
nonNullable: a(p(function(t) {
|
|
1187
|
+
return null != t;
|
|
1188
|
+
})),
|
|
1189
|
+
instanceOf: function(t) {
|
|
1190
|
+
return a(p(function(t) {
|
|
1191
|
+
return (e) => e instanceof t;
|
|
1192
|
+
}(t)));
|
|
1193
|
+
},
|
|
1194
|
+
shape: function(t) {
|
|
1195
|
+
return a(p(u(t)));
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
var I = class extends Error {
|
|
1199
|
+
constructor(t) {
|
|
1200
|
+
let e;
|
|
1201
|
+
try {
|
|
1202
|
+
e = JSON.stringify(t);
|
|
1203
|
+
} catch (n) {
|
|
1204
|
+
e = t;
|
|
1205
|
+
}
|
|
1206
|
+
super(`Pattern matching error: no pattern matches value ${e}`), this.input = void 0, this.input = t;
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
const L = {
|
|
1210
|
+
matched: !1,
|
|
1211
|
+
value: void 0
|
|
1212
|
+
};
|
|
1213
|
+
function M(t) {
|
|
1214
|
+
return new R(t, L);
|
|
1215
|
+
}
|
|
1216
|
+
var R = class R {
|
|
1217
|
+
constructor(t, e) {
|
|
1218
|
+
this.input = void 0, this.state = void 0, this.input = t, this.state = e;
|
|
1219
|
+
}
|
|
1220
|
+
with(...t) {
|
|
1221
|
+
if (this.state.matched) return this;
|
|
1222
|
+
const e = t[t.length - 1], r = [t[0]];
|
|
1223
|
+
let i;
|
|
1224
|
+
3 === t.length && "function" == typeof t[1] ? i = t[1] : t.length > 2 && r.push(...t.slice(1, t.length - 1));
|
|
1225
|
+
let s = !1, c = {};
|
|
1226
|
+
const u = (t, e) => {
|
|
1227
|
+
s = !0, c[t] = e;
|
|
1228
|
+
}, a = !r.some((t) => o(t, this.input, u)) || i && !Boolean(i(this.input)) ? L : {
|
|
1229
|
+
matched: !0,
|
|
1230
|
+
value: e(s ? n in c ? c[n] : c : this.input, this.input)
|
|
1231
|
+
};
|
|
1232
|
+
return new R(this.input, a);
|
|
1233
|
+
}
|
|
1234
|
+
when(t, e) {
|
|
1235
|
+
if (this.state.matched) return this;
|
|
1236
|
+
const n = Boolean(t(this.input));
|
|
1237
|
+
return new R(this.input, n ? {
|
|
1238
|
+
matched: !0,
|
|
1239
|
+
value: e(this.input, this.input)
|
|
1240
|
+
} : L);
|
|
1241
|
+
}
|
|
1242
|
+
otherwise(t) {
|
|
1243
|
+
return this.state.matched ? this.state.value : t(this.input);
|
|
1244
|
+
}
|
|
1245
|
+
exhaustive(t = F) {
|
|
1246
|
+
return this.state.matched ? this.state.value : t(this.input);
|
|
1247
|
+
}
|
|
1248
|
+
run() {
|
|
1249
|
+
return this.exhaustive();
|
|
1250
|
+
}
|
|
1251
|
+
returnType() {
|
|
1252
|
+
return this;
|
|
1253
|
+
}
|
|
1254
|
+
narrow() {
|
|
1255
|
+
return this;
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
function F(t) {
|
|
1259
|
+
throw new I(t);
|
|
1260
|
+
}
|
|
1261
|
+
//#endregion
|
|
1262
|
+
//#region src/utils/get-project-name.ts
|
|
1263
|
+
async function getProjectName() {
|
|
1264
|
+
return argv[2]?.trim() || await askProjectName();
|
|
1265
|
+
}
|
|
1266
|
+
async function askProjectName() {
|
|
1267
|
+
return M(await Pe({
|
|
1268
|
+
message: "Project name",
|
|
1269
|
+
placeholder: DEFAULT_PROJECT_NAME,
|
|
1270
|
+
defaultValue: DEFAULT_PROJECT_NAME
|
|
1271
|
+
})).with(z.string, (name) => name).with(z.when(q$1), () => {
|
|
1272
|
+
me("Operation cancelled");
|
|
1273
|
+
exit(0);
|
|
1274
|
+
}).exhaustive();
|
|
1275
|
+
}
|
|
1276
|
+
//#endregion
|
|
1277
|
+
//#region src/utils/resolve-new-dir.ts
|
|
1278
|
+
function resolveNewDir(projectName) {
|
|
1279
|
+
const targetDir = resolve(cwd(), projectName);
|
|
1280
|
+
if (existsSync(targetDir)) {
|
|
1281
|
+
me(`Directory already exists: ${targetDir}`);
|
|
1282
|
+
exit(1);
|
|
1283
|
+
}
|
|
1284
|
+
return targetDir;
|
|
1285
|
+
}
|
|
1286
|
+
//#endregion
|
|
1287
|
+
//#region src/index.ts
|
|
1288
|
+
async function main() {
|
|
1289
|
+
ge("create-template-ts");
|
|
1290
|
+
const projectName = await getProjectName();
|
|
1291
|
+
const targetDir = resolveNewDir(projectName);
|
|
1292
|
+
const s = ft();
|
|
1293
|
+
s.start("Fetching latest package versions");
|
|
1294
|
+
const [depVers, devDepVers] = await Promise.all([Promise.all(DEPS.map(async (dep) => [dep, await getLatestVer(dep)])), Promise.all(DEV_DEPS.map(async (dep) => [dep, await getLatestVer(dep)]))]);
|
|
1295
|
+
const deps = { ...Object.fromEntries(depVers) };
|
|
1296
|
+
const devDeps = {
|
|
1297
|
+
...Object.fromEntries(devDepVers),
|
|
1298
|
+
"@types/node": `^${version.match(/^v(\d+)/)?.[1]}`
|
|
1299
|
+
};
|
|
1300
|
+
s.stop("Fetched latest package versions");
|
|
1301
|
+
const templateDir = join(import.meta.dirname, "../template");
|
|
1302
|
+
mkdirSync(targetDir, { recursive: true });
|
|
1303
|
+
cpSync(templateDir, targetDir, { recursive: true });
|
|
1304
|
+
const gitignoreSrc = join(targetDir, "_gitignore");
|
|
1305
|
+
const gitignoreDst = join(targetDir, ".gitignore");
|
|
1306
|
+
if (existsSync(gitignoreSrc)) renameSync(gitignoreSrc, gitignoreDst);
|
|
1307
|
+
const vscodeSrc = join(targetDir, "_vscode");
|
|
1308
|
+
const vscodeDst = join(targetDir, ".vscode");
|
|
1309
|
+
if (existsSync(vscodeSrc)) renameSync(vscodeSrc, vscodeDst);
|
|
1310
|
+
const pkgPath = join(targetDir, "package.json");
|
|
1311
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
1312
|
+
pkg.name = basename(projectName);
|
|
1313
|
+
pkg.dependencies = deps;
|
|
1314
|
+
pkg.devDependencies = devDeps;
|
|
1315
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 4)}\n`);
|
|
1316
|
+
ye(`Done! Run:\n\n cd ${projectName}\n pnpm install`);
|
|
1317
|
+
}
|
|
1318
|
+
main().catch((err) => {
|
|
1319
|
+
console.error(err);
|
|
1320
|
+
exit(1);
|
|
1321
|
+
});
|
|
1322
|
+
//#endregion
|
|
1323
|
+
export {};
|