@rshono/create 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -0
- package/bin/create-rshono.mjs +29 -0
- package/dist/api.mjs +749 -0
- package/dist/cli.mjs +3930 -0
- package/package.json +59 -0
- package/templates/base/README.md +42 -0
- package/templates/base/_env +9 -0
- package/templates/base/_gitignore +8 -0
- package/templates/base/public/favicon.svg +1 -0
- package/templates/base/public/robots.txt +2 -0
- package/templates/base/rshono.config.ts +35 -0
- package/templates/base/src/actions.ts +19 -0
- package/templates/base/src/components/404.tsx +17 -0
- package/templates/base/src/components/500.tsx +21 -0
- package/templates/base/src/components/greet-form.tsx +27 -0
- package/templates/base/src/components/home.tsx +50 -0
- package/templates/base/src/components/layout.tsx +45 -0
- package/templates/base/src/env.d.ts +2 -0
- package/templates/base/src/lib/env.ts +26 -0
- package/templates/base/src/routes.ts +32 -0
- package/templates/base/src/server.ts +59 -0
- package/templates/base/src/styles.css +178 -0
- package/templates/base/tsconfig.json +20 -0
- package/templates/biome/biome.json +7 -0
- package/templates/biome-tailwind/biome.json +7 -0
- package/templates/oxfmt/_oxfmtrc.json +7 -0
- package/templates/oxlint/_oxlintrc.json +7 -0
- package/templates/prettier/_prettierignore +10 -0
- package/templates/prettier/_prettierrc.json +7 -0
- package/templates/tailwind/postcss.config.mjs +9 -0
- package/templates/tailwind/rshono.config.ts +45 -0
- package/templates/tailwind/src/components/home.tsx +50 -0
- package/templates/tailwind/src/components/layout.tsx +45 -0
- package/templates/tailwind/src/styles.css +40 -0
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,3930 @@
|
|
|
1
|
+
// Bundled by rspack — edit src/ and rebuild. Includes @clack/prompts (MIT).
|
|
2
|
+
import {fileURLToPath as __rspack_fileURLToPath} from "node:url";
|
|
3
|
+
import {dirname as __rspack_dirname} from "node:path";
|
|
4
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
5
|
+
import { parseArgs, styleText as external_node_util_styleText } from "node:util";
|
|
6
|
+
import node_process, { stdin as external_node_process_stdin, stdout as external_node_process_stdout } from "node:process";
|
|
7
|
+
import node_readline from "node:readline";
|
|
8
|
+
import "node:tty";
|
|
9
|
+
import { existsSync as external_node_fs_existsSync, mkdirSync, readFileSync, readdirSync as external_node_fs_readdirSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { basename, dirname as external_node_path_dirname, join as external_node_path_join, posix, relative as external_node_path_relative, resolve, sep } from "node:path";
|
|
11
|
+
import { spawnSync } from "node:child_process";
|
|
12
|
+
var __webpack_modules__ = ({
|
|
13
|
+
347(module) {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const ESC = '\x1B';
|
|
17
|
+
const CSI = `${ESC}[`;
|
|
18
|
+
const beep = '\u0007';
|
|
19
|
+
|
|
20
|
+
const cursor = {
|
|
21
|
+
to(x, y) {
|
|
22
|
+
if (!y) return `${CSI}${x + 1}G`;
|
|
23
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
24
|
+
},
|
|
25
|
+
move(x, y) {
|
|
26
|
+
let ret = '';
|
|
27
|
+
|
|
28
|
+
if (x < 0) ret += `${CSI}${-x}D`;
|
|
29
|
+
else if (x > 0) ret += `${CSI}${x}C`;
|
|
30
|
+
|
|
31
|
+
if (y < 0) ret += `${CSI}${-y}A`;
|
|
32
|
+
else if (y > 0) ret += `${CSI}${y}B`;
|
|
33
|
+
|
|
34
|
+
return ret;
|
|
35
|
+
},
|
|
36
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
37
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
38
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
39
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
40
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
41
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
42
|
+
left: `${CSI}G`,
|
|
43
|
+
hide: `${CSI}?25l`,
|
|
44
|
+
show: `${CSI}?25h`,
|
|
45
|
+
save: `${ESC}7`,
|
|
46
|
+
restore: `${ESC}8`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const scroll = {
|
|
50
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
51
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const erase = {
|
|
55
|
+
screen: `${CSI}2J`,
|
|
56
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
57
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
58
|
+
line: `${CSI}2K`,
|
|
59
|
+
lineEnd: `${CSI}K`,
|
|
60
|
+
lineStart: `${CSI}1K`,
|
|
61
|
+
lines(count) {
|
|
62
|
+
let clear = '';
|
|
63
|
+
for (let i = 0; i < count; i++)
|
|
64
|
+
clear += this.line + (i < count - 1 ? cursor.up() : '');
|
|
65
|
+
if (count)
|
|
66
|
+
clear += cursor.left;
|
|
67
|
+
return clear;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
});
|
|
77
|
+
// The module cache
|
|
78
|
+
var __webpack_module_cache__ = {};
|
|
79
|
+
|
|
80
|
+
// The require function
|
|
81
|
+
function __webpack_require__(moduleId) {
|
|
82
|
+
|
|
83
|
+
// Check if module is in cache
|
|
84
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
85
|
+
if (cachedModule !== undefined) {
|
|
86
|
+
return cachedModule.exports;
|
|
87
|
+
}
|
|
88
|
+
// Create a new module (and put it into the cache)
|
|
89
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
90
|
+
exports: {}
|
|
91
|
+
});
|
|
92
|
+
// Execute the module function
|
|
93
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
94
|
+
|
|
95
|
+
// Return the exports of the module
|
|
96
|
+
return module.exports;
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var __webpack_exports__ = {};
|
|
101
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
102
|
+
(() => {
|
|
103
|
+
|
|
104
|
+
;// CONCATENATED MODULE: external "node:util"
|
|
105
|
+
|
|
106
|
+
;// CONCATENATED MODULE: external "node:process"
|
|
107
|
+
|
|
108
|
+
;// CONCATENATED MODULE: external "node:readline"
|
|
109
|
+
|
|
110
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
111
|
+
/* MAIN */
|
|
112
|
+
const getCodePointsLength = (() => {
|
|
113
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
114
|
+
return (input) => {
|
|
115
|
+
let surrogatePairsNr = 0;
|
|
116
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
117
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
118
|
+
surrogatePairsNr += 1;
|
|
119
|
+
}
|
|
120
|
+
return input.length - surrogatePairsNr;
|
|
121
|
+
};
|
|
122
|
+
})();
|
|
123
|
+
const isFullWidth = (x) => {
|
|
124
|
+
return x === 0x3000 || x >= 0xFF01 && x <= 0xFF60 || x >= 0xFFE0 && x <= 0xFFE6;
|
|
125
|
+
};
|
|
126
|
+
const isWideNotCJKTNotEmoji = (x) => {
|
|
127
|
+
return x === 0x231B || x === 0x2329 || x >= 0x2FF0 && x <= 0x2FFF || x >= 0x3001 && x <= 0x303E || x >= 0x3099 && x <= 0x30FF || x >= 0x3105 && x <= 0x312F || x >= 0x3131 && x <= 0x318E || x >= 0x3190 && x <= 0x31E3 || x >= 0x31EF && x <= 0x321E || x >= 0x3220 && x <= 0x3247 || x >= 0x3250 && x <= 0x4DBF || x >= 0xFE10 && x <= 0xFE19 || x >= 0xFE30 && x <= 0xFE52 || x >= 0xFE54 && x <= 0xFE66 || x >= 0xFE68 && x <= 0xFE6B || x >= 0x1F200 && x <= 0x1F202 || x >= 0x1F210 && x <= 0x1F23B || x >= 0x1F240 && x <= 0x1F248 || x >= 0x20000 && x <= 0x2FFFD || x >= 0x30000 && x <= 0x3FFFD;
|
|
128
|
+
};
|
|
129
|
+
/* EXPORT */
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
133
|
+
/* IMPORT */
|
|
134
|
+
|
|
135
|
+
/* HELPERS */
|
|
136
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
137
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
138
|
+
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}/yu;
|
|
139
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
140
|
+
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?))*/yu;
|
|
141
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
142
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
143
|
+
const NO_TRUNCATION = { limit: Infinity, ellipsis: '' };
|
|
144
|
+
/* MAIN */
|
|
145
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
146
|
+
/* CONSTANTS */
|
|
147
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
148
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? '';
|
|
149
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
150
|
+
const ANSI_WIDTH = 0;
|
|
151
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
152
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
153
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
154
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
155
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
156
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
157
|
+
const PARSE_BLOCKS = [
|
|
158
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
159
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
160
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
161
|
+
[TAB_RE, TAB_WIDTH],
|
|
162
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
163
|
+
[CJKT_WIDE_RE, WIDE_WIDTH],
|
|
164
|
+
];
|
|
165
|
+
/* STATE */
|
|
166
|
+
let indexPrev = 0;
|
|
167
|
+
let index = 0;
|
|
168
|
+
let length = input.length;
|
|
169
|
+
let lengthExtra = 0;
|
|
170
|
+
let truncationEnabled = false;
|
|
171
|
+
let truncationIndex = length;
|
|
172
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
173
|
+
let unmatchedStart = 0;
|
|
174
|
+
let unmatchedEnd = 0;
|
|
175
|
+
let width = 0;
|
|
176
|
+
let widthExtra = 0;
|
|
177
|
+
/* PARSE LOOP */
|
|
178
|
+
outer: while (true) {
|
|
179
|
+
/* UNMATCHED */
|
|
180
|
+
if ((unmatchedEnd > unmatchedStart) || (index >= length && index > indexPrev)) {
|
|
181
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
182
|
+
lengthExtra = 0;
|
|
183
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, '')) {
|
|
184
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
185
|
+
if (isFullWidth(codePoint)) {
|
|
186
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
187
|
+
}
|
|
188
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
189
|
+
widthExtra = WIDE_WIDTH;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
widthExtra = REGULAR_WIDTH;
|
|
193
|
+
}
|
|
194
|
+
if ((width + widthExtra) > truncationLimit) {
|
|
195
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
196
|
+
}
|
|
197
|
+
if ((width + widthExtra) > LIMIT) {
|
|
198
|
+
truncationEnabled = true;
|
|
199
|
+
break outer;
|
|
200
|
+
}
|
|
201
|
+
lengthExtra += char.length;
|
|
202
|
+
width += widthExtra;
|
|
203
|
+
}
|
|
204
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
205
|
+
}
|
|
206
|
+
/* EXITING */
|
|
207
|
+
if (index >= length) {
|
|
208
|
+
break outer;
|
|
209
|
+
}
|
|
210
|
+
/* PARSE BLOCKS */
|
|
211
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
212
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
213
|
+
BLOCK_RE.lastIndex = index;
|
|
214
|
+
if (BLOCK_RE.test(input)) {
|
|
215
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
216
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
217
|
+
if ((width + widthExtra) > truncationLimit) {
|
|
218
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
219
|
+
}
|
|
220
|
+
if ((width + widthExtra) > LIMIT) {
|
|
221
|
+
truncationEnabled = true;
|
|
222
|
+
break outer;
|
|
223
|
+
}
|
|
224
|
+
width += widthExtra;
|
|
225
|
+
unmatchedStart = indexPrev;
|
|
226
|
+
unmatchedEnd = index;
|
|
227
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
228
|
+
continue outer;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/* UNMATCHED INDEX */
|
|
232
|
+
index += 1;
|
|
233
|
+
}
|
|
234
|
+
/* RETURN */
|
|
235
|
+
return {
|
|
236
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
237
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
238
|
+
truncated: truncationEnabled,
|
|
239
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
/* EXPORT */
|
|
243
|
+
/* export default */ const dist = (getStringTruncatedWidth);
|
|
244
|
+
|
|
245
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
246
|
+
/* IMPORT */
|
|
247
|
+
|
|
248
|
+
/* HELPERS */
|
|
249
|
+
const dist_NO_TRUNCATION = {
|
|
250
|
+
limit: Infinity,
|
|
251
|
+
ellipsis: '',
|
|
252
|
+
ellipsisWidth: 0,
|
|
253
|
+
};
|
|
254
|
+
/* MAIN */
|
|
255
|
+
const fastStringWidth = (input, options = {}) => {
|
|
256
|
+
return dist(input, dist_NO_TRUNCATION, options).width;
|
|
257
|
+
};
|
|
258
|
+
/* EXPORT */
|
|
259
|
+
/* export default */ const fast_string_width_dist = (fastStringWidth);
|
|
260
|
+
|
|
261
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
262
|
+
|
|
263
|
+
const ESC = '\x1B';
|
|
264
|
+
const CSI = '\x9B';
|
|
265
|
+
const END_CODE = 39;
|
|
266
|
+
const ANSI_ESCAPE_BELL = '\u0007';
|
|
267
|
+
const ANSI_CSI = '[';
|
|
268
|
+
const ANSI_OSC = ']';
|
|
269
|
+
const ANSI_SGR_TERMINATOR = 'm';
|
|
270
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
271
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, 'y');
|
|
272
|
+
const getClosingCode = (openingCode) => {
|
|
273
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
274
|
+
return 39;
|
|
275
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
276
|
+
return 39;
|
|
277
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
278
|
+
return 49;
|
|
279
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
280
|
+
return 49;
|
|
281
|
+
if (openingCode === 1 || openingCode === 2)
|
|
282
|
+
return 22;
|
|
283
|
+
if (openingCode === 3)
|
|
284
|
+
return 23;
|
|
285
|
+
if (openingCode === 4)
|
|
286
|
+
return 24;
|
|
287
|
+
if (openingCode === 7)
|
|
288
|
+
return 27;
|
|
289
|
+
if (openingCode === 8)
|
|
290
|
+
return 28;
|
|
291
|
+
if (openingCode === 9)
|
|
292
|
+
return 29;
|
|
293
|
+
if (openingCode === 0)
|
|
294
|
+
return 0;
|
|
295
|
+
return undefined;
|
|
296
|
+
};
|
|
297
|
+
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
298
|
+
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
299
|
+
const wrapWord = (rows, word, columns) => {
|
|
300
|
+
const characters = word[Symbol.iterator]();
|
|
301
|
+
let isInsideEscape = false;
|
|
302
|
+
let isInsideLinkEscape = false;
|
|
303
|
+
let lastRow = rows.at(-1);
|
|
304
|
+
let visible = lastRow === undefined ? 0 : fast_string_width_dist(lastRow);
|
|
305
|
+
let currentCharacter = characters.next();
|
|
306
|
+
let nextCharacter = characters.next();
|
|
307
|
+
let rawCharacterIndex = 0;
|
|
308
|
+
while (!currentCharacter.done) {
|
|
309
|
+
const character = currentCharacter.value;
|
|
310
|
+
const characterLength = fast_string_width_dist(character);
|
|
311
|
+
if (visible + characterLength <= columns) {
|
|
312
|
+
rows[rows.length - 1] += character;
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
rows.push(character);
|
|
316
|
+
visible = 0;
|
|
317
|
+
}
|
|
318
|
+
if (character === ESC || character === CSI) {
|
|
319
|
+
isInsideEscape = true;
|
|
320
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
321
|
+
}
|
|
322
|
+
if (isInsideEscape) {
|
|
323
|
+
if (isInsideLinkEscape) {
|
|
324
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
325
|
+
isInsideEscape = false;
|
|
326
|
+
isInsideLinkEscape = false;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else if (character === ANSI_SGR_TERMINATOR) {
|
|
330
|
+
isInsideEscape = false;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
visible += characterLength;
|
|
335
|
+
if (visible === columns && !nextCharacter.done) {
|
|
336
|
+
rows.push('');
|
|
337
|
+
visible = 0;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
currentCharacter = nextCharacter;
|
|
341
|
+
nextCharacter = characters.next();
|
|
342
|
+
rawCharacterIndex += character.length;
|
|
343
|
+
}
|
|
344
|
+
lastRow = rows.at(-1);
|
|
345
|
+
if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
|
|
346
|
+
rows[rows.length - 2] += rows.pop();
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
const stringVisibleTrimSpacesRight = (string) => {
|
|
350
|
+
const words = string.split(' ');
|
|
351
|
+
let last = words.length;
|
|
352
|
+
while (last) {
|
|
353
|
+
if (fast_string_width_dist(words[last - 1])) {
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
last--;
|
|
357
|
+
}
|
|
358
|
+
if (last === words.length) {
|
|
359
|
+
return string;
|
|
360
|
+
}
|
|
361
|
+
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
|
362
|
+
};
|
|
363
|
+
const exec = (string, columns, options = {}) => {
|
|
364
|
+
if (options.trim !== false && string.trim() === '') {
|
|
365
|
+
return '';
|
|
366
|
+
}
|
|
367
|
+
let returnValue = '';
|
|
368
|
+
let escapeCode;
|
|
369
|
+
let escapeUrl;
|
|
370
|
+
const words = string.split(' ');
|
|
371
|
+
let rows = [''];
|
|
372
|
+
let rowLength = 0;
|
|
373
|
+
for (let index = 0; index < words.length; index++) {
|
|
374
|
+
const word = words[index];
|
|
375
|
+
if (options.trim !== false) {
|
|
376
|
+
const row = rows.at(-1) ?? '';
|
|
377
|
+
const trimmed = row.trimStart();
|
|
378
|
+
if (row.length !== trimmed.length) {
|
|
379
|
+
rows[rows.length - 1] = trimmed;
|
|
380
|
+
rowLength = fast_string_width_dist(trimmed);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (index !== 0) {
|
|
384
|
+
if (rowLength >= columns &&
|
|
385
|
+
(options.wordWrap === false || options.trim === false)) {
|
|
386
|
+
rows.push('');
|
|
387
|
+
rowLength = 0;
|
|
388
|
+
}
|
|
389
|
+
if (rowLength || options.trim === false) {
|
|
390
|
+
rows[rows.length - 1] += ' ';
|
|
391
|
+
rowLength++;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const wordLength = fast_string_width_dist(word);
|
|
395
|
+
if (options.hard && wordLength > columns) {
|
|
396
|
+
const remainingColumns = columns - rowLength;
|
|
397
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
398
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
399
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
400
|
+
rows.push('');
|
|
401
|
+
}
|
|
402
|
+
wrapWord(rows, word, columns);
|
|
403
|
+
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
407
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
408
|
+
wrapWord(rows, word, columns);
|
|
409
|
+
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
rows.push('');
|
|
413
|
+
rowLength = 0;
|
|
414
|
+
}
|
|
415
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
416
|
+
wrapWord(rows, word, columns);
|
|
417
|
+
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
rows[rows.length - 1] += word;
|
|
421
|
+
rowLength += wordLength;
|
|
422
|
+
}
|
|
423
|
+
if (options.trim !== false) {
|
|
424
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
425
|
+
}
|
|
426
|
+
const preString = rows.join('\n');
|
|
427
|
+
let inSurrogate = false;
|
|
428
|
+
for (let i = 0; i < preString.length; i++) {
|
|
429
|
+
const character = preString[i];
|
|
430
|
+
returnValue += character;
|
|
431
|
+
if (!inSurrogate) {
|
|
432
|
+
inSurrogate = character >= '\ud800' && character <= '\udbff';
|
|
433
|
+
if (inSurrogate) {
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
inSurrogate = false;
|
|
439
|
+
}
|
|
440
|
+
if (character === ESC || character === CSI) {
|
|
441
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
442
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
443
|
+
const groups = groupsResult?.groups;
|
|
444
|
+
if (groups?.code !== undefined) {
|
|
445
|
+
const code = Number.parseFloat(groups.code);
|
|
446
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
447
|
+
}
|
|
448
|
+
else if (groups?.uri !== undefined) {
|
|
449
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (preString[i + 1] === '\n') {
|
|
453
|
+
if (escapeUrl) {
|
|
454
|
+
returnValue += wrapAnsiHyperlink('');
|
|
455
|
+
}
|
|
456
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
|
|
457
|
+
if (escapeCode && closingCode) {
|
|
458
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
else if (character === '\n') {
|
|
462
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
463
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
464
|
+
}
|
|
465
|
+
if (escapeUrl) {
|
|
466
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return returnValue;
|
|
471
|
+
};
|
|
472
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
473
|
+
function main_wrapAnsi(string, columns, options) {
|
|
474
|
+
return String(string)
|
|
475
|
+
.normalize()
|
|
476
|
+
.split(CRLF_OR_LF)
|
|
477
|
+
.map((line) => exec(line, columns, options))
|
|
478
|
+
.join('\n');
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
482
|
+
var src = __webpack_require__(347);
|
|
483
|
+
;// CONCATENATED MODULE: external "node:tty"
|
|
484
|
+
|
|
485
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
function findCursor(s, o, l) {
|
|
495
|
+
if (!l.some((r) => !r.disabled))
|
|
496
|
+
return s;
|
|
497
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
498
|
+
return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
499
|
+
}
|
|
500
|
+
function findTextCursor(s, o, l, i) {
|
|
501
|
+
const t = i.split(`
|
|
502
|
+
`);
|
|
503
|
+
let n = 0, e = s;
|
|
504
|
+
for (const r of t) {
|
|
505
|
+
if (e <= r.length)
|
|
506
|
+
break;
|
|
507
|
+
e -= r.length + 1, n++;
|
|
508
|
+
}
|
|
509
|
+
for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + o; e < 0 && n > 0; )
|
|
510
|
+
n--, e += t[n].length + 1;
|
|
511
|
+
for (; e > t[n].length && n < t.length - 1; )
|
|
512
|
+
e -= t[n].length + 1, n++;
|
|
513
|
+
e = Math.max(0, Math.min(t[n].length, e));
|
|
514
|
+
let h = 0;
|
|
515
|
+
for (let r = 0; r < n; r++)
|
|
516
|
+
h += t[r].length + 1;
|
|
517
|
+
return h + e;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"], dist_t = [
|
|
521
|
+
"January",
|
|
522
|
+
"February",
|
|
523
|
+
"March",
|
|
524
|
+
"April",
|
|
525
|
+
"May",
|
|
526
|
+
"June",
|
|
527
|
+
"July",
|
|
528
|
+
"August",
|
|
529
|
+
"September",
|
|
530
|
+
"October",
|
|
531
|
+
"November",
|
|
532
|
+
"December"
|
|
533
|
+
];
|
|
534
|
+
const dist_settings = {
|
|
535
|
+
actions: new Set(a$1),
|
|
536
|
+
aliases: /* @__PURE__ */ new Map([
|
|
537
|
+
// vim support
|
|
538
|
+
["k", "up"],
|
|
539
|
+
["j", "down"],
|
|
540
|
+
["h", "left"],
|
|
541
|
+
["l", "right"],
|
|
542
|
+
["", "cancel"],
|
|
543
|
+
// opinionated defaults!
|
|
544
|
+
["escape", "cancel"]
|
|
545
|
+
]),
|
|
546
|
+
messages: {
|
|
547
|
+
cancel: "Canceled",
|
|
548
|
+
error: "Something went wrong"
|
|
549
|
+
},
|
|
550
|
+
withGuide: true,
|
|
551
|
+
date: {
|
|
552
|
+
monthNames: [...dist_t],
|
|
553
|
+
messages: {
|
|
554
|
+
required: "Please enter a valid date",
|
|
555
|
+
invalidMonth: "There are only 12 months in a year",
|
|
556
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
557
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
558
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
function updateSettings(n) {
|
|
563
|
+
if (n.aliases !== void 0) {
|
|
564
|
+
const e = n.aliases;
|
|
565
|
+
for (const s in e) {
|
|
566
|
+
if (!Object.hasOwn(e, s)) continue;
|
|
567
|
+
const i = e[s];
|
|
568
|
+
i === void 0 || !dist_settings.actions.has(i) || dist_settings.aliases.has(s) || dist_settings.aliases.set(s, i);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (n.messages !== void 0) {
|
|
572
|
+
const e = n.messages;
|
|
573
|
+
e.cancel !== void 0 && (dist_settings.messages.cancel = e.cancel), e.error !== void 0 && (dist_settings.messages.error = e.error);
|
|
574
|
+
}
|
|
575
|
+
if (n.withGuide !== void 0 && (dist_settings.withGuide = n.withGuide !== false), n.date !== void 0) {
|
|
576
|
+
const e = n.date;
|
|
577
|
+
e.monthNames !== void 0 && (dist_settings.date.monthNames = [...e.monthNames]), e.messages !== void 0 && (e.messages.required !== void 0 && (dist_settings.date.messages.required = e.messages.required), e.messages.invalidMonth !== void 0 && (dist_settings.date.messages.invalidMonth = e.messages.invalidMonth), e.messages.invalidDay !== void 0 && (dist_settings.date.messages.invalidDay = e.messages.invalidDay), e.messages.afterMin !== void 0 && (dist_settings.date.messages.afterMin = e.messages.afterMin), e.messages.beforeMax !== void 0 && (dist_settings.date.messages.beforeMax = e.messages.beforeMax));
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function isActionKey(n, e) {
|
|
581
|
+
if (typeof n == "string")
|
|
582
|
+
return dist_settings.aliases.get(n) === e;
|
|
583
|
+
for (const s of n)
|
|
584
|
+
if (s !== void 0 && isActionKey(s, e))
|
|
585
|
+
return true;
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function diffLines(i, s) {
|
|
590
|
+
if (i === s) return;
|
|
591
|
+
const e = i.split(`
|
|
592
|
+
`), t = s.split(`
|
|
593
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
594
|
+
for (let n = 0; n < r; n++)
|
|
595
|
+
e[n] !== t[n] && f.push(n);
|
|
596
|
+
return {
|
|
597
|
+
lines: f,
|
|
598
|
+
numLinesBefore: e.length,
|
|
599
|
+
numLinesAfter: t.length,
|
|
600
|
+
numLines: r
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const dist_R = globalThis.process.platform.startsWith("win");
|
|
605
|
+
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
606
|
+
function dist_isCancel(e) {
|
|
607
|
+
return e === CANCEL_SYMBOL;
|
|
608
|
+
}
|
|
609
|
+
function setRawMode(e, r) {
|
|
610
|
+
const o = e;
|
|
611
|
+
o.isTTY && o.setRawMode(r);
|
|
612
|
+
}
|
|
613
|
+
function dist_block({
|
|
614
|
+
input: e = stdin,
|
|
615
|
+
output: r = stdout,
|
|
616
|
+
overwrite: o = true,
|
|
617
|
+
hideCursor: t = true
|
|
618
|
+
} = {}) {
|
|
619
|
+
const s = l.createInterface({
|
|
620
|
+
input: e,
|
|
621
|
+
output: r,
|
|
622
|
+
prompt: "",
|
|
623
|
+
tabSize: 1
|
|
624
|
+
});
|
|
625
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
626
|
+
const n = (f, { name: a, sequence: p }) => {
|
|
627
|
+
const c = String(f);
|
|
628
|
+
if (isActionKey([c, a, p], "cancel")) {
|
|
629
|
+
t && r.write(cursor.show), process.exit(0);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (!o) return;
|
|
633
|
+
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
634
|
+
l.moveCursor(r, i, m, () => {
|
|
635
|
+
l.clearLine(r, 1, () => {
|
|
636
|
+
e.once("keypress", n);
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
return t && r.write(cursor.hide), e.once("keypress", n), () => {
|
|
641
|
+
e.off("keypress", n), t && r.write(cursor.show), e instanceof ReadStream && e.isTTY && !dist_R && e.setRawMode(false), s.terminal = false, s.close();
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
const dist_getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
645
|
+
function dist_wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
646
|
+
const f = dist_getColumns(e ?? external_node_process_stdout);
|
|
647
|
+
return main_wrapAnsi(r, f - o.length, {
|
|
648
|
+
hard: true,
|
|
649
|
+
trim: false
|
|
650
|
+
}).split(`
|
|
651
|
+
`).map((c, i, m) => {
|
|
652
|
+
const d = n ? n(c, i) : c;
|
|
653
|
+
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
654
|
+
}).join(`
|
|
655
|
+
`);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function dist_runValidation(e, n) {
|
|
659
|
+
if ("~standard" in e) {
|
|
660
|
+
const a = e["~standard"].validate(n);
|
|
661
|
+
if (a instanceof Promise)
|
|
662
|
+
throw new TypeError(
|
|
663
|
+
"Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic."
|
|
664
|
+
);
|
|
665
|
+
return a.issues?.at(0)?.message;
|
|
666
|
+
}
|
|
667
|
+
return e(n);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
class dist_V {
|
|
671
|
+
input;
|
|
672
|
+
output;
|
|
673
|
+
_abortSignal;
|
|
674
|
+
rl;
|
|
675
|
+
opts;
|
|
676
|
+
_render;
|
|
677
|
+
_track = false;
|
|
678
|
+
_prevFrame = "";
|
|
679
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
680
|
+
_cursor = 0;
|
|
681
|
+
state = "initial";
|
|
682
|
+
error = "";
|
|
683
|
+
value;
|
|
684
|
+
userInput = "";
|
|
685
|
+
constructor(t, e = true) {
|
|
686
|
+
const { input: i = external_node_process_stdin, output: n = external_node_process_stdout, render: s, signal: r, ...o } = t;
|
|
687
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Unsubscribe all listeners
|
|
691
|
+
*/
|
|
692
|
+
unsubscribe() {
|
|
693
|
+
this._subscribers.clear();
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Set a subscriber with opts
|
|
697
|
+
* @param event - The event name
|
|
698
|
+
*/
|
|
699
|
+
setSubscriber(t, e) {
|
|
700
|
+
const i = this._subscribers.get(t) ?? [];
|
|
701
|
+
i.push(e), this._subscribers.set(t, i);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Subscribe to an event
|
|
705
|
+
* @param event - The event name
|
|
706
|
+
* @param cb - The callback
|
|
707
|
+
*/
|
|
708
|
+
on(t, e) {
|
|
709
|
+
this.setSubscriber(t, { cb: e });
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Subscribe to an event once
|
|
713
|
+
* @param event - The event name
|
|
714
|
+
* @param cb - The callback
|
|
715
|
+
*/
|
|
716
|
+
once(t, e) {
|
|
717
|
+
this.setSubscriber(t, { cb: e, once: true });
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Emit an event with data
|
|
721
|
+
* @param event - The event name
|
|
722
|
+
* @param data - The data to pass to the callback
|
|
723
|
+
*/
|
|
724
|
+
emit(t, ...e) {
|
|
725
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
726
|
+
for (const s of i)
|
|
727
|
+
s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
728
|
+
for (const s of n)
|
|
729
|
+
s();
|
|
730
|
+
}
|
|
731
|
+
prompt() {
|
|
732
|
+
return new Promise((t) => {
|
|
733
|
+
if (this._abortSignal) {
|
|
734
|
+
if (this._abortSignal.aborted)
|
|
735
|
+
return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
736
|
+
this._abortSignal.addEventListener(
|
|
737
|
+
"abort",
|
|
738
|
+
() => {
|
|
739
|
+
this.state = "cancel", this.close();
|
|
740
|
+
},
|
|
741
|
+
{ once: true }
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
this.rl = node_readline.createInterface({
|
|
745
|
+
input: this.input,
|
|
746
|
+
tabSize: 2,
|
|
747
|
+
prompt: "",
|
|
748
|
+
escapeCodeTimeout: 50,
|
|
749
|
+
terminal: true
|
|
750
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
751
|
+
this.output.write(src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
752
|
+
}), this.once("cancel", () => {
|
|
753
|
+
this.output.write(src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
_isActionKey(t, e) {
|
|
758
|
+
return t === " ";
|
|
759
|
+
}
|
|
760
|
+
_shouldSubmit(t, e) {
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
_setValue(t) {
|
|
764
|
+
this.value = t, this.emit("value", this.value);
|
|
765
|
+
}
|
|
766
|
+
_setUserInput(t, e) {
|
|
767
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
768
|
+
}
|
|
769
|
+
_clearUserInput() {
|
|
770
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
771
|
+
}
|
|
772
|
+
onKeypress(t, e) {
|
|
773
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && 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"), e?.name && (!this._track && dist_settings.aliases.has(e.name) && this.emit("cursor", dist_settings.aliases.get(e.name)), dist_settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
774
|
+
if (this.opts.validate) {
|
|
775
|
+
const i = dist_runValidation(this.opts.validate, this.value);
|
|
776
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
777
|
+
}
|
|
778
|
+
this.state !== "error" && (this.state = "submit");
|
|
779
|
+
}
|
|
780
|
+
isActionKey([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
781
|
+
}
|
|
782
|
+
close() {
|
|
783
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
784
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
785
|
+
}
|
|
786
|
+
restoreCursor() {
|
|
787
|
+
const t = main_wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
788
|
+
`).length - 1;
|
|
789
|
+
this.output.write(src.cursor.move(-999, t * -1));
|
|
790
|
+
}
|
|
791
|
+
render() {
|
|
792
|
+
const t = main_wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
793
|
+
hard: true,
|
|
794
|
+
trim: false
|
|
795
|
+
});
|
|
796
|
+
if (t !== this._prevFrame) {
|
|
797
|
+
if (this.state === "initial")
|
|
798
|
+
this.output.write(src.cursor.hide);
|
|
799
|
+
else {
|
|
800
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
801
|
+
if (this.restoreCursor(), e) {
|
|
802
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
803
|
+
let r = e.lines.find((o) => o >= n);
|
|
804
|
+
if (r === void 0) {
|
|
805
|
+
this._prevFrame = t;
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (e.lines.length === 1) {
|
|
809
|
+
this.output.write(src.cursor.move(0, r - s)), this.output.write(src.erase.lines(1));
|
|
810
|
+
const o = t.split(`
|
|
811
|
+
`);
|
|
812
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(src.cursor.move(0, o.length - r - 1));
|
|
813
|
+
return;
|
|
814
|
+
} else if (e.lines.length > 1) {
|
|
815
|
+
if (n < s)
|
|
816
|
+
r = n;
|
|
817
|
+
else {
|
|
818
|
+
const h = r - s;
|
|
819
|
+
h > 0 && this.output.write(src.cursor.move(0, h));
|
|
820
|
+
}
|
|
821
|
+
this.output.write(src.erase.down());
|
|
822
|
+
const f = t.split(`
|
|
823
|
+
`).slice(r);
|
|
824
|
+
this.output.write(f.join(`
|
|
825
|
+
`)), this._prevFrame = t;
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
this.output.write(src.erase.down());
|
|
830
|
+
}
|
|
831
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function p$1(l, e) {
|
|
837
|
+
if (l === void 0 || e.length === 0)
|
|
838
|
+
return 0;
|
|
839
|
+
const i = e.findIndex((s) => s.value === l);
|
|
840
|
+
return i !== -1 ? i : 0;
|
|
841
|
+
}
|
|
842
|
+
function dist_g(l, e) {
|
|
843
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
|
|
844
|
+
}
|
|
845
|
+
function dist_m(l, e) {
|
|
846
|
+
if (e)
|
|
847
|
+
return l ? e : e[0];
|
|
848
|
+
}
|
|
849
|
+
let T$1 = class T extends (/* unused pure expression or super */ null && (dist_V)) {
|
|
850
|
+
filteredOptions;
|
|
851
|
+
multiple;
|
|
852
|
+
isNavigating = false;
|
|
853
|
+
selectedValues = [];
|
|
854
|
+
focusedValue;
|
|
855
|
+
#e = 0;
|
|
856
|
+
#s = "";
|
|
857
|
+
#t;
|
|
858
|
+
#i;
|
|
859
|
+
#n;
|
|
860
|
+
get cursor() {
|
|
861
|
+
return this.#e;
|
|
862
|
+
}
|
|
863
|
+
get userInputWithCursor() {
|
|
864
|
+
if (!this.userInput)
|
|
865
|
+
return styleText(["inverse", "hidden"], "_");
|
|
866
|
+
if (this._cursor >= this.userInput.length)
|
|
867
|
+
return `${this.userInput}\u2588`;
|
|
868
|
+
const e = this.userInput.slice(0, this.cursor), t = this.userInput.slice(this.cursor, this.cursor + 1), i = this.userInput.slice(this.cursor + 1);
|
|
869
|
+
return `${e}${styleText("inverse", t)}${i}`;
|
|
870
|
+
}
|
|
871
|
+
get options() {
|
|
872
|
+
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
873
|
+
}
|
|
874
|
+
constructor(e) {
|
|
875
|
+
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
876
|
+
const t = this.options;
|
|
877
|
+
this.filteredOptions = [...t], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? dist_g;
|
|
878
|
+
let i;
|
|
879
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0]?.value]), i)
|
|
880
|
+
for (const s of i) {
|
|
881
|
+
const n = t.findIndex((o) => o.value === s);
|
|
882
|
+
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
883
|
+
}
|
|
884
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
885
|
+
}
|
|
886
|
+
_isActionKey(e, t) {
|
|
887
|
+
return e === " " || this.multiple && this.isNavigating && t.name === "space" && e !== void 0 && e !== "";
|
|
888
|
+
}
|
|
889
|
+
#l(e, t) {
|
|
890
|
+
const i = t.name === "up", s = t.name === "down", n = t.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#n, a = this.options, f = u !== void 0 && u !== "" && a.some(
|
|
891
|
+
(r) => !r.disabled && (this.#t ? this.#t(u, r) : true)
|
|
892
|
+
);
|
|
893
|
+
if (t.name === "tab" && o && f) {
|
|
894
|
+
this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = dist_m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (t.name === "tab" || this.isNavigating && t.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
898
|
+
}
|
|
899
|
+
deselectAll() {
|
|
900
|
+
this.selectedValues = [];
|
|
901
|
+
}
|
|
902
|
+
toggleSelected(e) {
|
|
903
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t) => t !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
904
|
+
}
|
|
905
|
+
#u(e) {
|
|
906
|
+
if (e !== this.#s) {
|
|
907
|
+
this.#s = e;
|
|
908
|
+
const t = this.options;
|
|
909
|
+
e && this.#t ? this.filteredOptions = t.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t];
|
|
910
|
+
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
911
|
+
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
912
|
+
const s = this.filteredOptions[this.#e];
|
|
913
|
+
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
class dist_r extends dist_V {
|
|
919
|
+
get cursor() {
|
|
920
|
+
return this.value ? 0 : 1;
|
|
921
|
+
}
|
|
922
|
+
get _value() {
|
|
923
|
+
return this.cursor === 0;
|
|
924
|
+
}
|
|
925
|
+
constructor(t) {
|
|
926
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
927
|
+
this.value = this._value;
|
|
928
|
+
}), this.on("confirm", (i) => {
|
|
929
|
+
this.output.write(src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
930
|
+
}), this.on("cursor", () => {
|
|
931
|
+
this.value = !this.value;
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
const dist_ = {
|
|
937
|
+
Y: { type: "year", len: 4 },
|
|
938
|
+
M: { type: "month", len: 2 },
|
|
939
|
+
D: { type: "day", len: 2 }
|
|
940
|
+
};
|
|
941
|
+
function dist_M(r) {
|
|
942
|
+
return [...r].map((t) => dist_[t]);
|
|
943
|
+
}
|
|
944
|
+
function dist_P(r) {
|
|
945
|
+
const i = new Intl.DateTimeFormat(r, {
|
|
946
|
+
year: "numeric",
|
|
947
|
+
month: "2-digit",
|
|
948
|
+
day: "2-digit"
|
|
949
|
+
}).formatToParts(new Date(2e3, 0, 15)), s = [];
|
|
950
|
+
let n = "/";
|
|
951
|
+
for (const e of i)
|
|
952
|
+
e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
|
|
953
|
+
return { segments: s, separator: n };
|
|
954
|
+
}
|
|
955
|
+
function dist_p(r) {
|
|
956
|
+
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
957
|
+
}
|
|
958
|
+
function dist_f(r) {
|
|
959
|
+
return {
|
|
960
|
+
year: dist_p(r.year),
|
|
961
|
+
month: dist_p(r.month),
|
|
962
|
+
day: dist_p(r.day)
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
function dist_c(r, t) {
|
|
966
|
+
return new Date(r || 2001, t || 1, 0).getDate();
|
|
967
|
+
}
|
|
968
|
+
function dist_b(r) {
|
|
969
|
+
const { year: t, month: i, day: s } = dist_f(r);
|
|
970
|
+
if (!t || t < 0 || t > 9999 || !i || i < 1 || i > 12 || !s || s < 1) return;
|
|
971
|
+
const n = new Date(Date.UTC(t, i - 1, s));
|
|
972
|
+
if (!(n.getUTCFullYear() !== t || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
973
|
+
return { year: t, month: i, day: s };
|
|
974
|
+
}
|
|
975
|
+
function dist_C(r) {
|
|
976
|
+
const t = dist_b(r);
|
|
977
|
+
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
|
|
978
|
+
}
|
|
979
|
+
function dist_T(r, t, i, s) {
|
|
980
|
+
const n = i ? {
|
|
981
|
+
year: i.getUTCFullYear(),
|
|
982
|
+
month: i.getUTCMonth() + 1,
|
|
983
|
+
day: i.getUTCDate()
|
|
984
|
+
} : null, e = s ? {
|
|
985
|
+
year: s.getUTCFullYear(),
|
|
986
|
+
month: s.getUTCMonth() + 1,
|
|
987
|
+
day: s.getUTCDate()
|
|
988
|
+
} : null;
|
|
989
|
+
return r === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r === "month" ? {
|
|
990
|
+
min: n && t.year === n.year ? n.month : 1,
|
|
991
|
+
max: e && t.year === e.year ? e.month : 12
|
|
992
|
+
} : {
|
|
993
|
+
min: n && t.year === n.year && t.month === n.month ? n.day : 1,
|
|
994
|
+
max: e && t.year === e.year && t.month === e.month ? e.day : dist_c(t.year, t.month)
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
class U extends dist_V {
|
|
998
|
+
#i;
|
|
999
|
+
#o;
|
|
1000
|
+
#t;
|
|
1001
|
+
#h;
|
|
1002
|
+
#u;
|
|
1003
|
+
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
1004
|
+
#n = true;
|
|
1005
|
+
#s = null;
|
|
1006
|
+
inlineError = "";
|
|
1007
|
+
get segmentCursor() {
|
|
1008
|
+
return { ...this.#e };
|
|
1009
|
+
}
|
|
1010
|
+
get segmentValues() {
|
|
1011
|
+
return { ...this.#t };
|
|
1012
|
+
}
|
|
1013
|
+
get segments() {
|
|
1014
|
+
return this.#i;
|
|
1015
|
+
}
|
|
1016
|
+
get separator() {
|
|
1017
|
+
return this.#o;
|
|
1018
|
+
}
|
|
1019
|
+
get formattedValue() {
|
|
1020
|
+
return this.#l(this.#t);
|
|
1021
|
+
}
|
|
1022
|
+
#l(t) {
|
|
1023
|
+
return this.#i.map((i) => t[i.type]).join(this.#o);
|
|
1024
|
+
}
|
|
1025
|
+
#r() {
|
|
1026
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(dist_C(this.#t) ?? void 0);
|
|
1027
|
+
}
|
|
1028
|
+
constructor(t) {
|
|
1029
|
+
const i = t.format ? { segments: dist_M(t.format), separator: t.separator ?? "/" } : dist_P(t.locale), s = t.separator ?? i.separator, n = t.format ? dist_M(t.format) : i.segments, e = t.initialValue ?? t.defaultValue, m = e ? {
|
|
1030
|
+
year: String(e.getUTCFullYear()).padStart(4, "0"),
|
|
1031
|
+
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
1032
|
+
day: String(e.getUTCDate()).padStart(2, "0")
|
|
1033
|
+
} : { year: "____", month: "__", day: "__" }, o = n.map((a) => m[a.type]).join(s);
|
|
1034
|
+
super({ ...t, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m, this.#h = t.minDate, this.#u = t.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t));
|
|
1035
|
+
}
|
|
1036
|
+
#a() {
|
|
1037
|
+
const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t];
|
|
1038
|
+
if (i)
|
|
1039
|
+
return this.#e.positionInSegment = Math.max(
|
|
1040
|
+
0,
|
|
1041
|
+
Math.min(this.#e.positionInSegment, i.len - 1)
|
|
1042
|
+
), { segment: i, index: t };
|
|
1043
|
+
}
|
|
1044
|
+
#m(t) {
|
|
1045
|
+
this.inlineError = "", this.#s = null;
|
|
1046
|
+
const i = this.#a();
|
|
1047
|
+
i && (this.#e.segmentIndex = Math.max(
|
|
1048
|
+
0,
|
|
1049
|
+
Math.min(this.#i.length - 1, i.index + t)
|
|
1050
|
+
), this.#e.positionInSegment = 0, this.#n = true);
|
|
1051
|
+
}
|
|
1052
|
+
#d(t) {
|
|
1053
|
+
const i = this.#a();
|
|
1054
|
+
if (!i) return;
|
|
1055
|
+
const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = dist_T(
|
|
1056
|
+
s.type,
|
|
1057
|
+
dist_f(this.#t),
|
|
1058
|
+
this.#h,
|
|
1059
|
+
this.#u
|
|
1060
|
+
);
|
|
1061
|
+
let a;
|
|
1062
|
+
e ? a = t === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m + t), o.min), this.#t = {
|
|
1063
|
+
...this.#t,
|
|
1064
|
+
[s.type]: a.toString().padStart(s.len, "0")
|
|
1065
|
+
}, this.#n = true, this.#s = null, this.#r();
|
|
1066
|
+
}
|
|
1067
|
+
#f(t) {
|
|
1068
|
+
if (t)
|
|
1069
|
+
switch (t) {
|
|
1070
|
+
case "right":
|
|
1071
|
+
return this.#m(1);
|
|
1072
|
+
case "left":
|
|
1073
|
+
return this.#m(-1);
|
|
1074
|
+
case "up":
|
|
1075
|
+
return this.#d(1);
|
|
1076
|
+
case "down":
|
|
1077
|
+
return this.#d(-1);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
#y(t, i) {
|
|
1081
|
+
if (i?.name === "backspace" || i?.sequence === "\x7F" || i?.sequence === "\b" || t === "\x7F" || t === "\b") {
|
|
1082
|
+
this.inlineError = "";
|
|
1083
|
+
const n = this.#a();
|
|
1084
|
+
if (!n) return;
|
|
1085
|
+
if (!this.#t[n.segment.type].replace(/_/g, "")) {
|
|
1086
|
+
this.#m(-1);
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
if (i?.name === "tab") {
|
|
1093
|
+
this.inlineError = "";
|
|
1094
|
+
const n = this.#a();
|
|
1095
|
+
if (!n) return;
|
|
1096
|
+
const e = i.shift ? -1 : 1, m = n.index + e;
|
|
1097
|
+
m >= 0 && m < this.#i.length && (this.#e.segmentIndex = m, this.#e.positionInSegment = 0, this.#n = true);
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
if (t && /^[0-9]$/.test(t)) {
|
|
1101
|
+
const n = this.#a();
|
|
1102
|
+
if (!n) return;
|
|
1103
|
+
const { segment: e } = n, m = !this.#t[e.type].replace(/_/g, "");
|
|
1104
|
+
if (this.#n && this.#s !== null && !m) {
|
|
1105
|
+
const h = this.#s + t, d = { ...this.#t, [e.type]: h }, g = this.#g(d, e);
|
|
1106
|
+
if (g) {
|
|
1107
|
+
this.inlineError = g, this.#s = null, this.#n = false;
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
this.#n && !m && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
1114
|
+
const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
|
|
1115
|
+
if (u < 0 || u >= e.len) return;
|
|
1116
|
+
let l = o.slice(0, u) + t + o.slice(u + 1), D = false;
|
|
1117
|
+
if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
|
|
1118
|
+
const h = Number.parseInt(t, 10);
|
|
1119
|
+
l = `0${t}`, D = h <= (e.type === "month" ? 1 : 2);
|
|
1120
|
+
}
|
|
1121
|
+
if (e.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(e.len, "_")), !l.includes("_")) {
|
|
1122
|
+
const h = { ...this.#t, [e.type]: l }, d = this.#g(h, e);
|
|
1123
|
+
if (d) {
|
|
1124
|
+
this.inlineError = d;
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
this.inlineError = "", this.#t[e.type] = l;
|
|
1129
|
+
const y = l.includes("_") ? void 0 : dist_b(this.#t);
|
|
1130
|
+
if (y) {
|
|
1131
|
+
const { year: h, month: d } = y, g = dist_c(h, d);
|
|
1132
|
+
this.#t = {
|
|
1133
|
+
year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
|
|
1134
|
+
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
1135
|
+
day: String(Math.max(1, Math.min(g, y.day))).padStart(2, "0")
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
this.#r();
|
|
1139
|
+
const S = l.indexOf("_");
|
|
1140
|
+
D ? (this.#n = true, this.#s = t) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
#g(t, i) {
|
|
1144
|
+
const { month: s, day: n } = dist_f(t);
|
|
1145
|
+
if (i.type === "month" && (s < 0 || s > 12))
|
|
1146
|
+
return dist_settings.date.messages.invalidMonth;
|
|
1147
|
+
if (i.type === "day" && (n < 0 || n > 31))
|
|
1148
|
+
return dist_settings.date.messages.invalidDay(31, "any month");
|
|
1149
|
+
}
|
|
1150
|
+
#p(t) {
|
|
1151
|
+
const { year: i, month: s, day: n } = dist_f(this.#t);
|
|
1152
|
+
if (i && s && n) {
|
|
1153
|
+
const e = dist_c(i, s);
|
|
1154
|
+
this.#t = {
|
|
1155
|
+
...this.#t,
|
|
1156
|
+
day: String(Math.min(n, e)).padStart(2, "0")
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
this.value = dist_C(this.#t) ?? t.defaultValue ?? void 0;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
let u$2 = class u extends (/* unused pure expression or super */ null && (dist_V)) {
|
|
1164
|
+
options;
|
|
1165
|
+
cursor = 0;
|
|
1166
|
+
#t;
|
|
1167
|
+
getGroupItems(t) {
|
|
1168
|
+
return this.options.filter((r) => r.group === t);
|
|
1169
|
+
}
|
|
1170
|
+
isGroupSelected(t) {
|
|
1171
|
+
const r = this.getGroupItems(t), e = this.value;
|
|
1172
|
+
return e === void 0 ? false : r.every((s) => e.includes(s.value));
|
|
1173
|
+
}
|
|
1174
|
+
toggleValue() {
|
|
1175
|
+
const t = this.options[this.cursor];
|
|
1176
|
+
if (t !== void 0)
|
|
1177
|
+
if (this.value === void 0 && (this.value = []), t.group === true) {
|
|
1178
|
+
const r = t.value, e = this.getGroupItems(r);
|
|
1179
|
+
this.isGroupSelected(r) ? this.value = this.value.filter(
|
|
1180
|
+
(s) => e.findIndex((i) => i.value === s) === -1
|
|
1181
|
+
) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
1182
|
+
} else {
|
|
1183
|
+
const r = this.value.includes(t.value);
|
|
1184
|
+
this.value = r ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
constructor(t) {
|
|
1188
|
+
super(t, false);
|
|
1189
|
+
const { options: r } = t;
|
|
1190
|
+
this.#t = t.selectableGroups !== false, this.options = Object.entries(r).flatMap(([e, s]) => [
|
|
1191
|
+
{ value: e, group: true, label: e },
|
|
1192
|
+
...s.map((i) => ({ ...i, group: e }))
|
|
1193
|
+
]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(
|
|
1194
|
+
this.options.findIndex(({ value: e }) => e === t.cursorAt),
|
|
1195
|
+
this.#t ? 0 : 1
|
|
1196
|
+
), this.on("cursor", (e) => {
|
|
1197
|
+
switch (e) {
|
|
1198
|
+
case "left":
|
|
1199
|
+
case "up": {
|
|
1200
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1201
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1202
|
+
!this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1203
|
+
break;
|
|
1204
|
+
}
|
|
1205
|
+
case "down":
|
|
1206
|
+
case "right": {
|
|
1207
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1208
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1209
|
+
!this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1210
|
+
break;
|
|
1211
|
+
}
|
|
1212
|
+
case "space":
|
|
1213
|
+
this.toggleValue();
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
const dist_o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
1221
|
+
class dist_h extends dist_V {
|
|
1222
|
+
#t = false;
|
|
1223
|
+
#s;
|
|
1224
|
+
focused = "editor";
|
|
1225
|
+
get userInputWithCursor() {
|
|
1226
|
+
if (this.state === "submit")
|
|
1227
|
+
return this.userInput;
|
|
1228
|
+
const t = this.userInput;
|
|
1229
|
+
if (this.cursor >= t.length)
|
|
1230
|
+
return `${t}\u2588`;
|
|
1231
|
+
const s = t.slice(0, this.cursor), r = t.slice(this.cursor, this.cursor + 1), i = t.slice(this.cursor + 1);
|
|
1232
|
+
return r === `
|
|
1233
|
+
` ? `${s}\u2588
|
|
1234
|
+
${i}` : `${s}${external_node_util_styleText("inverse", r)}${i}`;
|
|
1235
|
+
}
|
|
1236
|
+
get cursor() {
|
|
1237
|
+
return this._cursor;
|
|
1238
|
+
}
|
|
1239
|
+
#r(t) {
|
|
1240
|
+
if (this.userInput.length === 0) {
|
|
1241
|
+
this._setUserInput(t);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
this._setUserInput(
|
|
1245
|
+
this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor)
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
#i(t) {
|
|
1249
|
+
const s = this.value ?? "";
|
|
1250
|
+
switch (t) {
|
|
1251
|
+
case "up":
|
|
1252
|
+
this._cursor = findTextCursor(this._cursor, 0, -1, s);
|
|
1253
|
+
return;
|
|
1254
|
+
case "down":
|
|
1255
|
+
this._cursor = findTextCursor(this._cursor, 0, 1, s);
|
|
1256
|
+
return;
|
|
1257
|
+
case "left":
|
|
1258
|
+
this._cursor = findTextCursor(this._cursor, -1, 0, s);
|
|
1259
|
+
return;
|
|
1260
|
+
case "right":
|
|
1261
|
+
this._cursor = findTextCursor(this._cursor, 1, 0, s);
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
_shouldSubmit(t, s) {
|
|
1266
|
+
if (this.#s)
|
|
1267
|
+
return this.focused === "submit" ? true : (this.#r(`
|
|
1268
|
+
`), this._cursor++, false);
|
|
1269
|
+
const r = this.#t;
|
|
1270
|
+
return this.#t = true, r && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
|
|
1271
|
+
` && (this._setUserInput(
|
|
1272
|
+
this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
|
|
1273
|
+
), this._cursor--), true) : (this.#r(`
|
|
1274
|
+
`), this._cursor++, false);
|
|
1275
|
+
}
|
|
1276
|
+
constructor(t) {
|
|
1277
|
+
const s = t.initialUserInput ?? t.initialValue;
|
|
1278
|
+
super(
|
|
1279
|
+
{
|
|
1280
|
+
...t,
|
|
1281
|
+
initialUserInput: s
|
|
1282
|
+
},
|
|
1283
|
+
false
|
|
1284
|
+
), s !== void 0 && (this._cursor = s.length), this.#s = t.showSubmit ?? false, this.on("key", (r, i) => {
|
|
1285
|
+
if (i?.name && dist_o.has(i.name)) {
|
|
1286
|
+
this.#t = false, this.#i(i.name);
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
if (r === " " && this.#s) {
|
|
1290
|
+
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
if (i?.name !== "return") {
|
|
1294
|
+
if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
|
|
1295
|
+
this._setUserInput(
|
|
1296
|
+
this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
|
|
1297
|
+
), this._cursor--;
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
if (i?.name === "delete" && this.cursor < this.userInput.length) {
|
|
1301
|
+
this._setUserInput(
|
|
1302
|
+
this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1)
|
|
1303
|
+
);
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
r && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r ?? ""), this._cursor++);
|
|
1307
|
+
}
|
|
1308
|
+
}), this.on("userInput", (r) => {
|
|
1309
|
+
this._setValue(r);
|
|
1310
|
+
}), this.on("finalize", () => {
|
|
1311
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
class dist_a extends dist_V {
|
|
1317
|
+
options;
|
|
1318
|
+
cursor = 0;
|
|
1319
|
+
get _value() {
|
|
1320
|
+
return this.options[this.cursor]?.value;
|
|
1321
|
+
}
|
|
1322
|
+
get _enabledOptions() {
|
|
1323
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
1324
|
+
}
|
|
1325
|
+
toggleAll() {
|
|
1326
|
+
const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
|
|
1327
|
+
this.value = i ? [] : e.map((t) => t.value);
|
|
1328
|
+
}
|
|
1329
|
+
toggleInvert() {
|
|
1330
|
+
const e = this.value;
|
|
1331
|
+
if (!e)
|
|
1332
|
+
return;
|
|
1333
|
+
const i = this._enabledOptions.filter((t) => !e.includes(t.value));
|
|
1334
|
+
this.value = i.map((t) => t.value);
|
|
1335
|
+
}
|
|
1336
|
+
toggleValue() {
|
|
1337
|
+
this.value === void 0 && (this.value = []);
|
|
1338
|
+
const e = this.value.includes(this._value);
|
|
1339
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
1340
|
+
}
|
|
1341
|
+
constructor(e) {
|
|
1342
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
1343
|
+
const i = Math.max(
|
|
1344
|
+
this.options.findIndex(({ value: t }) => t === e.cursorAt),
|
|
1345
|
+
0
|
|
1346
|
+
);
|
|
1347
|
+
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
|
|
1348
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
1349
|
+
}), this.on("cursor", (t) => {
|
|
1350
|
+
switch (t) {
|
|
1351
|
+
case "left":
|
|
1352
|
+
case "up":
|
|
1353
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1354
|
+
break;
|
|
1355
|
+
case "down":
|
|
1356
|
+
case "right":
|
|
1357
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1358
|
+
break;
|
|
1359
|
+
case "space":
|
|
1360
|
+
this.toggleValue();
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
let u$1 = class u extends (/* unused pure expression or super */ null && (dist_V)) {
|
|
1368
|
+
_mask = "\u2022";
|
|
1369
|
+
get cursor() {
|
|
1370
|
+
return this._cursor;
|
|
1371
|
+
}
|
|
1372
|
+
get masked() {
|
|
1373
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
1374
|
+
}
|
|
1375
|
+
get userInputWithCursor() {
|
|
1376
|
+
if (this.state === "submit" || this.state === "cancel")
|
|
1377
|
+
return this.masked;
|
|
1378
|
+
const t = this.userInput;
|
|
1379
|
+
if (this.cursor >= t.length)
|
|
1380
|
+
return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
|
|
1381
|
+
const s = this.masked, r = s.slice(0, this.cursor), i = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
|
|
1382
|
+
return `${r}${styleText("inverse", i)}${o}`;
|
|
1383
|
+
}
|
|
1384
|
+
clear() {
|
|
1385
|
+
this._clearUserInput();
|
|
1386
|
+
}
|
|
1387
|
+
constructor({ mask: t, ...s }) {
|
|
1388
|
+
super(s), this._mask = t ?? "\u2022", this.on("userInput", (r) => {
|
|
1389
|
+
this._setValue(r);
|
|
1390
|
+
}), this.on("finalize", () => {
|
|
1391
|
+
this.value === void 0 && (this.value = "");
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
let n$1 = class n extends dist_V {
|
|
1397
|
+
options;
|
|
1398
|
+
cursor = 0;
|
|
1399
|
+
get _selectedValue() {
|
|
1400
|
+
return this.options[this.cursor];
|
|
1401
|
+
}
|
|
1402
|
+
changeValue() {
|
|
1403
|
+
const e = this._selectedValue;
|
|
1404
|
+
this.value = e === void 0 ? void 0 : e.value;
|
|
1405
|
+
}
|
|
1406
|
+
constructor(e) {
|
|
1407
|
+
super(e, false), this.options = e.options;
|
|
1408
|
+
const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t = o === -1 ? 0 : o;
|
|
1409
|
+
this.cursor = this.options[t]?.disabled ? findCursor(t, 1, this.options) : t, this.changeValue(), this.on("cursor", (s) => {
|
|
1410
|
+
switch (s) {
|
|
1411
|
+
case "left":
|
|
1412
|
+
case "up":
|
|
1413
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1414
|
+
break;
|
|
1415
|
+
case "down":
|
|
1416
|
+
case "right":
|
|
1417
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1418
|
+
break;
|
|
1419
|
+
}
|
|
1420
|
+
this.changeValue();
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
class dist_u extends dist_V {
|
|
1426
|
+
options;
|
|
1427
|
+
cursor = 0;
|
|
1428
|
+
constructor(t) {
|
|
1429
|
+
super(t, false), this.options = t.options;
|
|
1430
|
+
const s = t.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
|
|
1431
|
+
this.cursor = Math.max(i.indexOf(t.initialValue), 0), this.on("key", (e) => {
|
|
1432
|
+
if (!e)
|
|
1433
|
+
return;
|
|
1434
|
+
const o = s ? e : e.toLowerCase();
|
|
1435
|
+
if (!i.includes(o))
|
|
1436
|
+
return;
|
|
1437
|
+
const n = this.options.find(({ value: [r] }) => s ? r === o : r?.toLowerCase() === o);
|
|
1438
|
+
n && (this.value = n.value, this.state = "submit", this.emit("submit"));
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
class dist_n extends dist_V {
|
|
1444
|
+
get userInputWithCursor() {
|
|
1445
|
+
if (this.state === "submit")
|
|
1446
|
+
return this.userInput;
|
|
1447
|
+
const t = this.userInput;
|
|
1448
|
+
if (this.cursor >= t.length)
|
|
1449
|
+
return `${this.userInput}\u2588`;
|
|
1450
|
+
const r = t.slice(0, this.cursor), s = t.slice(this.cursor, this.cursor + 1), e = t.slice(this.cursor + 1);
|
|
1451
|
+
return `${r}${external_node_util_styleText("inverse", s)}${e}`;
|
|
1452
|
+
}
|
|
1453
|
+
get cursor() {
|
|
1454
|
+
return this._cursor;
|
|
1455
|
+
}
|
|
1456
|
+
constructor(t) {
|
|
1457
|
+
super({
|
|
1458
|
+
...t,
|
|
1459
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
1460
|
+
}), this.on("userInput", (r) => {
|
|
1461
|
+
this._setValue(r);
|
|
1462
|
+
}), this.on("finalize", () => {
|
|
1463
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
;// CONCATENATED MODULE: external "node:fs"
|
|
1471
|
+
|
|
1472
|
+
;// CONCATENATED MODULE: external "node:path"
|
|
1473
|
+
|
|
1474
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@clack+prompts@1.7.0/node_modules/@clack/prompts/dist/index.mjs
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
function isUnicodeSupported() {
|
|
1486
|
+
if (node_process.platform !== 'win32') {
|
|
1487
|
+
return node_process.env.TERM !== 'linux'; // Linux console (kernel)
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
return Boolean(node_process.env.CI)
|
|
1491
|
+
|| Boolean(node_process.env.WT_SESSION) // Windows Terminal
|
|
1492
|
+
|| Boolean(node_process.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
|
1493
|
+
|| node_process.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
|
1494
|
+
|| node_process.env.TERM_PROGRAM === 'Terminus-Sublime'
|
|
1495
|
+
|| node_process.env.TERM_PROGRAM === 'vscode'
|
|
1496
|
+
|| node_process.env.TERM === 'xterm-256color'
|
|
1497
|
+
|| node_process.env.TERM === 'alacritty'
|
|
1498
|
+
|| node_process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", isTTY = (o) => o.isTTY === true, unicodeOr = (o, e) => unicode ? o : e, S_STEP_ACTIVE = unicodeOr("\u25C6", "*"), S_STEP_CANCEL = unicodeOr("\u25A0", "x"), S_STEP_ERROR = unicodeOr("\u25B2", "x"), S_STEP_SUBMIT = unicodeOr("\u25C7", "o"), S_BAR_START = unicodeOr("\u250C", "T"), S_BAR = unicodeOr("\u2502", "|"), S_BAR_END = unicodeOr("\u2514", "\u2014"), S_BAR_START_RIGHT = (/* unused pure expression or super */ null && (unicodeOr("\u2510", "T"))), S_BAR_END_RIGHT = (/* unused pure expression or super */ null && (unicodeOr("\u2518", "\u2014"))), S_RADIO_ACTIVE = unicodeOr("\u25CF", ">"), S_RADIO_INACTIVE = unicodeOr("\u25CB", " "), S_CHECKBOX_ACTIVE = (/* unused pure expression or super */ null && (unicodeOr("\u25FB", "[\u2022]"))), S_CHECKBOX_SELECTED = (/* unused pure expression or super */ null && (unicodeOr("\u25FC", "[+]"))), S_CHECKBOX_INACTIVE = (/* unused pure expression or super */ null && (unicodeOr("\u25FB", "[ ]"))), S_PASSWORD_MASK = (/* unused pure expression or super */ null && (unicodeOr("\u25AA", "\u2022"))), S_BAR_H = unicodeOr("\u2500", "-"), S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+"), S_CONNECT_LEFT = unicodeOr("\u251C", "+"), S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+"), S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+"), S_CORNER_TOP_LEFT = (/* unused pure expression or super */ null && (unicodeOr("\u256D", "+"))), S_INFO = unicodeOr("\u25CF", "\u2022"), S_SUCCESS = unicodeOr("\u25C6", "*"), S_WARN = unicodeOr("\u25B2", "!"), S_ERROR = unicodeOr("\u25A0", "x"), symbol = (o) => {
|
|
1502
|
+
switch (o) {
|
|
1503
|
+
case "initial":
|
|
1504
|
+
case "active":
|
|
1505
|
+
return external_node_util_styleText("cyan", S_STEP_ACTIVE);
|
|
1506
|
+
case "cancel":
|
|
1507
|
+
return external_node_util_styleText("red", S_STEP_CANCEL);
|
|
1508
|
+
case "error":
|
|
1509
|
+
return external_node_util_styleText("yellow", S_STEP_ERROR);
|
|
1510
|
+
case "submit":
|
|
1511
|
+
return external_node_util_styleText("green", S_STEP_SUBMIT);
|
|
1512
|
+
}
|
|
1513
|
+
}, symbolBar = (o) => {
|
|
1514
|
+
switch (o) {
|
|
1515
|
+
case "initial":
|
|
1516
|
+
case "active":
|
|
1517
|
+
return external_node_util_styleText("cyan", S_BAR);
|
|
1518
|
+
case "cancel":
|
|
1519
|
+
return external_node_util_styleText("red", S_BAR);
|
|
1520
|
+
case "error":
|
|
1521
|
+
return external_node_util_styleText("yellow", S_BAR);
|
|
1522
|
+
case "submit":
|
|
1523
|
+
return external_node_util_styleText("green", S_BAR);
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
function formatInstructionFooter(o, e) {
|
|
1527
|
+
const r = [`${e ? `${external_node_util_styleText("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
|
|
1528
|
+
return e && r.push(external_node_util_styleText("cyan", S_BAR_END)), r;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
const dist_I = (l, e, w, p, b, C = false) => {
|
|
1532
|
+
let r = e, O = 0;
|
|
1533
|
+
if (C)
|
|
1534
|
+
for (let i = p - 1; i >= w; i--) {
|
|
1535
|
+
const m = l[i];
|
|
1536
|
+
if (m && (r -= m.length), O++, r <= b) break;
|
|
1537
|
+
}
|
|
1538
|
+
else
|
|
1539
|
+
for (let i = w; i < p; i++) {
|
|
1540
|
+
const m = l[i];
|
|
1541
|
+
if (m && (r -= m.length), O++, r <= b) break;
|
|
1542
|
+
}
|
|
1543
|
+
return { lineCount: r, removals: O };
|
|
1544
|
+
};
|
|
1545
|
+
const limitOptions = ({
|
|
1546
|
+
cursor: l,
|
|
1547
|
+
options: e,
|
|
1548
|
+
style: w,
|
|
1549
|
+
output: p = process.stdout,
|
|
1550
|
+
maxItems: b = Number.POSITIVE_INFINITY,
|
|
1551
|
+
columnPadding: C = 0,
|
|
1552
|
+
rowPadding: r = 4
|
|
1553
|
+
}) => {
|
|
1554
|
+
const i = dist_getColumns(p) - C, m = getRows(p), M = external_node_util_styleText("dim", "..."), v = Math.max(m - r, 0), a = Math.max(Math.min(b, v), 5);
|
|
1555
|
+
let f = 0;
|
|
1556
|
+
l >= a - 3 && (f = Math.max(
|
|
1557
|
+
Math.min(l - a + 3, e.length - a),
|
|
1558
|
+
0
|
|
1559
|
+
));
|
|
1560
|
+
let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
|
|
1561
|
+
const W = Math.min(
|
|
1562
|
+
f + a,
|
|
1563
|
+
e.length
|
|
1564
|
+
), s = [];
|
|
1565
|
+
let g = 0;
|
|
1566
|
+
d && g++, c && g++;
|
|
1567
|
+
const T = f + (d ? 1 : 0), y = W - (c ? 1 : 0);
|
|
1568
|
+
for (let t = T; t < y; t++) {
|
|
1569
|
+
const n = e[t], o = n ? w(n, t === l) : "", h = main_wrapAnsi(o, i, {
|
|
1570
|
+
hard: true,
|
|
1571
|
+
trim: false
|
|
1572
|
+
}).split(`
|
|
1573
|
+
`);
|
|
1574
|
+
s.push(h), g += h.length;
|
|
1575
|
+
}
|
|
1576
|
+
if (g > v) {
|
|
1577
|
+
let t = 0, n = 0, o = g;
|
|
1578
|
+
const h = l - T;
|
|
1579
|
+
let u = v;
|
|
1580
|
+
const L = () => dist_I(s, o, 0, h, u), E = () => dist_I(
|
|
1581
|
+
s,
|
|
1582
|
+
o,
|
|
1583
|
+
h + 1,
|
|
1584
|
+
s.length,
|
|
1585
|
+
u,
|
|
1586
|
+
true
|
|
1587
|
+
);
|
|
1588
|
+
d ? ({ lineCount: o, removals: t } = L(), o > u && (c || (u -= 1), { lineCount: o, removals: n } = E())) : (c || (u -= 1), { lineCount: o, removals: n } = E(), o > u && (u -= 1, { lineCount: o, removals: t } = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
|
|
1589
|
+
}
|
|
1590
|
+
const x = [];
|
|
1591
|
+
d && x.push(M);
|
|
1592
|
+
for (const t of s)
|
|
1593
|
+
for (const n of t)
|
|
1594
|
+
x.push(n);
|
|
1595
|
+
return c && x.push(M), x;
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
function prompts_dist_P(t) {
|
|
1599
|
+
return t.label ?? String(t.value ?? "");
|
|
1600
|
+
}
|
|
1601
|
+
function dist_E(t, c) {
|
|
1602
|
+
if (!t)
|
|
1603
|
+
return true;
|
|
1604
|
+
const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), l = String(c.value).toLowerCase(), o = t.toLowerCase();
|
|
1605
|
+
return n.includes(o) || i.includes(o) || l.includes(o);
|
|
1606
|
+
}
|
|
1607
|
+
function dist_N(t, c) {
|
|
1608
|
+
const n = [];
|
|
1609
|
+
for (const i of c)
|
|
1610
|
+
t.includes(i.value) && n.push(i);
|
|
1611
|
+
return n;
|
|
1612
|
+
}
|
|
1613
|
+
const autocomplete = (t) => new AutocompletePrompt({
|
|
1614
|
+
options: t.options,
|
|
1615
|
+
initialValue: t.initialValue ? [t.initialValue] : void 0,
|
|
1616
|
+
initialUserInput: t.initialUserInput,
|
|
1617
|
+
placeholder: t.placeholder,
|
|
1618
|
+
filter: t.filter ?? ((n, i) => dist_E(n, i)),
|
|
1619
|
+
signal: t.signal,
|
|
1620
|
+
input: t.input,
|
|
1621
|
+
output: t.output,
|
|
1622
|
+
validate: t.validate,
|
|
1623
|
+
render() {
|
|
1624
|
+
const n = t.withGuide ?? settings.withGuide, i = n ? [`${styleText("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], l = this.userInput, o = this.options, m = t.placeholder, p = l === "" && m !== void 0, $ = (r, s) => {
|
|
1625
|
+
const a = prompts_dist_P(r), u = r.hint && r.value === this.focusedValue ? styleText("dim", ` (${r.hint})`) : "";
|
|
1626
|
+
switch (s) {
|
|
1627
|
+
case "active":
|
|
1628
|
+
return `${styleText("green", S_RADIO_ACTIVE)} ${a}${u}`;
|
|
1629
|
+
case "inactive":
|
|
1630
|
+
return `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`;
|
|
1631
|
+
case "disabled":
|
|
1632
|
+
return `${styleText("gray", S_RADIO_INACTIVE)} ${styleText(["strikethrough", "gray"], a)}`;
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
switch (this.state) {
|
|
1636
|
+
case "submit": {
|
|
1637
|
+
const r = dist_N(this.selectedValues, o), s = r.length > 0 ? ` ${styleText("dim", r.map(prompts_dist_P).join(", "))}` : "", a = n ? styleText("gray", S_BAR) : "";
|
|
1638
|
+
return `${i.join(`
|
|
1639
|
+
`)}
|
|
1640
|
+
${a}${s}`;
|
|
1641
|
+
}
|
|
1642
|
+
case "cancel": {
|
|
1643
|
+
const r = l ? ` ${styleText(["strikethrough", "dim"], l)}` : "", s = n ? styleText("gray", S_BAR) : "";
|
|
1644
|
+
return `${i.join(`
|
|
1645
|
+
`)}
|
|
1646
|
+
${s}${r}`;
|
|
1647
|
+
}
|
|
1648
|
+
default: {
|
|
1649
|
+
const r = this.state === "error" ? "yellow" : "cyan", s = n ? `${styleText(r, S_BAR)} ` : "", a = n ? styleText(r, S_BAR_END) : "";
|
|
1650
|
+
let u = "";
|
|
1651
|
+
if (this.isNavigating || p) {
|
|
1652
|
+
const d = p ? m : l;
|
|
1653
|
+
u = d !== "" ? ` ${styleText("dim", d)}` : "";
|
|
1654
|
+
} else
|
|
1655
|
+
u = ` ${this.userInputWithCursor}`;
|
|
1656
|
+
const V = this.filteredOptions.length !== o.length ? styleText(
|
|
1657
|
+
"dim",
|
|
1658
|
+
` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
|
|
1659
|
+
) : "", y = this.filteredOptions.length === 0 && l ? [`${s}${styleText("yellow", "No matches found")}`] : [], b = this.state === "error" ? [`${s}${styleText("yellow", this.error)}`] : [];
|
|
1660
|
+
n && i.push(`${s.trimEnd()}`), i.push(
|
|
1661
|
+
`${s}${styleText("dim", "Search:")}${u}${V}`,
|
|
1662
|
+
...y,
|
|
1663
|
+
...b
|
|
1664
|
+
);
|
|
1665
|
+
const v = [
|
|
1666
|
+
`${styleText("dim", "\u2191/\u2193")} to select`,
|
|
1667
|
+
`${styleText("dim", "Enter:")} confirm`,
|
|
1668
|
+
`${styleText("dim", "Type:")} to search`
|
|
1669
|
+
], g = [`${s}${v.join(" \u2022 ")}`, a], O = this.filteredOptions.length === 0 ? [] : limitOptions({
|
|
1670
|
+
cursor: this.cursor,
|
|
1671
|
+
options: this.filteredOptions,
|
|
1672
|
+
columnPadding: n ? 3 : 0,
|
|
1673
|
+
// for `| ` when guide is shown
|
|
1674
|
+
rowPadding: i.length + g.length,
|
|
1675
|
+
style: (d, f) => $(
|
|
1676
|
+
d,
|
|
1677
|
+
d.disabled ? "disabled" : f ? "active" : "inactive"
|
|
1678
|
+
),
|
|
1679
|
+
maxItems: t.maxItems,
|
|
1680
|
+
output: t.output
|
|
1681
|
+
});
|
|
1682
|
+
return [
|
|
1683
|
+
...i,
|
|
1684
|
+
...O.map((d) => `${s}${d}`),
|
|
1685
|
+
...g
|
|
1686
|
+
].join(`
|
|
1687
|
+
`);
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
}).prompt(), autocompleteMultiselect = (t) => {
|
|
1692
|
+
const c = (i, l, o, m) => {
|
|
1693
|
+
const p = o.includes(i.value), $ = i.label ?? String(i.value ?? ""), r = i.hint && m !== void 0 && i.value === m ? styleText("dim", ` (${i.hint})`) : "", s = p ? styleText("green", S_CHECKBOX_SELECTED) : styleText("dim", S_CHECKBOX_INACTIVE);
|
|
1694
|
+
return i.disabled ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${styleText(["strikethrough", "gray"], $)}` : l ? `${s} ${$}${r}` : `${s} ${styleText("dim", $)}`;
|
|
1695
|
+
}, n = new AutocompletePrompt({
|
|
1696
|
+
options: t.options,
|
|
1697
|
+
multiple: true,
|
|
1698
|
+
placeholder: t.placeholder,
|
|
1699
|
+
filter: t.filter ?? ((i, l) => dist_E(i, l)),
|
|
1700
|
+
validate: () => {
|
|
1701
|
+
if (t.required && n.selectedValues.length === 0)
|
|
1702
|
+
return "Please select at least one item";
|
|
1703
|
+
},
|
|
1704
|
+
initialValue: t.initialValues,
|
|
1705
|
+
signal: t.signal,
|
|
1706
|
+
input: t.input,
|
|
1707
|
+
output: t.output,
|
|
1708
|
+
render() {
|
|
1709
|
+
const i = t.withGuide ?? settings.withGuide, l = `${i ? `${styleText("gray", S_BAR)}
|
|
1710
|
+
` : ""}${symbol(this.state)} ${t.message}
|
|
1711
|
+
`, o = this.userInput, m = t.placeholder, p = o === "" && m !== void 0, $ = this.isNavigating || p ? styleText("dim", p ? m : o) : this.userInputWithCursor, r = this.options, s = this.filteredOptions.length !== r.length ? styleText(
|
|
1712
|
+
"dim",
|
|
1713
|
+
` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
|
|
1714
|
+
) : "";
|
|
1715
|
+
switch (this.state) {
|
|
1716
|
+
case "submit":
|
|
1717
|
+
return `${l}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(
|
|
1718
|
+
"dim",
|
|
1719
|
+
`${this.selectedValues.length} items selected`
|
|
1720
|
+
)}`;
|
|
1721
|
+
case "cancel":
|
|
1722
|
+
return `${l}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(
|
|
1723
|
+
["strikethrough", "dim"],
|
|
1724
|
+
o
|
|
1725
|
+
)}`;
|
|
1726
|
+
default: {
|
|
1727
|
+
const a = this.state === "error" ? "yellow" : "cyan", u = i ? `${styleText(a, S_BAR)} ` : "", V = i ? styleText(a, S_BAR_END) : "", y = [
|
|
1728
|
+
`${styleText("dim", "\u2191/\u2193")} to navigate`,
|
|
1729
|
+
`${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
1730
|
+
`${styleText("dim", "Enter:")} confirm`,
|
|
1731
|
+
`${styleText("dim", "Type:")} to search`
|
|
1732
|
+
], b = this.filteredOptions.length === 0 && o ? [`${u}${styleText("yellow", "No matches found")}`] : [], v = this.state === "error" ? [`${u}${styleText("yellow", this.error)}`] : [], g = [
|
|
1733
|
+
...`${l}${i ? styleText(a, S_BAR) : ""}`.split(`
|
|
1734
|
+
`),
|
|
1735
|
+
`${u}${styleText("dim", "Search:")} ${$}${s}`,
|
|
1736
|
+
...b,
|
|
1737
|
+
...v
|
|
1738
|
+
], O = [`${u}${y.join(" \u2022 ")}`, V], d = limitOptions({
|
|
1739
|
+
cursor: this.cursor,
|
|
1740
|
+
options: this.filteredOptions,
|
|
1741
|
+
style: (f, _) => c(f, _, this.selectedValues, this.focusedValue),
|
|
1742
|
+
maxItems: t.maxItems,
|
|
1743
|
+
output: t.output,
|
|
1744
|
+
rowPadding: g.length + O.length
|
|
1745
|
+
});
|
|
1746
|
+
return [
|
|
1747
|
+
...g,
|
|
1748
|
+
...d.map((f) => `${u}${f}`),
|
|
1749
|
+
...O
|
|
1750
|
+
].join(`
|
|
1751
|
+
`);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
});
|
|
1756
|
+
return n.prompt();
|
|
1757
|
+
};
|
|
1758
|
+
|
|
1759
|
+
const J = (/* unused pure expression or super */ null && ([
|
|
1760
|
+
S_CORNER_TOP_LEFT,
|
|
1761
|
+
S_CORNER_TOP_RIGHT,
|
|
1762
|
+
S_CORNER_BOTTOM_LEFT,
|
|
1763
|
+
S_CORNER_BOTTOM_RIGHT
|
|
1764
|
+
])), K = (/* unused pure expression or super */ null && ([S_BAR_START, S_BAR_START_RIGHT, S_BAR_END, S_BAR_END_RIGHT]));
|
|
1765
|
+
function A$1(n, e, t, o) {
|
|
1766
|
+
let i = t, f = t;
|
|
1767
|
+
return o === "center" ? i = Math.floor((e - n) / 2) : o === "right" && (i = e - n - t), f = e - i - n, [i, f];
|
|
1768
|
+
}
|
|
1769
|
+
const Q = (n) => n;
|
|
1770
|
+
const box = (n = "", e = "", t) => {
|
|
1771
|
+
const o = t?.output ?? process.stdout, i = getColumns(o), R = 1 * 2, u = t?.titlePadding ?? 1, h = t?.contentPadding ?? 2, w = t?.width === void 0 || t.width === "auto" ? 1 : Math.min(1, t.width), m = t?.withGuide ?? settings.withGuide ? `${S_BAR} ` : "", b = t?.formatBorder ?? Q, a = (t?.rounded ? J : K).map(b), _ = b(S_BAR_H), B = b(S_BAR), p = l(m), x = l(e), O = i - p;
|
|
1772
|
+
let r = Math.floor(i * w) - p;
|
|
1773
|
+
if (t?.width === "auto") {
|
|
1774
|
+
const c = n.split(`
|
|
1775
|
+
`);
|
|
1776
|
+
let s = x + u * 2;
|
|
1777
|
+
for (const G of c) {
|
|
1778
|
+
const P = l(G) + h * 2;
|
|
1779
|
+
P > s && (s = P);
|
|
1780
|
+
}
|
|
1781
|
+
const g = s + R;
|
|
1782
|
+
g < r && (r = g);
|
|
1783
|
+
}
|
|
1784
|
+
r % 2 !== 0 && (r < O ? r++ : r--);
|
|
1785
|
+
const d = r - R, S = d - u * 2, T = x > S ? `${e.slice(0, S - 3)}...` : e, [y, W] = A$1(
|
|
1786
|
+
l(T),
|
|
1787
|
+
d,
|
|
1788
|
+
u,
|
|
1789
|
+
t?.titleAlign
|
|
1790
|
+
), L = wrapAnsi(n, d - h * 2, {
|
|
1791
|
+
hard: true,
|
|
1792
|
+
trim: false
|
|
1793
|
+
});
|
|
1794
|
+
o.write(
|
|
1795
|
+
`${m}${a[0]}${_.repeat(y)}${T}${_.repeat(W)}${a[1]}
|
|
1796
|
+
`
|
|
1797
|
+
);
|
|
1798
|
+
const E = L.split(`
|
|
1799
|
+
`);
|
|
1800
|
+
for (const c of E) {
|
|
1801
|
+
const [s, g] = A$1(
|
|
1802
|
+
l(c),
|
|
1803
|
+
d,
|
|
1804
|
+
h,
|
|
1805
|
+
t?.contentAlign
|
|
1806
|
+
);
|
|
1807
|
+
o.write(
|
|
1808
|
+
`${m}${B}${" ".repeat(s)}${c}${" ".repeat(g)}${B}
|
|
1809
|
+
`
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
o.write(`${m}${a[2]}${_.repeat(d)}${a[3]}
|
|
1813
|
+
`);
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1816
|
+
const dist_confirm = (i) => {
|
|
1817
|
+
const a = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
1818
|
+
return new dist_r({
|
|
1819
|
+
active: a,
|
|
1820
|
+
inactive: s,
|
|
1821
|
+
signal: i.signal,
|
|
1822
|
+
input: i.input,
|
|
1823
|
+
output: i.output,
|
|
1824
|
+
initialValue: i.initialValue ?? true,
|
|
1825
|
+
render() {
|
|
1826
|
+
const e = i.withGuide ?? dist_settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${external_node_util_styleText("gray", S_BAR)} ` : "", f = dist_wrapTextWithPrefix(
|
|
1827
|
+
i.output,
|
|
1828
|
+
i.message,
|
|
1829
|
+
l,
|
|
1830
|
+
u
|
|
1831
|
+
), o = `${e ? `${external_node_util_styleText("gray", S_BAR)}
|
|
1832
|
+
` : ""}${f}
|
|
1833
|
+
`, c = this.value ? a : s;
|
|
1834
|
+
switch (this.state) {
|
|
1835
|
+
case "submit": {
|
|
1836
|
+
const r = e ? `${external_node_util_styleText("gray", S_BAR)} ` : "";
|
|
1837
|
+
return `${o}${r}${external_node_util_styleText("dim", c)}`;
|
|
1838
|
+
}
|
|
1839
|
+
case "cancel": {
|
|
1840
|
+
const r = e ? `${external_node_util_styleText("gray", S_BAR)} ` : "";
|
|
1841
|
+
return `${o}${r}${external_node_util_styleText(["strikethrough", "dim"], c)}${e ? `
|
|
1842
|
+
${external_node_util_styleText("gray", S_BAR)}` : ""}`;
|
|
1843
|
+
}
|
|
1844
|
+
default: {
|
|
1845
|
+
const r = e ? `${external_node_util_styleText("cyan", S_BAR)} ` : "", g = e ? external_node_util_styleText("cyan", S_BAR_END) : "";
|
|
1846
|
+
return `${o}${r}${this.value ? `${external_node_util_styleText("green", S_RADIO_ACTIVE)} ${a}` : `${external_node_util_styleText("dim", S_RADIO_INACTIVE)} ${external_node_util_styleText("dim", a)}`}${i.vertical ? e ? `
|
|
1847
|
+
${external_node_util_styleText("cyan", S_BAR)} ` : `
|
|
1848
|
+
` : ` ${external_node_util_styleText("dim", "/")} `}${this.value ? `${external_node_util_styleText("dim", S_RADIO_INACTIVE)} ${external_node_util_styleText("dim", s)}` : `${external_node_util_styleText("green", S_RADIO_ACTIVE)} ${s}`}
|
|
1849
|
+
${g}
|
|
1850
|
+
`;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}).prompt();
|
|
1855
|
+
};
|
|
1856
|
+
|
|
1857
|
+
const date = (e) => {
|
|
1858
|
+
const r = e.validate;
|
|
1859
|
+
return new DatePrompt({
|
|
1860
|
+
...e,
|
|
1861
|
+
validate(t) {
|
|
1862
|
+
if (t === void 0)
|
|
1863
|
+
return e.defaultValue !== void 0 ? void 0 : r ? runValidation(r, t) : settings.date.messages.required;
|
|
1864
|
+
const o = (i) => i.toISOString().slice(0, 10);
|
|
1865
|
+
if (e.minDate && o(t) < o(e.minDate))
|
|
1866
|
+
return settings.date.messages.afterMin(e.minDate);
|
|
1867
|
+
if (e.maxDate && o(t) > o(e.maxDate))
|
|
1868
|
+
return settings.date.messages.beforeMax(e.maxDate);
|
|
1869
|
+
if (r) return runValidation(r, t);
|
|
1870
|
+
},
|
|
1871
|
+
render() {
|
|
1872
|
+
const t = (e?.withGuide ?? settings.withGuide) !== false, i = `${`${t ? `${styleText("gray", S_BAR)}
|
|
1873
|
+
` : ""}${symbol(this.state)} `}${e.message}
|
|
1874
|
+
`, l = this.state !== "initial" ? this.state : "active", d = prompts_dist_b(this, l), c = this.value instanceof Date ? this.formattedValue : "";
|
|
1875
|
+
switch (this.state) {
|
|
1876
|
+
case "error": {
|
|
1877
|
+
const a = this.error ? ` ${styleText("yellow", this.error)}` : "", s = t ? `${styleText("yellow", S_BAR)} ` : "", f = t ? styleText("yellow", S_BAR_END) : "";
|
|
1878
|
+
return `${i.trim()}
|
|
1879
|
+
${s}${d}
|
|
1880
|
+
${f}${a}
|
|
1881
|
+
`;
|
|
1882
|
+
}
|
|
1883
|
+
case "submit": {
|
|
1884
|
+
const a = c ? ` ${styleText("dim", c)}` : "", s = t ? styleText("gray", S_BAR) : "";
|
|
1885
|
+
return `${i}${s}${a}`;
|
|
1886
|
+
}
|
|
1887
|
+
case "cancel": {
|
|
1888
|
+
const a = c ? ` ${styleText(["strikethrough", "dim"], c)}` : "", s = t ? styleText("gray", S_BAR) : "";
|
|
1889
|
+
return `${i}${s}${a}${c.trim() ? `
|
|
1890
|
+
${s}` : ""}`;
|
|
1891
|
+
}
|
|
1892
|
+
default: {
|
|
1893
|
+
const a = t ? `${styleText("cyan", S_BAR)} ` : "", s = t ? styleText("cyan", S_BAR_END) : "", f = t ? `${styleText("cyan", S_BAR)} ` : "", g = this.inlineError ? `
|
|
1894
|
+
${f}${styleText("yellow", this.inlineError)}` : "";
|
|
1895
|
+
return `${i}${a}${d}${g}
|
|
1896
|
+
${s}
|
|
1897
|
+
`;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
}).prompt();
|
|
1902
|
+
};
|
|
1903
|
+
function prompts_dist_b(e, r) {
|
|
1904
|
+
const t = e.segmentValues, o = e.segmentCursor;
|
|
1905
|
+
if (r === "submit" || r === "cancel")
|
|
1906
|
+
return e.formattedValue;
|
|
1907
|
+
const i = styleText("gray", e.separator);
|
|
1908
|
+
return e.segments.map((l, d) => {
|
|
1909
|
+
const c = d === o.segmentIndex && !["submit", "cancel"].includes(r), a = prompts_dist_p[l.type];
|
|
1910
|
+
return dist_x(t[l.type], { isActive: c, label: a });
|
|
1911
|
+
}).join(i);
|
|
1912
|
+
}
|
|
1913
|
+
function dist_x(e, r) {
|
|
1914
|
+
const t = !e || e.replace(/_/g, "") === "";
|
|
1915
|
+
return r.isActive ? styleText("inverse", t ? r.label : e.replace(/_/g, " ")) : t ? styleText("dim", r.label) : e.replace(/_/g, styleText("dim", " "));
|
|
1916
|
+
}
|
|
1917
|
+
const prompts_dist_p = (/* unused pure expression or super */ null && ({
|
|
1918
|
+
year: "yyyy",
|
|
1919
|
+
month: "mm",
|
|
1920
|
+
day: "dd"
|
|
1921
|
+
}));
|
|
1922
|
+
|
|
1923
|
+
const group = async (o, r) => {
|
|
1924
|
+
const t = {}, p = Object.keys(o);
|
|
1925
|
+
for (const e of p) {
|
|
1926
|
+
const i = o[e], n = await i({ results: t })?.catch((a) => {
|
|
1927
|
+
throw a;
|
|
1928
|
+
});
|
|
1929
|
+
if (typeof r?.onCancel == "function" && isCancel(n)) {
|
|
1930
|
+
t[e] = "canceled", r.onCancel({ results: t });
|
|
1931
|
+
continue;
|
|
1932
|
+
}
|
|
1933
|
+
t[e] = n;
|
|
1934
|
+
}
|
|
1935
|
+
return t;
|
|
1936
|
+
};
|
|
1937
|
+
|
|
1938
|
+
const MULTISELECT_INSTRUCTIONS = [
|
|
1939
|
+
`${external_node_util_styleText("dim", "\u2191/\u2193")} to navigate`,
|
|
1940
|
+
`${external_node_util_styleText("dim", "Space:")} select`,
|
|
1941
|
+
`${external_node_util_styleText("dim", "Enter:")} confirm`
|
|
1942
|
+
];
|
|
1943
|
+
const prompts_dist_m = (i, u) => i.split(`
|
|
1944
|
+
`).map((d) => u(d)).join(`
|
|
1945
|
+
`);
|
|
1946
|
+
const multiselect = (i) => {
|
|
1947
|
+
const u = (t, a) => {
|
|
1948
|
+
const r = t.label ?? String(t.value);
|
|
1949
|
+
return a === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${prompts_dist_m(r, (o) => styleText(["strikethrough", "gray"], o))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${prompts_dist_m(r, (o) => styleText("dim", o))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "cancelled" ? `${prompts_dist_m(r, (o) => styleText(["strikethrough", "dim"], o))}` : a === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : a === "submitted" ? `${prompts_dist_m(r, (o) => styleText("dim", o))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${prompts_dist_m(r, (o) => styleText("dim", o))}`;
|
|
1950
|
+
}, d = i.required ?? true, v = i.showInstructions ?? true;
|
|
1951
|
+
return new MultiSelectPrompt({
|
|
1952
|
+
options: i.options,
|
|
1953
|
+
signal: i.signal,
|
|
1954
|
+
input: i.input,
|
|
1955
|
+
output: i.output,
|
|
1956
|
+
initialValues: i.initialValues,
|
|
1957
|
+
required: d,
|
|
1958
|
+
cursorAt: i.cursorAt,
|
|
1959
|
+
validate(t) {
|
|
1960
|
+
if (d && (t === void 0 || t.length === 0))
|
|
1961
|
+
return `Please select at least one option.
|
|
1962
|
+
${styleText(
|
|
1963
|
+
"reset",
|
|
1964
|
+
styleText(
|
|
1965
|
+
"dim",
|
|
1966
|
+
`Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText(
|
|
1967
|
+
"gray",
|
|
1968
|
+
styleText("bgWhite", styleText("inverse", " enter "))
|
|
1969
|
+
)} to submit`
|
|
1970
|
+
)
|
|
1971
|
+
)}`;
|
|
1972
|
+
},
|
|
1973
|
+
render() {
|
|
1974
|
+
const t = i.withGuide ?? settings.withGuide, a = wrapTextWithPrefix(
|
|
1975
|
+
i.output,
|
|
1976
|
+
i.message,
|
|
1977
|
+
t ? `${symbolBar(this.state)} ` : "",
|
|
1978
|
+
`${symbol(this.state)} `
|
|
1979
|
+
), r = `${t ? `${styleText("gray", S_BAR)}
|
|
1980
|
+
` : ""}${a}
|
|
1981
|
+
`, o = this.value ?? [], p = (n, l) => {
|
|
1982
|
+
if (n.disabled)
|
|
1983
|
+
return u(n, "disabled");
|
|
1984
|
+
const s = o.includes(n.value);
|
|
1985
|
+
return l && s ? u(n, "active-selected") : s ? u(n, "selected") : u(n, l ? "active" : "inactive");
|
|
1986
|
+
};
|
|
1987
|
+
switch (this.state) {
|
|
1988
|
+
case "submit": {
|
|
1989
|
+
const n = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = wrapTextWithPrefix(
|
|
1990
|
+
i.output,
|
|
1991
|
+
n,
|
|
1992
|
+
t ? `${styleText("gray", S_BAR)} ` : ""
|
|
1993
|
+
);
|
|
1994
|
+
return `${r}${l}`;
|
|
1995
|
+
}
|
|
1996
|
+
case "cancel": {
|
|
1997
|
+
const n = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u(s, "cancelled")).join(styleText("dim", ", "));
|
|
1998
|
+
if (n.trim() === "")
|
|
1999
|
+
return `${r}${styleText("gray", S_BAR)}`;
|
|
2000
|
+
const l = wrapTextWithPrefix(
|
|
2001
|
+
i.output,
|
|
2002
|
+
n,
|
|
2003
|
+
t ? `${styleText("gray", S_BAR)} ` : ""
|
|
2004
|
+
);
|
|
2005
|
+
return `${r}${l}${t ? `
|
|
2006
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
2007
|
+
}
|
|
2008
|
+
case "error": {
|
|
2009
|
+
const n = t ? `${styleText("yellow", S_BAR)} ` : "", l = this.error.split(`
|
|
2010
|
+
`).map(
|
|
2011
|
+
($, C) => C === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", $)}` : ` ${$}`
|
|
2012
|
+
).join(`
|
|
2013
|
+
`), s = r.split(`
|
|
2014
|
+
`).length, h = l.split(`
|
|
2015
|
+
`).length + 1;
|
|
2016
|
+
return `${r}${n}${limitOptions({
|
|
2017
|
+
output: i.output,
|
|
2018
|
+
options: this.options,
|
|
2019
|
+
cursor: this.cursor,
|
|
2020
|
+
maxItems: i.maxItems,
|
|
2021
|
+
columnPadding: n.length,
|
|
2022
|
+
rowPadding: s + h,
|
|
2023
|
+
style: p
|
|
2024
|
+
}).join(`
|
|
2025
|
+
${n}`)}
|
|
2026
|
+
${l}
|
|
2027
|
+
`;
|
|
2028
|
+
}
|
|
2029
|
+
default: {
|
|
2030
|
+
const n = t ? `${styleText("cyan", S_BAR)} ` : "", l = r.split(`
|
|
2031
|
+
`).length, s = v ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t) : t ? [styleText("cyan", S_BAR_END)] : [], h = s.join(`
|
|
2032
|
+
`), $ = s.length + 1;
|
|
2033
|
+
return `${r}${n}${limitOptions({
|
|
2034
|
+
output: i.output,
|
|
2035
|
+
options: this.options,
|
|
2036
|
+
cursor: this.cursor,
|
|
2037
|
+
maxItems: i.maxItems,
|
|
2038
|
+
columnPadding: n.length,
|
|
2039
|
+
rowPadding: l + $,
|
|
2040
|
+
style: p
|
|
2041
|
+
}).join(`
|
|
2042
|
+
${n}`)}
|
|
2043
|
+
${h}
|
|
2044
|
+
`;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
}).prompt();
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2051
|
+
const groupMultiselect = (o) => {
|
|
2052
|
+
const { selectableGroups: h = true, groupSpacing: x = 0 } = o, m = (n, l, g = []) => {
|
|
2053
|
+
const a = n.label ?? String(n.value), t = typeof n.group == "string", s = t && (g[g.indexOf(n) + 1] ?? { group: true }), u = t && s && s.group === true;
|
|
2054
|
+
let r = "", c = "";
|
|
2055
|
+
t && (h ? (r = u ? `${S_BAR_END} ` : `${S_BAR} `, c = u ? " " : `${S_BAR} `) : r = " ");
|
|
2056
|
+
let i = "";
|
|
2057
|
+
if (x > 0 && !t && (i = `
|
|
2058
|
+
`.repeat(x)), l === "active")
|
|
2059
|
+
return wrapTextWithPrefix(
|
|
2060
|
+
o.output,
|
|
2061
|
+
`${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
|
|
2062
|
+
`${i}${styleText("dim", r)} `,
|
|
2063
|
+
`${i}${styleText("dim", r)}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
2064
|
+
`${i}${styleText("dim", c)} `
|
|
2065
|
+
);
|
|
2066
|
+
if (l === "group-active")
|
|
2067
|
+
return wrapTextWithPrefix(
|
|
2068
|
+
o.output,
|
|
2069
|
+
a,
|
|
2070
|
+
`${i}${r} `,
|
|
2071
|
+
`${i}${r}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
2072
|
+
`${i}${c} `,
|
|
2073
|
+
(d) => styleText("dim", d)
|
|
2074
|
+
);
|
|
2075
|
+
if (l === "group-active-selected")
|
|
2076
|
+
return wrapTextWithPrefix(
|
|
2077
|
+
o.output,
|
|
2078
|
+
a,
|
|
2079
|
+
`${i}${r} `,
|
|
2080
|
+
`${i}${r}${styleText("green", S_CHECKBOX_SELECTED)} `,
|
|
2081
|
+
`${i}${c} `,
|
|
2082
|
+
(d) => styleText("dim", d)
|
|
2083
|
+
);
|
|
2084
|
+
if (l === "selected") {
|
|
2085
|
+
const d = t || h ? styleText("green", S_CHECKBOX_SELECTED) : "";
|
|
2086
|
+
return wrapTextWithPrefix(
|
|
2087
|
+
o.output,
|
|
2088
|
+
`${a}${n.hint ? ` (${n.hint})` : ""}`,
|
|
2089
|
+
`${i}${styleText("dim", r)} `,
|
|
2090
|
+
`${i}${styleText("dim", r)}${d} `,
|
|
2091
|
+
`${i}${styleText("dim", c)} `,
|
|
2092
|
+
(S) => styleText("dim", S)
|
|
2093
|
+
);
|
|
2094
|
+
}
|
|
2095
|
+
if (l === "cancelled")
|
|
2096
|
+
return `${styleText(["strikethrough", "dim"], a)}`;
|
|
2097
|
+
if (l === "active-selected")
|
|
2098
|
+
return wrapTextWithPrefix(
|
|
2099
|
+
o.output,
|
|
2100
|
+
`${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`,
|
|
2101
|
+
`${i}${styleText("dim", r)} `,
|
|
2102
|
+
`${i}${styleText("dim", r)}${styleText("green", S_CHECKBOX_SELECTED)} `,
|
|
2103
|
+
`${i}${styleText("dim", c)} `
|
|
2104
|
+
);
|
|
2105
|
+
if (l === "submitted")
|
|
2106
|
+
return `${styleText("dim", a)}`;
|
|
2107
|
+
const f = t || h ? styleText("dim", S_CHECKBOX_INACTIVE) : "";
|
|
2108
|
+
return wrapTextWithPrefix(
|
|
2109
|
+
o.output,
|
|
2110
|
+
a,
|
|
2111
|
+
`${i}${styleText("dim", r)} `,
|
|
2112
|
+
`${i}${styleText("dim", r)}${f} `,
|
|
2113
|
+
`${i}${styleText("dim", c)} `,
|
|
2114
|
+
(d) => styleText("dim", d)
|
|
2115
|
+
);
|
|
2116
|
+
}, y = o.required ?? true, I = o.showInstructions ?? true;
|
|
2117
|
+
return new GroupMultiSelectPrompt({
|
|
2118
|
+
options: o.options,
|
|
2119
|
+
signal: o.signal,
|
|
2120
|
+
input: o.input,
|
|
2121
|
+
output: o.output,
|
|
2122
|
+
initialValues: o.initialValues,
|
|
2123
|
+
required: y,
|
|
2124
|
+
cursorAt: o.cursorAt,
|
|
2125
|
+
selectableGroups: h,
|
|
2126
|
+
validate(n) {
|
|
2127
|
+
if (y && (n === void 0 || n.length === 0))
|
|
2128
|
+
return `Please select at least one option.
|
|
2129
|
+
${styleText(
|
|
2130
|
+
"reset",
|
|
2131
|
+
styleText(
|
|
2132
|
+
"dim",
|
|
2133
|
+
`Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText(
|
|
2134
|
+
"gray",
|
|
2135
|
+
styleText(["bgWhite", "inverse"], " enter ")
|
|
2136
|
+
)} to submit`
|
|
2137
|
+
)
|
|
2138
|
+
)}`;
|
|
2139
|
+
},
|
|
2140
|
+
render() {
|
|
2141
|
+
const n = o.withGuide ?? settings.withGuide, l = `${n ? `${styleText("gray", S_BAR)}
|
|
2142
|
+
` : ""}${symbol(this.state)} ${o.message}
|
|
2143
|
+
`, g = this.value ?? [], a = (t, s) => {
|
|
2144
|
+
const u = this.options, r = g.includes(t.value) || t.group === true && this.isGroupSelected(`${t.value}`);
|
|
2145
|
+
return !s && typeof t.group == "string" && this.options[this.cursor]?.value === t.group ? m(t, r ? "group-active-selected" : "group-active", u) : s && r ? m(t, "active-selected", u) : r ? m(t, "selected", u) : m(t, s ? "active" : "inactive", u);
|
|
2146
|
+
};
|
|
2147
|
+
switch (this.state) {
|
|
2148
|
+
case "submit": {
|
|
2149
|
+
const t = this.options.filter(({ value: u }) => g.includes(u)).map((u) => m(u, "submitted")), s = t.length === 0 ? "" : ` ${t.join(styleText("dim", ", "))}`;
|
|
2150
|
+
return `${l}${n ? styleText("gray", S_BAR) : ""}${s}`;
|
|
2151
|
+
}
|
|
2152
|
+
case "cancel": {
|
|
2153
|
+
const t = this.options.filter(({ value: s }) => g.includes(s)).map((s) => m(s, "cancelled")).join(styleText("dim", ", "));
|
|
2154
|
+
return `${l}${n ? `${styleText("gray", S_BAR)} ` : ""}${t.trim() ? `${t}${n ? `
|
|
2155
|
+
${styleText("gray", S_BAR)}` : ""}` : ""}`;
|
|
2156
|
+
}
|
|
2157
|
+
case "error": {
|
|
2158
|
+
const t = n ? `${styleText("yellow", S_BAR)} ` : "", s = this.error.split(`
|
|
2159
|
+
`).map(
|
|
2160
|
+
(i, f) => f === 0 ? `${n ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", i)}` : ` ${i}`
|
|
2161
|
+
).join(`
|
|
2162
|
+
`), u = l.split(`
|
|
2163
|
+
`).length, r = s.split(`
|
|
2164
|
+
`).length + 1, c = limitOptions({
|
|
2165
|
+
output: o.output,
|
|
2166
|
+
options: this.options,
|
|
2167
|
+
cursor: this.cursor,
|
|
2168
|
+
maxItems: o.maxItems,
|
|
2169
|
+
columnPadding: t.length,
|
|
2170
|
+
rowPadding: u + r,
|
|
2171
|
+
style: a
|
|
2172
|
+
}).join(`
|
|
2173
|
+
${t}`);
|
|
2174
|
+
return `${l}${t}${c}
|
|
2175
|
+
${s}
|
|
2176
|
+
`;
|
|
2177
|
+
}
|
|
2178
|
+
default: {
|
|
2179
|
+
const t = n ? `${styleText("cyan", S_BAR)} ` : "", s = l.split(`
|
|
2180
|
+
`).length, u = I ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], r = u.join(`
|
|
2181
|
+
`), c = u.length + 1, i = limitOptions({
|
|
2182
|
+
output: o.output,
|
|
2183
|
+
options: this.options,
|
|
2184
|
+
cursor: this.cursor,
|
|
2185
|
+
maxItems: o.maxItems,
|
|
2186
|
+
columnPadding: t.length,
|
|
2187
|
+
rowPadding: s + c,
|
|
2188
|
+
style: a
|
|
2189
|
+
}).join(`
|
|
2190
|
+
${t}`);
|
|
2191
|
+
return `${l}${t}${i}
|
|
2192
|
+
${r}
|
|
2193
|
+
`;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}).prompt();
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
const log = {
|
|
2201
|
+
message: (s = [], {
|
|
2202
|
+
symbol: e = external_node_util_styleText("gray", S_BAR),
|
|
2203
|
+
secondarySymbol: r = external_node_util_styleText("gray", S_BAR),
|
|
2204
|
+
output: m = process.stdout,
|
|
2205
|
+
spacing: l = 1,
|
|
2206
|
+
withGuide: c
|
|
2207
|
+
} = {}) => {
|
|
2208
|
+
const t = [], o = c ?? dist_settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
|
|
2209
|
+
for (let i = 0; i < l; i++)
|
|
2210
|
+
t.push(f);
|
|
2211
|
+
const g = Array.isArray(s) ? s : s.split(`
|
|
2212
|
+
`);
|
|
2213
|
+
if (g.length > 0) {
|
|
2214
|
+
const [i, ...y] = g;
|
|
2215
|
+
i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
|
|
2216
|
+
for (const p of y)
|
|
2217
|
+
p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
|
|
2218
|
+
}
|
|
2219
|
+
m.write(`${t.join(`
|
|
2220
|
+
`)}
|
|
2221
|
+
`);
|
|
2222
|
+
},
|
|
2223
|
+
info: (s, e) => {
|
|
2224
|
+
log.message(s, { ...e, symbol: external_node_util_styleText("blue", S_INFO) });
|
|
2225
|
+
},
|
|
2226
|
+
success: (s, e) => {
|
|
2227
|
+
log.message(s, { ...e, symbol: external_node_util_styleText("green", S_SUCCESS) });
|
|
2228
|
+
},
|
|
2229
|
+
step: (s, e) => {
|
|
2230
|
+
log.message(s, { ...e, symbol: external_node_util_styleText("green", S_STEP_SUBMIT) });
|
|
2231
|
+
},
|
|
2232
|
+
warn: (s, e) => {
|
|
2233
|
+
log.message(s, { ...e, symbol: external_node_util_styleText("yellow", S_WARN) });
|
|
2234
|
+
},
|
|
2235
|
+
/** alias for `log.warn()`. */
|
|
2236
|
+
warning: (s, e) => {
|
|
2237
|
+
log.warn(s, e);
|
|
2238
|
+
},
|
|
2239
|
+
error: (s, e) => {
|
|
2240
|
+
log.message(s, { ...e, symbol: external_node_util_styleText("red", S_ERROR) });
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
|
|
2244
|
+
const cancel = (o = "", t) => {
|
|
2245
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? dist_settings.withGuide ? `${external_node_util_styleText("gray", S_BAR_END)} ` : "";
|
|
2246
|
+
i.write(`${e}${external_node_util_styleText("red", o)}
|
|
2247
|
+
|
|
2248
|
+
`);
|
|
2249
|
+
}, intro = (o = "", t) => {
|
|
2250
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? dist_settings.withGuide ? `${external_node_util_styleText("gray", S_BAR_START)} ` : "";
|
|
2251
|
+
i.write(`${e}${o}
|
|
2252
|
+
`);
|
|
2253
|
+
}, outro = (o = "", t) => {
|
|
2254
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? dist_settings.withGuide ? `${external_node_util_styleText("gray", S_BAR)}
|
|
2255
|
+
${external_node_util_styleText("gray", S_BAR_END)} ` : "";
|
|
2256
|
+
i.write(`${e}${o}
|
|
2257
|
+
|
|
2258
|
+
`);
|
|
2259
|
+
};
|
|
2260
|
+
|
|
2261
|
+
const multiline = (e) => new MultiLinePrompt({
|
|
2262
|
+
validate: e.validate,
|
|
2263
|
+
placeholder: e.placeholder,
|
|
2264
|
+
defaultValue: e.defaultValue,
|
|
2265
|
+
initialValue: e.initialValue,
|
|
2266
|
+
showSubmit: e.showSubmit,
|
|
2267
|
+
output: e.output,
|
|
2268
|
+
signal: e.signal,
|
|
2269
|
+
input: e.input,
|
|
2270
|
+
render() {
|
|
2271
|
+
const i = e?.withGuide ?? settings.withGuide, o = `${`${i ? `${styleText("gray", S_BAR)}
|
|
2272
|
+
` : ""}${symbol(this.state)} `}${e.message}
|
|
2273
|
+
`, m = e.placeholder && e.placeholder.length > 0 ? (
|
|
2274
|
+
// biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
|
|
2275
|
+
styleText("inverse", e.placeholder[0]) + styleText("dim", e.placeholder.slice(1))
|
|
2276
|
+
) : styleText(["inverse", "hidden"], "_"), a = this.userInput ? this.userInputWithCursor : m, l = this.value ?? "", c = e.showSubmit ? `
|
|
2277
|
+
${styleText(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
|
|
2278
|
+
switch (this.state) {
|
|
2279
|
+
case "error": {
|
|
2280
|
+
const n = `${styleText("yellow", S_BAR)} `, r = i ? wrapTextWithPrefix(e.output, a, n, void 0) : a, u = styleText("yellow", S_BAR_END);
|
|
2281
|
+
return `${o}${r}
|
|
2282
|
+
${u} ${styleText("yellow", this.error)}${c}
|
|
2283
|
+
`;
|
|
2284
|
+
}
|
|
2285
|
+
case "submit": {
|
|
2286
|
+
const n = `${styleText("gray", S_BAR)} `, r = i ? wrapTextWithPrefix(
|
|
2287
|
+
e.output,
|
|
2288
|
+
l,
|
|
2289
|
+
n,
|
|
2290
|
+
void 0,
|
|
2291
|
+
void 0,
|
|
2292
|
+
(u) => styleText("dim", u)
|
|
2293
|
+
) : l ? styleText("dim", l) : "";
|
|
2294
|
+
return `${o}${r}`;
|
|
2295
|
+
}
|
|
2296
|
+
case "cancel": {
|
|
2297
|
+
const n = `${styleText("gray", S_BAR)} `, r = i ? wrapTextWithPrefix(
|
|
2298
|
+
e.output,
|
|
2299
|
+
l,
|
|
2300
|
+
n,
|
|
2301
|
+
void 0,
|
|
2302
|
+
void 0,
|
|
2303
|
+
(u) => styleText(["strikethrough", "dim"], u)
|
|
2304
|
+
) : l ? styleText(["strikethrough", "dim"], l) : "";
|
|
2305
|
+
return `${o}${r}`;
|
|
2306
|
+
}
|
|
2307
|
+
default: {
|
|
2308
|
+
const n = i ? `${styleText("cyan", S_BAR)} ` : "", r = i ? styleText("cyan", S_BAR_END) : "", u = i ? wrapTextWithPrefix(e.output, a, n) : a;
|
|
2309
|
+
return `${o}${u}
|
|
2310
|
+
${r}${c}
|
|
2311
|
+
`;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
}).prompt();
|
|
2316
|
+
|
|
2317
|
+
const W$1 = (o) => o, prompts_dist_C = (o, e, s) => {
|
|
2318
|
+
const a = {
|
|
2319
|
+
hard: true,
|
|
2320
|
+
trim: false
|
|
2321
|
+
}, i = main_wrapAnsi(o, e, a).split(`
|
|
2322
|
+
`), c = i.reduce((n, t) => Math.max(fast_string_width_dist(t), n), 0), u = i.map(s).reduce((n, t) => Math.max(fast_string_width_dist(t), n), 0), g = e - (u - c);
|
|
2323
|
+
return main_wrapAnsi(o, g, a);
|
|
2324
|
+
};
|
|
2325
|
+
const note = (o = "", e = "", s) => {
|
|
2326
|
+
const a = s?.output ?? node_process.stdout, i = s?.withGuide ?? dist_settings.withGuide, c = s?.format ?? W$1, g = ["", ...prompts_dist_C(o, dist_getColumns(a) - 6, c).split(`
|
|
2327
|
+
`).map(c), ""], n = fast_string_width_dist(e), t = Math.max(
|
|
2328
|
+
g.reduce((m, F) => {
|
|
2329
|
+
const O = fast_string_width_dist(F);
|
|
2330
|
+
return O > m ? O : m;
|
|
2331
|
+
}, 0),
|
|
2332
|
+
n
|
|
2333
|
+
) + 2, h = g.map(
|
|
2334
|
+
(m) => `${external_node_util_styleText("gray", S_BAR)} ${m}${" ".repeat(t - fast_string_width_dist(m))}${external_node_util_styleText("gray", S_BAR)}`
|
|
2335
|
+
).join(`
|
|
2336
|
+
`), T = i ? `${external_node_util_styleText("gray", S_BAR)}
|
|
2337
|
+
` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
2338
|
+
a.write(
|
|
2339
|
+
`${T}${external_node_util_styleText("green", S_STEP_SUBMIT)} ${external_node_util_styleText("reset", e)} ${external_node_util_styleText(
|
|
2340
|
+
"gray",
|
|
2341
|
+
S_BAR_H.repeat(Math.max(t - n - 1, 1)) + S_CORNER_TOP_RIGHT
|
|
2342
|
+
)}
|
|
2343
|
+
${h}
|
|
2344
|
+
${external_node_util_styleText("gray", l$1 + S_BAR_H.repeat(t + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
2345
|
+
`
|
|
2346
|
+
);
|
|
2347
|
+
};
|
|
2348
|
+
|
|
2349
|
+
const dist_password = (r) => new PasswordPrompt({
|
|
2350
|
+
validate: r.validate,
|
|
2351
|
+
mask: r.mask ?? S_PASSWORD_MASK,
|
|
2352
|
+
signal: r.signal,
|
|
2353
|
+
input: r.input,
|
|
2354
|
+
output: r.output,
|
|
2355
|
+
render() {
|
|
2356
|
+
const e = r.withGuide ?? settings.withGuide, o = `${e ? `${styleText("gray", S_BAR)}
|
|
2357
|
+
` : ""}${symbol(this.state)} ${r.message}
|
|
2358
|
+
`, c = this.userInputWithCursor, i = this.masked;
|
|
2359
|
+
switch (this.state) {
|
|
2360
|
+
case "error": {
|
|
2361
|
+
const s = e ? `${styleText("yellow", S_BAR)} ` : "", n = e ? `${styleText("yellow", S_BAR_END)} ` : "", l = i ?? "";
|
|
2362
|
+
return r.clearOnError && this.clear(), `${o.trim()}
|
|
2363
|
+
${s}${l}
|
|
2364
|
+
${n}${styleText("yellow", this.error)}
|
|
2365
|
+
`;
|
|
2366
|
+
}
|
|
2367
|
+
case "submit": {
|
|
2368
|
+
const s = e ? `${styleText("gray", S_BAR)} ` : "", n = i ? styleText("dim", i) : "";
|
|
2369
|
+
return `${o}${s}${n}`;
|
|
2370
|
+
}
|
|
2371
|
+
case "cancel": {
|
|
2372
|
+
const s = e ? `${styleText("gray", S_BAR)} ` : "", n = i ? styleText(["strikethrough", "dim"], i) : "";
|
|
2373
|
+
return `${o}${s}${n}${i && e ? `
|
|
2374
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
2375
|
+
}
|
|
2376
|
+
default: {
|
|
2377
|
+
const s = e ? `${styleText("cyan", S_BAR)} ` : "", n = e ? styleText("cyan", S_BAR_END) : "";
|
|
2378
|
+
return `${o}${s}${c}
|
|
2379
|
+
${n}
|
|
2380
|
+
`;
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
}).prompt();
|
|
2385
|
+
|
|
2386
|
+
const dist_path = (e) => {
|
|
2387
|
+
const a = e.validate;
|
|
2388
|
+
return autocomplete({
|
|
2389
|
+
...e,
|
|
2390
|
+
initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
|
|
2391
|
+
maxItems: 5,
|
|
2392
|
+
validate(t) {
|
|
2393
|
+
if (!Array.isArray(t)) {
|
|
2394
|
+
if (!t)
|
|
2395
|
+
return "Please select a path";
|
|
2396
|
+
if (a)
|
|
2397
|
+
return runValidation(a, t);
|
|
2398
|
+
}
|
|
2399
|
+
},
|
|
2400
|
+
options() {
|
|
2401
|
+
const t = this.userInput;
|
|
2402
|
+
if (t === "")
|
|
2403
|
+
return [];
|
|
2404
|
+
try {
|
|
2405
|
+
let i;
|
|
2406
|
+
existsSync(t) ? lstatSync(t).isDirectory() && (!e.directory || t.endsWith("/")) ? i = t : i = dirname(t) : i = dirname(t);
|
|
2407
|
+
const c = t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
|
|
2408
|
+
return readdirSync(i).map((r) => {
|
|
2409
|
+
const n = join(i, r), m = lstatSync(n);
|
|
2410
|
+
return {
|
|
2411
|
+
name: r,
|
|
2412
|
+
path: n,
|
|
2413
|
+
isDirectory: m.isDirectory()
|
|
2414
|
+
};
|
|
2415
|
+
}).filter(
|
|
2416
|
+
({ path: r, isDirectory: n }) => r.startsWith(c) && (n || !e.directory)
|
|
2417
|
+
).map((r) => ({
|
|
2418
|
+
value: r.path
|
|
2419
|
+
}));
|
|
2420
|
+
} catch {
|
|
2421
|
+
return [];
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
};
|
|
2426
|
+
|
|
2427
|
+
const dist_W = (l) => styleText("magenta", l);
|
|
2428
|
+
const spinner = ({
|
|
2429
|
+
indicator: l = "dots",
|
|
2430
|
+
onCancel: h,
|
|
2431
|
+
output: n = process.stdout,
|
|
2432
|
+
cancelMessage: G,
|
|
2433
|
+
errorMessage: O,
|
|
2434
|
+
frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
2435
|
+
delay: F = unicode ? 80 : 120,
|
|
2436
|
+
signal: m,
|
|
2437
|
+
...I
|
|
2438
|
+
} = {}) => {
|
|
2439
|
+
const u = isCI();
|
|
2440
|
+
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
2441
|
+
const x = getColumns(n), k = I?.styleFrame ?? dist_W, g = (e) => {
|
|
2442
|
+
const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
2443
|
+
S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
|
|
2444
|
+
}, f = () => g(2), i = () => g(1), A = () => {
|
|
2445
|
+
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
|
|
2446
|
+
}, H = () => {
|
|
2447
|
+
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
|
|
2448
|
+
}, y = () => {
|
|
2449
|
+
if (p === void 0) return;
|
|
2450
|
+
u && n.write(`
|
|
2451
|
+
`);
|
|
2452
|
+
const r = wrapAnsi(p, x, {
|
|
2453
|
+
hard: true,
|
|
2454
|
+
trim: false
|
|
2455
|
+
}).split(`
|
|
2456
|
+
`);
|
|
2457
|
+
r.length > 1 && n.write(cursor.up(r.length - 1)), n.write(cursor.to(0)), n.write(erase.down());
|
|
2458
|
+
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
2459
|
+
const r = (performance.now() - e) / 1e3, t = Math.floor(r / 60), o = Math.floor(r % 60);
|
|
2460
|
+
return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
|
|
2461
|
+
}, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
2462
|
+
d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText("gray", S_BAR)}
|
|
2463
|
+
`);
|
|
2464
|
+
let r = 0, t = 0;
|
|
2465
|
+
A(), T = setInterval(() => {
|
|
2466
|
+
if (u && s === p)
|
|
2467
|
+
return;
|
|
2468
|
+
y(), p = s;
|
|
2469
|
+
const o = k(E[r]);
|
|
2470
|
+
let v;
|
|
2471
|
+
if (u)
|
|
2472
|
+
v = `${o} ${s}...`;
|
|
2473
|
+
else if (l === "timer")
|
|
2474
|
+
v = `${o} ${s} ${_(w)}`;
|
|
2475
|
+
else {
|
|
2476
|
+
const B = ".".repeat(Math.floor(t)).slice(0, 3);
|
|
2477
|
+
v = `${o} ${s}${B}`;
|
|
2478
|
+
}
|
|
2479
|
+
const j = wrapAnsi(v, x, {
|
|
2480
|
+
hard: true,
|
|
2481
|
+
trim: false
|
|
2482
|
+
});
|
|
2483
|
+
n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + 0.125 : 0;
|
|
2484
|
+
}, F);
|
|
2485
|
+
}, a = (e = "", r = 0, t = false) => {
|
|
2486
|
+
if (!d) return;
|
|
2487
|
+
d = false, clearInterval(T), y();
|
|
2488
|
+
const o = r === 0 ? styleText("green", S_STEP_SUBMIT) : r === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
|
|
2489
|
+
s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
|
|
2490
|
+
`) : n.write(`${o} ${s}
|
|
2491
|
+
`)), H(), M();
|
|
2492
|
+
};
|
|
2493
|
+
return {
|
|
2494
|
+
start: P,
|
|
2495
|
+
stop: (e = "") => a(e, 0),
|
|
2496
|
+
message: (e = "") => {
|
|
2497
|
+
s = C(e ?? s);
|
|
2498
|
+
},
|
|
2499
|
+
cancel: (e = "") => a(e, 1),
|
|
2500
|
+
error: (e = "") => a(e, 2),
|
|
2501
|
+
clear: () => a("", 0, true),
|
|
2502
|
+
get isCancelled() {
|
|
2503
|
+
return S;
|
|
2504
|
+
}
|
|
2505
|
+
};
|
|
2506
|
+
};
|
|
2507
|
+
|
|
2508
|
+
const prompts_dist_u = {
|
|
2509
|
+
light: unicodeOr("\u2500", "-"),
|
|
2510
|
+
heavy: unicodeOr("\u2501", "="),
|
|
2511
|
+
block: unicodeOr("\u2588", "#")
|
|
2512
|
+
};
|
|
2513
|
+
function progress({
|
|
2514
|
+
style: o = "heavy",
|
|
2515
|
+
max: d = 100,
|
|
2516
|
+
size: v = 40,
|
|
2517
|
+
...x
|
|
2518
|
+
} = {}) {
|
|
2519
|
+
const r = spinner(x);
|
|
2520
|
+
let a = 0, n = "";
|
|
2521
|
+
const c = Math.max(1, d), l = Math.max(1, v), S = (t) => {
|
|
2522
|
+
switch (t) {
|
|
2523
|
+
case "initial":
|
|
2524
|
+
case "active":
|
|
2525
|
+
return (e) => styleText("magenta", e);
|
|
2526
|
+
case "error":
|
|
2527
|
+
case "cancel":
|
|
2528
|
+
return (e) => styleText("red", e);
|
|
2529
|
+
case "submit":
|
|
2530
|
+
return (e) => styleText("green", e);
|
|
2531
|
+
default:
|
|
2532
|
+
return (e) => styleText("magenta", e);
|
|
2533
|
+
}
|
|
2534
|
+
}, p = (t, e) => {
|
|
2535
|
+
const m = Math.floor(a / c * l);
|
|
2536
|
+
return `${S(t)(prompts_dist_u[o].repeat(m))}${styleText("dim", prompts_dist_u[o].repeat(l - m))} ${e}`;
|
|
2537
|
+
}, h = (t = "") => {
|
|
2538
|
+
n = t, r.start(p("initial", t));
|
|
2539
|
+
}, g = (t = 1, e) => {
|
|
2540
|
+
a = Math.min(c, t + a), r.message(p("active", e ?? n)), n = e ?? n;
|
|
2541
|
+
};
|
|
2542
|
+
return {
|
|
2543
|
+
start: h,
|
|
2544
|
+
stop: r.stop,
|
|
2545
|
+
cancel: r.cancel,
|
|
2546
|
+
error: r.error,
|
|
2547
|
+
clear: r.clear,
|
|
2548
|
+
advance: g,
|
|
2549
|
+
isCancelled: r.isCancelled,
|
|
2550
|
+
message: (t) => g(0, t)
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
const SELECT_INSTRUCTIONS = [
|
|
2555
|
+
`${external_node_util_styleText("dim", "\u2191/\u2193")} to navigate`,
|
|
2556
|
+
`${external_node_util_styleText("dim", "Enter:")} confirm`
|
|
2557
|
+
];
|
|
2558
|
+
const prompts_dist_c = (t, o) => t.includes(`
|
|
2559
|
+
`) ? t.split(`
|
|
2560
|
+
`).map((d) => o(d)).join(`
|
|
2561
|
+
`) : o(t);
|
|
2562
|
+
const dist_select = (t) => {
|
|
2563
|
+
const o = (n, m) => {
|
|
2564
|
+
if (n === void 0)
|
|
2565
|
+
return "";
|
|
2566
|
+
const s = n.label ?? String(n.value);
|
|
2567
|
+
switch (m) {
|
|
2568
|
+
case "disabled":
|
|
2569
|
+
return `${external_node_util_styleText("gray", S_RADIO_INACTIVE)} ${prompts_dist_c(s, (i) => external_node_util_styleText("gray", i))}${n.hint ? ` ${external_node_util_styleText("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
|
|
2570
|
+
case "selected":
|
|
2571
|
+
return `${prompts_dist_c(s, (i) => external_node_util_styleText("dim", i))}`;
|
|
2572
|
+
case "active":
|
|
2573
|
+
return `${external_node_util_styleText("green", S_RADIO_ACTIVE)} ${s}${n.hint ? ` ${external_node_util_styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
2574
|
+
case "cancelled":
|
|
2575
|
+
return `${prompts_dist_c(s, (i) => external_node_util_styleText(["strikethrough", "dim"], i))}`;
|
|
2576
|
+
default:
|
|
2577
|
+
return `${external_node_util_styleText("dim", S_RADIO_INACTIVE)} ${prompts_dist_c(s, (i) => external_node_util_styleText("dim", i))}`;
|
|
2578
|
+
}
|
|
2579
|
+
}, d = t.showInstructions ?? true;
|
|
2580
|
+
return new n$1({
|
|
2581
|
+
options: t.options,
|
|
2582
|
+
signal: t.signal,
|
|
2583
|
+
input: t.input,
|
|
2584
|
+
output: t.output,
|
|
2585
|
+
initialValue: t.initialValue,
|
|
2586
|
+
render() {
|
|
2587
|
+
const n = t.withGuide ?? dist_settings.withGuide, m = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i = dist_wrapTextWithPrefix(
|
|
2588
|
+
t.output,
|
|
2589
|
+
t.message,
|
|
2590
|
+
s,
|
|
2591
|
+
m
|
|
2592
|
+
), u = `${n ? `${external_node_util_styleText("gray", S_BAR)}
|
|
2593
|
+
` : ""}${i}
|
|
2594
|
+
`;
|
|
2595
|
+
switch (this.state) {
|
|
2596
|
+
case "submit": {
|
|
2597
|
+
const r = n ? `${external_node_util_styleText("gray", S_BAR)} ` : "", a = dist_wrapTextWithPrefix(
|
|
2598
|
+
t.output,
|
|
2599
|
+
o(this.options[this.cursor], "selected"),
|
|
2600
|
+
r
|
|
2601
|
+
);
|
|
2602
|
+
return `${u}${a}`;
|
|
2603
|
+
}
|
|
2604
|
+
case "cancel": {
|
|
2605
|
+
const r = n ? `${external_node_util_styleText("gray", S_BAR)} ` : "", a = dist_wrapTextWithPrefix(
|
|
2606
|
+
t.output,
|
|
2607
|
+
o(this.options[this.cursor], "cancelled"),
|
|
2608
|
+
r
|
|
2609
|
+
);
|
|
2610
|
+
return `${u}${a}${n ? `
|
|
2611
|
+
${external_node_util_styleText("gray", S_BAR)}` : ""}`;
|
|
2612
|
+
}
|
|
2613
|
+
default: {
|
|
2614
|
+
const r = n ? `${external_node_util_styleText("cyan", S_BAR)} ` : "", a = u.split(`
|
|
2615
|
+
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n) : n ? [external_node_util_styleText("cyan", S_BAR_END)] : [], b = p.join(`
|
|
2616
|
+
`), f = p.length + 1;
|
|
2617
|
+
return `${u}${r}${limitOptions({
|
|
2618
|
+
output: t.output,
|
|
2619
|
+
cursor: this.cursor,
|
|
2620
|
+
options: this.options,
|
|
2621
|
+
maxItems: t.maxItems,
|
|
2622
|
+
columnPadding: r.length,
|
|
2623
|
+
rowPadding: a + f,
|
|
2624
|
+
style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
|
|
2625
|
+
}).join(`
|
|
2626
|
+
${r}`)}
|
|
2627
|
+
${b}
|
|
2628
|
+
`;
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
}).prompt();
|
|
2633
|
+
};
|
|
2634
|
+
|
|
2635
|
+
const selectKey = (t) => {
|
|
2636
|
+
const l = (e, a = "inactive") => {
|
|
2637
|
+
if (e === void 0)
|
|
2638
|
+
return "";
|
|
2639
|
+
const n = e.label ?? String(e.value);
|
|
2640
|
+
return a === "selected" ? `${styleText("dim", n)}` : a === "cancelled" ? `${styleText(["strikethrough", "dim"], n)}` : a === "active" ? `${styleText(["bgCyan", "gray"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : `${styleText(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}`;
|
|
2641
|
+
};
|
|
2642
|
+
return new SelectKeyPrompt({
|
|
2643
|
+
options: t.options,
|
|
2644
|
+
signal: t.signal,
|
|
2645
|
+
input: t.input,
|
|
2646
|
+
output: t.output,
|
|
2647
|
+
initialValue: t.initialValue,
|
|
2648
|
+
caseSensitive: t.caseSensitive,
|
|
2649
|
+
render() {
|
|
2650
|
+
const e = t.withGuide ?? settings.withGuide, a = `${e ? `${styleText("gray", S_BAR)}
|
|
2651
|
+
` : ""}${symbol(this.state)} ${t.message}
|
|
2652
|
+
`;
|
|
2653
|
+
switch (this.state) {
|
|
2654
|
+
case "submit": {
|
|
2655
|
+
const n = e ? `${styleText("gray", S_BAR)} ` : "", s = this.options.find((u) => u.value === this.value) ?? t.options[0], c = wrapTextWithPrefix(
|
|
2656
|
+
t.output,
|
|
2657
|
+
l(s, "selected"),
|
|
2658
|
+
n
|
|
2659
|
+
);
|
|
2660
|
+
return `${a}${c}`;
|
|
2661
|
+
}
|
|
2662
|
+
case "cancel": {
|
|
2663
|
+
const n = e ? `${styleText("gray", S_BAR)} ` : "", s = wrapTextWithPrefix(
|
|
2664
|
+
t.output,
|
|
2665
|
+
l(this.options[0], "cancelled"),
|
|
2666
|
+
n
|
|
2667
|
+
);
|
|
2668
|
+
return `${a}${s}${e ? `
|
|
2669
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
2670
|
+
}
|
|
2671
|
+
default: {
|
|
2672
|
+
const n = e ? `${styleText("cyan", S_BAR)} ` : "", s = e ? styleText("cyan", S_BAR_END) : "", c = this.options.map(
|
|
2673
|
+
(u, d) => wrapTextWithPrefix(
|
|
2674
|
+
t.output,
|
|
2675
|
+
l(u, d === this.cursor ? "active" : "inactive"),
|
|
2676
|
+
n
|
|
2677
|
+
)
|
|
2678
|
+
).join(`
|
|
2679
|
+
`);
|
|
2680
|
+
return `${a}${c}
|
|
2681
|
+
${s}
|
|
2682
|
+
`;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}).prompt();
|
|
2687
|
+
};
|
|
2688
|
+
|
|
2689
|
+
const dist_i = `${external_node_util_styleText("gray", S_BAR)} `;
|
|
2690
|
+
const stream = (/* unused pure expression or super */ null && ({
|
|
2691
|
+
message: async (e, { symbol: l = styleText("gray", S_BAR) } = {}) => {
|
|
2692
|
+
process.stdout.write(`${styleText("gray", S_BAR)}
|
|
2693
|
+
${l} `);
|
|
2694
|
+
let s = 3;
|
|
2695
|
+
for await (let r of e) {
|
|
2696
|
+
r = r.replace(/\n/g, `
|
|
2697
|
+
${dist_i}`), r.includes(`
|
|
2698
|
+
`) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
|
|
2699
|
+
`))).length);
|
|
2700
|
+
const o = stripVTControlCharacters(r).length;
|
|
2701
|
+
s + o < process.stdout.columns ? (s += o, process.stdout.write(r)) : (process.stdout.write(`
|
|
2702
|
+
${dist_i}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
|
|
2703
|
+
}
|
|
2704
|
+
process.stdout.write(`
|
|
2705
|
+
`);
|
|
2706
|
+
},
|
|
2707
|
+
info: (e) => stream.message(e, { symbol: styleText("blue", S_INFO) }),
|
|
2708
|
+
success: (e) => stream.message(e, { symbol: styleText("green", S_SUCCESS) }),
|
|
2709
|
+
step: (e) => stream.message(e, { symbol: styleText("green", S_STEP_SUBMIT) }),
|
|
2710
|
+
warn: (e) => stream.message(e, { symbol: styleText("yellow", S_WARN) }),
|
|
2711
|
+
/** alias for `log.warn()`. */
|
|
2712
|
+
warning: (e) => stream.warn(e),
|
|
2713
|
+
error: (e) => stream.message(e, { symbol: styleText("red", S_ERROR) })
|
|
2714
|
+
}));
|
|
2715
|
+
|
|
2716
|
+
const tasks = async (o, e) => {
|
|
2717
|
+
for (const t of o) {
|
|
2718
|
+
if (t.enabled === false) continue;
|
|
2719
|
+
const s = spinner(e);
|
|
2720
|
+
s.start(t.title);
|
|
2721
|
+
const n = await t.task(s.message);
|
|
2722
|
+
s.stop(n || t.title);
|
|
2723
|
+
}
|
|
2724
|
+
};
|
|
2725
|
+
|
|
2726
|
+
const dist_A = (l) => l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
|
|
2727
|
+
const taskLog = (l) => {
|
|
2728
|
+
const r = l.output ?? process.stdout, O = getColumns(r), i = styleText("gray", S_BAR), p = l.spacing ?? 1, k = 3, m = l.retainLog === true, d = !isCI() && isTTY(r);
|
|
2729
|
+
r.write(`${i}
|
|
2730
|
+
`), r.write(`${styleText("green", S_STEP_SUBMIT)} ${l.title}
|
|
2731
|
+
`);
|
|
2732
|
+
for (let e = 0; e < p; e++)
|
|
2733
|
+
r.write(`${i}
|
|
2734
|
+
`);
|
|
2735
|
+
const n = [
|
|
2736
|
+
{
|
|
2737
|
+
value: "",
|
|
2738
|
+
full: ""
|
|
2739
|
+
}
|
|
2740
|
+
];
|
|
2741
|
+
let v = false;
|
|
2742
|
+
const f = (e) => {
|
|
2743
|
+
if (n.length === 0)
|
|
2744
|
+
return;
|
|
2745
|
+
let s = 0;
|
|
2746
|
+
e && (s += p + 2);
|
|
2747
|
+
for (const t of n) {
|
|
2748
|
+
const { value: o, result: a } = t;
|
|
2749
|
+
let g = a?.message ?? o;
|
|
2750
|
+
if (g.length === 0)
|
|
2751
|
+
continue;
|
|
2752
|
+
a === void 0 && t.header !== void 0 && t.header !== "" && (g += `
|
|
2753
|
+
${t.header}`);
|
|
2754
|
+
const E = g.split(`
|
|
2755
|
+
`).reduce((b, w) => w === "" ? b + 1 : b + Math.ceil((w.length + k) / O), 0);
|
|
2756
|
+
s += E;
|
|
2757
|
+
}
|
|
2758
|
+
s > 0 && (s += 1, r.write(erase.lines(s)));
|
|
2759
|
+
}, h = (e, s, t) => {
|
|
2760
|
+
const o = t ? `${e.full}
|
|
2761
|
+
${e.value}` : e.value;
|
|
2762
|
+
e.header !== void 0 && e.header !== "" && log.message(
|
|
2763
|
+
e.header.split(`
|
|
2764
|
+
`).map((a) => styleText("bold", a)),
|
|
2765
|
+
{
|
|
2766
|
+
output: r,
|
|
2767
|
+
secondarySymbol: i,
|
|
2768
|
+
symbol: i,
|
|
2769
|
+
spacing: 0
|
|
2770
|
+
}
|
|
2771
|
+
), log.message(
|
|
2772
|
+
o.split(`
|
|
2773
|
+
`).map((a) => styleText("dim", a)),
|
|
2774
|
+
{
|
|
2775
|
+
output: r,
|
|
2776
|
+
secondarySymbol: i,
|
|
2777
|
+
symbol: i,
|
|
2778
|
+
spacing: s ?? p
|
|
2779
|
+
}
|
|
2780
|
+
);
|
|
2781
|
+
}, T = () => {
|
|
2782
|
+
for (const e of n) {
|
|
2783
|
+
const { header: s, value: t, full: o } = e;
|
|
2784
|
+
(s === void 0 || s.length === 0) && t.length === 0 || h(e, void 0, m === true && o.length > 0);
|
|
2785
|
+
}
|
|
2786
|
+
}, L = (e, s, t) => {
|
|
2787
|
+
if (f(false), (t?.raw !== true || !v) && e.value !== "" && (e.value += `
|
|
2788
|
+
`), e.value += dist_A(s), v = t?.raw === true, l.limit !== void 0) {
|
|
2789
|
+
const o = e.value.split(`
|
|
2790
|
+
`), a = o.length - l.limit;
|
|
2791
|
+
if (a > 0) {
|
|
2792
|
+
const g = o.splice(0, a);
|
|
2793
|
+
m && (e.full += (e.full === "" ? "" : `
|
|
2794
|
+
`) + g.join(`
|
|
2795
|
+
`));
|
|
2796
|
+
}
|
|
2797
|
+
e.value = o.join(`
|
|
2798
|
+
`);
|
|
2799
|
+
}
|
|
2800
|
+
d && y();
|
|
2801
|
+
}, y = () => {
|
|
2802
|
+
for (const e of n)
|
|
2803
|
+
e.result ? e.result.status === "error" ? log.error(e.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : log.success(e.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : e.value !== "" && h(e, 0);
|
|
2804
|
+
}, B = (e, s) => {
|
|
2805
|
+
f(false), e.result = s, d && y();
|
|
2806
|
+
};
|
|
2807
|
+
return {
|
|
2808
|
+
message(e, s) {
|
|
2809
|
+
L(n[0], e, s);
|
|
2810
|
+
},
|
|
2811
|
+
group(e) {
|
|
2812
|
+
const s = {
|
|
2813
|
+
header: e,
|
|
2814
|
+
value: "",
|
|
2815
|
+
full: ""
|
|
2816
|
+
};
|
|
2817
|
+
return n.push(s), {
|
|
2818
|
+
message(t, o) {
|
|
2819
|
+
L(s, t, o);
|
|
2820
|
+
},
|
|
2821
|
+
error(t) {
|
|
2822
|
+
B(s, {
|
|
2823
|
+
status: "error",
|
|
2824
|
+
message: t
|
|
2825
|
+
});
|
|
2826
|
+
},
|
|
2827
|
+
success(t) {
|
|
2828
|
+
B(s, {
|
|
2829
|
+
status: "success",
|
|
2830
|
+
message: t
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
};
|
|
2834
|
+
},
|
|
2835
|
+
error(e, s) {
|
|
2836
|
+
f(true), log.error(e, { output: r, secondarySymbol: i, spacing: 1 }), s?.showLog !== false && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
|
|
2837
|
+
},
|
|
2838
|
+
success(e, s) {
|
|
2839
|
+
f(true), log.success(e, { output: r, secondarySymbol: i, spacing: 1 }), s?.showLog === true && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
|
|
2840
|
+
}
|
|
2841
|
+
};
|
|
2842
|
+
};
|
|
2843
|
+
|
|
2844
|
+
const dist_text = (e) => new dist_n({
|
|
2845
|
+
validate: e.validate,
|
|
2846
|
+
placeholder: e.placeholder,
|
|
2847
|
+
defaultValue: e.defaultValue,
|
|
2848
|
+
initialValue: e.initialValue,
|
|
2849
|
+
output: e.output,
|
|
2850
|
+
signal: e.signal,
|
|
2851
|
+
input: e.input,
|
|
2852
|
+
render() {
|
|
2853
|
+
const i = e?.withGuide ?? dist_settings.withGuide, s = `${`${i ? `${external_node_util_styleText("gray", S_BAR)}
|
|
2854
|
+
` : ""}${symbol(this.state)} `}${e.message}
|
|
2855
|
+
`, c = e.placeholder && e.placeholder.length > 0 ? (
|
|
2856
|
+
// biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
|
|
2857
|
+
external_node_util_styleText("inverse", e.placeholder[0]) + external_node_util_styleText("dim", e.placeholder.slice(1))
|
|
2858
|
+
) : external_node_util_styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, l = this.value ?? "";
|
|
2859
|
+
switch (this.state) {
|
|
2860
|
+
case "error": {
|
|
2861
|
+
const n = this.error ? ` ${external_node_util_styleText("yellow", this.error)}` : "", r = i ? `${external_node_util_styleText("yellow", S_BAR)} ` : "", d = i ? external_node_util_styleText("yellow", S_BAR_END) : "";
|
|
2862
|
+
return `${s.trim()}
|
|
2863
|
+
${r}${o}
|
|
2864
|
+
${d}${n}
|
|
2865
|
+
`;
|
|
2866
|
+
}
|
|
2867
|
+
case "submit": {
|
|
2868
|
+
const n = l ? ` ${external_node_util_styleText("dim", l)}` : "", r = i ? external_node_util_styleText("gray", S_BAR) : "";
|
|
2869
|
+
return `${s}${r}${n}`;
|
|
2870
|
+
}
|
|
2871
|
+
case "cancel": {
|
|
2872
|
+
const n = l ? ` ${external_node_util_styleText(["strikethrough", "dim"], l)}` : "", r = i ? external_node_util_styleText("gray", S_BAR) : "";
|
|
2873
|
+
return `${s}${r}${n}${l.trim() ? `
|
|
2874
|
+
${r}` : ""}`;
|
|
2875
|
+
}
|
|
2876
|
+
default: {
|
|
2877
|
+
const n = i ? `${external_node_util_styleText("cyan", S_BAR)} ` : "", r = i ? external_node_util_styleText("cyan", S_BAR_END) : "";
|
|
2878
|
+
return `${s}${n}${o}
|
|
2879
|
+
${r}
|
|
2880
|
+
`;
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
}).prompt();
|
|
2885
|
+
|
|
2886
|
+
|
|
2887
|
+
|
|
2888
|
+
;// CONCATENATED MODULE: external "node:child_process"
|
|
2889
|
+
|
|
2890
|
+
;// CONCATENATED MODULE: ./src/git.ts
|
|
2891
|
+
|
|
2892
|
+
function git_git(args, cwd) {
|
|
2893
|
+
const result = spawnSync('git', args, {
|
|
2894
|
+
cwd,
|
|
2895
|
+
encoding: 'utf8',
|
|
2896
|
+
shell: process.platform === 'win32'
|
|
2897
|
+
});
|
|
2898
|
+
return {
|
|
2899
|
+
ok: result.status === 0,
|
|
2900
|
+
stdout: (result.stdout ?? '').trim()
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
function hasGit(cwd) {
|
|
2904
|
+
return git_git([
|
|
2905
|
+
'--version'
|
|
2906
|
+
], cwd).ok;
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* Whether the new project already sits inside somebody's repository — scaffolding into a monorepo or an
|
|
2910
|
+
* existing checkout, where a nested repo would be a surprise rather than a convenience.
|
|
2911
|
+
*/ function isInsideRepo(cwd) {
|
|
2912
|
+
const { ok, stdout } = git_git([
|
|
2913
|
+
'rev-parse',
|
|
2914
|
+
'--is-inside-work-tree'
|
|
2915
|
+
], cwd);
|
|
2916
|
+
return ok && stdout === 'true';
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* Initializes a repository and makes the first commit.
|
|
2920
|
+
*
|
|
2921
|
+
* `initialized` rather than `committed` is the honest answer when the commit itself fails, which it does
|
|
2922
|
+
* on a machine with no `user.email` configured. That is not a reason to fail the scaffold — the files
|
|
2923
|
+
* are all there and staged — so the caller reports it and moves on.
|
|
2924
|
+
*/ function initRepo(cwd) {
|
|
2925
|
+
const init = git_git([
|
|
2926
|
+
'init',
|
|
2927
|
+
'-b',
|
|
2928
|
+
'main'
|
|
2929
|
+
], cwd).ok || git_git([
|
|
2930
|
+
'init'
|
|
2931
|
+
], cwd).ok;
|
|
2932
|
+
if (!init) return 'failed';
|
|
2933
|
+
if (!git_git([
|
|
2934
|
+
'add',
|
|
2935
|
+
'-A'
|
|
2936
|
+
], cwd).ok) return 'initialized';
|
|
2937
|
+
return git_git([
|
|
2938
|
+
'commit',
|
|
2939
|
+
'-m',
|
|
2940
|
+
'Initial commit from create-rshono'
|
|
2941
|
+
], cwd).ok ? 'committed' : 'initialized';
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
;// CONCATENATED MODULE: ./src/generated/framework.ts
|
|
2945
|
+
// GENERATED by scripts/codegen.mjs from packages/core — do not edit. Run `pnpm --filter @rshono/create codegen`.
|
|
2946
|
+
/** The framework release a scaffolded app is pinned to: this package and rshono ship together. */ const RSHONO_VERSION = '1.0.0-rc.0';
|
|
2947
|
+
/**
|
|
2948
|
+
* The dependency versions rshono is tested against, copied from its own manifest. Exact where it is
|
|
2949
|
+
* exact — React's RSC internals are coupled across builds, and a generated app has no workspace
|
|
2950
|
+
* overrides to fall back on.
|
|
2951
|
+
*/ const FRAMEWORK_DEPS = {
|
|
2952
|
+
hono: '^4.12.31',
|
|
2953
|
+
react: '19.2.8',
|
|
2954
|
+
'react-dom': '19.2.8',
|
|
2955
|
+
typescript: '^7.0.2',
|
|
2956
|
+
'@types/node': '^26.1.1',
|
|
2957
|
+
'@types/react': '^19.2.17'
|
|
2958
|
+
};
|
|
2959
|
+
/** Every `deploy` target the installed framework knows, with the command that ships what it built. */ const DEPLOY_TARGETS = [
|
|
2960
|
+
{
|
|
2961
|
+
name: 'node',
|
|
2962
|
+
hint: 'run `rshono start`'
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
name: 'cloudflare',
|
|
2966
|
+
hint: 'deploy with `wrangler deploy`'
|
|
2967
|
+
},
|
|
2968
|
+
{
|
|
2969
|
+
name: 'bun',
|
|
2970
|
+
hint: 'run `bun dist/server/main.mjs`'
|
|
2971
|
+
},
|
|
2972
|
+
{
|
|
2973
|
+
name: 'deno',
|
|
2974
|
+
hint: 'run `deno serve -A dist/server/main.mjs`'
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
name: 'vercel',
|
|
2978
|
+
hint: 'deploy with `vercel deploy --prebuilt`'
|
|
2979
|
+
},
|
|
2980
|
+
{
|
|
2981
|
+
name: 'netlify',
|
|
2982
|
+
hint: 'deploy with `netlify deploy --build=false --dir=.netlify/publish`'
|
|
2983
|
+
},
|
|
2984
|
+
{
|
|
2985
|
+
name: 'aws-lambda',
|
|
2986
|
+
hint: 'zip dist/ with the handler at dist/server/main.mjs'
|
|
2987
|
+
}
|
|
2988
|
+
];
|
|
2989
|
+
|
|
2990
|
+
;// CONCATENATED MODULE: ./src/options.ts
|
|
2991
|
+
|
|
2992
|
+
const PACKAGE_MANAGERS = (/* unused pure expression or super */ null && ([
|
|
2993
|
+
'npm',
|
|
2994
|
+
'pnpm',
|
|
2995
|
+
'yarn',
|
|
2996
|
+
'bun'
|
|
2997
|
+
]));
|
|
2998
|
+
const DEPLOY_TARGET_NAMES = DEPLOY_TARGETS.map((target)=>target.name);
|
|
2999
|
+
function deployHint(name) {
|
|
3000
|
+
return DEPLOY_TARGETS.find((target)=>target.name === name)?.hint ?? '';
|
|
3001
|
+
}
|
|
3002
|
+
function isDeployTarget(value) {
|
|
3003
|
+
return DEPLOY_TARGET_NAMES.includes(value);
|
|
3004
|
+
}
|
|
3005
|
+
const QUALITY_PRESETS = [
|
|
3006
|
+
{
|
|
3007
|
+
id: 'prettier-oxlint',
|
|
3008
|
+
label: 'Prettier + oxlint',
|
|
3009
|
+
hint: 'the conventional formatter, with a fast linter',
|
|
3010
|
+
formatter: 'prettier',
|
|
3011
|
+
linter: 'oxlint'
|
|
3012
|
+
},
|
|
3013
|
+
{
|
|
3014
|
+
id: 'biome',
|
|
3015
|
+
label: 'Biome',
|
|
3016
|
+
hint: 'formatter and linter in one tool',
|
|
3017
|
+
formatter: 'biome',
|
|
3018
|
+
linter: 'biome'
|
|
3019
|
+
},
|
|
3020
|
+
{
|
|
3021
|
+
id: 'oxc',
|
|
3022
|
+
label: 'oxfmt + oxlint',
|
|
3023
|
+
hint: 'the oxc toolchain — fastest, newest',
|
|
3024
|
+
formatter: 'oxfmt',
|
|
3025
|
+
linter: 'oxlint'
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
id: 'none',
|
|
3029
|
+
label: 'None',
|
|
3030
|
+
hint: 'add your own later',
|
|
3031
|
+
formatter: 'none',
|
|
3032
|
+
linter: 'none'
|
|
3033
|
+
}
|
|
3034
|
+
];
|
|
3035
|
+
/**
|
|
3036
|
+
* Turns whatever the user typed into a name npm will accept, or returns `null` when nothing usable is
|
|
3037
|
+
* left. Lowercasing and replacing runs of invalid characters covers the ordinary cases (`My App`,
|
|
3038
|
+
* `my_app`); a scoped name is kept intact, since `@scope/name` is legal.
|
|
3039
|
+
*/ function toPackageName(input) {
|
|
3040
|
+
const trimmed = input.trim().replace(/^\.\/+/, '').replace(/\/+$/, '');
|
|
3041
|
+
if (!trimmed || trimmed === '.') return null;
|
|
3042
|
+
// A scoped name is a name, not a path: `@scope/pkg` stays whole rather than becoming `pkg`. Anything
|
|
3043
|
+
// else is a path, and the last segment is the one that names the project.
|
|
3044
|
+
const scoped = /^@[^\\/]+[\\/][^\\/]+$/.test(trimmed);
|
|
3045
|
+
const base = scoped ? trimmed : trimmed.split(/[\\/]/).filter(Boolean).pop() ?? '';
|
|
3046
|
+
if (!base) return null;
|
|
3047
|
+
const name = base.toLowerCase().replace(/[\\/]/g, '/').replace(/[^a-z\d\-._~/@]+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
|
|
3048
|
+
if (!name || name === '@' || !scoped && name.startsWith('.')) return null;
|
|
3049
|
+
return name.slice(0, 214);
|
|
3050
|
+
}
|
|
3051
|
+
/** npm's own rule, narrowed to what we ever generate: no uppercase, no leading dot or underscore. */ function isValidPackageName(name) {
|
|
3052
|
+
return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(name) && name.length <= 214;
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
;// CONCATENATED MODULE: ./src/features/combinations.ts
|
|
3056
|
+
/**
|
|
3057
|
+
* Biome's CSS parser rejects Tailwind's syntax — `@apply` and a `@layer` block are parse errors, not
|
|
3058
|
+
* unknown-at-rule warnings — so a project with both needs Biome pointed away from stylesheets. The
|
|
3059
|
+
* overlay is a second `biome.json` listed after the first, which is all "later overlay wins" means.
|
|
3060
|
+
*
|
|
3061
|
+
* Narrow on purpose: the alternative was excluding CSS for everybody, which would quietly give up
|
|
3062
|
+
* formatting the plain-CSS template that Biome handles perfectly well.
|
|
3063
|
+
*/ const BIOME_TAILWIND = {
|
|
3064
|
+
id: 'biome-tailwind',
|
|
3065
|
+
overlays: [
|
|
3066
|
+
'biome-tailwind'
|
|
3067
|
+
]
|
|
3068
|
+
};
|
|
3069
|
+
/**
|
|
3070
|
+
* Features that exist because of how two answers *combine*, rather than because of either one alone.
|
|
3071
|
+
* Applied after the per-axis features, so an overlay here has the last word on a file.
|
|
3072
|
+
*
|
|
3073
|
+
* Keep this list short. A combination that needs more than a file swap is usually a sign that the two
|
|
3074
|
+
* options should not both be offered.
|
|
3075
|
+
*/ function combinationFeatures(answers) {
|
|
3076
|
+
const usesBiome = answers.formatter === 'biome' || answers.linter === 'biome';
|
|
3077
|
+
return usesBiome && answers.styling === 'tailwind' ? [
|
|
3078
|
+
BIOME_TAILWIND
|
|
3079
|
+
] : [];
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
;// CONCATENATED MODULE: ./src/versions.ts
|
|
3083
|
+
|
|
3084
|
+
|
|
3085
|
+
/** The framework range a scaffolded app gets. The two packages are released together, so this is ours. */ const RSHONO_RANGE = `^${RSHONO_VERSION}`;
|
|
3086
|
+
/**
|
|
3087
|
+
* Versions for the optional tooling the features can add — the one place in this package where a
|
|
3088
|
+
* dependency range is typed out by hand, because none of these are things the framework itself
|
|
3089
|
+
* declares. Everything a *scaffolded app* needs to run rshono comes from {@link FRAMEWORK_DEPS},
|
|
3090
|
+
* which is generated from rshono's own manifest and must not be edited here.
|
|
3091
|
+
*
|
|
3092
|
+
* Ranges are caret, not exact: these are the app's own dev tools, and a scaffold made six months from
|
|
3093
|
+
* now should pick up their patch releases rather than pinning whatever was current the day this file
|
|
3094
|
+
* was last touched.
|
|
3095
|
+
*/ const TOOL_VERSIONS = {
|
|
3096
|
+
tailwindcss: '^4.3.3',
|
|
3097
|
+
'@tailwindcss/postcss': '^4.3.3',
|
|
3098
|
+
// The pass Tailwind runs in, installed with it rather than with the framework.
|
|
3099
|
+
postcss: '^8.5.23',
|
|
3100
|
+
'postcss-loader': '^8.2.1',
|
|
3101
|
+
prettier: '^3.9.6',
|
|
3102
|
+
'@biomejs/biome': '^2.5.6',
|
|
3103
|
+
oxlint: '^1.76.0',
|
|
3104
|
+
oxfmt: '^0.61.0',
|
|
3105
|
+
wrangler: '^4.115.0'
|
|
3106
|
+
};
|
|
3107
|
+
|
|
3108
|
+
;// CONCATENATED MODULE: ./src/features/deploy.ts
|
|
3109
|
+
|
|
3110
|
+
/**
|
|
3111
|
+
* What a deploy target adds beyond the `deploy` line in `rshono.config.ts` — which is the build's job
|
|
3112
|
+
* to read, and the template's to carry.
|
|
3113
|
+
*
|
|
3114
|
+
* Deliberately thin. The framework already knows how to arrange its own output for every platform, and
|
|
3115
|
+
* `rshono build` writes the one platform config that has to exist (`wrangler.jsonc`, with the
|
|
3116
|
+
* `compatibility_date` of the day it ran) if the project has none. Generating a second copy here would
|
|
3117
|
+
* be a copy that goes stale. So a target contributes a `deploy` script, the CLI it needs locally, and
|
|
3118
|
+
* the build artefacts its platform leaves in the project.
|
|
3119
|
+
*/ const DEPLOY_FEATURES = {
|
|
3120
|
+
// Where a Node build goes from here is a Dockerfile or a process manager, neither of which this can
|
|
3121
|
+
// guess — so the target contributes only the command that runs what was built.
|
|
3122
|
+
node: {
|
|
3123
|
+
id: 'deploy-node',
|
|
3124
|
+
scripts: {
|
|
3125
|
+
start: 'rshono start'
|
|
3126
|
+
}
|
|
3127
|
+
},
|
|
3128
|
+
// `rshono start` is the Node target's launcher and refuses a build made for another platform, so
|
|
3129
|
+
// these two get the command their own runtime uses under the same script name.
|
|
3130
|
+
bun: {
|
|
3131
|
+
id: 'deploy-bun',
|
|
3132
|
+
scripts: {
|
|
3133
|
+
start: 'bun dist/server/main.mjs'
|
|
3134
|
+
}
|
|
3135
|
+
},
|
|
3136
|
+
deno: {
|
|
3137
|
+
id: 'deploy-deno',
|
|
3138
|
+
scripts: {
|
|
3139
|
+
start: 'deno serve -A dist/server/main.mjs'
|
|
3140
|
+
}
|
|
3141
|
+
},
|
|
3142
|
+
cloudflare: {
|
|
3143
|
+
id: 'deploy-cloudflare',
|
|
3144
|
+
devDependencies: {
|
|
3145
|
+
wrangler: TOOL_VERSIONS.wrangler
|
|
3146
|
+
},
|
|
3147
|
+
scripts: {
|
|
3148
|
+
deploy: 'rshono build && wrangler deploy'
|
|
3149
|
+
},
|
|
3150
|
+
gitignore: [
|
|
3151
|
+
'.wrangler/'
|
|
3152
|
+
],
|
|
3153
|
+
notes: [
|
|
3154
|
+
'The first build writes wrangler.jsonc — yours to edit after that.'
|
|
3155
|
+
]
|
|
3156
|
+
},
|
|
3157
|
+
vercel: {
|
|
3158
|
+
id: 'deploy-vercel',
|
|
3159
|
+
scripts: {
|
|
3160
|
+
deploy: 'rshono build && vercel deploy --prebuilt'
|
|
3161
|
+
},
|
|
3162
|
+
gitignore: [
|
|
3163
|
+
'.vercel/'
|
|
3164
|
+
],
|
|
3165
|
+
notes: [
|
|
3166
|
+
'--prebuilt uploads what rshono build assembled; the platform must not rebuild it.'
|
|
3167
|
+
]
|
|
3168
|
+
},
|
|
3169
|
+
netlify: {
|
|
3170
|
+
id: 'deploy-netlify',
|
|
3171
|
+
scripts: {
|
|
3172
|
+
deploy: 'rshono build && netlify deploy --build=false --dir=.netlify/publish'
|
|
3173
|
+
},
|
|
3174
|
+
gitignore: [
|
|
3175
|
+
'.netlify/'
|
|
3176
|
+
]
|
|
3177
|
+
},
|
|
3178
|
+
'aws-lambda': {
|
|
3179
|
+
id: 'deploy-aws-lambda',
|
|
3180
|
+
notes: [
|
|
3181
|
+
'Use a Function URL in RESPONSE_STREAM mode — a buffered invoke mode drops the streaming.'
|
|
3182
|
+
]
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
function deployFeature(target) {
|
|
3186
|
+
return DEPLOY_FEATURES[target];
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
;// CONCATENATED MODULE: ./src/features/quality.ts
|
|
3190
|
+
|
|
3191
|
+
/**
|
|
3192
|
+
* The formatter and linter features. Biome answers to both slots and appears once — `selectFeatures`
|
|
3193
|
+
* deduplicates by `id`, so `formatter: 'biome', linter: 'biome'` contributes one set of files, one
|
|
3194
|
+
* dependency and one pair of scripts.
|
|
3195
|
+
*
|
|
3196
|
+
* Each tool brings its own `check` script alongside `format`/`lint`, because the writing half and the
|
|
3197
|
+
* CI half want different exit-code behaviour: `format` rewrites files, `check` fails instead.
|
|
3198
|
+
*/ const PRETTIER = {
|
|
3199
|
+
id: 'prettier',
|
|
3200
|
+
overlays: [
|
|
3201
|
+
'prettier'
|
|
3202
|
+
],
|
|
3203
|
+
devDependencies: {
|
|
3204
|
+
prettier: TOOL_VERSIONS.prettier
|
|
3205
|
+
},
|
|
3206
|
+
scripts: {
|
|
3207
|
+
format: 'prettier --write .',
|
|
3208
|
+
'format:check': 'prettier --check .'
|
|
3209
|
+
}
|
|
3210
|
+
};
|
|
3211
|
+
const OXFMT = {
|
|
3212
|
+
id: 'oxfmt',
|
|
3213
|
+
overlays: [
|
|
3214
|
+
'oxfmt'
|
|
3215
|
+
],
|
|
3216
|
+
devDependencies: {
|
|
3217
|
+
oxfmt: TOOL_VERSIONS.oxfmt
|
|
3218
|
+
},
|
|
3219
|
+
scripts: {
|
|
3220
|
+
format: 'oxfmt .',
|
|
3221
|
+
'format:check': 'oxfmt --check .'
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
const OXLINT = {
|
|
3225
|
+
id: 'oxlint',
|
|
3226
|
+
overlays: [
|
|
3227
|
+
'oxlint'
|
|
3228
|
+
],
|
|
3229
|
+
devDependencies: {
|
|
3230
|
+
oxlint: TOOL_VERSIONS.oxlint
|
|
3231
|
+
},
|
|
3232
|
+
scripts: {
|
|
3233
|
+
lint: 'oxlint',
|
|
3234
|
+
'lint:fix': 'oxlint --fix'
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
const BIOME = {
|
|
3238
|
+
id: 'biome',
|
|
3239
|
+
overlays: [
|
|
3240
|
+
'biome'
|
|
3241
|
+
],
|
|
3242
|
+
devDependencies: {
|
|
3243
|
+
'@biomejs/biome': TOOL_VERSIONS["@biomejs/biome"]
|
|
3244
|
+
},
|
|
3245
|
+
scripts: {
|
|
3246
|
+
format: 'biome format --write .',
|
|
3247
|
+
'format:check': 'biome format .',
|
|
3248
|
+
lint: 'biome lint .',
|
|
3249
|
+
'lint:fix': 'biome lint --write .',
|
|
3250
|
+
check: 'biome check .'
|
|
3251
|
+
}
|
|
3252
|
+
};
|
|
3253
|
+
const FORMATTERS = {
|
|
3254
|
+
prettier: PRETTIER,
|
|
3255
|
+
oxfmt: OXFMT,
|
|
3256
|
+
biome: BIOME,
|
|
3257
|
+
none: null
|
|
3258
|
+
};
|
|
3259
|
+
const LINTERS = {
|
|
3260
|
+
oxlint: OXLINT,
|
|
3261
|
+
biome: BIOME,
|
|
3262
|
+
none: null
|
|
3263
|
+
};
|
|
3264
|
+
function formatterFeature(formatter) {
|
|
3265
|
+
return FORMATTERS[formatter];
|
|
3266
|
+
}
|
|
3267
|
+
function linterFeature(linter) {
|
|
3268
|
+
return LINTERS[linter];
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
;// CONCATENATED MODULE: ./src/features/styling.ts
|
|
3272
|
+
|
|
3273
|
+
/**
|
|
3274
|
+
* Tailwind is a PostCSS plugin and nothing more, which is the whole of this feature: four packages, and
|
|
3275
|
+
* an overlay carrying the `postcss.config.mjs` naming the plugin, an `rshono.config.ts` whose `rspack`
|
|
3276
|
+
* hook puts postcss-loader in front of the CSS parser, a Tailwind entry stylesheet, and the two views
|
|
3277
|
+
* written in utilities instead of classes of their own.
|
|
3278
|
+
*
|
|
3279
|
+
* `postcss` and `postcss-loader` are the app's dependencies rather than the framework's — rshono
|
|
3280
|
+
* compiles CSS natively and has no PostCSS in it, so an app that does not want a plugin chain does not
|
|
3281
|
+
* install one.
|
|
3282
|
+
*/ const TAILWIND = {
|
|
3283
|
+
id: 'tailwind',
|
|
3284
|
+
overlays: [
|
|
3285
|
+
'tailwind'
|
|
3286
|
+
],
|
|
3287
|
+
devDependencies: {
|
|
3288
|
+
tailwindcss: TOOL_VERSIONS.tailwindcss,
|
|
3289
|
+
'@tailwindcss/postcss': TOOL_VERSIONS["@tailwindcss/postcss"],
|
|
3290
|
+
postcss: TOOL_VERSIONS.postcss,
|
|
3291
|
+
'postcss-loader': TOOL_VERSIONS["postcss-loader"]
|
|
3292
|
+
}
|
|
3293
|
+
};
|
|
3294
|
+
function stylingFeature(styling) {
|
|
3295
|
+
return styling === 'tailwind' ? TAILWIND : null;
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
;// CONCATENATED MODULE: ./src/features/index.ts
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
/**
|
|
3304
|
+
* The features a set of answers selects, in application order — so an overlay listed later wins a file
|
|
3305
|
+
* both of them ship. Deduplicated by `id`, which is what lets one feature answer two questions (Biome
|
|
3306
|
+
* is both the formatter and the linter) without contributing twice.
|
|
3307
|
+
*/ function selectFeatures(answers) {
|
|
3308
|
+
const selected = [
|
|
3309
|
+
deployFeature(answers.deploy),
|
|
3310
|
+
stylingFeature(answers.styling),
|
|
3311
|
+
formatterFeature(answers.formatter),
|
|
3312
|
+
linterFeature(answers.linter),
|
|
3313
|
+
...combinationFeatures(answers)
|
|
3314
|
+
];
|
|
3315
|
+
const features = [];
|
|
3316
|
+
const seen = new Set();
|
|
3317
|
+
for (const feature of selected){
|
|
3318
|
+
if (!feature || seen.has(feature.id)) continue;
|
|
3319
|
+
seen.add(feature.id);
|
|
3320
|
+
features.push(feature);
|
|
3321
|
+
}
|
|
3322
|
+
return features;
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
;// CONCATENATED MODULE: ./src/pkg.ts
|
|
3326
|
+
|
|
3327
|
+
/**
|
|
3328
|
+
* The scripts every app gets. `start` is not among them: it is the *Node* launcher, and the deploy
|
|
3329
|
+
* features each contribute the command their own platform runs what was built with.
|
|
3330
|
+
*/ const BASE_SCRIPTS = {
|
|
3331
|
+
dev: 'rshono dev',
|
|
3332
|
+
build: 'rshono build',
|
|
3333
|
+
typecheck: 'tsc --noEmit'
|
|
3334
|
+
};
|
|
3335
|
+
/** Field order in the emitted file — the conventional reading order, and stable so snapshots are too. */ const FIELD_ORDER = [
|
|
3336
|
+
'name',
|
|
3337
|
+
'version',
|
|
3338
|
+
'private',
|
|
3339
|
+
'type',
|
|
3340
|
+
'engines',
|
|
3341
|
+
'packageManager',
|
|
3342
|
+
'scripts',
|
|
3343
|
+
'dependencies',
|
|
3344
|
+
'devDependencies'
|
|
3345
|
+
];
|
|
3346
|
+
function sorted(record) {
|
|
3347
|
+
return Object.fromEntries(Object.entries(record).sort(([a], [b])=>a < b ? -1 : 1));
|
|
3348
|
+
}
|
|
3349
|
+
/**
|
|
3350
|
+
* Assembles `package.json` from the answers and whatever the selected features contribute.
|
|
3351
|
+
*
|
|
3352
|
+
* Dependencies are sorted by name and scripts are left in contribution order (the base ones, then each
|
|
3353
|
+
* feature's, in the order features were selected) — so two runs with the same answers produce byte-
|
|
3354
|
+
* identical output, which is what makes the generated manifest snapshot-testable.
|
|
3355
|
+
*/ function buildPackageJson(answers, features, pm) {
|
|
3356
|
+
const scripts = {
|
|
3357
|
+
...BASE_SCRIPTS
|
|
3358
|
+
};
|
|
3359
|
+
const dependencies = {
|
|
3360
|
+
'@rshono/core': RSHONO_RANGE,
|
|
3361
|
+
hono: FRAMEWORK_DEPS.hono,
|
|
3362
|
+
react: FRAMEWORK_DEPS.react,
|
|
3363
|
+
'react-dom': FRAMEWORK_DEPS["react-dom"]
|
|
3364
|
+
};
|
|
3365
|
+
const devDependencies = {
|
|
3366
|
+
'@types/node': FRAMEWORK_DEPS["@types/node"],
|
|
3367
|
+
'@types/react': FRAMEWORK_DEPS["@types/react"],
|
|
3368
|
+
typescript: FRAMEWORK_DEPS.typescript
|
|
3369
|
+
};
|
|
3370
|
+
for (const feature of features){
|
|
3371
|
+
Object.assign(scripts, feature.scripts);
|
|
3372
|
+
Object.assign(dependencies, feature.dependencies);
|
|
3373
|
+
Object.assign(devDependencies, feature.devDependencies);
|
|
3374
|
+
}
|
|
3375
|
+
const manifest = {
|
|
3376
|
+
name: answers.packageName,
|
|
3377
|
+
version: '0.1.0',
|
|
3378
|
+
private: true,
|
|
3379
|
+
type: 'module',
|
|
3380
|
+
// The floor the framework declares. Stated here too so a CI image or a contributor on an older
|
|
3381
|
+
// Node finds out from their package manager rather than from a stack trace.
|
|
3382
|
+
engines: {
|
|
3383
|
+
node: '>=22.1.0'
|
|
3384
|
+
},
|
|
3385
|
+
scripts,
|
|
3386
|
+
dependencies: sorted(dependencies),
|
|
3387
|
+
devDependencies: sorted(devDependencies)
|
|
3388
|
+
};
|
|
3389
|
+
// Only when the environment told us the exact version: `packageManager` pins the tool for Corepack,
|
|
3390
|
+
// and a guess at the version is worse than leaving the field out.
|
|
3391
|
+
if (pm.version) manifest.packageManager = `${pm.name}@${pm.version}`;
|
|
3392
|
+
const ordered = Object.fromEntries(FIELD_ORDER.filter((field)=>field in manifest).map((field)=>[
|
|
3393
|
+
field,
|
|
3394
|
+
manifest[field]
|
|
3395
|
+
]));
|
|
3396
|
+
return `${JSON.stringify(ordered, null, 2)}\n`;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
;// CONCATENATED MODULE: ./src/render.ts
|
|
3400
|
+
|
|
3401
|
+
const TOKEN_PATTERN = /__[A-Z][A-Z\d_]*__/g;
|
|
3402
|
+
function tokensFor(answers, pm) {
|
|
3403
|
+
return {
|
|
3404
|
+
__PROJECT_NAME__: answers.packageName,
|
|
3405
|
+
__DEPLOY_TARGET__: answers.deploy,
|
|
3406
|
+
__DEPLOY_HINT__: deployHint(answers.deploy),
|
|
3407
|
+
__PM__: pm.name,
|
|
3408
|
+
__PM_RUN__: pm.run
|
|
3409
|
+
};
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* Substitutes tokens, and throws on one it doesn't know — a typo in a template would otherwise ship a
|
|
3413
|
+
* literal `__PORJECT_NAME__` into somebody's new app, which no test of the generator's logic would
|
|
3414
|
+
* catch.
|
|
3415
|
+
*/ function render(contents, tokens, source) {
|
|
3416
|
+
return contents.replace(TOKEN_PATTERN, (token)=>{
|
|
3417
|
+
const value = tokens[token];
|
|
3418
|
+
if (value === undefined) throw new Error(`[create-rshono] ${source} uses unknown template token ${token}`);
|
|
3419
|
+
return value;
|
|
3420
|
+
});
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
;// CONCATENATED MODULE: ./src/plan.ts
|
|
3424
|
+
|
|
3425
|
+
|
|
3426
|
+
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
/** `dist/cli.mjs` and `templates/` are siblings in the published package, as they are in the repo. */ const TEMPLATES_DIR = external_node_path_join(__rspack_import_meta_dirname__, '..', 'templates');
|
|
3430
|
+
function readTemplateDir(dir) {
|
|
3431
|
+
const files = new Map();
|
|
3432
|
+
for (const entry of external_node_fs_readdirSync(dir, {
|
|
3433
|
+
recursive: true,
|
|
3434
|
+
withFileTypes: true
|
|
3435
|
+
})){
|
|
3436
|
+
if (!entry.isFile()) continue;
|
|
3437
|
+
const absolute = external_node_path_join(entry.parentPath, entry.name);
|
|
3438
|
+
const relative = absolute.slice(dir.length + 1).split(sep).join(posix.sep);
|
|
3439
|
+
files.set(relative, readFileSync(absolute, 'utf8'));
|
|
3440
|
+
}
|
|
3441
|
+
return files;
|
|
3442
|
+
}
|
|
3443
|
+
/**
|
|
3444
|
+
* `_gitignore` → `.gitignore`, and so on for every dotfile.
|
|
3445
|
+
*
|
|
3446
|
+
* npm strips a literal `.gitignore` out of a published tarball, so a template cannot simply contain
|
|
3447
|
+
* one — the file would exist in the repo, pass every local test, and be missing from the package
|
|
3448
|
+
* everybody actually installs. Naming them with an underscore and renaming here is the long-standing
|
|
3449
|
+
* fix. It applies to the basename only, so `src/lib/_x.ts` is a dotfile but `templates/_x/y.ts` is not.
|
|
3450
|
+
*/ function undotted(path) {
|
|
3451
|
+
const segments = path.split(posix.sep);
|
|
3452
|
+
const name = segments.pop();
|
|
3453
|
+
return [
|
|
3454
|
+
...segments,
|
|
3455
|
+
name.startsWith('_') ? `.${name.slice(1)}` : name
|
|
3456
|
+
].join(posix.sep);
|
|
3457
|
+
}
|
|
3458
|
+
/**
|
|
3459
|
+
* A feature's `.gitignore` lines, appended under a heading naming it — so somebody reading the file six
|
|
3460
|
+
* months later can tell why `.wrangler/` is in there.
|
|
3461
|
+
*/ function appendGitignore(existing, features) {
|
|
3462
|
+
const additions = features.filter((feature)=>feature.gitignore?.length);
|
|
3463
|
+
if (additions.length === 0) return existing;
|
|
3464
|
+
const blocks = additions.map((feature)=>`\n# ${feature.id}\n${feature.gitignore.join('\n')}\n`);
|
|
3465
|
+
return existing + blocks.join('');
|
|
3466
|
+
}
|
|
3467
|
+
/**
|
|
3468
|
+
* Turns answers into the exact set of files to write, without touching the target directory — the
|
|
3469
|
+
* decisions and the I/O are separated so the whole matrix of answers can be asserted on in a test, and
|
|
3470
|
+
* so `--dry-run` is the same code path minus the last step.
|
|
3471
|
+
*/ function plan_plan(answers, pm) {
|
|
3472
|
+
const features = selectFeatures(answers);
|
|
3473
|
+
const tokens = tokensFor(answers, pm);
|
|
3474
|
+
const raw = readTemplateDir(external_node_path_join(TEMPLATES_DIR, 'base'));
|
|
3475
|
+
for (const feature of features){
|
|
3476
|
+
for (const overlay of feature.overlays ?? []){
|
|
3477
|
+
for (const [path, contents] of readTemplateDir(external_node_path_join(TEMPLATES_DIR, overlay))){
|
|
3478
|
+
raw.set(path, contents);
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
const files = new Map();
|
|
3483
|
+
for (const [path, contents] of raw){
|
|
3484
|
+
files.set(undotted(path), render(contents, tokens, path));
|
|
3485
|
+
}
|
|
3486
|
+
const gitignore = files.get('.gitignore');
|
|
3487
|
+
if (gitignore) files.set('.gitignore', appendGitignore(gitignore, features));
|
|
3488
|
+
files.set('package.json', buildPackageJson(answers, features, pm));
|
|
3489
|
+
return {
|
|
3490
|
+
// Sorted, so both the write order and a test's snapshot are stable.
|
|
3491
|
+
files: new Map([
|
|
3492
|
+
...files
|
|
3493
|
+
].sort(([a], [b])=>a < b ? -1 : 1)),
|
|
3494
|
+
features,
|
|
3495
|
+
notes: features.flatMap((feature)=>feature.notes ?? [])
|
|
3496
|
+
};
|
|
3497
|
+
}
|
|
3498
|
+
|
|
3499
|
+
;// CONCATENATED MODULE: ./src/pm.ts
|
|
3500
|
+
|
|
3501
|
+
const INSTALL = {
|
|
3502
|
+
npm: [
|
|
3503
|
+
'install'
|
|
3504
|
+
],
|
|
3505
|
+
pnpm: [
|
|
3506
|
+
'install'
|
|
3507
|
+
],
|
|
3508
|
+
yarn: [],
|
|
3509
|
+
bun: [
|
|
3510
|
+
'install'
|
|
3511
|
+
]
|
|
3512
|
+
};
|
|
3513
|
+
const RUN = {
|
|
3514
|
+
npm: 'npm run',
|
|
3515
|
+
pnpm: 'pnpm',
|
|
3516
|
+
yarn: 'yarn',
|
|
3517
|
+
bun: 'bun'
|
|
3518
|
+
};
|
|
3519
|
+
function isKnown(name) {
|
|
3520
|
+
return name === 'npm' || name === 'pnpm' || name === 'yarn' || name === 'bun';
|
|
3521
|
+
}
|
|
3522
|
+
function packageManager(name, version) {
|
|
3523
|
+
return {
|
|
3524
|
+
name,
|
|
3525
|
+
version,
|
|
3526
|
+
install: INSTALL[name],
|
|
3527
|
+
run: RUN[name]
|
|
3528
|
+
};
|
|
3529
|
+
}
|
|
3530
|
+
/**
|
|
3531
|
+
* Which package manager invoked us. Every one of them sets `npm_config_user_agent` for the process it
|
|
3532
|
+
* spawns — `pnpm/11.9.0 npm/? node/v22.14.0 darwin arm64` — so `pnpm create @rshono` scaffolds a pnpm
|
|
3533
|
+
* project without asking, and the exact version comes along for the `packageManager` field.
|
|
3534
|
+
*
|
|
3535
|
+
* Falls back to npm, which is also what a bare `node bin/create-rshono.mjs` gets.
|
|
3536
|
+
*/ function detectPackageManager(userAgent = process.env.npm_config_user_agent) {
|
|
3537
|
+
const [spec] = (userAgent ?? '').split(' ');
|
|
3538
|
+
const [name, version] = (spec ?? '').split('/');
|
|
3539
|
+
if (name && isKnown(name)) return packageManager(name, version && /^\d+\.\d+\.\d+/.test(version) ? version : undefined);
|
|
3540
|
+
return packageManager('npm');
|
|
3541
|
+
}
|
|
3542
|
+
/**
|
|
3543
|
+
* Runs the install, streaming its output. `shell: true` on Windows because npm, pnpm and yarn are all
|
|
3544
|
+
* `.cmd` shims there, which `spawn` cannot execute directly — and with a shell involved the arguments
|
|
3545
|
+
* are all fixed strings from the tables above, never anything the user typed.
|
|
3546
|
+
*/ function runInstall(pm, cwd) {
|
|
3547
|
+
return run(pm, pm.install, cwd);
|
|
3548
|
+
}
|
|
3549
|
+
/** `<pm> run <script>` — the one form every package manager accepts, Yarn v1 included. */ function runScript(pm, script, cwd) {
|
|
3550
|
+
return run(pm, [
|
|
3551
|
+
'run',
|
|
3552
|
+
script
|
|
3553
|
+
], cwd);
|
|
3554
|
+
}
|
|
3555
|
+
function run(pm, args, cwd) {
|
|
3556
|
+
const result = spawnSync(pm.name, args, {
|
|
3557
|
+
cwd,
|
|
3558
|
+
stdio: 'inherit',
|
|
3559
|
+
shell: process.platform === 'win32'
|
|
3560
|
+
});
|
|
3561
|
+
return result.status === 0;
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
;// CONCATENATED MODULE: ./src/ui.ts
|
|
3565
|
+
|
|
3566
|
+
|
|
3567
|
+
/**
|
|
3568
|
+
* What to do next, in the order to do it — the last thing the user reads, and for most people the only
|
|
3569
|
+
* documentation they will read today. `installed` decides whether the install step is still theirs.
|
|
3570
|
+
*/ function nextSteps(answers, plan, pm, options) {
|
|
3571
|
+
const steps = [];
|
|
3572
|
+
if (options.directory !== '.') steps.push(`cd ${options.directory}`);
|
|
3573
|
+
if (!options.installed) steps.push(`${pm.name}${pm.install.length > 0 ? ` ${pm.install.join(' ')}` : ''}`);
|
|
3574
|
+
steps.push(`${pm.run} dev`);
|
|
3575
|
+
const lines = [
|
|
3576
|
+
steps.join('\n')
|
|
3577
|
+
];
|
|
3578
|
+
lines.push(`\nThen ${pm.run} build, and ${deployHint(answers.deploy)}.`);
|
|
3579
|
+
if (plan.notes.length > 0) lines.push(`\n${plan.notes.join('\n')}`);
|
|
3580
|
+
return lines.join('\n');
|
|
3581
|
+
}
|
|
3582
|
+
/** The one-line summary of what was chosen, for the run that answered everything from flags. */ function summary(answers) {
|
|
3583
|
+
const quality = [
|
|
3584
|
+
answers.formatter,
|
|
3585
|
+
answers.linter === answers.formatter ? null : answers.linter
|
|
3586
|
+
].filter((part)=>part && part !== 'none');
|
|
3587
|
+
return [
|
|
3588
|
+
`deploy: ${answers.deploy}`,
|
|
3589
|
+
`styling: ${answers.styling === 'tailwind' ? 'Tailwind CSS' : 'plain CSS'}`,
|
|
3590
|
+
`quality: ${quality.length > 0 ? quality.join(' + ') : 'none'}`
|
|
3591
|
+
].join(' · ');
|
|
3592
|
+
}
|
|
3593
|
+
/** A cancelled prompt ends the run, rather than falling through to a default the user did not pick. */ function unwrap(value) {
|
|
3594
|
+
if (dist_isCancel(value)) {
|
|
3595
|
+
cancel('Cancelled — nothing was written.');
|
|
3596
|
+
process.exit(130);
|
|
3597
|
+
}
|
|
3598
|
+
return value;
|
|
3599
|
+
}
|
|
3600
|
+
|
|
3601
|
+
;// CONCATENATED MODULE: ./src/write.ts
|
|
3602
|
+
|
|
3603
|
+
|
|
3604
|
+
/**
|
|
3605
|
+
* Files that do not make a directory "occupied". A user who ran `git init` or opened the folder in an
|
|
3606
|
+
* editor before scaffolding has not put anything in it that we would overwrite.
|
|
3607
|
+
*/ const IGNORED_ENTRIES = new Set([
|
|
3608
|
+
'.git',
|
|
3609
|
+
'.DS_Store',
|
|
3610
|
+
'.idea',
|
|
3611
|
+
'.vscode',
|
|
3612
|
+
'Thumbs.db'
|
|
3613
|
+
]);
|
|
3614
|
+
function inspectTarget(dir) {
|
|
3615
|
+
if (!external_node_fs_existsSync(dir)) return {
|
|
3616
|
+
exists: false,
|
|
3617
|
+
conflicts: []
|
|
3618
|
+
};
|
|
3619
|
+
return {
|
|
3620
|
+
exists: true,
|
|
3621
|
+
conflicts: external_node_fs_readdirSync(dir).filter((entry)=>!IGNORED_ENTRIES.has(entry))
|
|
3622
|
+
};
|
|
3623
|
+
}
|
|
3624
|
+
/**
|
|
3625
|
+
* Writes the plan. Directories are created as needed, and files are written with the plan's own
|
|
3626
|
+
* ordering so a failure part-way through leaves something a person can make sense of.
|
|
3627
|
+
*/ function writePlan(plan, targetDir) {
|
|
3628
|
+
mkdirSync(targetDir, {
|
|
3629
|
+
recursive: true
|
|
3630
|
+
});
|
|
3631
|
+
for (const [path, contents] of plan.files){
|
|
3632
|
+
const absolute = external_node_path_join(targetDir, path);
|
|
3633
|
+
mkdirSync(external_node_path_dirname(absolute), {
|
|
3634
|
+
recursive: true
|
|
3635
|
+
});
|
|
3636
|
+
writeFileSync(absolute, contents);
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
;// CONCATENATED MODULE: ./src/cli.ts
|
|
3641
|
+
|
|
3642
|
+
|
|
3643
|
+
|
|
3644
|
+
|
|
3645
|
+
|
|
3646
|
+
|
|
3647
|
+
|
|
3648
|
+
|
|
3649
|
+
|
|
3650
|
+
const DEFAULT_DIRECTORY = 'my-rshono-app';
|
|
3651
|
+
const HELP = `create-rshono — scaffold a new rshono app
|
|
3652
|
+
|
|
3653
|
+
Usage:
|
|
3654
|
+
npm create @rshono@latest [directory] [options]
|
|
3655
|
+
|
|
3656
|
+
Options:
|
|
3657
|
+
-y, --yes accept the default for every question not given as a flag
|
|
3658
|
+
-d, --deploy <target> ${DEPLOY_TARGET_NAMES.join(' | ')}
|
|
3659
|
+
--tailwind Tailwind CSS (--no-tailwind for plain CSS)
|
|
3660
|
+
--quality <preset> ${QUALITY_PRESETS.map((preset)=>preset.id).join(' | ')}
|
|
3661
|
+
--formatter <name> prettier | biome | oxfmt | none (overrides --quality)
|
|
3662
|
+
--linter <name> oxlint | biome | none (overrides --quality)
|
|
3663
|
+
--pm <name> npm | pnpm | yarn | bun (default: whatever ran this)
|
|
3664
|
+
--no-install write the files and stop
|
|
3665
|
+
--no-git do not initialize a repository
|
|
3666
|
+
--force scaffold into a directory that is not empty
|
|
3667
|
+
--dry-run list the files that would be written, and write nothing
|
|
3668
|
+
-h, --help show this help
|
|
3669
|
+
-v, --version print the version
|
|
3670
|
+
|
|
3671
|
+
Every question can be answered by a flag, and a non-interactive terminal implies --yes — so one command
|
|
3672
|
+
scaffolds without prompting:
|
|
3673
|
+
|
|
3674
|
+
npm create @rshono@latest my-app -y --deploy cloudflare --tailwind --quality biome
|
|
3675
|
+
`;
|
|
3676
|
+
function fail(message) {
|
|
3677
|
+
log.error(message);
|
|
3678
|
+
process.exit(1);
|
|
3679
|
+
}
|
|
3680
|
+
/** A flag's value, checked against what the option accepts — a typo should not become a silent default. */ function oneOf(value, allowed, flag) {
|
|
3681
|
+
if (value === undefined) return undefined;
|
|
3682
|
+
if (!allowed.includes(value)) fail(`--${flag} must be one of: ${allowed.join(', ')} (got "${value}")`);
|
|
3683
|
+
return value;
|
|
3684
|
+
}
|
|
3685
|
+
/** `--x` / `--no-x` pairs, since `parseArgs` has no notion of a negatable boolean. */ function tristate(on, off, flag) {
|
|
3686
|
+
if (on && off) fail(`--${flag} and --no-${flag} contradict each other.`);
|
|
3687
|
+
if (on) return true;
|
|
3688
|
+
if (off) return false;
|
|
3689
|
+
return undefined;
|
|
3690
|
+
}
|
|
3691
|
+
async function main() {
|
|
3692
|
+
const { values, positionals } = parseArgs({
|
|
3693
|
+
options: {
|
|
3694
|
+
yes: {
|
|
3695
|
+
type: 'boolean',
|
|
3696
|
+
short: 'y'
|
|
3697
|
+
},
|
|
3698
|
+
deploy: {
|
|
3699
|
+
type: 'string',
|
|
3700
|
+
short: 'd'
|
|
3701
|
+
},
|
|
3702
|
+
tailwind: {
|
|
3703
|
+
type: 'boolean'
|
|
3704
|
+
},
|
|
3705
|
+
'no-tailwind': {
|
|
3706
|
+
type: 'boolean'
|
|
3707
|
+
},
|
|
3708
|
+
quality: {
|
|
3709
|
+
type: 'string'
|
|
3710
|
+
},
|
|
3711
|
+
formatter: {
|
|
3712
|
+
type: 'string'
|
|
3713
|
+
},
|
|
3714
|
+
linter: {
|
|
3715
|
+
type: 'string'
|
|
3716
|
+
},
|
|
3717
|
+
pm: {
|
|
3718
|
+
type: 'string'
|
|
3719
|
+
},
|
|
3720
|
+
install: {
|
|
3721
|
+
type: 'boolean'
|
|
3722
|
+
},
|
|
3723
|
+
'no-install': {
|
|
3724
|
+
type: 'boolean'
|
|
3725
|
+
},
|
|
3726
|
+
git: {
|
|
3727
|
+
type: 'boolean'
|
|
3728
|
+
},
|
|
3729
|
+
'no-git': {
|
|
3730
|
+
type: 'boolean'
|
|
3731
|
+
},
|
|
3732
|
+
force: {
|
|
3733
|
+
type: 'boolean'
|
|
3734
|
+
},
|
|
3735
|
+
'dry-run': {
|
|
3736
|
+
type: 'boolean'
|
|
3737
|
+
},
|
|
3738
|
+
help: {
|
|
3739
|
+
type: 'boolean',
|
|
3740
|
+
short: 'h'
|
|
3741
|
+
},
|
|
3742
|
+
version: {
|
|
3743
|
+
type: 'boolean',
|
|
3744
|
+
short: 'v'
|
|
3745
|
+
}
|
|
3746
|
+
},
|
|
3747
|
+
allowPositionals: true
|
|
3748
|
+
});
|
|
3749
|
+
if (values.help) return console.log(HELP);
|
|
3750
|
+
if (values.version) return console.log("1.0.0-rc.0");
|
|
3751
|
+
// A pipe, a CI job or an agent gets the defaults rather than a prompt nothing can answer.
|
|
3752
|
+
const interactive = Boolean(process.stdout.isTTY) && !values.yes;
|
|
3753
|
+
const pmFlag = oneOf(values.pm, [
|
|
3754
|
+
'npm',
|
|
3755
|
+
'pnpm',
|
|
3756
|
+
'yarn',
|
|
3757
|
+
'bun'
|
|
3758
|
+
], 'pm');
|
|
3759
|
+
const pm = pmFlag ? packageManager(pmFlag) : detectPackageManager();
|
|
3760
|
+
const deployFlag = oneOf(values.deploy, DEPLOY_TARGET_NAMES, 'deploy');
|
|
3761
|
+
const formatterFlag = oneOf(values.formatter, [
|
|
3762
|
+
'prettier',
|
|
3763
|
+
'biome',
|
|
3764
|
+
'oxfmt',
|
|
3765
|
+
'none'
|
|
3766
|
+
], 'formatter');
|
|
3767
|
+
const linterFlag = oneOf(values.linter, [
|
|
3768
|
+
'oxlint',
|
|
3769
|
+
'biome',
|
|
3770
|
+
'none'
|
|
3771
|
+
], 'linter');
|
|
3772
|
+
const qualityFlag = oneOf(values.quality, QUALITY_PRESETS.map((preset)=>preset.id), 'quality');
|
|
3773
|
+
const tailwindFlag = tristate(values.tailwind, values['no-tailwind'], 'tailwind');
|
|
3774
|
+
const installFlag = tristate(values.install, values['no-install'], 'install');
|
|
3775
|
+
const gitFlag = tristate(values.git, values['no-git'], 'git');
|
|
3776
|
+
intro(`create-rshono · rshono ${"1.0.0-rc.0"}`);
|
|
3777
|
+
// ── Where ───────────────────────────────────────────────────────────────────────────────────────
|
|
3778
|
+
let directory = positionals[0];
|
|
3779
|
+
if (!directory) {
|
|
3780
|
+
directory = interactive ? unwrap(await dist_text({
|
|
3781
|
+
message: 'Where should the app go?',
|
|
3782
|
+
placeholder: DEFAULT_DIRECTORY,
|
|
3783
|
+
defaultValue: DEFAULT_DIRECTORY,
|
|
3784
|
+
validate: (value)=>toPackageName(value || DEFAULT_DIRECTORY) ? undefined : 'That leaves nothing usable as a package name.'
|
|
3785
|
+
})) : DEFAULT_DIRECTORY;
|
|
3786
|
+
}
|
|
3787
|
+
const targetDir = resolve(process.cwd(), directory);
|
|
3788
|
+
const packageName = toPackageName(directory === '.' ? basename(targetDir) : directory);
|
|
3789
|
+
if (!packageName || !isValidPackageName(packageName)) fail(`"${directory}" does not give a usable npm package name.`);
|
|
3790
|
+
const conflicts = inspectTarget(targetDir).conflicts;
|
|
3791
|
+
if (conflicts.length > 0 && !values.force) {
|
|
3792
|
+
const where = directory === '.' ? 'this directory' : `"${directory}"`;
|
|
3793
|
+
const listed = `${conflicts.slice(0, 3).join(', ')}${conflicts.length > 3 ? ', …' : ''}`;
|
|
3794
|
+
if (!interactive) fail(`${where} is not empty (${listed}) — pass --force to scaffold into it anyway.`);
|
|
3795
|
+
const proceed = unwrap(await dist_confirm({
|
|
3796
|
+
message: `${where} is not empty (${listed}). Write into it anyway?`,
|
|
3797
|
+
initialValue: false
|
|
3798
|
+
}));
|
|
3799
|
+
if (!proceed) {
|
|
3800
|
+
cancel('Nothing was written.');
|
|
3801
|
+
process.exit(0);
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
// ── What ────────────────────────────────────────────────────────────────────────────────────────
|
|
3805
|
+
let deploy = deployFlag ?? 'node';
|
|
3806
|
+
if (!deployFlag && interactive) {
|
|
3807
|
+
deploy = unwrap(await dist_select({
|
|
3808
|
+
message: 'Where will it be deployed?',
|
|
3809
|
+
initialValue: deploy,
|
|
3810
|
+
options: DEPLOY_TARGET_NAMES.map((name)=>({
|
|
3811
|
+
value: name,
|
|
3812
|
+
label: name
|
|
3813
|
+
}))
|
|
3814
|
+
}));
|
|
3815
|
+
}
|
|
3816
|
+
let styling = tailwindFlag === undefined ? 'css' : tailwindFlag ? 'tailwind' : 'css';
|
|
3817
|
+
if (tailwindFlag === undefined && interactive) {
|
|
3818
|
+
styling = unwrap(await dist_select({
|
|
3819
|
+
message: 'Styling?',
|
|
3820
|
+
initialValue: styling,
|
|
3821
|
+
options: [
|
|
3822
|
+
{
|
|
3823
|
+
value: 'css',
|
|
3824
|
+
label: 'Plain CSS',
|
|
3825
|
+
hint: 'compiled natively, no PostCSS'
|
|
3826
|
+
},
|
|
3827
|
+
{
|
|
3828
|
+
value: 'tailwind',
|
|
3829
|
+
label: 'Tailwind CSS',
|
|
3830
|
+
hint: 'adds postcss.config.mjs'
|
|
3831
|
+
}
|
|
3832
|
+
]
|
|
3833
|
+
}));
|
|
3834
|
+
}
|
|
3835
|
+
/*
|
|
3836
|
+
* The preset asks one question instead of two. The two axes stay independent underneath — a
|
|
3837
|
+
* `--formatter` or `--linter` flag addresses either on its own, and skips the question entirely.
|
|
3838
|
+
*/ let preset = QUALITY_PRESETS.find((candidate)=>candidate.id === qualityFlag);
|
|
3839
|
+
if (!preset && !formatterFlag && !linterFlag) {
|
|
3840
|
+
const fallback = QUALITY_PRESETS["0"];
|
|
3841
|
+
if (interactive) {
|
|
3842
|
+
const id = unwrap(await dist_select({
|
|
3843
|
+
message: 'Formatting and linting?',
|
|
3844
|
+
initialValue: fallback.id,
|
|
3845
|
+
options: QUALITY_PRESETS.map((option)=>({
|
|
3846
|
+
value: option.id,
|
|
3847
|
+
label: option.label,
|
|
3848
|
+
hint: option.hint
|
|
3849
|
+
}))
|
|
3850
|
+
}));
|
|
3851
|
+
preset = QUALITY_PRESETS.find((candidate)=>candidate.id === id);
|
|
3852
|
+
} else {
|
|
3853
|
+
preset = fallback;
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
const formatter = formatterFlag ?? preset?.formatter ?? 'none';
|
|
3857
|
+
const linter = linterFlag ?? preset?.linter ?? 'none';
|
|
3858
|
+
// ── How ─────────────────────────────────────────────────────────────────────────────────────────
|
|
3859
|
+
let install = installFlag ?? true;
|
|
3860
|
+
if (installFlag === undefined && interactive) {
|
|
3861
|
+
install = unwrap(await dist_confirm({
|
|
3862
|
+
message: `Install dependencies with ${pm.name}?`,
|
|
3863
|
+
initialValue: true
|
|
3864
|
+
}));
|
|
3865
|
+
}
|
|
3866
|
+
let git = gitFlag ?? !isInsideRepo(process.cwd());
|
|
3867
|
+
if (gitFlag === undefined && interactive) {
|
|
3868
|
+
const nested = isInsideRepo(process.cwd());
|
|
3869
|
+
git = unwrap(await dist_confirm({
|
|
3870
|
+
message: nested ? 'Initialize a git repository? (this is already inside one)' : 'Initialize a git repository?',
|
|
3871
|
+
initialValue: !nested
|
|
3872
|
+
}));
|
|
3873
|
+
}
|
|
3874
|
+
const answers = {
|
|
3875
|
+
packageName,
|
|
3876
|
+
targetDir,
|
|
3877
|
+
deploy,
|
|
3878
|
+
styling,
|
|
3879
|
+
formatter,
|
|
3880
|
+
linter,
|
|
3881
|
+
packageManager: pm.name,
|
|
3882
|
+
install,
|
|
3883
|
+
git
|
|
3884
|
+
};
|
|
3885
|
+
// ── Plan, then write ────────────────────────────────────────────────────────────────────────────
|
|
3886
|
+
const plan = plan_plan(answers, pm);
|
|
3887
|
+
if (values['dry-run']) {
|
|
3888
|
+
note([
|
|
3889
|
+
...plan.files.keys()
|
|
3890
|
+
].join('\n'), `${plan.files.size} files — ${summary(answers)}`);
|
|
3891
|
+
outro('Dry run: nothing was written.');
|
|
3892
|
+
return;
|
|
3893
|
+
}
|
|
3894
|
+
writePlan(plan, targetDir);
|
|
3895
|
+
log.success(`Created ${plan.files.size} files in ${external_node_path_relative(process.cwd(), targetDir) || '.'} · ${summary(answers)}`);
|
|
3896
|
+
let installed = false;
|
|
3897
|
+
if (install) {
|
|
3898
|
+
log.step(`Installing dependencies with ${pm.name}…`);
|
|
3899
|
+
installed = runInstall(pm, targetDir);
|
|
3900
|
+
if (!installed) log.warn(`${pm.name} install failed — run it yourself and the rest will work.`);
|
|
3901
|
+
}
|
|
3902
|
+
/*
|
|
3903
|
+
* Format the scaffold with the tool it was scaffolded with, so a fresh project passes its own
|
|
3904
|
+
* `format:check` instead of reporting a diff nobody made. Needs the install, since the formatter is a
|
|
3905
|
+
* devDependency — hence the skip, rather than a failure, when there is none.
|
|
3906
|
+
*/ if (installed && formatter !== 'none') {
|
|
3907
|
+
if (!runScript(pm, 'format', targetDir)) log.warn(`\`${pm.run} format\` failed — the files are fine, the formatter is not.`);
|
|
3908
|
+
}
|
|
3909
|
+
if (git) {
|
|
3910
|
+
if (!hasGit(targetDir)) {
|
|
3911
|
+
log.warn('git was not found on PATH — skipped.');
|
|
3912
|
+
} else {
|
|
3913
|
+
const result = initRepo(targetDir);
|
|
3914
|
+
if (result === 'initialized') log.warn('Repository initialized, but the first commit failed — set git user.name and user.email.');
|
|
3915
|
+
if (result === 'failed') log.warn('git init failed — skipped.');
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
note(nextSteps(answers, plan, pm, {
|
|
3919
|
+
directory,
|
|
3920
|
+
installed
|
|
3921
|
+
}), 'Next');
|
|
3922
|
+
outro('Happy building.');
|
|
3923
|
+
}
|
|
3924
|
+
main().catch((error)=>{
|
|
3925
|
+
log.error(error instanceof Error ? error.message : String(error));
|
|
3926
|
+
process.exit(1);
|
|
3927
|
+
});
|
|
3928
|
+
|
|
3929
|
+
})();
|
|
3930
|
+
|