create-guren-app 1.8.7 → 1.8.9

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 CHANGED
@@ -1,506 +1,385 @@
1
1
  #!/usr/bin/env node
2
-
3
- // src/cli.ts
4
- import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
5
- import { relative as relative2, resolve } from "path";
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
2
+ import { cp, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, join, relative, resolve, sep } from "node:path";
4
+ import g$1 from "node:process";
5
+ import { formatWithOptions } from "node:util";
6
+ import * as tty from "node:tty";
7
+ import { randomBytes } from "node:crypto";
8
+ import { fileURLToPath } from "node:url";
9
+ import { spawnSync } from "node:child_process";
10
+ //#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/core.mjs
11
+ const LogLevels = {
12
+ silent: Number.NEGATIVE_INFINITY,
13
+ fatal: 0,
14
+ error: 0,
15
+ warn: 1,
16
+ log: 2,
17
+ info: 3,
18
+ success: 3,
19
+ fail: 3,
20
+ ready: 3,
21
+ start: 3,
22
+ box: 3,
23
+ debug: 4,
24
+ trace: 5,
25
+ verbose: Number.POSITIVE_INFINITY
24
26
  };
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
- }
27
+ const LogTypes = {
28
+ silent: { level: -1 },
29
+ fatal: { level: LogLevels.fatal },
30
+ error: { level: LogLevels.error },
31
+ warn: { level: LogLevels.warn },
32
+ log: { level: LogLevels.log },
33
+ info: { level: LogLevels.info },
34
+ success: { level: LogLevels.success },
35
+ fail: { level: LogLevels.fail },
36
+ ready: { level: LogLevels.info },
37
+ start: { level: LogLevels.info },
38
+ box: { level: LogLevels.info },
39
+ debug: { level: LogLevels.debug },
40
+ trace: { level: LogLevels.trace },
41
+ verbose: { level: LogLevels.verbose }
76
42
  };
77
43
  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;
44
+ if (value === null || typeof value !== "object") return false;
45
+ const prototype = Object.getPrototypeOf(value);
46
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
47
+ if (Symbol.iterator in value) return false;
48
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
49
+ return true;
92
50
  }
93
51
  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;
52
+ if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
53
+ const object = Object.assign({}, defaults);
54
+ for (const key in baseObject) {
55
+ if (key === "__proto__" || key === "constructor") continue;
56
+ const value = baseObject[key];
57
+ if (value === null || value === void 0) continue;
58
+ if (merger && merger(object, key, value, namespace)) continue;
59
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
60
+ else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
61
+ else object[key] = value;
62
+ }
63
+ return object;
123
64
  }
124
65
  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
- );
66
+ return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
129
67
  }
130
- var defu = createDefu();
68
+ const defu = createDefu();
131
69
  function isPlainObject(obj) {
132
- return Object.prototype.toString.call(obj) === "[object Object]";
70
+ return Object.prototype.toString.call(obj) === "[object Object]";
133
71
  }
134
72
  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
- }
73
+ if (!isPlainObject(arg)) return false;
74
+ if (!arg.message && !arg.args) return false;
75
+ if (arg.stack) return false;
76
+ return true;
77
+ }
78
+ let paused = false;
79
+ const queue = [];
80
+ var Consola = class Consola {
81
+ options;
82
+ _lastLog;
83
+ _mockFn;
84
+ /**
85
+ * Creates an instance of Consola with specified options or defaults.
86
+ *
87
+ * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
88
+ */
89
+ constructor(options = {}) {
90
+ const types = options.types || LogTypes;
91
+ this.options = defu({
92
+ ...options,
93
+ defaults: { ...options.defaults },
94
+ level: _normalizeLogLevel(options.level, types),
95
+ reporters: [...options.reporters || []]
96
+ }, {
97
+ types: LogTypes,
98
+ throttle: 1e3,
99
+ throttleMin: 5,
100
+ formatOptions: {
101
+ date: true,
102
+ colors: false,
103
+ compact: true
104
+ }
105
+ });
106
+ for (const type in types) {
107
+ const defaults = {
108
+ type,
109
+ ...this.options.defaults,
110
+ ...types[type]
111
+ };
112
+ this[type] = this._wrapLogFn(defaults);
113
+ this[type].raw = this._wrapLogFn(defaults, true);
114
+ }
115
+ if (this.options.mockFn) this.mockTypes();
116
+ this._lastLog = {};
117
+ }
118
+ /**
119
+ * Gets the current log level of the Consola instance.
120
+ *
121
+ * @returns {number} The current log level.
122
+ */
123
+ get level() {
124
+ return this.options.level;
125
+ }
126
+ /**
127
+ * Sets the minimum log level that will be output by the instance.
128
+ *
129
+ * @param {number} level - The new log level to set.
130
+ */
131
+ set level(level) {
132
+ this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
133
+ }
134
+ /**
135
+ * Displays a prompt to the user and returns the response.
136
+ * Throw an error if `prompt` is not supported by the current configuration.
137
+ *
138
+ * @template T
139
+ * @param {string} message - The message to display in the prompt.
140
+ * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
141
+ * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
142
+ */
143
+ prompt(message, opts) {
144
+ if (!this.options.prompt) throw new Error("prompt is not supported!");
145
+ return this.options.prompt(message, opts);
146
+ }
147
+ /**
148
+ * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
149
+ *
150
+ * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
151
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
152
+ */
153
+ create(options) {
154
+ const instance = new Consola({
155
+ ...this.options,
156
+ ...options
157
+ });
158
+ if (this._mockFn) instance.mockTypes(this._mockFn);
159
+ return instance;
160
+ }
161
+ /**
162
+ * Creates a new Consola instance with the specified default log object properties.
163
+ *
164
+ * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
165
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
166
+ */
167
+ withDefaults(defaults) {
168
+ return this.create({
169
+ ...this.options,
170
+ defaults: {
171
+ ...this.options.defaults,
172
+ ...defaults
173
+ }
174
+ });
175
+ }
176
+ /**
177
+ * Creates a new Consola instance with a specified tag, which will be included in every log.
178
+ *
179
+ * @param {string} tag - The tag to include in each log of the new instance.
180
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
181
+ */
182
+ withTag(tag) {
183
+ return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
184
+ }
185
+ /**
186
+ * Adds a custom reporter to the Consola instance.
187
+ * Reporters will be called for each log message, depending on their implementation and log level.
188
+ *
189
+ * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
190
+ * @returns {Consola} The current Consola instance.
191
+ */
192
+ addReporter(reporter) {
193
+ this.options.reporters.push(reporter);
194
+ return this;
195
+ }
196
+ /**
197
+ * Removes a custom reporter from the Consola instance.
198
+ * If no reporter is specified, all reporters will be removed.
199
+ *
200
+ * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
201
+ * @returns {Consola} The current Consola instance.
202
+ */
203
+ removeReporter(reporter) {
204
+ if (reporter) {
205
+ const i = this.options.reporters.indexOf(reporter);
206
+ if (i !== -1) return this.options.reporters.splice(i, 1);
207
+ } else this.options.reporters.splice(0);
208
+ return this;
209
+ }
210
+ /**
211
+ * Replaces all reporters of the Consola instance with the specified array of reporters.
212
+ *
213
+ * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
214
+ * @returns {Consola} The current Consola instance.
215
+ */
216
+ setReporters(reporters) {
217
+ this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
218
+ return this;
219
+ }
220
+ wrapAll() {
221
+ this.wrapConsole();
222
+ this.wrapStd();
223
+ }
224
+ restoreAll() {
225
+ this.restoreConsole();
226
+ this.restoreStd();
227
+ }
228
+ /**
229
+ * Overrides console methods with Consola logging methods for consistent logging.
230
+ */
231
+ wrapConsole() {
232
+ for (const type in this.options.types) {
233
+ if (!console["__" + type]) console["__" + type] = console[type];
234
+ console[type] = this[type].raw;
235
+ }
236
+ }
237
+ /**
238
+ * Restores the original console methods, removing Consola overrides.
239
+ */
240
+ restoreConsole() {
241
+ for (const type in this.options.types) if (console["__" + type]) {
242
+ console[type] = console["__" + type];
243
+ delete console["__" + type];
244
+ }
245
+ }
246
+ /**
247
+ * Overrides standard output and error streams to redirect them through Consola.
248
+ */
249
+ wrapStd() {
250
+ this._wrapStream(this.options.stdout, "log");
251
+ this._wrapStream(this.options.stderr, "log");
252
+ }
253
+ _wrapStream(stream, type) {
254
+ if (!stream) return;
255
+ if (!stream.__write) stream.__write = stream.write;
256
+ stream.write = (data) => {
257
+ this[type].raw(String(data).trim());
258
+ };
259
+ }
260
+ /**
261
+ * Restores the original standard output and error streams, removing the Consola redirection.
262
+ */
263
+ restoreStd() {
264
+ this._restoreStream(this.options.stdout);
265
+ this._restoreStream(this.options.stderr);
266
+ }
267
+ _restoreStream(stream) {
268
+ if (!stream) return;
269
+ if (stream.__write) {
270
+ stream.write = stream.__write;
271
+ delete stream.__write;
272
+ }
273
+ }
274
+ /**
275
+ * Pauses logging, queues incoming logs until resumed.
276
+ */
277
+ pauseLogs() {
278
+ paused = true;
279
+ }
280
+ /**
281
+ * Resumes logging, processing any queued logs.
282
+ */
283
+ resumeLogs() {
284
+ paused = false;
285
+ const _queue = queue.splice(0);
286
+ for (const item of _queue) item[0]._logFn(item[1], item[2]);
287
+ }
288
+ /**
289
+ * Replaces logging methods with mocks if a mock function is provided.
290
+ *
291
+ * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
292
+ */
293
+ mockTypes(mockFn) {
294
+ const _mockFn = mockFn || this.options.mockFn;
295
+ this._mockFn = _mockFn;
296
+ if (typeof _mockFn !== "function") return;
297
+ for (const type in this.options.types) {
298
+ this[type] = _mockFn(type, this.options.types[type]) || this[type];
299
+ this[type].raw = this[type];
300
+ }
301
+ }
302
+ _wrapLogFn(defaults, isRaw) {
303
+ return (...args) => {
304
+ if (paused) {
305
+ queue.push([
306
+ this,
307
+ defaults,
308
+ args,
309
+ isRaw
310
+ ]);
311
+ return;
312
+ }
313
+ return this._logFn(defaults, args, isRaw);
314
+ };
315
+ }
316
+ _logFn(defaults, args, isRaw) {
317
+ if ((defaults.level || 0) > this.level) return false;
318
+ const logObj = {
319
+ date: /* @__PURE__ */ new Date(),
320
+ args: [],
321
+ ...defaults,
322
+ level: _normalizeLogLevel(defaults.level, this.options.types)
323
+ };
324
+ if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
325
+ else logObj.args = [...args];
326
+ if (logObj.message) {
327
+ logObj.args.unshift(logObj.message);
328
+ delete logObj.message;
329
+ }
330
+ if (logObj.additional) {
331
+ if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
332
+ logObj.args.push("\n" + logObj.additional.join("\n"));
333
+ delete logObj.additional;
334
+ }
335
+ logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
336
+ logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
337
+ const resolveLog = (newLog = false) => {
338
+ const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
339
+ if (this._lastLog.object && repeated > 0) {
340
+ const args2 = [...this._lastLog.object.args];
341
+ if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
342
+ this._log({
343
+ ...this._lastLog.object,
344
+ args: args2
345
+ });
346
+ this._lastLog.count = 1;
347
+ }
348
+ if (newLog) {
349
+ this._lastLog.object = logObj;
350
+ this._log(logObj);
351
+ }
352
+ };
353
+ clearTimeout(this._lastLog.timeout);
354
+ const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
355
+ this._lastLog.time = logObj.date;
356
+ if (diffTime < this.options.throttle) try {
357
+ const serializedLog = JSON.stringify([
358
+ logObj.type,
359
+ logObj.tag,
360
+ logObj.args
361
+ ]);
362
+ const isSameLog = this._lastLog.serialized === serializedLog;
363
+ this._lastLog.serialized = serializedLog;
364
+ if (isSameLog) {
365
+ this._lastLog.count = (this._lastLog.count || 0) + 1;
366
+ if (this._lastLog.count > this.options.throttleMin) {
367
+ this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
368
+ return;
369
+ }
370
+ }
371
+ } catch {}
372
+ resolveLog(true);
373
+ }
374
+ _log(logObj) {
375
+ for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
376
+ }
492
377
  };
493
378
  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;
379
+ if (input === void 0) return defaultLevel;
380
+ if (typeof input === "number") return input;
381
+ if (types[input] && types[input].level !== void 0) return types[input].level;
382
+ return defaultLevel;
504
383
  }
505
384
  Consola.prototype.add = Consola.prototype.addReporter;
506
385
  Consola.prototype.remove = Consola.prototype.removeReporter;
@@ -509,1278 +388,1137 @@ Consola.prototype.withScope = Consola.prototype.withTag;
509
388
  Consola.prototype.mock = Consola.prototype.mockTypes;
510
389
  Consola.prototype.pause = Consola.prototype.pauseLogs;
511
390
  Consola.prototype.resume = Consola.prototype.resumeLogs;
512
- function createConsola(options = {}) {
513
- return new Consola(options);
391
+ function createConsola$1(options = {}) {
392
+ return new Consola(options);
514
393
  }
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";
394
+ //#endregion
395
+ //#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
519
396
  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;
397
+ const cwd = process.cwd() + sep;
398
+ return stack.split("\n").splice(message.split("\n").length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
523
399
  }
524
400
  function writeStream(data, stream) {
525
- const write = stream.__write || stream.write;
526
- return write.call(stream, data);
401
+ return (stream.__write || stream.write).call(stream, data);
527
402
  }
528
- var bracket = (x) => x ? `[${x}]` : "";
403
+ const bracket = (x) => x ? `[${x}]` : "";
529
404
  var BasicReporter = class {
530
- formatStack(stack, message, opts) {
531
- const indent = " ".repeat((opts?.errorLevel || 0) + 1);
532
- return indent + parseStack(stack, message).join(`
405
+ formatStack(stack, message, opts) {
406
+ const indent = " ".repeat((opts?.errorLevel || 0) + 1);
407
+ return indent + parseStack(stack, message).join(`
533
408
  ${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
- }
409
+ }
410
+ formatError(err, opts) {
411
+ const message = err.message ?? formatWithOptions(opts, err);
412
+ const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
413
+ const level = opts?.errorLevel || 0;
414
+ const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
415
+ const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
416
+ ...opts,
417
+ errorLevel: level + 1
418
+ }) : "";
419
+ return causedPrefix + message + "\n" + stack + causedError;
420
+ }
421
+ formatArgs(args, opts) {
422
+ const _args = args.map((arg) => {
423
+ if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
424
+ return arg;
425
+ });
426
+ return formatWithOptions(opts, ..._args);
427
+ }
428
+ formatDate(date, opts) {
429
+ return opts.date ? date.toLocaleTimeString() : "";
430
+ }
431
+ filterAndJoin(arr) {
432
+ return arr.filter(Boolean).join(" ");
433
+ }
434
+ formatLogObj(logObj, opts) {
435
+ const message = this.formatArgs(logObj.args, opts);
436
+ if (logObj.type === "box") return "\n" + [
437
+ bracket(logObj.tag),
438
+ logObj.title && logObj.title,
439
+ ...message.split("\n")
440
+ ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
441
+ return this.filterAndJoin([
442
+ bracket(logObj.type),
443
+ bracket(logObj.tag),
444
+ message
445
+ ]);
446
+ }
447
+ log(logObj, ctx) {
448
+ return writeStream(this.formatLogObj(logObj, {
449
+ columns: ctx.options.stdout.columns || 0,
450
+ ...ctx.options.formatOptions
451
+ }) + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
452
+ }
583
453
  };
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);
454
+ //#endregion
455
+ //#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
456
+ const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
457
+ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
458
+ const isForced = "FORCE_COLOR" in env || argv.includes("--color");
459
+ const isWindows = platform === "win32";
460
+ const isDumbTerminal = env.TERM === "dumb";
461
+ const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
462
+ const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
463
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
602
464
  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));
465
+ return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
604
466
  }
605
467
  function clearBleed(index, string, open, close, replace) {
606
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
468
+ return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
607
469
  }
608
470
  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
- ) : "";
471
+ return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
616
472
  }
617
473
  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)
474
+ return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
475
+ }
476
+ const colorDefs = {
477
+ reset: init(0, 0),
478
+ bold: init(1, 22, "\x1B[22m\x1B[1m"),
479
+ dim: init(2, 22, "\x1B[22m\x1B[2m"),
480
+ italic: init(3, 23),
481
+ underline: init(4, 24),
482
+ inverse: init(7, 27),
483
+ hidden: init(8, 28),
484
+ strikethrough: init(9, 29),
485
+ black: init(30, 39),
486
+ red: init(31, 39),
487
+ green: init(32, 39),
488
+ yellow: init(33, 39),
489
+ blue: init(34, 39),
490
+ magenta: init(35, 39),
491
+ cyan: init(36, 39),
492
+ white: init(37, 39),
493
+ gray: init(90, 39),
494
+ bgBlack: init(40, 49),
495
+ bgRed: init(41, 49),
496
+ bgGreen: init(42, 49),
497
+ bgYellow: init(43, 49),
498
+ bgBlue: init(44, 49),
499
+ bgMagenta: init(45, 49),
500
+ bgCyan: init(46, 49),
501
+ bgWhite: init(47, 49),
502
+ blackBright: init(90, 39),
503
+ redBright: init(91, 39),
504
+ greenBright: init(92, 39),
505
+ yellowBright: init(93, 39),
506
+ blueBright: init(94, 39),
507
+ magentaBright: init(95, 39),
508
+ cyanBright: init(96, 39),
509
+ whiteBright: init(97, 39),
510
+ bgBlackBright: init(100, 49),
511
+ bgRedBright: init(101, 49),
512
+ bgGreenBright: init(102, 49),
513
+ bgYellowBright: init(103, 49),
514
+ bgBlueBright: init(104, 49),
515
+ bgMagentaBright: init(105, 49),
516
+ bgCyanBright: init(106, 49),
517
+ bgWhiteBright: init(107, 49)
662
518
  };
663
519
  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
- }
520
+ return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
521
+ }
522
+ const colors = createColors();
523
+ function getColor$1(color, fallback = "reset") {
524
+ return colors[color] || colors[fallback];
525
+ }
526
+ const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
527
+ function stripAnsi$1(text) {
528
+ return text.replace(new RegExp(ansiRegex$1, "g"), "");
529
+ }
530
+ const boxStylePresets = {
531
+ solid: {
532
+ tl: "┌",
533
+ tr: "┐",
534
+ bl: "└",
535
+ br: "┘",
536
+ h: "─",
537
+ v: "│"
538
+ },
539
+ double: {
540
+ tl: "╔",
541
+ tr: "╗",
542
+ bl: "╚",
543
+ br: "╝",
544
+ h: "═",
545
+ v: "║"
546
+ },
547
+ doubleSingle: {
548
+ tl: "╓",
549
+ tr: "╖",
550
+ bl: "╙",
551
+ br: "╜",
552
+ h: "─",
553
+ v: "║"
554
+ },
555
+ doubleSingleRounded: {
556
+ tl: "╭",
557
+ tr: "╮",
558
+ bl: "╰",
559
+ br: "╯",
560
+ h: "─",
561
+ v: "║"
562
+ },
563
+ singleThick: {
564
+ tl: "┏",
565
+ tr: "┓",
566
+ bl: "┗",
567
+ br: "┛",
568
+ h: "━",
569
+ v: "┃"
570
+ },
571
+ singleDouble: {
572
+ tl: "╒",
573
+ tr: "╕",
574
+ bl: "╘",
575
+ br: "╛",
576
+ h: "═",
577
+ v: "│"
578
+ },
579
+ singleDoubleRounded: {
580
+ tl: "╭",
581
+ tr: "╮",
582
+ bl: "╰",
583
+ br: "╯",
584
+ h: "═",
585
+ v: "│"
586
+ },
587
+ rounded: {
588
+ tl: "╭",
589
+ tr: "╮",
590
+ bl: "╰",
591
+ br: "╯",
592
+ h: "─",
593
+ v: "│"
594
+ }
742
595
  };
743
- var defaultStyle = {
744
- borderColor: "white",
745
- borderStyle: "rounded",
746
- valign: "center",
747
- padding: 2,
748
- marginLeft: 1,
749
- marginTop: 1,
750
- marginBottom: 1
596
+ const defaultStyle = {
597
+ borderColor: "white",
598
+ borderStyle: "rounded",
599
+ valign: "center",
600
+ padding: 2,
601
+ marginLeft: 1,
602
+ marginTop: 1,
603
+ marginBottom: 1
751
604
  };
752
605
  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 }]];
606
+ const opts = {
607
+ ..._opts,
608
+ style: {
609
+ ...defaultStyle,
610
+ ..._opts.style
611
+ }
612
+ };
613
+ const textLines = text.split("\n");
614
+ const boxLines = [];
615
+ const _color = getColor$1(opts.style.borderColor);
616
+ const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
617
+ if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
618
+ const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
619
+ const height = textLines.length + paddingOffset;
620
+ const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length), opts.title ? stripAnsi$1(opts.title).length : 0) + paddingOffset;
621
+ const widthOffset = width + paddingOffset;
622
+ const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
623
+ if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
624
+ if (opts.title) {
625
+ const title = _color ? _color(opts.title) : opts.title;
626
+ const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
627
+ const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
628
+ boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
629
+ } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
630
+ const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
631
+ for (let i = 0; i < height; i++) if (i < valignOffset || i >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
632
+ else {
633
+ const line = textLines[i - valignOffset];
634
+ const left = " ".repeat(paddingOffset);
635
+ const right = " ".repeat(width - stripAnsi$1(line).length);
636
+ boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
637
+ }
638
+ boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
639
+ if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
640
+ return boxLines.join("\n");
641
+ }
642
+ //#endregion
643
+ //#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/index.mjs
644
+ const r = Object.create(null);
645
+ const i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
646
+ const o = new Proxy(r, {
647
+ get(e, s) {
648
+ return i()[s] ?? r[s];
649
+ },
650
+ has(e, s) {
651
+ return s in i() || s in r;
652
+ },
653
+ set(e, s, E) {
654
+ const B = i(true);
655
+ return B[s] = E, true;
656
+ },
657
+ deleteProperty(e, s) {
658
+ if (!s) return false;
659
+ const E = i(true);
660
+ return delete E[s], true;
661
+ },
662
+ ownKeys() {
663
+ const e = i(true);
664
+ return Object.keys(e);
665
+ }
666
+ });
667
+ const t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
668
+ const f = [
669
+ ["APPVEYOR"],
670
+ [
671
+ "AWS_AMPLIFY",
672
+ "AWS_APP_ID",
673
+ { ci: true }
674
+ ],
675
+ ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
676
+ ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
677
+ ["APPCIRCLE", "AC_APPCIRCLE"],
678
+ ["BAMBOO", "bamboo_planKey"],
679
+ ["BITBUCKET", "BITBUCKET_COMMIT"],
680
+ ["BITRISE", "BITRISE_IO"],
681
+ ["BUDDY", "BUDDY_WORKSPACE_ID"],
682
+ ["BUILDKITE"],
683
+ ["CIRCLE", "CIRCLECI"],
684
+ ["CIRRUS", "CIRRUS_CI"],
685
+ [
686
+ "CLOUDFLARE_PAGES",
687
+ "CF_PAGES",
688
+ { ci: true }
689
+ ],
690
+ ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
691
+ ["CODEFRESH", "CF_BUILD_ID"],
692
+ ["DRONE"],
693
+ ["DRONE", "DRONE_BUILD_EVENT"],
694
+ ["DSARI"],
695
+ ["GITHUB_ACTIONS"],
696
+ ["GITLAB", "GITLAB_CI"],
697
+ ["GITLAB", "CI_MERGE_REQUEST_ID"],
698
+ ["GOCD", "GO_PIPELINE_LABEL"],
699
+ ["LAYERCI"],
700
+ ["HUDSON", "HUDSON_URL"],
701
+ ["JENKINS", "JENKINS_URL"],
702
+ ["MAGNUM"],
703
+ ["NETLIFY"],
704
+ [
705
+ "NETLIFY",
706
+ "NETLIFY_LOCAL",
707
+ { ci: false }
708
+ ],
709
+ ["NEVERCODE"],
710
+ ["RENDER"],
711
+ ["SAIL", "SAILCI"],
712
+ ["SEMAPHORE"],
713
+ ["SCREWDRIVER"],
714
+ ["SHIPPABLE"],
715
+ ["SOLANO", "TDDIUM"],
716
+ ["STRIDER"],
717
+ ["TEAMCITY", "TEAMCITY_VERSION"],
718
+ ["TRAVIS"],
719
+ ["VERCEL", "NOW_BUILDER"],
720
+ [
721
+ "VERCEL",
722
+ "VERCEL",
723
+ { ci: false }
724
+ ],
725
+ [
726
+ "VERCEL",
727
+ "VERCEL_ENV",
728
+ { ci: false }
729
+ ],
730
+ ["APPCENTER", "APPCENTER_BUILD_ID"],
731
+ [
732
+ "CODESANDBOX",
733
+ "CODESANDBOX_SSE",
734
+ { ci: false }
735
+ ],
736
+ [
737
+ "CODESANDBOX",
738
+ "CODESANDBOX_HOST",
739
+ { ci: false }
740
+ ],
741
+ ["STACKBLITZ"],
742
+ ["STORMKIT"],
743
+ ["CLEAVR"],
744
+ ["ZEABUR"],
745
+ [
746
+ "CODESPHERE",
747
+ "CODESPHERE_APP_ID",
748
+ { ci: true }
749
+ ],
750
+ ["RAILWAY", "RAILWAY_PROJECT_ID"],
751
+ ["RAILWAY", "RAILWAY_SERVICE_ID"],
752
+ ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
753
+ [
754
+ "FIREBASE_APP_HOSTING",
755
+ "FIREBASE_APP_HOSTING",
756
+ { ci: true }
757
+ ]
758
+ ];
848
759
  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();
760
+ if (globalThis.process?.env) for (const e of f) {
761
+ const s = e[1] || e[0];
762
+ if (globalThis.process?.env[s]) return {
763
+ name: e[0].toLowerCase(),
764
+ ...e[2]
765
+ };
766
+ }
767
+ return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
768
+ name: "stackblitz",
769
+ ci: false
770
+ } : {
771
+ name: "",
772
+ ci: false
773
+ };
774
+ }
775
+ const l = b();
856
776
  l.name;
857
777
  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];
778
+ return e ? e !== "false" : false;
779
+ }
780
+ const I = globalThis.process?.platform || "";
781
+ const T = n(o.CI) || l.ci !== false;
782
+ const a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
783
+ const g = n(o.DEBUG);
784
+ const R = t === "test" || n(o.TEST);
785
+ o.MINIMAL;
786
+ const A = /^win/i.test(I);
787
+ !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
788
+ const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
789
+ Number(C?.split(".")[0]);
790
+ const y = globalThis.process || Object.create(null);
791
+ const _ = { versions: {} };
792
+ new Proxy(y, { get(e, s) {
793
+ if (s === "env") return o;
794
+ if (s in e) return e[s];
795
+ if (s in _) return _[s];
876
796
  } });
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"]];
797
+ const c = globalThis.process?.release?.name === "node";
798
+ const O = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
799
+ const D = !!globalThis.Deno;
800
+ const L = !!globalThis.fastly;
801
+ const S = !!globalThis.Netlify;
802
+ const u = !!globalThis.EdgeRuntime;
803
+ const N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
804
+ const F = [
805
+ [S, "netlify"],
806
+ [u, "edge-light"],
807
+ [N, "workerd"],
808
+ [L, "fastly"],
809
+ [D, "deno"],
810
+ [O, "bun"],
811
+ [c, "node"]
812
+ ];
885
813
  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, "");
814
+ const e = F.find((s) => s[0]);
815
+ if (e) return { name: e[1] };
816
+ }
817
+ G()?.name;
818
+ function ansiRegex({ onlyFirst = false } = {}) {
819
+ const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
820
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
821
+ }
822
+ const regex = ansiRegex();
823
+ function stripAnsi(string) {
824
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
825
+ return string.replace(regex, "");
905
826
  }
906
827
  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;
828
+ 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
829
  }
909
830
  function isFullWidth(x) {
910
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
831
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
911
832
  }
912
833
  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;
834
+ 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
835
  }
915
836
  function validate(codePoint) {
916
- if (!Number.isSafeInteger(codePoint)) {
917
- throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
918
- }
837
+ if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
919
838
  }
920
839
  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;
840
+ validate(codePoint);
841
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
842
+ return 1;
843
+ }
844
+ const emojiRegex = () => {
845
+ 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
846
  };
930
- var segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
931
- var defaultIgnorableCodePointRegex = new RegExp("^\\p{Default_Ignorable_Code_Point}$", "u");
847
+ const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
848
+ const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
932
849
  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;
850
+ if (typeof string !== "string" || string.length === 0) return 0;
851
+ const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
852
+ if (!countAnsiEscapeCodes) string = stripAnsi(string);
853
+ if (string.length === 0) return 0;
854
+ let width = 0;
855
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
856
+ for (const { segment: character } of segmenter.segment(string)) {
857
+ const codePoint = character.codePointAt(0);
858
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
859
+ if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
860
+ if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
861
+ if (codePoint >= 55296 && codePoint <= 57343) continue;
862
+ if (codePoint >= 65024 && codePoint <= 65039) continue;
863
+ if (defaultIgnorableCodePointRegex.test(character)) continue;
864
+ if (emojiRegex().test(character)) {
865
+ width += 2;
866
+ continue;
867
+ }
868
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
869
+ }
870
+ return width;
975
871
  }
976
872
  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"
873
+ const { env } = g$1;
874
+ const { TERM, TERM_PROGRAM } = env;
875
+ if (g$1.platform !== "win32") return TERM !== "linux";
876
+ return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
877
+ }
878
+ const TYPE_COLOR_MAP = {
879
+ info: "cyan",
880
+ fail: "red",
881
+ success: "green",
882
+ ready: "green",
883
+ start: "magenta"
990
884
  };
991
- var LEVEL_COLOR_MAP = {
992
- 0: "red",
993
- 1: "yellow"
885
+ const LEVEL_COLOR_MAP = {
886
+ 0: "red",
887
+ 1: "yellow"
994
888
  };
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: ""
889
+ const unicode = isUnicodeSupported();
890
+ const s = (c, fallback) => unicode ? c : fallback;
891
+ const TYPE_ICONS = {
892
+ error: s("✖", "×"),
893
+ fatal: s("✖", "×"),
894
+ ready: s("✔", "√"),
895
+ warn: s("⚠", "‼"),
896
+ info: s("ℹ", "i"),
897
+ success: s("✔", "√"),
898
+ debug: s("⚙", "D"),
899
+ trace: s("→", "→"),
900
+ fail: s("✖", "×"),
901
+ start: s("◐", "o"),
902
+ log: ""
1009
903
  };
1010
904
  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);
905
+ if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi$1(str).length;
906
+ return stringWidth$1(str);
1016
907
  }
1017
908
  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(`
909
+ formatStack(stack, message, opts) {
910
+ const indent = " ".repeat((opts?.errorLevel || 0) + 1);
911
+ return `
912
+ ${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)).join(`
1024
913
  ${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
- }
914
+ }
915
+ formatType(logObj, isBadge, opts) {
916
+ const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
917
+ if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
918
+ const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
919
+ return _type ? getColor(typeColor)(_type) : "";
920
+ }
921
+ formatLogObj(logObj, opts) {
922
+ const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
923
+ if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
924
+ title: logObj.title ? characterFormat(logObj.title) : void 0,
925
+ style: logObj.style
926
+ });
927
+ const date = this.formatDate(logObj.date, opts);
928
+ const coloredDate = date && colors.gray(date);
929
+ const isBadge = logObj.badge ?? logObj.level < 2;
930
+ const type = this.formatType(logObj, isBadge, opts);
931
+ const tag = logObj.tag ? colors.gray(logObj.tag) : "";
932
+ let line;
933
+ const left = this.filterAndJoin([type, characterFormat(message)]);
934
+ const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
935
+ const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
936
+ line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
937
+ line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
938
+ if (logObj.type === "trace") {
939
+ const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
940
+ line += this.formatStack(_err.stack || "", _err.message);
941
+ }
942
+ return isBadge ? "\n" + line + "\n" : line;
943
+ }
1070
944
  };
1071
945
  function characterFormat(str) {
1072
- return str.replace(/`([^`]+)`/gm, (_2, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_2, m) => ` ${colors.underline(m)} `);
946
+ return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
1073
947
  }
1074
- function getColor2(color = "white") {
1075
- return colors[color] || colors.white;
948
+ function getColor(color = "white") {
949
+ return colors[color] || colors.white;
1076
950
  }
1077
951
  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;
952
+ return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
953
+ }
954
+ function createConsola(options = {}) {
955
+ let level = _getDefaultLogLevel();
956
+ if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
957
+ return createConsola$1({
958
+ level,
959
+ defaults: { level },
960
+ stdout: process.stdout,
961
+ stderr: process.stderr,
962
+ prompt: (...args) => import("./prompt-BU6Ge-7H.js").then((m) => m.prompt(...args)),
963
+ reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
964
+ ...options
965
+ });
1097
966
  }
1098
967
  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
968
+ if (g) return LogLevels.debug;
969
+ if (R) return LogLevels.warn;
970
+ return LogLevels.info;
971
+ }
972
+ const consola = createConsola();
973
+ //#endregion
974
+ //#region ../../node_modules/.bun/citty@0.1.6/node_modules/citty/dist/index.mjs
1113
975
  function toArray(val) {
1114
- if (Array.isArray(val)) {
1115
- return val;
1116
- }
1117
- return val === void 0 ? [] : [val];
976
+ if (Array.isArray(val)) return val;
977
+ return val === void 0 ? [] : [val];
1118
978
  }
1119
979
  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");
980
+ const maxLengh = [];
981
+ for (const line of lines) for (const [i, element] of line.entries()) maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
982
+ return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])).join(" ")).join("\n");
1131
983
  }
1132
984
  function resolveValue(input) {
1133
- return typeof input === "function" ? input() : input;
985
+ return typeof input === "function" ? input() : input;
1134
986
  }
1135
987
  var CLIError = class extends Error {
1136
- constructor(message, code) {
1137
- super(message);
1138
- this.code = code;
1139
- this.name = "CLIError";
1140
- }
988
+ constructor(message, code) {
989
+ super(message);
990
+ this.code = code;
991
+ this.name = "CLIError";
992
+ }
1141
993
  };
1142
- var NUMBER_CHAR_RE = /\d/;
1143
- var STR_SPLITTERS = ["-", "_", "/", "."];
994
+ const NUMBER_CHAR_RE = /\d/;
995
+ const STR_SPLITTERS = [
996
+ "-",
997
+ "_",
998
+ "/",
999
+ "."
1000
+ ];
1144
1001
  function isUppercase(char = "") {
1145
- if (NUMBER_CHAR_RE.test(char)) {
1146
- return void 0;
1147
- }
1148
- return char !== char.toLowerCase();
1002
+ if (NUMBER_CHAR_RE.test(char)) return;
1003
+ return char !== char.toLowerCase();
1149
1004
  }
1150
1005
  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;
1006
+ const splitters = separators ?? STR_SPLITTERS;
1007
+ const parts = [];
1008
+ if (!str || typeof str !== "string") return parts;
1009
+ let buff = "";
1010
+ let previousUpper;
1011
+ let previousSplitter;
1012
+ for (const char of str) {
1013
+ const isSplitter = splitters.includes(char);
1014
+ if (isSplitter === true) {
1015
+ parts.push(buff);
1016
+ buff = "";
1017
+ previousUpper = void 0;
1018
+ continue;
1019
+ }
1020
+ const isUpper = isUppercase(char);
1021
+ if (previousSplitter === false) {
1022
+ if (previousUpper === false && isUpper === true) {
1023
+ parts.push(buff);
1024
+ buff = char;
1025
+ previousUpper = isUpper;
1026
+ continue;
1027
+ }
1028
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
1029
+ const lastChar = buff.at(-1);
1030
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
1031
+ buff = lastChar + char;
1032
+ previousUpper = isUpper;
1033
+ continue;
1034
+ }
1035
+ }
1036
+ buff += char;
1037
+ previousUpper = isUpper;
1038
+ previousSplitter = isSplitter;
1039
+ }
1040
+ parts.push(buff);
1041
+ return parts;
1189
1042
  }
1190
1043
  function upperFirst(str) {
1191
- return str ? str[0].toUpperCase() + str.slice(1) : "";
1044
+ return str ? str[0].toUpperCase() + str.slice(1) : "";
1192
1045
  }
1193
1046
  function lowerFirst(str) {
1194
- return str ? str[0].toLowerCase() + str.slice(1) : "";
1047
+ return str ? str[0].toLowerCase() + str.slice(1) : "";
1195
1048
  }
1196
1049
  function pascalCase(str, opts) {
1197
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
1050
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
1198
1051
  }
1199
1052
  function camelCase(str, opts) {
1200
- return lowerFirst(pascalCase(str || "", opts));
1053
+ return lowerFirst(pascalCase(str || "", opts));
1201
1054
  }
1202
1055
  function kebabCase(str, joiner) {
1203
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
1056
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
1204
1057
  }
1205
1058
  function toArr(any) {
1206
- return any == void 0 ? [] : Array.isArray(any) ? any : [any];
1059
+ return any == void 0 ? [] : Array.isArray(any) ? any : [any];
1207
1060
  }
1208
1061
  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];
1062
+ let x;
1063
+ const old = out[key];
1064
+ 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;
1065
+ out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
1213
1066
  }
1214
1067
  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;
1068
+ let k;
1069
+ let arr;
1070
+ let arg;
1071
+ let name;
1072
+ let val;
1073
+ const out = { _: [] };
1074
+ let i = 0;
1075
+ let j = 0;
1076
+ let idx = 0;
1077
+ const len = args.length;
1078
+ const alibi = opts.alias !== void 0;
1079
+ const strict = opts.unknown !== void 0;
1080
+ const defaults = opts.default !== void 0;
1081
+ opts.alias = opts.alias || {};
1082
+ opts.string = toArr(opts.string);
1083
+ opts.boolean = toArr(opts.boolean);
1084
+ if (alibi) for (k in opts.alias) {
1085
+ arr = opts.alias[k] = toArr(opts.alias[k]);
1086
+ for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
1087
+ }
1088
+ for (i = opts.boolean.length; i-- > 0;) {
1089
+ arr = opts.alias[opts.boolean[i]] || [];
1090
+ for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
1091
+ }
1092
+ for (i = opts.string.length; i-- > 0;) {
1093
+ arr = opts.alias[opts.string[i]] || [];
1094
+ for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
1095
+ }
1096
+ if (defaults) for (k in opts.default) {
1097
+ name = typeof opts.default[k];
1098
+ arr = opts.alias[k] = opts.alias[k] || [];
1099
+ if (opts[name] !== void 0) {
1100
+ opts[name].push(k);
1101
+ for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
1102
+ }
1103
+ }
1104
+ const keys = strict ? Object.keys(opts.alias) : [];
1105
+ for (i = 0; i < len; i++) {
1106
+ arg = args[i];
1107
+ if (arg === "--") {
1108
+ out._ = out._.concat(args.slice(++i));
1109
+ break;
1110
+ }
1111
+ for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
1112
+ if (j === 0) out._.push(arg);
1113
+ else if (arg.substring(j, j + 3) === "no-") {
1114
+ name = arg.slice(Math.max(0, j + 3));
1115
+ if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
1116
+ out[name] = false;
1117
+ } else {
1118
+ for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
1119
+ name = arg.substring(j, idx);
1120
+ val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
1121
+ arr = j === 2 ? [name] : name;
1122
+ for (idx = 0; idx < arr.length; idx++) {
1123
+ name = arr[idx];
1124
+ if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
1125
+ toVal(out, name, idx + 1 < arr.length || val, opts);
1126
+ }
1127
+ }
1128
+ }
1129
+ if (defaults) {
1130
+ for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
1131
+ }
1132
+ if (alibi) for (k in out) {
1133
+ arr = opts.alias[k] || [];
1134
+ while (arr.length > 0) out[arr.shift()] = out[k];
1135
+ }
1136
+ return out;
1317
1137
  }
1318
1138
  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;
1139
+ const parseOptions = {
1140
+ boolean: [],
1141
+ string: [],
1142
+ mixed: [],
1143
+ alias: {},
1144
+ default: {}
1145
+ };
1146
+ const args = resolveArgs(argsDef);
1147
+ for (const arg of args) {
1148
+ if (arg.type === "positional") continue;
1149
+ if (arg.type === "string") parseOptions.string.push(arg.name);
1150
+ else if (arg.type === "boolean") parseOptions.boolean.push(arg.name);
1151
+ if (arg.default !== void 0) parseOptions.default[arg.name] = arg.default;
1152
+ if (arg.alias) parseOptions.alias[arg.name] = arg.alias;
1153
+ }
1154
+ const parsed = parseRawArgs(rawArgs, parseOptions);
1155
+ const [ ...positionalArguments] = parsed._;
1156
+ const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
1157
+ return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
1158
+ } });
1159
+ for (const [, arg] of args.entries()) if (arg.type === "positional") {
1160
+ const nextPositionalArgument = positionalArguments.shift();
1161
+ if (nextPositionalArgument !== void 0) parsedArgsProxy[arg.name] = nextPositionalArgument;
1162
+ else if (arg.default === void 0 && arg.required !== false) throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
1163
+ else parsedArgsProxy[arg.name] = arg.default;
1164
+ } else if (arg.required && parsedArgsProxy[arg.name] === void 0) throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
1165
+ return parsedArgsProxy;
1368
1166
  }
1369
1167
  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;
1168
+ const args = [];
1169
+ for (const [name, argDef] of Object.entries(argsDef || {})) args.push({
1170
+ ...argDef,
1171
+ name,
1172
+ alias: toArray(argDef.alias)
1173
+ });
1174
+ return args;
1379
1175
  }
1380
1176
  function defineCommand(def) {
1381
- return def;
1177
+ return def;
1382
1178
  }
1383
1179
  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 };
1180
+ const cmdArgs = await resolveValue(cmd.args || {});
1181
+ const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
1182
+ const context = {
1183
+ rawArgs: opts.rawArgs,
1184
+ args: parsedArgs,
1185
+ data: opts.data,
1186
+ cmd
1187
+ };
1188
+ if (typeof cmd.setup === "function") await cmd.setup(context);
1189
+ let result;
1190
+ try {
1191
+ const subCommands = await resolveValue(cmd.subCommands);
1192
+ if (subCommands && Object.keys(subCommands).length > 0) {
1193
+ const subCommandArgIndex = opts.rawArgs.findIndex((arg) => !arg.startsWith("-"));
1194
+ const subCommandName = opts.rawArgs[subCommandArgIndex];
1195
+ if (subCommandName) {
1196
+ if (!subCommands[subCommandName]) throw new CLIError(`Unknown command \`${subCommandName}\``, "E_UNKNOWN_COMMAND");
1197
+ const subCommand = await resolveValue(subCommands[subCommandName]);
1198
+ if (subCommand) await runCommand(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
1199
+ } else if (!cmd.run) throw new CLIError(`No command specified.`, "E_NO_COMMAND");
1200
+ }
1201
+ if (typeof cmd.run === "function") result = await cmd.run(context);
1202
+ } finally {
1203
+ if (typeof cmd.cleanup === "function") await cmd.cleanup(context);
1204
+ }
1205
+ return { result };
1429
1206
  }
1430
1207
  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];
1208
+ const subCommands = await resolveValue(cmd.subCommands);
1209
+ if (subCommands && Object.keys(subCommands).length > 0) {
1210
+ const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
1211
+ const subCommandName = rawArgs[subCommandArgIndex];
1212
+ const subCommand = await resolveValue(subCommands[subCommandName]);
1213
+ if (subCommand) return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
1214
+ }
1215
+ return [cmd, parent];
1445
1216
  }
1446
1217
  async function showUsage(cmd, parent) {
1447
- try {
1448
- consola.log(await renderUsage(cmd, parent) + "\n");
1449
- } catch (error) {
1450
- consola.error(error);
1451
- }
1218
+ try {
1219
+ consola.log(await renderUsage(cmd, parent) + "\n");
1220
+ } catch (error) {
1221
+ consola.error(error);
1222
+ }
1452
1223
  }
1453
1224
  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");
1225
+ const cmdMeta = await resolveValue(cmd.meta || {});
1226
+ const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
1227
+ const parentMeta = await resolveValue(parent?.meta || {});
1228
+ const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
1229
+ const argLines = [];
1230
+ const posLines = [];
1231
+ const commandsLines = [];
1232
+ const usageLine = [];
1233
+ for (const arg of cmdArgs) if (arg.type === "positional") {
1234
+ const name = arg.name.toUpperCase();
1235
+ const isRequired = arg.required !== false && arg.default === void 0;
1236
+ const defaultHint = arg.default ? `="${arg.default}"` : "";
1237
+ posLines.push([
1238
+ "`" + name + defaultHint + "`",
1239
+ arg.description || "",
1240
+ arg.valueHint ? `<${arg.valueHint}>` : ""
1241
+ ]);
1242
+ usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
1243
+ } else {
1244
+ const isRequired = arg.required === true && arg.default === void 0;
1245
+ const argStr = (arg.type === "boolean" && arg.default === true ? [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ") : [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ")) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
1246
+ argLines.push(["`" + argStr + (isRequired ? " (required)" : "") + "`", arg.description || ""]);
1247
+ if (isRequired) usageLine.push(argStr);
1248
+ }
1249
+ if (cmd.subCommands) {
1250
+ const commandNames = [];
1251
+ const subCommands = await resolveValue(cmd.subCommands);
1252
+ for (const [name, sub] of Object.entries(subCommands)) {
1253
+ const meta = await resolveValue((await resolveValue(sub))?.meta);
1254
+ commandsLines.push([`\`${name}\``, meta?.description || ""]);
1255
+ commandNames.push(name);
1256
+ }
1257
+ usageLine.push(commandNames.join("|"));
1258
+ }
1259
+ const usageLines = [];
1260
+ const version = cmdMeta.version || parentMeta.version;
1261
+ usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
1262
+ const hasOptions = argLines.length > 0 || posLines.length > 0;
1263
+ usageLines.push(`${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``, "");
1264
+ if (posLines.length > 0) {
1265
+ usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
1266
+ usageLines.push(formatLineColumns(posLines, " "));
1267
+ usageLines.push("");
1268
+ }
1269
+ if (argLines.length > 0) {
1270
+ usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
1271
+ usageLines.push(formatLineColumns(argLines, " "));
1272
+ usageLines.push("");
1273
+ }
1274
+ if (commandsLines.length > 0) {
1275
+ usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
1276
+ usageLines.push(formatLineColumns(commandsLines, " "));
1277
+ usageLines.push("", `Use \`${commandName} <command> --help\` for more information about a command.`);
1278
+ }
1279
+ return usageLines.filter((l) => typeof l === "string").join("\n");
1533
1280
  }
1534
1281
  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
- }
1562
-
1563
- // src/blueprints.ts
1564
- import { randomBytes } from "crypto";
1565
- import { cp, readdir as readdir2, readFile, rename, rm, writeFile } from "fs/promises";
1566
- import { basename, dirname, join, relative } from "path";
1567
- import process2 from "process";
1568
- import { fileURLToPath } from "url";
1569
-
1570
- // src/utils.ts
1571
- import { readdir, stat } from "fs/promises";
1282
+ const rawArgs = opts.rawArgs || process.argv.slice(2);
1283
+ const showUsage$1 = opts.showUsage || showUsage;
1284
+ try {
1285
+ if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
1286
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
1287
+ process.exit(0);
1288
+ } else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
1289
+ const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
1290
+ if (!meta?.version) throw new CLIError("No version specified", "E_NO_VERSION");
1291
+ consola.log(meta.version);
1292
+ } else await runCommand(cmd, { rawArgs });
1293
+ } catch (error) {
1294
+ const isCLIError = error instanceof CLIError;
1295
+ if (!isCLIError) consola.error(error, "\n");
1296
+ if (isCLIError) await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
1297
+ consola.error(error.message);
1298
+ process.exit(1);
1299
+ }
1300
+ }
1301
+ //#endregion
1302
+ //#region src/utils.ts
1572
1303
  async function directoryExists(path) {
1573
- try {
1574
- const stats = await stat(path);
1575
- return stats.isDirectory();
1576
- } catch (error) {
1577
- if (error.code === "ENOENT") {
1578
- return false;
1579
- }
1580
- throw error;
1581
- }
1304
+ try {
1305
+ return (await stat(path)).isDirectory();
1306
+ } catch (error) {
1307
+ if (error.code === "ENOENT") return false;
1308
+ throw error;
1309
+ }
1582
1310
  }
1583
1311
  async function fileExists(path) {
1584
- try {
1585
- const stats = await stat(path);
1586
- return stats.isFile();
1587
- } catch (error) {
1588
- if (error.code === "ENOENT") {
1589
- return false;
1590
- }
1591
- throw error;
1592
- }
1312
+ try {
1313
+ return (await stat(path)).isFile();
1314
+ } catch (error) {
1315
+ if (error.code === "ENOENT") return false;
1316
+ throw error;
1317
+ }
1593
1318
  }
1594
1319
  async function isDirectoryEmpty(path) {
1595
- try {
1596
- const entries = await readdir(path);
1597
- return entries.length === 0;
1598
- } catch (error) {
1599
- if (error.code === "ENOENT") {
1600
- return true;
1601
- }
1602
- throw error;
1603
- }
1320
+ try {
1321
+ return (await readdir(path)).length === 0;
1322
+ } catch (error) {
1323
+ if (error.code === "ENOENT") return true;
1324
+ throw error;
1325
+ }
1604
1326
  }
1605
1327
  function toKebabCase(value) {
1606
- return value.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^a-zA-Z0-9]+/gu, "-").toLowerCase().replace(/^-+|-+$/gu, "");
1328
+ return value.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^a-zA-Z0-9]+/gu, "-").toLowerCase().replace(/^-+|-+$/gu, "");
1607
1329
  }
1608
1330
  function toTitleCase(value) {
1609
- const words = value.replace(/[-_]+/gu, " ").split(/\s+/u).filter(Boolean);
1610
- if (words.length === 0) {
1611
- return "Guren App";
1612
- }
1613
- return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
1331
+ const words = value.replace(/[-_]+/gu, " ").split(/\s+/u).filter(Boolean);
1332
+ if (words.length === 0) return "Guren App";
1333
+ return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
1614
1334
  }
1615
1335
  function toPackageName(value) {
1616
- const trimmed = value.trim();
1617
- if (trimmed.startsWith("@")) {
1618
- const withoutScope = trimmed.slice(1);
1619
- const [scope, name = "guren-app"] = withoutScope.split("/", 2);
1620
- const safeScope = toKebabCase(scope);
1621
- const safeName = toKebabCase(name);
1622
- return `@${safeScope || "guren"}/${safeName || "app"}`;
1623
- }
1624
- const safe = toKebabCase(trimmed);
1625
- return safe || "guren-app";
1626
- }
1627
-
1628
- // src/blueprints.ts
1629
- var APP_BLUEPRINTS = ["default", "api", "blog", "worker"];
1630
- var DATABASE_DRIVERS = ["sqlite", "postgres", "mysql"];
1631
- var TEMPLATES_ROOT = fileURLToPath(new URL("../templates", import.meta.url));
1336
+ const trimmed = value.trim();
1337
+ if (trimmed.startsWith("@")) {
1338
+ const [scope, name = "guren-app"] = trimmed.slice(1).split("/", 2);
1339
+ const safeScope = toKebabCase(scope);
1340
+ const safeName = toKebabCase(name);
1341
+ return `@${safeScope || "guren"}/${safeName || "app"}`;
1342
+ }
1343
+ return toKebabCase(trimmed) || "guren-app";
1344
+ }
1345
+ //#endregion
1346
+ //#region src/blueprints.ts
1347
+ const APP_BLUEPRINTS = [
1348
+ "default",
1349
+ "api",
1350
+ "blog",
1351
+ "worker"
1352
+ ];
1353
+ const DATABASE_DRIVERS = [
1354
+ "sqlite",
1355
+ "postgres",
1356
+ "mysql"
1357
+ ];
1358
+ /**
1359
+ * The directory holding every template a blueprint can copy from. It is the
1360
+ * only source tree in this package's `files` field, so a layer resolved outside
1361
+ * it scaffolds fine from the monorepo and ENOENTs from an npm install: that is
1362
+ * how the `blog` blueprint shipped broken for releases, overlaying
1363
+ * `examples/blog`, which no tarball contains.
1364
+ *
1365
+ * Layers are therefore named, not pathed — `TemplateName` makes a layer outside
1366
+ * this directory unrepresentable rather than merely asserted against.
1367
+ */
1368
+ const TEMPLATES_ROOT = fileURLToPath(new URL("../templates", import.meta.url));
1632
1369
  function templateDir(name) {
1633
- return join(TEMPLATES_ROOT, name);
1634
- }
1635
- var DEFAULT_TRANSFORM_FILES = [
1636
- "README.md",
1637
- "package.json",
1638
- "public/index.html",
1639
- "bin/serve.ts",
1640
- "app/Http/Controllers/HomeController.ts",
1641
- "resources/js/pages/Home.tsx"
1370
+ return join(TEMPLATES_ROOT, name);
1371
+ }
1372
+ const DEFAULT_TRANSFORM_FILES = [
1373
+ "README.md",
1374
+ "package.json",
1375
+ "public/index.html",
1376
+ "bin/serve.ts",
1377
+ "app/Http/Controllers/HomeController.ts",
1378
+ "resources/js/pages/Home.tsx"
1642
1379
  ];
1643
- var API_TRANSFORM_FILES = [
1644
- "README.md",
1645
- "package.json",
1646
- "bin/serve.ts"
1380
+ const API_TRANSFORM_FILES = [
1381
+ "README.md",
1382
+ "package.json",
1383
+ "bin/serve.ts"
1647
1384
  ];
1648
- var BLOG_TRANSFORM_FILES = [
1649
- ...DEFAULT_TRANSFORM_FILES,
1650
- "resources/js/components/Layout.tsx",
1651
- "db/seeders/001_users.ts"
1385
+ const BLOG_TRANSFORM_FILES = [
1386
+ ...DEFAULT_TRANSFORM_FILES,
1387
+ "resources/js/components/Layout.tsx",
1388
+ "db/seeders/001_users.ts"
1652
1389
  ];
1653
- var blueprintRegistry = {
1654
- default: {
1655
- name: "default",
1656
- description: "The standard Guren starter blueprint.",
1657
- baseTemplate: "default",
1658
- overlayTemplates: {
1659
- ssr: ["default-ssr"]
1660
- },
1661
- transformFiles: DEFAULT_TRANSFORM_FILES
1662
- },
1663
- api: {
1664
- name: "api",
1665
- description: "API-only starter \u2014 no Inertia, no React, no frontend assets.",
1666
- baseTemplate: "api-only",
1667
- overlayTemplates: {},
1668
- transformFiles: API_TRANSFORM_FILES
1669
- },
1670
- blog: {
1671
- name: "blog",
1672
- description: "Blog starter \u2014 posts CRUD, session auth, and a seeded demo account.",
1673
- baseTemplate: "default",
1674
- // The overlay lands last in both modes so its pages and controllers win, and
1675
- // SSR still gets `default-ssr` — the blueprint this replaces overlaid only
1676
- // itself in SSR mode and shipped an app with no ssr.tsx entry.
1677
- overlayTemplates: {
1678
- spa: ["blog"],
1679
- ssr: ["default-ssr", "blog"]
1680
- },
1681
- transformFiles: BLOG_TRANSFORM_FILES,
1682
- includesAuth: true
1683
- },
1684
- worker: {
1685
- name: "worker",
1686
- description: "Full-stack app pre-configured with queue, events, cache, and scheduling",
1687
- baseTemplate: "default",
1688
- overlayTemplates: {
1689
- ssr: ["default-ssr"]
1690
- },
1691
- transformFiles: DEFAULT_TRANSFORM_FILES,
1692
- postScaffold: async ({ destination }) => {
1693
- let runBlueprint;
1694
- try {
1695
- ;
1696
- ({ runBlueprint } = await import("@guren/cli"));
1697
- } catch {
1698
- return;
1699
- }
1700
- const originalCwd = process2.cwd();
1701
- try {
1702
- process2.chdir(destination);
1703
- await runBlueprint("queue", { force: true });
1704
- await runBlueprint("events", { force: true });
1705
- await runBlueprint("cache", { force: true });
1706
- await runBlueprint("schedule", { force: true });
1707
- } finally {
1708
- process2.chdir(originalCwd);
1709
- }
1710
- }
1711
- }
1390
+ const blueprintRegistry = {
1391
+ default: {
1392
+ name: "default",
1393
+ description: "The standard Guren starter blueprint.",
1394
+ baseTemplate: "default",
1395
+ overlayTemplates: { ssr: ["default-ssr"] },
1396
+ transformFiles: DEFAULT_TRANSFORM_FILES
1397
+ },
1398
+ api: {
1399
+ name: "api",
1400
+ description: "API-only starter — no Inertia, no React, no frontend assets.",
1401
+ baseTemplate: "api-only",
1402
+ overlayTemplates: {},
1403
+ transformFiles: API_TRANSFORM_FILES
1404
+ },
1405
+ blog: {
1406
+ name: "blog",
1407
+ description: "Blog starter — posts CRUD, session auth, and a seeded demo account.",
1408
+ baseTemplate: "default",
1409
+ overlayTemplates: {
1410
+ spa: ["blog"],
1411
+ ssr: ["default-ssr", "blog"]
1412
+ },
1413
+ transformFiles: BLOG_TRANSFORM_FILES,
1414
+ includesAuth: true
1415
+ },
1416
+ worker: {
1417
+ name: "worker",
1418
+ description: "Full-stack app pre-configured with queue, events, cache, and scheduling",
1419
+ baseTemplate: "default",
1420
+ overlayTemplates: { ssr: ["default-ssr"] },
1421
+ transformFiles: DEFAULT_TRANSFORM_FILES,
1422
+ postScaffold: async ({ destination }) => {
1423
+ let runBlueprint;
1424
+ try {
1425
+ ({runBlueprint} = await import("@guren/cli"));
1426
+ } catch {
1427
+ return;
1428
+ }
1429
+ const originalCwd = g$1.cwd();
1430
+ try {
1431
+ g$1.chdir(destination);
1432
+ await runBlueprint("queue", { force: true });
1433
+ await runBlueprint("events", { force: true });
1434
+ await runBlueprint("cache", { force: true });
1435
+ await runBlueprint("schedule", { force: true });
1436
+ } finally {
1437
+ g$1.chdir(originalCwd);
1438
+ }
1439
+ }
1440
+ }
1712
1441
  };
1713
1442
  function replaceTokens(content, tokens) {
1714
- let updated = content;
1715
- for (const [token, replacement] of tokens) {
1716
- updated = updated.split(token).join(replacement);
1717
- }
1718
- return updated;
1443
+ let updated = content;
1444
+ for (const [token, replacement] of tokens) updated = updated.split(token).join(replacement);
1445
+ return updated;
1719
1446
  }
1720
- var TEMPLATE_DOTFILES = /* @__PURE__ */ new Map([["_gitignore", ".gitignore"]]);
1447
+ const TEMPLATE_DOTFILES = /* @__PURE__ */ new Map([["_gitignore", ".gitignore"]]);
1721
1448
  async function copyLayer(layer, destination) {
1722
- const dotfiles = /* @__PURE__ */ new Set();
1723
- const source = templateDir(layer);
1724
- await cp(source, destination, {
1725
- recursive: true,
1726
- force: true,
1727
- filter: (sourcePath) => {
1728
- if (TEMPLATE_DOTFILES.has(basename(sourcePath))) {
1729
- dotfiles.add(relative(source, sourcePath));
1730
- }
1731
- return true;
1732
- }
1733
- });
1734
- for (const path of dotfiles) {
1735
- const dotted = TEMPLATE_DOTFILES.get(basename(path));
1736
- await rename(join(destination, path), join(destination, dirname(path), dotted));
1737
- }
1449
+ const dotfiles = /* @__PURE__ */ new Set();
1450
+ const source = templateDir(layer);
1451
+ await cp(source, destination, {
1452
+ recursive: true,
1453
+ force: true,
1454
+ filter: (sourcePath) => {
1455
+ if (TEMPLATE_DOTFILES.has(basename(sourcePath))) dotfiles.add(relative(source, sourcePath));
1456
+ return true;
1457
+ }
1458
+ });
1459
+ for (const path of dotfiles) {
1460
+ const dotted = TEMPLATE_DOTFILES.get(basename(path));
1461
+ await rename(join(destination, path), join(destination, dirname(path), dotted));
1462
+ }
1738
1463
  }
1739
1464
  async function applyTokenTransforms(destination, files, tokens) {
1740
- for (const file of files) {
1741
- const path = join(destination, file);
1742
- const content = await readFile(path, "utf8");
1743
- const updated = replaceTokens(content, tokens);
1744
- if (updated !== content) {
1745
- await writeFile(path, updated, "utf8");
1746
- }
1747
- }
1465
+ for (const file of files) {
1466
+ const path = join(destination, file);
1467
+ const content = await readFile(path, "utf8");
1468
+ const updated = replaceTokens(content, tokens);
1469
+ if (updated !== content) await writeFile(path, updated, "utf8");
1470
+ }
1748
1471
  }
1749
1472
  async function scaffoldEnvFiles(destination) {
1750
- const envExamplePath = join(destination, ".env.example");
1751
- const envPath = join(destination, ".env");
1752
- let envExample;
1753
- try {
1754
- envExample = await readFile(envExamplePath, "utf8");
1755
- } catch {
1756
- return;
1757
- }
1758
- const appKey = `base64:${randomBytes(32).toString("base64")}`;
1759
- const envContent = envExample.replace(/^APP_KEY=.*$/mu, `APP_KEY=${appKey}`);
1760
- await writeFile(envPath, envContent.endsWith("\n") ? envContent : `${envContent}
1761
- `, "utf8");
1762
- }
1763
- var DATABASE_DEFAULTS = {
1764
- postgres: { url: "postgres://guren:guren@localhost:54322/guren", dialect: "postgresql", dep: { postgres: "^3.4.3" } },
1765
- mysql: { url: "mysql://guren:guren@localhost:33306/guren", dialect: "mysql", dep: { mysql2: "^3.11.3" } },
1766
- sqlite: { url: "./data/guren.db", dialect: "sqlite", dep: null }
1473
+ const envExamplePath = join(destination, ".env.example");
1474
+ const envPath = join(destination, ".env");
1475
+ let envExample;
1476
+ try {
1477
+ envExample = await readFile(envExamplePath, "utf8");
1478
+ } catch {
1479
+ return;
1480
+ }
1481
+ const appKey = `base64:${randomBytes(32).toString("base64")}`;
1482
+ const envContent = envExample.replace(/^APP_KEY=.*$/mu, `APP_KEY=${appKey}`);
1483
+ await writeFile(envPath, envContent.endsWith("\n") ? envContent : `${envContent}\n`, "utf8");
1484
+ }
1485
+ const DATABASE_DEFAULTS = {
1486
+ postgres: {
1487
+ url: "postgres://guren:guren@localhost:54322/guren",
1488
+ dialect: "postgresql",
1489
+ dep: { postgres: "^3.4.3" }
1490
+ },
1491
+ mysql: {
1492
+ url: "mysql://guren:guren@localhost:33306/guren",
1493
+ dialect: "mysql",
1494
+ dep: { mysql2: "^3.11.3" }
1495
+ },
1496
+ sqlite: {
1497
+ url: "./data/guren.db",
1498
+ dialect: "sqlite",
1499
+ dep: null
1500
+ }
1767
1501
  };
1502
+ /**
1503
+ * `config/database.ts` ships as one real source file per driver, copied
1504
+ * verbatim — no tokens, and `templates/database` is not a `TemplateName`
1505
+ * layer, so only the selected driver's file reaches the app. The full
1506
+ * rationale lives in this package's CLAUDE.md;
1507
+ * `tests/database-config-template.test.ts` pins the files to this path and to
1508
+ * the `DATABASE_DEFAULTS` constants they hardcode.
1509
+ */
1768
1510
  function databaseConfigTemplatePath(driver) {
1769
- return join(TEMPLATES_ROOT, "database", driver, "config/database.ts");
1511
+ return join(TEMPLATES_ROOT, "database", driver, "config/database.ts");
1770
1512
  }
1771
1513
  async function loadDatabaseConfig(driver) {
1772
- try {
1773
- return await readFile(databaseConfigTemplatePath(driver), "utf8");
1774
- } catch (cause) {
1775
- throw new Error(
1776
- `Could not read the ${driver} database config template at "${databaseConfigTemplatePath(driver)}". This build of create-guren-app may be incomplete \u2014 please report it at https://github.com/gurenjs/guren/issues and try \`npm create guren-app@latest\` meanwhile.`,
1777
- { cause }
1778
- );
1779
- }
1514
+ try {
1515
+ return await readFile(databaseConfigTemplatePath(driver), "utf8");
1516
+ } catch (cause) {
1517
+ throw new Error(`Could not read the ${driver} database config template at "${databaseConfigTemplatePath(driver)}". This build of create-guren-app may be incomplete — please report it at https://github.com/gurenjs/guren/issues and try \`npm create guren-app@latest\` meanwhile.`, { cause });
1518
+ }
1780
1519
  }
1781
1520
  function generateSchema(driver) {
1782
- if (driver === "postgres") {
1783
- return `import { pgTable, serial, text, timestamp } from '@guren/orm/drizzle/pg'
1521
+ if (driver === "postgres") return `import { pgTable, serial, text, timestamp } from '@guren/orm/drizzle/pg'
1784
1522
 
1785
1523
  export const users = pgTable('users', {
1786
1524
  id: serial('id').primaryKey(),
@@ -1789,9 +1527,7 @@ export const users = pgTable('users', {
1789
1527
  createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
1790
1528
  })
1791
1529
  `;
1792
- }
1793
- if (driver === "mysql") {
1794
- return `import { mysqlTable, int, varchar, timestamp } from '@guren/orm/drizzle/mysql'
1530
+ if (driver === "mysql") return `import { mysqlTable, int, varchar, timestamp } from '@guren/orm/drizzle/mysql'
1795
1531
 
1796
1532
  export const users = mysqlTable('users', {
1797
1533
  id: int('id').primaryKey().autoincrement(),
@@ -1800,8 +1536,7 @@ export const users = mysqlTable('users', {
1800
1536
  createdAt: timestamp('created_at').notNull().defaultNow(),
1801
1537
  })
1802
1538
  `;
1803
- }
1804
- return `import { sqliteTable, integer, text } from '@guren/orm/drizzle/sqlite'
1539
+ return `import { sqliteTable, integer, text } from '@guren/orm/drizzle/sqlite'
1805
1540
 
1806
1541
  export const users = sqliteTable('users', {
1807
1542
  id: integer('id').primaryKey({ autoIncrement: true }),
@@ -1811,33 +1546,41 @@ export const users = sqliteTable('users', {
1811
1546
  })
1812
1547
  `;
1813
1548
  }
1549
+ /**
1550
+ * Templates whose app code needs more than the single `users` table above ship
1551
+ * their own schema, one file per driver, as `db/schema.<driver>.ts`. The variant
1552
+ * for the selected driver becomes `db/schema.ts` and the rest are deleted.
1553
+ *
1554
+ * The indirection exists because `applyDatabaseConfig` has to overwrite
1555
+ * `db/schema.ts` — a template carrying a plain `db/schema.ts` written for one
1556
+ * driver would otherwise be handed to users who picked another. The blueprint
1557
+ * this replaced worked around that by regenerating its schema from a copy kept
1558
+ * in this file, which then drifted from the columns its own controllers read.
1559
+ *
1560
+ * A template that ships some variants but not the selected one is a packaging
1561
+ * bug, not a reason to fall back to the generic schema: the fallback would
1562
+ * scaffold an app whose models reference tables that do not exist.
1563
+ */
1814
1564
  function schemaVariantPath(destination, driver) {
1815
- return join(destination, `db/schema.${driver}.ts`);
1565
+ return join(destination, `db/schema.${driver}.ts`);
1816
1566
  }
1817
1567
  async function resolveSchema(destination, driver) {
1818
- const shipped = (await Promise.all(
1819
- DATABASE_DRIVERS.map(async (name) => await fileExists(schemaVariantPath(destination, name)) ? name : null)
1820
- )).filter((name) => name !== null);
1821
- if (shipped.length === 0) {
1822
- return generateSchema(driver);
1823
- }
1824
- if (!shipped.includes(driver)) {
1825
- throw new Error(
1826
- `This template ships a database schema for ${shipped.join(", ")} but not for ${driver}. This build of create-guren-app is incomplete \u2014 please report it at https://github.com/gurenjs/guren/issues.`
1827
- );
1828
- }
1829
- return readFile(schemaVariantPath(destination, driver), "utf8");
1568
+ const shipped = (await Promise.all(DATABASE_DRIVERS.map(async (name) => await fileExists(schemaVariantPath(destination, name)) ? name : null))).filter((name) => name !== null);
1569
+ if (shipped.length === 0) return generateSchema(driver);
1570
+ if (!shipped.includes(driver)) throw new Error(`This template ships a database schema for ${shipped.join(", ")} but not for ${driver}. This build of create-guren-app is incomplete — please report it at https://github.com/gurenjs/guren/issues.`);
1571
+ return readFile(schemaVariantPath(destination, driver), "utf8");
1830
1572
  }
1831
1573
  function generateDrizzleConfig(driver) {
1832
- const { url, dialect } = DATABASE_DEFAULTS[driver];
1833
- const preamble = driver !== "sqlite" ? "" : `
1574
+ const { url, dialect } = DATABASE_DEFAULTS[driver];
1575
+ return `import { defineConfig } from 'drizzle-kit'
1576
+ ${driver !== "sqlite" ? "" : `
1834
1577
  const filename = process.env.DATABASE_URL ?? '${url}'
1835
1578
 
1836
1579
  /**
1837
1580
  * DATABASE_URL is read by two different SQLite implementations that disagree
1838
1581
  * about URI filenames: the app opens it with \`bun:sqlite\`, which honours them,
1839
1582
  * while drizzle-kit opens it with \`node:sqlite\`, which does not. So \`file:\` is
1840
- * not a shared spelling of anything \u2014 \`file:local.db\` migrates the app into
1583
+ * not a shared spelling of anything — \`file:local.db\` migrates the app into
1841
1584
  * \`local.db\` and drizzle-kit into a file *named* \`file:local.db\`. The safe set
1842
1585
  * is what both agree on: plain paths, and \`:memory:\`.
1843
1586
  *
@@ -1852,26 +1595,27 @@ if (uriScheme) {
1852
1595
  'Point it at a file such as ${url}, or use ":memory:".',
1853
1596
  )
1854
1597
  }
1855
- `;
1856
- const credentialUrl = driver === "sqlite" ? "filename" : `process.env.DATABASE_URL ?? '${url}'`;
1857
- return `import { defineConfig } from 'drizzle-kit'
1858
- ${preamble}
1598
+ `}
1859
1599
  export default defineConfig({
1860
1600
  schema: './db/schema.ts',
1861
1601
  out: './db/migrations',
1862
1602
  dialect: '${dialect}',
1863
1603
  dbCredentials: {
1864
- url: ${credentialUrl},
1604
+ url: ${driver === "sqlite" ? "filename" : `process.env.DATABASE_URL ?? '${url}'`},
1865
1605
  },
1866
1606
  })
1867
1607
  `;
1868
1608
  }
1609
+ /**
1610
+ * True when the driver runs in a container the scaffolder provisions — the one
1611
+ * fact that decides docker-compose.yml, the db:up/db:down scripts, and whether
1612
+ * the next-steps output mentions starting a database.
1613
+ */
1869
1614
  function usesDatabaseContainer(driver) {
1870
- return generateDockerCompose(driver) !== null;
1615
+ return generateDockerCompose(driver) !== null;
1871
1616
  }
1872
1617
  function generateDockerCompose(driver) {
1873
- if (driver === "postgres") {
1874
- return `services:
1618
+ if (driver === "postgres") return `services:
1875
1619
  postgres:
1876
1620
  image: postgres:17-alpine
1877
1621
  ports:
@@ -1886,9 +1630,7 @@ function generateDockerCompose(driver) {
1886
1630
  volumes:
1887
1631
  postgres_data:
1888
1632
  `;
1889
- }
1890
- if (driver === "mysql") {
1891
- return `services:
1633
+ if (driver === "mysql") return `services:
1892
1634
  mysql:
1893
1635
  image: mysql:8.4
1894
1636
  ports:
@@ -1904,510 +1646,480 @@ volumes:
1904
1646
  volumes:
1905
1647
  mysql_data:
1906
1648
  `;
1907
- }
1908
- return null;
1649
+ return null;
1909
1650
  }
1910
1651
  async function applyDatabaseConfig(destination, driver) {
1911
- const { url, dep } = DATABASE_DEFAULTS[driver];
1912
- const dockerCompose = generateDockerCompose(driver);
1913
- const schema = await resolveSchema(destination, driver);
1914
- const databaseConfig = await loadDatabaseConfig(driver);
1915
- await Promise.all([
1916
- writeFile(join(destination, "config/database.ts"), databaseConfig, "utf8"),
1917
- writeFile(join(destination, "db/schema.ts"), schema, "utf8"),
1918
- // Independent of the write above: the selected variant's contents are
1919
- // already in `schema`, and no variant shares a path with db/schema.ts.
1920
- ...DATABASE_DRIVERS.map((name) => rm(schemaVariantPath(destination, name), { force: true })),
1921
- writeFile(join(destination, "drizzle.config.ts"), generateDrizzleConfig(driver), "utf8"),
1922
- dockerCompose ? writeFile(join(destination, "docker-compose.yml"), dockerCompose, "utf8") : Promise.resolve(),
1923
- // Update .env and .env.example with the correct DATABASE_URL
1924
- ...[".env", ".env.example"].map(async (envFile) => {
1925
- const envPath = join(destination, envFile);
1926
- try {
1927
- const content = await readFile(envPath, "utf8");
1928
- await writeFile(envPath, content.replace(/^DATABASE_URL=.*$/mu, `DATABASE_URL=${url}`), "utf8");
1929
- } catch {
1930
- }
1931
- })
1932
- ]);
1933
- if (dep || dockerCompose) {
1934
- const packageJsonPath = join(destination, "package.json");
1935
- const raw = await readFile(packageJsonPath, "utf8");
1936
- const pkg = JSON.parse(raw);
1937
- if (dep) {
1938
- pkg.dependencies ??= {};
1939
- Object.assign(pkg.dependencies, dep);
1940
- }
1941
- if (dockerCompose) {
1942
- pkg.scripts ??= {};
1943
- pkg.scripts["db:up"] = "docker compose up -d";
1944
- pkg.scripts["db:down"] = "docker compose down";
1945
- }
1946
- await writeFile(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
1947
- `, "utf8");
1948
- }
1652
+ const { url, dep } = DATABASE_DEFAULTS[driver];
1653
+ const dockerCompose = generateDockerCompose(driver);
1654
+ const schema = await resolveSchema(destination, driver);
1655
+ const databaseConfig = await loadDatabaseConfig(driver);
1656
+ await Promise.all([
1657
+ writeFile(join(destination, "config/database.ts"), databaseConfig, "utf8"),
1658
+ writeFile(join(destination, "db/schema.ts"), schema, "utf8"),
1659
+ ...DATABASE_DRIVERS.map((name) => rm(schemaVariantPath(destination, name), { force: true })),
1660
+ writeFile(join(destination, "drizzle.config.ts"), generateDrizzleConfig(driver), "utf8"),
1661
+ dockerCompose ? writeFile(join(destination, "docker-compose.yml"), dockerCompose, "utf8") : Promise.resolve(),
1662
+ ...[".env", ".env.example"].map(async (envFile) => {
1663
+ const envPath = join(destination, envFile);
1664
+ try {
1665
+ const content = await readFile(envPath, "utf8");
1666
+ await writeFile(envPath, content.replace(/^DATABASE_URL=.*$/mu, `DATABASE_URL=${url}`), "utf8");
1667
+ } catch {}
1668
+ })
1669
+ ]);
1670
+ if (dep || dockerCompose) {
1671
+ const packageJsonPath = join(destination, "package.json");
1672
+ const raw = await readFile(packageJsonPath, "utf8");
1673
+ const pkg = JSON.parse(raw);
1674
+ if (dep) {
1675
+ pkg.dependencies ??= {};
1676
+ Object.assign(pkg.dependencies, dep);
1677
+ }
1678
+ if (dockerCompose) {
1679
+ pkg.scripts ??= {};
1680
+ pkg.scripts["db:up"] = "docker compose up -d";
1681
+ pkg.scripts["db:down"] = "docker compose down";
1682
+ }
1683
+ await writeFile(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
1684
+ }
1949
1685
  }
1950
1686
  function listAppBlueprints() {
1951
- return [...APP_BLUEPRINTS];
1687
+ return [...APP_BLUEPRINTS];
1952
1688
  }
1689
+ /**
1690
+ * The templates a blueprint copies from, in copy order: base first, then
1691
+ * overlays, each overwriting what came before. Omit `renderingMode` for every
1692
+ * mode the blueprint supports — what the packaging checks need; pass one for
1693
+ * the templates a single scaffold will actually copy.
1694
+ *
1695
+ * Repeats are returned as-is rather than deduped: a name listed twice means
1696
+ * "copy it again at this point", and collapsing it would silently change which
1697
+ * template wins.
1698
+ */
1953
1699
  function listBlueprintTemplates(blueprint, renderingMode) {
1954
- const overlays = renderingMode ? blueprint.overlayTemplates[renderingMode] ?? [] : Object.values(blueprint.overlayTemplates).flat();
1955
- return [blueprint.baseTemplate, ...overlays];
1700
+ const overlays = renderingMode ? blueprint.overlayTemplates[renderingMode] ?? [] : Object.values(blueprint.overlayTemplates).flat();
1701
+ return [blueprint.baseTemplate, ...overlays];
1956
1702
  }
1957
1703
  async function assertBlueprintLayersExist(blueprint, renderingMode) {
1958
- for (const layer of listBlueprintTemplates(blueprint, renderingMode)) {
1959
- if (!await directoryExists(templateDir(layer))) {
1960
- throw new Error(
1961
- `Blueprint "${blueprint.name}" is missing its template directory "${templateDir(layer)}". This build of create-guren-app is incomplete \u2014 please report it at https://github.com/gurenjs/guren/issues and try \`npm create guren-app@latest\` meanwhile.`
1962
- );
1963
- }
1964
- }
1704
+ for (const layer of listBlueprintTemplates(blueprint, renderingMode)) if (!await directoryExists(templateDir(layer))) throw new Error(`Blueprint "${blueprint.name}" is missing its template directory "${templateDir(layer)}". This build of create-guren-app is incomplete — please report it at https://github.com/gurenjs/guren/issues and try \`npm create guren-app@latest\` meanwhile.`);
1965
1705
  }
1966
1706
  function getAppBlueprint(name) {
1967
- const blueprintName = name ?? "default";
1968
- const blueprint = blueprintRegistry[blueprintName];
1969
- if (!blueprint) {
1970
- throw new Error(`Unknown blueprint "${name}". Available blueprints: ${listAppBlueprints().join(", ")}`);
1971
- }
1972
- return blueprint;
1707
+ const blueprint = blueprintRegistry[name ?? "default"];
1708
+ if (!blueprint) throw new Error(`Unknown blueprint "${name}". Available blueprints: ${listAppBlueprints().join(", ")}`);
1709
+ return blueprint;
1973
1710
  }
1974
1711
  async function scaffoldAppBlueprint(options) {
1975
- const blueprint = getAppBlueprint(options.blueprint);
1976
- const appName = basename(options.destination);
1977
- const packageName = toPackageName(appName);
1978
- const appTitle = toTitleCase(appName);
1979
- const context = {
1980
- appName,
1981
- appTitle,
1982
- destination: options.destination,
1983
- packageName,
1984
- renderingMode: options.renderingMode,
1985
- database: options.database
1986
- };
1987
- const tokenMap = /* @__PURE__ */ new Map([
1988
- ["guren-app-placeholder", packageName],
1989
- ["__APP_TITLE__", appTitle],
1990
- ["__APP_NAME__", appName]
1991
- ]);
1992
- await assertBlueprintLayersExist(blueprint, options.renderingMode);
1993
- for (const layer of listBlueprintTemplates(blueprint, options.renderingMode)) {
1994
- await copyLayer(layer, options.destination);
1995
- }
1996
- await applyTokenTransforms(options.destination, blueprint.transformFiles, tokenMap);
1997
- await scaffoldEnvFiles(options.destination);
1998
- await applyDatabaseConfig(options.destination, options.database);
1999
- await blueprint.postScaffold?.(context);
2000
- return blueprint;
2001
- }
2002
-
2003
- // src/git.ts
2004
- import { spawnSync } from "child_process";
2005
- var GIT_TIMEOUT_MS = 3e4;
1712
+ const blueprint = getAppBlueprint(options.blueprint);
1713
+ const appName = basename(options.destination);
1714
+ const packageName = toPackageName(appName);
1715
+ const appTitle = toTitleCase(appName);
1716
+ const context = {
1717
+ appName,
1718
+ appTitle,
1719
+ destination: options.destination,
1720
+ packageName,
1721
+ renderingMode: options.renderingMode,
1722
+ database: options.database
1723
+ };
1724
+ const tokenMap = /* @__PURE__ */ new Map([
1725
+ ["guren-app-placeholder", packageName],
1726
+ ["__APP_TITLE__", appTitle],
1727
+ ["__APP_NAME__", appName]
1728
+ ]);
1729
+ await assertBlueprintLayersExist(blueprint, options.renderingMode);
1730
+ for (const layer of listBlueprintTemplates(blueprint, options.renderingMode)) await copyLayer(layer, options.destination);
1731
+ await applyTokenTransforms(options.destination, blueprint.transformFiles, tokenMap);
1732
+ await scaffoldEnvFiles(options.destination);
1733
+ await applyDatabaseConfig(options.destination, options.database);
1734
+ await blueprint.postScaffold?.(context);
1735
+ return blueprint;
1736
+ }
1737
+ //#endregion
1738
+ //#region src/git.ts
1739
+ /**
1740
+ * How long the scaffolder waits on `git` before giving up.
1741
+ *
1742
+ * The bound is tied to how these children are run, not applied to every child
1743
+ * the scaffolder spawns. `bun install` and the app's own CLI inherit the
1744
+ * terminal: they can answer a prompt, they show progress, and a long one is
1745
+ * visibly working. These run with `stdio: 'pipe'` and no terminal, where a
1746
+ * signing passphrase prompt, a credential helper, or a stalled name lookup
1747
+ * while git guesses the committer identity waits on input that can never
1748
+ * arrive — silently, with the app already written to disk. Generous enough
1749
+ * that an ordinary commit on a loaded machine never trips it.
1750
+ */
1751
+ const GIT_TIMEOUT_MS = 3e4;
2006
1752
  function runGit(cwd, args, timeoutMs = GIT_TIMEOUT_MS) {
2007
- return spawnSync("git", args, {
2008
- cwd,
2009
- stdio: "pipe",
2010
- // Read at call time rather than hoisted: a caller that sets
2011
- // GIT_AUTHOR_*/GIT_COMMITTER_* just before this runs has to reach the
2012
- // child. GIT_TERMINAL_PROMPT keeps git from waiting on a terminal it does
2013
- // not have.
2014
- env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
2015
- // spawnSync reads a non-positive timeout as "no timeout".
2016
- timeout: Math.max(1, timeoutMs),
2017
- // SIGTERM leaves a git blocked in a syscall alive, and spawnSync would go
2018
- // on blocking with it.
2019
- killSignal: "SIGKILL"
2020
- });
1753
+ return spawnSync("git", args, {
1754
+ cwd,
1755
+ stdio: "pipe",
1756
+ env: {
1757
+ ...process.env,
1758
+ GIT_TERMINAL_PROMPT: "0"
1759
+ },
1760
+ timeout: Math.max(1, timeoutMs),
1761
+ killSignal: "SIGKILL"
1762
+ });
2021
1763
  }
2022
1764
  function wasKilledByTimeout(result) {
2023
- return result.error?.code === "ETIMEDOUT";
1765
+ return result.error?.code === "ETIMEDOUT";
2024
1766
  }
2025
1767
  function isInsideGitWorkTree(cwd, options = {}) {
2026
- const result = runGit(cwd, ["rev-parse", "--is-inside-work-tree"], options.timeoutMs);
2027
- if (wasKilledByTimeout(result)) {
2028
- return true;
2029
- }
2030
- return result.status === 0 && result.stdout.toString().trim() === "true";
1768
+ const result = runGit(cwd, ["rev-parse", "--is-inside-work-tree"], options.timeoutMs);
1769
+ if (wasKilledByTimeout(result)) return true;
1770
+ return result.status === 0 && result.stdout.toString().trim() === "true";
2031
1771
  }
2032
1772
  function initGitRepository(cwd, options = {}) {
2033
- const deadline = Date.now() + (options.timeoutMs ?? GIT_TIMEOUT_MS);
2034
- const run = (failedStep, args) => {
2035
- const remaining = deadline - Date.now();
2036
- const ok = remaining > 0 && runGit(cwd, args, remaining).status === 0;
2037
- return ok ? { ok: true } : { ok: false, failedStep, command: `git ${args.join(" ")}` };
2038
- };
2039
- const init2 = run("init", ["init"]);
2040
- if (!init2.ok) return init2;
2041
- const add = run("add", ["add", "-A"]);
2042
- if (!add.ok) return add;
2043
- return run("commit", ["commit", "-m", "chore: initial commit"]);
2044
- }
2045
-
2046
- // src/cli.ts
2047
- var RENDERING_MODES = ["spa", "ssr"];
2048
- var RENDERING_MODE_SET = new Set(RENDERING_MODES);
2049
- var DATABASE_DRIVER_SET = new Set(DATABASE_DRIVERS);
1773
+ const deadline = Date.now() + (options.timeoutMs ?? 3e4);
1774
+ const run = (failedStep, args) => {
1775
+ const remaining = deadline - Date.now();
1776
+ return remaining > 0 && runGit(cwd, args, remaining).status === 0 ? { ok: true } : {
1777
+ ok: false,
1778
+ failedStep,
1779
+ command: `git ${args.join(" ")}`
1780
+ };
1781
+ };
1782
+ const init = run("init", ["init"]);
1783
+ if (!init.ok) return init;
1784
+ const add = run("add", ["add", "-A"]);
1785
+ if (!add.ok) return add;
1786
+ return run("commit", [
1787
+ "commit",
1788
+ "-m",
1789
+ "chore: initial commit"
1790
+ ]);
1791
+ }
1792
+ //#endregion
1793
+ //#region src/cli.ts
1794
+ const RENDERING_MODE_SET = /* @__PURE__ */ new Set(["spa", "ssr"]);
1795
+ const DATABASE_DRIVER_SET = new Set(DATABASE_DRIVERS);
2050
1796
  async function ensureTargetDirectory(path, force) {
2051
- try {
2052
- await mkdir(path, { recursive: true });
2053
- } catch (error) {
2054
- if (error.code === "EEXIST") {
2055
- throw new Error(`Path "${path}" exists and is not a directory.`);
2056
- }
2057
- throw error;
2058
- }
2059
- if (!force) {
2060
- const empty = await isDirectoryEmpty(path);
2061
- if (!empty) {
2062
- throw new Error(`Directory "${path}" is not empty. Use --force to scaffold anyway.`);
2063
- }
2064
- }
1797
+ try {
1798
+ await mkdir(path, { recursive: true });
1799
+ } catch (error) {
1800
+ if (error.code === "EEXIST") throw new Error(`Path "${path}" exists and is not a directory.`);
1801
+ throw error;
1802
+ }
1803
+ if (!force) {
1804
+ if (!await isDirectoryEmpty(path)) throw new Error(`Directory "${path}" is not empty. Use --force to scaffold anyway.`);
1805
+ }
2065
1806
  }
2066
1807
  async function updateSsrPackageJson(destination) {
2067
- const packageJsonPath = resolve(destination, "package.json");
2068
- const raw = await readFile2(packageJsonPath, "utf8");
2069
- const pkg = JSON.parse(raw);
2070
- pkg.scripts ??= {};
2071
- pkg.scripts.build = "bun run codegen && bunx vite build && bunx vite build --ssr";
2072
- await writeFile2(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
2073
- `, "utf8");
1808
+ const packageJsonPath = resolve(destination, "package.json");
1809
+ const raw = await readFile(packageJsonPath, "utf8");
1810
+ const pkg = JSON.parse(raw);
1811
+ pkg.scripts ??= {};
1812
+ pkg.scripts.build = "bun run codegen && bunx vite build && bunx vite build --ssr";
1813
+ await writeFile(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
2074
1814
  }
2075
1815
  async function runAppCli(targetDir, cliArgs) {
2076
- const { spawnSync: spawnSync2 } = await import("child_process");
2077
- const cliBin = resolve(targetDir, "node_modules/@guren/cli/dist/bin.js");
2078
- const result = spawnSync2("bun", [cliBin, ...cliArgs], {
2079
- cwd: targetDir,
2080
- stdio: "inherit"
2081
- });
2082
- return result.status === 0;
1816
+ const { spawnSync } = await import("node:child_process");
1817
+ return spawnSync("bun", [resolve(targetDir, "node_modules/@guren/cli/dist/bin.js"), ...cliArgs], {
1818
+ cwd: targetDir,
1819
+ stdio: "inherit"
1820
+ }).status === 0;
2083
1821
  }
2084
1822
  async function resolveRenderingMode(flagValue) {
2085
- if (typeof flagValue === "string") {
2086
- const normalized = flagValue.toLowerCase();
2087
- if (!RENDERING_MODE_SET.has(normalized)) {
2088
- throw new Error('Invalid rendering mode. Supported values are "spa" or "ssr".');
2089
- }
2090
- return normalized;
2091
- }
2092
- if (!process3.stdin.isTTY) {
2093
- return "ssr";
2094
- }
2095
- const result = await consola.prompt("Choose the rendering mode for this project", {
2096
- type: "select",
2097
- options: [
2098
- { value: "ssr", label: "SSR (server-side rendering)" },
2099
- { value: "spa", label: "SPA (client-side rendering only)" }
2100
- ],
2101
- initial: "ssr",
2102
- default: "ssr"
2103
- });
2104
- const value = typeof result === "string" ? result : "ssr";
2105
- return value ?? "ssr";
1823
+ if (typeof flagValue === "string") {
1824
+ const normalized = flagValue.toLowerCase();
1825
+ if (!RENDERING_MODE_SET.has(normalized)) throw new Error("Invalid rendering mode. Supported values are \"spa\" or \"ssr\".");
1826
+ return normalized;
1827
+ }
1828
+ if (!g$1.stdin.isTTY) return "ssr";
1829
+ const result = await consola.prompt("Choose the rendering mode for this project", {
1830
+ type: "select",
1831
+ options: [{
1832
+ value: "ssr",
1833
+ label: "SSR (server-side rendering)"
1834
+ }, {
1835
+ value: "spa",
1836
+ label: "SPA (client-side rendering only)"
1837
+ }],
1838
+ initial: "ssr",
1839
+ default: "ssr"
1840
+ });
1841
+ return (typeof result === "string" ? result : "ssr") ?? "ssr";
2106
1842
  }
2107
1843
  async function resolveDatabase(flagValue) {
2108
- if (typeof flagValue === "string") {
2109
- const normalized = flagValue.toLowerCase();
2110
- if (!DATABASE_DRIVER_SET.has(normalized)) {
2111
- throw new Error(`Invalid database driver. Supported values are: ${DATABASE_DRIVERS.join(", ")}`);
2112
- }
2113
- return normalized;
2114
- }
2115
- if (!process3.stdin.isTTY) {
2116
- return "sqlite";
2117
- }
2118
- const result = await consola.prompt("Choose the database driver", {
2119
- type: "select",
2120
- options: [
2121
- { value: "sqlite", label: "SQLite (zero-config, recommended for getting started)" },
2122
- { value: "postgres", label: "PostgreSQL" },
2123
- { value: "mysql", label: "MySQL" }
2124
- ],
2125
- initial: "sqlite",
2126
- default: "sqlite"
2127
- });
2128
- const value = typeof result === "string" ? result : "sqlite";
2129
- return value ?? "sqlite";
2130
- }
2131
- var AGENT_CHOICES = ["claude", "codex", "cursor", "copilot", "opencode"];
2132
- var AGENT_CHOICE_SET = new Set(AGENT_CHOICES);
2133
- var AGENT_CHOICES_HELP = `Supported values are: ${AGENT_CHOICES.join(", ")}, all, none.`;
2134
- var DEFAULT_AGENTS = ["claude"];
1844
+ if (typeof flagValue === "string") {
1845
+ const normalized = flagValue.toLowerCase();
1846
+ if (!DATABASE_DRIVER_SET.has(normalized)) throw new Error(`Invalid database driver. Supported values are: ${DATABASE_DRIVERS.join(", ")}`);
1847
+ return normalized;
1848
+ }
1849
+ if (!g$1.stdin.isTTY) return "sqlite";
1850
+ const result = await consola.prompt("Choose the database driver", {
1851
+ type: "select",
1852
+ options: [
1853
+ {
1854
+ value: "sqlite",
1855
+ label: "SQLite (zero-config, recommended for getting started)"
1856
+ },
1857
+ {
1858
+ value: "postgres",
1859
+ label: "PostgreSQL"
1860
+ },
1861
+ {
1862
+ value: "mysql",
1863
+ label: "MySQL"
1864
+ }
1865
+ ],
1866
+ initial: "sqlite",
1867
+ default: "sqlite"
1868
+ });
1869
+ return (typeof result === "string" ? result : "sqlite") ?? "sqlite";
1870
+ }
1871
+ const AGENT_CHOICES = [
1872
+ "claude",
1873
+ "codex",
1874
+ "cursor",
1875
+ "copilot",
1876
+ "opencode"
1877
+ ];
1878
+ const AGENT_CHOICE_SET = new Set(AGENT_CHOICES);
1879
+ const AGENT_CHOICES_HELP = `Supported values are: ${AGENT_CHOICES.join(", ")}, all, none.`;
1880
+ const DEFAULT_AGENTS = ["claude"];
1881
+ /**
1882
+ * The selection handed to `guren agent:init --target`: agent names, `['all']`
1883
+ * forwarded verbatim (the app's CLI owns the expansion, so a framework
1884
+ * release that learns a new target is not narrowed by this list), or null
1885
+ * when the user opted out of the harness entirely.
1886
+ */
2135
1887
  async function resolveAgents(flagValue) {
2136
- const raw = Array.isArray(flagValue) ? flagValue.join(",") : flagValue;
2137
- if (typeof raw === "string") {
2138
- const parts = new Set(
2139
- raw.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean)
2140
- );
2141
- if (parts.size === 0) {
2142
- throw new Error(`Invalid --agents value. ${AGENT_CHOICES_HELP}`);
2143
- }
2144
- if (parts.has("none")) {
2145
- if (parts.size > 1) {
2146
- throw new Error('--agents "none" cannot be combined with other values.');
2147
- }
2148
- return null;
2149
- }
2150
- for (const part of parts) {
2151
- if (part !== "all" && !AGENT_CHOICE_SET.has(part)) {
2152
- throw new Error(`Invalid agent "${part}". ${AGENT_CHOICES_HELP}`);
2153
- }
2154
- }
2155
- return parts.has("all") ? ["all"] : [...parts];
2156
- }
2157
- if (!process3.stdin.isTTY) {
2158
- return DEFAULT_AGENTS;
2159
- }
2160
- const result = await consola.prompt("Which AI coding agents should the agent harness support?", {
2161
- type: "multiselect",
2162
- options: [
2163
- { value: "claude", label: "Claude Code" },
2164
- { value: "codex", label: "Codex" },
2165
- { value: "cursor", label: "Cursor" },
2166
- { value: "copilot", label: "GitHub Copilot" },
2167
- { value: "opencode", label: "OpenCode" }
2168
- ],
2169
- initial: DEFAULT_AGENTS,
2170
- required: false
2171
- });
2172
- if (!Array.isArray(result)) {
2173
- return DEFAULT_AGENTS;
2174
- }
2175
- if (result.length === 0) {
2176
- return null;
2177
- }
2178
- const agents = result.map(
2179
- (entry) => String(
2180
- typeof entry === "object" && entry !== null && "value" in entry ? entry.value : entry
2181
- )
2182
- ).filter((value) => AGENT_CHOICE_SET.has(value));
2183
- return agents.length > 0 ? agents : DEFAULT_AGENTS;
1888
+ const raw = Array.isArray(flagValue) ? flagValue.join(",") : flagValue;
1889
+ if (typeof raw === "string") {
1890
+ const parts = new Set(raw.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean));
1891
+ if (parts.size === 0) throw new Error(`Invalid --agents value. ${AGENT_CHOICES_HELP}`);
1892
+ if (parts.has("none")) {
1893
+ if (parts.size > 1) throw new Error("--agents \"none\" cannot be combined with other values.");
1894
+ return null;
1895
+ }
1896
+ for (const part of parts) if (part !== "all" && !AGENT_CHOICE_SET.has(part)) throw new Error(`Invalid agent "${part}". ${AGENT_CHOICES_HELP}`);
1897
+ return parts.has("all") ? ["all"] : [...parts];
1898
+ }
1899
+ if (!g$1.stdin.isTTY) return DEFAULT_AGENTS;
1900
+ const result = await consola.prompt("Which AI coding agents should the agent harness support?", {
1901
+ type: "multiselect",
1902
+ options: [
1903
+ {
1904
+ value: "claude",
1905
+ label: "Claude Code"
1906
+ },
1907
+ {
1908
+ value: "codex",
1909
+ label: "Codex"
1910
+ },
1911
+ {
1912
+ value: "cursor",
1913
+ label: "Cursor"
1914
+ },
1915
+ {
1916
+ value: "copilot",
1917
+ label: "GitHub Copilot"
1918
+ },
1919
+ {
1920
+ value: "opencode",
1921
+ label: "OpenCode"
1922
+ }
1923
+ ],
1924
+ initial: DEFAULT_AGENTS,
1925
+ required: false
1926
+ });
1927
+ if (!Array.isArray(result)) return DEFAULT_AGENTS;
1928
+ if (result.length === 0) return null;
1929
+ const agents = result.map((entry) => String(typeof entry === "object" && entry !== null && "value" in entry ? entry.value : entry)).filter((value) => AGENT_CHOICE_SET.has(value));
1930
+ return agents.length > 0 ? agents : DEFAULT_AGENTS;
2184
1931
  }
2185
1932
  async function resolveGitInit(flagValue, target) {
2186
- if (flagValue === false) {
2187
- return false;
2188
- }
2189
- if (flagValue !== true && !process3.stdin.isTTY) {
2190
- return false;
2191
- }
2192
- const declined = (reason) => {
2193
- if (flagValue === true) {
2194
- consola.warn(`Skipping git initialization: ${reason}`);
2195
- }
2196
- return false;
2197
- };
2198
- if (!target.wasEmpty) {
2199
- return declined("the target directory already contained files.");
2200
- }
2201
- if (isInsideGitWorkTree(target.dir)) {
2202
- return declined("the target directory is already inside a git repository.");
2203
- }
2204
- if (flagValue === true) {
2205
- return true;
2206
- }
2207
- const result = await consola.prompt("Initialize a git repository with an initial commit?", {
2208
- type: "confirm",
2209
- initial: true
2210
- });
2211
- return result === true;
1933
+ if (flagValue === false) return false;
1934
+ if (flagValue !== true && !g$1.stdin.isTTY) return false;
1935
+ const declined = (reason) => {
1936
+ if (flagValue === true) consola.warn(`Skipping git initialization: ${reason}`);
1937
+ return false;
1938
+ };
1939
+ if (!target.wasEmpty) return declined("the target directory already contained files.");
1940
+ if (isInsideGitWorkTree(target.dir)) return declined("the target directory is already inside a git repository.");
1941
+ if (flagValue === true) return true;
1942
+ return await consola.prompt("Initialize a git repository with an initial commit?", {
1943
+ type: "confirm",
1944
+ initial: true
1945
+ }) === true;
2212
1946
  }
2213
1947
  function reportGitInit(cwd) {
2214
- consola.start("Initializing git repository...");
2215
- const result = initGitRepository(cwd);
2216
- if (result.ok) {
2217
- consola.success("Initialized a git repository with an initial commit");
2218
- return;
2219
- }
2220
- if (result.failedStep === "commit") {
2221
- consola.warn("Created a git repository, but the initial commit failed (git identity may be unset).");
2222
- consola.warn('Set `git config user.name` and `git config user.email`, then run `git commit -m "chore: initial commit"`.');
2223
- return;
2224
- }
2225
- consola.warn(`Failed to run \`${result.command}\`. Initialize the repository manually.`);
1948
+ consola.start("Initializing git repository...");
1949
+ const result = initGitRepository(cwd);
1950
+ if (result.ok) {
1951
+ consola.success("Initialized a git repository with an initial commit");
1952
+ return;
1953
+ }
1954
+ if (result.failedStep === "commit") {
1955
+ consola.warn("Created a git repository, but the initial commit failed (git identity may be unset).");
1956
+ consola.warn("Set `git config user.name` and `git config user.email`, then run `git commit -m \"chore: initial commit\"`.");
1957
+ return;
1958
+ }
1959
+ consola.warn(`Failed to run \`${result.command}\`. Initialize the repository manually.`);
2226
1960
  }
2227
1961
  async function installDependencies(cwd) {
2228
- try {
2229
- consola.start("Installing dependencies...");
2230
- const { spawnSync: spawnSync2 } = await import("child_process");
2231
- const result = spawnSync2("bun", ["install"], { cwd, stdio: "inherit" });
2232
- if (result.status !== 0) {
2233
- consola.warn("Failed to install dependencies. Run `bun install` manually.");
2234
- return false;
2235
- }
2236
- consola.success("Dependencies installed");
2237
- return true;
2238
- } catch {
2239
- consola.warn("Failed to install dependencies. Run `bun install` manually.");
2240
- return false;
2241
- }
2242
- }
2243
- var command = defineCommand({
2244
- meta: {
2245
- name: "create-guren-app",
2246
- description: "Scaffold a new Guren application."
2247
- },
2248
- args: {
2249
- target: {
2250
- type: "positional",
2251
- description: "Directory to create the application in",
2252
- default: "."
2253
- },
2254
- force: {
2255
- type: "boolean",
2256
- alias: "f",
2257
- description: "Overwrite existing files in the target directory"
2258
- },
2259
- mode: {
2260
- type: "string",
2261
- description: "Rendering mode to scaffold (spa or ssr)"
2262
- },
2263
- auth: {
2264
- type: "boolean",
2265
- description: "Include authentication scaffolding with auto-configured providers and middleware"
2266
- },
2267
- blueprint: {
2268
- type: "string",
2269
- description: `Starter blueprint to scaffold (${listAppBlueprints().join(", ")})`
2270
- },
2271
- db: {
2272
- type: "string",
2273
- description: `Database driver (${DATABASE_DRIVERS.join(", ")})`
2274
- },
2275
- install: {
2276
- type: "boolean",
2277
- description: "Install dependencies after scaffolding (default: true)",
2278
- default: true
2279
- },
2280
- git: {
2281
- type: "boolean",
2282
- description: "Initialize a git repository and create an initial commit (prompted when interactive, off otherwise)"
2283
- },
2284
- agents: {
2285
- type: "string",
2286
- description: "AI agents to set up the harness for: claude, codex, cursor, copilot, opencode, all, or none (prompted when interactive; default: claude)"
2287
- }
2288
- },
2289
- async run({ args }) {
2290
- const target = args.target;
2291
- const force = Boolean(args.force);
2292
- const targetDir = resolve(process3.cwd(), target);
2293
- let targetWasEmpty = true;
2294
- if (await directoryExists(targetDir)) {
2295
- targetWasEmpty = await isDirectoryEmpty(targetDir);
2296
- if (!force && !targetWasEmpty) {
2297
- throw new Error(`Directory "${targetDir}" is not empty. Use --force to scaffold anyway.`);
2298
- }
2299
- } else {
2300
- await ensureTargetDirectory(targetDir, true);
2301
- }
2302
- const blueprint = getAppBlueprint(typeof args.blueprint === "string" ? args.blueprint : void 0);
2303
- const renderingMode = blueprint.name === "api" ? "spa" : await resolveRenderingMode(args.mode);
2304
- const database = await resolveDatabase(args.db);
2305
- const agents = await resolveAgents(args.agents);
2306
- const shouldInitGit = await resolveGitInit(args.git, { dir: targetDir, wasEmpty: targetWasEmpty });
2307
- await scaffoldAppBlueprint({
2308
- blueprint: blueprint.name,
2309
- destination: targetDir,
2310
- renderingMode,
2311
- database
2312
- });
2313
- if (renderingMode === "ssr") {
2314
- await updateSsrPackageJson(targetDir);
2315
- }
2316
- if (args.auth && blueprint.includesAuth) {
2317
- consola.info(`The ${blueprint.name} blueprint already ships authentication \u2014 ignoring --auth.`);
2318
- }
2319
- const includeAuth = Boolean(args.auth) && !blueprint.includesAuth;
2320
- const shouldInstall = args.install !== false;
2321
- let installed = false;
2322
- if (shouldInstall) {
2323
- installed = await installDependencies(targetDir);
2324
- }
2325
- if (agents === null) {
2326
- consola.info(
2327
- "Skipping the AI agent harness. Add it later with `bunx guren agent:init --target <agents>`."
2328
- );
2329
- } else {
2330
- const targetList = agents.join(",");
2331
- let harnessInstalled = false;
2332
- if (installed) {
2333
- consola.start("Setting up AI agent harness...");
2334
- harnessInstalled = await runAppCli(targetDir, ["agent:init", "--target", targetList]);
2335
- if (harnessInstalled) {
2336
- consola.success(`AI agent harness installed for: ${targetList}`);
2337
- }
2338
- }
2339
- if (!harnessInstalled) {
2340
- consola.warn(
2341
- `AI agent harness was not installed automatically. Run \`bunx guren agent:init --target ${targetList}\` inside the app after installing dependencies.`
2342
- );
2343
- }
2344
- }
2345
- let authInstalled = false;
2346
- if (includeAuth) {
2347
- if (installed) {
2348
- consola.start("Adding authentication scaffolding...");
2349
- authInstalled = await runAppCli(targetDir, ["add", "auth", "--force"]);
2350
- if (authInstalled) {
2351
- consola.success("Authentication scaffolding added");
2352
- }
2353
- }
2354
- if (!authInstalled) {
2355
- consola.warn("Authentication was not scaffolded automatically. Run `bunx guren add auth` inside the app after installing dependencies.");
2356
- }
2357
- }
2358
- if (shouldInitGit) {
2359
- reportGitInit(targetDir);
2360
- }
2361
- const relativeTarget = relative2(process3.cwd(), targetDir) || ".";
2362
- consola.success(`Scaffolded a new Guren app (${blueprint.name}/${renderingMode.toUpperCase()}/${database}) in ${relativeTarget}`);
2363
- consola.info("Next steps:");
2364
- if (relativeTarget !== ".") {
2365
- consola.log(` cd ${relativeTarget}`);
2366
- }
2367
- if (!installed) {
2368
- consola.log(" bun install");
2369
- }
2370
- if (usesDatabaseContainer(database)) {
2371
- consola.log(" bun run db:up");
2372
- }
2373
- consola.log("");
2374
- consola.info("Add features:");
2375
- if (!blueprint.includesAuth) {
2376
- consola.log(" bunx guren add auth");
2377
- }
2378
- consola.log(' bunx guren add resource posts --fields "title:string,body:text"');
2379
- consola.log("");
2380
- consola.info("Generate types and set up database:");
2381
- consola.log(" bun run codegen");
2382
- consola.log(" bun run db:make");
2383
- consola.log(" bun run db:migrate");
2384
- consola.log(" bun run db:seed");
2385
- consola.log("");
2386
- consola.info("Verify and run:");
2387
- consola.log(" bun run typecheck");
2388
- consola.log(" bun run test");
2389
- consola.log(" bun run dev");
2390
- if (authInstalled) {
2391
- consola.log("");
2392
- consola.info("Auth scaffolding was included automatically.");
2393
- consola.info("Set up the users table with: bun run db:make && bun run db:migrate && bun run db:seed");
2394
- }
2395
- if (renderingMode === "ssr") {
2396
- consola.log("");
2397
- consola.info("Production build:");
2398
- consola.log(" bun run build");
2399
- consola.log("");
2400
- consola.info("Optional deploy path:");
2401
- consola.log(" bunx guren plugin @guren/plugin-vercel");
2402
- consola.log(" bun add @guren/plugin-vercel");
2403
- }
2404
- }
2405
- });
2406
- runMain(command).catch((error) => {
2407
- if (error instanceof Error) {
2408
- consola.error(error.message);
2409
- } else {
2410
- consola.error(String(error));
2411
- }
2412
- process3.exit(1);
1962
+ try {
1963
+ consola.start("Installing dependencies...");
1964
+ const { spawnSync } = await import("node:child_process");
1965
+ if (spawnSync("bun", ["install"], {
1966
+ cwd,
1967
+ stdio: "inherit"
1968
+ }).status !== 0) {
1969
+ consola.warn("Failed to install dependencies. Run `bun install` manually.");
1970
+ return false;
1971
+ }
1972
+ consola.success("Dependencies installed");
1973
+ return true;
1974
+ } catch {
1975
+ consola.warn("Failed to install dependencies. Run `bun install` manually.");
1976
+ return false;
1977
+ }
1978
+ }
1979
+ runMain(defineCommand({
1980
+ meta: {
1981
+ name: "create-guren-app",
1982
+ description: "Scaffold a new Guren application."
1983
+ },
1984
+ args: {
1985
+ target: {
1986
+ type: "positional",
1987
+ description: "Directory to create the application in",
1988
+ default: "."
1989
+ },
1990
+ force: {
1991
+ type: "boolean",
1992
+ alias: "f",
1993
+ description: "Overwrite existing files in the target directory"
1994
+ },
1995
+ mode: {
1996
+ type: "string",
1997
+ description: "Rendering mode to scaffold (spa or ssr)"
1998
+ },
1999
+ auth: {
2000
+ type: "boolean",
2001
+ description: "Include authentication scaffolding with auto-configured providers and middleware"
2002
+ },
2003
+ blueprint: {
2004
+ type: "string",
2005
+ description: `Starter blueprint to scaffold (${listAppBlueprints().join(", ")})`
2006
+ },
2007
+ db: {
2008
+ type: "string",
2009
+ description: `Database driver (${DATABASE_DRIVERS.join(", ")})`
2010
+ },
2011
+ install: {
2012
+ type: "boolean",
2013
+ description: "Install dependencies after scaffolding (default: true)",
2014
+ default: true
2015
+ },
2016
+ git: {
2017
+ type: "boolean",
2018
+ description: "Initialize a git repository and create an initial commit (prompted when interactive, off otherwise)"
2019
+ },
2020
+ agents: {
2021
+ type: "string",
2022
+ description: "AI agents to set up the harness for: claude, codex, cursor, copilot, opencode, all, or none (prompted when interactive; default: claude)"
2023
+ }
2024
+ },
2025
+ async run({ args }) {
2026
+ const target = args.target;
2027
+ const force = Boolean(args.force);
2028
+ const targetDir = resolve(g$1.cwd(), target);
2029
+ let targetWasEmpty = true;
2030
+ if (await directoryExists(targetDir)) {
2031
+ targetWasEmpty = await isDirectoryEmpty(targetDir);
2032
+ if (!force && !targetWasEmpty) throw new Error(`Directory "${targetDir}" is not empty. Use --force to scaffold anyway.`);
2033
+ } else await ensureTargetDirectory(targetDir, true);
2034
+ const blueprint = getAppBlueprint(typeof args.blueprint === "string" ? args.blueprint : void 0);
2035
+ const renderingMode = blueprint.name === "api" ? "spa" : await resolveRenderingMode(args.mode);
2036
+ const database = await resolveDatabase(args.db);
2037
+ const agents = await resolveAgents(args.agents);
2038
+ const shouldInitGit = await resolveGitInit(args.git, {
2039
+ dir: targetDir,
2040
+ wasEmpty: targetWasEmpty
2041
+ });
2042
+ await scaffoldAppBlueprint({
2043
+ blueprint: blueprint.name,
2044
+ destination: targetDir,
2045
+ renderingMode,
2046
+ database
2047
+ });
2048
+ if (renderingMode === "ssr") await updateSsrPackageJson(targetDir);
2049
+ if (args.auth && blueprint.includesAuth) consola.info(`The ${blueprint.name} blueprint already ships authentication — ignoring --auth.`);
2050
+ const includeAuth = Boolean(args.auth) && !blueprint.includesAuth;
2051
+ const shouldInstall = args.install !== false;
2052
+ let installed = false;
2053
+ if (shouldInstall) installed = await installDependencies(targetDir);
2054
+ if (agents === null) consola.info("Skipping the AI agent harness. Add it later with `bunx guren agent:init --target <agents>`.");
2055
+ else {
2056
+ const targetList = agents.join(",");
2057
+ let harnessInstalled = false;
2058
+ if (installed) {
2059
+ consola.start("Setting up AI agent harness...");
2060
+ harnessInstalled = await runAppCli(targetDir, [
2061
+ "agent:init",
2062
+ "--target",
2063
+ targetList
2064
+ ]);
2065
+ if (harnessInstalled) consola.success(`AI agent harness installed for: ${targetList}`);
2066
+ }
2067
+ if (!harnessInstalled) consola.warn(`AI agent harness was not installed automatically. Run \`bunx guren agent:init --target ${targetList}\` inside the app after installing dependencies.`);
2068
+ }
2069
+ let authInstalled = false;
2070
+ if (includeAuth) {
2071
+ if (installed) {
2072
+ consola.start("Adding authentication scaffolding...");
2073
+ authInstalled = await runAppCli(targetDir, [
2074
+ "add",
2075
+ "auth",
2076
+ "--force"
2077
+ ]);
2078
+ if (authInstalled) consola.success("Authentication scaffolding added");
2079
+ }
2080
+ if (!authInstalled) consola.warn("Authentication was not scaffolded automatically. Run `bunx guren add auth` inside the app after installing dependencies.");
2081
+ }
2082
+ if (shouldInitGit) reportGitInit(targetDir);
2083
+ const relativeTarget = relative(g$1.cwd(), targetDir) || ".";
2084
+ consola.success(`Scaffolded a new Guren app (${blueprint.name}/${renderingMode.toUpperCase()}/${database}) in ${relativeTarget}`);
2085
+ consola.info("Next steps:");
2086
+ if (relativeTarget !== ".") consola.log(` cd ${relativeTarget}`);
2087
+ if (!installed) consola.log(" bun install");
2088
+ if (usesDatabaseContainer(database)) consola.log(" bun run db:up");
2089
+ consola.log("");
2090
+ consola.info("Add features:");
2091
+ if (!blueprint.includesAuth) consola.log(" bunx guren add auth");
2092
+ consola.log(" bunx guren add resource posts --fields \"title:string,body:text\"");
2093
+ consola.log("");
2094
+ consola.info("Generate types and set up database:");
2095
+ consola.log(" bun run codegen");
2096
+ consola.log(" bun run db:make");
2097
+ consola.log(" bun run db:migrate");
2098
+ consola.log(" bun run db:seed");
2099
+ consola.log("");
2100
+ consola.info("Verify and run:");
2101
+ consola.log(" bun run typecheck");
2102
+ consola.log(" bun run test");
2103
+ consola.log(" bun run dev");
2104
+ if (authInstalled) {
2105
+ consola.log("");
2106
+ consola.info("Auth scaffolding was included automatically.");
2107
+ consola.info("Set up the users table with: bun run db:make && bun run db:migrate && bun run db:seed");
2108
+ }
2109
+ if (renderingMode === "ssr") {
2110
+ consola.log("");
2111
+ consola.info("Production build:");
2112
+ consola.log(" bun run build");
2113
+ consola.log("");
2114
+ consola.info("Optional deploy path:");
2115
+ consola.log(" bunx guren plugin @guren/plugin-vercel");
2116
+ consola.log(" bun add @guren/plugin-vercel");
2117
+ }
2118
+ }
2119
+ })).catch((error) => {
2120
+ if (error instanceof Error) consola.error(error.message);
2121
+ else consola.error(String(error));
2122
+ g$1.exit(1);
2413
2123
  });
2124
+ //#endregion
2125
+ export {};