simple-scaffold 2.3.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -13
- package/before-write.d.ts +7 -0
- package/cmd.js +214 -260
- package/cmd.js.map +1 -1
- package/colors.d.ts +32 -0
- package/config.d.ts +12 -10
- package/file.d.ts +30 -11
- package/fs-utils.d.ts +9 -0
- package/index.js +12 -23
- package/index.js.map +1 -1
- package/logger.d.ts +7 -1
- package/package.json +22 -20
- package/parser.d.ts +1 -1
- package/path-utils.d.ts +6 -0
- package/prompts.d.ts +27 -0
- package/scaffold-Ce-rIwy9.js +2636 -0
- package/scaffold-Ce-rIwy9.js.map +1 -0
- package/types.d.ts +38 -2
- package/utils.d.ts +4 -24
- package/config.js +0 -242
- package/config.js.map +0 -1
- package/file.js +0 -169
- package/file.js.map +0 -1
- package/git.js +0 -71
- package/git.js.map +0 -1
- package/logger.js +0 -58
- package/logger.js.map +0 -1
- package/parser.js +0 -100
- package/parser.js.map +0 -1
- package/scaffold.js +0 -139
- package/scaffold.js.map +0 -1
- package/types.js +0 -31
- package/types.js.map +0 -1
- package/utils.js +0 -61
- package/utils.js.map +0 -1
|
@@ -0,0 +1,2636 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let node_path = require("node:path");
|
|
25
|
+
node_path = __toESM(node_path);
|
|
26
|
+
let node_os = require("node:os");
|
|
27
|
+
node_os = __toESM(node_os);
|
|
28
|
+
let node_fs_promises = require("node:fs/promises");
|
|
29
|
+
node_fs_promises = __toESM(node_fs_promises);
|
|
30
|
+
let glob = require("glob");
|
|
31
|
+
let handlebars = require("handlebars");
|
|
32
|
+
handlebars = __toESM(handlebars);
|
|
33
|
+
let date_fns = require("date-fns");
|
|
34
|
+
let node_constants = require("node:constants");
|
|
35
|
+
let node_child_process = require("node:child_process");
|
|
36
|
+
let node_util = require("node:util");
|
|
37
|
+
//#region src/colors.ts
|
|
38
|
+
/** ANSI color code mapping for terminal output. */
|
|
39
|
+
var colorMap = {
|
|
40
|
+
reset: 0,
|
|
41
|
+
dim: 2,
|
|
42
|
+
bold: 1,
|
|
43
|
+
italic: 3,
|
|
44
|
+
underline: 4,
|
|
45
|
+
red: 31,
|
|
46
|
+
green: 32,
|
|
47
|
+
yellow: 33,
|
|
48
|
+
blue: 34,
|
|
49
|
+
magenta: 35,
|
|
50
|
+
cyan: 36,
|
|
51
|
+
white: 37,
|
|
52
|
+
gray: 90
|
|
53
|
+
};
|
|
54
|
+
function _colorize(text, color) {
|
|
55
|
+
const c = colorMap[color];
|
|
56
|
+
let r = 0;
|
|
57
|
+
if (c > 1 && c < 30) r = c + 20;
|
|
58
|
+
else if (c === 1) r = 23;
|
|
59
|
+
else r = 0;
|
|
60
|
+
return `\x1b[${c}m${text}\x1b[${r}m`;
|
|
61
|
+
}
|
|
62
|
+
function isTemplateStringArray(template) {
|
|
63
|
+
return Array.isArray(template) && typeof template[0] === "string";
|
|
64
|
+
}
|
|
65
|
+
var createColorize = (color) => (template, ...params) => {
|
|
66
|
+
return isTemplateStringArray(template) ? _colorize(template.reduce((acc, str, i) => acc + str + (params[i] ?? ""), ""), color) : _colorize(String(template), color);
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Colorize text for terminal output.
|
|
70
|
+
*
|
|
71
|
+
* Can be used as a function: `colorize("text", "red")`
|
|
72
|
+
* Or via named helpers: `colorize.red("text")` / `colorize.red\`template\``
|
|
73
|
+
*/
|
|
74
|
+
var colorize = Object.assign(_colorize, Object.entries(colorMap).reduce((acc, [key]) => {
|
|
75
|
+
acc[key] = createColorize(key);
|
|
76
|
+
return acc;
|
|
77
|
+
}, {}));
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/utils.ts
|
|
80
|
+
/** Throws the error if non-null, no-ops otherwise. */
|
|
81
|
+
function handleErr(err) {
|
|
82
|
+
if (err) throw err;
|
|
83
|
+
}
|
|
84
|
+
/** Resolves a value that may be either a static value or a function that produces one. */
|
|
85
|
+
function resolve(resolver, arg) {
|
|
86
|
+
return typeof resolver === "function" ? resolver(arg) : resolver;
|
|
87
|
+
}
|
|
88
|
+
/** Wraps a static value in a resolver function. If already a function, returns as-is. */
|
|
89
|
+
function wrapNoopResolver(value) {
|
|
90
|
+
if (typeof value === "function") return value;
|
|
91
|
+
return (_) => value;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/types.ts
|
|
95
|
+
/**
|
|
96
|
+
* The amount of information to log when generating scaffold.
|
|
97
|
+
* When not `none`, the selected level will be the lowest level included.
|
|
98
|
+
*
|
|
99
|
+
* For example, level `info` will include `info`, `warning` and `error`, but not `debug`; and `warning` will only
|
|
100
|
+
* show `warning` and `error`, but not `info` or `debug`.
|
|
101
|
+
*
|
|
102
|
+
* @default `info`
|
|
103
|
+
*
|
|
104
|
+
* @category Logging (const)
|
|
105
|
+
*/
|
|
106
|
+
var LogLevel = {
|
|
107
|
+
none: "none",
|
|
108
|
+
debug: "debug",
|
|
109
|
+
info: "info",
|
|
110
|
+
warning: "warning",
|
|
111
|
+
error: "error"
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region __vite-browser-external
|
|
115
|
+
var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
116
|
+
module.exports = {};
|
|
117
|
+
}));
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/logger.ts
|
|
120
|
+
var import___vite_browser_external = /* @__PURE__ */ __toESM(require___vite_browser_external());
|
|
121
|
+
/** Priority ordering for log levels (higher = more severe). */
|
|
122
|
+
var LOG_PRIORITY = {
|
|
123
|
+
[LogLevel.none]: 0,
|
|
124
|
+
[LogLevel.debug]: 1,
|
|
125
|
+
[LogLevel.info]: 2,
|
|
126
|
+
[LogLevel.warning]: 3,
|
|
127
|
+
[LogLevel.error]: 4
|
|
128
|
+
};
|
|
129
|
+
/** Maps each log level to a terminal color. */
|
|
130
|
+
var LOG_LEVEL_COLOR = {
|
|
131
|
+
[LogLevel.none]: "reset",
|
|
132
|
+
[LogLevel.debug]: "blue",
|
|
133
|
+
[LogLevel.info]: "dim",
|
|
134
|
+
[LogLevel.warning]: "yellow",
|
|
135
|
+
[LogLevel.error]: "red"
|
|
136
|
+
};
|
|
137
|
+
/** Logs a message at the given level, respecting the configured log level filter. */
|
|
138
|
+
function log(config, level, ...obj) {
|
|
139
|
+
if (config.logLevel === LogLevel.none || LOG_PRIORITY[level] < LOG_PRIORITY[config.logLevel ?? LogLevel.info]) return;
|
|
140
|
+
const colorFn = colorize[LOG_LEVEL_COLOR[level]];
|
|
141
|
+
const key = level === LogLevel.error ? "error" : level === LogLevel.warning ? "warn" : "log";
|
|
142
|
+
const logFn = console[key];
|
|
143
|
+
logFn(...obj.map((i) => i instanceof Error ? colorFn(i, JSON.stringify(i, void 0, 1), i.stack) : typeof i === "object" ? import___vite_browser_external.default.inspect(i, {
|
|
144
|
+
depth: null,
|
|
145
|
+
colors: true
|
|
146
|
+
}) : colorFn(i)));
|
|
147
|
+
}
|
|
148
|
+
/** Logs the full scaffold configuration at debug level, with a data summary at info level. */
|
|
149
|
+
function logInitStep(config) {
|
|
150
|
+
log(config, LogLevel.debug, "Full config:", {
|
|
151
|
+
name: config.name,
|
|
152
|
+
templates: config.templates,
|
|
153
|
+
output: config.output,
|
|
154
|
+
subdir: config.subdir,
|
|
155
|
+
data: config.data,
|
|
156
|
+
overwrite: config.overwrite,
|
|
157
|
+
subdirHelper: config.subdirHelper,
|
|
158
|
+
helpers: Object.keys(config.helpers ?? {}),
|
|
159
|
+
logLevel: config.logLevel,
|
|
160
|
+
dryRun: config.dryRun,
|
|
161
|
+
beforeWrite: config.beforeWrite
|
|
162
|
+
});
|
|
163
|
+
log(config, LogLevel.info, "Data:", config.data);
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/parser.ts
|
|
167
|
+
var dateFns = {
|
|
168
|
+
add: date_fns.add,
|
|
169
|
+
format: date_fns.format,
|
|
170
|
+
parseISO: date_fns.parseISO
|
|
171
|
+
};
|
|
172
|
+
var defaultHelpers = {
|
|
173
|
+
camelCase,
|
|
174
|
+
snakeCase,
|
|
175
|
+
startCase,
|
|
176
|
+
kebabCase,
|
|
177
|
+
hyphenCase: kebabCase,
|
|
178
|
+
pascalCase,
|
|
179
|
+
lowerCase: (text) => text.toLowerCase(),
|
|
180
|
+
upperCase: (text) => text.toUpperCase(),
|
|
181
|
+
now: nowHelper,
|
|
182
|
+
date: dateHelper
|
|
183
|
+
};
|
|
184
|
+
function _dateHelper(date, formatString, durationDifference, durationType) {
|
|
185
|
+
if (durationType && durationDifference !== void 0) return dateFns.format(dateFns.add(date, { [durationType]: durationDifference }), formatString);
|
|
186
|
+
return dateFns.format(date, formatString);
|
|
187
|
+
}
|
|
188
|
+
function nowHelper(formatString, durationDifference, durationType) {
|
|
189
|
+
return _dateHelper(/* @__PURE__ */ new Date(), formatString, durationDifference, durationType);
|
|
190
|
+
}
|
|
191
|
+
function dateHelper(date, formatString, durationDifference, durationType) {
|
|
192
|
+
return _dateHelper(dateFns.parseISO(date), formatString, durationDifference, durationType);
|
|
193
|
+
}
|
|
194
|
+
function toWordParts(string) {
|
|
195
|
+
return string.split(/[^a-zA-Z0-9]/).flatMap((segment) => segment.split(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/)).filter((s) => s.length > 0);
|
|
196
|
+
}
|
|
197
|
+
function camelCase(s) {
|
|
198
|
+
return toWordParts(s).reduce((acc, part, i) => {
|
|
199
|
+
if (i === 0) return part.toLowerCase();
|
|
200
|
+
return acc + part[0].toUpperCase() + part.slice(1).toLowerCase();
|
|
201
|
+
}, "");
|
|
202
|
+
}
|
|
203
|
+
function snakeCase(s) {
|
|
204
|
+
return toWordParts(s).join("_").toLowerCase();
|
|
205
|
+
}
|
|
206
|
+
function kebabCase(s) {
|
|
207
|
+
return toWordParts(s).join("-").toLowerCase();
|
|
208
|
+
}
|
|
209
|
+
function startCase(s) {
|
|
210
|
+
return toWordParts(s).map((part) => part[0].toUpperCase() + part.slice(1).toLowerCase()).join(" ");
|
|
211
|
+
}
|
|
212
|
+
function pascalCase(s) {
|
|
213
|
+
return startCase(s).replace(/\s+/g, "");
|
|
214
|
+
}
|
|
215
|
+
function registerHelpers(config) {
|
|
216
|
+
const _helpers = {
|
|
217
|
+
...defaultHelpers,
|
|
218
|
+
...config.helpers
|
|
219
|
+
};
|
|
220
|
+
for (const helperName in _helpers) {
|
|
221
|
+
log(config, LogLevel.debug, `Registering helper: ${helperName}`);
|
|
222
|
+
handlebars.default.registerHelper(helperName, _helpers[helperName]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function handlebarsParse(config, templateBuffer, { asPath = false } = {}) {
|
|
226
|
+
const { data } = config;
|
|
227
|
+
try {
|
|
228
|
+
let str = templateBuffer.toString();
|
|
229
|
+
if (asPath) str = str.replace(/\\/g, "/");
|
|
230
|
+
let outputContents = handlebars.default.compile(str, { noEscape: true })(data);
|
|
231
|
+
if (asPath && node_path.default.sep !== "/") outputContents = outputContents.replace(/\//g, "\\");
|
|
232
|
+
return Buffer.from(outputContents);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
log(config, LogLevel.debug, e);
|
|
235
|
+
log(config, LogLevel.info, "Couldn't parse file with handlebars, returning original content");
|
|
236
|
+
return Buffer.from(templateBuffer);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/fs-utils.ts
|
|
241
|
+
var { stat, access, mkdir } = node_fs_promises.default;
|
|
242
|
+
/** Recursively creates a directory and its parents if they don't exist. */
|
|
243
|
+
async function createDirIfNotExists(dir, config) {
|
|
244
|
+
if (config.dryRun) {
|
|
245
|
+
log(config, LogLevel.info, `Dry Run. Not creating dir ${dir}`);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const parentDir = node_path.default.dirname(dir);
|
|
249
|
+
if (!await pathExists(parentDir)) await createDirIfNotExists(parentDir, config);
|
|
250
|
+
if (!await pathExists(dir)) try {
|
|
251
|
+
log(config, LogLevel.debug, `Creating dir ${dir}`);
|
|
252
|
+
await mkdir(dir);
|
|
253
|
+
return;
|
|
254
|
+
} catch (e) {
|
|
255
|
+
if (e && e.code !== "EEXIST") throw e;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** Checks whether a file or directory exists at the given path. */
|
|
260
|
+
async function pathExists(filePath) {
|
|
261
|
+
try {
|
|
262
|
+
await access(filePath, node_constants.F_OK);
|
|
263
|
+
return true;
|
|
264
|
+
} catch (e) {
|
|
265
|
+
if (e && e.code === "ENOENT") return false;
|
|
266
|
+
throw e;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/** Returns true if the given path is a directory. */
|
|
270
|
+
async function isDir(dirPath) {
|
|
271
|
+
return (await stat(dirPath)).isDirectory();
|
|
272
|
+
}
|
|
273
|
+
/** Generates a unique temporary directory path for scaffold operations. @internal */
|
|
274
|
+
function getUniqueTmpPath() {
|
|
275
|
+
return node_path.default.resolve(node_os.default.tmpdir(), `scaffold-config-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/path-utils.ts
|
|
279
|
+
/** Strips glob wildcard characters from a template path. */
|
|
280
|
+
function removeGlob(template) {
|
|
281
|
+
return node_path.default.normalize(template.replace(/\*/g, ""));
|
|
282
|
+
}
|
|
283
|
+
/** Removes a leading path separator, making the path relative. */
|
|
284
|
+
function makeRelativePath(str) {
|
|
285
|
+
return str.startsWith(node_path.default.sep) ? str.slice(1) : str;
|
|
286
|
+
}
|
|
287
|
+
/** Computes a base path relative to the current working directory. */
|
|
288
|
+
function getBasePath(relPath) {
|
|
289
|
+
return node_path.default.resolve(process.cwd(), relPath).replace(process.cwd() + node_path.default.sep, "").replace(process.cwd(), "");
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/file.ts
|
|
293
|
+
var { readFile, writeFile } = node_fs_promises.default;
|
|
294
|
+
/**
|
|
295
|
+
* Resolves a config option that may be either a static value or a per-file function.
|
|
296
|
+
* For function values, the file path is parsed through Handlebars before being passed.
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
function getOptionValueForFile(config, filePath, fn, defaultValue) {
|
|
300
|
+
if (typeof fn !== "function") return defaultValue ?? fn;
|
|
301
|
+
return fn(filePath, node_path.default.dirname(handlebarsParse(config, filePath, { asPath: true }).toString()), node_path.default.basename(handlebarsParse(config, filePath, { asPath: true }).toString()));
|
|
302
|
+
}
|
|
303
|
+
/** Expands a list of glob patterns into a flat list of matching file paths. */
|
|
304
|
+
async function getFileList(config, templates) {
|
|
305
|
+
log(config, LogLevel.debug, `Getting file list for glob list: ${templates}`);
|
|
306
|
+
return (await (0, glob.glob)(templates, {
|
|
307
|
+
dot: true,
|
|
308
|
+
nodir: true
|
|
309
|
+
})).map(node_path.default.normalize);
|
|
310
|
+
}
|
|
311
|
+
/** Analyzes a template path to determine if it's a glob, directory, or single file. */
|
|
312
|
+
async function getTemplateGlobInfo(config, template) {
|
|
313
|
+
const _isGlob = (0, glob.hasMagic)(template);
|
|
314
|
+
log(config, LogLevel.debug, "before isDir", "isGlob:", _isGlob, template);
|
|
315
|
+
let resolvedTemplate = template;
|
|
316
|
+
let baseTemplatePath = _isGlob ? removeGlob(template) : template;
|
|
317
|
+
baseTemplatePath = node_path.default.normalize(baseTemplatePath);
|
|
318
|
+
const isDirOrGlob = _isGlob ? true : await isDir(template);
|
|
319
|
+
const shouldAddGlob = !_isGlob && isDirOrGlob;
|
|
320
|
+
log(config, LogLevel.debug, "after", {
|
|
321
|
+
isDirOrGlob,
|
|
322
|
+
shouldAddGlob
|
|
323
|
+
});
|
|
324
|
+
if (shouldAddGlob) resolvedTemplate = node_path.default.join(template, "**", "*");
|
|
325
|
+
return {
|
|
326
|
+
baseTemplatePath,
|
|
327
|
+
origTemplate: template,
|
|
328
|
+
isDirOrGlob,
|
|
329
|
+
isGlob: _isGlob,
|
|
330
|
+
template: resolvedTemplate
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/** Computes the full output path and metadata for a single template file. */
|
|
334
|
+
async function getTemplateFileInfo(config, { templatePath, basePath }) {
|
|
335
|
+
const inputPath = node_path.default.resolve(process.cwd(), templatePath);
|
|
336
|
+
const outputPathOpt = getOptionValueForFile(config, inputPath, config.output);
|
|
337
|
+
const outputDir = getOutputDir(config, outputPathOpt, basePath.replace(config.tmpDir, "./"));
|
|
338
|
+
const outputPath = handlebarsParse(config, node_path.default.join(outputDir, node_path.default.basename(inputPath)), { asPath: true }).toString();
|
|
339
|
+
return {
|
|
340
|
+
inputPath,
|
|
341
|
+
outputPathOpt,
|
|
342
|
+
outputDir,
|
|
343
|
+
outputPath,
|
|
344
|
+
exists: await pathExists(outputPath)
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Reads a template file, applies Handlebars parsing, runs the beforeWrite hook,
|
|
349
|
+
* and writes the result to the output path.
|
|
350
|
+
*/
|
|
351
|
+
async function copyFileTransformed(config, { exists, overwrite, outputPath, inputPath }) {
|
|
352
|
+
if (!exists || overwrite) {
|
|
353
|
+
if (exists && overwrite) log(config, LogLevel.info, `File ${outputPath} exists, overwriting`);
|
|
354
|
+
log(config, LogLevel.debug, `Processing file ${inputPath}`);
|
|
355
|
+
const templateBuffer = await readFile(inputPath);
|
|
356
|
+
const unprocessedOutputContents = handlebarsParse(config, templateBuffer);
|
|
357
|
+
const finalOutputContents = await config.beforeWrite?.(unprocessedOutputContents, templateBuffer, outputPath) ?? unprocessedOutputContents;
|
|
358
|
+
if (!config.dryRun) await writeFile(outputPath, finalOutputContents);
|
|
359
|
+
else {
|
|
360
|
+
log(config, LogLevel.info, "Dry Run. Output should be:");
|
|
361
|
+
log(config, LogLevel.info, finalOutputContents.toString());
|
|
362
|
+
}
|
|
363
|
+
} else if (exists) log(config, LogLevel.info, `File ${outputPath} already exists, skipping`);
|
|
364
|
+
log(config, LogLevel.info, "Done.");
|
|
365
|
+
}
|
|
366
|
+
/** Computes the output directory for a file, combining the output path, base path, and optional subdir. */
|
|
367
|
+
function getOutputDir(config, outputPathOpt, basePath) {
|
|
368
|
+
return node_path.default.resolve(process.cwd(), ...[
|
|
369
|
+
outputPathOpt,
|
|
370
|
+
basePath,
|
|
371
|
+
config.subdir ? config.subdirHelper ? handlebarsParse(config, `{{ ${config.subdirHelper} name }}`).toString() : config.name : void 0
|
|
372
|
+
].filter(Boolean));
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Processes a single template file: resolves output paths, creates directories,
|
|
376
|
+
* and writes the transformed output.
|
|
377
|
+
*/
|
|
378
|
+
async function handleTemplateFile(config, { templatePath, basePath }) {
|
|
379
|
+
try {
|
|
380
|
+
const { inputPath, outputPathOpt, outputDir, outputPath, exists } = await getTemplateFileInfo(config, {
|
|
381
|
+
templatePath,
|
|
382
|
+
basePath
|
|
383
|
+
});
|
|
384
|
+
const overwrite = getOptionValueForFile(config, inputPath, config.overwrite ?? false);
|
|
385
|
+
log(config, LogLevel.debug, `\nParsing ${templatePath}`, `\nBase path: ${basePath}`, `\nFull input path: ${inputPath}`, `\nOutput Path Opt: ${outputPathOpt}`, `\nFull output dir: ${outputDir}`, `\nFull output path: ${outputPath}`, `\n`);
|
|
386
|
+
await createDirIfNotExists(node_path.default.dirname(outputPath), config);
|
|
387
|
+
log(config, LogLevel.info, `Writing to ${outputPath}`);
|
|
388
|
+
await copyFileTransformed(config, {
|
|
389
|
+
exists,
|
|
390
|
+
overwrite,
|
|
391
|
+
outputPath,
|
|
392
|
+
inputPath
|
|
393
|
+
});
|
|
394
|
+
} catch (e) {
|
|
395
|
+
handleErr(e);
|
|
396
|
+
throw e;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/git.ts
|
|
401
|
+
async function getGitConfig(url, file, tmpPath, logConfig) {
|
|
402
|
+
const repoUrl = `${url.protocol}//${url.host}${url.pathname}`;
|
|
403
|
+
log(logConfig, LogLevel.info, `Cloning git repo ${repoUrl}`);
|
|
404
|
+
return new Promise((res, reject) => {
|
|
405
|
+
log(logConfig, LogLevel.debug, `Cloning git repo to ${tmpPath}`);
|
|
406
|
+
const clone = (0, node_child_process.spawn)("git", [
|
|
407
|
+
"clone",
|
|
408
|
+
"--recurse-submodules",
|
|
409
|
+
"--depth",
|
|
410
|
+
"1",
|
|
411
|
+
repoUrl,
|
|
412
|
+
tmpPath
|
|
413
|
+
]);
|
|
414
|
+
clone.on("error", reject);
|
|
415
|
+
clone.on("close", async (code) => {
|
|
416
|
+
if (code === 0) {
|
|
417
|
+
res(await loadGitConfig({
|
|
418
|
+
logConfig,
|
|
419
|
+
url: repoUrl,
|
|
420
|
+
file,
|
|
421
|
+
tmpPath
|
|
422
|
+
}));
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
reject(/* @__PURE__ */ new Error(`Git clone failed with code ${code}`));
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
/** @internal */
|
|
430
|
+
async function loadGitConfig({ logConfig, url: repoUrl, file, tmpPath }) {
|
|
431
|
+
log(logConfig, LogLevel.info, `Loading config from git repo: ${repoUrl}`);
|
|
432
|
+
const filename = file || await findConfigFile(tmpPath);
|
|
433
|
+
const absolutePath = node_path.default.resolve(tmpPath, filename);
|
|
434
|
+
log(logConfig, LogLevel.debug, `Resolving config file: ${absolutePath}`);
|
|
435
|
+
const loadedConfig = await resolve(async () => (await import(absolutePath)).default, logConfig);
|
|
436
|
+
log(logConfig, LogLevel.info, `Loaded config from git`);
|
|
437
|
+
log(logConfig, LogLevel.debug, `Raw config:`, loadedConfig);
|
|
438
|
+
const fixedConfig = {};
|
|
439
|
+
for (const [k, v] of Object.entries(loadedConfig)) fixedConfig[k] = {
|
|
440
|
+
...v,
|
|
441
|
+
templates: v.templates.map((t) => node_path.default.resolve(tmpPath, t))
|
|
442
|
+
};
|
|
443
|
+
return wrapNoopResolver(fixedConfig);
|
|
444
|
+
}
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/before-write.ts
|
|
447
|
+
/**
|
|
448
|
+
* Wraps a CLI beforeWrite command string into a beforeWrite callback function.
|
|
449
|
+
* The command receives the processed content via a temp file and can return modified content via stdout.
|
|
450
|
+
* @internal
|
|
451
|
+
*/
|
|
452
|
+
function wrapBeforeWrite(config, beforeWrite) {
|
|
453
|
+
return async (content, rawContent, outputFile) => {
|
|
454
|
+
const tmpDir = node_path.default.join(getUniqueTmpPath(), node_path.default.basename(outputFile));
|
|
455
|
+
await createDirIfNotExists(node_path.default.dirname(tmpDir), config);
|
|
456
|
+
const ext = node_path.default.extname(outputFile);
|
|
457
|
+
const rawTmpPath = tmpDir.replace(ext, ".raw" + ext);
|
|
458
|
+
try {
|
|
459
|
+
log(config, LogLevel.debug, "Parsing beforeWrite command", beforeWrite);
|
|
460
|
+
const cmd = await prepareBeforeWriteCmd({
|
|
461
|
+
beforeWrite,
|
|
462
|
+
tmpDir,
|
|
463
|
+
content,
|
|
464
|
+
rawTmpPath,
|
|
465
|
+
rawContent
|
|
466
|
+
});
|
|
467
|
+
return await new Promise((resolve, reject) => {
|
|
468
|
+
log(config, LogLevel.debug, "Running parsed beforeWrite command:", cmd);
|
|
469
|
+
const proc = (0, node_child_process.exec)(cmd);
|
|
470
|
+
proc.stdout.on("data", (data) => {
|
|
471
|
+
if (data.trim()) resolve(data.toString());
|
|
472
|
+
else resolve(void 0);
|
|
473
|
+
});
|
|
474
|
+
proc.stderr.on("data", (data) => {
|
|
475
|
+
reject(data.toString());
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
} catch (e) {
|
|
479
|
+
log(config, LogLevel.debug, e);
|
|
480
|
+
log(config, LogLevel.warning, "Error running beforeWrite command, returning original content");
|
|
481
|
+
return;
|
|
482
|
+
} finally {
|
|
483
|
+
await node_fs_promises.default.rm(tmpDir, { force: true });
|
|
484
|
+
await node_fs_promises.default.rm(rawTmpPath, { force: true });
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
async function prepareBeforeWriteCmd({ beforeWrite, tmpDir, content, rawTmpPath, rawContent }) {
|
|
489
|
+
let cmd = "";
|
|
490
|
+
const pathReg = /\{\{\s*path\s*\}\}/gi;
|
|
491
|
+
const rawPathReg = /\{\{\s*rawpath\s*\}\}/gi;
|
|
492
|
+
if (pathReg.test(beforeWrite)) {
|
|
493
|
+
await node_fs_promises.default.writeFile(tmpDir, content);
|
|
494
|
+
cmd = beforeWrite.replaceAll(pathReg, tmpDir);
|
|
495
|
+
}
|
|
496
|
+
if (rawPathReg.test(beforeWrite)) {
|
|
497
|
+
await node_fs_promises.default.writeFile(rawTmpPath, rawContent);
|
|
498
|
+
cmd = beforeWrite.replaceAll(rawPathReg, rawTmpPath);
|
|
499
|
+
}
|
|
500
|
+
if (!cmd) {
|
|
501
|
+
await node_fs_promises.default.writeFile(tmpDir, content);
|
|
502
|
+
cmd = [beforeWrite, tmpDir].join(" ");
|
|
503
|
+
}
|
|
504
|
+
return cmd;
|
|
505
|
+
}
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/config.ts
|
|
508
|
+
/** Parses CLI append-data syntax (`key=value` or `key:=jsonValue`) into a data object. @internal */
|
|
509
|
+
function parseAppendData(value, options) {
|
|
510
|
+
const data = options.data ?? {};
|
|
511
|
+
const [key, val] = value.split(/:?=/);
|
|
512
|
+
if (value.includes(":=") && !val.includes(":=")) return {
|
|
513
|
+
...data,
|
|
514
|
+
[key]: JSON.parse(val)
|
|
515
|
+
};
|
|
516
|
+
return {
|
|
517
|
+
...data,
|
|
518
|
+
[key]: isWrappedWithQuotes(val) ? val.substring(1, val.length - 1) : val
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function isWrappedWithQuotes(string) {
|
|
522
|
+
return string.startsWith("\"") && string.endsWith("\"") || string.startsWith("'") && string.endsWith("'");
|
|
523
|
+
}
|
|
524
|
+
/** Loads and resolves a config file (local or remote). @internal */
|
|
525
|
+
async function getConfigFile(config) {
|
|
526
|
+
if (config.git && !config.git.includes("://")) {
|
|
527
|
+
log(config, LogLevel.info, `Loading config from GitHub ${config.git}`);
|
|
528
|
+
config.git = githubPartToUrl(config.git);
|
|
529
|
+
}
|
|
530
|
+
const isGit = Boolean(config.git);
|
|
531
|
+
const configFilename = config.config;
|
|
532
|
+
const configPath = isGit ? config.git : configFilename;
|
|
533
|
+
log(config, LogLevel.info, `Loading config from file ${configFilename}`);
|
|
534
|
+
let configImport = await resolve(await (isGit ? getRemoteConfig({
|
|
535
|
+
git: configPath,
|
|
536
|
+
config: configFilename,
|
|
537
|
+
logLevel: config.logLevel,
|
|
538
|
+
tmpDir: config.tmpDir
|
|
539
|
+
}) : getLocalConfig({
|
|
540
|
+
config: configFilename,
|
|
541
|
+
logLevel: config.logLevel
|
|
542
|
+
})), config);
|
|
543
|
+
if (typeof configImport.default === "function" || configImport.default instanceof Promise) {
|
|
544
|
+
log(config, LogLevel.debug, "Config is a function or promise, resolving...");
|
|
545
|
+
configImport = await resolve(configImport.default, config);
|
|
546
|
+
}
|
|
547
|
+
return configImport;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Parses a CLI config into a full ScaffoldConfig by merging CLI args, config file values,
|
|
551
|
+
* and append-data overrides. @internal
|
|
552
|
+
*/
|
|
553
|
+
async function parseConfigFile(config) {
|
|
554
|
+
let output = {
|
|
555
|
+
name: config.name,
|
|
556
|
+
templates: config.templates ?? [],
|
|
557
|
+
output: config.output,
|
|
558
|
+
logLevel: config.logLevel,
|
|
559
|
+
dryRun: config.dryRun,
|
|
560
|
+
data: config.data,
|
|
561
|
+
subdir: config.subdir,
|
|
562
|
+
overwrite: config.overwrite,
|
|
563
|
+
subdirHelper: config.subdirHelper,
|
|
564
|
+
beforeWrite: void 0,
|
|
565
|
+
tmpDir: config.tmpDir
|
|
566
|
+
};
|
|
567
|
+
if (config.quiet) config.logLevel = LogLevel.none;
|
|
568
|
+
if (Boolean(config.config || config.git)) {
|
|
569
|
+
const key = config.key ?? "default";
|
|
570
|
+
const configImport = await getConfigFile(config);
|
|
571
|
+
if (!configImport[key]) throw new Error(`Template "${key}" not found in ${config.config}`);
|
|
572
|
+
const imported = configImport[key];
|
|
573
|
+
log(config, LogLevel.debug, "Imported result", imported);
|
|
574
|
+
output = {
|
|
575
|
+
...output,
|
|
576
|
+
...imported,
|
|
577
|
+
beforeWrite: void 0,
|
|
578
|
+
templates: config.templates || imported.templates,
|
|
579
|
+
output: config.output || imported.output,
|
|
580
|
+
data: {
|
|
581
|
+
...imported.data,
|
|
582
|
+
...config.data
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
output.data = {
|
|
587
|
+
...output.data,
|
|
588
|
+
...config.appendData
|
|
589
|
+
};
|
|
590
|
+
const cmdBeforeWrite = config.beforeWrite ? wrapBeforeWrite(config, config.beforeWrite) : void 0;
|
|
591
|
+
output.beforeWrite = cmdBeforeWrite ?? output.beforeWrite;
|
|
592
|
+
if (!output.name) throw new Error("simple-scaffold: Missing required option: name");
|
|
593
|
+
log(output, LogLevel.debug, "Parsed config", output);
|
|
594
|
+
return output;
|
|
595
|
+
}
|
|
596
|
+
/** Converts a GitHub shorthand (user/repo) to a full HTTPS git URL. @internal */
|
|
597
|
+
function githubPartToUrl(part) {
|
|
598
|
+
const gitUrl = new URL(`https://github.com/${part}`);
|
|
599
|
+
if (!gitUrl.pathname.endsWith(".git")) gitUrl.pathname += ".git";
|
|
600
|
+
return gitUrl.toString();
|
|
601
|
+
}
|
|
602
|
+
/** Loads a scaffold config from a local file or directory. @internal */
|
|
603
|
+
async function getLocalConfig(config) {
|
|
604
|
+
const { config: configFile, ...logConfig } = config;
|
|
605
|
+
const absolutePath = node_path.default.resolve(process.cwd(), configFile);
|
|
606
|
+
if (await isDir(absolutePath)) {
|
|
607
|
+
log(logConfig, LogLevel.debug, `Resolving config file from directory ${absolutePath}`);
|
|
608
|
+
const file = await findConfigFile(absolutePath);
|
|
609
|
+
if (!await pathExists(file)) throw new Error(`Could not find config file in directory ${absolutePath}`);
|
|
610
|
+
log(logConfig, LogLevel.info, `Loading config from: ${node_path.default.resolve(absolutePath, file)}`);
|
|
611
|
+
return wrapNoopResolver(import(node_path.default.resolve(absolutePath, file)));
|
|
612
|
+
}
|
|
613
|
+
log(logConfig, LogLevel.info, `Loading config from: ${absolutePath}`);
|
|
614
|
+
return wrapNoopResolver(import(absolutePath));
|
|
615
|
+
}
|
|
616
|
+
/** Loads a scaffold config from a remote git repository. @internal */
|
|
617
|
+
async function getRemoteConfig(config) {
|
|
618
|
+
const { config: configFile, git, tmpDir, ...logConfig } = config;
|
|
619
|
+
log(logConfig, LogLevel.info, `Loading config from remote ${git}, config file ${configFile || "<auto-detect>"}`);
|
|
620
|
+
const url = new URL(git);
|
|
621
|
+
const isHttp = url.protocol === "http:" || url.protocol === "https:";
|
|
622
|
+
if (!(url.protocol === "git:" || isHttp && url.pathname.endsWith(".git"))) throw new Error(`Unsupported protocol ${url.protocol}`);
|
|
623
|
+
return getGitConfig(url, configFile, tmpDir, logConfig);
|
|
624
|
+
}
|
|
625
|
+
/** Searches for a scaffold config file in the given directory, trying known filenames in order. @internal */
|
|
626
|
+
async function findConfigFile(root) {
|
|
627
|
+
const allowed = [
|
|
628
|
+
"mjs",
|
|
629
|
+
"cjs",
|
|
630
|
+
"js",
|
|
631
|
+
"json"
|
|
632
|
+
].reduce((acc, ext) => {
|
|
633
|
+
acc.push(`scaffold.config.${ext}`);
|
|
634
|
+
acc.push(`scaffold.${ext}`);
|
|
635
|
+
acc.push(`.scaffold.${ext}`);
|
|
636
|
+
return acc;
|
|
637
|
+
}, []);
|
|
638
|
+
for (const file of allowed) if (await pathExists(node_path.default.resolve(root, file))) return file;
|
|
639
|
+
throw new Error(`Could not find config file in git repo`);
|
|
640
|
+
}
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
643
|
+
var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
644
|
+
var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
645
|
+
var isBackspaceKey = (key) => key.name === "backspace";
|
|
646
|
+
var isTabKey = (key) => key.name === "tab";
|
|
647
|
+
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
648
|
+
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/errors.js
|
|
651
|
+
var AbortPromptError = class extends Error {
|
|
652
|
+
name = "AbortPromptError";
|
|
653
|
+
message = "Prompt was aborted";
|
|
654
|
+
constructor(options) {
|
|
655
|
+
super();
|
|
656
|
+
this.cause = options?.cause;
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
var CancelPromptError = class extends Error {
|
|
660
|
+
name = "CancelPromptError";
|
|
661
|
+
message = "Prompt was canceled";
|
|
662
|
+
};
|
|
663
|
+
var ExitPromptError = class extends Error {
|
|
664
|
+
name = "ExitPromptError";
|
|
665
|
+
};
|
|
666
|
+
var HookError = class extends Error {
|
|
667
|
+
name = "HookError";
|
|
668
|
+
};
|
|
669
|
+
var ValidationError = class extends Error {
|
|
670
|
+
name = "ValidationError";
|
|
671
|
+
};
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
674
|
+
var hookStorage = new import___vite_browser_external.AsyncLocalStorage();
|
|
675
|
+
function createStore(rl) {
|
|
676
|
+
return {
|
|
677
|
+
rl,
|
|
678
|
+
hooks: [],
|
|
679
|
+
hooksCleanup: [],
|
|
680
|
+
hooksEffect: [],
|
|
681
|
+
index: 0,
|
|
682
|
+
handleChange() {}
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function withHooks(rl, cb) {
|
|
686
|
+
const store = createStore(rl);
|
|
687
|
+
return hookStorage.run(store, () => {
|
|
688
|
+
function cycle(render) {
|
|
689
|
+
store.handleChange = () => {
|
|
690
|
+
store.index = 0;
|
|
691
|
+
render();
|
|
692
|
+
};
|
|
693
|
+
store.handleChange();
|
|
694
|
+
}
|
|
695
|
+
return cb(cycle);
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
function getStore() {
|
|
699
|
+
const store = hookStorage.getStore();
|
|
700
|
+
if (!store) throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
|
|
701
|
+
return store;
|
|
702
|
+
}
|
|
703
|
+
function readline() {
|
|
704
|
+
return getStore().rl;
|
|
705
|
+
}
|
|
706
|
+
function withUpdates(fn) {
|
|
707
|
+
const wrapped = (...args) => {
|
|
708
|
+
const store = getStore();
|
|
709
|
+
let shouldUpdate = false;
|
|
710
|
+
const oldHandleChange = store.handleChange;
|
|
711
|
+
store.handleChange = () => {
|
|
712
|
+
shouldUpdate = true;
|
|
713
|
+
};
|
|
714
|
+
const returnValue = fn(...args);
|
|
715
|
+
if (shouldUpdate) oldHandleChange();
|
|
716
|
+
store.handleChange = oldHandleChange;
|
|
717
|
+
return returnValue;
|
|
718
|
+
};
|
|
719
|
+
return import___vite_browser_external.AsyncResource.bind(wrapped);
|
|
720
|
+
}
|
|
721
|
+
function withPointer(cb) {
|
|
722
|
+
const store = getStore();
|
|
723
|
+
const { index } = store;
|
|
724
|
+
const returnValue = cb({
|
|
725
|
+
get() {
|
|
726
|
+
return store.hooks[index];
|
|
727
|
+
},
|
|
728
|
+
set(value) {
|
|
729
|
+
store.hooks[index] = value;
|
|
730
|
+
},
|
|
731
|
+
initialized: index in store.hooks
|
|
732
|
+
});
|
|
733
|
+
store.index++;
|
|
734
|
+
return returnValue;
|
|
735
|
+
}
|
|
736
|
+
function handleChange() {
|
|
737
|
+
getStore().handleChange();
|
|
738
|
+
}
|
|
739
|
+
var effectScheduler = {
|
|
740
|
+
queue(cb) {
|
|
741
|
+
const store = getStore();
|
|
742
|
+
const { index } = store;
|
|
743
|
+
store.hooksEffect.push(() => {
|
|
744
|
+
store.hooksCleanup[index]?.();
|
|
745
|
+
const cleanFn = cb(readline());
|
|
746
|
+
if (cleanFn != null && typeof cleanFn !== "function") throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
|
|
747
|
+
store.hooksCleanup[index] = cleanFn;
|
|
748
|
+
});
|
|
749
|
+
},
|
|
750
|
+
run() {
|
|
751
|
+
const store = getStore();
|
|
752
|
+
withUpdates(() => {
|
|
753
|
+
store.hooksEffect.forEach((effect) => {
|
|
754
|
+
effect();
|
|
755
|
+
});
|
|
756
|
+
store.hooksEffect.length = 0;
|
|
757
|
+
})();
|
|
758
|
+
},
|
|
759
|
+
clearAll() {
|
|
760
|
+
const store = getStore();
|
|
761
|
+
store.hooksCleanup.forEach((cleanFn) => {
|
|
762
|
+
cleanFn?.();
|
|
763
|
+
});
|
|
764
|
+
store.hooksEffect.length = 0;
|
|
765
|
+
store.hooksCleanup.length = 0;
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
770
|
+
function useState(defaultValue) {
|
|
771
|
+
return withPointer((pointer) => {
|
|
772
|
+
const setState = import___vite_browser_external.AsyncResource.bind(function setState(newValue) {
|
|
773
|
+
if (pointer.get() !== newValue) {
|
|
774
|
+
pointer.set(newValue);
|
|
775
|
+
handleChange();
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
if (pointer.initialized) return [pointer.get(), setState];
|
|
779
|
+
const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
780
|
+
pointer.set(value);
|
|
781
|
+
return [value, setState];
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
786
|
+
function useEffect(cb, depArray) {
|
|
787
|
+
withPointer((pointer) => {
|
|
788
|
+
const oldDeps = pointer.get();
|
|
789
|
+
if (!Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]))) effectScheduler.queue(cb);
|
|
790
|
+
pointer.set(depArray);
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
//#endregion
|
|
794
|
+
//#region node_modules/.pnpm/@inquirer+figures@2.0.4/node_modules/@inquirer/figures/dist/index.js
|
|
795
|
+
function isUnicodeSupported() {
|
|
796
|
+
if (import___vite_browser_external.default.platform !== "win32") return import___vite_browser_external.default.env["TERM"] !== "linux";
|
|
797
|
+
return Boolean(import___vite_browser_external.default.env["WT_SESSION"]) || Boolean(import___vite_browser_external.default.env["TERMINUS_SUBLIME"]) || import___vite_browser_external.default.env["ConEmuTask"] === "{cmd::Cmder}" || import___vite_browser_external.default.env["TERM_PROGRAM"] === "Terminus-Sublime" || import___vite_browser_external.default.env["TERM_PROGRAM"] === "vscode" || import___vite_browser_external.default.env["TERM"] === "xterm-256color" || import___vite_browser_external.default.env["TERM"] === "alacritty" || import___vite_browser_external.default.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
|
|
798
|
+
}
|
|
799
|
+
var common = {
|
|
800
|
+
circleQuestionMark: "(?)",
|
|
801
|
+
questionMarkPrefix: "(?)",
|
|
802
|
+
square: "█",
|
|
803
|
+
squareDarkShade: "▓",
|
|
804
|
+
squareMediumShade: "▒",
|
|
805
|
+
squareLightShade: "░",
|
|
806
|
+
squareTop: "▀",
|
|
807
|
+
squareBottom: "▄",
|
|
808
|
+
squareLeft: "▌",
|
|
809
|
+
squareRight: "▐",
|
|
810
|
+
squareCenter: "■",
|
|
811
|
+
bullet: "●",
|
|
812
|
+
dot: "․",
|
|
813
|
+
ellipsis: "…",
|
|
814
|
+
pointerSmall: "›",
|
|
815
|
+
triangleUp: "▲",
|
|
816
|
+
triangleUpSmall: "▴",
|
|
817
|
+
triangleDown: "▼",
|
|
818
|
+
triangleDownSmall: "▾",
|
|
819
|
+
triangleLeftSmall: "◂",
|
|
820
|
+
triangleRightSmall: "▸",
|
|
821
|
+
home: "⌂",
|
|
822
|
+
heart: "♥",
|
|
823
|
+
musicNote: "♪",
|
|
824
|
+
musicNoteBeamed: "♫",
|
|
825
|
+
arrowUp: "↑",
|
|
826
|
+
arrowDown: "↓",
|
|
827
|
+
arrowLeft: "←",
|
|
828
|
+
arrowRight: "→",
|
|
829
|
+
arrowLeftRight: "↔",
|
|
830
|
+
arrowUpDown: "↕",
|
|
831
|
+
almostEqual: "≈",
|
|
832
|
+
notEqual: "≠",
|
|
833
|
+
lessOrEqual: "≤",
|
|
834
|
+
greaterOrEqual: "≥",
|
|
835
|
+
identical: "≡",
|
|
836
|
+
infinity: "∞",
|
|
837
|
+
subscriptZero: "₀",
|
|
838
|
+
subscriptOne: "₁",
|
|
839
|
+
subscriptTwo: "₂",
|
|
840
|
+
subscriptThree: "₃",
|
|
841
|
+
subscriptFour: "₄",
|
|
842
|
+
subscriptFive: "₅",
|
|
843
|
+
subscriptSix: "₆",
|
|
844
|
+
subscriptSeven: "₇",
|
|
845
|
+
subscriptEight: "₈",
|
|
846
|
+
subscriptNine: "₉",
|
|
847
|
+
oneHalf: "½",
|
|
848
|
+
oneThird: "⅓",
|
|
849
|
+
oneQuarter: "¼",
|
|
850
|
+
oneFifth: "⅕",
|
|
851
|
+
oneSixth: "⅙",
|
|
852
|
+
oneEighth: "⅛",
|
|
853
|
+
twoThirds: "⅔",
|
|
854
|
+
twoFifths: "⅖",
|
|
855
|
+
threeQuarters: "¾",
|
|
856
|
+
threeFifths: "⅗",
|
|
857
|
+
threeEighths: "⅜",
|
|
858
|
+
fourFifths: "⅘",
|
|
859
|
+
fiveSixths: "⅚",
|
|
860
|
+
fiveEighths: "⅝",
|
|
861
|
+
sevenEighths: "⅞",
|
|
862
|
+
line: "─",
|
|
863
|
+
lineBold: "━",
|
|
864
|
+
lineDouble: "═",
|
|
865
|
+
lineDashed0: "┄",
|
|
866
|
+
lineDashed1: "┅",
|
|
867
|
+
lineDashed2: "┈",
|
|
868
|
+
lineDashed3: "┉",
|
|
869
|
+
lineDashed4: "╌",
|
|
870
|
+
lineDashed5: "╍",
|
|
871
|
+
lineDashed6: "╴",
|
|
872
|
+
lineDashed7: "╶",
|
|
873
|
+
lineDashed8: "╸",
|
|
874
|
+
lineDashed9: "╺",
|
|
875
|
+
lineDashed10: "╼",
|
|
876
|
+
lineDashed11: "╾",
|
|
877
|
+
lineDashed12: "−",
|
|
878
|
+
lineDashed13: "–",
|
|
879
|
+
lineDashed14: "‐",
|
|
880
|
+
lineDashed15: "⁃",
|
|
881
|
+
lineVertical: "│",
|
|
882
|
+
lineVerticalBold: "┃",
|
|
883
|
+
lineVerticalDouble: "║",
|
|
884
|
+
lineVerticalDashed0: "┆",
|
|
885
|
+
lineVerticalDashed1: "┇",
|
|
886
|
+
lineVerticalDashed2: "┊",
|
|
887
|
+
lineVerticalDashed3: "┋",
|
|
888
|
+
lineVerticalDashed4: "╎",
|
|
889
|
+
lineVerticalDashed5: "╏",
|
|
890
|
+
lineVerticalDashed6: "╵",
|
|
891
|
+
lineVerticalDashed7: "╷",
|
|
892
|
+
lineVerticalDashed8: "╹",
|
|
893
|
+
lineVerticalDashed9: "╻",
|
|
894
|
+
lineVerticalDashed10: "╽",
|
|
895
|
+
lineVerticalDashed11: "╿",
|
|
896
|
+
lineDownLeft: "┐",
|
|
897
|
+
lineDownLeftArc: "╮",
|
|
898
|
+
lineDownBoldLeftBold: "┓",
|
|
899
|
+
lineDownBoldLeft: "┒",
|
|
900
|
+
lineDownLeftBold: "┑",
|
|
901
|
+
lineDownDoubleLeftDouble: "╗",
|
|
902
|
+
lineDownDoubleLeft: "╖",
|
|
903
|
+
lineDownLeftDouble: "╕",
|
|
904
|
+
lineDownRight: "┌",
|
|
905
|
+
lineDownRightArc: "╭",
|
|
906
|
+
lineDownBoldRightBold: "┏",
|
|
907
|
+
lineDownBoldRight: "┎",
|
|
908
|
+
lineDownRightBold: "┍",
|
|
909
|
+
lineDownDoubleRightDouble: "╔",
|
|
910
|
+
lineDownDoubleRight: "╓",
|
|
911
|
+
lineDownRightDouble: "╒",
|
|
912
|
+
lineUpLeft: "┘",
|
|
913
|
+
lineUpLeftArc: "╯",
|
|
914
|
+
lineUpBoldLeftBold: "┛",
|
|
915
|
+
lineUpBoldLeft: "┚",
|
|
916
|
+
lineUpLeftBold: "┙",
|
|
917
|
+
lineUpDoubleLeftDouble: "╝",
|
|
918
|
+
lineUpDoubleLeft: "╜",
|
|
919
|
+
lineUpLeftDouble: "╛",
|
|
920
|
+
lineUpRight: "└",
|
|
921
|
+
lineUpRightArc: "╰",
|
|
922
|
+
lineUpBoldRightBold: "┗",
|
|
923
|
+
lineUpBoldRight: "┖",
|
|
924
|
+
lineUpRightBold: "┕",
|
|
925
|
+
lineUpDoubleRightDouble: "╚",
|
|
926
|
+
lineUpDoubleRight: "╙",
|
|
927
|
+
lineUpRightDouble: "╘",
|
|
928
|
+
lineUpDownLeft: "┤",
|
|
929
|
+
lineUpBoldDownBoldLeftBold: "┫",
|
|
930
|
+
lineUpBoldDownBoldLeft: "┨",
|
|
931
|
+
lineUpDownLeftBold: "┥",
|
|
932
|
+
lineUpBoldDownLeftBold: "┩",
|
|
933
|
+
lineUpDownBoldLeftBold: "┪",
|
|
934
|
+
lineUpDownBoldLeft: "┧",
|
|
935
|
+
lineUpBoldDownLeft: "┦",
|
|
936
|
+
lineUpDoubleDownDoubleLeftDouble: "╣",
|
|
937
|
+
lineUpDoubleDownDoubleLeft: "╢",
|
|
938
|
+
lineUpDownLeftDouble: "╡",
|
|
939
|
+
lineUpDownRight: "├",
|
|
940
|
+
lineUpBoldDownBoldRightBold: "┣",
|
|
941
|
+
lineUpBoldDownBoldRight: "┠",
|
|
942
|
+
lineUpDownRightBold: "┝",
|
|
943
|
+
lineUpBoldDownRightBold: "┡",
|
|
944
|
+
lineUpDownBoldRightBold: "┢",
|
|
945
|
+
lineUpDownBoldRight: "┟",
|
|
946
|
+
lineUpBoldDownRight: "┞",
|
|
947
|
+
lineUpDoubleDownDoubleRightDouble: "╠",
|
|
948
|
+
lineUpDoubleDownDoubleRight: "╟",
|
|
949
|
+
lineUpDownRightDouble: "╞",
|
|
950
|
+
lineDownLeftRight: "┬",
|
|
951
|
+
lineDownBoldLeftBoldRightBold: "┳",
|
|
952
|
+
lineDownLeftBoldRightBold: "┯",
|
|
953
|
+
lineDownBoldLeftRight: "┰",
|
|
954
|
+
lineDownBoldLeftBoldRight: "┱",
|
|
955
|
+
lineDownBoldLeftRightBold: "┲",
|
|
956
|
+
lineDownLeftRightBold: "┮",
|
|
957
|
+
lineDownLeftBoldRight: "┭",
|
|
958
|
+
lineDownDoubleLeftDoubleRightDouble: "╦",
|
|
959
|
+
lineDownDoubleLeftRight: "╥",
|
|
960
|
+
lineDownLeftDoubleRightDouble: "╤",
|
|
961
|
+
lineUpLeftRight: "┴",
|
|
962
|
+
lineUpBoldLeftBoldRightBold: "┻",
|
|
963
|
+
lineUpLeftBoldRightBold: "┷",
|
|
964
|
+
lineUpBoldLeftRight: "┸",
|
|
965
|
+
lineUpBoldLeftBoldRight: "┹",
|
|
966
|
+
lineUpBoldLeftRightBold: "┺",
|
|
967
|
+
lineUpLeftRightBold: "┶",
|
|
968
|
+
lineUpLeftBoldRight: "┵",
|
|
969
|
+
lineUpDoubleLeftDoubleRightDouble: "╩",
|
|
970
|
+
lineUpDoubleLeftRight: "╨",
|
|
971
|
+
lineUpLeftDoubleRightDouble: "╧",
|
|
972
|
+
lineUpDownLeftRight: "┼",
|
|
973
|
+
lineUpBoldDownBoldLeftBoldRightBold: "╋",
|
|
974
|
+
lineUpDownBoldLeftBoldRightBold: "╈",
|
|
975
|
+
lineUpBoldDownLeftBoldRightBold: "╇",
|
|
976
|
+
lineUpBoldDownBoldLeftRightBold: "╊",
|
|
977
|
+
lineUpBoldDownBoldLeftBoldRight: "╉",
|
|
978
|
+
lineUpBoldDownLeftRight: "╀",
|
|
979
|
+
lineUpDownBoldLeftRight: "╁",
|
|
980
|
+
lineUpDownLeftBoldRight: "┽",
|
|
981
|
+
lineUpDownLeftRightBold: "┾",
|
|
982
|
+
lineUpBoldDownBoldLeftRight: "╂",
|
|
983
|
+
lineUpDownLeftBoldRightBold: "┿",
|
|
984
|
+
lineUpBoldDownLeftBoldRight: "╃",
|
|
985
|
+
lineUpBoldDownLeftRightBold: "╄",
|
|
986
|
+
lineUpDownBoldLeftBoldRight: "╅",
|
|
987
|
+
lineUpDownBoldLeftRightBold: "╆",
|
|
988
|
+
lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
|
|
989
|
+
lineUpDoubleDownDoubleLeftRight: "╫",
|
|
990
|
+
lineUpDownLeftDoubleRightDouble: "╪",
|
|
991
|
+
lineCross: "╳",
|
|
992
|
+
lineBackslash: "╲",
|
|
993
|
+
lineSlash: "╱"
|
|
994
|
+
};
|
|
995
|
+
var specialMainSymbols = {
|
|
996
|
+
tick: "✔",
|
|
997
|
+
info: "ℹ",
|
|
998
|
+
warning: "⚠",
|
|
999
|
+
cross: "✘",
|
|
1000
|
+
squareSmall: "◻",
|
|
1001
|
+
squareSmallFilled: "◼",
|
|
1002
|
+
circle: "◯",
|
|
1003
|
+
circleFilled: "◉",
|
|
1004
|
+
circleDotted: "◌",
|
|
1005
|
+
circleDouble: "◎",
|
|
1006
|
+
circleCircle: "ⓞ",
|
|
1007
|
+
circleCross: "ⓧ",
|
|
1008
|
+
circlePipe: "Ⓘ",
|
|
1009
|
+
radioOn: "◉",
|
|
1010
|
+
radioOff: "◯",
|
|
1011
|
+
checkboxOn: "☒",
|
|
1012
|
+
checkboxOff: "☐",
|
|
1013
|
+
checkboxCircleOn: "ⓧ",
|
|
1014
|
+
checkboxCircleOff: "Ⓘ",
|
|
1015
|
+
pointer: "❯",
|
|
1016
|
+
triangleUpOutline: "△",
|
|
1017
|
+
triangleLeft: "◀",
|
|
1018
|
+
triangleRight: "▶",
|
|
1019
|
+
lozenge: "◆",
|
|
1020
|
+
lozengeOutline: "◇",
|
|
1021
|
+
hamburger: "☰",
|
|
1022
|
+
smiley: "㋡",
|
|
1023
|
+
mustache: "෴",
|
|
1024
|
+
star: "★",
|
|
1025
|
+
play: "▶",
|
|
1026
|
+
nodejs: "⬢",
|
|
1027
|
+
oneSeventh: "⅐",
|
|
1028
|
+
oneNinth: "⅑",
|
|
1029
|
+
oneTenth: "⅒"
|
|
1030
|
+
};
|
|
1031
|
+
var specialFallbackSymbols = {
|
|
1032
|
+
tick: "√",
|
|
1033
|
+
info: "i",
|
|
1034
|
+
warning: "‼",
|
|
1035
|
+
cross: "×",
|
|
1036
|
+
squareSmall: "□",
|
|
1037
|
+
squareSmallFilled: "■",
|
|
1038
|
+
circle: "( )",
|
|
1039
|
+
circleFilled: "(*)",
|
|
1040
|
+
circleDotted: "( )",
|
|
1041
|
+
circleDouble: "( )",
|
|
1042
|
+
circleCircle: "(○)",
|
|
1043
|
+
circleCross: "(×)",
|
|
1044
|
+
circlePipe: "(│)",
|
|
1045
|
+
radioOn: "(*)",
|
|
1046
|
+
radioOff: "( )",
|
|
1047
|
+
checkboxOn: "[×]",
|
|
1048
|
+
checkboxOff: "[ ]",
|
|
1049
|
+
checkboxCircleOn: "(×)",
|
|
1050
|
+
checkboxCircleOff: "( )",
|
|
1051
|
+
pointer: ">",
|
|
1052
|
+
triangleUpOutline: "∆",
|
|
1053
|
+
triangleLeft: "◄",
|
|
1054
|
+
triangleRight: "►",
|
|
1055
|
+
lozenge: "♦",
|
|
1056
|
+
lozengeOutline: "◊",
|
|
1057
|
+
hamburger: "≡",
|
|
1058
|
+
smiley: "☺",
|
|
1059
|
+
mustache: "┌─┐",
|
|
1060
|
+
star: "✶",
|
|
1061
|
+
play: "►",
|
|
1062
|
+
nodejs: "♦",
|
|
1063
|
+
oneSeventh: "1/7",
|
|
1064
|
+
oneNinth: "1/9",
|
|
1065
|
+
oneTenth: "1/10"
|
|
1066
|
+
};
|
|
1067
|
+
var mainSymbols = {
|
|
1068
|
+
...common,
|
|
1069
|
+
...specialMainSymbols
|
|
1070
|
+
};
|
|
1071
|
+
var fallbackSymbols = {
|
|
1072
|
+
...common,
|
|
1073
|
+
...specialFallbackSymbols
|
|
1074
|
+
};
|
|
1075
|
+
var figures = isUnicodeSupported() ? mainSymbols : fallbackSymbols;
|
|
1076
|
+
Object.entries(specialMainSymbols);
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
1079
|
+
var defaultTheme = {
|
|
1080
|
+
prefix: {
|
|
1081
|
+
idle: (0, node_util.styleText)("blue", "?"),
|
|
1082
|
+
done: (0, node_util.styleText)("green", figures.tick)
|
|
1083
|
+
},
|
|
1084
|
+
spinner: {
|
|
1085
|
+
interval: 80,
|
|
1086
|
+
frames: [
|
|
1087
|
+
"⠋",
|
|
1088
|
+
"⠙",
|
|
1089
|
+
"⠹",
|
|
1090
|
+
"⠸",
|
|
1091
|
+
"⠼",
|
|
1092
|
+
"⠴",
|
|
1093
|
+
"⠦",
|
|
1094
|
+
"⠧",
|
|
1095
|
+
"⠇",
|
|
1096
|
+
"⠏"
|
|
1097
|
+
].map((frame) => (0, node_util.styleText)("yellow", frame))
|
|
1098
|
+
},
|
|
1099
|
+
style: {
|
|
1100
|
+
answer: (text) => (0, node_util.styleText)("cyan", text),
|
|
1101
|
+
message: (text) => (0, node_util.styleText)("bold", text),
|
|
1102
|
+
error: (text) => (0, node_util.styleText)("red", `> ${text}`),
|
|
1103
|
+
defaultAnswer: (text) => (0, node_util.styleText)("dim", `(${text})`),
|
|
1104
|
+
help: (text) => (0, node_util.styleText)("dim", text),
|
|
1105
|
+
highlight: (text) => (0, node_util.styleText)("cyan", text),
|
|
1106
|
+
key: (text) => (0, node_util.styleText)("cyan", (0, node_util.styleText)("bold", `<${text}>`))
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
//#endregion
|
|
1110
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
1111
|
+
function isPlainObject(value) {
|
|
1112
|
+
if (typeof value !== "object" || value === null) return false;
|
|
1113
|
+
let proto = value;
|
|
1114
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
1115
|
+
return Object.getPrototypeOf(value) === proto;
|
|
1116
|
+
}
|
|
1117
|
+
function deepMerge(...objects) {
|
|
1118
|
+
const output = {};
|
|
1119
|
+
for (const obj of objects) for (const [key, value] of Object.entries(obj)) {
|
|
1120
|
+
const prevValue = output[key];
|
|
1121
|
+
output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
|
|
1122
|
+
}
|
|
1123
|
+
return output;
|
|
1124
|
+
}
|
|
1125
|
+
function makeTheme(...themes) {
|
|
1126
|
+
return deepMerge(...[defaultTheme, ...themes.filter((theme) => theme != null)]);
|
|
1127
|
+
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
1130
|
+
function usePrefix({ status = "idle", theme }) {
|
|
1131
|
+
const [showLoader, setShowLoader] = useState(false);
|
|
1132
|
+
const [tick, setTick] = useState(0);
|
|
1133
|
+
const { prefix, spinner } = makeTheme(theme);
|
|
1134
|
+
useEffect(() => {
|
|
1135
|
+
if (status === "loading") {
|
|
1136
|
+
let tickInterval;
|
|
1137
|
+
let inc = -1;
|
|
1138
|
+
const delayTimeout = setTimeout(() => {
|
|
1139
|
+
setShowLoader(true);
|
|
1140
|
+
tickInterval = setInterval(() => {
|
|
1141
|
+
inc = inc + 1;
|
|
1142
|
+
setTick(inc % spinner.frames.length);
|
|
1143
|
+
}, spinner.interval);
|
|
1144
|
+
}, 300);
|
|
1145
|
+
return () => {
|
|
1146
|
+
clearTimeout(delayTimeout);
|
|
1147
|
+
clearInterval(tickInterval);
|
|
1148
|
+
};
|
|
1149
|
+
} else setShowLoader(false);
|
|
1150
|
+
}, [status]);
|
|
1151
|
+
if (showLoader) return spinner.frames[tick];
|
|
1152
|
+
return typeof prefix === "string" ? prefix : prefix[status === "loading" ? "idle" : status] ?? prefix["idle"];
|
|
1153
|
+
}
|
|
1154
|
+
//#endregion
|
|
1155
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
1156
|
+
function useMemo(fn, dependencies) {
|
|
1157
|
+
return withPointer((pointer) => {
|
|
1158
|
+
const prev = pointer.get();
|
|
1159
|
+
if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
|
|
1160
|
+
const value = fn();
|
|
1161
|
+
pointer.set({
|
|
1162
|
+
value,
|
|
1163
|
+
dependencies
|
|
1164
|
+
});
|
|
1165
|
+
return value;
|
|
1166
|
+
}
|
|
1167
|
+
return prev.value;
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
//#endregion
|
|
1171
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
1172
|
+
function useRef(val) {
|
|
1173
|
+
return useState({ current: val })[0];
|
|
1174
|
+
}
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
1177
|
+
function useKeypress(userHandler) {
|
|
1178
|
+
const signal = useRef(userHandler);
|
|
1179
|
+
signal.current = userHandler;
|
|
1180
|
+
useEffect((rl) => {
|
|
1181
|
+
let ignore = false;
|
|
1182
|
+
const handler = withUpdates((_input, event) => {
|
|
1183
|
+
if (ignore) return;
|
|
1184
|
+
signal.current(event, rl);
|
|
1185
|
+
});
|
|
1186
|
+
rl.input.on("keypress", handler);
|
|
1187
|
+
return () => {
|
|
1188
|
+
ignore = true;
|
|
1189
|
+
rl.input.removeListener("keypress", handler);
|
|
1190
|
+
};
|
|
1191
|
+
}, []);
|
|
1192
|
+
}
|
|
1193
|
+
//#endregion
|
|
1194
|
+
//#region node_modules/.pnpm/cli-width@4.1.0/node_modules/cli-width/index.js
|
|
1195
|
+
var require_cli_width = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1196
|
+
module.exports = cliWidth;
|
|
1197
|
+
function normalizeOpts(options) {
|
|
1198
|
+
const defaultOpts = {
|
|
1199
|
+
defaultWidth: 0,
|
|
1200
|
+
output: process.stdout,
|
|
1201
|
+
tty: require___vite_browser_external()
|
|
1202
|
+
};
|
|
1203
|
+
if (!options) return defaultOpts;
|
|
1204
|
+
Object.keys(defaultOpts).forEach(function(key) {
|
|
1205
|
+
if (!options[key]) options[key] = defaultOpts[key];
|
|
1206
|
+
});
|
|
1207
|
+
return options;
|
|
1208
|
+
}
|
|
1209
|
+
function cliWidth(options) {
|
|
1210
|
+
const opts = normalizeOpts(options);
|
|
1211
|
+
if (opts.output.getWindowSize) return opts.output.getWindowSize()[0] || opts.defaultWidth;
|
|
1212
|
+
if (opts.tty.getWindowSize) return opts.tty.getWindowSize()[1] || opts.defaultWidth;
|
|
1213
|
+
if (opts.output.columns) return opts.output.columns;
|
|
1214
|
+
if (process.env.CLI_WIDTH) {
|
|
1215
|
+
const width = parseInt(process.env.CLI_WIDTH, 10);
|
|
1216
|
+
if (!isNaN(width) && width !== 0) return width;
|
|
1217
|
+
}
|
|
1218
|
+
return opts.defaultWidth;
|
|
1219
|
+
}
|
|
1220
|
+
}));
|
|
1221
|
+
//#endregion
|
|
1222
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
1223
|
+
var getCodePointsLength = (() => {
|
|
1224
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
1225
|
+
return (input) => {
|
|
1226
|
+
let surrogatePairsNr = 0;
|
|
1227
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
1228
|
+
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
1229
|
+
return input.length - surrogatePairsNr;
|
|
1230
|
+
};
|
|
1231
|
+
})();
|
|
1232
|
+
var isFullWidth = (x) => {
|
|
1233
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
1234
|
+
};
|
|
1235
|
+
var isWideNotCJKTNotEmoji = (x) => {
|
|
1236
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
1237
|
+
};
|
|
1238
|
+
//#endregion
|
|
1239
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
1240
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
1241
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
1242
|
+
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
|
|
1243
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
1244
|
+
var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
|
|
1245
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
1246
|
+
var MODIFIER_RE = /\p{M}+/gu;
|
|
1247
|
+
var NO_TRUNCATION$1 = {
|
|
1248
|
+
limit: Infinity,
|
|
1249
|
+
ellipsis: ""
|
|
1250
|
+
};
|
|
1251
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
1252
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
1253
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
1254
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
1255
|
+
const ANSI_WIDTH = 0;
|
|
1256
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
1257
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
1258
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
1259
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
1260
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
1261
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
1262
|
+
const PARSE_BLOCKS = [
|
|
1263
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
1264
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
1265
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
1266
|
+
[TAB_RE, TAB_WIDTH],
|
|
1267
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
1268
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
1269
|
+
];
|
|
1270
|
+
let indexPrev = 0;
|
|
1271
|
+
let index = 0;
|
|
1272
|
+
let length = input.length;
|
|
1273
|
+
let lengthExtra = 0;
|
|
1274
|
+
let truncationEnabled = false;
|
|
1275
|
+
let truncationIndex = length;
|
|
1276
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
1277
|
+
let unmatchedStart = 0;
|
|
1278
|
+
let unmatchedEnd = 0;
|
|
1279
|
+
let width = 0;
|
|
1280
|
+
let widthExtra = 0;
|
|
1281
|
+
outer: while (true) {
|
|
1282
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
1283
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
1284
|
+
lengthExtra = 0;
|
|
1285
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
1286
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
1287
|
+
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
1288
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
1289
|
+
else widthExtra = REGULAR_WIDTH;
|
|
1290
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
1291
|
+
if (width + widthExtra > LIMIT) {
|
|
1292
|
+
truncationEnabled = true;
|
|
1293
|
+
break outer;
|
|
1294
|
+
}
|
|
1295
|
+
lengthExtra += char.length;
|
|
1296
|
+
width += widthExtra;
|
|
1297
|
+
}
|
|
1298
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
1299
|
+
}
|
|
1300
|
+
if (index >= length) break outer;
|
|
1301
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
1302
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
1303
|
+
BLOCK_RE.lastIndex = index;
|
|
1304
|
+
if (BLOCK_RE.test(input)) {
|
|
1305
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
1306
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
1307
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
1308
|
+
if (width + widthExtra > LIMIT) {
|
|
1309
|
+
truncationEnabled = true;
|
|
1310
|
+
break outer;
|
|
1311
|
+
}
|
|
1312
|
+
width += widthExtra;
|
|
1313
|
+
unmatchedStart = indexPrev;
|
|
1314
|
+
unmatchedEnd = index;
|
|
1315
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
1316
|
+
continue outer;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
index += 1;
|
|
1320
|
+
}
|
|
1321
|
+
return {
|
|
1322
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
1323
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
1324
|
+
truncated: truncationEnabled,
|
|
1325
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
1326
|
+
};
|
|
1327
|
+
};
|
|
1328
|
+
//#endregion
|
|
1329
|
+
//#region node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
1330
|
+
var NO_TRUNCATION = {
|
|
1331
|
+
limit: Infinity,
|
|
1332
|
+
ellipsis: "",
|
|
1333
|
+
ellipsisWidth: 0
|
|
1334
|
+
};
|
|
1335
|
+
var fastStringWidth = (input, options = {}) => {
|
|
1336
|
+
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
1337
|
+
};
|
|
1338
|
+
//#endregion
|
|
1339
|
+
//#region node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js
|
|
1340
|
+
var ESC$1 = "\x1B";
|
|
1341
|
+
var CSI = "";
|
|
1342
|
+
var END_CODE = 39;
|
|
1343
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
1344
|
+
var ANSI_CSI = "[";
|
|
1345
|
+
var ANSI_OSC = "]";
|
|
1346
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
1347
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
1348
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
1349
|
+
var getClosingCode = (openingCode) => {
|
|
1350
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
1351
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
1352
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
1353
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
1354
|
+
if (openingCode === 1 || openingCode === 2) return 22;
|
|
1355
|
+
if (openingCode === 3) return 23;
|
|
1356
|
+
if (openingCode === 4) return 24;
|
|
1357
|
+
if (openingCode === 7) return 27;
|
|
1358
|
+
if (openingCode === 8) return 28;
|
|
1359
|
+
if (openingCode === 9) return 29;
|
|
1360
|
+
if (openingCode === 0) return 0;
|
|
1361
|
+
};
|
|
1362
|
+
var wrapAnsiCode = (code) => `${ESC$1}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
1363
|
+
var wrapAnsiHyperlink = (url) => `${ESC$1}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
1364
|
+
var wrapWord = (rows, word, columns) => {
|
|
1365
|
+
const characters = word[Symbol.iterator]();
|
|
1366
|
+
let isInsideEscape = false;
|
|
1367
|
+
let isInsideLinkEscape = false;
|
|
1368
|
+
let lastRow = rows.at(-1);
|
|
1369
|
+
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
1370
|
+
let currentCharacter = characters.next();
|
|
1371
|
+
let nextCharacter = characters.next();
|
|
1372
|
+
let rawCharacterIndex = 0;
|
|
1373
|
+
while (!currentCharacter.done) {
|
|
1374
|
+
const character = currentCharacter.value;
|
|
1375
|
+
const characterLength = fastStringWidth(character);
|
|
1376
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
1377
|
+
else {
|
|
1378
|
+
rows.push(character);
|
|
1379
|
+
visible = 0;
|
|
1380
|
+
}
|
|
1381
|
+
if (character === ESC$1 || character === CSI) {
|
|
1382
|
+
isInsideEscape = true;
|
|
1383
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
1384
|
+
}
|
|
1385
|
+
if (isInsideEscape) {
|
|
1386
|
+
if (isInsideLinkEscape) {
|
|
1387
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
1388
|
+
isInsideEscape = false;
|
|
1389
|
+
isInsideLinkEscape = false;
|
|
1390
|
+
}
|
|
1391
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
1392
|
+
} else {
|
|
1393
|
+
visible += characterLength;
|
|
1394
|
+
if (visible === columns && !nextCharacter.done) {
|
|
1395
|
+
rows.push("");
|
|
1396
|
+
visible = 0;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
currentCharacter = nextCharacter;
|
|
1400
|
+
nextCharacter = characters.next();
|
|
1401
|
+
rawCharacterIndex += character.length;
|
|
1402
|
+
}
|
|
1403
|
+
lastRow = rows.at(-1);
|
|
1404
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
1405
|
+
};
|
|
1406
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
1407
|
+
const words = string.split(" ");
|
|
1408
|
+
let last = words.length;
|
|
1409
|
+
while (last) {
|
|
1410
|
+
if (fastStringWidth(words[last - 1])) break;
|
|
1411
|
+
last--;
|
|
1412
|
+
}
|
|
1413
|
+
if (last === words.length) return string;
|
|
1414
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
1415
|
+
};
|
|
1416
|
+
var exec = (string, columns, options = {}) => {
|
|
1417
|
+
if (options.trim !== false && string.trim() === "") return "";
|
|
1418
|
+
let returnValue = "";
|
|
1419
|
+
let escapeCode;
|
|
1420
|
+
let escapeUrl;
|
|
1421
|
+
const words = string.split(" ");
|
|
1422
|
+
let rows = [""];
|
|
1423
|
+
let rowLength = 0;
|
|
1424
|
+
for (let index = 0; index < words.length; index++) {
|
|
1425
|
+
const word = words[index];
|
|
1426
|
+
if (options.trim !== false) {
|
|
1427
|
+
const row = rows.at(-1) ?? "";
|
|
1428
|
+
const trimmed = row.trimStart();
|
|
1429
|
+
if (row.length !== trimmed.length) {
|
|
1430
|
+
rows[rows.length - 1] = trimmed;
|
|
1431
|
+
rowLength = fastStringWidth(trimmed);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
if (index !== 0) {
|
|
1435
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
1436
|
+
rows.push("");
|
|
1437
|
+
rowLength = 0;
|
|
1438
|
+
}
|
|
1439
|
+
if (rowLength || options.trim === false) {
|
|
1440
|
+
rows[rows.length - 1] += " ";
|
|
1441
|
+
rowLength++;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
const wordLength = fastStringWidth(word);
|
|
1445
|
+
if (options.hard && wordLength > columns) {
|
|
1446
|
+
const remainingColumns = columns - rowLength;
|
|
1447
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
1448
|
+
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
1449
|
+
wrapWord(rows, word, columns);
|
|
1450
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
1451
|
+
continue;
|
|
1452
|
+
}
|
|
1453
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
1454
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
1455
|
+
wrapWord(rows, word, columns);
|
|
1456
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
1457
|
+
continue;
|
|
1458
|
+
}
|
|
1459
|
+
rows.push("");
|
|
1460
|
+
rowLength = 0;
|
|
1461
|
+
}
|
|
1462
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
1463
|
+
wrapWord(rows, word, columns);
|
|
1464
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
1465
|
+
continue;
|
|
1466
|
+
}
|
|
1467
|
+
rows[rows.length - 1] += word;
|
|
1468
|
+
rowLength += wordLength;
|
|
1469
|
+
}
|
|
1470
|
+
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
1471
|
+
const preString = rows.join("\n");
|
|
1472
|
+
let inSurrogate = false;
|
|
1473
|
+
for (let i = 0; i < preString.length; i++) {
|
|
1474
|
+
const character = preString[i];
|
|
1475
|
+
returnValue += character;
|
|
1476
|
+
if (!inSurrogate) {
|
|
1477
|
+
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
1478
|
+
if (inSurrogate) continue;
|
|
1479
|
+
} else inSurrogate = false;
|
|
1480
|
+
if (character === ESC$1 || character === CSI) {
|
|
1481
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
1482
|
+
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
1483
|
+
if (groups?.code !== void 0) {
|
|
1484
|
+
const code = Number.parseFloat(groups.code);
|
|
1485
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
1486
|
+
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
1487
|
+
}
|
|
1488
|
+
if (preString[i + 1] === "\n") {
|
|
1489
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
1490
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
1491
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
1492
|
+
} else if (character === "\n") {
|
|
1493
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
1494
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
return returnValue;
|
|
1498
|
+
};
|
|
1499
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
1500
|
+
function wrapAnsi(string, columns, options) {
|
|
1501
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
1502
|
+
}
|
|
1503
|
+
//#endregion
|
|
1504
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
1505
|
+
var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
|
|
1506
|
+
/**
|
|
1507
|
+
* Force line returns at specific width. This function is ANSI code friendly and it'll
|
|
1508
|
+
* ignore invisible codes during width calculation.
|
|
1509
|
+
* @param {string} content
|
|
1510
|
+
* @param {number} width
|
|
1511
|
+
* @return {string}
|
|
1512
|
+
*/
|
|
1513
|
+
function breakLines(content, width) {
|
|
1514
|
+
return content.split("\n").flatMap((line) => wrapAnsi(line, width, {
|
|
1515
|
+
trim: false,
|
|
1516
|
+
hard: true
|
|
1517
|
+
}).split("\n").map((str) => str.trimEnd())).join("\n");
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Returns the width of the active readline, or 80 as default value.
|
|
1521
|
+
* @returns {number}
|
|
1522
|
+
*/
|
|
1523
|
+
function readlineWidth() {
|
|
1524
|
+
return (0, import_cli_width.default)({
|
|
1525
|
+
defaultWidth: 80,
|
|
1526
|
+
output: readline().output
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
//#endregion
|
|
1530
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
1531
|
+
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
1532
|
+
const state = useRef({
|
|
1533
|
+
lastPointer: active,
|
|
1534
|
+
lastActive: void 0
|
|
1535
|
+
});
|
|
1536
|
+
const { lastPointer, lastActive } = state.current;
|
|
1537
|
+
const middle = Math.floor(pageSize / 2);
|
|
1538
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
1539
|
+
const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
|
|
1540
|
+
let pointer = defaultPointerPosition;
|
|
1541
|
+
if (renderedLength > pageSize) if (loop) {
|
|
1542
|
+
/**
|
|
1543
|
+
* Creates the next position for the pointer considering an infinitely
|
|
1544
|
+
* looping list of items to be rendered on the page.
|
|
1545
|
+
*
|
|
1546
|
+
* The goal is to progressively move the cursor to the middle position as the user move down, and then keep
|
|
1547
|
+
* the cursor there. When the user move up, maintain the cursor position.
|
|
1548
|
+
*/
|
|
1549
|
+
pointer = lastPointer;
|
|
1550
|
+
if (lastActive != null && lastActive < active && active - lastActive < pageSize) pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
|
|
1551
|
+
} else {
|
|
1552
|
+
/**
|
|
1553
|
+
* Creates the next position for the pointer considering a finite list of
|
|
1554
|
+
* items to be rendered on a page.
|
|
1555
|
+
*
|
|
1556
|
+
* The goal is to keep the pointer in the middle of the page whenever possible, until
|
|
1557
|
+
* we reach the bounds of the list (top or bottom). In which case, the cursor moves progressively
|
|
1558
|
+
* to the bottom or top of the list.
|
|
1559
|
+
*/
|
|
1560
|
+
const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
|
|
1561
|
+
pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
|
|
1562
|
+
}
|
|
1563
|
+
state.current.lastPointer = pointer;
|
|
1564
|
+
state.current.lastActive = active;
|
|
1565
|
+
return pointer;
|
|
1566
|
+
}
|
|
1567
|
+
function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
1568
|
+
const width = readlineWidth();
|
|
1569
|
+
const bound = (num) => (num % items.length + items.length) % items.length;
|
|
1570
|
+
const renderedItems = items.map((item, index) => {
|
|
1571
|
+
if (item == null) return [];
|
|
1572
|
+
return breakLines(renderItem({
|
|
1573
|
+
item,
|
|
1574
|
+
index,
|
|
1575
|
+
isActive: index === active
|
|
1576
|
+
}), width).split("\n");
|
|
1577
|
+
});
|
|
1578
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
1579
|
+
const renderItemAtIndex = (index) => renderedItems[index] ?? [];
|
|
1580
|
+
const pointer = usePointerPosition({
|
|
1581
|
+
active,
|
|
1582
|
+
renderedItems,
|
|
1583
|
+
pageSize,
|
|
1584
|
+
loop
|
|
1585
|
+
});
|
|
1586
|
+
const activeItem = renderItemAtIndex(active).slice(0, pageSize);
|
|
1587
|
+
const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
|
|
1588
|
+
const pageBuffer = Array.from({ length: pageSize });
|
|
1589
|
+
pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
|
|
1590
|
+
const itemVisited = new Set([active]);
|
|
1591
|
+
let bufferPointer = activeItemPosition + activeItem.length;
|
|
1592
|
+
let itemPointer = bound(active + 1);
|
|
1593
|
+
while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
|
|
1594
|
+
const linesToAdd = renderItemAtIndex(itemPointer).slice(0, pageSize - bufferPointer);
|
|
1595
|
+
pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
|
|
1596
|
+
itemVisited.add(itemPointer);
|
|
1597
|
+
bufferPointer += linesToAdd.length;
|
|
1598
|
+
itemPointer = bound(itemPointer + 1);
|
|
1599
|
+
}
|
|
1600
|
+
bufferPointer = activeItemPosition - 1;
|
|
1601
|
+
itemPointer = bound(active - 1);
|
|
1602
|
+
while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
|
|
1603
|
+
const lines = renderItemAtIndex(itemPointer);
|
|
1604
|
+
const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
|
|
1605
|
+
pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
|
|
1606
|
+
itemVisited.add(itemPointer);
|
|
1607
|
+
bufferPointer -= linesToAdd.length;
|
|
1608
|
+
itemPointer = bound(itemPointer - 1);
|
|
1609
|
+
}
|
|
1610
|
+
return pageBuffer.filter((line) => typeof line === "string").join("\n");
|
|
1611
|
+
}
|
|
1612
|
+
//#endregion
|
|
1613
|
+
//#region node_modules/.pnpm/mute-stream@3.0.0/node_modules/mute-stream/lib/index.js
|
|
1614
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1615
|
+
var Stream = require___vite_browser_external();
|
|
1616
|
+
var MuteStream = class extends Stream {
|
|
1617
|
+
#isTTY = null;
|
|
1618
|
+
constructor(opts = {}) {
|
|
1619
|
+
super(opts);
|
|
1620
|
+
this.writable = this.readable = true;
|
|
1621
|
+
this.muted = false;
|
|
1622
|
+
this.on("pipe", this._onpipe);
|
|
1623
|
+
this.replace = opts.replace;
|
|
1624
|
+
this._prompt = opts.prompt || null;
|
|
1625
|
+
this._hadControl = false;
|
|
1626
|
+
}
|
|
1627
|
+
#destSrc(key, def) {
|
|
1628
|
+
if (this._dest) return this._dest[key];
|
|
1629
|
+
if (this._src) return this._src[key];
|
|
1630
|
+
return def;
|
|
1631
|
+
}
|
|
1632
|
+
#proxy(method, ...args) {
|
|
1633
|
+
if (typeof this._dest?.[method] === "function") this._dest[method](...args);
|
|
1634
|
+
if (typeof this._src?.[method] === "function") this._src[method](...args);
|
|
1635
|
+
}
|
|
1636
|
+
get isTTY() {
|
|
1637
|
+
if (this.#isTTY !== null) return this.#isTTY;
|
|
1638
|
+
return this.#destSrc("isTTY", false);
|
|
1639
|
+
}
|
|
1640
|
+
set isTTY(val) {
|
|
1641
|
+
this.#isTTY = val;
|
|
1642
|
+
}
|
|
1643
|
+
get rows() {
|
|
1644
|
+
return this.#destSrc("rows");
|
|
1645
|
+
}
|
|
1646
|
+
get columns() {
|
|
1647
|
+
return this.#destSrc("columns");
|
|
1648
|
+
}
|
|
1649
|
+
mute() {
|
|
1650
|
+
this.muted = true;
|
|
1651
|
+
}
|
|
1652
|
+
unmute() {
|
|
1653
|
+
this.muted = false;
|
|
1654
|
+
}
|
|
1655
|
+
_onpipe(src) {
|
|
1656
|
+
this._src = src;
|
|
1657
|
+
}
|
|
1658
|
+
pipe(dest, options) {
|
|
1659
|
+
this._dest = dest;
|
|
1660
|
+
return super.pipe(dest, options);
|
|
1661
|
+
}
|
|
1662
|
+
pause() {
|
|
1663
|
+
if (this._src) return this._src.pause();
|
|
1664
|
+
}
|
|
1665
|
+
resume() {
|
|
1666
|
+
if (this._src) return this._src.resume();
|
|
1667
|
+
}
|
|
1668
|
+
write(c) {
|
|
1669
|
+
if (this.muted) {
|
|
1670
|
+
if (!this.replace) return true;
|
|
1671
|
+
if (c.match(/^\u001b/)) {
|
|
1672
|
+
if (c.indexOf(this._prompt) === 0) {
|
|
1673
|
+
c = c.slice(this._prompt.length);
|
|
1674
|
+
c = c.replace(/./g, this.replace);
|
|
1675
|
+
c = this._prompt + c;
|
|
1676
|
+
}
|
|
1677
|
+
this._hadControl = true;
|
|
1678
|
+
return this.emit("data", c);
|
|
1679
|
+
} else {
|
|
1680
|
+
if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
|
|
1681
|
+
this._hadControl = false;
|
|
1682
|
+
this.emit("data", this._prompt);
|
|
1683
|
+
c = c.slice(this._prompt.length);
|
|
1684
|
+
}
|
|
1685
|
+
c = c.toString().replace(/./g, this.replace);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
this.emit("data", c);
|
|
1689
|
+
}
|
|
1690
|
+
end(c) {
|
|
1691
|
+
if (this.muted) if (c && this.replace) c = c.toString().replace(/./g, this.replace);
|
|
1692
|
+
else c = null;
|
|
1693
|
+
if (c) this.emit("data", c);
|
|
1694
|
+
this.emit("end");
|
|
1695
|
+
}
|
|
1696
|
+
destroy(...args) {
|
|
1697
|
+
return this.#proxy("destroy", ...args);
|
|
1698
|
+
}
|
|
1699
|
+
destroySoon(...args) {
|
|
1700
|
+
return this.#proxy("destroySoon", ...args);
|
|
1701
|
+
}
|
|
1702
|
+
close(...args) {
|
|
1703
|
+
return this.#proxy("close", ...args);
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
module.exports = MuteStream;
|
|
1707
|
+
}));
|
|
1708
|
+
//#endregion
|
|
1709
|
+
//#region node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
1710
|
+
/**
|
|
1711
|
+
* This is not the set of all possible signals.
|
|
1712
|
+
*
|
|
1713
|
+
* It IS, however, the set of all signals that trigger
|
|
1714
|
+
* an exit on either Linux or BSD systems. Linux is a
|
|
1715
|
+
* superset of the signal names supported on BSD, and
|
|
1716
|
+
* the unknown signals just fail to register, so we can
|
|
1717
|
+
* catch that easily enough.
|
|
1718
|
+
*
|
|
1719
|
+
* Windows signals are a different set, since there are
|
|
1720
|
+
* signals that terminate Windows processes, but don't
|
|
1721
|
+
* terminate (or don't even exist) on Posix systems.
|
|
1722
|
+
*
|
|
1723
|
+
* Don't bother with SIGKILL. It's uncatchable, which
|
|
1724
|
+
* means that we can't fire any callbacks anyway.
|
|
1725
|
+
*
|
|
1726
|
+
* If a user does happen to register a handler on a non-
|
|
1727
|
+
* fatal signal like SIGWINCH or something, and then
|
|
1728
|
+
* exit, it'll end up firing `process.emit('exit')`, so
|
|
1729
|
+
* the handler will be fired anyway.
|
|
1730
|
+
*
|
|
1731
|
+
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
1732
|
+
* artificially, inherently leave the process in a
|
|
1733
|
+
* state from which it is not safe to try and enter JS
|
|
1734
|
+
* listeners.
|
|
1735
|
+
*/
|
|
1736
|
+
var signals = [];
|
|
1737
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
1738
|
+
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
1739
|
+
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
1740
|
+
//#endregion
|
|
1741
|
+
//#region node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
1742
|
+
var processOk = (process) => !!process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
|
|
1743
|
+
var kExitEmitter = Symbol.for("signal-exit emitter");
|
|
1744
|
+
var global = globalThis;
|
|
1745
|
+
var ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
1746
|
+
var Emitter = class {
|
|
1747
|
+
emitted = {
|
|
1748
|
+
afterExit: false,
|
|
1749
|
+
exit: false
|
|
1750
|
+
};
|
|
1751
|
+
listeners = {
|
|
1752
|
+
afterExit: [],
|
|
1753
|
+
exit: []
|
|
1754
|
+
};
|
|
1755
|
+
count = 0;
|
|
1756
|
+
id = Math.random();
|
|
1757
|
+
constructor() {
|
|
1758
|
+
if (global[kExitEmitter]) return global[kExitEmitter];
|
|
1759
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
1760
|
+
value: this,
|
|
1761
|
+
writable: false,
|
|
1762
|
+
enumerable: false,
|
|
1763
|
+
configurable: false
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
on(ev, fn) {
|
|
1767
|
+
this.listeners[ev].push(fn);
|
|
1768
|
+
}
|
|
1769
|
+
removeListener(ev, fn) {
|
|
1770
|
+
const list = this.listeners[ev];
|
|
1771
|
+
const i = list.indexOf(fn);
|
|
1772
|
+
/* c8 ignore start */
|
|
1773
|
+
if (i === -1) return;
|
|
1774
|
+
/* c8 ignore stop */
|
|
1775
|
+
if (i === 0 && list.length === 1) list.length = 0;
|
|
1776
|
+
else list.splice(i, 1);
|
|
1777
|
+
}
|
|
1778
|
+
emit(ev, code, signal) {
|
|
1779
|
+
if (this.emitted[ev]) return false;
|
|
1780
|
+
this.emitted[ev] = true;
|
|
1781
|
+
let ret = false;
|
|
1782
|
+
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
|
|
1783
|
+
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
|
|
1784
|
+
return ret;
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
var SignalExitBase = class {};
|
|
1788
|
+
var signalExitWrap = (handler) => {
|
|
1789
|
+
return {
|
|
1790
|
+
onExit(cb, opts) {
|
|
1791
|
+
return handler.onExit(cb, opts);
|
|
1792
|
+
},
|
|
1793
|
+
load() {
|
|
1794
|
+
return handler.load();
|
|
1795
|
+
},
|
|
1796
|
+
unload() {
|
|
1797
|
+
return handler.unload();
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
};
|
|
1801
|
+
var SignalExitFallback = class extends SignalExitBase {
|
|
1802
|
+
onExit() {
|
|
1803
|
+
return () => {};
|
|
1804
|
+
}
|
|
1805
|
+
load() {}
|
|
1806
|
+
unload() {}
|
|
1807
|
+
};
|
|
1808
|
+
var SignalExit = class extends SignalExitBase {
|
|
1809
|
+
/* c8 ignore start */
|
|
1810
|
+
#hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
1811
|
+
/* c8 ignore stop */
|
|
1812
|
+
#emitter = new Emitter();
|
|
1813
|
+
#process;
|
|
1814
|
+
#originalProcessEmit;
|
|
1815
|
+
#originalProcessReallyExit;
|
|
1816
|
+
#sigListeners = {};
|
|
1817
|
+
#loaded = false;
|
|
1818
|
+
constructor(process) {
|
|
1819
|
+
super();
|
|
1820
|
+
this.#process = process;
|
|
1821
|
+
this.#sigListeners = {};
|
|
1822
|
+
for (const sig of signals) this.#sigListeners[sig] = () => {
|
|
1823
|
+
const listeners = this.#process.listeners(sig);
|
|
1824
|
+
let { count } = this.#emitter;
|
|
1825
|
+
/* c8 ignore start */
|
|
1826
|
+
const p = process;
|
|
1827
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
|
|
1828
|
+
/* c8 ignore stop */
|
|
1829
|
+
if (listeners.length === count) {
|
|
1830
|
+
this.unload();
|
|
1831
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
1832
|
+
/* c8 ignore start */
|
|
1833
|
+
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
1834
|
+
if (!ret) process.kill(process.pid, s);
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
this.#originalProcessReallyExit = process.reallyExit;
|
|
1838
|
+
this.#originalProcessEmit = process.emit;
|
|
1839
|
+
}
|
|
1840
|
+
onExit(cb, opts) {
|
|
1841
|
+
/* c8 ignore start */
|
|
1842
|
+
if (!processOk(this.#process)) return () => {};
|
|
1843
|
+
/* c8 ignore stop */
|
|
1844
|
+
if (this.#loaded === false) this.load();
|
|
1845
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
1846
|
+
this.#emitter.on(ev, cb);
|
|
1847
|
+
return () => {
|
|
1848
|
+
this.#emitter.removeListener(ev, cb);
|
|
1849
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
|
|
1850
|
+
};
|
|
1851
|
+
}
|
|
1852
|
+
load() {
|
|
1853
|
+
if (this.#loaded) return;
|
|
1854
|
+
this.#loaded = true;
|
|
1855
|
+
this.#emitter.count += 1;
|
|
1856
|
+
for (const sig of signals) try {
|
|
1857
|
+
const fn = this.#sigListeners[sig];
|
|
1858
|
+
if (fn) this.#process.on(sig, fn);
|
|
1859
|
+
} catch (_) {}
|
|
1860
|
+
this.#process.emit = (ev, ...a) => {
|
|
1861
|
+
return this.#processEmit(ev, ...a);
|
|
1862
|
+
};
|
|
1863
|
+
this.#process.reallyExit = (code) => {
|
|
1864
|
+
return this.#processReallyExit(code);
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
unload() {
|
|
1868
|
+
if (!this.#loaded) return;
|
|
1869
|
+
this.#loaded = false;
|
|
1870
|
+
signals.forEach((sig) => {
|
|
1871
|
+
const listener = this.#sigListeners[sig];
|
|
1872
|
+
/* c8 ignore start */
|
|
1873
|
+
if (!listener) throw new Error("Listener not defined for signal: " + sig);
|
|
1874
|
+
/* c8 ignore stop */
|
|
1875
|
+
try {
|
|
1876
|
+
this.#process.removeListener(sig, listener);
|
|
1877
|
+
} catch (_) {}
|
|
1878
|
+
/* c8 ignore stop */
|
|
1879
|
+
});
|
|
1880
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
1881
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
1882
|
+
this.#emitter.count -= 1;
|
|
1883
|
+
}
|
|
1884
|
+
#processReallyExit(code) {
|
|
1885
|
+
/* c8 ignore start */
|
|
1886
|
+
if (!processOk(this.#process)) return 0;
|
|
1887
|
+
this.#process.exitCode = code || 0;
|
|
1888
|
+
/* c8 ignore stop */
|
|
1889
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1890
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
1891
|
+
}
|
|
1892
|
+
#processEmit(ev, ...args) {
|
|
1893
|
+
const og = this.#originalProcessEmit;
|
|
1894
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
1895
|
+
if (typeof args[0] === "number") this.#process.exitCode = args[0];
|
|
1896
|
+
/* c8 ignore start */
|
|
1897
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
1898
|
+
/* c8 ignore start */
|
|
1899
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1900
|
+
/* c8 ignore stop */
|
|
1901
|
+
return ret;
|
|
1902
|
+
} else return og.call(this.#process, ev, ...args);
|
|
1903
|
+
}
|
|
1904
|
+
};
|
|
1905
|
+
var process$1 = globalThis.process;
|
|
1906
|
+
var { onExit, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
|
|
1907
|
+
//#endregion
|
|
1908
|
+
//#region node_modules/.pnpm/@inquirer+ansi@2.0.4/node_modules/@inquirer/ansi/dist/index.js
|
|
1909
|
+
var ESC = "\x1B[";
|
|
1910
|
+
ESC + "";
|
|
1911
|
+
/** Hide the cursor */
|
|
1912
|
+
var cursorHide = ESC + "?25l";
|
|
1913
|
+
/** Show the cursor */
|
|
1914
|
+
var cursorShow = ESC + "?25h";
|
|
1915
|
+
/** Move cursor up by count rows */
|
|
1916
|
+
var cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
|
|
1917
|
+
/** Move cursor down by count rows */
|
|
1918
|
+
var cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
|
|
1919
|
+
/** Move cursor to position (x, y) */
|
|
1920
|
+
var cursorTo = (x, y) => {
|
|
1921
|
+
if (typeof y === "number" && !Number.isNaN(y)) return `${ESC}${y + 1};${x + 1}H`;
|
|
1922
|
+
return `${ESC}${x + 1}G`;
|
|
1923
|
+
};
|
|
1924
|
+
var eraseLine = ESC + "2K";
|
|
1925
|
+
/** Erase the specified number of lines above the cursor */
|
|
1926
|
+
var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + "\x1B[G" : "";
|
|
1927
|
+
//#endregion
|
|
1928
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
1929
|
+
var height = (content) => content.split("\n").length;
|
|
1930
|
+
var lastLine = (content) => content.split("\n").pop() ?? "";
|
|
1931
|
+
var ScreenManager = class {
|
|
1932
|
+
height = 0;
|
|
1933
|
+
extraLinesUnderPrompt = 0;
|
|
1934
|
+
cursorPos;
|
|
1935
|
+
rl;
|
|
1936
|
+
constructor(rl) {
|
|
1937
|
+
this.rl = rl;
|
|
1938
|
+
this.cursorPos = rl.getCursorPos();
|
|
1939
|
+
}
|
|
1940
|
+
write(content) {
|
|
1941
|
+
this.rl.output.unmute();
|
|
1942
|
+
this.rl.output.write(content);
|
|
1943
|
+
this.rl.output.mute();
|
|
1944
|
+
}
|
|
1945
|
+
render(content, bottomContent = "") {
|
|
1946
|
+
const rawPromptLine = (0, node_util.stripVTControlCharacters)(lastLine(content));
|
|
1947
|
+
let prompt = rawPromptLine;
|
|
1948
|
+
if (this.rl.line.length > 0) prompt = prompt.slice(0, -this.rl.line.length);
|
|
1949
|
+
this.rl.setPrompt(prompt);
|
|
1950
|
+
this.cursorPos = this.rl.getCursorPos();
|
|
1951
|
+
const width = readlineWidth();
|
|
1952
|
+
content = breakLines(content, width);
|
|
1953
|
+
bottomContent = breakLines(bottomContent, width);
|
|
1954
|
+
if (rawPromptLine.length % width === 0) content += "\n";
|
|
1955
|
+
let output = content + (bottomContent ? "\n" + bottomContent : "");
|
|
1956
|
+
const bottomContentHeight = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows + (bottomContent ? height(bottomContent) : 0);
|
|
1957
|
+
if (bottomContentHeight > 0) output += cursorUp(bottomContentHeight);
|
|
1958
|
+
output += cursorTo(this.cursorPos.cols);
|
|
1959
|
+
/**
|
|
1960
|
+
* Render and store state for future re-rendering
|
|
1961
|
+
*/
|
|
1962
|
+
this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
|
|
1963
|
+
this.extraLinesUnderPrompt = bottomContentHeight;
|
|
1964
|
+
this.height = height(output);
|
|
1965
|
+
}
|
|
1966
|
+
checkCursorPos() {
|
|
1967
|
+
const cursorPos = this.rl.getCursorPos();
|
|
1968
|
+
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
1969
|
+
this.write(cursorTo(cursorPos.cols));
|
|
1970
|
+
this.cursorPos = cursorPos;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
done({ clearContent }) {
|
|
1974
|
+
this.rl.setPrompt("");
|
|
1975
|
+
let output = cursorDown(this.extraLinesUnderPrompt);
|
|
1976
|
+
output += clearContent ? eraseLines(this.height) : "\n";
|
|
1977
|
+
output += cursorShow;
|
|
1978
|
+
this.write(output);
|
|
1979
|
+
this.rl.close();
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1982
|
+
//#endregion
|
|
1983
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
1984
|
+
var PromisePolyfill = class extends Promise {
|
|
1985
|
+
static withResolver() {
|
|
1986
|
+
let resolve;
|
|
1987
|
+
let reject;
|
|
1988
|
+
return {
|
|
1989
|
+
promise: new Promise((res, rej) => {
|
|
1990
|
+
resolve = res;
|
|
1991
|
+
reject = rej;
|
|
1992
|
+
}),
|
|
1993
|
+
resolve,
|
|
1994
|
+
reject
|
|
1995
|
+
};
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
//#endregion
|
|
1999
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
2000
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
2001
|
+
var nativeSetImmediate = globalThis.setImmediate;
|
|
2002
|
+
function getCallSites() {
|
|
2003
|
+
const _prepareStackTrace = Error.prepareStackTrace;
|
|
2004
|
+
let result = [];
|
|
2005
|
+
try {
|
|
2006
|
+
Error.prepareStackTrace = (_, callSites) => {
|
|
2007
|
+
const callSitesWithoutCurrent = callSites.slice(1);
|
|
2008
|
+
result = callSitesWithoutCurrent;
|
|
2009
|
+
return callSitesWithoutCurrent;
|
|
2010
|
+
};
|
|
2011
|
+
(/* @__PURE__ */ new Error()).stack;
|
|
2012
|
+
} catch {
|
|
2013
|
+
return result;
|
|
2014
|
+
}
|
|
2015
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
|
2016
|
+
return result;
|
|
2017
|
+
}
|
|
2018
|
+
function createPrompt(view) {
|
|
2019
|
+
const callSites = getCallSites();
|
|
2020
|
+
const prompt = (config, context = {}) => {
|
|
2021
|
+
const { input = process.stdin, signal } = context;
|
|
2022
|
+
const cleanups = /* @__PURE__ */ new Set();
|
|
2023
|
+
const output = new import_lib.default();
|
|
2024
|
+
output.pipe(context.output ?? process.stdout);
|
|
2025
|
+
output.mute();
|
|
2026
|
+
const rl = import___vite_browser_external.createInterface({
|
|
2027
|
+
terminal: true,
|
|
2028
|
+
input,
|
|
2029
|
+
output
|
|
2030
|
+
});
|
|
2031
|
+
const screen = new ScreenManager(rl);
|
|
2032
|
+
const { promise, resolve, reject } = PromisePolyfill.withResolver();
|
|
2033
|
+
const cancel = () => reject(new CancelPromptError());
|
|
2034
|
+
if (signal) {
|
|
2035
|
+
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
2036
|
+
if (signal.aborted) {
|
|
2037
|
+
abort();
|
|
2038
|
+
return Object.assign(promise, { cancel });
|
|
2039
|
+
}
|
|
2040
|
+
signal.addEventListener("abort", abort);
|
|
2041
|
+
cleanups.add(() => signal.removeEventListener("abort", abort));
|
|
2042
|
+
}
|
|
2043
|
+
cleanups.add(onExit((code, signal) => {
|
|
2044
|
+
reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal}`));
|
|
2045
|
+
}));
|
|
2046
|
+
const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
|
|
2047
|
+
rl.on("SIGINT", sigint);
|
|
2048
|
+
cleanups.add(() => rl.removeListener("SIGINT", sigint));
|
|
2049
|
+
return withHooks(rl, (cycle) => {
|
|
2050
|
+
const hooksCleanup = import___vite_browser_external.AsyncResource.bind(() => effectScheduler.clearAll());
|
|
2051
|
+
rl.on("close", hooksCleanup);
|
|
2052
|
+
cleanups.add(() => rl.removeListener("close", hooksCleanup));
|
|
2053
|
+
const startCycle = () => {
|
|
2054
|
+
const checkCursorPos = () => screen.checkCursorPos();
|
|
2055
|
+
rl.input.on("keypress", checkCursorPos);
|
|
2056
|
+
cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
|
|
2057
|
+
cycle(() => {
|
|
2058
|
+
try {
|
|
2059
|
+
const nextView = view(config, (value) => {
|
|
2060
|
+
setImmediate(() => resolve(value));
|
|
2061
|
+
});
|
|
2062
|
+
if (nextView === void 0) {
|
|
2063
|
+
const callerFilename = callSites[1]?.getFileName();
|
|
2064
|
+
throw new Error(`Prompt functions must return a string.\n at ${callerFilename}`);
|
|
2065
|
+
}
|
|
2066
|
+
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
2067
|
+
screen.render(content, bottomContent);
|
|
2068
|
+
effectScheduler.run();
|
|
2069
|
+
} catch (error) {
|
|
2070
|
+
reject(error);
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
};
|
|
2074
|
+
if ("readableFlowing" in input) nativeSetImmediate(startCycle);
|
|
2075
|
+
else startCycle();
|
|
2076
|
+
return Object.assign(promise.then((answer) => {
|
|
2077
|
+
effectScheduler.clearAll();
|
|
2078
|
+
return answer;
|
|
2079
|
+
}, (error) => {
|
|
2080
|
+
effectScheduler.clearAll();
|
|
2081
|
+
throw error;
|
|
2082
|
+
}).finally(() => {
|
|
2083
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
2084
|
+
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
2085
|
+
output.end();
|
|
2086
|
+
}).then(() => promise), { cancel });
|
|
2087
|
+
});
|
|
2088
|
+
};
|
|
2089
|
+
return prompt;
|
|
2090
|
+
}
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/Separator.js
|
|
2093
|
+
/**
|
|
2094
|
+
* Separator object
|
|
2095
|
+
* Used to space/separate choices group
|
|
2096
|
+
*/
|
|
2097
|
+
var Separator = class {
|
|
2098
|
+
separator = (0, node_util.styleText)("dim", Array.from({ length: 15 }).join(figures.line));
|
|
2099
|
+
type = "separator";
|
|
2100
|
+
constructor(separator) {
|
|
2101
|
+
if (separator) this.separator = separator;
|
|
2102
|
+
}
|
|
2103
|
+
static isSeparator(choice) {
|
|
2104
|
+
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
//#endregion
|
|
2108
|
+
//#region node_modules/.pnpm/@inquirer+input@5.0.10_@types+node@25.5.0/node_modules/@inquirer/input/dist/index.js
|
|
2109
|
+
var inputTheme = { validationFailureMode: "keep" };
|
|
2110
|
+
var dist_default$1 = createPrompt((config, done) => {
|
|
2111
|
+
const { prefill = "tab" } = config;
|
|
2112
|
+
const theme = makeTheme(inputTheme, config.theme);
|
|
2113
|
+
const [status, setStatus] = useState("idle");
|
|
2114
|
+
const [defaultValue, setDefaultValue] = useState(String(config.default ?? ""));
|
|
2115
|
+
const [errorMsg, setError] = useState();
|
|
2116
|
+
const [value, setValue] = useState("");
|
|
2117
|
+
const prefix = usePrefix({
|
|
2118
|
+
status,
|
|
2119
|
+
theme
|
|
2120
|
+
});
|
|
2121
|
+
async function validate(value) {
|
|
2122
|
+
const { required, pattern, patternError = "Invalid input" } = config;
|
|
2123
|
+
if (required && !value) return "You must provide a value";
|
|
2124
|
+
if (pattern && !pattern.test(value)) return patternError;
|
|
2125
|
+
if (typeof config.validate === "function") return await config.validate(value) || "You must provide a valid value";
|
|
2126
|
+
return true;
|
|
2127
|
+
}
|
|
2128
|
+
useKeypress(async (key, rl) => {
|
|
2129
|
+
if (status !== "idle") return;
|
|
2130
|
+
if (isEnterKey(key)) {
|
|
2131
|
+
const answer = value || defaultValue;
|
|
2132
|
+
setStatus("loading");
|
|
2133
|
+
const isValid = await validate(answer);
|
|
2134
|
+
if (isValid === true) {
|
|
2135
|
+
setValue(answer);
|
|
2136
|
+
setStatus("done");
|
|
2137
|
+
done(answer);
|
|
2138
|
+
} else {
|
|
2139
|
+
if (theme.validationFailureMode === "clear") setValue("");
|
|
2140
|
+
else rl.write(value);
|
|
2141
|
+
setError(isValid);
|
|
2142
|
+
setStatus("idle");
|
|
2143
|
+
}
|
|
2144
|
+
} else if (isBackspaceKey(key) && !value) setDefaultValue("");
|
|
2145
|
+
else if (isTabKey(key) && !value) {
|
|
2146
|
+
setDefaultValue("");
|
|
2147
|
+
rl.clearLine(0);
|
|
2148
|
+
rl.write(defaultValue);
|
|
2149
|
+
setValue(defaultValue);
|
|
2150
|
+
} else {
|
|
2151
|
+
setValue(rl.line);
|
|
2152
|
+
setError(void 0);
|
|
2153
|
+
}
|
|
2154
|
+
});
|
|
2155
|
+
useEffect((rl) => {
|
|
2156
|
+
if (prefill === "editable" && defaultValue) {
|
|
2157
|
+
rl.write(defaultValue);
|
|
2158
|
+
setValue(defaultValue);
|
|
2159
|
+
}
|
|
2160
|
+
}, []);
|
|
2161
|
+
const message = theme.style.message(config.message, status);
|
|
2162
|
+
let formattedValue = value;
|
|
2163
|
+
if (typeof config.transformer === "function") formattedValue = config.transformer(value, { isFinal: status === "done" });
|
|
2164
|
+
else if (status === "done") formattedValue = theme.style.answer(value);
|
|
2165
|
+
let defaultStr;
|
|
2166
|
+
if (defaultValue && status !== "done" && !value) defaultStr = theme.style.defaultAnswer(defaultValue);
|
|
2167
|
+
let error = "";
|
|
2168
|
+
if (errorMsg) error = theme.style.error(errorMsg);
|
|
2169
|
+
return [[
|
|
2170
|
+
prefix,
|
|
2171
|
+
message,
|
|
2172
|
+
defaultStr,
|
|
2173
|
+
formattedValue
|
|
2174
|
+
].filter((v) => v !== void 0).join(" "), error];
|
|
2175
|
+
});
|
|
2176
|
+
//#endregion
|
|
2177
|
+
//#region node_modules/.pnpm/@inquirer+select@5.1.2_@types+node@25.5.0/node_modules/@inquirer/select/dist/index.js
|
|
2178
|
+
var selectTheme = {
|
|
2179
|
+
icon: { cursor: figures.pointer },
|
|
2180
|
+
style: {
|
|
2181
|
+
disabled: (text) => (0, node_util.styleText)("dim", text),
|
|
2182
|
+
description: (text) => (0, node_util.styleText)("cyan", text),
|
|
2183
|
+
keysHelpTip: (keys) => keys.map(([key, action]) => `${(0, node_util.styleText)("bold", key)} ${(0, node_util.styleText)("dim", action)}`).join((0, node_util.styleText)("dim", " • "))
|
|
2184
|
+
},
|
|
2185
|
+
i18n: { disabledError: "This option is disabled and cannot be selected." },
|
|
2186
|
+
indexMode: "hidden",
|
|
2187
|
+
keybindings: []
|
|
2188
|
+
};
|
|
2189
|
+
function isSelectable(item) {
|
|
2190
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
|
2191
|
+
}
|
|
2192
|
+
function isNavigable(item) {
|
|
2193
|
+
return !Separator.isSeparator(item);
|
|
2194
|
+
}
|
|
2195
|
+
function normalizeChoices(choices) {
|
|
2196
|
+
return choices.map((choice) => {
|
|
2197
|
+
if (Separator.isSeparator(choice)) return choice;
|
|
2198
|
+
if (typeof choice !== "object" || choice === null || !("value" in choice)) {
|
|
2199
|
+
const name = String(choice);
|
|
2200
|
+
return {
|
|
2201
|
+
value: choice,
|
|
2202
|
+
name,
|
|
2203
|
+
short: name,
|
|
2204
|
+
disabled: false
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
const name = choice.name ?? String(choice.value);
|
|
2208
|
+
const normalizedChoice = {
|
|
2209
|
+
value: choice.value,
|
|
2210
|
+
name,
|
|
2211
|
+
short: choice.short ?? name,
|
|
2212
|
+
disabled: choice.disabled ?? false
|
|
2213
|
+
};
|
|
2214
|
+
if (choice.description) normalizedChoice.description = choice.description;
|
|
2215
|
+
return normalizedChoice;
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
var dist_default = createPrompt((config, done) => {
|
|
2219
|
+
const { loop = true, pageSize = 7 } = config;
|
|
2220
|
+
const theme = makeTheme(selectTheme, config.theme);
|
|
2221
|
+
const { keybindings } = theme;
|
|
2222
|
+
const [status, setStatus] = useState("idle");
|
|
2223
|
+
const prefix = usePrefix({
|
|
2224
|
+
status,
|
|
2225
|
+
theme
|
|
2226
|
+
});
|
|
2227
|
+
const searchTimeoutRef = useRef();
|
|
2228
|
+
const searchEnabled = !keybindings.includes("vim");
|
|
2229
|
+
const items = useMemo(() => normalizeChoices(config.choices), [config.choices]);
|
|
2230
|
+
const bounds = useMemo(() => {
|
|
2231
|
+
const first = items.findIndex(isNavigable);
|
|
2232
|
+
const last = items.findLastIndex(isNavigable);
|
|
2233
|
+
if (first === -1) throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
|
|
2234
|
+
return {
|
|
2235
|
+
first,
|
|
2236
|
+
last
|
|
2237
|
+
};
|
|
2238
|
+
}, [items]);
|
|
2239
|
+
const defaultItemIndex = useMemo(() => {
|
|
2240
|
+
if (!("default" in config)) return -1;
|
|
2241
|
+
return items.findIndex((item) => isSelectable(item) && item.value === config.default);
|
|
2242
|
+
}, [config.default, items]);
|
|
2243
|
+
const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
|
|
2244
|
+
const selectedChoice = items[active];
|
|
2245
|
+
const [errorMsg, setError] = useState();
|
|
2246
|
+
useKeypress((key, rl) => {
|
|
2247
|
+
clearTimeout(searchTimeoutRef.current);
|
|
2248
|
+
if (errorMsg) setError(void 0);
|
|
2249
|
+
if (isEnterKey(key)) if (selectedChoice.disabled) setError(theme.i18n.disabledError);
|
|
2250
|
+
else {
|
|
2251
|
+
setStatus("done");
|
|
2252
|
+
done(selectedChoice.value);
|
|
2253
|
+
}
|
|
2254
|
+
else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
|
|
2255
|
+
rl.clearLine(0);
|
|
2256
|
+
if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
|
|
2257
|
+
const offset = isUpKey(key, keybindings) ? -1 : 1;
|
|
2258
|
+
let next = active;
|
|
2259
|
+
do
|
|
2260
|
+
next = (next + offset + items.length) % items.length;
|
|
2261
|
+
while (!isNavigable(items[next]));
|
|
2262
|
+
setActive(next);
|
|
2263
|
+
}
|
|
2264
|
+
} else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
|
|
2265
|
+
const selectedIndex = Number(rl.line) - 1;
|
|
2266
|
+
let selectableIndex = -1;
|
|
2267
|
+
const position = items.findIndex((item) => {
|
|
2268
|
+
if (Separator.isSeparator(item)) return false;
|
|
2269
|
+
selectableIndex++;
|
|
2270
|
+
return selectableIndex === selectedIndex;
|
|
2271
|
+
});
|
|
2272
|
+
const item = items[position];
|
|
2273
|
+
if (item != null && isSelectable(item)) setActive(position);
|
|
2274
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
2275
|
+
rl.clearLine(0);
|
|
2276
|
+
}, 700);
|
|
2277
|
+
} else if (isBackspaceKey(key)) rl.clearLine(0);
|
|
2278
|
+
else if (searchEnabled) {
|
|
2279
|
+
const searchTerm = rl.line.toLowerCase();
|
|
2280
|
+
const matchIndex = items.findIndex((item) => {
|
|
2281
|
+
if (Separator.isSeparator(item) || !isSelectable(item)) return false;
|
|
2282
|
+
return item.name.toLowerCase().startsWith(searchTerm);
|
|
2283
|
+
});
|
|
2284
|
+
if (matchIndex !== -1) setActive(matchIndex);
|
|
2285
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
2286
|
+
rl.clearLine(0);
|
|
2287
|
+
}, 700);
|
|
2288
|
+
}
|
|
2289
|
+
});
|
|
2290
|
+
useEffect(() => () => {
|
|
2291
|
+
clearTimeout(searchTimeoutRef.current);
|
|
2292
|
+
}, []);
|
|
2293
|
+
const message = theme.style.message(config.message, status);
|
|
2294
|
+
const helpLine = theme.style.keysHelpTip([["↑↓", "navigate"], ["⏎", "select"]]);
|
|
2295
|
+
let separatorCount = 0;
|
|
2296
|
+
const page = usePagination({
|
|
2297
|
+
items,
|
|
2298
|
+
active,
|
|
2299
|
+
renderItem({ item, isActive, index }) {
|
|
2300
|
+
if (Separator.isSeparator(item)) {
|
|
2301
|
+
separatorCount++;
|
|
2302
|
+
return ` ${item.separator}`;
|
|
2303
|
+
}
|
|
2304
|
+
const cursor = isActive ? theme.icon.cursor : " ";
|
|
2305
|
+
const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
|
|
2306
|
+
if (item.disabled) {
|
|
2307
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
2308
|
+
const disabledCursor = isActive ? theme.icon.cursor : "-";
|
|
2309
|
+
return theme.style.disabled(`${disabledCursor} ${indexLabel}${item.name} ${disabledLabel}`);
|
|
2310
|
+
}
|
|
2311
|
+
return (isActive ? theme.style.highlight : (x) => x)(`${cursor} ${indexLabel}${item.name}`);
|
|
2312
|
+
},
|
|
2313
|
+
pageSize,
|
|
2314
|
+
loop
|
|
2315
|
+
});
|
|
2316
|
+
if (status === "done") return [
|
|
2317
|
+
prefix,
|
|
2318
|
+
message,
|
|
2319
|
+
theme.style.answer(selectedChoice.short)
|
|
2320
|
+
].filter(Boolean).join(" ");
|
|
2321
|
+
const { description } = selectedChoice;
|
|
2322
|
+
return `${[
|
|
2323
|
+
[prefix, message].filter(Boolean).join(" "),
|
|
2324
|
+
page,
|
|
2325
|
+
" ",
|
|
2326
|
+
description ? theme.style.description(description) : "",
|
|
2327
|
+
errorMsg ? theme.style.error(errorMsg) : "",
|
|
2328
|
+
helpLine
|
|
2329
|
+
].filter(Boolean).join("\n").trimEnd()}${cursorHide}`;
|
|
2330
|
+
});
|
|
2331
|
+
//#endregion
|
|
2332
|
+
//#region src/prompts.ts
|
|
2333
|
+
/** Prompts the user for a scaffold name. */
|
|
2334
|
+
async function promptForName() {
|
|
2335
|
+
return dist_default$1({
|
|
2336
|
+
message: colorize.cyan("Scaffold name:"),
|
|
2337
|
+
required: true,
|
|
2338
|
+
validate: (value) => {
|
|
2339
|
+
if (!value.trim()) return "Name cannot be empty";
|
|
2340
|
+
return true;
|
|
2341
|
+
}
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
/** Prompts the user to select a template key from the available config keys. */
|
|
2345
|
+
async function promptForTemplateKey(configMap) {
|
|
2346
|
+
const keys = Object.keys(configMap);
|
|
2347
|
+
if (keys.length === 0) throw new Error("No templates found in config file");
|
|
2348
|
+
if (keys.length === 1) return keys[0];
|
|
2349
|
+
return dist_default({
|
|
2350
|
+
message: colorize.cyan("Select a template:"),
|
|
2351
|
+
choices: keys.map((key) => ({
|
|
2352
|
+
name: key,
|
|
2353
|
+
value: key
|
|
2354
|
+
}))
|
|
2355
|
+
});
|
|
2356
|
+
}
|
|
2357
|
+
/** Prompts the user for an output directory path. */
|
|
2358
|
+
async function promptForOutput() {
|
|
2359
|
+
return dist_default$1({
|
|
2360
|
+
message: colorize.cyan("Output directory:"),
|
|
2361
|
+
required: true,
|
|
2362
|
+
default: ".",
|
|
2363
|
+
validate: (value) => {
|
|
2364
|
+
if (!value.trim()) return "Output directory cannot be empty";
|
|
2365
|
+
return true;
|
|
2366
|
+
}
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
/** Prompts the user for template paths (comma-separated). */
|
|
2370
|
+
async function promptForTemplates() {
|
|
2371
|
+
return (await dist_default$1({
|
|
2372
|
+
message: colorize.cyan("Template paths (comma-separated):"),
|
|
2373
|
+
required: true,
|
|
2374
|
+
validate: (value) => {
|
|
2375
|
+
if (!value.trim()) return "At least one template path is required";
|
|
2376
|
+
return true;
|
|
2377
|
+
}
|
|
2378
|
+
})).split(",").map((t) => t.trim()).filter(Boolean);
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Prompts the user for any required scaffold inputs that are not already provided in data.
|
|
2382
|
+
* Also applies default values for optional inputs that have one.
|
|
2383
|
+
* Returns the merged data object.
|
|
2384
|
+
*/
|
|
2385
|
+
async function promptForInputs(inputs, existingData = {}) {
|
|
2386
|
+
const data = { ...existingData };
|
|
2387
|
+
for (const [key, def] of Object.entries(inputs)) {
|
|
2388
|
+
if (key in data && data[key] !== void 0 && data[key] !== "") continue;
|
|
2389
|
+
if (def.required) data[key] = await dist_default$1({
|
|
2390
|
+
message: colorize.cyan(def.message ?? `${key}:`),
|
|
2391
|
+
required: true,
|
|
2392
|
+
default: def.default,
|
|
2393
|
+
validate: (value) => {
|
|
2394
|
+
if (!value.trim()) return `${key} is required`;
|
|
2395
|
+
return true;
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
else if (def.default !== void 0 && !(key in data)) data[key] = def.default;
|
|
2399
|
+
}
|
|
2400
|
+
return data;
|
|
2401
|
+
}
|
|
2402
|
+
/** Returns true if the process is running in an interactive terminal. */
|
|
2403
|
+
function isInteractive() {
|
|
2404
|
+
return Boolean(process.stdin.isTTY);
|
|
2405
|
+
}
|
|
2406
|
+
/**
|
|
2407
|
+
* Fills in missing config values by prompting the user interactively.
|
|
2408
|
+
* Only prompts when running in a TTY — in non-interactive mode, returns config as-is.
|
|
2409
|
+
*/
|
|
2410
|
+
async function promptForMissingConfig(config, configMap) {
|
|
2411
|
+
if (!isInteractive()) return config;
|
|
2412
|
+
if (!config.name) config.name = await promptForName();
|
|
2413
|
+
if (configMap && !config.key) {
|
|
2414
|
+
if (Object.keys(configMap).length > 1) config.key = await promptForTemplateKey(configMap);
|
|
2415
|
+
}
|
|
2416
|
+
if (!config.output) config.output = await promptForOutput();
|
|
2417
|
+
if (!config.templates || config.templates.length === 0) config.templates = await promptForTemplates();
|
|
2418
|
+
return config;
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* Prompts for any required inputs defined in the scaffold config and merges them into data.
|
|
2422
|
+
* Only prompts in interactive mode; in non-interactive mode, only applies defaults.
|
|
2423
|
+
*/
|
|
2424
|
+
async function resolveInputs(config) {
|
|
2425
|
+
if (!config.inputs) return config;
|
|
2426
|
+
if (isInteractive()) config.data = await promptForInputs(config.inputs, config.data);
|
|
2427
|
+
else {
|
|
2428
|
+
const data = { ...config.data };
|
|
2429
|
+
for (const [key, def] of Object.entries(config.inputs)) if (def.default !== void 0 && !(key in data)) data[key] = def.default;
|
|
2430
|
+
config.data = data;
|
|
2431
|
+
}
|
|
2432
|
+
return config;
|
|
2433
|
+
}
|
|
2434
|
+
//#endregion
|
|
2435
|
+
//#region src/scaffold.ts
|
|
2436
|
+
/**
|
|
2437
|
+
* @module
|
|
2438
|
+
* Simple Scaffold
|
|
2439
|
+
*
|
|
2440
|
+
* See [readme](README.md)
|
|
2441
|
+
*/
|
|
2442
|
+
/**
|
|
2443
|
+
* Create a scaffold using given `options`.
|
|
2444
|
+
*
|
|
2445
|
+
* #### Create files
|
|
2446
|
+
* To create a file structure to output, use any directory and file structure you would like.
|
|
2447
|
+
* Inside folder names, file names or file contents, you may place `{{ var }}` where `var` is either
|
|
2448
|
+
* `name` which is the scaffold name you provided or one of the keys you provided in the `data` option.
|
|
2449
|
+
*
|
|
2450
|
+
* The contents and names will be replaced with the transformed values so you can use your original structure as a
|
|
2451
|
+
* boilerplate for other projects, components, modules, or even single files.
|
|
2452
|
+
*
|
|
2453
|
+
* The files will maintain their structure, starting from the directory containing the template (or the template itself
|
|
2454
|
+
* if it is already a directory), and will output from that directory into the directory defined by `config.output`.
|
|
2455
|
+
*
|
|
2456
|
+
* #### Helpers
|
|
2457
|
+
* Helpers are functions you can use to transform your `{{ var }}` contents into other values without having to
|
|
2458
|
+
* pre-define the data and use a duplicated key.
|
|
2459
|
+
*
|
|
2460
|
+
* Any functions you provide in `helpers` option will also be available to you to make custom formatting as you see fit
|
|
2461
|
+
* (for example, formatting a date)
|
|
2462
|
+
*
|
|
2463
|
+
* For available default values, see {@link DefaultHelpers}.
|
|
2464
|
+
*
|
|
2465
|
+
* @param {ScaffoldConfig} config The main configuration object
|
|
2466
|
+
* @return {Promise<void>} A promise that resolves when the scaffold is complete
|
|
2467
|
+
*
|
|
2468
|
+
* @see {@link DefaultHelpers}
|
|
2469
|
+
* @see {@link CaseHelpers}
|
|
2470
|
+
* @see {@link DateHelpers}
|
|
2471
|
+
*
|
|
2472
|
+
* @category Main
|
|
2473
|
+
*/
|
|
2474
|
+
async function Scaffold(config) {
|
|
2475
|
+
config.output ??= process.cwd();
|
|
2476
|
+
config = await resolveInputs(config);
|
|
2477
|
+
registerHelpers(config);
|
|
2478
|
+
try {
|
|
2479
|
+
config.data = {
|
|
2480
|
+
name: config.name,
|
|
2481
|
+
...config.data
|
|
2482
|
+
};
|
|
2483
|
+
logInitStep(config);
|
|
2484
|
+
const excludes = config.templates.filter((t) => t.startsWith("!"));
|
|
2485
|
+
const includes = config.templates.filter((t) => !t.startsWith("!"));
|
|
2486
|
+
const templates = await resolveTemplateGlobs(config, includes);
|
|
2487
|
+
for (const tpl of templates) await processTemplateGlob(config, tpl, excludes);
|
|
2488
|
+
} catch (e) {
|
|
2489
|
+
log(config, LogLevel.error, e);
|
|
2490
|
+
throw e;
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
/** Resolves included template paths into GlobInfo objects. */
|
|
2494
|
+
async function resolveTemplateGlobs(config, includes) {
|
|
2495
|
+
const templates = [];
|
|
2496
|
+
for (const includedTemplate of includes) try {
|
|
2497
|
+
templates.push(await getTemplateGlobInfo(config, includedTemplate));
|
|
2498
|
+
} catch (e) {
|
|
2499
|
+
handleErr(e);
|
|
2500
|
+
}
|
|
2501
|
+
return templates;
|
|
2502
|
+
}
|
|
2503
|
+
/** Processes all files matching a single template glob pattern. */
|
|
2504
|
+
async function processTemplateGlob(config, tpl, excludes) {
|
|
2505
|
+
const files = await getFileList(config, [tpl.template, ...excludes]);
|
|
2506
|
+
for (const file of files) {
|
|
2507
|
+
if (await isDir(file)) continue;
|
|
2508
|
+
log(config, LogLevel.debug, "Iterating files", {
|
|
2509
|
+
files,
|
|
2510
|
+
file
|
|
2511
|
+
});
|
|
2512
|
+
const relPath = makeRelativePath(node_path.default.dirname(removeGlob(file).replace(tpl.baseTemplatePath, "")));
|
|
2513
|
+
const basePath = getBasePath(relPath);
|
|
2514
|
+
log(config, LogLevel.debug, {
|
|
2515
|
+
originalTemplate: tpl.origTemplate,
|
|
2516
|
+
relativePath: relPath,
|
|
2517
|
+
parsedTemplate: tpl.template,
|
|
2518
|
+
inputFilePath: file,
|
|
2519
|
+
baseTemplatePath: tpl.baseTemplatePath,
|
|
2520
|
+
basePath,
|
|
2521
|
+
isDirOrGlob: tpl.isDirOrGlob,
|
|
2522
|
+
isGlob: tpl.isGlob
|
|
2523
|
+
});
|
|
2524
|
+
await handleTemplateFile(config, {
|
|
2525
|
+
templatePath: file,
|
|
2526
|
+
basePath
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
/**
|
|
2531
|
+
* Create a scaffold based on a config file or URL.
|
|
2532
|
+
*
|
|
2533
|
+
* @param {string} pathOrUrl The path or URL to the config file
|
|
2534
|
+
* @param {Record<string, string>} config Information needed before loading the config
|
|
2535
|
+
* @param {Partial<Omit<ScaffoldConfig, 'name'>>} overrides Any overrides to the loaded config
|
|
2536
|
+
*
|
|
2537
|
+
* @see {@link Scaffold}
|
|
2538
|
+
* @category Main
|
|
2539
|
+
* @return {Promise<void>} A promise that resolves when the scaffold is complete
|
|
2540
|
+
*/
|
|
2541
|
+
Scaffold.fromConfig = async function(pathOrUrl, config, overrides) {
|
|
2542
|
+
const tmpPath = node_path.default.resolve(node_os.default.tmpdir(), `scaffold-config-${Date.now()}`);
|
|
2543
|
+
const _cmdConfig = {
|
|
2544
|
+
dryRun: false,
|
|
2545
|
+
output: process.cwd(),
|
|
2546
|
+
logLevel: LogLevel.info,
|
|
2547
|
+
overwrite: false,
|
|
2548
|
+
templates: [],
|
|
2549
|
+
subdir: false,
|
|
2550
|
+
quiet: false,
|
|
2551
|
+
config: pathOrUrl,
|
|
2552
|
+
version: false,
|
|
2553
|
+
tmpDir: tmpPath,
|
|
2554
|
+
...config
|
|
2555
|
+
};
|
|
2556
|
+
const _overrides = resolve(overrides, _cmdConfig);
|
|
2557
|
+
return Scaffold({
|
|
2558
|
+
...await parseConfigFile(_cmdConfig),
|
|
2559
|
+
..._overrides
|
|
2560
|
+
});
|
|
2561
|
+
};
|
|
2562
|
+
//#endregion
|
|
2563
|
+
Object.defineProperty(exports, "LogLevel", {
|
|
2564
|
+
enumerable: true,
|
|
2565
|
+
get: function() {
|
|
2566
|
+
return LogLevel;
|
|
2567
|
+
}
|
|
2568
|
+
});
|
|
2569
|
+
Object.defineProperty(exports, "Scaffold", {
|
|
2570
|
+
enumerable: true,
|
|
2571
|
+
get: function() {
|
|
2572
|
+
return Scaffold;
|
|
2573
|
+
}
|
|
2574
|
+
});
|
|
2575
|
+
Object.defineProperty(exports, "__toESM", {
|
|
2576
|
+
enumerable: true,
|
|
2577
|
+
get: function() {
|
|
2578
|
+
return __toESM;
|
|
2579
|
+
}
|
|
2580
|
+
});
|
|
2581
|
+
Object.defineProperty(exports, "colorize", {
|
|
2582
|
+
enumerable: true,
|
|
2583
|
+
get: function() {
|
|
2584
|
+
return colorize;
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
Object.defineProperty(exports, "findConfigFile", {
|
|
2588
|
+
enumerable: true,
|
|
2589
|
+
get: function() {
|
|
2590
|
+
return findConfigFile;
|
|
2591
|
+
}
|
|
2592
|
+
});
|
|
2593
|
+
Object.defineProperty(exports, "getConfigFile", {
|
|
2594
|
+
enumerable: true,
|
|
2595
|
+
get: function() {
|
|
2596
|
+
return getConfigFile;
|
|
2597
|
+
}
|
|
2598
|
+
});
|
|
2599
|
+
Object.defineProperty(exports, "getUniqueTmpPath", {
|
|
2600
|
+
enumerable: true,
|
|
2601
|
+
get: function() {
|
|
2602
|
+
return getUniqueTmpPath;
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
Object.defineProperty(exports, "log", {
|
|
2606
|
+
enumerable: true,
|
|
2607
|
+
get: function() {
|
|
2608
|
+
return log;
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2611
|
+
Object.defineProperty(exports, "parseAppendData", {
|
|
2612
|
+
enumerable: true,
|
|
2613
|
+
get: function() {
|
|
2614
|
+
return parseAppendData;
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
Object.defineProperty(exports, "parseConfigFile", {
|
|
2618
|
+
enumerable: true,
|
|
2619
|
+
get: function() {
|
|
2620
|
+
return parseConfigFile;
|
|
2621
|
+
}
|
|
2622
|
+
});
|
|
2623
|
+
Object.defineProperty(exports, "promptForMissingConfig", {
|
|
2624
|
+
enumerable: true,
|
|
2625
|
+
get: function() {
|
|
2626
|
+
return promptForMissingConfig;
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
Object.defineProperty(exports, "resolveInputs", {
|
|
2630
|
+
enumerable: true,
|
|
2631
|
+
get: function() {
|
|
2632
|
+
return resolveInputs;
|
|
2633
|
+
}
|
|
2634
|
+
});
|
|
2635
|
+
|
|
2636
|
+
//# sourceMappingURL=scaffold-Ce-rIwy9.js.map
|