create-guren-app 1.0.0-rc.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1926 -34
- package/dist/prompt-NH7GB4RH.js +754 -0
- package/package.json +1 -2
- package/templates/api-only/config/database.ts +1 -3
- package/templates/api-only/package.json +9 -5
- package/templates/api-only/tsconfig.json +1 -1
- package/templates/default/.env.example +2 -1
- package/templates/default/.guren/api-client.gen.ts +1 -1
- package/templates/default/README.md +1 -1
- package/templates/default/app/Http/Controllers/HomeController.ts +1 -1
- package/templates/default/config/database.ts +1 -3
- package/templates/default/package.json +12 -8
- package/templates/default/resources/js/app.tsx +1 -1
- package/templates/default/tsconfig.json +1 -1
- package/templates/default-ssr/README.md +17 -0
- package/templates/default-ssr/resources/js/ssr.tsx +1 -1
- package/templates/default/.claude/agents/code-review.md +0 -130
- package/templates/default/.claude/agents/test-writer.md +0 -194
- package/templates/default/.claude/skills/db-manage/SKILL.md +0 -93
- package/templates/default/.claude/skills/dev-workflow/SKILL.md +0 -74
- package/templates/default/.claude/skills/feature/SKILL.md +0 -193
- package/templates/default/.claude/skills/guren-api/SKILL.md +0 -403
- package/templates/default/.claude/skills/scaffold/SKILL.md +0 -81
- package/templates/default/.mcp.json +0 -8
- package/templates/default/CLAUDE.md +0 -192
package/dist/cli.js
CHANGED
|
@@ -3,14 +3,1568 @@
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
5
5
|
import { relative as relative2, resolve } from "path";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import process3 from "process";
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/core.mjs
|
|
9
|
+
var LogLevels = {
|
|
10
|
+
silent: Number.NEGATIVE_INFINITY,
|
|
11
|
+
fatal: 0,
|
|
12
|
+
error: 0,
|
|
13
|
+
warn: 1,
|
|
14
|
+
log: 2,
|
|
15
|
+
info: 3,
|
|
16
|
+
success: 3,
|
|
17
|
+
fail: 3,
|
|
18
|
+
ready: 3,
|
|
19
|
+
start: 3,
|
|
20
|
+
box: 3,
|
|
21
|
+
debug: 4,
|
|
22
|
+
trace: 5,
|
|
23
|
+
verbose: Number.POSITIVE_INFINITY
|
|
24
|
+
};
|
|
25
|
+
var LogTypes = {
|
|
26
|
+
// Silent
|
|
27
|
+
silent: {
|
|
28
|
+
level: -1
|
|
29
|
+
},
|
|
30
|
+
// Level 0
|
|
31
|
+
fatal: {
|
|
32
|
+
level: LogLevels.fatal
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
level: LogLevels.error
|
|
36
|
+
},
|
|
37
|
+
// Level 1
|
|
38
|
+
warn: {
|
|
39
|
+
level: LogLevels.warn
|
|
40
|
+
},
|
|
41
|
+
// Level 2
|
|
42
|
+
log: {
|
|
43
|
+
level: LogLevels.log
|
|
44
|
+
},
|
|
45
|
+
// Level 3
|
|
46
|
+
info: {
|
|
47
|
+
level: LogLevels.info
|
|
48
|
+
},
|
|
49
|
+
success: {
|
|
50
|
+
level: LogLevels.success
|
|
51
|
+
},
|
|
52
|
+
fail: {
|
|
53
|
+
level: LogLevels.fail
|
|
54
|
+
},
|
|
55
|
+
ready: {
|
|
56
|
+
level: LogLevels.info
|
|
57
|
+
},
|
|
58
|
+
start: {
|
|
59
|
+
level: LogLevels.info
|
|
60
|
+
},
|
|
61
|
+
box: {
|
|
62
|
+
level: LogLevels.info
|
|
63
|
+
},
|
|
64
|
+
// Level 4
|
|
65
|
+
debug: {
|
|
66
|
+
level: LogLevels.debug
|
|
67
|
+
},
|
|
68
|
+
// Level 5
|
|
69
|
+
trace: {
|
|
70
|
+
level: LogLevels.trace
|
|
71
|
+
},
|
|
72
|
+
// Verbose
|
|
73
|
+
verbose: {
|
|
74
|
+
level: LogLevels.verbose
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function isPlainObject$1(value) {
|
|
78
|
+
if (value === null || typeof value !== "object") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const prototype = Object.getPrototypeOf(value);
|
|
82
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (Symbol.iterator in value) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (Symbol.toStringTag in value) {
|
|
89
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
94
|
+
if (!isPlainObject$1(defaults)) {
|
|
95
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
96
|
+
}
|
|
97
|
+
const object = Object.assign({}, defaults);
|
|
98
|
+
for (const key in baseObject) {
|
|
99
|
+
if (key === "__proto__" || key === "constructor") {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const value = baseObject[key];
|
|
103
|
+
if (value === null || value === void 0) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
110
|
+
object[key] = [...value, ...object[key]];
|
|
111
|
+
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
112
|
+
object[key] = _defu(
|
|
113
|
+
value,
|
|
114
|
+
object[key],
|
|
115
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
116
|
+
merger
|
|
117
|
+
);
|
|
118
|
+
} else {
|
|
119
|
+
object[key] = value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return object;
|
|
123
|
+
}
|
|
124
|
+
function createDefu(merger) {
|
|
125
|
+
return (...arguments_) => (
|
|
126
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
127
|
+
arguments_.reduce((p, c2) => _defu(p, c2, "", merger), {})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
var defu = createDefu();
|
|
131
|
+
function isPlainObject(obj) {
|
|
132
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
133
|
+
}
|
|
134
|
+
function isLogObj(arg) {
|
|
135
|
+
if (!isPlainObject(arg)) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if (!arg.message && !arg.args) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (arg.stack) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
var paused = false;
|
|
147
|
+
var queue = [];
|
|
148
|
+
var Consola = class _Consola {
|
|
149
|
+
options;
|
|
150
|
+
_lastLog;
|
|
151
|
+
_mockFn;
|
|
152
|
+
/**
|
|
153
|
+
* Creates an instance of Consola with specified options or defaults.
|
|
154
|
+
*
|
|
155
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
156
|
+
*/
|
|
157
|
+
constructor(options = {}) {
|
|
158
|
+
const types = options.types || LogTypes;
|
|
159
|
+
this.options = defu(
|
|
160
|
+
{
|
|
161
|
+
...options,
|
|
162
|
+
defaults: { ...options.defaults },
|
|
163
|
+
level: _normalizeLogLevel(options.level, types),
|
|
164
|
+
reporters: [...options.reporters || []]
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
types: LogTypes,
|
|
168
|
+
throttle: 1e3,
|
|
169
|
+
throttleMin: 5,
|
|
170
|
+
formatOptions: {
|
|
171
|
+
date: true,
|
|
172
|
+
colors: false,
|
|
173
|
+
compact: true
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
for (const type in types) {
|
|
178
|
+
const defaults = {
|
|
179
|
+
type,
|
|
180
|
+
...this.options.defaults,
|
|
181
|
+
...types[type]
|
|
182
|
+
};
|
|
183
|
+
this[type] = this._wrapLogFn(defaults);
|
|
184
|
+
this[type].raw = this._wrapLogFn(
|
|
185
|
+
defaults,
|
|
186
|
+
true
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
if (this.options.mockFn) {
|
|
190
|
+
this.mockTypes();
|
|
191
|
+
}
|
|
192
|
+
this._lastLog = {};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Gets the current log level of the Consola instance.
|
|
196
|
+
*
|
|
197
|
+
* @returns {number} The current log level.
|
|
198
|
+
*/
|
|
199
|
+
get level() {
|
|
200
|
+
return this.options.level;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Sets the minimum log level that will be output by the instance.
|
|
204
|
+
*
|
|
205
|
+
* @param {number} level - The new log level to set.
|
|
206
|
+
*/
|
|
207
|
+
set level(level) {
|
|
208
|
+
this.options.level = _normalizeLogLevel(
|
|
209
|
+
level,
|
|
210
|
+
this.options.types,
|
|
211
|
+
this.options.level
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Displays a prompt to the user and returns the response.
|
|
216
|
+
* Throw an error if `prompt` is not supported by the current configuration.
|
|
217
|
+
*
|
|
218
|
+
* @template T
|
|
219
|
+
* @param {string} message - The message to display in the prompt.
|
|
220
|
+
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
221
|
+
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
222
|
+
*/
|
|
223
|
+
prompt(message, opts) {
|
|
224
|
+
if (!this.options.prompt) {
|
|
225
|
+
throw new Error("prompt is not supported!");
|
|
226
|
+
}
|
|
227
|
+
return this.options.prompt(message, opts);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
231
|
+
*
|
|
232
|
+
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
233
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
234
|
+
*/
|
|
235
|
+
create(options) {
|
|
236
|
+
const instance = new _Consola({
|
|
237
|
+
...this.options,
|
|
238
|
+
...options
|
|
239
|
+
});
|
|
240
|
+
if (this._mockFn) {
|
|
241
|
+
instance.mockTypes(this._mockFn);
|
|
242
|
+
}
|
|
243
|
+
return instance;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Creates a new Consola instance with the specified default log object properties.
|
|
247
|
+
*
|
|
248
|
+
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
249
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
250
|
+
*/
|
|
251
|
+
withDefaults(defaults) {
|
|
252
|
+
return this.create({
|
|
253
|
+
...this.options,
|
|
254
|
+
defaults: {
|
|
255
|
+
...this.options.defaults,
|
|
256
|
+
...defaults
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
262
|
+
*
|
|
263
|
+
* @param {string} tag - The tag to include in each log of the new instance.
|
|
264
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
265
|
+
*/
|
|
266
|
+
withTag(tag) {
|
|
267
|
+
return this.withDefaults({
|
|
268
|
+
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Adds a custom reporter to the Consola instance.
|
|
273
|
+
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
274
|
+
*
|
|
275
|
+
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
276
|
+
* @returns {Consola} The current Consola instance.
|
|
277
|
+
*/
|
|
278
|
+
addReporter(reporter) {
|
|
279
|
+
this.options.reporters.push(reporter);
|
|
280
|
+
return this;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Removes a custom reporter from the Consola instance.
|
|
284
|
+
* If no reporter is specified, all reporters will be removed.
|
|
285
|
+
*
|
|
286
|
+
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
287
|
+
* @returns {Consola} The current Consola instance.
|
|
288
|
+
*/
|
|
289
|
+
removeReporter(reporter) {
|
|
290
|
+
if (reporter) {
|
|
291
|
+
const i2 = this.options.reporters.indexOf(reporter);
|
|
292
|
+
if (i2 !== -1) {
|
|
293
|
+
return this.options.reporters.splice(i2, 1);
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
this.options.reporters.splice(0);
|
|
297
|
+
}
|
|
298
|
+
return this;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
302
|
+
*
|
|
303
|
+
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
304
|
+
* @returns {Consola} The current Consola instance.
|
|
305
|
+
*/
|
|
306
|
+
setReporters(reporters) {
|
|
307
|
+
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
wrapAll() {
|
|
311
|
+
this.wrapConsole();
|
|
312
|
+
this.wrapStd();
|
|
313
|
+
}
|
|
314
|
+
restoreAll() {
|
|
315
|
+
this.restoreConsole();
|
|
316
|
+
this.restoreStd();
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Overrides console methods with Consola logging methods for consistent logging.
|
|
320
|
+
*/
|
|
321
|
+
wrapConsole() {
|
|
322
|
+
for (const type in this.options.types) {
|
|
323
|
+
if (!console["__" + type]) {
|
|
324
|
+
console["__" + type] = console[type];
|
|
325
|
+
}
|
|
326
|
+
console[type] = this[type].raw;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Restores the original console methods, removing Consola overrides.
|
|
331
|
+
*/
|
|
332
|
+
restoreConsole() {
|
|
333
|
+
for (const type in this.options.types) {
|
|
334
|
+
if (console["__" + type]) {
|
|
335
|
+
console[type] = console["__" + type];
|
|
336
|
+
delete console["__" + type];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Overrides standard output and error streams to redirect them through Consola.
|
|
342
|
+
*/
|
|
343
|
+
wrapStd() {
|
|
344
|
+
this._wrapStream(this.options.stdout, "log");
|
|
345
|
+
this._wrapStream(this.options.stderr, "log");
|
|
346
|
+
}
|
|
347
|
+
_wrapStream(stream, type) {
|
|
348
|
+
if (!stream) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (!stream.__write) {
|
|
352
|
+
stream.__write = stream.write;
|
|
353
|
+
}
|
|
354
|
+
stream.write = (data) => {
|
|
355
|
+
this[type].raw(String(data).trim());
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
360
|
+
*/
|
|
361
|
+
restoreStd() {
|
|
362
|
+
this._restoreStream(this.options.stdout);
|
|
363
|
+
this._restoreStream(this.options.stderr);
|
|
364
|
+
}
|
|
365
|
+
_restoreStream(stream) {
|
|
366
|
+
if (!stream) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (stream.__write) {
|
|
370
|
+
stream.write = stream.__write;
|
|
371
|
+
delete stream.__write;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Pauses logging, queues incoming logs until resumed.
|
|
376
|
+
*/
|
|
377
|
+
pauseLogs() {
|
|
378
|
+
paused = true;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Resumes logging, processing any queued logs.
|
|
382
|
+
*/
|
|
383
|
+
resumeLogs() {
|
|
384
|
+
paused = false;
|
|
385
|
+
const _queue = queue.splice(0);
|
|
386
|
+
for (const item of _queue) {
|
|
387
|
+
item[0]._logFn(item[1], item[2]);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Replaces logging methods with mocks if a mock function is provided.
|
|
392
|
+
*
|
|
393
|
+
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
394
|
+
*/
|
|
395
|
+
mockTypes(mockFn) {
|
|
396
|
+
const _mockFn = mockFn || this.options.mockFn;
|
|
397
|
+
this._mockFn = _mockFn;
|
|
398
|
+
if (typeof _mockFn !== "function") {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
for (const type in this.options.types) {
|
|
402
|
+
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
403
|
+
this[type].raw = this[type];
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
_wrapLogFn(defaults, isRaw) {
|
|
407
|
+
return (...args) => {
|
|
408
|
+
if (paused) {
|
|
409
|
+
queue.push([this, defaults, args, isRaw]);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
return this._logFn(defaults, args, isRaw);
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
_logFn(defaults, args, isRaw) {
|
|
416
|
+
if ((defaults.level || 0) > this.level) {
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
const logObj = {
|
|
420
|
+
date: /* @__PURE__ */ new Date(),
|
|
421
|
+
args: [],
|
|
422
|
+
...defaults,
|
|
423
|
+
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
424
|
+
};
|
|
425
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
426
|
+
Object.assign(logObj, args[0]);
|
|
427
|
+
} else {
|
|
428
|
+
logObj.args = [...args];
|
|
429
|
+
}
|
|
430
|
+
if (logObj.message) {
|
|
431
|
+
logObj.args.unshift(logObj.message);
|
|
432
|
+
delete logObj.message;
|
|
433
|
+
}
|
|
434
|
+
if (logObj.additional) {
|
|
435
|
+
if (!Array.isArray(logObj.additional)) {
|
|
436
|
+
logObj.additional = logObj.additional.split("\n");
|
|
437
|
+
}
|
|
438
|
+
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
439
|
+
delete logObj.additional;
|
|
440
|
+
}
|
|
441
|
+
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
442
|
+
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
443
|
+
const resolveLog = (newLog = false) => {
|
|
444
|
+
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
445
|
+
if (this._lastLog.object && repeated > 0) {
|
|
446
|
+
const args2 = [...this._lastLog.object.args];
|
|
447
|
+
if (repeated > 1) {
|
|
448
|
+
args2.push(`(repeated ${repeated} times)`);
|
|
449
|
+
}
|
|
450
|
+
this._log({ ...this._lastLog.object, args: args2 });
|
|
451
|
+
this._lastLog.count = 1;
|
|
452
|
+
}
|
|
453
|
+
if (newLog) {
|
|
454
|
+
this._lastLog.object = logObj;
|
|
455
|
+
this._log(logObj);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
clearTimeout(this._lastLog.timeout);
|
|
459
|
+
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
460
|
+
this._lastLog.time = logObj.date;
|
|
461
|
+
if (diffTime < this.options.throttle) {
|
|
462
|
+
try {
|
|
463
|
+
const serializedLog = JSON.stringify([
|
|
464
|
+
logObj.type,
|
|
465
|
+
logObj.tag,
|
|
466
|
+
logObj.args
|
|
467
|
+
]);
|
|
468
|
+
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
469
|
+
this._lastLog.serialized = serializedLog;
|
|
470
|
+
if (isSameLog) {
|
|
471
|
+
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
472
|
+
if (this._lastLog.count > this.options.throttleMin) {
|
|
473
|
+
this._lastLog.timeout = setTimeout(
|
|
474
|
+
resolveLog,
|
|
475
|
+
this.options.throttle
|
|
476
|
+
);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
} catch {
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
resolveLog(true);
|
|
484
|
+
}
|
|
485
|
+
_log(logObj) {
|
|
486
|
+
for (const reporter of this.options.reporters) {
|
|
487
|
+
reporter.log(logObj, {
|
|
488
|
+
options: this.options
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
494
|
+
if (input === void 0) {
|
|
495
|
+
return defaultLevel;
|
|
496
|
+
}
|
|
497
|
+
if (typeof input === "number") {
|
|
498
|
+
return input;
|
|
499
|
+
}
|
|
500
|
+
if (types[input] && types[input].level !== void 0) {
|
|
501
|
+
return types[input].level;
|
|
502
|
+
}
|
|
503
|
+
return defaultLevel;
|
|
504
|
+
}
|
|
505
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
506
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
507
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
508
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
509
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
510
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
511
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
512
|
+
function createConsola(options = {}) {
|
|
513
|
+
return new Consola(options);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
|
|
517
|
+
import { formatWithOptions } from "util";
|
|
518
|
+
import { sep } from "path";
|
|
519
|
+
function parseStack(stack, message) {
|
|
520
|
+
const cwd = process.cwd() + sep;
|
|
521
|
+
const lines = stack.split("\n").splice(message.split("\n").length).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
|
|
522
|
+
return lines;
|
|
523
|
+
}
|
|
524
|
+
function writeStream(data, stream) {
|
|
525
|
+
const write = stream.__write || stream.write;
|
|
526
|
+
return write.call(stream, data);
|
|
527
|
+
}
|
|
528
|
+
var bracket = (x) => x ? `[${x}]` : "";
|
|
529
|
+
var BasicReporter = class {
|
|
530
|
+
formatStack(stack, message, opts) {
|
|
531
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
532
|
+
return indent + parseStack(stack, message).join(`
|
|
533
|
+
${indent}`);
|
|
534
|
+
}
|
|
535
|
+
formatError(err, opts) {
|
|
536
|
+
const message = err.message ?? formatWithOptions(opts, err);
|
|
537
|
+
const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
|
|
538
|
+
const level = opts?.errorLevel || 0;
|
|
539
|
+
const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
|
|
540
|
+
const causedError = err.cause ? "\n\n" + this.formatError(err.cause, { ...opts, errorLevel: level + 1 }) : "";
|
|
541
|
+
return causedPrefix + message + "\n" + stack + causedError;
|
|
542
|
+
}
|
|
543
|
+
formatArgs(args, opts) {
|
|
544
|
+
const _args = args.map((arg) => {
|
|
545
|
+
if (arg && typeof arg.stack === "string") {
|
|
546
|
+
return this.formatError(arg, opts);
|
|
547
|
+
}
|
|
548
|
+
return arg;
|
|
549
|
+
});
|
|
550
|
+
return formatWithOptions(opts, ..._args);
|
|
551
|
+
}
|
|
552
|
+
formatDate(date, opts) {
|
|
553
|
+
return opts.date ? date.toLocaleTimeString() : "";
|
|
554
|
+
}
|
|
555
|
+
filterAndJoin(arr) {
|
|
556
|
+
return arr.filter(Boolean).join(" ");
|
|
557
|
+
}
|
|
558
|
+
formatLogObj(logObj, opts) {
|
|
559
|
+
const message = this.formatArgs(logObj.args, opts);
|
|
560
|
+
if (logObj.type === "box") {
|
|
561
|
+
return "\n" + [
|
|
562
|
+
bracket(logObj.tag),
|
|
563
|
+
logObj.title && logObj.title,
|
|
564
|
+
...message.split("\n")
|
|
565
|
+
].filter(Boolean).map((l2) => " > " + l2).join("\n") + "\n";
|
|
566
|
+
}
|
|
567
|
+
return this.filterAndJoin([
|
|
568
|
+
bracket(logObj.type),
|
|
569
|
+
bracket(logObj.tag),
|
|
570
|
+
message
|
|
571
|
+
]);
|
|
572
|
+
}
|
|
573
|
+
log(logObj, ctx) {
|
|
574
|
+
const line = this.formatLogObj(logObj, {
|
|
575
|
+
columns: ctx.options.stdout.columns || 0,
|
|
576
|
+
...ctx.options.formatOptions
|
|
577
|
+
});
|
|
578
|
+
return writeStream(
|
|
579
|
+
line + "\n",
|
|
580
|
+
logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
586
|
+
import g$1 from "process";
|
|
587
|
+
|
|
588
|
+
// ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
|
|
589
|
+
import * as tty from "tty";
|
|
590
|
+
var {
|
|
591
|
+
env = {},
|
|
592
|
+
argv = [],
|
|
593
|
+
platform = ""
|
|
594
|
+
} = typeof process === "undefined" ? {} : process;
|
|
595
|
+
var isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
596
|
+
var isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
597
|
+
var isWindows = platform === "win32";
|
|
598
|
+
var isDumbTerminal = env.TERM === "dumb";
|
|
599
|
+
var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
600
|
+
var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
601
|
+
var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
602
|
+
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
|
603
|
+
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
604
|
+
}
|
|
605
|
+
function clearBleed(index, string, open, close, replace) {
|
|
606
|
+
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
607
|
+
}
|
|
608
|
+
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
|
609
|
+
return (string) => string || !(string === "" || string === void 0) ? clearBleed(
|
|
610
|
+
("" + string).indexOf(close, at),
|
|
611
|
+
string,
|
|
612
|
+
open,
|
|
613
|
+
close,
|
|
614
|
+
replace
|
|
615
|
+
) : "";
|
|
616
|
+
}
|
|
617
|
+
function init(open, close, replace) {
|
|
618
|
+
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
|
619
|
+
}
|
|
620
|
+
var colorDefs = {
|
|
621
|
+
reset: init(0, 0),
|
|
622
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
623
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
624
|
+
italic: init(3, 23),
|
|
625
|
+
underline: init(4, 24),
|
|
626
|
+
inverse: init(7, 27),
|
|
627
|
+
hidden: init(8, 28),
|
|
628
|
+
strikethrough: init(9, 29),
|
|
629
|
+
black: init(30, 39),
|
|
630
|
+
red: init(31, 39),
|
|
631
|
+
green: init(32, 39),
|
|
632
|
+
yellow: init(33, 39),
|
|
633
|
+
blue: init(34, 39),
|
|
634
|
+
magenta: init(35, 39),
|
|
635
|
+
cyan: init(36, 39),
|
|
636
|
+
white: init(37, 39),
|
|
637
|
+
gray: init(90, 39),
|
|
638
|
+
bgBlack: init(40, 49),
|
|
639
|
+
bgRed: init(41, 49),
|
|
640
|
+
bgGreen: init(42, 49),
|
|
641
|
+
bgYellow: init(43, 49),
|
|
642
|
+
bgBlue: init(44, 49),
|
|
643
|
+
bgMagenta: init(45, 49),
|
|
644
|
+
bgCyan: init(46, 49),
|
|
645
|
+
bgWhite: init(47, 49),
|
|
646
|
+
blackBright: init(90, 39),
|
|
647
|
+
redBright: init(91, 39),
|
|
648
|
+
greenBright: init(92, 39),
|
|
649
|
+
yellowBright: init(93, 39),
|
|
650
|
+
blueBright: init(94, 39),
|
|
651
|
+
magentaBright: init(95, 39),
|
|
652
|
+
cyanBright: init(96, 39),
|
|
653
|
+
whiteBright: init(97, 39),
|
|
654
|
+
bgBlackBright: init(100, 49),
|
|
655
|
+
bgRedBright: init(101, 49),
|
|
656
|
+
bgGreenBright: init(102, 49),
|
|
657
|
+
bgYellowBright: init(103, 49),
|
|
658
|
+
bgBlueBright: init(104, 49),
|
|
659
|
+
bgMagentaBright: init(105, 49),
|
|
660
|
+
bgCyanBright: init(106, 49),
|
|
661
|
+
bgWhiteBright: init(107, 49)
|
|
662
|
+
};
|
|
663
|
+
function createColors(useColor = isColorSupported) {
|
|
664
|
+
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
665
|
+
}
|
|
666
|
+
var colors = createColors();
|
|
667
|
+
function getColor(color, fallback = "reset") {
|
|
668
|
+
return colors[color] || colors[fallback];
|
|
669
|
+
}
|
|
670
|
+
var ansiRegex = [
|
|
671
|
+
String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
|
|
672
|
+
String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
|
|
673
|
+
].join("|");
|
|
674
|
+
function stripAnsi(text) {
|
|
675
|
+
return text.replace(new RegExp(ansiRegex, "g"), "");
|
|
676
|
+
}
|
|
677
|
+
var boxStylePresets = {
|
|
678
|
+
solid: {
|
|
679
|
+
tl: "\u250C",
|
|
680
|
+
tr: "\u2510",
|
|
681
|
+
bl: "\u2514",
|
|
682
|
+
br: "\u2518",
|
|
683
|
+
h: "\u2500",
|
|
684
|
+
v: "\u2502"
|
|
685
|
+
},
|
|
686
|
+
double: {
|
|
687
|
+
tl: "\u2554",
|
|
688
|
+
tr: "\u2557",
|
|
689
|
+
bl: "\u255A",
|
|
690
|
+
br: "\u255D",
|
|
691
|
+
h: "\u2550",
|
|
692
|
+
v: "\u2551"
|
|
693
|
+
},
|
|
694
|
+
doubleSingle: {
|
|
695
|
+
tl: "\u2553",
|
|
696
|
+
tr: "\u2556",
|
|
697
|
+
bl: "\u2559",
|
|
698
|
+
br: "\u255C",
|
|
699
|
+
h: "\u2500",
|
|
700
|
+
v: "\u2551"
|
|
701
|
+
},
|
|
702
|
+
doubleSingleRounded: {
|
|
703
|
+
tl: "\u256D",
|
|
704
|
+
tr: "\u256E",
|
|
705
|
+
bl: "\u2570",
|
|
706
|
+
br: "\u256F",
|
|
707
|
+
h: "\u2500",
|
|
708
|
+
v: "\u2551"
|
|
709
|
+
},
|
|
710
|
+
singleThick: {
|
|
711
|
+
tl: "\u250F",
|
|
712
|
+
tr: "\u2513",
|
|
713
|
+
bl: "\u2517",
|
|
714
|
+
br: "\u251B",
|
|
715
|
+
h: "\u2501",
|
|
716
|
+
v: "\u2503"
|
|
717
|
+
},
|
|
718
|
+
singleDouble: {
|
|
719
|
+
tl: "\u2552",
|
|
720
|
+
tr: "\u2555",
|
|
721
|
+
bl: "\u2558",
|
|
722
|
+
br: "\u255B",
|
|
723
|
+
h: "\u2550",
|
|
724
|
+
v: "\u2502"
|
|
725
|
+
},
|
|
726
|
+
singleDoubleRounded: {
|
|
727
|
+
tl: "\u256D",
|
|
728
|
+
tr: "\u256E",
|
|
729
|
+
bl: "\u2570",
|
|
730
|
+
br: "\u256F",
|
|
731
|
+
h: "\u2550",
|
|
732
|
+
v: "\u2502"
|
|
733
|
+
},
|
|
734
|
+
rounded: {
|
|
735
|
+
tl: "\u256D",
|
|
736
|
+
tr: "\u256E",
|
|
737
|
+
bl: "\u2570",
|
|
738
|
+
br: "\u256F",
|
|
739
|
+
h: "\u2500",
|
|
740
|
+
v: "\u2502"
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
var defaultStyle = {
|
|
744
|
+
borderColor: "white",
|
|
745
|
+
borderStyle: "rounded",
|
|
746
|
+
valign: "center",
|
|
747
|
+
padding: 2,
|
|
748
|
+
marginLeft: 1,
|
|
749
|
+
marginTop: 1,
|
|
750
|
+
marginBottom: 1
|
|
751
|
+
};
|
|
752
|
+
function box(text, _opts = {}) {
|
|
753
|
+
const opts = {
|
|
754
|
+
..._opts,
|
|
755
|
+
style: {
|
|
756
|
+
...defaultStyle,
|
|
757
|
+
..._opts.style
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
const textLines = text.split("\n");
|
|
761
|
+
const boxLines = [];
|
|
762
|
+
const _color = getColor(opts.style.borderColor);
|
|
763
|
+
const borderStyle = {
|
|
764
|
+
...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
|
|
765
|
+
};
|
|
766
|
+
if (_color) {
|
|
767
|
+
for (const key in borderStyle) {
|
|
768
|
+
borderStyle[key] = _color(
|
|
769
|
+
borderStyle[key]
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
774
|
+
const height = textLines.length + paddingOffset;
|
|
775
|
+
const width = Math.max(
|
|
776
|
+
...textLines.map((line) => stripAnsi(line).length),
|
|
777
|
+
opts.title ? stripAnsi(opts.title).length : 0
|
|
778
|
+
) + paddingOffset;
|
|
779
|
+
const widthOffset = width + paddingOffset;
|
|
780
|
+
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
781
|
+
if (opts.style.marginTop > 0) {
|
|
782
|
+
boxLines.push("".repeat(opts.style.marginTop));
|
|
783
|
+
}
|
|
784
|
+
if (opts.title) {
|
|
785
|
+
const title = _color ? _color(opts.title) : opts.title;
|
|
786
|
+
const left = borderStyle.h.repeat(
|
|
787
|
+
Math.floor((width - stripAnsi(opts.title).length) / 2)
|
|
788
|
+
);
|
|
789
|
+
const right = borderStyle.h.repeat(
|
|
790
|
+
width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
|
|
791
|
+
);
|
|
792
|
+
boxLines.push(
|
|
793
|
+
`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`
|
|
794
|
+
);
|
|
795
|
+
} else {
|
|
796
|
+
boxLines.push(
|
|
797
|
+
`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
801
|
+
for (let i2 = 0; i2 < height; i2++) {
|
|
802
|
+
if (i2 < valignOffset || i2 >= valignOffset + textLines.length) {
|
|
803
|
+
boxLines.push(
|
|
804
|
+
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
|
|
805
|
+
);
|
|
806
|
+
} else {
|
|
807
|
+
const line = textLines[i2 - valignOffset];
|
|
808
|
+
const left = " ".repeat(paddingOffset);
|
|
809
|
+
const right = " ".repeat(width - stripAnsi(line).length);
|
|
810
|
+
boxLines.push(
|
|
811
|
+
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
boxLines.push(
|
|
816
|
+
`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
|
|
817
|
+
);
|
|
818
|
+
if (opts.style.marginBottom > 0) {
|
|
819
|
+
boxLines.push("".repeat(opts.style.marginBottom));
|
|
820
|
+
}
|
|
821
|
+
return boxLines.join("\n");
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
// ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
825
|
+
import "util";
|
|
826
|
+
import "path";
|
|
827
|
+
import "tty";
|
|
828
|
+
var r = /* @__PURE__ */ Object.create(null);
|
|
829
|
+
var i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
|
|
830
|
+
var o = new Proxy(r, { get(e, s2) {
|
|
831
|
+
return i()[s2] ?? r[s2];
|
|
832
|
+
}, has(e, s2) {
|
|
833
|
+
const E = i();
|
|
834
|
+
return s2 in E || s2 in r;
|
|
835
|
+
}, set(e, s2, E) {
|
|
836
|
+
const B = i(true);
|
|
837
|
+
return B[s2] = E, true;
|
|
838
|
+
}, deleteProperty(e, s2) {
|
|
839
|
+
if (!s2) return false;
|
|
840
|
+
const E = i(true);
|
|
841
|
+
return delete E[s2], true;
|
|
842
|
+
}, ownKeys() {
|
|
843
|
+
const e = i(true);
|
|
844
|
+
return Object.keys(e);
|
|
845
|
+
} });
|
|
846
|
+
var t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
|
|
847
|
+
var f = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
|
|
848
|
+
function b() {
|
|
849
|
+
if (globalThis.process?.env) for (const e of f) {
|
|
850
|
+
const s2 = e[1] || e[0];
|
|
851
|
+
if (globalThis.process?.env[s2]) return { name: e[0].toLowerCase(), ...e[2] };
|
|
852
|
+
}
|
|
853
|
+
return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
|
|
854
|
+
}
|
|
855
|
+
var l = b();
|
|
856
|
+
l.name;
|
|
857
|
+
function n(e) {
|
|
858
|
+
return e ? e !== "false" : false;
|
|
859
|
+
}
|
|
860
|
+
var I = globalThis.process?.platform || "";
|
|
861
|
+
var T = n(o.CI) || l.ci !== false;
|
|
862
|
+
var a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
|
|
863
|
+
var g = n(o.DEBUG);
|
|
864
|
+
var R = t === "test" || n(o.TEST);
|
|
865
|
+
n(o.MINIMAL) || T || R || !a;
|
|
866
|
+
var A = /^win/i.test(I);
|
|
867
|
+
!n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM !== "dumb" || T);
|
|
868
|
+
var C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
|
|
869
|
+
Number(C?.split(".")[0]) || null;
|
|
870
|
+
var y = globalThis.process || /* @__PURE__ */ Object.create(null);
|
|
871
|
+
var _ = { versions: {} };
|
|
872
|
+
new Proxy(y, { get(e, s2) {
|
|
873
|
+
if (s2 === "env") return o;
|
|
874
|
+
if (s2 in e) return e[s2];
|
|
875
|
+
if (s2 in _) return _[s2];
|
|
876
|
+
} });
|
|
877
|
+
var c = globalThis.process?.release?.name === "node";
|
|
878
|
+
var O = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
|
|
879
|
+
var D = !!globalThis.Deno;
|
|
880
|
+
var L = !!globalThis.fastly;
|
|
881
|
+
var S = !!globalThis.Netlify;
|
|
882
|
+
var u = !!globalThis.EdgeRuntime;
|
|
883
|
+
var N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
|
|
884
|
+
var F = [[S, "netlify"], [u, "edge-light"], [N, "workerd"], [L, "fastly"], [D, "deno"], [O, "bun"], [c, "node"]];
|
|
885
|
+
function G() {
|
|
886
|
+
const e = F.find((s2) => s2[0]);
|
|
887
|
+
if (e) return { name: e[1] };
|
|
888
|
+
}
|
|
889
|
+
var P = G();
|
|
890
|
+
P?.name || "";
|
|
891
|
+
function ansiRegex2({ onlyFirst = false } = {}) {
|
|
892
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
893
|
+
const pattern = [
|
|
894
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
895
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
896
|
+
].join("|");
|
|
897
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
898
|
+
}
|
|
899
|
+
var regex = ansiRegex2();
|
|
900
|
+
function stripAnsi2(string) {
|
|
901
|
+
if (typeof string !== "string") {
|
|
902
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
903
|
+
}
|
|
904
|
+
return string.replace(regex, "");
|
|
905
|
+
}
|
|
906
|
+
function isAmbiguous(x) {
|
|
907
|
+
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
908
|
+
}
|
|
909
|
+
function isFullWidth(x) {
|
|
910
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
911
|
+
}
|
|
912
|
+
function isWide(x) {
|
|
913
|
+
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
914
|
+
}
|
|
915
|
+
function validate(codePoint) {
|
|
916
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
917
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
921
|
+
validate(codePoint);
|
|
922
|
+
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
923
|
+
return 2;
|
|
924
|
+
}
|
|
925
|
+
return 1;
|
|
926
|
+
}
|
|
927
|
+
var emojiRegex = () => {
|
|
928
|
+
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
929
|
+
};
|
|
930
|
+
var segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
|
|
931
|
+
var defaultIgnorableCodePointRegex = new RegExp("^\\p{Default_Ignorable_Code_Point}$", "u");
|
|
932
|
+
function stringWidth$1(string, options = {}) {
|
|
933
|
+
if (typeof string !== "string" || string.length === 0) {
|
|
934
|
+
return 0;
|
|
935
|
+
}
|
|
936
|
+
const {
|
|
937
|
+
ambiguousIsNarrow = true,
|
|
938
|
+
countAnsiEscapeCodes = false
|
|
939
|
+
} = options;
|
|
940
|
+
if (!countAnsiEscapeCodes) {
|
|
941
|
+
string = stripAnsi2(string);
|
|
942
|
+
}
|
|
943
|
+
if (string.length === 0) {
|
|
944
|
+
return 0;
|
|
945
|
+
}
|
|
946
|
+
let width = 0;
|
|
947
|
+
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
948
|
+
for (const { segment: character } of segmenter.segment(string)) {
|
|
949
|
+
const codePoint = character.codePointAt(0);
|
|
950
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
951
|
+
continue;
|
|
952
|
+
}
|
|
953
|
+
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
if (emojiRegex().test(character)) {
|
|
969
|
+
width += 2;
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
973
|
+
}
|
|
974
|
+
return width;
|
|
975
|
+
}
|
|
976
|
+
function isUnicodeSupported() {
|
|
977
|
+
const { env: env2 } = g$1;
|
|
978
|
+
const { TERM, TERM_PROGRAM } = env2;
|
|
979
|
+
if (g$1.platform !== "win32") {
|
|
980
|
+
return TERM !== "linux";
|
|
981
|
+
}
|
|
982
|
+
return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
983
|
+
}
|
|
984
|
+
var TYPE_COLOR_MAP = {
|
|
985
|
+
info: "cyan",
|
|
986
|
+
fail: "red",
|
|
987
|
+
success: "green",
|
|
988
|
+
ready: "green",
|
|
989
|
+
start: "magenta"
|
|
990
|
+
};
|
|
991
|
+
var LEVEL_COLOR_MAP = {
|
|
992
|
+
0: "red",
|
|
993
|
+
1: "yellow"
|
|
994
|
+
};
|
|
995
|
+
var unicode = isUnicodeSupported();
|
|
996
|
+
var s = (c2, fallback) => unicode ? c2 : fallback;
|
|
997
|
+
var TYPE_ICONS = {
|
|
998
|
+
error: s("\u2716", "\xD7"),
|
|
999
|
+
fatal: s("\u2716", "\xD7"),
|
|
1000
|
+
ready: s("\u2714", "\u221A"),
|
|
1001
|
+
warn: s("\u26A0", "\u203C"),
|
|
1002
|
+
info: s("\u2139", "i"),
|
|
1003
|
+
success: s("\u2714", "\u221A"),
|
|
1004
|
+
debug: s("\u2699", "D"),
|
|
1005
|
+
trace: s("\u2192", "\u2192"),
|
|
1006
|
+
fail: s("\u2716", "\xD7"),
|
|
1007
|
+
start: s("\u25D0", "o"),
|
|
1008
|
+
log: ""
|
|
1009
|
+
};
|
|
1010
|
+
function stringWidth(str) {
|
|
1011
|
+
const hasICU = typeof Intl === "object";
|
|
1012
|
+
if (!hasICU || !Intl.Segmenter) {
|
|
1013
|
+
return stripAnsi(str).length;
|
|
1014
|
+
}
|
|
1015
|
+
return stringWidth$1(str);
|
|
1016
|
+
}
|
|
1017
|
+
var FancyReporter = class extends BasicReporter {
|
|
1018
|
+
formatStack(stack, message, opts) {
|
|
1019
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
1020
|
+
return `
|
|
1021
|
+
${indent}` + parseStack(stack, message).map(
|
|
1022
|
+
(line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_2, m) => `(${colors.cyan(m)})`)
|
|
1023
|
+
).join(`
|
|
1024
|
+
${indent}`);
|
|
1025
|
+
}
|
|
1026
|
+
formatType(logObj, isBadge, opts) {
|
|
1027
|
+
const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
|
|
1028
|
+
if (isBadge) {
|
|
1029
|
+
return getBgColor(typeColor)(
|
|
1030
|
+
colors.black(` ${logObj.type.toUpperCase()} `)
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
1034
|
+
return _type ? getColor2(typeColor)(_type) : "";
|
|
1035
|
+
}
|
|
1036
|
+
formatLogObj(logObj, opts) {
|
|
1037
|
+
const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
|
|
1038
|
+
"\n"
|
|
1039
|
+
);
|
|
1040
|
+
if (logObj.type === "box") {
|
|
1041
|
+
return box(
|
|
1042
|
+
characterFormat(
|
|
1043
|
+
message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
|
|
1044
|
+
),
|
|
1045
|
+
{
|
|
1046
|
+
title: logObj.title ? characterFormat(logObj.title) : void 0,
|
|
1047
|
+
style: logObj.style
|
|
1048
|
+
}
|
|
1049
|
+
);
|
|
1050
|
+
}
|
|
1051
|
+
const date = this.formatDate(logObj.date, opts);
|
|
1052
|
+
const coloredDate = date && colors.gray(date);
|
|
1053
|
+
const isBadge = logObj.badge ?? logObj.level < 2;
|
|
1054
|
+
const type = this.formatType(logObj, isBadge, opts);
|
|
1055
|
+
const tag = logObj.tag ? colors.gray(logObj.tag) : "";
|
|
1056
|
+
let line;
|
|
1057
|
+
const left = this.filterAndJoin([type, characterFormat(message)]);
|
|
1058
|
+
const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
|
|
1059
|
+
const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
|
|
1060
|
+
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
|
|
1061
|
+
line += characterFormat(
|
|
1062
|
+
additional.length > 0 ? "\n" + additional.join("\n") : ""
|
|
1063
|
+
);
|
|
1064
|
+
if (logObj.type === "trace") {
|
|
1065
|
+
const _err = new Error("Trace: " + logObj.message);
|
|
1066
|
+
line += this.formatStack(_err.stack || "", _err.message);
|
|
1067
|
+
}
|
|
1068
|
+
return isBadge ? "\n" + line + "\n" : line;
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
function characterFormat(str) {
|
|
1072
|
+
return str.replace(/`([^`]+)`/gm, (_2, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_2, m) => ` ${colors.underline(m)} `);
|
|
1073
|
+
}
|
|
1074
|
+
function getColor2(color = "white") {
|
|
1075
|
+
return colors[color] || colors.white;
|
|
1076
|
+
}
|
|
1077
|
+
function getBgColor(color = "bgWhite") {
|
|
1078
|
+
return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
|
|
1079
|
+
}
|
|
1080
|
+
function createConsola2(options = {}) {
|
|
1081
|
+
let level = _getDefaultLogLevel();
|
|
1082
|
+
if (process.env.CONSOLA_LEVEL) {
|
|
1083
|
+
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
1084
|
+
}
|
|
1085
|
+
const consola2 = createConsola({
|
|
1086
|
+
level,
|
|
1087
|
+
defaults: { level },
|
|
1088
|
+
stdout: process.stdout,
|
|
1089
|
+
stderr: process.stderr,
|
|
1090
|
+
prompt: (...args) => import("./prompt-NH7GB4RH.js").then((m) => m.prompt(...args)),
|
|
1091
|
+
reporters: options.reporters || [
|
|
1092
|
+
options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()
|
|
1093
|
+
],
|
|
1094
|
+
...options
|
|
1095
|
+
});
|
|
1096
|
+
return consola2;
|
|
1097
|
+
}
|
|
1098
|
+
function _getDefaultLogLevel() {
|
|
1099
|
+
if (g) {
|
|
1100
|
+
return LogLevels.debug;
|
|
1101
|
+
}
|
|
1102
|
+
if (R) {
|
|
1103
|
+
return LogLevels.warn;
|
|
1104
|
+
}
|
|
1105
|
+
return LogLevels.info;
|
|
1106
|
+
}
|
|
1107
|
+
var consola = createConsola2();
|
|
1108
|
+
|
|
1109
|
+
// ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/utils.mjs
|
|
1110
|
+
import "tty";
|
|
1111
|
+
|
|
1112
|
+
// ../../node_modules/.bun/citty@0.1.6/node_modules/citty/dist/index.mjs
|
|
1113
|
+
function toArray(val) {
|
|
1114
|
+
if (Array.isArray(val)) {
|
|
1115
|
+
return val;
|
|
1116
|
+
}
|
|
1117
|
+
return val === void 0 ? [] : [val];
|
|
1118
|
+
}
|
|
1119
|
+
function formatLineColumns(lines, linePrefix = "") {
|
|
1120
|
+
const maxLengh = [];
|
|
1121
|
+
for (const line of lines) {
|
|
1122
|
+
for (const [i2, element] of line.entries()) {
|
|
1123
|
+
maxLengh[i2] = Math.max(maxLengh[i2] || 0, element.length);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
return lines.map(
|
|
1127
|
+
(l2) => l2.map(
|
|
1128
|
+
(c2, i2) => linePrefix + c2[i2 === 0 ? "padStart" : "padEnd"](maxLengh[i2])
|
|
1129
|
+
).join(" ")
|
|
1130
|
+
).join("\n");
|
|
1131
|
+
}
|
|
1132
|
+
function resolveValue(input) {
|
|
1133
|
+
return typeof input === "function" ? input() : input;
|
|
1134
|
+
}
|
|
1135
|
+
var CLIError = class extends Error {
|
|
1136
|
+
constructor(message, code) {
|
|
1137
|
+
super(message);
|
|
1138
|
+
this.code = code;
|
|
1139
|
+
this.name = "CLIError";
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
var NUMBER_CHAR_RE = /\d/;
|
|
1143
|
+
var STR_SPLITTERS = ["-", "_", "/", "."];
|
|
1144
|
+
function isUppercase(char = "") {
|
|
1145
|
+
if (NUMBER_CHAR_RE.test(char)) {
|
|
1146
|
+
return void 0;
|
|
1147
|
+
}
|
|
1148
|
+
return char !== char.toLowerCase();
|
|
1149
|
+
}
|
|
1150
|
+
function splitByCase(str, separators) {
|
|
1151
|
+
const splitters = separators ?? STR_SPLITTERS;
|
|
1152
|
+
const parts = [];
|
|
1153
|
+
if (!str || typeof str !== "string") {
|
|
1154
|
+
return parts;
|
|
1155
|
+
}
|
|
1156
|
+
let buff = "";
|
|
1157
|
+
let previousUpper;
|
|
1158
|
+
let previousSplitter;
|
|
1159
|
+
for (const char of str) {
|
|
1160
|
+
const isSplitter = splitters.includes(char);
|
|
1161
|
+
if (isSplitter === true) {
|
|
1162
|
+
parts.push(buff);
|
|
1163
|
+
buff = "";
|
|
1164
|
+
previousUpper = void 0;
|
|
1165
|
+
continue;
|
|
1166
|
+
}
|
|
1167
|
+
const isUpper = isUppercase(char);
|
|
1168
|
+
if (previousSplitter === false) {
|
|
1169
|
+
if (previousUpper === false && isUpper === true) {
|
|
1170
|
+
parts.push(buff);
|
|
1171
|
+
buff = char;
|
|
1172
|
+
previousUpper = isUpper;
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1175
|
+
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
1176
|
+
const lastChar = buff.at(-1);
|
|
1177
|
+
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
1178
|
+
buff = lastChar + char;
|
|
1179
|
+
previousUpper = isUpper;
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
buff += char;
|
|
1184
|
+
previousUpper = isUpper;
|
|
1185
|
+
previousSplitter = isSplitter;
|
|
1186
|
+
}
|
|
1187
|
+
parts.push(buff);
|
|
1188
|
+
return parts;
|
|
1189
|
+
}
|
|
1190
|
+
function upperFirst(str) {
|
|
1191
|
+
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
1192
|
+
}
|
|
1193
|
+
function lowerFirst(str) {
|
|
1194
|
+
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
1195
|
+
}
|
|
1196
|
+
function pascalCase(str, opts) {
|
|
1197
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
1198
|
+
}
|
|
1199
|
+
function camelCase(str, opts) {
|
|
1200
|
+
return lowerFirst(pascalCase(str || "", opts));
|
|
1201
|
+
}
|
|
1202
|
+
function kebabCase(str, joiner) {
|
|
1203
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
1204
|
+
}
|
|
1205
|
+
function toArr(any) {
|
|
1206
|
+
return any == void 0 ? [] : Array.isArray(any) ? any : [any];
|
|
1207
|
+
}
|
|
1208
|
+
function toVal(out, key, val, opts) {
|
|
1209
|
+
let x;
|
|
1210
|
+
const old = out[key];
|
|
1211
|
+
const nxt = ~opts.string.indexOf(key) ? val == void 0 || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
1212
|
+
out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
1213
|
+
}
|
|
1214
|
+
function parseRawArgs(args = [], opts = {}) {
|
|
1215
|
+
let k;
|
|
1216
|
+
let arr;
|
|
1217
|
+
let arg;
|
|
1218
|
+
let name;
|
|
1219
|
+
let val;
|
|
1220
|
+
const out = { _: [] };
|
|
1221
|
+
let i2 = 0;
|
|
1222
|
+
let j = 0;
|
|
1223
|
+
let idx = 0;
|
|
1224
|
+
const len = args.length;
|
|
1225
|
+
const alibi = opts.alias !== void 0;
|
|
1226
|
+
const strict = opts.unknown !== void 0;
|
|
1227
|
+
const defaults = opts.default !== void 0;
|
|
1228
|
+
opts.alias = opts.alias || {};
|
|
1229
|
+
opts.string = toArr(opts.string);
|
|
1230
|
+
opts.boolean = toArr(opts.boolean);
|
|
1231
|
+
if (alibi) {
|
|
1232
|
+
for (k in opts.alias) {
|
|
1233
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
1234
|
+
for (i2 = 0; i2 < arr.length; i2++) {
|
|
1235
|
+
(opts.alias[arr[i2]] = arr.concat(k)).splice(i2, 1);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
for (i2 = opts.boolean.length; i2-- > 0; ) {
|
|
1240
|
+
arr = opts.alias[opts.boolean[i2]] || [];
|
|
1241
|
+
for (j = arr.length; j-- > 0; ) {
|
|
1242
|
+
opts.boolean.push(arr[j]);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
for (i2 = opts.string.length; i2-- > 0; ) {
|
|
1246
|
+
arr = opts.alias[opts.string[i2]] || [];
|
|
1247
|
+
for (j = arr.length; j-- > 0; ) {
|
|
1248
|
+
opts.string.push(arr[j]);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
if (defaults) {
|
|
1252
|
+
for (k in opts.default) {
|
|
1253
|
+
name = typeof opts.default[k];
|
|
1254
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
1255
|
+
if (opts[name] !== void 0) {
|
|
1256
|
+
opts[name].push(k);
|
|
1257
|
+
for (i2 = 0; i2 < arr.length; i2++) {
|
|
1258
|
+
opts[name].push(arr[i2]);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
1264
|
+
for (i2 = 0; i2 < len; i2++) {
|
|
1265
|
+
arg = args[i2];
|
|
1266
|
+
if (arg === "--") {
|
|
1267
|
+
out._ = out._.concat(args.slice(++i2));
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
for (j = 0; j < arg.length; j++) {
|
|
1271
|
+
if (arg.charCodeAt(j) !== 45) {
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (j === 0) {
|
|
1276
|
+
out._.push(arg);
|
|
1277
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
1278
|
+
name = arg.slice(Math.max(0, j + 3));
|
|
1279
|
+
if (strict && !~keys.indexOf(name)) {
|
|
1280
|
+
return opts.unknown(arg);
|
|
1281
|
+
}
|
|
1282
|
+
out[name] = false;
|
|
1283
|
+
} else {
|
|
1284
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
1285
|
+
if (arg.charCodeAt(idx) === 61) {
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
name = arg.substring(j, idx);
|
|
1290
|
+
val = arg.slice(Math.max(0, ++idx)) || i2 + 1 === len || ("" + args[i2 + 1]).charCodeAt(0) === 45 || args[++i2];
|
|
1291
|
+
arr = j === 2 ? [name] : name;
|
|
1292
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
1293
|
+
name = arr[idx];
|
|
1294
|
+
if (strict && !~keys.indexOf(name)) {
|
|
1295
|
+
return opts.unknown("-".repeat(j) + name);
|
|
1296
|
+
}
|
|
1297
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
if (defaults) {
|
|
1302
|
+
for (k in opts.default) {
|
|
1303
|
+
if (out[k] === void 0) {
|
|
1304
|
+
out[k] = opts.default[k];
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
if (alibi) {
|
|
1309
|
+
for (k in out) {
|
|
1310
|
+
arr = opts.alias[k] || [];
|
|
1311
|
+
while (arr.length > 0) {
|
|
1312
|
+
out[arr.shift()] = out[k];
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
return out;
|
|
1317
|
+
}
|
|
1318
|
+
function parseArgs(rawArgs, argsDef) {
|
|
1319
|
+
const parseOptions = {
|
|
1320
|
+
boolean: [],
|
|
1321
|
+
string: [],
|
|
1322
|
+
mixed: [],
|
|
1323
|
+
alias: {},
|
|
1324
|
+
default: {}
|
|
1325
|
+
};
|
|
1326
|
+
const args = resolveArgs(argsDef);
|
|
1327
|
+
for (const arg of args) {
|
|
1328
|
+
if (arg.type === "positional") {
|
|
1329
|
+
continue;
|
|
1330
|
+
}
|
|
1331
|
+
if (arg.type === "string") {
|
|
1332
|
+
parseOptions.string.push(arg.name);
|
|
1333
|
+
} else if (arg.type === "boolean") {
|
|
1334
|
+
parseOptions.boolean.push(arg.name);
|
|
1335
|
+
}
|
|
1336
|
+
if (arg.default !== void 0) {
|
|
1337
|
+
parseOptions.default[arg.name] = arg.default;
|
|
1338
|
+
}
|
|
1339
|
+
if (arg.alias) {
|
|
1340
|
+
parseOptions.alias[arg.name] = arg.alias;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
const parsed = parseRawArgs(rawArgs, parseOptions);
|
|
1344
|
+
const [...positionalArguments] = parsed._;
|
|
1345
|
+
const parsedArgsProxy = new Proxy(parsed, {
|
|
1346
|
+
get(target, prop) {
|
|
1347
|
+
return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
for (const [, arg] of args.entries()) {
|
|
1351
|
+
if (arg.type === "positional") {
|
|
1352
|
+
const nextPositionalArgument = positionalArguments.shift();
|
|
1353
|
+
if (nextPositionalArgument !== void 0) {
|
|
1354
|
+
parsedArgsProxy[arg.name] = nextPositionalArgument;
|
|
1355
|
+
} else if (arg.default === void 0 && arg.required !== false) {
|
|
1356
|
+
throw new CLIError(
|
|
1357
|
+
`Missing required positional argument: ${arg.name.toUpperCase()}`,
|
|
1358
|
+
"EARG"
|
|
1359
|
+
);
|
|
1360
|
+
} else {
|
|
1361
|
+
parsedArgsProxy[arg.name] = arg.default;
|
|
1362
|
+
}
|
|
1363
|
+
} else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
|
|
1364
|
+
throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
return parsedArgsProxy;
|
|
1368
|
+
}
|
|
1369
|
+
function resolveArgs(argsDef) {
|
|
1370
|
+
const args = [];
|
|
1371
|
+
for (const [name, argDef] of Object.entries(argsDef || {})) {
|
|
1372
|
+
args.push({
|
|
1373
|
+
...argDef,
|
|
1374
|
+
name,
|
|
1375
|
+
alias: toArray(argDef.alias)
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
return args;
|
|
1379
|
+
}
|
|
1380
|
+
function defineCommand(def) {
|
|
1381
|
+
return def;
|
|
1382
|
+
}
|
|
1383
|
+
async function runCommand(cmd, opts) {
|
|
1384
|
+
const cmdArgs = await resolveValue(cmd.args || {});
|
|
1385
|
+
const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
|
|
1386
|
+
const context = {
|
|
1387
|
+
rawArgs: opts.rawArgs,
|
|
1388
|
+
args: parsedArgs,
|
|
1389
|
+
data: opts.data,
|
|
1390
|
+
cmd
|
|
1391
|
+
};
|
|
1392
|
+
if (typeof cmd.setup === "function") {
|
|
1393
|
+
await cmd.setup(context);
|
|
1394
|
+
}
|
|
1395
|
+
let result;
|
|
1396
|
+
try {
|
|
1397
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
1398
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
1399
|
+
const subCommandArgIndex = opts.rawArgs.findIndex(
|
|
1400
|
+
(arg) => !arg.startsWith("-")
|
|
1401
|
+
);
|
|
1402
|
+
const subCommandName = opts.rawArgs[subCommandArgIndex];
|
|
1403
|
+
if (subCommandName) {
|
|
1404
|
+
if (!subCommands[subCommandName]) {
|
|
1405
|
+
throw new CLIError(
|
|
1406
|
+
`Unknown command \`${subCommandName}\``,
|
|
1407
|
+
"E_UNKNOWN_COMMAND"
|
|
1408
|
+
);
|
|
1409
|
+
}
|
|
1410
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
1411
|
+
if (subCommand) {
|
|
1412
|
+
await runCommand(subCommand, {
|
|
1413
|
+
rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1)
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
} else if (!cmd.run) {
|
|
1417
|
+
throw new CLIError(`No command specified.`, "E_NO_COMMAND");
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
if (typeof cmd.run === "function") {
|
|
1421
|
+
result = await cmd.run(context);
|
|
1422
|
+
}
|
|
1423
|
+
} finally {
|
|
1424
|
+
if (typeof cmd.cleanup === "function") {
|
|
1425
|
+
await cmd.cleanup(context);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
return { result };
|
|
1429
|
+
}
|
|
1430
|
+
async function resolveSubCommand(cmd, rawArgs, parent) {
|
|
1431
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
1432
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
1433
|
+
const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
|
|
1434
|
+
const subCommandName = rawArgs[subCommandArgIndex];
|
|
1435
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
1436
|
+
if (subCommand) {
|
|
1437
|
+
return resolveSubCommand(
|
|
1438
|
+
subCommand,
|
|
1439
|
+
rawArgs.slice(subCommandArgIndex + 1),
|
|
1440
|
+
cmd
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
return [cmd, parent];
|
|
1445
|
+
}
|
|
1446
|
+
async function showUsage(cmd, parent) {
|
|
1447
|
+
try {
|
|
1448
|
+
consola.log(await renderUsage(cmd, parent) + "\n");
|
|
1449
|
+
} catch (error) {
|
|
1450
|
+
consola.error(error);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
async function renderUsage(cmd, parent) {
|
|
1454
|
+
const cmdMeta = await resolveValue(cmd.meta || {});
|
|
1455
|
+
const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
|
|
1456
|
+
const parentMeta = await resolveValue(parent?.meta || {});
|
|
1457
|
+
const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
|
|
1458
|
+
const argLines = [];
|
|
1459
|
+
const posLines = [];
|
|
1460
|
+
const commandsLines = [];
|
|
1461
|
+
const usageLine = [];
|
|
1462
|
+
for (const arg of cmdArgs) {
|
|
1463
|
+
if (arg.type === "positional") {
|
|
1464
|
+
const name = arg.name.toUpperCase();
|
|
1465
|
+
const isRequired = arg.required !== false && arg.default === void 0;
|
|
1466
|
+
const defaultHint = arg.default ? `="${arg.default}"` : "";
|
|
1467
|
+
posLines.push([
|
|
1468
|
+
"`" + name + defaultHint + "`",
|
|
1469
|
+
arg.description || "",
|
|
1470
|
+
arg.valueHint ? `<${arg.valueHint}>` : ""
|
|
1471
|
+
]);
|
|
1472
|
+
usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
|
|
1473
|
+
} else {
|
|
1474
|
+
const isRequired = arg.required === true && arg.default === void 0;
|
|
1475
|
+
const argStr = (arg.type === "boolean" && arg.default === true ? [
|
|
1476
|
+
...(arg.alias || []).map((a2) => `--no-${a2}`),
|
|
1477
|
+
`--no-${arg.name}`
|
|
1478
|
+
].join(", ") : [...(arg.alias || []).map((a2) => `-${a2}`), `--${arg.name}`].join(
|
|
1479
|
+
", "
|
|
1480
|
+
)) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
|
|
1481
|
+
argLines.push([
|
|
1482
|
+
"`" + argStr + (isRequired ? " (required)" : "") + "`",
|
|
1483
|
+
arg.description || ""
|
|
1484
|
+
]);
|
|
1485
|
+
if (isRequired) {
|
|
1486
|
+
usageLine.push(argStr);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
if (cmd.subCommands) {
|
|
1491
|
+
const commandNames = [];
|
|
1492
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
1493
|
+
for (const [name, sub] of Object.entries(subCommands)) {
|
|
1494
|
+
const subCmd = await resolveValue(sub);
|
|
1495
|
+
const meta = await resolveValue(subCmd?.meta);
|
|
1496
|
+
commandsLines.push([`\`${name}\``, meta?.description || ""]);
|
|
1497
|
+
commandNames.push(name);
|
|
1498
|
+
}
|
|
1499
|
+
usageLine.push(commandNames.join("|"));
|
|
1500
|
+
}
|
|
1501
|
+
const usageLines = [];
|
|
1502
|
+
const version = cmdMeta.version || parentMeta.version;
|
|
1503
|
+
usageLines.push(
|
|
1504
|
+
colors.gray(
|
|
1505
|
+
`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`
|
|
1506
|
+
),
|
|
1507
|
+
""
|
|
1508
|
+
);
|
|
1509
|
+
const hasOptions = argLines.length > 0 || posLines.length > 0;
|
|
1510
|
+
usageLines.push(
|
|
1511
|
+
`${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``,
|
|
1512
|
+
""
|
|
1513
|
+
);
|
|
1514
|
+
if (posLines.length > 0) {
|
|
1515
|
+
usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
|
|
1516
|
+
usageLines.push(formatLineColumns(posLines, " "));
|
|
1517
|
+
usageLines.push("");
|
|
1518
|
+
}
|
|
1519
|
+
if (argLines.length > 0) {
|
|
1520
|
+
usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
|
|
1521
|
+
usageLines.push(formatLineColumns(argLines, " "));
|
|
1522
|
+
usageLines.push("");
|
|
1523
|
+
}
|
|
1524
|
+
if (commandsLines.length > 0) {
|
|
1525
|
+
usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
|
|
1526
|
+
usageLines.push(formatLineColumns(commandsLines, " "));
|
|
1527
|
+
usageLines.push(
|
|
1528
|
+
"",
|
|
1529
|
+
`Use \`${commandName} <command> --help\` for more information about a command.`
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
return usageLines.filter((l2) => typeof l2 === "string").join("\n");
|
|
1533
|
+
}
|
|
1534
|
+
async function runMain(cmd, opts = {}) {
|
|
1535
|
+
const rawArgs = opts.rawArgs || process.argv.slice(2);
|
|
1536
|
+
const showUsage$1 = opts.showUsage || showUsage;
|
|
1537
|
+
try {
|
|
1538
|
+
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
1539
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
1540
|
+
process.exit(0);
|
|
1541
|
+
} else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
|
|
1542
|
+
const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
|
|
1543
|
+
if (!meta?.version) {
|
|
1544
|
+
throw new CLIError("No version specified", "E_NO_VERSION");
|
|
1545
|
+
}
|
|
1546
|
+
consola.log(meta.version);
|
|
1547
|
+
} else {
|
|
1548
|
+
await runCommand(cmd, { rawArgs });
|
|
1549
|
+
}
|
|
1550
|
+
} catch (error) {
|
|
1551
|
+
const isCLIError = error instanceof CLIError;
|
|
1552
|
+
if (!isCLIError) {
|
|
1553
|
+
consola.error(error, "\n");
|
|
1554
|
+
}
|
|
1555
|
+
if (isCLIError) {
|
|
1556
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
1557
|
+
}
|
|
1558
|
+
consola.error(error.message);
|
|
1559
|
+
process.exit(1);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
9
1562
|
|
|
10
1563
|
// src/blueprints.ts
|
|
1564
|
+
import { randomBytes } from "crypto";
|
|
11
1565
|
import { cp, readFile, writeFile } from "fs/promises";
|
|
12
1566
|
import { basename, join, relative } from "path";
|
|
13
|
-
import
|
|
1567
|
+
import process2 from "process";
|
|
14
1568
|
import { fileURLToPath } from "url";
|
|
15
1569
|
|
|
16
1570
|
// src/utils.ts
|
|
@@ -62,8 +1616,8 @@ function toPackageName(value) {
|
|
|
62
1616
|
|
|
63
1617
|
// src/blueprints.ts
|
|
64
1618
|
var APP_BLUEPRINTS = ["default", "api", "blog", "worker"];
|
|
1619
|
+
var DATABASE_DRIVERS = ["sqlite", "postgres", "mysql"];
|
|
65
1620
|
var DEFAULT_TRANSFORM_FILES = [
|
|
66
|
-
"CLAUDE.md",
|
|
67
1621
|
"README.md",
|
|
68
1622
|
"package.json",
|
|
69
1623
|
"public/index.html",
|
|
@@ -90,6 +1644,8 @@ var BLOG_OVERLAY_EXCLUDES = [
|
|
|
90
1644
|
".env",
|
|
91
1645
|
".guren",
|
|
92
1646
|
"CLAUDE.md",
|
|
1647
|
+
"db/migrations",
|
|
1648
|
+
"db/schema.ts",
|
|
93
1649
|
"node_modules",
|
|
94
1650
|
"package.json",
|
|
95
1651
|
"public/assets",
|
|
@@ -140,13 +1696,13 @@ var blueprintRegistry = {
|
|
|
140
1696
|
["Guren Blog", appTitle],
|
|
141
1697
|
["blog.example.com", `${packageName}.example.com`]
|
|
142
1698
|
]),
|
|
143
|
-
postScaffold: async ({ destination, renderingMode }) => {
|
|
1699
|
+
postScaffold: async ({ destination, renderingMode, database }) => {
|
|
144
1700
|
const packageJsonPath = join(destination, "package.json");
|
|
145
1701
|
const rawPackage = await readFile(packageJsonPath, "utf8");
|
|
146
1702
|
const packageJson = JSON.parse(rawPackage);
|
|
147
1703
|
packageJson.scripts ??= {};
|
|
148
1704
|
packageJson.dependencies ??= {};
|
|
149
|
-
const gurenVersion = packageJson.dependencies["@guren/core"] ?? packageJson.dependencies["@guren/server"] ?? packageJson.dependencies["@guren/orm"] ?? "^0.
|
|
1705
|
+
const gurenVersion = packageJson.dependencies["@guren/core"] ?? packageJson.dependencies["@guren/server"] ?? packageJson.dependencies["@guren/orm"] ?? "^1.0.0";
|
|
150
1706
|
packageJson.scripts.typecheck ??= "tsc --noEmit";
|
|
151
1707
|
packageJson.scripts.smoke ??= "bun run ./smoke.ts";
|
|
152
1708
|
packageJson.dependencies["@guren/core"] ??= gurenVersion;
|
|
@@ -155,6 +1711,14 @@ var blueprintRegistry = {
|
|
|
155
1711
|
packageJson.dependencies.zod ??= "^4.1.5";
|
|
156
1712
|
await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
157
1713
|
`, "utf8");
|
|
1714
|
+
const schemaPath = join(destination, "db/schema.ts");
|
|
1715
|
+
await writeFile(schemaPath, generateBlogSchema(database), "utf8");
|
|
1716
|
+
if (database === "postgres") {
|
|
1717
|
+
await cp(join(exampleBlogDir, "db/migrations"), join(destination, "db/migrations"), {
|
|
1718
|
+
recursive: true,
|
|
1719
|
+
force: true
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
158
1722
|
if (renderingMode === "spa") {
|
|
159
1723
|
const mainPath = join(destination, "src/main.ts");
|
|
160
1724
|
const mainSource = await readFile(mainPath, "utf8");
|
|
@@ -179,16 +1743,22 @@ var blueprintRegistry = {
|
|
|
179
1743
|
},
|
|
180
1744
|
transformFiles: DEFAULT_TRANSFORM_FILES,
|
|
181
1745
|
postScaffold: async ({ destination }) => {
|
|
182
|
-
|
|
183
|
-
|
|
1746
|
+
let runBlueprint;
|
|
1747
|
+
try {
|
|
1748
|
+
;
|
|
1749
|
+
({ runBlueprint } = await import("@guren/cli"));
|
|
1750
|
+
} catch {
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
const originalCwd = process2.cwd();
|
|
184
1754
|
try {
|
|
185
|
-
|
|
1755
|
+
process2.chdir(destination);
|
|
186
1756
|
await runBlueprint("queue", { force: true });
|
|
187
1757
|
await runBlueprint("events", { force: true });
|
|
188
1758
|
await runBlueprint("cache", { force: true });
|
|
189
1759
|
await runBlueprint("schedule", { force: true });
|
|
190
1760
|
} finally {
|
|
191
|
-
|
|
1761
|
+
process2.chdir(originalCwd);
|
|
192
1762
|
}
|
|
193
1763
|
}
|
|
194
1764
|
}
|
|
@@ -239,12 +1809,247 @@ async function scaffoldEnvFiles(destination) {
|
|
|
239
1809
|
} catch {
|
|
240
1810
|
return;
|
|
241
1811
|
}
|
|
242
|
-
const
|
|
243
|
-
const appKey = generateKeyValue();
|
|
1812
|
+
const appKey = `base64:${randomBytes(32).toString("base64")}`;
|
|
244
1813
|
const envContent = envExample.replace(/^APP_KEY=.*$/mu, `APP_KEY=${appKey}`);
|
|
245
1814
|
await writeFile(envPath, envContent.endsWith("\n") ? envContent : `${envContent}
|
|
246
1815
|
`, "utf8");
|
|
247
1816
|
}
|
|
1817
|
+
var DATABASE_DEFAULTS = {
|
|
1818
|
+
postgres: { url: "postgres://guren:guren@localhost:54322/guren", dialect: "postgresql", dep: { postgres: "^3.4.3" } },
|
|
1819
|
+
mysql: { url: "mysql://guren:guren@localhost:33306/guren", dialect: "mysql", dep: { mysql2: "^3.11.3" } },
|
|
1820
|
+
sqlite: { url: "./data/guren.db", dialect: "sqlite", dep: null }
|
|
1821
|
+
};
|
|
1822
|
+
function generateDatabaseConfig(driver) {
|
|
1823
|
+
const { url } = DATABASE_DEFAULTS[driver];
|
|
1824
|
+
if (driver === "postgres") {
|
|
1825
|
+
return `import { createPostgresDatabase } from '@guren/orm'
|
|
1826
|
+
|
|
1827
|
+
const database = createPostgresDatabase({
|
|
1828
|
+
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
1829
|
+
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
1830
|
+
connectionString: () => process.env.DATABASE_URL ?? '${url}',
|
|
1831
|
+
})
|
|
1832
|
+
|
|
1833
|
+
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
1834
|
+
`;
|
|
1835
|
+
}
|
|
1836
|
+
if (driver === "mysql") {
|
|
1837
|
+
return `import { createMySqlDatabase } from '@guren/orm'
|
|
1838
|
+
|
|
1839
|
+
const database = createMySqlDatabase({
|
|
1840
|
+
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
1841
|
+
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
1842
|
+
connectionString: () => process.env.DATABASE_URL ?? '${url}',
|
|
1843
|
+
})
|
|
1844
|
+
|
|
1845
|
+
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
1846
|
+
`;
|
|
1847
|
+
}
|
|
1848
|
+
return `import { createSqliteDatabase } from '@guren/orm'
|
|
1849
|
+
|
|
1850
|
+
const database = createSqliteDatabase({
|
|
1851
|
+
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
1852
|
+
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
1853
|
+
filename: () => process.env.DATABASE_URL ?? '${url}',
|
|
1854
|
+
})
|
|
1855
|
+
|
|
1856
|
+
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
1857
|
+
`;
|
|
1858
|
+
}
|
|
1859
|
+
function generateSchema(driver) {
|
|
1860
|
+
if (driver === "postgres") {
|
|
1861
|
+
return `import { pgTable, serial, text, timestamp } from '@guren/orm/drizzle'
|
|
1862
|
+
|
|
1863
|
+
export const users = pgTable('users', {
|
|
1864
|
+
id: serial('id').primaryKey(),
|
|
1865
|
+
name: text('name').notNull(),
|
|
1866
|
+
email: text('email').notNull(),
|
|
1867
|
+
createdAt: timestamp('created_at').notNull().defaultNow(),
|
|
1868
|
+
})
|
|
1869
|
+
`;
|
|
1870
|
+
}
|
|
1871
|
+
if (driver === "mysql") {
|
|
1872
|
+
return `import { mysqlTable, int, varchar, timestamp } from '@guren/orm/drizzle'
|
|
1873
|
+
|
|
1874
|
+
export const users = mysqlTable('users', {
|
|
1875
|
+
id: int('id').primaryKey().autoincrement(),
|
|
1876
|
+
name: varchar('name', { length: 255 }).notNull(),
|
|
1877
|
+
email: varchar('email', { length: 255 }).notNull(),
|
|
1878
|
+
createdAt: timestamp('created_at').notNull().defaultNow(),
|
|
1879
|
+
})
|
|
1880
|
+
`;
|
|
1881
|
+
}
|
|
1882
|
+
return `import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core'
|
|
1883
|
+
|
|
1884
|
+
export const users = sqliteTable('users', {
|
|
1885
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
1886
|
+
name: text('name').notNull(),
|
|
1887
|
+
email: text('email').notNull(),
|
|
1888
|
+
createdAt: text('created_at').notNull().$defaultFn(() => new Date().toISOString()),
|
|
1889
|
+
})
|
|
1890
|
+
`;
|
|
1891
|
+
}
|
|
1892
|
+
function generateBlogSchema(driver) {
|
|
1893
|
+
if (driver === "postgres") {
|
|
1894
|
+
return `import { pgTable, serial, text, integer, uniqueIndex } from '@guren/orm/drizzle'
|
|
1895
|
+
|
|
1896
|
+
export const users = pgTable(
|
|
1897
|
+
'users',
|
|
1898
|
+
{
|
|
1899
|
+
id: serial('id').primaryKey(),
|
|
1900
|
+
name: text('name').notNull(),
|
|
1901
|
+
email: text('email').notNull(),
|
|
1902
|
+
passwordHash: text('password_hash').notNull(),
|
|
1903
|
+
rememberToken: text('remember_token'),
|
|
1904
|
+
},
|
|
1905
|
+
(table) => [uniqueIndex('users_email_unique').on(table.email)],
|
|
1906
|
+
)
|
|
1907
|
+
|
|
1908
|
+
export const posts = pgTable('posts', {
|
|
1909
|
+
id: serial('id').primaryKey(),
|
|
1910
|
+
title: text('title').notNull(),
|
|
1911
|
+
excerpt: text('excerpt').notNull(),
|
|
1912
|
+
body: text('body'),
|
|
1913
|
+
authorId: integer('author_id').notNull().references(() => users.id),
|
|
1914
|
+
})
|
|
1915
|
+
|
|
1916
|
+
export const schema = { posts, users }
|
|
1917
|
+
export type BlogSchema = typeof schema
|
|
1918
|
+
`;
|
|
1919
|
+
}
|
|
1920
|
+
if (driver === "mysql") {
|
|
1921
|
+
return `import { mysqlTable, int, varchar, text, uniqueIndex } from '@guren/orm/drizzle'
|
|
1922
|
+
|
|
1923
|
+
export const users = mysqlTable(
|
|
1924
|
+
'users',
|
|
1925
|
+
{
|
|
1926
|
+
id: int('id').primaryKey().autoincrement(),
|
|
1927
|
+
name: varchar('name', { length: 255 }).notNull(),
|
|
1928
|
+
email: varchar('email', { length: 255 }).notNull(),
|
|
1929
|
+
passwordHash: varchar('password_hash', { length: 255 }).notNull(),
|
|
1930
|
+
rememberToken: varchar('remember_token', { length: 255 }),
|
|
1931
|
+
},
|
|
1932
|
+
(table) => [uniqueIndex('users_email_unique').on(table.email)],
|
|
1933
|
+
)
|
|
1934
|
+
|
|
1935
|
+
export const posts = mysqlTable('posts', {
|
|
1936
|
+
id: int('id').primaryKey().autoincrement(),
|
|
1937
|
+
title: varchar('title', { length: 255 }).notNull(),
|
|
1938
|
+
excerpt: varchar('excerpt', { length: 500 }).notNull(),
|
|
1939
|
+
body: text('body'),
|
|
1940
|
+
authorId: int('author_id').notNull().references(() => users.id),
|
|
1941
|
+
})
|
|
1942
|
+
|
|
1943
|
+
export const schema = { posts, users }
|
|
1944
|
+
export type BlogSchema = typeof schema
|
|
1945
|
+
`;
|
|
1946
|
+
}
|
|
1947
|
+
return `import { sqliteTable, integer, text, uniqueIndex } from 'drizzle-orm/sqlite-core'
|
|
1948
|
+
|
|
1949
|
+
export const users = sqliteTable(
|
|
1950
|
+
'users',
|
|
1951
|
+
{
|
|
1952
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
1953
|
+
name: text('name').notNull(),
|
|
1954
|
+
email: text('email').notNull(),
|
|
1955
|
+
passwordHash: text('password_hash').notNull(),
|
|
1956
|
+
rememberToken: text('remember_token'),
|
|
1957
|
+
},
|
|
1958
|
+
(table) => [uniqueIndex('users_email_unique').on(table.email)],
|
|
1959
|
+
)
|
|
1960
|
+
|
|
1961
|
+
export const posts = sqliteTable('posts', {
|
|
1962
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
1963
|
+
title: text('title').notNull(),
|
|
1964
|
+
excerpt: text('excerpt').notNull(),
|
|
1965
|
+
body: text('body'),
|
|
1966
|
+
authorId: integer('author_id').notNull().references(() => users.id),
|
|
1967
|
+
})
|
|
1968
|
+
|
|
1969
|
+
export const schema = { posts, users }
|
|
1970
|
+
export type BlogSchema = typeof schema
|
|
1971
|
+
`;
|
|
1972
|
+
}
|
|
1973
|
+
function generateDrizzleConfig(driver) {
|
|
1974
|
+
const { url, dialect } = DATABASE_DEFAULTS[driver];
|
|
1975
|
+
return `import { defineConfig } from 'drizzle-kit'
|
|
1976
|
+
|
|
1977
|
+
export default defineConfig({
|
|
1978
|
+
schema: './db/schema.ts',
|
|
1979
|
+
out: './db/migrations',
|
|
1980
|
+
dialect: '${dialect}',
|
|
1981
|
+
dbCredentials: {
|
|
1982
|
+
url: process.env.DATABASE_URL ?? '${url}',
|
|
1983
|
+
},
|
|
1984
|
+
})
|
|
1985
|
+
`;
|
|
1986
|
+
}
|
|
1987
|
+
function generateDockerCompose(driver) {
|
|
1988
|
+
if (driver === "postgres") {
|
|
1989
|
+
return `services:
|
|
1990
|
+
postgres:
|
|
1991
|
+
image: postgres:17-alpine
|
|
1992
|
+
ports:
|
|
1993
|
+
- '54322:5432'
|
|
1994
|
+
environment:
|
|
1995
|
+
POSTGRES_USER: guren
|
|
1996
|
+
POSTGRES_PASSWORD: guren
|
|
1997
|
+
POSTGRES_DB: guren
|
|
1998
|
+
volumes:
|
|
1999
|
+
- postgres_data:/var/lib/postgresql/data
|
|
2000
|
+
|
|
2001
|
+
volumes:
|
|
2002
|
+
postgres_data:
|
|
2003
|
+
`;
|
|
2004
|
+
}
|
|
2005
|
+
if (driver === "mysql") {
|
|
2006
|
+
return `services:
|
|
2007
|
+
mysql:
|
|
2008
|
+
image: mysql:8.4
|
|
2009
|
+
ports:
|
|
2010
|
+
- '33306:3306'
|
|
2011
|
+
environment:
|
|
2012
|
+
MYSQL_ROOT_PASSWORD: guren
|
|
2013
|
+
MYSQL_USER: guren
|
|
2014
|
+
MYSQL_PASSWORD: guren
|
|
2015
|
+
MYSQL_DATABASE: guren
|
|
2016
|
+
volumes:
|
|
2017
|
+
- mysql_data:/var/lib/mysql
|
|
2018
|
+
|
|
2019
|
+
volumes:
|
|
2020
|
+
mysql_data:
|
|
2021
|
+
`;
|
|
2022
|
+
}
|
|
2023
|
+
return null;
|
|
2024
|
+
}
|
|
2025
|
+
async function applyDatabaseConfig(destination, driver) {
|
|
2026
|
+
const { url, dep } = DATABASE_DEFAULTS[driver];
|
|
2027
|
+
const dockerCompose = generateDockerCompose(driver);
|
|
2028
|
+
await Promise.all([
|
|
2029
|
+
writeFile(join(destination, "config/database.ts"), generateDatabaseConfig(driver), "utf8"),
|
|
2030
|
+
writeFile(join(destination, "db/schema.ts"), generateSchema(driver), "utf8"),
|
|
2031
|
+
writeFile(join(destination, "drizzle.config.ts"), generateDrizzleConfig(driver), "utf8"),
|
|
2032
|
+
dockerCompose ? writeFile(join(destination, "docker-compose.yml"), dockerCompose, "utf8") : Promise.resolve(),
|
|
2033
|
+
// Update .env and .env.example with the correct DATABASE_URL
|
|
2034
|
+
...[".env", ".env.example"].map(async (envFile) => {
|
|
2035
|
+
const envPath = join(destination, envFile);
|
|
2036
|
+
try {
|
|
2037
|
+
const content = await readFile(envPath, "utf8");
|
|
2038
|
+
await writeFile(envPath, content.replace(/^DATABASE_URL=.*$/mu, `DATABASE_URL=${url}`), "utf8");
|
|
2039
|
+
} catch {
|
|
2040
|
+
}
|
|
2041
|
+
})
|
|
2042
|
+
]);
|
|
2043
|
+
if (dep) {
|
|
2044
|
+
const packageJsonPath = join(destination, "package.json");
|
|
2045
|
+
const raw = await readFile(packageJsonPath, "utf8");
|
|
2046
|
+
const pkg = JSON.parse(raw);
|
|
2047
|
+
pkg.dependencies ??= {};
|
|
2048
|
+
Object.assign(pkg.dependencies, dep);
|
|
2049
|
+
await writeFile(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
|
|
2050
|
+
`, "utf8");
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
248
2053
|
function listAppBlueprints() {
|
|
249
2054
|
return [...APP_BLUEPRINTS];
|
|
250
2055
|
}
|
|
@@ -266,7 +2071,8 @@ async function scaffoldAppBlueprint(options) {
|
|
|
266
2071
|
appTitle,
|
|
267
2072
|
destination: options.destination,
|
|
268
2073
|
packageName,
|
|
269
|
-
renderingMode: options.renderingMode
|
|
2074
|
+
renderingMode: options.renderingMode,
|
|
2075
|
+
database: options.database
|
|
270
2076
|
};
|
|
271
2077
|
const tokenMap = /* @__PURE__ */ new Map([
|
|
272
2078
|
["guren-app-placeholder", packageName],
|
|
@@ -282,6 +2088,7 @@ async function scaffoldAppBlueprint(options) {
|
|
|
282
2088
|
}
|
|
283
2089
|
await applyTokenTransforms(options.destination, blueprint.transformFiles, tokenMap);
|
|
284
2090
|
await scaffoldEnvFiles(options.destination);
|
|
2091
|
+
await applyDatabaseConfig(options.destination, options.database);
|
|
285
2092
|
await blueprint.postScaffold?.(context);
|
|
286
2093
|
return blueprint;
|
|
287
2094
|
}
|
|
@@ -289,6 +2096,7 @@ async function scaffoldAppBlueprint(options) {
|
|
|
289
2096
|
// src/cli.ts
|
|
290
2097
|
var RENDERING_MODES = ["spa", "ssr"];
|
|
291
2098
|
var RENDERING_MODE_SET = new Set(RENDERING_MODES);
|
|
2099
|
+
var DATABASE_DRIVER_SET = new Set(DATABASE_DRIVERS);
|
|
292
2100
|
async function ensureTargetDirectory(path, force) {
|
|
293
2101
|
try {
|
|
294
2102
|
await mkdir(path, { recursive: true });
|
|
@@ -314,9 +2122,14 @@ async function updateSsrPackageJson(destination) {
|
|
|
314
2122
|
await writeFile2(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
|
|
315
2123
|
`, "utf8");
|
|
316
2124
|
}
|
|
317
|
-
async function
|
|
318
|
-
const {
|
|
319
|
-
|
|
2125
|
+
async function runAppCli(targetDir, cliArgs) {
|
|
2126
|
+
const { spawnSync } = await import("child_process");
|
|
2127
|
+
const cliBin = resolve(targetDir, "node_modules/@guren/cli/dist/bin.js");
|
|
2128
|
+
const result = spawnSync("bun", [cliBin, ...cliArgs], {
|
|
2129
|
+
cwd: targetDir,
|
|
2130
|
+
stdio: "inherit"
|
|
2131
|
+
});
|
|
2132
|
+
return result.status === 0;
|
|
320
2133
|
}
|
|
321
2134
|
async function resolveRenderingMode(flagValue) {
|
|
322
2135
|
if (typeof flagValue === "string") {
|
|
@@ -326,7 +2139,7 @@ async function resolveRenderingMode(flagValue) {
|
|
|
326
2139
|
}
|
|
327
2140
|
return normalized;
|
|
328
2141
|
}
|
|
329
|
-
if (!
|
|
2142
|
+
if (!process3.stdin.isTTY) {
|
|
330
2143
|
return "ssr";
|
|
331
2144
|
}
|
|
332
2145
|
const result = await consola.prompt("Choose the rendering mode for this project", {
|
|
@@ -341,6 +2154,46 @@ async function resolveRenderingMode(flagValue) {
|
|
|
341
2154
|
const value = typeof result === "string" ? result : "ssr";
|
|
342
2155
|
return value ?? "ssr";
|
|
343
2156
|
}
|
|
2157
|
+
async function resolveDatabase(flagValue) {
|
|
2158
|
+
if (typeof flagValue === "string") {
|
|
2159
|
+
const normalized = flagValue.toLowerCase();
|
|
2160
|
+
if (!DATABASE_DRIVER_SET.has(normalized)) {
|
|
2161
|
+
throw new Error(`Invalid database driver. Supported values are: ${DATABASE_DRIVERS.join(", ")}`);
|
|
2162
|
+
}
|
|
2163
|
+
return normalized;
|
|
2164
|
+
}
|
|
2165
|
+
if (!process3.stdin.isTTY) {
|
|
2166
|
+
return "sqlite";
|
|
2167
|
+
}
|
|
2168
|
+
const result = await consola.prompt("Choose the database driver", {
|
|
2169
|
+
type: "select",
|
|
2170
|
+
options: [
|
|
2171
|
+
{ value: "sqlite", label: "SQLite (zero-config, recommended for getting started)" },
|
|
2172
|
+
{ value: "postgres", label: "PostgreSQL" },
|
|
2173
|
+
{ value: "mysql", label: "MySQL" }
|
|
2174
|
+
],
|
|
2175
|
+
initial: "sqlite",
|
|
2176
|
+
default: "sqlite"
|
|
2177
|
+
});
|
|
2178
|
+
const value = typeof result === "string" ? result : "sqlite";
|
|
2179
|
+
return value ?? "sqlite";
|
|
2180
|
+
}
|
|
2181
|
+
async function installDependencies(cwd) {
|
|
2182
|
+
try {
|
|
2183
|
+
consola.start("Installing dependencies...");
|
|
2184
|
+
const { spawnSync } = await import("child_process");
|
|
2185
|
+
const result = spawnSync("bun", ["install"], { cwd, stdio: "inherit" });
|
|
2186
|
+
if (result.status !== 0) {
|
|
2187
|
+
consola.warn("Failed to install dependencies. Run `bun install` manually.");
|
|
2188
|
+
return false;
|
|
2189
|
+
}
|
|
2190
|
+
consola.success("Dependencies installed");
|
|
2191
|
+
return true;
|
|
2192
|
+
} catch {
|
|
2193
|
+
consola.warn("Failed to install dependencies. Run `bun install` manually.");
|
|
2194
|
+
return false;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
344
2197
|
var command = defineCommand({
|
|
345
2198
|
meta: {
|
|
346
2199
|
name: "create-guren-app",
|
|
@@ -368,12 +2221,21 @@ var command = defineCommand({
|
|
|
368
2221
|
blueprint: {
|
|
369
2222
|
type: "string",
|
|
370
2223
|
description: `Starter blueprint to scaffold (${listAppBlueprints().join(", ")})`
|
|
2224
|
+
},
|
|
2225
|
+
db: {
|
|
2226
|
+
type: "string",
|
|
2227
|
+
description: `Database driver (${DATABASE_DRIVERS.join(", ")})`
|
|
2228
|
+
},
|
|
2229
|
+
install: {
|
|
2230
|
+
type: "boolean",
|
|
2231
|
+
description: "Install dependencies after scaffolding (default: true)",
|
|
2232
|
+
default: true
|
|
371
2233
|
}
|
|
372
2234
|
},
|
|
373
2235
|
async run({ args }) {
|
|
374
2236
|
const target = args.target;
|
|
375
2237
|
const force = Boolean(args.force);
|
|
376
|
-
const targetDir = resolve(
|
|
2238
|
+
const targetDir = resolve(process3.cwd(), target);
|
|
377
2239
|
if (await directoryExists(targetDir)) {
|
|
378
2240
|
if (!force) {
|
|
379
2241
|
const empty = await isDirectoryEmpty(targetDir);
|
|
@@ -386,34 +2248,58 @@ var command = defineCommand({
|
|
|
386
2248
|
}
|
|
387
2249
|
const blueprint = getAppBlueprint(typeof args.blueprint === "string" ? args.blueprint : void 0);
|
|
388
2250
|
const renderingMode = blueprint.name === "api" ? "spa" : await resolveRenderingMode(args.mode);
|
|
2251
|
+
const database = await resolveDatabase(args.db);
|
|
389
2252
|
await scaffoldAppBlueprint({
|
|
390
2253
|
blueprint: blueprint.name,
|
|
391
2254
|
destination: targetDir,
|
|
392
|
-
renderingMode
|
|
2255
|
+
renderingMode,
|
|
2256
|
+
database
|
|
393
2257
|
});
|
|
394
2258
|
if (renderingMode === "ssr") {
|
|
395
2259
|
await updateSsrPackageJson(targetDir);
|
|
396
2260
|
}
|
|
397
2261
|
const includeAuth = Boolean(args.auth);
|
|
2262
|
+
const shouldInstall = args.install !== false;
|
|
2263
|
+
let installed = false;
|
|
2264
|
+
if (shouldInstall) {
|
|
2265
|
+
installed = await installDependencies(targetDir);
|
|
2266
|
+
}
|
|
2267
|
+
let harnessInstalled = false;
|
|
2268
|
+
if (installed) {
|
|
2269
|
+
consola.start("Setting up AI agent harness...");
|
|
2270
|
+
harnessInstalled = await runAppCli(targetDir, ["agent:init"]);
|
|
2271
|
+
if (harnessInstalled) {
|
|
2272
|
+
consola.success("AI agent harness installed (CLAUDE.md, .claude/, .mcp.json)");
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
if (!harnessInstalled) {
|
|
2276
|
+
consola.warn("AI agent harness was not installed automatically. Run `bunx guren agent:init` inside the app after installing dependencies.");
|
|
2277
|
+
}
|
|
2278
|
+
let authInstalled = false;
|
|
398
2279
|
if (includeAuth) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
2280
|
+
if (installed) {
|
|
2281
|
+
consola.start("Adding authentication scaffolding...");
|
|
2282
|
+
authInstalled = await runAppCli(targetDir, ["add", "auth", "--force"]);
|
|
2283
|
+
if (authInstalled) {
|
|
2284
|
+
consola.success("Authentication scaffolding added");
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
if (!authInstalled) {
|
|
2288
|
+
consola.warn("Authentication was not scaffolded automatically. Run `bunx guren add auth` inside the app after installing dependencies.");
|
|
408
2289
|
}
|
|
409
2290
|
}
|
|
410
|
-
const relativeTarget = relative2(
|
|
411
|
-
consola.success(`Scaffolded a new Guren app (${blueprint.name}/${renderingMode.toUpperCase()}) in ${relativeTarget}`);
|
|
2291
|
+
const relativeTarget = relative2(process3.cwd(), targetDir) || ".";
|
|
2292
|
+
consola.success(`Scaffolded a new Guren app (${blueprint.name}/${renderingMode.toUpperCase()}/${database}) in ${relativeTarget}`);
|
|
412
2293
|
consola.info("Next steps:");
|
|
413
2294
|
if (relativeTarget !== ".") {
|
|
414
2295
|
consola.log(` cd ${relativeTarget}`);
|
|
415
2296
|
}
|
|
416
|
-
|
|
2297
|
+
if (!installed) {
|
|
2298
|
+
consola.log(" bun install");
|
|
2299
|
+
}
|
|
2300
|
+
if (database !== "sqlite") {
|
|
2301
|
+
consola.log(" docker compose up -d");
|
|
2302
|
+
}
|
|
417
2303
|
consola.log("");
|
|
418
2304
|
consola.info("Add features:");
|
|
419
2305
|
consola.log(" bunx guren add auth");
|
|
@@ -421,6 +2307,7 @@ var command = defineCommand({
|
|
|
421
2307
|
consola.log("");
|
|
422
2308
|
consola.info("Generate types and set up database:");
|
|
423
2309
|
consola.log(" bun run codegen");
|
|
2310
|
+
consola.log(" bun run db:make");
|
|
424
2311
|
consola.log(" bun run db:migrate");
|
|
425
2312
|
consola.log(" bun run db:seed");
|
|
426
2313
|
consola.log("");
|
|
@@ -428,14 +2315,19 @@ var command = defineCommand({
|
|
|
428
2315
|
consola.log(" bun run typecheck");
|
|
429
2316
|
consola.log(" bun run test");
|
|
430
2317
|
consola.log(" bun run dev");
|
|
431
|
-
if (
|
|
2318
|
+
if (authInstalled) {
|
|
432
2319
|
consola.log("");
|
|
433
2320
|
consola.info("Auth scaffolding was included automatically.");
|
|
2321
|
+
consola.info("Set up the users table with: bun run db:migrate && bun run db:seed");
|
|
434
2322
|
}
|
|
435
2323
|
if (renderingMode === "ssr") {
|
|
436
2324
|
consola.log("");
|
|
437
2325
|
consola.info("Production build:");
|
|
438
2326
|
consola.log(" bun run build");
|
|
2327
|
+
consola.log("");
|
|
2328
|
+
consola.info("Optional deploy path:");
|
|
2329
|
+
consola.log(" bunx guren plugin @guren/plugin-vercel");
|
|
2330
|
+
consola.log(" bun add @guren/plugin-vercel");
|
|
439
2331
|
}
|
|
440
2332
|
}
|
|
441
2333
|
});
|
|
@@ -445,5 +2337,5 @@ runMain(command).catch((error) => {
|
|
|
445
2337
|
} else {
|
|
446
2338
|
consola.error(String(error));
|
|
447
2339
|
}
|
|
448
|
-
|
|
2340
|
+
process3.exit(1);
|
|
449
2341
|
});
|