@itsflower/cli 0.2.1 → 0.2.3

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/bin.js DELETED
@@ -1,1784 +0,0 @@
1
- #!/usr/bin/env node
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
28
- if (canCache)
29
- cache.set(mod, to);
30
- return to;
31
- };
32
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
- var __returnValue = (v) => v;
34
- function __exportSetter(name, newValue) {
35
- this[name] = __returnValue.bind(null, newValue);
36
- }
37
- var __export = (target, all) => {
38
- for (var name in all)
39
- __defProp(target, name, {
40
- get: all[name],
41
- enumerable: true,
42
- configurable: true,
43
- set: __exportSetter.bind(all, name)
44
- });
45
- };
46
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
47
-
48
- // ../../node_modules/.bun/citty@0.2.2/node_modules/citty/dist/_chunks/libs/scule.mjs
49
- function isUppercase(char = "") {
50
- if (NUMBER_CHAR_RE.test(char))
51
- return;
52
- return char !== char.toLowerCase();
53
- }
54
- function splitByCase(str, separators) {
55
- const splitters = separators ?? STR_SPLITTERS;
56
- const parts = [];
57
- if (!str || typeof str !== "string")
58
- return parts;
59
- let buff = "";
60
- let previousUpper;
61
- let previousSplitter;
62
- for (const char of str) {
63
- const isSplitter = splitters.includes(char);
64
- if (isSplitter === true) {
65
- parts.push(buff);
66
- buff = "";
67
- previousUpper = undefined;
68
- continue;
69
- }
70
- const isUpper = isUppercase(char);
71
- if (previousSplitter === false) {
72
- if (previousUpper === false && isUpper === true) {
73
- parts.push(buff);
74
- buff = char;
75
- previousUpper = isUpper;
76
- continue;
77
- }
78
- if (previousUpper === true && isUpper === false && buff.length > 1) {
79
- const lastChar = buff.at(-1);
80
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
81
- buff = lastChar + char;
82
- previousUpper = isUpper;
83
- continue;
84
- }
85
- }
86
- buff += char;
87
- previousUpper = isUpper;
88
- previousSplitter = isSplitter;
89
- }
90
- parts.push(buff);
91
- return parts;
92
- }
93
- function upperFirst(str) {
94
- return str ? str[0].toUpperCase() + str.slice(1) : "";
95
- }
96
- function lowerFirst(str) {
97
- return str ? str[0].toLowerCase() + str.slice(1) : "";
98
- }
99
- function pascalCase(str, opts) {
100
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
101
- }
102
- function camelCase(str, opts) {
103
- return lowerFirst(pascalCase(str || "", opts));
104
- }
105
- function kebabCase(str, joiner) {
106
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
107
- }
108
- function snakeCase(str) {
109
- return kebabCase(str || "", "_");
110
- }
111
- var NUMBER_CHAR_RE, STR_SPLITTERS;
112
- var init_scule = __esm(() => {
113
- NUMBER_CHAR_RE = /\d/;
114
- STR_SPLITTERS = [
115
- "-",
116
- "_",
117
- "/",
118
- "."
119
- ];
120
- });
121
-
122
- // ../../node_modules/.bun/citty@0.2.2/node_modules/citty/dist/index.mjs
123
- import { parseArgs as parseArgs$1 } from "node:util";
124
- function toArray(val) {
125
- if (Array.isArray(val))
126
- return val;
127
- return val === undefined ? [] : [val];
128
- }
129
- function formatLineColumns(lines, linePrefix = "") {
130
- const maxLength = [];
131
- for (const line of lines)
132
- for (const [i, element] of line.entries())
133
- maxLength[i] = Math.max(maxLength[i] || 0, element.length);
134
- return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLength[i])).join(" ")).join(`
135
- `);
136
- }
137
- function resolveValue(input) {
138
- return typeof input === "function" ? input() : input;
139
- }
140
- function parseRawArgs(args = [], opts = {}) {
141
- const booleans = new Set(opts.boolean || []);
142
- const strings = new Set(opts.string || []);
143
- const aliasMap = opts.alias || {};
144
- const defaults = opts.default || {};
145
- const aliasToMain = /* @__PURE__ */ new Map;
146
- const mainToAliases = /* @__PURE__ */ new Map;
147
- for (const [key, value] of Object.entries(aliasMap)) {
148
- const targets = value;
149
- for (const target of targets) {
150
- aliasToMain.set(key, target);
151
- if (!mainToAliases.has(target))
152
- mainToAliases.set(target, []);
153
- mainToAliases.get(target).push(key);
154
- aliasToMain.set(target, key);
155
- if (!mainToAliases.has(key))
156
- mainToAliases.set(key, []);
157
- mainToAliases.get(key).push(target);
158
- }
159
- }
160
- const options = {};
161
- function getType(name) {
162
- if (booleans.has(name))
163
- return "boolean";
164
- const aliases = mainToAliases.get(name) || [];
165
- for (const alias of aliases)
166
- if (booleans.has(alias))
167
- return "boolean";
168
- return "string";
169
- }
170
- function isStringType(name) {
171
- if (strings.has(name))
172
- return true;
173
- const aliases = mainToAliases.get(name) || [];
174
- for (const alias of aliases)
175
- if (strings.has(alias))
176
- return true;
177
- return false;
178
- }
179
- const allOptions = new Set([
180
- ...booleans,
181
- ...strings,
182
- ...Object.keys(aliasMap),
183
- ...Object.values(aliasMap).flat(),
184
- ...Object.keys(defaults)
185
- ]);
186
- for (const name of allOptions)
187
- if (!options[name])
188
- options[name] = {
189
- type: getType(name),
190
- default: defaults[name]
191
- };
192
- for (const [alias, main] of aliasToMain.entries())
193
- if (alias.length === 1 && options[main] && !options[main].short)
194
- options[main].short = alias;
195
- const processedArgs = [];
196
- const negatedFlags = {};
197
- for (let i = 0;i < args.length; i++) {
198
- const arg = args[i];
199
- if (arg === "--") {
200
- processedArgs.push(...args.slice(i));
201
- break;
202
- }
203
- if (arg.startsWith("--no-")) {
204
- const flagName = arg.slice(5);
205
- negatedFlags[flagName] = true;
206
- continue;
207
- }
208
- processedArgs.push(arg);
209
- }
210
- let parsed;
211
- try {
212
- parsed = parseArgs$1({
213
- args: processedArgs,
214
- options: Object.keys(options).length > 0 ? options : undefined,
215
- allowPositionals: true,
216
- strict: false
217
- });
218
- } catch {
219
- parsed = {
220
- values: {},
221
- positionals: processedArgs
222
- };
223
- }
224
- const out = { _: [] };
225
- out._ = parsed.positionals;
226
- for (const [key, value] of Object.entries(parsed.values)) {
227
- let coerced = value;
228
- if (getType(key) === "boolean" && typeof value === "string")
229
- coerced = value !== "false";
230
- else if (isStringType(key) && typeof value === "boolean")
231
- coerced = "";
232
- out[key] = coerced;
233
- }
234
- for (const [name] of Object.entries(negatedFlags)) {
235
- out[name] = false;
236
- const mainName = aliasToMain.get(name);
237
- if (mainName)
238
- out[mainName] = false;
239
- const aliases = mainToAliases.get(name);
240
- if (aliases)
241
- for (const alias of aliases)
242
- out[alias] = false;
243
- }
244
- for (const [alias, main] of aliasToMain.entries()) {
245
- if (out[alias] !== undefined && out[main] === undefined)
246
- out[main] = out[alias];
247
- if (out[main] !== undefined && out[alias] === undefined)
248
- out[alias] = out[main];
249
- if (out[alias] !== out[main] && defaults[main] === out[main])
250
- out[main] = out[alias];
251
- }
252
- return out;
253
- }
254
- function parseArgs(rawArgs, argsDef) {
255
- const parseOptions = {
256
- boolean: [],
257
- string: [],
258
- alias: {},
259
- default: {}
260
- };
261
- const args = resolveArgs(argsDef);
262
- for (const arg of args) {
263
- if (arg.type === "positional")
264
- continue;
265
- if (arg.type === "string" || arg.type === "enum")
266
- parseOptions.string.push(arg.name);
267
- else if (arg.type === "boolean")
268
- parseOptions.boolean.push(arg.name);
269
- if (arg.default !== undefined)
270
- parseOptions.default[arg.name] = arg.default;
271
- if (arg.alias)
272
- parseOptions.alias[arg.name] = arg.alias;
273
- const camelName = camelCase(arg.name);
274
- const kebabName = kebabCase(arg.name);
275
- if (camelName !== arg.name || kebabName !== arg.name) {
276
- const existingAliases = toArray(parseOptions.alias[arg.name] || []);
277
- if (camelName !== arg.name && !existingAliases.includes(camelName))
278
- existingAliases.push(camelName);
279
- if (kebabName !== arg.name && !existingAliases.includes(kebabName))
280
- existingAliases.push(kebabName);
281
- if (existingAliases.length > 0)
282
- parseOptions.alias[arg.name] = existingAliases;
283
- }
284
- }
285
- const parsed = parseRawArgs(rawArgs, parseOptions);
286
- const [...positionalArguments] = parsed._;
287
- const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
288
- return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
289
- } });
290
- for (const [, arg] of args.entries())
291
- if (arg.type === "positional") {
292
- const nextPositionalArgument = positionalArguments.shift();
293
- if (nextPositionalArgument !== undefined)
294
- parsedArgsProxy[arg.name] = nextPositionalArgument;
295
- else if (arg.default === undefined && arg.required !== false)
296
- throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
297
- else
298
- parsedArgsProxy[arg.name] = arg.default;
299
- } else if (arg.type === "enum") {
300
- const argument = parsedArgsProxy[arg.name];
301
- const options = arg.options || [];
302
- if (argument !== undefined && options.length > 0 && !options.includes(argument))
303
- throw new CLIError(`Invalid value for argument: ${cyan(`--${arg.name}`)} (${cyan(argument)}). Expected one of: ${options.map((o) => cyan(o)).join(", ")}.`, "EARG");
304
- } else if (arg.required && parsedArgsProxy[arg.name] === undefined)
305
- throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
306
- return parsedArgsProxy;
307
- }
308
- function resolveArgs(argsDef) {
309
- const args = [];
310
- for (const [name, argDef] of Object.entries(argsDef || {}))
311
- args.push({
312
- ...argDef,
313
- name,
314
- alias: toArray(argDef.alias)
315
- });
316
- return args;
317
- }
318
- async function resolvePlugins(plugins) {
319
- return Promise.all(plugins.map((p) => resolveValue(p)));
320
- }
321
- function defineCommand(def) {
322
- return def;
323
- }
324
- async function runCommand(cmd, opts) {
325
- const cmdArgs = await resolveValue(cmd.args || {});
326
- const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
327
- const context = {
328
- rawArgs: opts.rawArgs,
329
- args: parsedArgs,
330
- data: opts.data,
331
- cmd
332
- };
333
- const plugins = await resolvePlugins(cmd.plugins ?? []);
334
- let result;
335
- let runError;
336
- try {
337
- for (const plugin of plugins)
338
- await plugin.setup?.(context);
339
- if (typeof cmd.setup === "function")
340
- await cmd.setup(context);
341
- const subCommands = await resolveValue(cmd.subCommands);
342
- if (subCommands && Object.keys(subCommands).length > 0) {
343
- const subCommandArgIndex = findSubCommandIndex(opts.rawArgs, cmdArgs);
344
- const explicitName = opts.rawArgs[subCommandArgIndex];
345
- if (explicitName) {
346
- const subCommand = await _findSubCommand(subCommands, explicitName);
347
- if (!subCommand)
348
- throw new CLIError(`Unknown command ${cyan(explicitName)}`, "E_UNKNOWN_COMMAND");
349
- await runCommand(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
350
- } else {
351
- const defaultSubCommand = await resolveValue(cmd.default);
352
- if (defaultSubCommand) {
353
- if (cmd.run)
354
- throw new CLIError(`Cannot specify both 'run' and 'default' on the same command.`, "E_DEFAULT_CONFLICT");
355
- const subCommand = await _findSubCommand(subCommands, defaultSubCommand);
356
- if (!subCommand)
357
- throw new CLIError(`Default sub command ${cyan(defaultSubCommand)} not found in subCommands.`, "E_UNKNOWN_COMMAND");
358
- await runCommand(subCommand, { rawArgs: opts.rawArgs });
359
- } else if (!cmd.run)
360
- throw new CLIError(`No command specified.`, "E_NO_COMMAND");
361
- }
362
- }
363
- if (typeof cmd.run === "function")
364
- result = await cmd.run(context);
365
- } catch (error) {
366
- runError = error;
367
- }
368
- const cleanupErrors = [];
369
- if (typeof cmd.cleanup === "function")
370
- try {
371
- await cmd.cleanup(context);
372
- } catch (error) {
373
- cleanupErrors.push(error);
374
- }
375
- for (const plugin of [...plugins].reverse())
376
- try {
377
- await plugin.cleanup?.(context);
378
- } catch (error) {
379
- cleanupErrors.push(error);
380
- }
381
- if (runError)
382
- throw runError;
383
- if (cleanupErrors.length === 1)
384
- throw cleanupErrors[0];
385
- if (cleanupErrors.length > 1)
386
- throw new Error("Multiple cleanup errors", { cause: cleanupErrors });
387
- return { result };
388
- }
389
- async function resolveSubCommand(cmd, rawArgs, parent) {
390
- const subCommands = await resolveValue(cmd.subCommands);
391
- if (subCommands && Object.keys(subCommands).length > 0) {
392
- const subCommandArgIndex = findSubCommandIndex(rawArgs, await resolveValue(cmd.args || {}));
393
- const subCommandName = rawArgs[subCommandArgIndex];
394
- const subCommand = await _findSubCommand(subCommands, subCommandName);
395
- if (subCommand)
396
- return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
397
- }
398
- return [cmd, parent];
399
- }
400
- async function _findSubCommand(subCommands, name) {
401
- if (name in subCommands)
402
- return resolveValue(subCommands[name]);
403
- for (const sub of Object.values(subCommands)) {
404
- const resolved = await resolveValue(sub);
405
- const meta = await resolveValue(resolved?.meta);
406
- if (meta?.alias) {
407
- if (toArray(meta.alias).includes(name))
408
- return resolved;
409
- }
410
- }
411
- }
412
- function findSubCommandIndex(rawArgs, argsDef) {
413
- for (let i = 0;i < rawArgs.length; i++) {
414
- const arg = rawArgs[i];
415
- if (arg === "--")
416
- return -1;
417
- if (arg.startsWith("-")) {
418
- if (!arg.includes("=") && _isValueFlag(arg, argsDef))
419
- i++;
420
- continue;
421
- }
422
- return i;
423
- }
424
- return -1;
425
- }
426
- function _isValueFlag(flag, argsDef) {
427
- const name = flag.replace(/^-{1,2}/, "");
428
- const normalized = camelCase(name);
429
- for (const [key, def] of Object.entries(argsDef)) {
430
- if (def.type !== "string" && def.type !== "enum")
431
- continue;
432
- if (normalized === camelCase(key))
433
- return true;
434
- if ((Array.isArray(def.alias) ? def.alias : def.alias ? [def.alias] : []).includes(name))
435
- return true;
436
- }
437
- return false;
438
- }
439
- async function showUsage(cmd, parent) {
440
- try {
441
- console.log(await renderUsage(cmd, parent) + `
442
- `);
443
- } catch (error) {
444
- console.error(error);
445
- }
446
- }
447
- async function renderUsage(cmd, parent) {
448
- const cmdMeta = await resolveValue(cmd.meta || {});
449
- const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
450
- const parentMeta = await resolveValue(parent?.meta || {});
451
- const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
452
- const argLines = [];
453
- const posLines = [];
454
- const commandsLines = [];
455
- const usageLine = [];
456
- for (const arg of cmdArgs)
457
- if (arg.type === "positional") {
458
- const name = arg.name.toUpperCase();
459
- const isRequired = arg.required !== false && arg.default === undefined;
460
- posLines.push([cyan(name + renderValueHint(arg)), renderDescription(arg, isRequired)]);
461
- usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
462
- } else {
463
- const isRequired = arg.required === true && arg.default === undefined;
464
- const argStr = [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ") + renderValueHint(arg);
465
- argLines.push([cyan(argStr), renderDescription(arg, isRequired)]);
466
- if (arg.type === "boolean" && (arg.default === true || arg.negativeDescription) && !negativePrefixRe.test(arg.name)) {
467
- const negativeArgStr = [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ");
468
- argLines.push([cyan(negativeArgStr), [arg.negativeDescription, isRequired ? gray("(Required)") : ""].filter(Boolean).join(" ")]);
469
- }
470
- if (isRequired)
471
- usageLine.push(`--${arg.name}` + renderValueHint(arg));
472
- }
473
- if (cmd.subCommands) {
474
- const commandNames = [];
475
- const subCommands = await resolveValue(cmd.subCommands);
476
- for (const [name, sub] of Object.entries(subCommands)) {
477
- const meta = await resolveValue((await resolveValue(sub))?.meta);
478
- if (meta?.hidden)
479
- continue;
480
- const aliases = toArray(meta?.alias);
481
- const label = [name, ...aliases].join(", ");
482
- commandsLines.push([cyan(label), meta?.description || ""]);
483
- commandNames.push(name, ...aliases);
484
- }
485
- usageLine.push(commandNames.join("|"));
486
- }
487
- const usageLines = [];
488
- const version = cmdMeta.version || parentMeta.version;
489
- usageLines.push(gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
490
- const hasOptions = argLines.length > 0 || posLines.length > 0;
491
- usageLines.push(`${underline(bold("USAGE"))} ${cyan(`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}`)}`, "");
492
- if (posLines.length > 0) {
493
- usageLines.push(underline(bold("ARGUMENTS")), "");
494
- usageLines.push(formatLineColumns(posLines, " "));
495
- usageLines.push("");
496
- }
497
- if (argLines.length > 0) {
498
- usageLines.push(underline(bold("OPTIONS")), "");
499
- usageLines.push(formatLineColumns(argLines, " "));
500
- usageLines.push("");
501
- }
502
- if (commandsLines.length > 0) {
503
- usageLines.push(underline(bold("COMMANDS")), "");
504
- usageLines.push(formatLineColumns(commandsLines, " "));
505
- usageLines.push("", `Use ${cyan(`${commandName} <command> --help`)} for more information about a command.`);
506
- }
507
- return usageLines.filter((l) => typeof l === "string").join(`
508
- `);
509
- }
510
- function renderValueHint(arg) {
511
- const valueHint = arg.valueHint ? `=<${arg.valueHint}>` : "";
512
- const fallbackValueHint = valueHint || `=<${snakeCase(arg.name)}>`;
513
- if (!arg.type || arg.type === "positional" || arg.type === "boolean")
514
- return valueHint;
515
- if (arg.type === "enum" && arg.options?.length)
516
- return `=<${arg.options.join("|")}>`;
517
- return fallbackValueHint;
518
- }
519
- function renderDescription(arg, required) {
520
- const requiredHint = required ? gray("(Required)") : "";
521
- const defaultHint = arg.default === undefined ? "" : gray(`(Default: ${arg.default})`);
522
- return [
523
- arg.description,
524
- requiredHint,
525
- defaultHint
526
- ].filter(Boolean).join(" ");
527
- }
528
- async function runMain(cmd, opts = {}) {
529
- const rawArgs = opts.rawArgs || process.argv.slice(2);
530
- const showUsage$1 = opts.showUsage || showUsage;
531
- try {
532
- const builtinFlags = await _resolveBuiltinFlags(cmd);
533
- if (builtinFlags.help.length > 0 && rawArgs.some((arg) => builtinFlags.help.includes(arg))) {
534
- await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
535
- process.exit(0);
536
- } else if (rawArgs.length === 1 && builtinFlags.version.includes(rawArgs[0])) {
537
- const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
538
- if (!meta?.version)
539
- throw new CLIError("No version specified", "E_NO_VERSION");
540
- console.log(meta.version);
541
- } else
542
- await runCommand(cmd, { rawArgs });
543
- } catch (error) {
544
- if (error instanceof CLIError) {
545
- await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
546
- console.error(error.message);
547
- } else
548
- console.error(error, `
549
- `);
550
- process.exit(1);
551
- }
552
- }
553
- async function _resolveBuiltinFlags(cmd) {
554
- const argsDef = await resolveValue(cmd.args || {});
555
- const userNames = /* @__PURE__ */ new Set;
556
- const userAliases = /* @__PURE__ */ new Set;
557
- for (const [name, def] of Object.entries(argsDef)) {
558
- userNames.add(name);
559
- for (const alias of toArray(def.alias))
560
- userAliases.add(alias);
561
- }
562
- return {
563
- help: _getBuiltinFlags("help", "h", userNames, userAliases),
564
- version: _getBuiltinFlags("version", "v", userNames, userAliases)
565
- };
566
- }
567
- function _getBuiltinFlags(long, short, userNames, userAliases) {
568
- if (userNames.has(long) || userAliases.has(long))
569
- return [];
570
- if (userNames.has(short) || userAliases.has(short))
571
- return [`--${long}`];
572
- return [`--${long}`, `-${short}`];
573
- }
574
- var CLIError, noColor, _c = (c, r = 39) => (t) => noColor ? t : `\x1B[${c}m${t}\x1B[${r}m`, bold, cyan, gray, underline, negativePrefixRe;
575
- var init_dist = __esm(() => {
576
- init_scule();
577
- CLIError = class extends Error {
578
- code;
579
- constructor(message, code) {
580
- super(message);
581
- this.name = "CLIError";
582
- this.code = code;
583
- }
584
- };
585
- noColor = /* @__PURE__ */ (() => {
586
- const env = globalThis.process?.env ?? {};
587
- return env.NO_COLOR === "1" || env.TERM === "dumb" || env.TEST || env.CI;
588
- })();
589
- bold = /* @__PURE__ */ _c(1, 22);
590
- cyan = /* @__PURE__ */ _c(36);
591
- gray = /* @__PURE__ */ _c(90);
592
- underline = /* @__PURE__ */ _c(4, 24);
593
- negativePrefixRe = /^no[-A-Z]/;
594
- });
595
-
596
- // ../../node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/utils.js
597
- var isAmbiguous = (x) => {
598
- 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;
599
- }, isFullWidth = (x) => {
600
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
601
- }, isWide = (x) => {
602
- 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 >= 9800 && x <= 9811 || x === 9855 || 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 <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && 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 >= 101632 && 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 === 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 <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
603
- };
604
- var init_utils = () => {};
605
-
606
- // ../../node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/index.js
607
- var ANSI_RE, CONTROL_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
608
- const LIMIT = truncationOptions.limit ?? Infinity;
609
- const ELLIPSIS = truncationOptions.ellipsis ?? "";
610
- const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
611
- const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
612
- const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
613
- const TAB_WIDTH = widthOptions.tabWidth ?? 8;
614
- const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
615
- const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
616
- const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
617
- const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
618
- const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
619
- let indexPrev = 0;
620
- let index = 0;
621
- let length = input.length;
622
- let lengthExtra = 0;
623
- let truncationEnabled = false;
624
- let truncationIndex = length;
625
- let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
626
- let unmatchedStart = 0;
627
- let unmatchedEnd = 0;
628
- let width = 0;
629
- let widthExtra = 0;
630
- outer:
631
- while (true) {
632
- if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
633
- const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
634
- lengthExtra = 0;
635
- for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
636
- const codePoint = char.codePointAt(0) || 0;
637
- if (isFullWidth(codePoint)) {
638
- widthExtra = FULL_WIDTH_WIDTH;
639
- } else if (isWide(codePoint)) {
640
- widthExtra = WIDE_WIDTH;
641
- } else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
642
- widthExtra = AMBIGUOUS_WIDTH;
643
- } else {
644
- widthExtra = REGULAR_WIDTH;
645
- }
646
- if (width + widthExtra > truncationLimit) {
647
- truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
648
- }
649
- if (width + widthExtra > LIMIT) {
650
- truncationEnabled = true;
651
- break outer;
652
- }
653
- lengthExtra += char.length;
654
- width += widthExtra;
655
- }
656
- unmatchedStart = unmatchedEnd = 0;
657
- }
658
- if (index >= length)
659
- break;
660
- LATIN_RE.lastIndex = index;
661
- if (LATIN_RE.test(input)) {
662
- lengthExtra = LATIN_RE.lastIndex - index;
663
- widthExtra = lengthExtra * REGULAR_WIDTH;
664
- if (width + widthExtra > truncationLimit) {
665
- truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
666
- }
667
- if (width + widthExtra > LIMIT) {
668
- truncationEnabled = true;
669
- break;
670
- }
671
- width += widthExtra;
672
- unmatchedStart = indexPrev;
673
- unmatchedEnd = index;
674
- index = indexPrev = LATIN_RE.lastIndex;
675
- continue;
676
- }
677
- ANSI_RE.lastIndex = index;
678
- if (ANSI_RE.test(input)) {
679
- if (width + ANSI_WIDTH > truncationLimit) {
680
- truncationIndex = Math.min(truncationIndex, index);
681
- }
682
- if (width + ANSI_WIDTH > LIMIT) {
683
- truncationEnabled = true;
684
- break;
685
- }
686
- width += ANSI_WIDTH;
687
- unmatchedStart = indexPrev;
688
- unmatchedEnd = index;
689
- index = indexPrev = ANSI_RE.lastIndex;
690
- continue;
691
- }
692
- CONTROL_RE.lastIndex = index;
693
- if (CONTROL_RE.test(input)) {
694
- lengthExtra = CONTROL_RE.lastIndex - index;
695
- widthExtra = lengthExtra * CONTROL_WIDTH;
696
- if (width + widthExtra > truncationLimit) {
697
- truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
698
- }
699
- if (width + widthExtra > LIMIT) {
700
- truncationEnabled = true;
701
- break;
702
- }
703
- width += widthExtra;
704
- unmatchedStart = indexPrev;
705
- unmatchedEnd = index;
706
- index = indexPrev = CONTROL_RE.lastIndex;
707
- continue;
708
- }
709
- TAB_RE.lastIndex = index;
710
- if (TAB_RE.test(input)) {
711
- lengthExtra = TAB_RE.lastIndex - index;
712
- widthExtra = lengthExtra * TAB_WIDTH;
713
- if (width + widthExtra > truncationLimit) {
714
- truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
715
- }
716
- if (width + widthExtra > LIMIT) {
717
- truncationEnabled = true;
718
- break;
719
- }
720
- width += widthExtra;
721
- unmatchedStart = indexPrev;
722
- unmatchedEnd = index;
723
- index = indexPrev = TAB_RE.lastIndex;
724
- continue;
725
- }
726
- EMOJI_RE.lastIndex = index;
727
- if (EMOJI_RE.test(input)) {
728
- if (width + EMOJI_WIDTH > truncationLimit) {
729
- truncationIndex = Math.min(truncationIndex, index);
730
- }
731
- if (width + EMOJI_WIDTH > LIMIT) {
732
- truncationEnabled = true;
733
- break;
734
- }
735
- width += EMOJI_WIDTH;
736
- unmatchedStart = indexPrev;
737
- unmatchedEnd = index;
738
- index = indexPrev = EMOJI_RE.lastIndex;
739
- continue;
740
- }
741
- index += 1;
742
- }
743
- return {
744
- width: truncationEnabled ? truncationLimit : width,
745
- index: truncationEnabled ? truncationIndex : length,
746
- truncated: truncationEnabled,
747
- ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
748
- };
749
- }, dist_default;
750
- var init_dist2 = __esm(() => {
751
- init_utils();
752
- ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
753
- CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
754
- TAB_RE = /\t{1,1000}/y;
755
- EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
756
- LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
757
- MODIFIER_RE = /\p{M}+/gu;
758
- NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
759
- dist_default = getStringTruncatedWidth;
760
- });
761
-
762
- // ../../node_modules/.bun/fast-string-width@1.1.0/node_modules/fast-string-width/dist/index.js
763
- var NO_TRUNCATION2, fastStringWidth = (input, options = {}) => {
764
- return dist_default(input, NO_TRUNCATION2, options).width;
765
- }, dist_default2;
766
- var init_dist3 = __esm(() => {
767
- init_dist2();
768
- NO_TRUNCATION2 = {
769
- limit: Infinity,
770
- ellipsis: "",
771
- ellipsisWidth: 0
772
- };
773
- dist_default2 = fastStringWidth;
774
- });
775
-
776
- // ../../node_modules/.bun/fast-wrap-ansi@0.1.6/node_modules/fast-wrap-ansi/lib/main.js
777
- function wrapAnsi(string, columns, options) {
778
- return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
779
- `);
780
- }
781
- var ESC = "\x1B", CSI = "›", END_CODE = 39, ANSI_ESCAPE_BELL = "\x07", ANSI_CSI = "[", ANSI_OSC = "]", ANSI_SGR_TERMINATOR = "m", ANSI_ESCAPE_LINK, GROUP_REGEX, getClosingCode = (openingCode) => {
782
- if (openingCode >= 30 && openingCode <= 37)
783
- return 39;
784
- if (openingCode >= 90 && openingCode <= 97)
785
- return 39;
786
- if (openingCode >= 40 && openingCode <= 47)
787
- return 49;
788
- if (openingCode >= 100 && openingCode <= 107)
789
- return 49;
790
- if (openingCode === 1 || openingCode === 2)
791
- return 22;
792
- if (openingCode === 3)
793
- return 23;
794
- if (openingCode === 4)
795
- return 24;
796
- if (openingCode === 7)
797
- return 27;
798
- if (openingCode === 8)
799
- return 28;
800
- if (openingCode === 9)
801
- return 29;
802
- if (openingCode === 0)
803
- return 0;
804
- return;
805
- }, wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`, wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`, wrapWord = (rows, word, columns) => {
806
- const characters = word[Symbol.iterator]();
807
- let isInsideEscape = false;
808
- let isInsideLinkEscape = false;
809
- let lastRow = rows.at(-1);
810
- let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
811
- let currentCharacter = characters.next();
812
- let nextCharacter = characters.next();
813
- let rawCharacterIndex = 0;
814
- while (!currentCharacter.done) {
815
- const character = currentCharacter.value;
816
- const characterLength = dist_default2(character);
817
- if (visible + characterLength <= columns) {
818
- rows[rows.length - 1] += character;
819
- } else {
820
- rows.push(character);
821
- visible = 0;
822
- }
823
- if (character === ESC || character === CSI) {
824
- isInsideEscape = true;
825
- isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
826
- }
827
- if (isInsideEscape) {
828
- if (isInsideLinkEscape) {
829
- if (character === ANSI_ESCAPE_BELL) {
830
- isInsideEscape = false;
831
- isInsideLinkEscape = false;
832
- }
833
- } else if (character === ANSI_SGR_TERMINATOR) {
834
- isInsideEscape = false;
835
- }
836
- } else {
837
- visible += characterLength;
838
- if (visible === columns && !nextCharacter.done) {
839
- rows.push("");
840
- visible = 0;
841
- }
842
- }
843
- currentCharacter = nextCharacter;
844
- nextCharacter = characters.next();
845
- rawCharacterIndex += character.length;
846
- }
847
- lastRow = rows.at(-1);
848
- if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
849
- rows[rows.length - 2] += rows.pop();
850
- }
851
- }, stringVisibleTrimSpacesRight = (string) => {
852
- const words = string.split(" ");
853
- let last = words.length;
854
- while (last) {
855
- if (dist_default2(words[last - 1])) {
856
- break;
857
- }
858
- last--;
859
- }
860
- if (last === words.length) {
861
- return string;
862
- }
863
- return words.slice(0, last).join(" ") + words.slice(last).join("");
864
- }, exec = (string, columns, options = {}) => {
865
- if (options.trim !== false && string.trim() === "") {
866
- return "";
867
- }
868
- let returnValue = "";
869
- let escapeCode;
870
- let escapeUrl;
871
- const words = string.split(" ");
872
- let rows = [""];
873
- let rowLength = 0;
874
- for (let index = 0;index < words.length; index++) {
875
- const word = words[index];
876
- if (options.trim !== false) {
877
- const row = rows.at(-1) ?? "";
878
- const trimmed = row.trimStart();
879
- if (row.length !== trimmed.length) {
880
- rows[rows.length - 1] = trimmed;
881
- rowLength = dist_default2(trimmed);
882
- }
883
- }
884
- if (index !== 0) {
885
- if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
886
- rows.push("");
887
- rowLength = 0;
888
- }
889
- if (rowLength || options.trim === false) {
890
- rows[rows.length - 1] += " ";
891
- rowLength++;
892
- }
893
- }
894
- const wordLength = dist_default2(word);
895
- if (options.hard && wordLength > columns) {
896
- const remainingColumns = columns - rowLength;
897
- const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
898
- const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
899
- if (breaksStartingNextLine < breaksStartingThisLine) {
900
- rows.push("");
901
- }
902
- wrapWord(rows, word, columns);
903
- rowLength = dist_default2(rows.at(-1) ?? "");
904
- continue;
905
- }
906
- if (rowLength + wordLength > columns && rowLength && wordLength) {
907
- if (options.wordWrap === false && rowLength < columns) {
908
- wrapWord(rows, word, columns);
909
- rowLength = dist_default2(rows.at(-1) ?? "");
910
- continue;
911
- }
912
- rows.push("");
913
- rowLength = 0;
914
- }
915
- if (rowLength + wordLength > columns && options.wordWrap === false) {
916
- wrapWord(rows, word, columns);
917
- rowLength = dist_default2(rows.at(-1) ?? "");
918
- continue;
919
- }
920
- rows[rows.length - 1] += word;
921
- rowLength += wordLength;
922
- }
923
- if (options.trim !== false) {
924
- rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
925
- }
926
- const preString = rows.join(`
927
- `);
928
- let inSurrogate = false;
929
- for (let i = 0;i < preString.length; i++) {
930
- const character = preString[i];
931
- returnValue += character;
932
- if (!inSurrogate) {
933
- inSurrogate = character >= "\uD800" && character <= "\uDBFF";
934
- } else {
935
- continue;
936
- }
937
- if (character === ESC || character === CSI) {
938
- GROUP_REGEX.lastIndex = i + 1;
939
- const groupsResult = GROUP_REGEX.exec(preString);
940
- const groups = groupsResult?.groups;
941
- if (groups?.code !== undefined) {
942
- const code = Number.parseFloat(groups.code);
943
- escapeCode = code === END_CODE ? undefined : code;
944
- } else if (groups?.uri !== undefined) {
945
- escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
946
- }
947
- }
948
- if (preString[i + 1] === `
949
- `) {
950
- if (escapeUrl) {
951
- returnValue += wrapAnsiHyperlink("");
952
- }
953
- const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
954
- if (escapeCode && closingCode) {
955
- returnValue += wrapAnsiCode(closingCode);
956
- }
957
- } else if (character === `
958
- `) {
959
- if (escapeCode && getClosingCode(escapeCode)) {
960
- returnValue += wrapAnsiCode(escapeCode);
961
- }
962
- if (escapeUrl) {
963
- returnValue += wrapAnsiHyperlink(escapeUrl);
964
- }
965
- }
966
- }
967
- return returnValue;
968
- }, CRLF_OR_LF;
969
- var init_main = __esm(() => {
970
- init_dist3();
971
- ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
972
- GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
973
- CRLF_OR_LF = /\r?\n/;
974
- });
975
-
976
- // ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
977
- var require_src = __commonJS((exports, module) => {
978
- var ESC2 = "\x1B";
979
- var CSI2 = `${ESC2}[`;
980
- var beep = "\x07";
981
- var cursor = {
982
- to(x, y) {
983
- if (!y)
984
- return `${CSI2}${x + 1}G`;
985
- return `${CSI2}${y + 1};${x + 1}H`;
986
- },
987
- move(x, y) {
988
- let ret = "";
989
- if (x < 0)
990
- ret += `${CSI2}${-x}D`;
991
- else if (x > 0)
992
- ret += `${CSI2}${x}C`;
993
- if (y < 0)
994
- ret += `${CSI2}${-y}A`;
995
- else if (y > 0)
996
- ret += `${CSI2}${y}B`;
997
- return ret;
998
- },
999
- up: (count = 1) => `${CSI2}${count}A`,
1000
- down: (count = 1) => `${CSI2}${count}B`,
1001
- forward: (count = 1) => `${CSI2}${count}C`,
1002
- backward: (count = 1) => `${CSI2}${count}D`,
1003
- nextLine: (count = 1) => `${CSI2}E`.repeat(count),
1004
- prevLine: (count = 1) => `${CSI2}F`.repeat(count),
1005
- left: `${CSI2}G`,
1006
- hide: `${CSI2}?25l`,
1007
- show: `${CSI2}?25h`,
1008
- save: `${ESC2}7`,
1009
- restore: `${ESC2}8`
1010
- };
1011
- var scroll = {
1012
- up: (count = 1) => `${CSI2}S`.repeat(count),
1013
- down: (count = 1) => `${CSI2}T`.repeat(count)
1014
- };
1015
- var erase = {
1016
- screen: `${CSI2}2J`,
1017
- up: (count = 1) => `${CSI2}1J`.repeat(count),
1018
- down: (count = 1) => `${CSI2}J`.repeat(count),
1019
- line: `${CSI2}2K`,
1020
- lineEnd: `${CSI2}K`,
1021
- lineStart: `${CSI2}1K`,
1022
- lines(count) {
1023
- let clear = "";
1024
- for (let i = 0;i < count; i++)
1025
- clear += this.line + (i < count - 1 ? cursor.up() : "");
1026
- if (count)
1027
- clear += cursor.left;
1028
- return clear;
1029
- }
1030
- };
1031
- module.exports = { cursor, scroll, erase, beep };
1032
- });
1033
-
1034
- // ../../node_modules/.bun/@clack+core@1.2.0/node_modules/@clack/core/dist/index.mjs
1035
- import { styleText as y } from "node:util";
1036
- import { stdout as S, stdin as $ } from "node:process";
1037
- import P from "node:readline";
1038
- function d(r, t, e) {
1039
- if (!e.some((o) => !o.disabled))
1040
- return r;
1041
- const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
1042
- return e[n].disabled ? d(n, t < 0 ? -1 : 1, e) : n;
1043
- }
1044
- function V(r, t) {
1045
- if (typeof r == "string")
1046
- return u.aliases.get(r) === t;
1047
- for (const e of r)
1048
- if (e !== undefined && V(e, t))
1049
- return true;
1050
- return false;
1051
- }
1052
- function j(r, t) {
1053
- if (r === t)
1054
- return;
1055
- const e = r.split(`
1056
- `), s = t.split(`
1057
- `), i = Math.max(e.length, s.length), n = [];
1058
- for (let o = 0;o < i; o++)
1059
- e[o] !== s[o] && n.push(o);
1060
- return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
1061
- }
1062
- function q(r) {
1063
- return r === C;
1064
- }
1065
- function w(r, t) {
1066
- const e = r;
1067
- e.isTTY && e.setRawMode(t);
1068
- }
1069
- function W(r, t) {
1070
- if (r === undefined || t.length === 0)
1071
- return 0;
1072
- const e = t.findIndex((s) => s.value === r);
1073
- return e !== -1 ? e : 0;
1074
- }
1075
- function B(r, t) {
1076
- return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
1077
- }
1078
- function J(r, t) {
1079
- if (t)
1080
- return r ? t : t[0];
1081
- }
1082
- function L(r) {
1083
- return [...r].map((t) => X[t]);
1084
- }
1085
- function Z(r) {
1086
- const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
1087
- let s = "/";
1088
- for (const i of t)
1089
- i.type === "literal" ? s = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && e.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
1090
- return { segments: e, separator: s };
1091
- }
1092
- function k(r) {
1093
- return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
1094
- }
1095
- function I(r) {
1096
- return { year: k(r.year), month: k(r.month), day: k(r.day) };
1097
- }
1098
- function T(r, t) {
1099
- return new Date(r || 2001, t || 1, 0).getDate();
1100
- }
1101
- function F(r) {
1102
- const { year: t, month: e, day: s } = I(r);
1103
- if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
1104
- return;
1105
- const i = new Date(Date.UTC(t, e - 1, s));
1106
- if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s))
1107
- return { year: t, month: e, day: s };
1108
- }
1109
- function N(r) {
1110
- const t = F(r);
1111
- return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
1112
- }
1113
- function tt(r, t, e, s) {
1114
- const i = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null, n = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null;
1115
- return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : T(t.year, t.month) };
1116
- }
1117
- var import_sisteransi, E, G, u, Y, C, A = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20, p = class {
1118
- input;
1119
- output;
1120
- _abortSignal;
1121
- rl;
1122
- opts;
1123
- _render;
1124
- _track = false;
1125
- _prevFrame = "";
1126
- _subscribers = new Map;
1127
- _cursor = 0;
1128
- state = "initial";
1129
- error = "";
1130
- value;
1131
- userInput = "";
1132
- constructor(t, e = true) {
1133
- const { input: s = $, output: i = S, render: n, signal: o, ...a } = t;
1134
- this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = e, this._abortSignal = o, this.input = s, this.output = i;
1135
- }
1136
- unsubscribe() {
1137
- this._subscribers.clear();
1138
- }
1139
- setSubscriber(t, e) {
1140
- const s = this._subscribers.get(t) ?? [];
1141
- s.push(e), this._subscribers.set(t, s);
1142
- }
1143
- on(t, e) {
1144
- this.setSubscriber(t, { cb: e });
1145
- }
1146
- once(t, e) {
1147
- this.setSubscriber(t, { cb: e, once: true });
1148
- }
1149
- emit(t, ...e) {
1150
- const s = this._subscribers.get(t) ?? [], i = [];
1151
- for (const n of s)
1152
- n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
1153
- for (const n of i)
1154
- n();
1155
- }
1156
- prompt() {
1157
- return new Promise((t) => {
1158
- if (this._abortSignal) {
1159
- if (this._abortSignal.aborted)
1160
- return this.state = "cancel", this.close(), t(C);
1161
- this._abortSignal.addEventListener("abort", () => {
1162
- this.state = "cancel", this.close();
1163
- }, { once: true });
1164
- }
1165
- this.rl = P.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
1166
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
1167
- }), this.once("cancel", () => {
1168
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(C);
1169
- });
1170
- });
1171
- }
1172
- _isActionKey(t, e) {
1173
- return t === "\t";
1174
- }
1175
- _setValue(t) {
1176
- this.value = t, this.emit("value", this.value);
1177
- }
1178
- _setUserInput(t, e) {
1179
- this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
1180
- }
1181
- _clearUserInput() {
1182
- this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
1183
- }
1184
- onKeypress(t, e) {
1185
- if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
1186
- if (this.opts.validate) {
1187
- const s = this.opts.validate(this.value);
1188
- s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
1189
- }
1190
- this.state !== "error" && (this.state = "submit");
1191
- }
1192
- V([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
1193
- }
1194
- close() {
1195
- this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
1196
- `), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
1197
- }
1198
- restoreCursor() {
1199
- const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
1200
- `).length - 1;
1201
- this.output.write(import_sisteransi.cursor.move(-999, t * -1));
1202
- }
1203
- render() {
1204
- const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
1205
- if (t !== this._prevFrame) {
1206
- if (this.state === "initial")
1207
- this.output.write(import_sisteransi.cursor.hide);
1208
- else {
1209
- const e = j(this._prevFrame, t), s = A(this.output);
1210
- if (this.restoreCursor(), e) {
1211
- const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
1212
- let o = e.lines.find((a) => a >= i);
1213
- if (o === undefined) {
1214
- this._prevFrame = t;
1215
- return;
1216
- }
1217
- if (e.lines.length === 1) {
1218
- this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
1219
- const a = t.split(`
1220
- `);
1221
- this.output.write(a[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
1222
- return;
1223
- } else if (e.lines.length > 1) {
1224
- if (i < n)
1225
- o = i;
1226
- else {
1227
- const h = o - n;
1228
- h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
1229
- }
1230
- this.output.write(import_sisteransi.erase.down());
1231
- const a = t.split(`
1232
- `).slice(o);
1233
- this.output.write(a.join(`
1234
- `)), this._prevFrame = t;
1235
- return;
1236
- }
1237
- }
1238
- this.output.write(import_sisteransi.erase.down());
1239
- }
1240
- this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
1241
- }
1242
- }
1243
- }, H, X, et, st, at;
1244
- var init_dist4 = __esm(() => {
1245
- init_main();
1246
- import_sisteransi = __toESM(require_src(), 1);
1247
- E = ["up", "down", "left", "right", "space", "enter", "cancel"];
1248
- G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
1249
- u = { actions: new Set(E), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...G], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
1250
- Y = globalThis.process.platform.startsWith("win");
1251
- C = Symbol("clack:cancel");
1252
- H = class extends p {
1253
- filteredOptions;
1254
- multiple;
1255
- isNavigating = false;
1256
- selectedValues = [];
1257
- focusedValue;
1258
- #e = 0;
1259
- #o = "";
1260
- #t;
1261
- #n;
1262
- #a;
1263
- get cursor() {
1264
- return this.#e;
1265
- }
1266
- get userInputWithCursor() {
1267
- if (!this.userInput)
1268
- return y(["inverse", "hidden"], "_");
1269
- if (this._cursor >= this.userInput.length)
1270
- return `${this.userInput}█`;
1271
- const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
1272
- return `${t}${y("inverse", e)}${s.join("")}`;
1273
- }
1274
- get options() {
1275
- return typeof this.#n == "function" ? this.#n() : this.#n;
1276
- }
1277
- constructor(t) {
1278
- super(t), this.#n = t.options, this.#a = t.placeholder;
1279
- const e = this.options;
1280
- this.filteredOptions = [...e], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
1281
- let s;
1282
- if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s)
1283
- for (const i of s) {
1284
- const n = e.findIndex((o) => o.value === i);
1285
- n !== -1 && (this.toggleSelected(i), this.#e = n);
1286
- }
1287
- this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
1288
- }
1289
- _isActionKey(t, e) {
1290
- return t === "\t" || this.multiple && this.isNavigating && e.name === "space" && t !== undefined && t !== "";
1291
- }
1292
- #s(t, e) {
1293
- const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === "\t", a = this.#a, h = this.options, l = a !== undefined && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : true));
1294
- if (e.name === "tab" && o && l) {
1295
- this.userInput === "\t" && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
1296
- return;
1297
- }
1298
- s || i ? (this.#e = d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
1299
- }
1300
- deselectAll() {
1301
- this.selectedValues = [];
1302
- }
1303
- toggleSelected(t) {
1304
- this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e) => e !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
1305
- }
1306
- #i(t) {
1307
- if (t !== this.#o) {
1308
- this.#o = t;
1309
- const e = this.options;
1310
- t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
1311
- const s = W(this.focusedValue, this.filteredOptions);
1312
- this.#e = d(s, 0, this.filteredOptions);
1313
- const i = this.filteredOptions[this.#e];
1314
- i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
1315
- }
1316
- }
1317
- };
1318
- X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
1319
- et = class et extends p {
1320
- #e;
1321
- #o;
1322
- #t;
1323
- #n;
1324
- #a;
1325
- #s = { segmentIndex: 0, positionInSegment: 0 };
1326
- #i = true;
1327
- #r = null;
1328
- inlineError = "";
1329
- get segmentCursor() {
1330
- return { ...this.#s };
1331
- }
1332
- get segmentValues() {
1333
- return { ...this.#t };
1334
- }
1335
- get segments() {
1336
- return this.#e;
1337
- }
1338
- get separator() {
1339
- return this.#o;
1340
- }
1341
- get formattedValue() {
1342
- return this.#c(this.#t);
1343
- }
1344
- #c(t) {
1345
- return this.#e.map((e) => t[e.type]).join(this.#o);
1346
- }
1347
- #h() {
1348
- this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
1349
- }
1350
- constructor(t) {
1351
- const e = t.format ? { segments: L(t.format), separator: t.separator ?? "/" } : Z(t.locale), s = t.separator ?? e.separator, i = t.format ? L(t.format) : e.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, a = i.map((h) => o[h.type]).join(s);
1352
- super({ ...t, initialUserInput: a }, false), this.#e = i, this.#o = s, this.#t = o, this.#n = t.minDate, this.#a = t.maxDate, this.#h(), this.on("cursor", (h) => this.#d(h)), this.on("key", (h, l) => this.#f(h, l)), this.on("finalize", () => this.#g(t));
1353
- }
1354
- #u() {
1355
- const t = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t];
1356
- if (e)
1357
- return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t };
1358
- }
1359
- #l(t) {
1360
- this.inlineError = "", this.#r = null;
1361
- const e = this.#u();
1362
- e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t)), this.#s.positionInSegment = 0, this.#i = true);
1363
- }
1364
- #p(t) {
1365
- const e = this.#u();
1366
- if (!e)
1367
- return;
1368
- const { segment: s } = e, i = this.#t[s.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, a = tt(s.type, I(this.#t), this.#n, this.#a);
1369
- let h;
1370
- n ? h = t === 1 ? a.min : a.max : h = Math.max(Math.min(a.max, o + t), a.min), this.#t = { ...this.#t, [s.type]: h.toString().padStart(s.len, "0") }, this.#i = true, this.#r = null, this.#h();
1371
- }
1372
- #d(t) {
1373
- if (t)
1374
- switch (t) {
1375
- case "right":
1376
- return this.#l(1);
1377
- case "left":
1378
- return this.#l(-1);
1379
- case "up":
1380
- return this.#p(1);
1381
- case "down":
1382
- return this.#p(-1);
1383
- }
1384
- }
1385
- #f(t, e) {
1386
- if (e?.name === "backspace" || e?.sequence === "" || e?.sequence === "\b" || t === "" || t === "\b") {
1387
- this.inlineError = "";
1388
- const s = this.#u();
1389
- if (!s)
1390
- return;
1391
- if (!this.#t[s.segment.type].replace(/_/g, "")) {
1392
- this.#l(-1);
1393
- return;
1394
- }
1395
- this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
1396
- return;
1397
- }
1398
- if (e?.name === "tab") {
1399
- this.inlineError = "";
1400
- const s = this.#u();
1401
- if (!s)
1402
- return;
1403
- const i = e.shift ? -1 : 1, n = s.index + i;
1404
- n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
1405
- return;
1406
- }
1407
- if (t && /^[0-9]$/.test(t)) {
1408
- const s = this.#u();
1409
- if (!s)
1410
- return;
1411
- const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
1412
- if (this.#i && this.#r !== null && !n) {
1413
- const m = this.#r + t, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
1414
- if (b) {
1415
- this.inlineError = b, this.#r = null, this.#i = false;
1416
- return;
1417
- }
1418
- this.inlineError = "", this.#t[i.type] = m, this.#r = null, this.#i = false, this.#h(), s.index < this.#e.length - 1 && (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true);
1419
- return;
1420
- }
1421
- this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
1422
- const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
1423
- if (h < 0 || h >= i.len)
1424
- return;
1425
- let l = o.slice(0, h) + t + o.slice(h + 1), f = false;
1426
- if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
1427
- const m = Number.parseInt(t, 10);
1428
- l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
1429
- }
1430
- if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
1431
- const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
1432
- if (g) {
1433
- this.inlineError = g;
1434
- return;
1435
- }
1436
- }
1437
- this.inlineError = "", this.#t[i.type] = l;
1438
- const v = l.includes("_") ? undefined : F(this.#t);
1439
- if (v) {
1440
- const { year: m, month: g } = v, b = T(m, g);
1441
- this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(b, v.day))).padStart(2, "0") };
1442
- }
1443
- this.#h();
1444
- const U = l.indexOf("_");
1445
- f ? (this.#i = true, this.#r = t) : U >= 0 ? this.#s.positionInSegment = U : a >= 0 && s.index < this.#e.length - 1 ? (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true) : this.#s.positionInSegment = Math.min(h + 1, i.len - 1);
1446
- }
1447
- }
1448
- #m(t, e) {
1449
- const { month: s, day: i } = I(t);
1450
- if (e.type === "month" && (s < 0 || s > 12))
1451
- return u.date.messages.invalidMonth;
1452
- if (e.type === "day" && (i < 0 || i > 31))
1453
- return u.date.messages.invalidDay(31, "any month");
1454
- }
1455
- #g(t) {
1456
- const { year: e, month: s, day: i } = I(this.#t);
1457
- if (e && s && i) {
1458
- const n = T(e, s);
1459
- this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
1460
- }
1461
- this.value = N(this.#t) ?? t.defaultValue ?? undefined;
1462
- }
1463
- };
1464
- st = class st extends p {
1465
- options;
1466
- cursor = 0;
1467
- #e;
1468
- getGroupItems(t) {
1469
- return this.options.filter((e) => e.group === t);
1470
- }
1471
- isGroupSelected(t) {
1472
- const e = this.getGroupItems(t), s = this.value;
1473
- return s === undefined ? false : e.every((i) => s.includes(i.value));
1474
- }
1475
- toggleValue() {
1476
- const t = this.options[this.cursor];
1477
- if (this.value === undefined && (this.value = []), t.group === true) {
1478
- const e = t.value, s = this.getGroupItems(e);
1479
- this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
1480
- } else {
1481
- const e = this.value.includes(t.value);
1482
- this.value = e ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
1483
- }
1484
- }
1485
- constructor(t) {
1486
- super(t, false);
1487
- const { options: e } = t;
1488
- this.#e = t.selectableGroups !== false, this.options = Object.entries(e).flatMap(([s, i]) => [{ value: s, group: true, label: s }, ...i.map((n) => ({ ...n, group: s }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
1489
- switch (s) {
1490
- case "left":
1491
- case "up": {
1492
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
1493
- const i = this.options[this.cursor]?.group === true;
1494
- !this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
1495
- break;
1496
- }
1497
- case "down":
1498
- case "right": {
1499
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
1500
- const i = this.options[this.cursor]?.group === true;
1501
- !this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
1502
- break;
1503
- }
1504
- case "space":
1505
- this.toggleValue();
1506
- break;
1507
- }
1508
- });
1509
- }
1510
- };
1511
- at = class at extends p {
1512
- get userInputWithCursor() {
1513
- if (this.state === "submit")
1514
- return this.userInput;
1515
- const t = this.userInput;
1516
- if (this.cursor >= t.length)
1517
- return `${this.userInput}█`;
1518
- const e = t.slice(0, this.cursor), [s, ...i] = t.slice(this.cursor);
1519
- return `${e}${y("inverse", s)}${i.join("")}`;
1520
- }
1521
- get cursor() {
1522
- return this._cursor;
1523
- }
1524
- constructor(t) {
1525
- super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (e) => {
1526
- this._setValue(e);
1527
- }), this.on("finalize", () => {
1528
- this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
1529
- });
1530
- }
1531
- };
1532
- });
1533
-
1534
- // ../../node_modules/.bun/@clack+prompts@1.2.0/node_modules/@clack/prompts/dist/index.mjs
1535
- import { styleText as t, stripVTControlCharacters as ne } from "node:util";
1536
- import P2 from "node:process";
1537
- function Ze() {
1538
- return P2.platform !== "win32" ? P2.env.TERM !== "linux" : !!P2.env.CI || !!P2.env.WT_SESSION || !!P2.env.TERMINUS_SUBLIME || P2.env.ConEmuTask === "{cmd::Cmder}" || P2.env.TERM_PROGRAM === "Terminus-Sublime" || P2.env.TERM_PROGRAM === "vscode" || P2.env.TERM === "xterm-256color" || P2.env.TERM === "alacritty" || P2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1539
- }
1540
- var import_sisteransi2, ee, w2 = (e, i) => ee ? e : i, _e, oe, ue, F2, le, d2, E2, Ie, Ee, z2, H2, te, U, J2, xe, se, ce, Ge, $e, de, Oe, he, pe, me, ge, V2 = (e) => {
1541
- switch (e) {
1542
- case "initial":
1543
- case "active":
1544
- return t("cyan", _e);
1545
- case "cancel":
1546
- return t("red", oe);
1547
- case "error":
1548
- return t("yellow", ue);
1549
- case "submit":
1550
- return t("green", F2);
1551
- }
1552
- }, pt = (e = "", i) => {
1553
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", E2)} ` : "";
1554
- s.write(`${r}${t("red", e)}
1555
-
1556
- `);
1557
- }, mt = (e = "", i) => {
1558
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", le)} ` : "";
1559
- s.write(`${r}${e}
1560
- `);
1561
- }, gt = (e = "", i) => {
1562
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", d2)}
1563
- ${t("gray", E2)} ` : "";
1564
- s.write(`${r}${e}
1565
-
1566
- `);
1567
- }, Ve, je, Ot = (e) => new at({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
1568
- const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${t("gray", d2)}
1569
- ` : ""}${V2(this.state)} `}${e.message}
1570
- `, r = e.placeholder ? t("inverse", e.placeholder[0]) + t("dim", e.placeholder.slice(1)) : t(["inverse", "hidden"], "_"), u2 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
1571
- switch (this.state) {
1572
- case "error": {
1573
- const o = this.error ? ` ${t("yellow", this.error)}` : "", c2 = i ? `${t("yellow", d2)} ` : "", a = i ? t("yellow", E2) : "";
1574
- return `${s.trim()}
1575
- ${c2}${u2}
1576
- ${a}${o}
1577
- `;
1578
- }
1579
- case "submit": {
1580
- const o = n ? ` ${t("dim", n)}` : "", c2 = i ? t("gray", d2) : "";
1581
- return `${s}${c2}${o}`;
1582
- }
1583
- case "cancel": {
1584
- const o = n ? ` ${t(["strikethrough", "dim"], n)}` : "", c2 = i ? t("gray", d2) : "";
1585
- return `${s}${c2}${o}${n.trim() ? `
1586
- ${c2}` : ""}`;
1587
- }
1588
- default: {
1589
- const o = i ? `${t("cyan", d2)} ` : "", c2 = i ? t("cyan", E2) : "";
1590
- return `${s}${o}${u2}
1591
- ${c2}
1592
- `;
1593
- }
1594
- }
1595
- } }).prompt();
1596
- var init_dist5 = __esm(() => {
1597
- init_dist4();
1598
- init_dist4();
1599
- init_main();
1600
- init_dist3();
1601
- import_sisteransi2 = __toESM(require_src(), 1);
1602
- ee = Ze();
1603
- _e = w2("◆", "*");
1604
- oe = w2("■", "x");
1605
- ue = w2("▲", "x");
1606
- F2 = w2("◇", "o");
1607
- le = w2("┌", "T");
1608
- d2 = w2("│", "|");
1609
- E2 = w2("└", "—");
1610
- Ie = w2("┐", "T");
1611
- Ee = w2("┘", "—");
1612
- z2 = w2("●", ">");
1613
- H2 = w2("○", " ");
1614
- te = w2("◻", "[•]");
1615
- U = w2("◼", "[+]");
1616
- J2 = w2("◻", "[ ]");
1617
- xe = w2("▪", "•");
1618
- se = w2("─", "-");
1619
- ce = w2("╮", "+");
1620
- Ge = w2("├", "+");
1621
- $e = w2("╯", "+");
1622
- de = w2("╰", "+");
1623
- Oe = w2("╭", "+");
1624
- he = w2("●", "•");
1625
- pe = w2("◆", "*");
1626
- me = w2("▲", "!");
1627
- ge = w2("■", "x");
1628
- Ve = { light: w2("─", "-"), heavy: w2("━", "="), block: w2("█", "#") };
1629
- je = `${t("gray", d2)} `;
1630
- });
1631
-
1632
- // package.json
1633
- var package_default;
1634
- var init_package = __esm(() => {
1635
- package_default = {
1636
- name: "@itsflower/cli",
1637
- version: "0.2.1",
1638
- bin: {
1639
- flower: "./bin.js"
1640
- },
1641
- files: [
1642
- "bin.js",
1643
- "dist"
1644
- ],
1645
- type: "module",
1646
- main: "./dist/main.js",
1647
- types: "./dist/main.d.ts",
1648
- exports: {
1649
- ".": {
1650
- types: "./dist/main.d.ts",
1651
- import: "./dist/main.js"
1652
- }
1653
- },
1654
- scripts: {
1655
- build: "bun build ./src/main.ts --outfile ./bin.js --target node && chmod +x ./bin.js",
1656
- dev: "bun run ./src/main.ts",
1657
- typecheck: "tsc --noEmit"
1658
- },
1659
- dependencies: {
1660
- "@clack/prompts": "^1.2.0",
1661
- citty: "^0.2.2"
1662
- },
1663
- devDependencies: {
1664
- "@types/bun": "^1.3.12",
1665
- typescript: "^6.0.2"
1666
- }
1667
- };
1668
- });
1669
-
1670
- // src/utils/prompts.ts
1671
- function handleCancel(value) {
1672
- if (q(value)) {
1673
- pt("Operation cancelled");
1674
- process.exit(0);
1675
- }
1676
- return false;
1677
- }
1678
- var init_prompts = __esm(() => {
1679
- init_dist5();
1680
- });
1681
-
1682
- // src/commands/hello.ts
1683
- var exports_hello = {};
1684
- __export(exports_hello, {
1685
- default: () => hello_default
1686
- });
1687
- var hello_default;
1688
- var init_hello = __esm(() => {
1689
- init_dist();
1690
- init_dist5();
1691
- init_prompts();
1692
- hello_default = defineCommand({
1693
- meta: {
1694
- name: "hello",
1695
- description: "Say hello to someone"
1696
- },
1697
- args: {
1698
- name: {
1699
- type: "positional",
1700
- description: "Name to greet",
1701
- required: false
1702
- },
1703
- formal: {
1704
- type: "boolean",
1705
- description: "Use formal greeting",
1706
- alias: "f"
1707
- }
1708
- },
1709
- run: async ({ args }) => {
1710
- mt("hello");
1711
- let name = args.name;
1712
- if (!name) {
1713
- const result = await Ot({
1714
- message: "Who would you like to greet?",
1715
- placeholder: "World"
1716
- });
1717
- if (handleCancel(result)) {
1718
- return;
1719
- }
1720
- name = result || "World";
1721
- }
1722
- const greeting = args.formal ? "Good day" : "Hello";
1723
- gt(`${greeting}, ${name}!`);
1724
- }
1725
- });
1726
- });
1727
-
1728
- // src/commands/version.ts
1729
- var exports_version = {};
1730
- __export(exports_version, {
1731
- default: () => version_default
1732
- });
1733
- var version_default;
1734
- var init_version = __esm(() => {
1735
- init_dist();
1736
- init_package();
1737
- version_default = defineCommand({
1738
- meta: {
1739
- name: "version",
1740
- description: "Display the current version"
1741
- },
1742
- run() {
1743
- console.log(`${package_default.name}@${package_default.version}`);
1744
- }
1745
- });
1746
- });
1747
-
1748
- // src/main.ts
1749
- init_dist();
1750
- init_dist5();
1751
- init_package();
1752
-
1753
- // src/commands/index.ts
1754
- var commands_default = {
1755
- hello: () => Promise.resolve().then(() => (init_hello(), exports_hello)).then((m) => m.default),
1756
- version: () => Promise.resolve().then(() => (init_version(), exports_version)).then((m) => m.default)
1757
- };
1758
-
1759
- // src/main.ts
1760
- var main = defineCommand({
1761
- meta: {
1762
- name: package_default.name,
1763
- version: package_default.version,
1764
- description: "flower - \uD83C\uDF38 Scaffold structured development workflows in your project"
1765
- },
1766
- args: {
1767
- verbose: {
1768
- type: "boolean",
1769
- description: "Enable verbose output",
1770
- alias: "v"
1771
- }
1772
- },
1773
- subCommands: commands_default,
1774
- setup: ({ args }) => {
1775
- if (args.verbose) {
1776
- Bun.env.VERBOSE = "true";
1777
- }
1778
- },
1779
- run: () => {
1780
- mt("flower");
1781
- gt("Use `flower --help` to see available commands");
1782
- }
1783
- });
1784
- runMain(main);