sv 0.7.2 → 0.8.1

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/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { Element, __commonJS, __require, __toESM, addPnpmBuildDependendencies, box, cancel, confirm, create, detect, esm_exports, from, getUserAgent, group, installDependencies, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss, parseHtml, parseHtml$1, parseJson, parseScript, parseSvelte, resolveCommand, select, spinner, templates, text, up, walk_exports } from "./package-manager-BusIB9Xp.js";
3
- import { __commonJS$1, __export, __toESM$1, addFromString, applyAddons, array_exports, common_exports, createWorkspace, dedent_default, exports_exports, formatFiles, function_exports, getHighlighter, imports_exports, kit_exports, object_exports, require_picocolors, setupAddons, variables_exports } from "./install-DPLwqpud.js";
2
+ import { AGENT_NAMES, Command, Element, Option, Tag, __commonJS, __export, __require, __toESM as __toESM$1, __toESM$1 as __toESM, addPnpmBuildDependencies, box, cancel, confirm, create, detect, esm_exports, from, getUserAgent, group, installDependencies, installOption, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss$1, parseHtml, parseHtml$1, parseJson$1, parseScript$1, parseSvelte, program, require_picocolors, resolveCommand, select, spinner, templates, text, up, walk_exports } from "./package-manager-D3PRQ-L_.js";
3
+ import { addFromString, applyAddons, array_exports, common_exports, createWorkspace, dedent_default, exports_exports, formatFiles, function_exports, getHighlighter, imports_exports, kit_exports, object_exports, require_picocolors$1, setupAddons, variables_exports } from "./install-iBxCFLH9.js";
4
4
  import fs, { existsSync } from "node:fs";
5
5
  import path, { dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -12,7 +12,7 @@ import { promisify } from "node:util";
12
12
 
13
13
  //#region packages/cli/package.json
14
14
  var name = "sv";
15
- var version = "0.7.2";
15
+ var version = "0.8.1";
16
16
  var type = "module";
17
17
  var description = "A CLI for creating and updating SvelteKit projects";
18
18
  var license = "MIT";
@@ -47,14 +47,14 @@ var devDependencies = {
47
47
  "@types/degit": "^2.8.6",
48
48
  "@types/ps-tree": "^1.1.6",
49
49
  "@types/tar-fs": "^2.0.4",
50
- "commander": "^13.0.0",
50
+ "commander": "^13.1.0",
51
51
  "degit": "^2.8.4",
52
52
  "empathic": "^1.0.0",
53
- "package-manager-detector": "^0.2.7",
53
+ "package-manager-detector": "^0.2.11",
54
54
  "picocolors": "^1.1.1",
55
55
  "ps-tree": "^1.2.0",
56
- "tar-fs": "^3.0.6",
57
- "tinyexec": "^0.3.1",
56
+ "tar-fs": "^3.0.8",
57
+ "tinyexec": "^0.3.2",
58
58
  "valibot": "^0.41.0"
59
59
  };
60
60
  var keywords = [
@@ -84,2902 +84,7 @@ var package_default = {
84
84
  };
85
85
 
86
86
  //#endregion
87
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/error.js
88
- var require_error = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/error.js"(exports) {
89
- var CommanderError$3 = class extends Error {
90
- /**
91
- * Constructs the CommanderError class
92
- * @param {number} exitCode suggested exit code which could be used with process.exit
93
- * @param {string} code an id string representing the error
94
- * @param {string} message human-readable description of the error
95
- */
96
- constructor(exitCode, code, message) {
97
- super(message);
98
- Error.captureStackTrace(this, this.constructor);
99
- this.name = this.constructor.name;
100
- this.code = code;
101
- this.exitCode = exitCode;
102
- this.nestedError = undefined;
103
- }
104
- };
105
- var InvalidArgumentError$4 = class extends CommanderError$3 {
106
- /**
107
- * Constructs the InvalidArgumentError class
108
- * @param {string} [message] explanation of why argument is invalid
109
- */
110
- constructor(message) {
111
- super(1, "commander.invalidArgument", message);
112
- Error.captureStackTrace(this, this.constructor);
113
- this.name = this.constructor.name;
114
- }
115
- };
116
- exports.CommanderError = CommanderError$3;
117
- exports.InvalidArgumentError = InvalidArgumentError$4;
118
- } });
119
-
120
- //#endregion
121
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/argument.js
122
- var require_argument = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/argument.js"(exports) {
123
- const { InvalidArgumentError: InvalidArgumentError$3 } = require_error();
124
- var Argument$3 = class {
125
- /**
126
- * Initialize a new command argument with the given name and description.
127
- * The default is that the argument is required, and you can explicitly
128
- * indicate this with <> around the name. Put [] around the name for an optional argument.
129
- *
130
- * @param {string} name
131
- * @param {string} [description]
132
- */
133
- constructor(name$1, description$1) {
134
- this.description = description$1 || "";
135
- this.variadic = false;
136
- this.parseArg = undefined;
137
- this.defaultValue = undefined;
138
- this.defaultValueDescription = undefined;
139
- this.argChoices = undefined;
140
- switch (name$1[0]) {
141
- case "<":
142
- this.required = true;
143
- this._name = name$1.slice(1, -1);
144
- break;
145
- case "[":
146
- this.required = false;
147
- this._name = name$1.slice(1, -1);
148
- break;
149
- default:
150
- this.required = true;
151
- this._name = name$1;
152
- break;
153
- }
154
- if (this._name.length > 3 && this._name.slice(-3) === "...") {
155
- this.variadic = true;
156
- this._name = this._name.slice(0, -3);
157
- }
158
- }
159
- /**
160
- * Return argument name.
161
- *
162
- * @return {string}
163
- */
164
- name() {
165
- return this._name;
166
- }
167
- /**
168
- * @package
169
- */
170
- _concatValue(value, previous) {
171
- if (previous === this.defaultValue || !Array.isArray(previous)) return [value];
172
- return previous.concat(value);
173
- }
174
- /**
175
- * Set the default value, and optionally supply the description to be displayed in the help.
176
- *
177
- * @param {*} value
178
- * @param {string} [description]
179
- * @return {Argument}
180
- */
181
- default(value, description$1) {
182
- this.defaultValue = value;
183
- this.defaultValueDescription = description$1;
184
- return this;
185
- }
186
- /**
187
- * Set the custom handler for processing CLI command arguments into argument values.
188
- *
189
- * @param {Function} [fn]
190
- * @return {Argument}
191
- */
192
- argParser(fn) {
193
- this.parseArg = fn;
194
- return this;
195
- }
196
- /**
197
- * Only allow argument value to be one of choices.
198
- *
199
- * @param {string[]} values
200
- * @return {Argument}
201
- */
202
- choices(values) {
203
- this.argChoices = values.slice();
204
- this.parseArg = (arg, previous) => {
205
- if (!this.argChoices.includes(arg)) throw new InvalidArgumentError$3(`Allowed choices are ${this.argChoices.join(", ")}.`);
206
- if (this.variadic) return this._concatValue(arg, previous);
207
- return arg;
208
- };
209
- return this;
210
- }
211
- /**
212
- * Make argument required.
213
- *
214
- * @returns {Argument}
215
- */
216
- argRequired() {
217
- this.required = true;
218
- return this;
219
- }
220
- /**
221
- * Make argument optional.
222
- *
223
- * @returns {Argument}
224
- */
225
- argOptional() {
226
- this.required = false;
227
- return this;
228
- }
229
- };
230
- /**
231
- * Takes an argument and returns its human readable equivalent for help usage.
232
- *
233
- * @param {Argument} arg
234
- * @return {string}
235
- * @private
236
- */
237
- function humanReadableArgName$2(arg) {
238
- const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
239
- return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
240
- }
241
- exports.Argument = Argument$3;
242
- exports.humanReadableArgName = humanReadableArgName$2;
243
- } });
244
-
245
- //#endregion
246
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/help.js
247
- var require_help = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/help.js"(exports) {
248
- const { humanReadableArgName: humanReadableArgName$1 } = require_argument();
249
- var Help$3 = class {
250
- constructor() {
251
- this.helpWidth = undefined;
252
- this.minWidthToWrap = 40;
253
- this.sortSubcommands = false;
254
- this.sortOptions = false;
255
- this.showGlobalOptions = false;
256
- }
257
- /**
258
- * prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
259
- * and just before calling `formatHelp()`.
260
- *
261
- * Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses.
262
- *
263
- * @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions
264
- */
265
- prepareContext(contextOptions) {
266
- this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
267
- }
268
- /**
269
- * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
270
- *
271
- * @param {Command} cmd
272
- * @returns {Command[]}
273
- */
274
- visibleCommands(cmd) {
275
- const visibleCommands = cmd.commands.filter((cmd$1) => !cmd$1._hidden);
276
- const helpCommand = cmd._getHelpCommand();
277
- if (helpCommand && !helpCommand._hidden) visibleCommands.push(helpCommand);
278
- if (this.sortSubcommands) visibleCommands.sort((a, b) => {
279
- return a.name().localeCompare(b.name());
280
- });
281
- return visibleCommands;
282
- }
283
- /**
284
- * Compare options for sort.
285
- *
286
- * @param {Option} a
287
- * @param {Option} b
288
- * @returns {number}
289
- */
290
- compareOptions(a, b) {
291
- const getSortKey = (option) => {
292
- return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
293
- };
294
- return getSortKey(a).localeCompare(getSortKey(b));
295
- }
296
- /**
297
- * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
298
- *
299
- * @param {Command} cmd
300
- * @returns {Option[]}
301
- */
302
- visibleOptions(cmd) {
303
- const visibleOptions = cmd.options.filter((option) => !option.hidden);
304
- const helpOption = cmd._getHelpOption();
305
- if (helpOption && !helpOption.hidden) {
306
- const removeShort = helpOption.short && cmd._findOption(helpOption.short);
307
- const removeLong = helpOption.long && cmd._findOption(helpOption.long);
308
- if (!removeShort && !removeLong) visibleOptions.push(helpOption);
309
- else if (helpOption.long && !removeLong) visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
310
- else if (helpOption.short && !removeShort) visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
311
- }
312
- if (this.sortOptions) visibleOptions.sort(this.compareOptions);
313
- return visibleOptions;
314
- }
315
- /**
316
- * Get an array of the visible global options. (Not including help.)
317
- *
318
- * @param {Command} cmd
319
- * @returns {Option[]}
320
- */
321
- visibleGlobalOptions(cmd) {
322
- if (!this.showGlobalOptions) return [];
323
- const globalOptions = [];
324
- for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
325
- const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
326
- globalOptions.push(...visibleOptions);
327
- }
328
- if (this.sortOptions) globalOptions.sort(this.compareOptions);
329
- return globalOptions;
330
- }
331
- /**
332
- * Get an array of the arguments if any have a description.
333
- *
334
- * @param {Command} cmd
335
- * @returns {Argument[]}
336
- */
337
- visibleArguments(cmd) {
338
- if (cmd._argsDescription) cmd.registeredArguments.forEach((argument) => {
339
- argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
340
- });
341
- if (cmd.registeredArguments.find((argument) => argument.description)) return cmd.registeredArguments;
342
- return [];
343
- }
344
- /**
345
- * Get the command term to show in the list of subcommands.
346
- *
347
- * @param {Command} cmd
348
- * @returns {string}
349
- */
350
- subcommandTerm(cmd) {
351
- const args = cmd.registeredArguments.map((arg) => humanReadableArgName$1(arg)).join(" ");
352
- return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
353
- }
354
- /**
355
- * Get the option term to show in the list of options.
356
- *
357
- * @param {Option} option
358
- * @returns {string}
359
- */
360
- optionTerm(option) {
361
- return option.flags;
362
- }
363
- /**
364
- * Get the argument term to show in the list of arguments.
365
- *
366
- * @param {Argument} argument
367
- * @returns {string}
368
- */
369
- argumentTerm(argument) {
370
- return argument.name();
371
- }
372
- /**
373
- * Get the longest command term length.
374
- *
375
- * @param {Command} cmd
376
- * @param {Help} helper
377
- * @returns {number}
378
- */
379
- longestSubcommandTermLength(cmd, helper) {
380
- return helper.visibleCommands(cmd).reduce((max, command) => {
381
- return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
382
- }, 0);
383
- }
384
- /**
385
- * Get the longest option term length.
386
- *
387
- * @param {Command} cmd
388
- * @param {Help} helper
389
- * @returns {number}
390
- */
391
- longestOptionTermLength(cmd, helper) {
392
- return helper.visibleOptions(cmd).reduce((max, option) => {
393
- return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
394
- }, 0);
395
- }
396
- /**
397
- * Get the longest global option term length.
398
- *
399
- * @param {Command} cmd
400
- * @param {Help} helper
401
- * @returns {number}
402
- */
403
- longestGlobalOptionTermLength(cmd, helper) {
404
- return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
405
- return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
406
- }, 0);
407
- }
408
- /**
409
- * Get the longest argument term length.
410
- *
411
- * @param {Command} cmd
412
- * @param {Help} helper
413
- * @returns {number}
414
- */
415
- longestArgumentTermLength(cmd, helper) {
416
- return helper.visibleArguments(cmd).reduce((max, argument) => {
417
- return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
418
- }, 0);
419
- }
420
- /**
421
- * Get the command usage to be displayed at the top of the built-in help.
422
- *
423
- * @param {Command} cmd
424
- * @returns {string}
425
- */
426
- commandUsage(cmd) {
427
- let cmdName = cmd._name;
428
- if (cmd._aliases[0]) cmdName = cmdName + "|" + cmd._aliases[0];
429
- let ancestorCmdNames = "";
430
- for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
431
- return ancestorCmdNames + cmdName + " " + cmd.usage();
432
- }
433
- /**
434
- * Get the description for the command.
435
- *
436
- * @param {Command} cmd
437
- * @returns {string}
438
- */
439
- commandDescription(cmd) {
440
- return cmd.description();
441
- }
442
- /**
443
- * Get the subcommand summary to show in the list of subcommands.
444
- * (Fallback to description for backwards compatibility.)
445
- *
446
- * @param {Command} cmd
447
- * @returns {string}
448
- */
449
- subcommandDescription(cmd) {
450
- return cmd.summary() || cmd.description();
451
- }
452
- /**
453
- * Get the option description to show in the list of options.
454
- *
455
- * @param {Option} option
456
- * @return {string}
457
- */
458
- optionDescription(option) {
459
- const extraInfo = [];
460
- if (option.argChoices) extraInfo.push(
461
- // use stringify to match the display of the default value
462
- `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
463
- );
464
- if (option.defaultValue !== undefined) {
465
- const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
466
- if (showDefault) extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
467
- }
468
- if (option.presetArg !== undefined && option.optional) extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
469
- if (option.envVar !== undefined) extraInfo.push(`env: ${option.envVar}`);
470
- if (extraInfo.length > 0) return `${option.description} (${extraInfo.join(", ")})`;
471
- return option.description;
472
- }
473
- /**
474
- * Get the argument description to show in the list of arguments.
475
- *
476
- * @param {Argument} argument
477
- * @return {string}
478
- */
479
- argumentDescription(argument) {
480
- const extraInfo = [];
481
- if (argument.argChoices) extraInfo.push(
482
- // use stringify to match the display of the default value
483
- `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
484
- );
485
- if (argument.defaultValue !== undefined) extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
486
- if (extraInfo.length > 0) {
487
- const extraDescription = `(${extraInfo.join(", ")})`;
488
- if (argument.description) return `${argument.description} ${extraDescription}`;
489
- return extraDescription;
490
- }
491
- return argument.description;
492
- }
493
- /**
494
- * Generate the built-in help text.
495
- *
496
- * @param {Command} cmd
497
- * @param {Help} helper
498
- * @returns {string}
499
- */
500
- formatHelp(cmd, helper) {
501
- const termWidth = helper.padWidth(cmd, helper);
502
- const helpWidth = helper.helpWidth ?? 80;
503
- function callFormatItem(term, description$1) {
504
- return helper.formatItem(term, termWidth, description$1, helper);
505
- }
506
- let output = [`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`, ""];
507
- const commandDescription = helper.commandDescription(cmd);
508
- if (commandDescription.length > 0) output = output.concat([helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth), ""]);
509
- const argumentList = helper.visibleArguments(cmd).map((argument) => {
510
- return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
511
- });
512
- if (argumentList.length > 0) output = output.concat([
513
- helper.styleTitle("Arguments:"),
514
- ...argumentList,
515
- ""
516
- ]);
517
- const optionList = helper.visibleOptions(cmd).map((option) => {
518
- return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
519
- });
520
- if (optionList.length > 0) output = output.concat([
521
- helper.styleTitle("Options:"),
522
- ...optionList,
523
- ""
524
- ]);
525
- if (helper.showGlobalOptions) {
526
- const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
527
- return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
528
- });
529
- if (globalOptionList.length > 0) output = output.concat([
530
- helper.styleTitle("Global Options:"),
531
- ...globalOptionList,
532
- ""
533
- ]);
534
- }
535
- const commandList = helper.visibleCommands(cmd).map((cmd$1) => {
536
- return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(cmd$1)), helper.styleSubcommandDescription(helper.subcommandDescription(cmd$1)));
537
- });
538
- if (commandList.length > 0) output = output.concat([
539
- helper.styleTitle("Commands:"),
540
- ...commandList,
541
- ""
542
- ]);
543
- return output.join("\n");
544
- }
545
- /**
546
- * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
547
- *
548
- * @param {string} str
549
- * @returns {number}
550
- */
551
- displayWidth(str) {
552
- return stripColor$1(str).length;
553
- }
554
- /**
555
- * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
556
- *
557
- * @param {string} str
558
- * @returns {string}
559
- */
560
- styleTitle(str) {
561
- return str;
562
- }
563
- styleUsage(str) {
564
- return str.split(" ").map((word) => {
565
- if (word === "[options]") return this.styleOptionText(word);
566
- if (word === "[command]") return this.styleSubcommandText(word);
567
- if (word[0] === "[" || word[0] === "<") return this.styleArgumentText(word);
568
- return this.styleCommandText(word);
569
- }).join(" ");
570
- }
571
- styleCommandDescription(str) {
572
- return this.styleDescriptionText(str);
573
- }
574
- styleOptionDescription(str) {
575
- return this.styleDescriptionText(str);
576
- }
577
- styleSubcommandDescription(str) {
578
- return this.styleDescriptionText(str);
579
- }
580
- styleArgumentDescription(str) {
581
- return this.styleDescriptionText(str);
582
- }
583
- styleDescriptionText(str) {
584
- return str;
585
- }
586
- styleOptionTerm(str) {
587
- return this.styleOptionText(str);
588
- }
589
- styleSubcommandTerm(str) {
590
- return str.split(" ").map((word) => {
591
- if (word === "[options]") return this.styleOptionText(word);
592
- if (word[0] === "[" || word[0] === "<") return this.styleArgumentText(word);
593
- return this.styleSubcommandText(word);
594
- }).join(" ");
595
- }
596
- styleArgumentTerm(str) {
597
- return this.styleArgumentText(str);
598
- }
599
- styleOptionText(str) {
600
- return str;
601
- }
602
- styleArgumentText(str) {
603
- return str;
604
- }
605
- styleSubcommandText(str) {
606
- return str;
607
- }
608
- styleCommandText(str) {
609
- return str;
610
- }
611
- /**
612
- * Calculate the pad width from the maximum term length.
613
- *
614
- * @param {Command} cmd
615
- * @param {Help} helper
616
- * @returns {number}
617
- */
618
- padWidth(cmd, helper) {
619
- return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
620
- }
621
- /**
622
- * Detect manually wrapped and indented strings by checking for line break followed by whitespace.
623
- *
624
- * @param {string} str
625
- * @returns {boolean}
626
- */
627
- preformatted(str) {
628
- return /\n[^\S\r\n]/.test(str);
629
- }
630
- /**
631
- * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
632
- *
633
- * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
634
- * TTT DDD DDDD
635
- * DD DDD
636
- *
637
- * @param {string} term
638
- * @param {number} termWidth
639
- * @param {string} description
640
- * @param {Help} helper
641
- * @returns {string}
642
- */
643
- formatItem(term, termWidth, description$1, helper) {
644
- const itemIndent = 2;
645
- const itemIndentStr = " ".repeat(itemIndent);
646
- if (!description$1) return itemIndentStr + term;
647
- const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
648
- const spacerWidth = 2;
649
- const helpWidth = this.helpWidth ?? 80;
650
- const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
651
- let formattedDescription;
652
- if (remainingWidth < this.minWidthToWrap || helper.preformatted(description$1)) formattedDescription = description$1;
653
- else {
654
- const wrappedDescription = helper.boxWrap(description$1, remainingWidth);
655
- formattedDescription = wrappedDescription.replace(/\n/g, "\n" + " ".repeat(termWidth + spacerWidth));
656
- }
657
- return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `\n${itemIndentStr}`);
658
- }
659
- /**
660
- * Wrap a string at whitespace, preserving existing line breaks.
661
- * Wrapping is skipped if the width is less than `minWidthToWrap`.
662
- *
663
- * @param {string} str
664
- * @param {number} width
665
- * @returns {string}
666
- */
667
- boxWrap(str, width) {
668
- if (width < this.minWidthToWrap) return str;
669
- const rawLines = str.split(/\r\n|\n/);
670
- const chunkPattern = /[\s]*[^\s]+/g;
671
- const wrappedLines = [];
672
- rawLines.forEach((line) => {
673
- const chunks = line.match(chunkPattern);
674
- if (chunks === null) {
675
- wrappedLines.push("");
676
- return;
677
- }
678
- let sumChunks = [chunks.shift()];
679
- let sumWidth = this.displayWidth(sumChunks[0]);
680
- chunks.forEach((chunk) => {
681
- const visibleWidth = this.displayWidth(chunk);
682
- if (sumWidth + visibleWidth <= width) {
683
- sumChunks.push(chunk);
684
- sumWidth += visibleWidth;
685
- return;
686
- }
687
- wrappedLines.push(sumChunks.join(""));
688
- const nextChunk = chunk.trimStart();
689
- sumChunks = [nextChunk];
690
- sumWidth = this.displayWidth(nextChunk);
691
- });
692
- wrappedLines.push(sumChunks.join(""));
693
- });
694
- return wrappedLines.join("\n");
695
- }
696
- };
697
- /**
698
- * Strip style ANSI escape sequences from the string. In particular, SGR (Select Graphic Rendition) codes.
699
- *
700
- * @param {string} str
701
- * @returns {string}
702
- * @package
703
- */
704
- function stripColor$1(str) {
705
- const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
706
- return str.replace(sgrPattern, "");
707
- }
708
- exports.Help = Help$3;
709
- exports.stripColor = stripColor$1;
710
- } });
711
-
712
- //#endregion
713
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/option.js
714
- var require_option = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/option.js"(exports) {
715
- const { InvalidArgumentError: InvalidArgumentError$2 } = require_error();
716
- var Option$3 = class {
717
- /**
718
- * Initialize a new `Option` with the given `flags` and `description`.
719
- *
720
- * @param {string} flags
721
- * @param {string} [description]
722
- */
723
- constructor(flags, description$1) {
724
- this.flags = flags;
725
- this.description = description$1 || "";
726
- this.required = flags.includes("<");
727
- this.optional = flags.includes("[");
728
- this.variadic = /\w\.\.\.[>\]]$/.test(flags);
729
- this.mandatory = false;
730
- const optionFlags = splitOptionFlags(flags);
731
- this.short = optionFlags.shortFlag;
732
- this.long = optionFlags.longFlag;
733
- this.negate = false;
734
- if (this.long) this.negate = this.long.startsWith("--no-");
735
- this.defaultValue = undefined;
736
- this.defaultValueDescription = undefined;
737
- this.presetArg = undefined;
738
- this.envVar = undefined;
739
- this.parseArg = undefined;
740
- this.hidden = false;
741
- this.argChoices = undefined;
742
- this.conflictsWith = [];
743
- this.implied = undefined;
744
- }
745
- /**
746
- * Set the default value, and optionally supply the description to be displayed in the help.
747
- *
748
- * @param {*} value
749
- * @param {string} [description]
750
- * @return {Option}
751
- */
752
- default(value, description$1) {
753
- this.defaultValue = value;
754
- this.defaultValueDescription = description$1;
755
- return this;
756
- }
757
- /**
758
- * Preset to use when option used without option-argument, especially optional but also boolean and negated.
759
- * The custom processing (parseArg) is called.
760
- *
761
- * @example
762
- * new Option('--color').default('GREYSCALE').preset('RGB');
763
- * new Option('--donate [amount]').preset('20').argParser(parseFloat);
764
- *
765
- * @param {*} arg
766
- * @return {Option}
767
- */
768
- preset(arg) {
769
- this.presetArg = arg;
770
- return this;
771
- }
772
- /**
773
- * Add option name(s) that conflict with this option.
774
- * An error will be displayed if conflicting options are found during parsing.
775
- *
776
- * @example
777
- * new Option('--rgb').conflicts('cmyk');
778
- * new Option('--js').conflicts(['ts', 'jsx']);
779
- *
780
- * @param {(string | string[])} names
781
- * @return {Option}
782
- */
783
- conflicts(names) {
784
- this.conflictsWith = this.conflictsWith.concat(names);
785
- return this;
786
- }
787
- /**
788
- * Specify implied option values for when this option is set and the implied options are not.
789
- *
790
- * The custom processing (parseArg) is not called on the implied values.
791
- *
792
- * @example
793
- * program
794
- * .addOption(new Option('--log', 'write logging information to file'))
795
- * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
796
- *
797
- * @param {object} impliedOptionValues
798
- * @return {Option}
799
- */
800
- implies(impliedOptionValues) {
801
- let newImplied = impliedOptionValues;
802
- if (typeof impliedOptionValues === "string") newImplied = { [impliedOptionValues]: true };
803
- this.implied = Object.assign(this.implied || {}, newImplied);
804
- return this;
805
- }
806
- /**
807
- * Set environment variable to check for option value.
808
- *
809
- * An environment variable is only used if when processed the current option value is
810
- * undefined, or the source of the current value is 'default' or 'config' or 'env'.
811
- *
812
- * @param {string} name
813
- * @return {Option}
814
- */
815
- env(name$1) {
816
- this.envVar = name$1;
817
- return this;
818
- }
819
- /**
820
- * Set the custom handler for processing CLI option arguments into option values.
821
- *
822
- * @param {Function} [fn]
823
- * @return {Option}
824
- */
825
- argParser(fn) {
826
- this.parseArg = fn;
827
- return this;
828
- }
829
- /**
830
- * Whether the option is mandatory and must have a value after parsing.
831
- *
832
- * @param {boolean} [mandatory=true]
833
- * @return {Option}
834
- */
835
- makeOptionMandatory(mandatory = true) {
836
- this.mandatory = !!mandatory;
837
- return this;
838
- }
839
- /**
840
- * Hide option in help.
841
- *
842
- * @param {boolean} [hide=true]
843
- * @return {Option}
844
- */
845
- hideHelp(hide = true) {
846
- this.hidden = !!hide;
847
- return this;
848
- }
849
- /**
850
- * @package
851
- */
852
- _concatValue(value, previous) {
853
- if (previous === this.defaultValue || !Array.isArray(previous)) return [value];
854
- return previous.concat(value);
855
- }
856
- /**
857
- * Only allow option value to be one of choices.
858
- *
859
- * @param {string[]} values
860
- * @return {Option}
861
- */
862
- choices(values) {
863
- this.argChoices = values.slice();
864
- this.parseArg = (arg, previous) => {
865
- if (!this.argChoices.includes(arg)) throw new InvalidArgumentError$2(`Allowed choices are ${this.argChoices.join(", ")}.`);
866
- if (this.variadic) return this._concatValue(arg, previous);
867
- return arg;
868
- };
869
- return this;
870
- }
871
- /**
872
- * Return option name.
873
- *
874
- * @return {string}
875
- */
876
- name() {
877
- if (this.long) return this.long.replace(/^--/, "");
878
- return this.short.replace(/^-/, "");
879
- }
880
- /**
881
- * Return option name, in a camelcase format that can be used
882
- * as an object attribute key.
883
- *
884
- * @return {string}
885
- */
886
- attributeName() {
887
- if (this.negate) return camelcase(this.name().replace(/^no-/, ""));
888
- return camelcase(this.name());
889
- }
890
- /**
891
- * Check if `arg` matches the short or long flag.
892
- *
893
- * @param {string} arg
894
- * @return {boolean}
895
- * @package
896
- */
897
- is(arg) {
898
- return this.short === arg || this.long === arg;
899
- }
900
- /**
901
- * Return whether a boolean option.
902
- *
903
- * Options are one of boolean, negated, required argument, or optional argument.
904
- *
905
- * @return {boolean}
906
- * @package
907
- */
908
- isBoolean() {
909
- return !this.required && !this.optional && !this.negate;
910
- }
911
- };
912
- var DualOptions$1 = class {
913
- /**
914
- * @param {Option[]} options
915
- */
916
- constructor(options$6) {
917
- this.positiveOptions = new Map();
918
- this.negativeOptions = new Map();
919
- this.dualOptions = new Set();
920
- options$6.forEach((option) => {
921
- if (option.negate) this.negativeOptions.set(option.attributeName(), option);
922
- else this.positiveOptions.set(option.attributeName(), option);
923
- });
924
- this.negativeOptions.forEach((value, key) => {
925
- if (this.positiveOptions.has(key)) this.dualOptions.add(key);
926
- });
927
- }
928
- /**
929
- * Did the value come from the option, and not from possible matching dual option?
930
- *
931
- * @param {*} value
932
- * @param {Option} option
933
- * @returns {boolean}
934
- */
935
- valueFromOption(value, option) {
936
- const optionKey = option.attributeName();
937
- if (!this.dualOptions.has(optionKey)) return true;
938
- const preset = this.negativeOptions.get(optionKey).presetArg;
939
- const negativeValue = preset !== undefined ? preset : false;
940
- return option.negate === (negativeValue === value);
941
- }
942
- };
943
- /**
944
- * Convert string from kebab-case to camelCase.
945
- *
946
- * @param {string} str
947
- * @return {string}
948
- * @private
949
- */
950
- function camelcase(str) {
951
- return str.split("-").reduce((str$1, word) => {
952
- return str$1 + word[0].toUpperCase() + word.slice(1);
953
- });
954
- }
955
- /**
956
- * Split the short and long flag out of something like '-m,--mixed <value>'
957
- *
958
- * @private
959
- */
960
- function splitOptionFlags(flags) {
961
- let shortFlag;
962
- let longFlag;
963
- const shortFlagExp = /^-[^-]$/;
964
- const longFlagExp = /^--[^-]/;
965
- const flagParts = flags.split(/[ |,]+/).concat("guard");
966
- if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
967
- if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
968
- if (/^-[^-][^-]/.test(flagParts[0])) throw new Error(`invalid Option flags, short option is dash and single character: '${flags}'`);
969
- if (shortFlag && shortFlagExp.test(flagParts[0])) throw new Error(`invalid Option flags, more than one short flag: '${flags}'`);
970
- if (longFlag && longFlagExp.test(flagParts[0])) throw new Error(`invalid Option flags, more than one long flag: '${flags}'`);
971
- if (!(shortFlag || longFlag) || flagParts[0].startsWith("-")) throw new Error(`invalid Option flags: '${flags}'`);
972
- return {
973
- shortFlag,
974
- longFlag
975
- };
976
- }
977
- exports.Option = Option$3;
978
- exports.DualOptions = DualOptions$1;
979
- } });
980
-
981
- //#endregion
982
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/suggestSimilar.js
983
- var require_suggestSimilar = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/suggestSimilar.js"(exports) {
984
- const maxDistance = 3;
985
- function editDistance(a, b) {
986
- if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
987
- const d = [];
988
- for (let i = 0; i <= a.length; i++) d[i] = [i];
989
- for (let j = 0; j <= b.length; j++) d[0][j] = j;
990
- for (let j = 1; j <= b.length; j++) for (let i = 1; i <= a.length; i++) {
991
- let cost = 1;
992
- if (a[i - 1] === b[j - 1]) cost = 0;
993
- else cost = 1;
994
- d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
995
- if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
996
- }
997
- return d[a.length][b.length];
998
- }
999
- /**
1000
- * Find close matches, restricted to same number of edits.
1001
- *
1002
- * @param {string} word
1003
- * @param {string[]} candidates
1004
- * @returns {string}
1005
- */
1006
- function suggestSimilar$1(word, candidates) {
1007
- if (!candidates || candidates.length === 0) return "";
1008
- candidates = Array.from(new Set(candidates));
1009
- const searchingOptions = word.startsWith("--");
1010
- if (searchingOptions) {
1011
- word = word.slice(2);
1012
- candidates = candidates.map((candidate) => candidate.slice(2));
1013
- }
1014
- let similar = [];
1015
- let bestDistance = maxDistance;
1016
- const minSimilarity = .4;
1017
- candidates.forEach((candidate) => {
1018
- if (candidate.length <= 1) return;
1019
- const distance = editDistance(word, candidate);
1020
- const length = Math.max(word.length, candidate.length);
1021
- const similarity = (length - distance) / length;
1022
- if (similarity > minSimilarity) {
1023
- if (distance < bestDistance) {
1024
- bestDistance = distance;
1025
- similar = [candidate];
1026
- } else if (distance === bestDistance) similar.push(candidate);
1027
- }
1028
- });
1029
- similar.sort((a, b) => a.localeCompare(b));
1030
- if (searchingOptions) similar = similar.map((candidate) => `--${candidate}`);
1031
- if (similar.length > 1) return `\n(Did you mean one of ${similar.join(", ")}?)`;
1032
- if (similar.length === 1) return `\n(Did you mean ${similar[0]}?)`;
1033
- return "";
1034
- }
1035
- exports.suggestSimilar = suggestSimilar$1;
1036
- } });
1037
-
1038
- //#endregion
1039
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/command.js
1040
- var require_command = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modules/commander/lib/command.js"(exports) {
1041
- const EventEmitter$1 = __require("node:events").EventEmitter;
1042
- const childProcess = __require("node:child_process");
1043
- const path$2 = __require("node:path");
1044
- const fs$3 = __require("node:fs");
1045
- const process$2 = __require("node:process");
1046
- const { Argument: Argument$2, humanReadableArgName } = require_argument();
1047
- const { CommanderError: CommanderError$2 } = require_error();
1048
- const { Help: Help$2, stripColor } = require_help();
1049
- const { Option: Option$2, DualOptions } = require_option();
1050
- const { suggestSimilar } = require_suggestSimilar();
1051
- var Command$2 = class Command$2 extends EventEmitter$1 {
1052
- /**
1053
- * Initialize a new `Command`.
1054
- *
1055
- * @param {string} [name]
1056
- */
1057
- constructor(name$1) {
1058
- super();
1059
- /** @type {Command[]} */
1060
- this.commands = [];
1061
- /** @type {Option[]} */
1062
- this.options = [];
1063
- this.parent = null;
1064
- this._allowUnknownOption = false;
1065
- this._allowExcessArguments = false;
1066
- /** @type {Argument[]} */
1067
- this.registeredArguments = [];
1068
- this._args = this.registeredArguments;
1069
- /** @type {string[]} */
1070
- this.args = [];
1071
- this.rawArgs = [];
1072
- this.processedArgs = [];
1073
- this._scriptPath = null;
1074
- this._name = name$1 || "";
1075
- this._optionValues = {};
1076
- this._optionValueSources = {};
1077
- this._storeOptionsAsProperties = false;
1078
- this._actionHandler = null;
1079
- this._executableHandler = false;
1080
- this._executableFile = null;
1081
- this._executableDir = null;
1082
- this._defaultCommandName = null;
1083
- this._exitCallback = null;
1084
- this._aliases = [];
1085
- this._combineFlagAndOptionalValue = true;
1086
- this._description = "";
1087
- this._summary = "";
1088
- this._argsDescription = undefined;
1089
- this._enablePositionalOptions = false;
1090
- this._passThroughOptions = false;
1091
- this._lifeCycleHooks = {};
1092
- /** @type {(boolean | string)} */
1093
- this._showHelpAfterError = false;
1094
- this._showSuggestionAfterError = true;
1095
- this._savedState = null;
1096
- this._outputConfiguration = {
1097
- writeOut: (str) => process$2.stdout.write(str),
1098
- writeErr: (str) => process$2.stderr.write(str),
1099
- outputError: (str, write$1) => write$1(str),
1100
- getOutHelpWidth: () => process$2.stdout.isTTY ? process$2.stdout.columns : undefined,
1101
- getErrHelpWidth: () => process$2.stderr.isTTY ? process$2.stderr.columns : undefined,
1102
- getOutHasColors: () => useColor() ?? (process$2.stdout.isTTY && process$2.stdout.hasColors?.()),
1103
- getErrHasColors: () => useColor() ?? (process$2.stderr.isTTY && process$2.stderr.hasColors?.()),
1104
- stripColor: (str) => stripColor(str)
1105
- };
1106
- this._hidden = false;
1107
- /** @type {(Option | null | undefined)} */
1108
- this._helpOption = undefined;
1109
- this._addImplicitHelpCommand = undefined;
1110
- /** @type {Command} */
1111
- this._helpCommand = undefined;
1112
- this._helpConfiguration = {};
1113
- }
1114
- /**
1115
- * Copy settings that are useful to have in common across root command and subcommands.
1116
- *
1117
- * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
1118
- *
1119
- * @param {Command} sourceCommand
1120
- * @return {Command} `this` command for chaining
1121
- */
1122
- copyInheritedSettings(sourceCommand) {
1123
- this._outputConfiguration = sourceCommand._outputConfiguration;
1124
- this._helpOption = sourceCommand._helpOption;
1125
- this._helpCommand = sourceCommand._helpCommand;
1126
- this._helpConfiguration = sourceCommand._helpConfiguration;
1127
- this._exitCallback = sourceCommand._exitCallback;
1128
- this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
1129
- this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
1130
- this._allowExcessArguments = sourceCommand._allowExcessArguments;
1131
- this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
1132
- this._showHelpAfterError = sourceCommand._showHelpAfterError;
1133
- this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
1134
- return this;
1135
- }
1136
- /**
1137
- * @returns {Command[]}
1138
- * @private
1139
- */
1140
- _getCommandAndAncestors() {
1141
- const result = [];
1142
- for (let command = this; command; command = command.parent) result.push(command);
1143
- return result;
1144
- }
1145
- /**
1146
- * Define a command.
1147
- *
1148
- * There are two styles of command: pay attention to where to put the description.
1149
- *
1150
- * @example
1151
- * // Command implemented using action handler (description is supplied separately to `.command`)
1152
- * program
1153
- * .command('clone <source> [destination]')
1154
- * .description('clone a repository into a newly created directory')
1155
- * .action((source, destination) => {
1156
- * console.log('clone command called');
1157
- * });
1158
- *
1159
- * // Command implemented using separate executable file (description is second parameter to `.command`)
1160
- * program
1161
- * .command('start <service>', 'start named service')
1162
- * .command('stop [service]', 'stop named service, or all if no name supplied');
1163
- *
1164
- * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
1165
- * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1166
- * @param {object} [execOpts] - configuration options (for executable)
1167
- * @return {Command} returns new command for action handler, or `this` for executable command
1168
- */
1169
- command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
1170
- let desc = actionOptsOrExecDesc;
1171
- let opts = execOpts;
1172
- if (typeof desc === "object" && desc !== null) {
1173
- opts = desc;
1174
- desc = null;
1175
- }
1176
- opts = opts || {};
1177
- const [, name$1, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
1178
- const cmd = this.createCommand(name$1);
1179
- if (desc) {
1180
- cmd.description(desc);
1181
- cmd._executableHandler = true;
1182
- }
1183
- if (opts.isDefault) this._defaultCommandName = cmd._name;
1184
- cmd._hidden = !!(opts.noHelp || opts.hidden);
1185
- cmd._executableFile = opts.executableFile || null;
1186
- if (args) cmd.arguments(args);
1187
- this._registerCommand(cmd);
1188
- cmd.parent = this;
1189
- cmd.copyInheritedSettings(this);
1190
- if (desc) return this;
1191
- return cmd;
1192
- }
1193
- /**
1194
- * Factory routine to create a new unattached command.
1195
- *
1196
- * See .command() for creating an attached subcommand, which uses this routine to
1197
- * create the command. You can override createCommand to customise subcommands.
1198
- *
1199
- * @param {string} [name]
1200
- * @return {Command} new command
1201
- */
1202
- createCommand(name$1) {
1203
- return new Command$2(name$1);
1204
- }
1205
- /**
1206
- * You can customise the help with a subclass of Help by overriding createHelp,
1207
- * or by overriding Help properties using configureHelp().
1208
- *
1209
- * @return {Help}
1210
- */
1211
- createHelp() {
1212
- return Object.assign(new Help$2(), this.configureHelp());
1213
- }
1214
- /**
1215
- * You can customise the help by overriding Help properties using configureHelp(),
1216
- * or with a subclass of Help by overriding createHelp().
1217
- *
1218
- * @param {object} [configuration] - configuration options
1219
- * @return {(Command | object)} `this` command for chaining, or stored configuration
1220
- */
1221
- configureHelp(configuration) {
1222
- if (configuration === undefined) return this._helpConfiguration;
1223
- this._helpConfiguration = configuration;
1224
- return this;
1225
- }
1226
- /**
1227
- * The default output goes to stdout and stderr. You can customise this for special
1228
- * applications. You can also customise the display of errors by overriding outputError.
1229
- *
1230
- * The configuration properties are all functions:
1231
- *
1232
- * // change how output being written, defaults to stdout and stderr
1233
- * writeOut(str)
1234
- * writeErr(str)
1235
- * // change how output being written for errors, defaults to writeErr
1236
- * outputError(str, write) // used for displaying errors and not used for displaying help
1237
- * // specify width for wrapping help
1238
- * getOutHelpWidth()
1239
- * getErrHelpWidth()
1240
- * // color support, currently only used with Help
1241
- * getOutHasColors()
1242
- * getErrHasColors()
1243
- * stripColor() // used to remove ANSI escape codes if output does not have colors
1244
- *
1245
- * @param {object} [configuration] - configuration options
1246
- * @return {(Command | object)} `this` command for chaining, or stored configuration
1247
- */
1248
- configureOutput(configuration) {
1249
- if (configuration === undefined) return this._outputConfiguration;
1250
- Object.assign(this._outputConfiguration, configuration);
1251
- return this;
1252
- }
1253
- /**
1254
- * Display the help or a custom message after an error occurs.
1255
- *
1256
- * @param {(boolean|string)} [displayHelp]
1257
- * @return {Command} `this` command for chaining
1258
- */
1259
- showHelpAfterError(displayHelp = true) {
1260
- if (typeof displayHelp !== "string") displayHelp = !!displayHelp;
1261
- this._showHelpAfterError = displayHelp;
1262
- return this;
1263
- }
1264
- /**
1265
- * Display suggestion of similar commands for unknown commands, or options for unknown options.
1266
- *
1267
- * @param {boolean} [displaySuggestion]
1268
- * @return {Command} `this` command for chaining
1269
- */
1270
- showSuggestionAfterError(displaySuggestion = true) {
1271
- this._showSuggestionAfterError = !!displaySuggestion;
1272
- return this;
1273
- }
1274
- /**
1275
- * Add a prepared subcommand.
1276
- *
1277
- * See .command() for creating an attached subcommand which inherits settings from its parent.
1278
- *
1279
- * @param {Command} cmd - new subcommand
1280
- * @param {object} [opts] - configuration options
1281
- * @return {Command} `this` command for chaining
1282
- */
1283
- addCommand(cmd, opts) {
1284
- if (!cmd._name) throw new Error(`Command passed to .addCommand() must have a name
1285
- - specify the name in Command constructor or using .name()`);
1286
- opts = opts || {};
1287
- if (opts.isDefault) this._defaultCommandName = cmd._name;
1288
- if (opts.noHelp || opts.hidden) cmd._hidden = true;
1289
- this._registerCommand(cmd);
1290
- cmd.parent = this;
1291
- cmd._checkForBrokenPassThrough();
1292
- return this;
1293
- }
1294
- /**
1295
- * Factory routine to create a new unattached argument.
1296
- *
1297
- * See .argument() for creating an attached argument, which uses this routine to
1298
- * create the argument. You can override createArgument to return a custom argument.
1299
- *
1300
- * @param {string} name
1301
- * @param {string} [description]
1302
- * @return {Argument} new argument
1303
- */
1304
- createArgument(name$1, description$1) {
1305
- return new Argument$2(name$1, description$1);
1306
- }
1307
- /**
1308
- * Define argument syntax for command.
1309
- *
1310
- * The default is that the argument is required, and you can explicitly
1311
- * indicate this with <> around the name. Put [] around the name for an optional argument.
1312
- *
1313
- * @example
1314
- * program.argument('<input-file>');
1315
- * program.argument('[output-file]');
1316
- *
1317
- * @param {string} name
1318
- * @param {string} [description]
1319
- * @param {(Function|*)} [fn] - custom argument processing function
1320
- * @param {*} [defaultValue]
1321
- * @return {Command} `this` command for chaining
1322
- */
1323
- argument(name$1, description$1, fn, defaultValue) {
1324
- const argument = this.createArgument(name$1, description$1);
1325
- if (typeof fn === "function") argument.default(defaultValue).argParser(fn);
1326
- else argument.default(fn);
1327
- this.addArgument(argument);
1328
- return this;
1329
- }
1330
- /**
1331
- * Define argument syntax for command, adding multiple at once (without descriptions).
1332
- *
1333
- * See also .argument().
1334
- *
1335
- * @example
1336
- * program.arguments('<cmd> [env]');
1337
- *
1338
- * @param {string} names
1339
- * @return {Command} `this` command for chaining
1340
- */
1341
- arguments(names) {
1342
- names.trim().split(/ +/).forEach((detail) => {
1343
- this.argument(detail);
1344
- });
1345
- return this;
1346
- }
1347
- /**
1348
- * Define argument syntax for command, adding a prepared argument.
1349
- *
1350
- * @param {Argument} argument
1351
- * @return {Command} `this` command for chaining
1352
- */
1353
- addArgument(argument) {
1354
- const previousArgument = this.registeredArguments.slice(-1)[0];
1355
- if (previousArgument && previousArgument.variadic) throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
1356
- if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
1357
- this.registeredArguments.push(argument);
1358
- return this;
1359
- }
1360
- /**
1361
- * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
1362
- *
1363
- * @example
1364
- * program.helpCommand('help [cmd]');
1365
- * program.helpCommand('help [cmd]', 'show help');
1366
- * program.helpCommand(false); // suppress default help command
1367
- * program.helpCommand(true); // add help command even if no subcommands
1368
- *
1369
- * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added
1370
- * @param {string} [description] - custom description
1371
- * @return {Command} `this` command for chaining
1372
- */
1373
- helpCommand(enableOrNameAndArgs, description$1) {
1374
- if (typeof enableOrNameAndArgs === "boolean") {
1375
- this._addImplicitHelpCommand = enableOrNameAndArgs;
1376
- return this;
1377
- }
1378
- enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]";
1379
- const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
1380
- const helpDescription = description$1 ?? "display help for command";
1381
- const helpCommand = this.createCommand(helpName);
1382
- helpCommand.helpOption(false);
1383
- if (helpArgs) helpCommand.arguments(helpArgs);
1384
- if (helpDescription) helpCommand.description(helpDescription);
1385
- this._addImplicitHelpCommand = true;
1386
- this._helpCommand = helpCommand;
1387
- return this;
1388
- }
1389
- /**
1390
- * Add prepared custom help command.
1391
- *
1392
- * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`
1393
- * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only
1394
- * @return {Command} `this` command for chaining
1395
- */
1396
- addHelpCommand(helpCommand, deprecatedDescription) {
1397
- if (typeof helpCommand !== "object") {
1398
- this.helpCommand(helpCommand, deprecatedDescription);
1399
- return this;
1400
- }
1401
- this._addImplicitHelpCommand = true;
1402
- this._helpCommand = helpCommand;
1403
- return this;
1404
- }
1405
- /**
1406
- * Lazy create help command.
1407
- *
1408
- * @return {(Command|null)}
1409
- * @package
1410
- */
1411
- _getHelpCommand() {
1412
- const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
1413
- if (hasImplicitHelpCommand) {
1414
- if (this._helpCommand === undefined) this.helpCommand(undefined, undefined);
1415
- return this._helpCommand;
1416
- }
1417
- return null;
1418
- }
1419
- /**
1420
- * Add hook for life cycle event.
1421
- *
1422
- * @param {string} event
1423
- * @param {Function} listener
1424
- * @return {Command} `this` command for chaining
1425
- */
1426
- hook(event, listener) {
1427
- const allowedValues = [
1428
- "preSubcommand",
1429
- "preAction",
1430
- "postAction"
1431
- ];
1432
- if (!allowedValues.includes(event)) throw new Error(`Unexpected value for event passed to hook : '${event}'.
1433
- Expecting one of '${allowedValues.join("', '")}'`);
1434
- if (this._lifeCycleHooks[event]) this._lifeCycleHooks[event].push(listener);
1435
- else this._lifeCycleHooks[event] = [listener];
1436
- return this;
1437
- }
1438
- /**
1439
- * Register callback to use as replacement for calling process.exit.
1440
- *
1441
- * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
1442
- * @return {Command} `this` command for chaining
1443
- */
1444
- exitOverride(fn) {
1445
- if (fn) this._exitCallback = fn;
1446
- else this._exitCallback = (err) => {
1447
- if (err.code !== "commander.executeSubCommandAsync") throw err;
1448
- else {}
1449
- };
1450
- return this;
1451
- }
1452
- /**
1453
- * Call process.exit, and _exitCallback if defined.
1454
- *
1455
- * @param {number} exitCode exit code for using with process.exit
1456
- * @param {string} code an id string representing the error
1457
- * @param {string} message human-readable description of the error
1458
- * @return never
1459
- * @private
1460
- */
1461
- _exit(exitCode, code, message) {
1462
- if (this._exitCallback) this._exitCallback(new CommanderError$2(exitCode, code, message));
1463
- process$2.exit(exitCode);
1464
- }
1465
- /**
1466
- * Register callback `fn` for the command.
1467
- *
1468
- * @example
1469
- * program
1470
- * .command('serve')
1471
- * .description('start service')
1472
- * .action(function() {
1473
- * // do work here
1474
- * });
1475
- *
1476
- * @param {Function} fn
1477
- * @return {Command} `this` command for chaining
1478
- */
1479
- action(fn) {
1480
- const listener = (args) => {
1481
- const expectedArgsCount = this.registeredArguments.length;
1482
- const actionArgs = args.slice(0, expectedArgsCount);
1483
- if (this._storeOptionsAsProperties) actionArgs[expectedArgsCount] = this;
1484
- else actionArgs[expectedArgsCount] = this.opts();
1485
- actionArgs.push(this);
1486
- return fn.apply(this, actionArgs);
1487
- };
1488
- this._actionHandler = listener;
1489
- return this;
1490
- }
1491
- /**
1492
- * Factory routine to create a new unattached option.
1493
- *
1494
- * See .option() for creating an attached option, which uses this routine to
1495
- * create the option. You can override createOption to return a custom option.
1496
- *
1497
- * @param {string} flags
1498
- * @param {string} [description]
1499
- * @return {Option} new option
1500
- */
1501
- createOption(flags, description$1) {
1502
- return new Option$2(flags, description$1);
1503
- }
1504
- /**
1505
- * Wrap parseArgs to catch 'commander.invalidArgument'.
1506
- *
1507
- * @param {(Option | Argument)} target
1508
- * @param {string} value
1509
- * @param {*} previous
1510
- * @param {string} invalidArgumentMessage
1511
- * @private
1512
- */
1513
- _callParseArg(target, value, previous, invalidArgumentMessage) {
1514
- try {
1515
- return target.parseArg(value, previous);
1516
- } catch (err) {
1517
- if (err.code === "commander.invalidArgument") {
1518
- const message = `${invalidArgumentMessage} ${err.message}`;
1519
- this.error(message, {
1520
- exitCode: err.exitCode,
1521
- code: err.code
1522
- });
1523
- }
1524
- throw err;
1525
- }
1526
- }
1527
- /**
1528
- * Check for option flag conflicts.
1529
- * Register option if no conflicts found, or throw on conflict.
1530
- *
1531
- * @param {Option} option
1532
- * @private
1533
- */
1534
- _registerOption(option) {
1535
- const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
1536
- if (matchingOption) {
1537
- const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
1538
- throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1539
- - already used by option '${matchingOption.flags}'`);
1540
- }
1541
- this.options.push(option);
1542
- }
1543
- /**
1544
- * Check for command name and alias conflicts with existing commands.
1545
- * Register command if no conflicts found, or throw on conflict.
1546
- *
1547
- * @param {Command} command
1548
- * @private
1549
- */
1550
- _registerCommand(command) {
1551
- const knownBy = (cmd) => {
1552
- return [cmd.name()].concat(cmd.aliases());
1553
- };
1554
- const alreadyUsed = knownBy(command).find((name$1) => this._findCommand(name$1));
1555
- if (alreadyUsed) {
1556
- const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
1557
- const newCmd = knownBy(command).join("|");
1558
- throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
1559
- }
1560
- this.commands.push(command);
1561
- }
1562
- /**
1563
- * Add an option.
1564
- *
1565
- * @param {Option} option
1566
- * @return {Command} `this` command for chaining
1567
- */
1568
- addOption(option) {
1569
- this._registerOption(option);
1570
- const oname = option.name();
1571
- const name$1 = option.attributeName();
1572
- if (option.negate) {
1573
- const positiveLongFlag = option.long.replace(/^--no-/, "--");
1574
- if (!this._findOption(positiveLongFlag)) this.setOptionValueWithSource(name$1, option.defaultValue === undefined ? true : option.defaultValue, "default");
1575
- } else if (option.defaultValue !== undefined) this.setOptionValueWithSource(name$1, option.defaultValue, "default");
1576
- const handleOptionValue = (val, invalidValueMessage, valueSource) => {
1577
- if (val == null && option.presetArg !== undefined) val = option.presetArg;
1578
- const oldValue = this.getOptionValue(name$1);
1579
- if (val !== null && option.parseArg) val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1580
- else if (val !== null && option.variadic) val = option._concatValue(val, oldValue);
1581
- if (val == null) if (option.negate) val = false;
1582
- else if (option.isBoolean() || option.optional) val = true;
1583
- else val = "";
1584
- this.setOptionValueWithSource(name$1, val, valueSource);
1585
- };
1586
- this.on("option:" + oname, (val) => {
1587
- const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1588
- handleOptionValue(val, invalidValueMessage, "cli");
1589
- });
1590
- if (option.envVar) this.on("optionEnv:" + oname, (val) => {
1591
- const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1592
- handleOptionValue(val, invalidValueMessage, "env");
1593
- });
1594
- return this;
1595
- }
1596
- /**
1597
- * Internal implementation shared by .option() and .requiredOption()
1598
- *
1599
- * @return {Command} `this` command for chaining
1600
- * @private
1601
- */
1602
- _optionEx(config, flags, description$1, fn, defaultValue) {
1603
- if (typeof flags === "object" && flags instanceof Option$2) throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
1604
- const option = this.createOption(flags, description$1);
1605
- option.makeOptionMandatory(!!config.mandatory);
1606
- if (typeof fn === "function") option.default(defaultValue).argParser(fn);
1607
- else if (fn instanceof RegExp) {
1608
- const regex$1 = fn;
1609
- fn = (val, def) => {
1610
- const m = regex$1.exec(val);
1611
- return m ? m[0] : def;
1612
- };
1613
- option.default(defaultValue).argParser(fn);
1614
- } else option.default(fn);
1615
- return this.addOption(option);
1616
- }
1617
- /**
1618
- * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
1619
- *
1620
- * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
1621
- * option-argument is indicated by `<>` and an optional option-argument by `[]`.
1622
- *
1623
- * See the README for more details, and see also addOption() and requiredOption().
1624
- *
1625
- * @example
1626
- * program
1627
- * .option('-p, --pepper', 'add pepper')
1628
- * .option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
1629
- * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
1630
- * .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
1631
- *
1632
- * @param {string} flags
1633
- * @param {string} [description]
1634
- * @param {(Function|*)} [parseArg] - custom option processing function or default value
1635
- * @param {*} [defaultValue]
1636
- * @return {Command} `this` command for chaining
1637
- */
1638
- option(flags, description$1, parseArg, defaultValue) {
1639
- return this._optionEx({}, flags, description$1, parseArg, defaultValue);
1640
- }
1641
- /**
1642
- * Add a required option which must have a value after parsing. This usually means
1643
- * the option must be specified on the command line. (Otherwise the same as .option().)
1644
- *
1645
- * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1646
- *
1647
- * @param {string} flags
1648
- * @param {string} [description]
1649
- * @param {(Function|*)} [parseArg] - custom option processing function or default value
1650
- * @param {*} [defaultValue]
1651
- * @return {Command} `this` command for chaining
1652
- */
1653
- requiredOption(flags, description$1, parseArg, defaultValue) {
1654
- return this._optionEx({ mandatory: true }, flags, description$1, parseArg, defaultValue);
1655
- }
1656
- /**
1657
- * Alter parsing of short flags with optional values.
1658
- *
1659
- * @example
1660
- * // for `.option('-f,--flag [value]'):
1661
- * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1662
- * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1663
- *
1664
- * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
1665
- * @return {Command} `this` command for chaining
1666
- */
1667
- combineFlagAndOptionalValue(combine = true) {
1668
- this._combineFlagAndOptionalValue = !!combine;
1669
- return this;
1670
- }
1671
- /**
1672
- * Allow unknown options on the command line.
1673
- *
1674
- * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
1675
- * @return {Command} `this` command for chaining
1676
- */
1677
- allowUnknownOption(allowUnknown = true) {
1678
- this._allowUnknownOption = !!allowUnknown;
1679
- return this;
1680
- }
1681
- /**
1682
- * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1683
- *
1684
- * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
1685
- * @return {Command} `this` command for chaining
1686
- */
1687
- allowExcessArguments(allowExcess = true) {
1688
- this._allowExcessArguments = !!allowExcess;
1689
- return this;
1690
- }
1691
- /**
1692
- * Enable positional options. Positional means global options are specified before subcommands which lets
1693
- * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1694
- * The default behaviour is non-positional and global options may appear anywhere on the command line.
1695
- *
1696
- * @param {boolean} [positional]
1697
- * @return {Command} `this` command for chaining
1698
- */
1699
- enablePositionalOptions(positional = true) {
1700
- this._enablePositionalOptions = !!positional;
1701
- return this;
1702
- }
1703
- /**
1704
- * Pass through options that come after command-arguments rather than treat them as command-options,
1705
- * so actual command-options come before command-arguments. Turning this on for a subcommand requires
1706
- * positional options to have been enabled on the program (parent commands).
1707
- * The default behaviour is non-positional and options may appear before or after command-arguments.
1708
- *
1709
- * @param {boolean} [passThrough] for unknown options.
1710
- * @return {Command} `this` command for chaining
1711
- */
1712
- passThroughOptions(passThrough = true) {
1713
- this._passThroughOptions = !!passThrough;
1714
- this._checkForBrokenPassThrough();
1715
- return this;
1716
- }
1717
- /**
1718
- * @private
1719
- */
1720
- _checkForBrokenPassThrough() {
1721
- if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
1722
- }
1723
- /**
1724
- * Whether to store option values as properties on command object,
1725
- * or store separately (specify false). In both cases the option values can be accessed using .opts().
1726
- *
1727
- * @param {boolean} [storeAsProperties=true]
1728
- * @return {Command} `this` command for chaining
1729
- */
1730
- storeOptionsAsProperties(storeAsProperties = true) {
1731
- if (this.options.length) throw new Error("call .storeOptionsAsProperties() before adding options");
1732
- if (Object.keys(this._optionValues).length) throw new Error("call .storeOptionsAsProperties() before setting option values");
1733
- this._storeOptionsAsProperties = !!storeAsProperties;
1734
- return this;
1735
- }
1736
- /**
1737
- * Retrieve option value.
1738
- *
1739
- * @param {string} key
1740
- * @return {object} value
1741
- */
1742
- getOptionValue(key) {
1743
- if (this._storeOptionsAsProperties) return this[key];
1744
- return this._optionValues[key];
1745
- }
1746
- /**
1747
- * Store option value.
1748
- *
1749
- * @param {string} key
1750
- * @param {object} value
1751
- * @return {Command} `this` command for chaining
1752
- */
1753
- setOptionValue(key, value) {
1754
- return this.setOptionValueWithSource(key, value, undefined);
1755
- }
1756
- /**
1757
- * Store option value and where the value came from.
1758
- *
1759
- * @param {string} key
1760
- * @param {object} value
1761
- * @param {string} source - expected values are default/config/env/cli/implied
1762
- * @return {Command} `this` command for chaining
1763
- */
1764
- setOptionValueWithSource(key, value, source) {
1765
- if (this._storeOptionsAsProperties) this[key] = value;
1766
- else this._optionValues[key] = value;
1767
- this._optionValueSources[key] = source;
1768
- return this;
1769
- }
1770
- /**
1771
- * Get source of option value.
1772
- * Expected values are default | config | env | cli | implied
1773
- *
1774
- * @param {string} key
1775
- * @return {string}
1776
- */
1777
- getOptionValueSource(key) {
1778
- return this._optionValueSources[key];
1779
- }
1780
- /**
1781
- * Get source of option value. See also .optsWithGlobals().
1782
- * Expected values are default | config | env | cli | implied
1783
- *
1784
- * @param {string} key
1785
- * @return {string}
1786
- */
1787
- getOptionValueSourceWithGlobals(key) {
1788
- let source;
1789
- this._getCommandAndAncestors().forEach((cmd) => {
1790
- if (cmd.getOptionValueSource(key) !== undefined) source = cmd.getOptionValueSource(key);
1791
- });
1792
- return source;
1793
- }
1794
- /**
1795
- * Get user arguments from implied or explicit arguments.
1796
- * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
1797
- *
1798
- * @private
1799
- */
1800
- _prepareUserArgs(argv, parseOptions) {
1801
- if (argv !== undefined && !Array.isArray(argv)) throw new Error("first parameter to parse must be array or undefined");
1802
- parseOptions = parseOptions || {};
1803
- if (argv === undefined && parseOptions.from === undefined) {
1804
- if (process$2.versions?.electron) parseOptions.from = "electron";
1805
- const execArgv = process$2.execArgv ?? [];
1806
- if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) parseOptions.from = "eval";
1807
- }
1808
- if (argv === undefined) argv = process$2.argv;
1809
- this.rawArgs = argv.slice();
1810
- let userArgs;
1811
- switch (parseOptions.from) {
1812
- case undefined:
1813
- case "node":
1814
- this._scriptPath = argv[1];
1815
- userArgs = argv.slice(2);
1816
- break;
1817
- case "electron":
1818
- if (process$2.defaultApp) {
1819
- this._scriptPath = argv[1];
1820
- userArgs = argv.slice(2);
1821
- } else userArgs = argv.slice(1);
1822
- break;
1823
- case "user":
1824
- userArgs = argv.slice(0);
1825
- break;
1826
- case "eval":
1827
- userArgs = argv.slice(1);
1828
- break;
1829
- default: throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
1830
- }
1831
- if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath);
1832
- this._name = this._name || "program";
1833
- return userArgs;
1834
- }
1835
- /**
1836
- * Parse `argv`, setting options and invoking commands when defined.
1837
- *
1838
- * Use parseAsync instead of parse if any of your action handlers are async.
1839
- *
1840
- * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1841
- *
1842
- * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1843
- * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1844
- * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1845
- * - `'user'`: just user arguments
1846
- *
1847
- * @example
1848
- * program.parse(); // parse process.argv and auto-detect electron and special node flags
1849
- * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
1850
- * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1851
- *
1852
- * @param {string[]} [argv] - optional, defaults to process.argv
1853
- * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
1854
- * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
1855
- * @return {Command} `this` command for chaining
1856
- */
1857
- parse(argv, parseOptions) {
1858
- this._prepareForParse();
1859
- const userArgs = this._prepareUserArgs(argv, parseOptions);
1860
- this._parseCommand([], userArgs);
1861
- return this;
1862
- }
1863
- /**
1864
- * Parse `argv`, setting options and invoking commands when defined.
1865
- *
1866
- * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1867
- *
1868
- * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1869
- * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1870
- * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1871
- * - `'user'`: just user arguments
1872
- *
1873
- * @example
1874
- * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
1875
- * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
1876
- * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1877
- *
1878
- * @param {string[]} [argv]
1879
- * @param {object} [parseOptions]
1880
- * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
1881
- * @return {Promise}
1882
- */
1883
- async parseAsync(argv, parseOptions) {
1884
- this._prepareForParse();
1885
- const userArgs = this._prepareUserArgs(argv, parseOptions);
1886
- await this._parseCommand([], userArgs);
1887
- return this;
1888
- }
1889
- _prepareForParse() {
1890
- if (this._savedState === null) this.saveStateBeforeParse();
1891
- else this.restoreStateBeforeParse();
1892
- }
1893
- /**
1894
- * Called the first time parse is called to save state and allow a restore before subsequent calls to parse.
1895
- * Not usually called directly, but available for subclasses to save their custom state.
1896
- *
1897
- * This is called in a lazy way. Only commands used in parsing chain will have state saved.
1898
- */
1899
- saveStateBeforeParse() {
1900
- this._savedState = {
1901
- _name: this._name,
1902
- _optionValues: { ...this._optionValues },
1903
- _optionValueSources: { ...this._optionValueSources }
1904
- };
1905
- }
1906
- /**
1907
- * Restore state before parse for calls after the first.
1908
- * Not usually called directly, but available for subclasses to save their custom state.
1909
- *
1910
- * This is called in a lazy way. Only commands used in parsing chain will have state restored.
1911
- */
1912
- restoreStateBeforeParse() {
1913
- if (this._storeOptionsAsProperties) throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
1914
- - either make a new Command for each call to parse, or stop storing options as properties`);
1915
- this._name = this._savedState._name;
1916
- this._scriptPath = null;
1917
- this.rawArgs = [];
1918
- this._optionValues = { ...this._savedState._optionValues };
1919
- this._optionValueSources = { ...this._savedState._optionValueSources };
1920
- this.args = [];
1921
- this.processedArgs = [];
1922
- }
1923
- /**
1924
- * Throw if expected executable is missing. Add lots of help for author.
1925
- *
1926
- * @param {string} executableFile
1927
- * @param {string} executableDir
1928
- * @param {string} subcommandName
1929
- */
1930
- _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
1931
- if (fs$3.existsSync(executableFile)) return;
1932
- const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
1933
- const executableMissing = `'${executableFile}' does not exist
1934
- - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
1935
- - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
1936
- - ${executableDirMessage}`;
1937
- throw new Error(executableMissing);
1938
- }
1939
- /**
1940
- * Execute a sub-command executable.
1941
- *
1942
- * @private
1943
- */
1944
- _executeSubCommand(subcommand, args) {
1945
- args = args.slice();
1946
- let launchWithNode = false;
1947
- const sourceExt = [
1948
- ".js",
1949
- ".ts",
1950
- ".tsx",
1951
- ".mjs",
1952
- ".cjs"
1953
- ];
1954
- function findFile(baseDir, baseName) {
1955
- const localBin = path$2.resolve(baseDir, baseName);
1956
- if (fs$3.existsSync(localBin)) return localBin;
1957
- if (sourceExt.includes(path$2.extname(baseName))) return undefined;
1958
- const foundExt = sourceExt.find((ext) => fs$3.existsSync(`${localBin}${ext}`));
1959
- if (foundExt) return `${localBin}${foundExt}`;
1960
- return undefined;
1961
- }
1962
- this._checkForMissingMandatoryOptions();
1963
- this._checkForConflictingOptions();
1964
- let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
1965
- let executableDir = this._executableDir || "";
1966
- if (this._scriptPath) {
1967
- let resolvedScriptPath;
1968
- try {
1969
- resolvedScriptPath = fs$3.realpathSync(this._scriptPath);
1970
- } catch {
1971
- resolvedScriptPath = this._scriptPath;
1972
- }
1973
- executableDir = path$2.resolve(path$2.dirname(resolvedScriptPath), executableDir);
1974
- }
1975
- if (executableDir) {
1976
- let localFile = findFile(executableDir, executableFile);
1977
- if (!localFile && !subcommand._executableFile && this._scriptPath) {
1978
- const legacyName = path$2.basename(this._scriptPath, path$2.extname(this._scriptPath));
1979
- if (legacyName !== this._name) localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1980
- }
1981
- executableFile = localFile || executableFile;
1982
- }
1983
- launchWithNode = sourceExt.includes(path$2.extname(executableFile));
1984
- let proc;
1985
- if (process$2.platform !== "win32") if (launchWithNode) {
1986
- args.unshift(executableFile);
1987
- args = incrementNodeInspectorPort(process$2.execArgv).concat(args);
1988
- proc = childProcess.spawn(process$2.argv[0], args, { stdio: "inherit" });
1989
- } else proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1990
- else {
1991
- this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
1992
- args.unshift(executableFile);
1993
- args = incrementNodeInspectorPort(process$2.execArgv).concat(args);
1994
- proc = childProcess.spawn(process$2.execPath, args, { stdio: "inherit" });
1995
- }
1996
- if (!proc.killed) {
1997
- const signals = [
1998
- "SIGUSR1",
1999
- "SIGUSR2",
2000
- "SIGTERM",
2001
- "SIGINT",
2002
- "SIGHUP"
2003
- ];
2004
- signals.forEach((signal) => {
2005
- process$2.on(signal, () => {
2006
- if (proc.killed === false && proc.exitCode === null) proc.kill(signal);
2007
- });
2008
- });
2009
- }
2010
- const exitCallback = this._exitCallback;
2011
- proc.on("close", (code) => {
2012
- code = code ?? 1;
2013
- if (!exitCallback) process$2.exit(code);
2014
- else exitCallback(new CommanderError$2(code, "commander.executeSubCommandAsync", "(close)"));
2015
- });
2016
- proc.on("error", (err) => {
2017
- if (err.code === "ENOENT") this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
2018
- else if (err.code === "EACCES") throw new Error(`'${executableFile}' not executable`);
2019
- if (!exitCallback) process$2.exit(1);
2020
- else {
2021
- const wrappedError = new CommanderError$2(1, "commander.executeSubCommandAsync", "(error)");
2022
- wrappedError.nestedError = err;
2023
- exitCallback(wrappedError);
2024
- }
2025
- });
2026
- this.runningCommand = proc;
2027
- }
2028
- /**
2029
- * @private
2030
- */
2031
- _dispatchSubcommand(commandName, operands, unknown) {
2032
- const subCommand = this._findCommand(commandName);
2033
- if (!subCommand) this.help({ error: true });
2034
- subCommand._prepareForParse();
2035
- let promiseChain;
2036
- promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
2037
- promiseChain = this._chainOrCall(promiseChain, () => {
2038
- if (subCommand._executableHandler) this._executeSubCommand(subCommand, operands.concat(unknown));
2039
- else return subCommand._parseCommand(operands, unknown);
2040
- });
2041
- return promiseChain;
2042
- }
2043
- /**
2044
- * Invoke help directly if possible, or dispatch if necessary.
2045
- * e.g. help foo
2046
- *
2047
- * @private
2048
- */
2049
- _dispatchHelpCommand(subcommandName) {
2050
- if (!subcommandName) this.help();
2051
- const subCommand = this._findCommand(subcommandName);
2052
- if (subCommand && !subCommand._executableHandler) subCommand.help();
2053
- return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
2054
- }
2055
- /**
2056
- * Check this.args against expected this.registeredArguments.
2057
- *
2058
- * @private
2059
- */
2060
- _checkNumberOfArguments() {
2061
- this.registeredArguments.forEach((arg, i) => {
2062
- if (arg.required && this.args[i] == null) this.missingArgument(arg.name());
2063
- });
2064
- if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) return;
2065
- if (this.args.length > this.registeredArguments.length) this._excessArguments(this.args);
2066
- }
2067
- /**
2068
- * Process this.args using this.registeredArguments and save as this.processedArgs!
2069
- *
2070
- * @private
2071
- */
2072
- _processArguments() {
2073
- const myParseArg = (argument, value, previous) => {
2074
- let parsedValue = value;
2075
- if (value !== null && argument.parseArg) {
2076
- const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
2077
- parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
2078
- }
2079
- return parsedValue;
2080
- };
2081
- this._checkNumberOfArguments();
2082
- const processedArgs = [];
2083
- this.registeredArguments.forEach((declaredArg, index) => {
2084
- let value = declaredArg.defaultValue;
2085
- if (declaredArg.variadic) {
2086
- if (index < this.args.length) {
2087
- value = this.args.slice(index);
2088
- if (declaredArg.parseArg) value = value.reduce((processed, v) => {
2089
- return myParseArg(declaredArg, v, processed);
2090
- }, declaredArg.defaultValue);
2091
- } else if (value === undefined) value = [];
2092
- } else if (index < this.args.length) {
2093
- value = this.args[index];
2094
- if (declaredArg.parseArg) value = myParseArg(declaredArg, value, declaredArg.defaultValue);
2095
- }
2096
- processedArgs[index] = value;
2097
- });
2098
- this.processedArgs = processedArgs;
2099
- }
2100
- /**
2101
- * Once we have a promise we chain, but call synchronously until then.
2102
- *
2103
- * @param {(Promise|undefined)} promise
2104
- * @param {Function} fn
2105
- * @return {(Promise|undefined)}
2106
- * @private
2107
- */
2108
- _chainOrCall(promise, fn) {
2109
- if (promise && promise.then && typeof promise.then === "function") return promise.then(() => fn());
2110
- return fn();
2111
- }
2112
- /**
2113
- *
2114
- * @param {(Promise|undefined)} promise
2115
- * @param {string} event
2116
- * @return {(Promise|undefined)}
2117
- * @private
2118
- */
2119
- _chainOrCallHooks(promise, event) {
2120
- let result = promise;
2121
- const hooks = [];
2122
- this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
2123
- hookedCommand._lifeCycleHooks[event].forEach((callback) => {
2124
- hooks.push({
2125
- hookedCommand,
2126
- callback
2127
- });
2128
- });
2129
- });
2130
- if (event === "postAction") hooks.reverse();
2131
- hooks.forEach((hookDetail) => {
2132
- result = this._chainOrCall(result, () => {
2133
- return hookDetail.callback(hookDetail.hookedCommand, this);
2134
- });
2135
- });
2136
- return result;
2137
- }
2138
- /**
2139
- *
2140
- * @param {(Promise|undefined)} promise
2141
- * @param {Command} subCommand
2142
- * @param {string} event
2143
- * @return {(Promise|undefined)}
2144
- * @private
2145
- */
2146
- _chainOrCallSubCommandHook(promise, subCommand, event) {
2147
- let result = promise;
2148
- if (this._lifeCycleHooks[event] !== undefined) this._lifeCycleHooks[event].forEach((hook) => {
2149
- result = this._chainOrCall(result, () => {
2150
- return hook(this, subCommand);
2151
- });
2152
- });
2153
- return result;
2154
- }
2155
- /**
2156
- * Process arguments in context of this command.
2157
- * Returns action result, in case it is a promise.
2158
- *
2159
- * @private
2160
- */
2161
- _parseCommand(operands, unknown) {
2162
- const parsed = this.parseOptions(unknown);
2163
- this._parseOptionsEnv();
2164
- this._parseOptionsImplied();
2165
- operands = operands.concat(parsed.operands);
2166
- unknown = parsed.unknown;
2167
- this.args = operands.concat(unknown);
2168
- if (operands && this._findCommand(operands[0])) return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
2169
- if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) return this._dispatchHelpCommand(operands[1]);
2170
- if (this._defaultCommandName) {
2171
- this._outputHelpIfRequested(unknown);
2172
- return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
2173
- }
2174
- if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) this.help({ error: true });
2175
- this._outputHelpIfRequested(parsed.unknown);
2176
- this._checkForMissingMandatoryOptions();
2177
- this._checkForConflictingOptions();
2178
- const checkForUnknownOptions = () => {
2179
- if (parsed.unknown.length > 0) this.unknownOption(parsed.unknown[0]);
2180
- };
2181
- const commandEvent = `command:${this.name()}`;
2182
- if (this._actionHandler) {
2183
- checkForUnknownOptions();
2184
- this._processArguments();
2185
- let promiseChain;
2186
- promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
2187
- promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
2188
- if (this.parent) promiseChain = this._chainOrCall(promiseChain, () => {
2189
- this.parent.emit(commandEvent, operands, unknown);
2190
- });
2191
- promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
2192
- return promiseChain;
2193
- }
2194
- if (this.parent && this.parent.listenerCount(commandEvent)) {
2195
- checkForUnknownOptions();
2196
- this._processArguments();
2197
- this.parent.emit(commandEvent, operands, unknown);
2198
- } else if (operands.length) {
2199
- if (this._findCommand("*")) return this._dispatchSubcommand("*", operands, unknown);
2200
- if (this.listenerCount("command:*")) this.emit("command:*", operands, unknown);
2201
- else if (this.commands.length) this.unknownCommand();
2202
- else {
2203
- checkForUnknownOptions();
2204
- this._processArguments();
2205
- }
2206
- } else if (this.commands.length) {
2207
- checkForUnknownOptions();
2208
- this.help({ error: true });
2209
- } else {
2210
- checkForUnknownOptions();
2211
- this._processArguments();
2212
- }
2213
- }
2214
- /**
2215
- * Find matching command.
2216
- *
2217
- * @private
2218
- * @return {Command | undefined}
2219
- */
2220
- _findCommand(name$1) {
2221
- if (!name$1) return undefined;
2222
- return this.commands.find((cmd) => cmd._name === name$1 || cmd._aliases.includes(name$1));
2223
- }
2224
- /**
2225
- * Return an option matching `arg` if any.
2226
- *
2227
- * @param {string} arg
2228
- * @return {Option}
2229
- * @package
2230
- */
2231
- _findOption(arg) {
2232
- return this.options.find((option) => option.is(arg));
2233
- }
2234
- /**
2235
- * Display an error message if a mandatory option does not have a value.
2236
- * Called after checking for help flags in leaf subcommand.
2237
- *
2238
- * @private
2239
- */
2240
- _checkForMissingMandatoryOptions() {
2241
- this._getCommandAndAncestors().forEach((cmd) => {
2242
- cmd.options.forEach((anOption) => {
2243
- if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) cmd.missingMandatoryOptionValue(anOption);
2244
- });
2245
- });
2246
- }
2247
- /**
2248
- * Display an error message if conflicting options are used together in this.
2249
- *
2250
- * @private
2251
- */
2252
- _checkForConflictingLocalOptions() {
2253
- const definedNonDefaultOptions = this.options.filter((option) => {
2254
- const optionKey = option.attributeName();
2255
- if (this.getOptionValue(optionKey) === undefined) return false;
2256
- return this.getOptionValueSource(optionKey) !== "default";
2257
- });
2258
- const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
2259
- optionsWithConflicting.forEach((option) => {
2260
- const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
2261
- if (conflictingAndDefined) this._conflictingOption(option, conflictingAndDefined);
2262
- });
2263
- }
2264
- /**
2265
- * Display an error message if conflicting options are used together.
2266
- * Called after checking for help flags in leaf subcommand.
2267
- *
2268
- * @private
2269
- */
2270
- _checkForConflictingOptions() {
2271
- this._getCommandAndAncestors().forEach((cmd) => {
2272
- cmd._checkForConflictingLocalOptions();
2273
- });
2274
- }
2275
- /**
2276
- * Parse options from `argv` removing known options,
2277
- * and return argv split into operands and unknown arguments.
2278
- *
2279
- * Side effects: modifies command by storing options. Does not reset state if called again.
2280
- *
2281
- * Examples:
2282
- *
2283
- * argv => operands, unknown
2284
- * --known kkk op => [op], []
2285
- * op --known kkk => [op], []
2286
- * sub --unknown uuu op => [sub], [--unknown uuu op]
2287
- * sub -- --unknown uuu op => [sub --unknown uuu op], []
2288
- *
2289
- * @param {string[]} argv
2290
- * @return {{operands: string[], unknown: string[]}}
2291
- */
2292
- parseOptions(argv) {
2293
- const operands = [];
2294
- const unknown = [];
2295
- let dest = operands;
2296
- const args = argv.slice();
2297
- function maybeOption(arg) {
2298
- return arg.length > 1 && arg[0] === "-";
2299
- }
2300
- let activeVariadicOption = null;
2301
- while (args.length) {
2302
- const arg = args.shift();
2303
- if (arg === "--") {
2304
- if (dest === unknown) dest.push(arg);
2305
- dest.push(...args);
2306
- break;
2307
- }
2308
- if (activeVariadicOption && !maybeOption(arg)) {
2309
- this.emit(`option:${activeVariadicOption.name()}`, arg);
2310
- continue;
2311
- }
2312
- activeVariadicOption = null;
2313
- if (maybeOption(arg)) {
2314
- const option = this._findOption(arg);
2315
- if (option) {
2316
- if (option.required) {
2317
- const value = args.shift();
2318
- if (value === undefined) this.optionMissingArgument(option);
2319
- this.emit(`option:${option.name()}`, value);
2320
- } else if (option.optional) {
2321
- let value = null;
2322
- if (args.length > 0 && !maybeOption(args[0])) value = args.shift();
2323
- this.emit(`option:${option.name()}`, value);
2324
- } else this.emit(`option:${option.name()}`);
2325
- activeVariadicOption = option.variadic ? option : null;
2326
- continue;
2327
- }
2328
- }
2329
- if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
2330
- const option = this._findOption(`-${arg[1]}`);
2331
- if (option) {
2332
- if (option.required || option.optional && this._combineFlagAndOptionalValue) this.emit(`option:${option.name()}`, arg.slice(2));
2333
- else {
2334
- this.emit(`option:${option.name()}`);
2335
- args.unshift(`-${arg.slice(2)}`);
2336
- }
2337
- continue;
2338
- }
2339
- }
2340
- if (/^--[^=]+=/.test(arg)) {
2341
- const index = arg.indexOf("=");
2342
- const option = this._findOption(arg.slice(0, index));
2343
- if (option && (option.required || option.optional)) {
2344
- this.emit(`option:${option.name()}`, arg.slice(index + 1));
2345
- continue;
2346
- }
2347
- }
2348
- if (maybeOption(arg)) dest = unknown;
2349
- if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2350
- if (this._findCommand(arg)) {
2351
- operands.push(arg);
2352
- if (args.length > 0) unknown.push(...args);
2353
- break;
2354
- } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
2355
- operands.push(arg);
2356
- if (args.length > 0) operands.push(...args);
2357
- break;
2358
- } else if (this._defaultCommandName) {
2359
- unknown.push(arg);
2360
- if (args.length > 0) unknown.push(...args);
2361
- break;
2362
- }
2363
- }
2364
- if (this._passThroughOptions) {
2365
- dest.push(arg);
2366
- if (args.length > 0) dest.push(...args);
2367
- break;
2368
- }
2369
- dest.push(arg);
2370
- }
2371
- return {
2372
- operands,
2373
- unknown
2374
- };
2375
- }
2376
- /**
2377
- * Return an object containing local option values as key-value pairs.
2378
- *
2379
- * @return {object}
2380
- */
2381
- opts() {
2382
- if (this._storeOptionsAsProperties) {
2383
- const result = {};
2384
- const len = this.options.length;
2385
- for (let i = 0; i < len; i++) {
2386
- const key = this.options[i].attributeName();
2387
- result[key] = key === this._versionOptionName ? this._version : this[key];
2388
- }
2389
- return result;
2390
- }
2391
- return this._optionValues;
2392
- }
2393
- /**
2394
- * Return an object containing merged local and global option values as key-value pairs.
2395
- *
2396
- * @return {object}
2397
- */
2398
- optsWithGlobals() {
2399
- return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
2400
- }
2401
- /**
2402
- * Display error message and exit (or call exitOverride).
2403
- *
2404
- * @param {string} message
2405
- * @param {object} [errorOptions]
2406
- * @param {string} [errorOptions.code] - an id string representing the error
2407
- * @param {number} [errorOptions.exitCode] - used with process.exit
2408
- */
2409
- error(message, errorOptions) {
2410
- this._outputConfiguration.outputError(`${message}\n`, this._outputConfiguration.writeErr);
2411
- if (typeof this._showHelpAfterError === "string") this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`);
2412
- else if (this._showHelpAfterError) {
2413
- this._outputConfiguration.writeErr("\n");
2414
- this.outputHelp({ error: true });
2415
- }
2416
- const config = errorOptions || {};
2417
- const exitCode = config.exitCode || 1;
2418
- const code = config.code || "commander.error";
2419
- this._exit(exitCode, code, message);
2420
- }
2421
- /**
2422
- * Apply any option related environment variables, if option does
2423
- * not have a value from cli or client code.
2424
- *
2425
- * @private
2426
- */
2427
- _parseOptionsEnv() {
2428
- this.options.forEach((option) => {
2429
- if (option.envVar && option.envVar in process$2.env) {
2430
- const optionKey = option.attributeName();
2431
- if (this.getOptionValue(optionKey) === undefined || [
2432
- "default",
2433
- "config",
2434
- "env"
2435
- ].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$2.env[option.envVar]);
2436
- else this.emit(`optionEnv:${option.name()}`);
2437
- }
2438
- });
2439
- }
2440
- /**
2441
- * Apply any implied option values, if option is undefined or default value.
2442
- *
2443
- * @private
2444
- */
2445
- _parseOptionsImplied() {
2446
- const dualHelper = new DualOptions(this.options);
2447
- const hasCustomOptionValue = (optionKey) => {
2448
- return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
2449
- };
2450
- this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
2451
- Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
2452
- this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
2453
- });
2454
- });
2455
- }
2456
- /**
2457
- * Argument `name` is missing.
2458
- *
2459
- * @param {string} name
2460
- * @private
2461
- */
2462
- missingArgument(name$1) {
2463
- const message = `error: missing required argument '${name$1}'`;
2464
- this.error(message, { code: "commander.missingArgument" });
2465
- }
2466
- /**
2467
- * `Option` is missing an argument.
2468
- *
2469
- * @param {Option} option
2470
- * @private
2471
- */
2472
- optionMissingArgument(option) {
2473
- const message = `error: option '${option.flags}' argument missing`;
2474
- this.error(message, { code: "commander.optionMissingArgument" });
2475
- }
2476
- /**
2477
- * `Option` does not have a value, and is a mandatory option.
2478
- *
2479
- * @param {Option} option
2480
- * @private
2481
- */
2482
- missingMandatoryOptionValue(option) {
2483
- const message = `error: required option '${option.flags}' not specified`;
2484
- this.error(message, { code: "commander.missingMandatoryOptionValue" });
2485
- }
2486
- /**
2487
- * `Option` conflicts with another option.
2488
- *
2489
- * @param {Option} option
2490
- * @param {Option} conflictingOption
2491
- * @private
2492
- */
2493
- _conflictingOption(option, conflictingOption) {
2494
- const findBestOptionFromValue = (option$1) => {
2495
- const optionKey = option$1.attributeName();
2496
- const optionValue = this.getOptionValue(optionKey);
2497
- const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
2498
- const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
2499
- if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) return negativeOption;
2500
- return positiveOption || option$1;
2501
- };
2502
- const getErrorMessage = (option$1) => {
2503
- const bestOption = findBestOptionFromValue(option$1);
2504
- const optionKey = bestOption.attributeName();
2505
- const source = this.getOptionValueSource(optionKey);
2506
- if (source === "env") return `environment variable '${bestOption.envVar}'`;
2507
- return `option '${bestOption.flags}'`;
2508
- };
2509
- const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2510
- this.error(message, { code: "commander.conflictingOption" });
2511
- }
2512
- /**
2513
- * Unknown option `flag`.
2514
- *
2515
- * @param {string} flag
2516
- * @private
2517
- */
2518
- unknownOption(flag) {
2519
- if (this._allowUnknownOption) return;
2520
- let suggestion = "";
2521
- if (flag.startsWith("--") && this._showSuggestionAfterError) {
2522
- let candidateFlags = [];
2523
- let command = this;
2524
- do {
2525
- const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
2526
- candidateFlags = candidateFlags.concat(moreFlags);
2527
- command = command.parent;
2528
- } while (command && !command._enablePositionalOptions);
2529
- suggestion = suggestSimilar(flag, candidateFlags);
2530
- }
2531
- const message = `error: unknown option '${flag}'${suggestion}`;
2532
- this.error(message, { code: "commander.unknownOption" });
2533
- }
2534
- /**
2535
- * Excess arguments, more than expected.
2536
- *
2537
- * @param {string[]} receivedArgs
2538
- * @private
2539
- */
2540
- _excessArguments(receivedArgs) {
2541
- if (this._allowExcessArguments) return;
2542
- const expected = this.registeredArguments.length;
2543
- const s$1 = expected === 1 ? "" : "s";
2544
- const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
2545
- const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s$1} but got ${receivedArgs.length}.`;
2546
- this.error(message, { code: "commander.excessArguments" });
2547
- }
2548
- /**
2549
- * Unknown command.
2550
- *
2551
- * @private
2552
- */
2553
- unknownCommand() {
2554
- const unknownName = this.args[0];
2555
- let suggestion = "";
2556
- if (this._showSuggestionAfterError) {
2557
- const candidateNames = [];
2558
- this.createHelp().visibleCommands(this).forEach((command) => {
2559
- candidateNames.push(command.name());
2560
- if (command.alias()) candidateNames.push(command.alias());
2561
- });
2562
- suggestion = suggestSimilar(unknownName, candidateNames);
2563
- }
2564
- const message = `error: unknown command '${unknownName}'${suggestion}`;
2565
- this.error(message, { code: "commander.unknownCommand" });
2566
- }
2567
- /**
2568
- * Get or set the program version.
2569
- *
2570
- * This method auto-registers the "-V, --version" option which will print the version number.
2571
- *
2572
- * You can optionally supply the flags and description to override the defaults.
2573
- *
2574
- * @param {string} [str]
2575
- * @param {string} [flags]
2576
- * @param {string} [description]
2577
- * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
2578
- */
2579
- version(str, flags, description$1) {
2580
- if (str === undefined) return this._version;
2581
- this._version = str;
2582
- flags = flags || "-V, --version";
2583
- description$1 = description$1 || "output the version number";
2584
- const versionOption = this.createOption(flags, description$1);
2585
- this._versionOptionName = versionOption.attributeName();
2586
- this._registerOption(versionOption);
2587
- this.on("option:" + versionOption.name(), () => {
2588
- this._outputConfiguration.writeOut(`${str}\n`);
2589
- this._exit(0, "commander.version", str);
2590
- });
2591
- return this;
2592
- }
2593
- /**
2594
- * Set the description.
2595
- *
2596
- * @param {string} [str]
2597
- * @param {object} [argsDescription]
2598
- * @return {(string|Command)}
2599
- */
2600
- description(str, argsDescription) {
2601
- if (str === undefined && argsDescription === undefined) return this._description;
2602
- this._description = str;
2603
- if (argsDescription) this._argsDescription = argsDescription;
2604
- return this;
2605
- }
2606
- /**
2607
- * Set the summary. Used when listed as subcommand of parent.
2608
- *
2609
- * @param {string} [str]
2610
- * @return {(string|Command)}
2611
- */
2612
- summary(str) {
2613
- if (str === undefined) return this._summary;
2614
- this._summary = str;
2615
- return this;
2616
- }
2617
- /**
2618
- * Set an alias for the command.
2619
- *
2620
- * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
2621
- *
2622
- * @param {string} [alias]
2623
- * @return {(string|Command)}
2624
- */
2625
- alias(alias) {
2626
- if (alias === undefined) return this._aliases[0];
2627
- /** @type {Command} */
2628
- let command = this;
2629
- if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) command = this.commands[this.commands.length - 1];
2630
- if (alias === command._name) throw new Error("Command alias can't be the same as its name");
2631
- const matchingCommand = this.parent?._findCommand(alias);
2632
- if (matchingCommand) {
2633
- const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
2634
- throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
2635
- }
2636
- command._aliases.push(alias);
2637
- return this;
2638
- }
2639
- /**
2640
- * Set aliases for the command.
2641
- *
2642
- * Only the first alias is shown in the auto-generated help.
2643
- *
2644
- * @param {string[]} [aliases]
2645
- * @return {(string[]|Command)}
2646
- */
2647
- aliases(aliases$1) {
2648
- if (aliases$1 === undefined) return this._aliases;
2649
- aliases$1.forEach((alias) => this.alias(alias));
2650
- return this;
2651
- }
2652
- /**
2653
- * Set / get the command usage `str`.
2654
- *
2655
- * @param {string} [str]
2656
- * @return {(string|Command)}
2657
- */
2658
- usage(str) {
2659
- if (str === undefined) {
2660
- if (this._usage) return this._usage;
2661
- const args = this.registeredArguments.map((arg) => {
2662
- return humanReadableArgName(arg);
2663
- });
2664
- return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
2665
- }
2666
- this._usage = str;
2667
- return this;
2668
- }
2669
- /**
2670
- * Get or set the name of the command.
2671
- *
2672
- * @param {string} [str]
2673
- * @return {(string|Command)}
2674
- */
2675
- name(str) {
2676
- if (str === undefined) return this._name;
2677
- this._name = str;
2678
- return this;
2679
- }
2680
- /**
2681
- * Set the name of the command from script filename, such as process.argv[1],
2682
- * or require.main.filename, or __filename.
2683
- *
2684
- * (Used internally and public although not documented in README.)
2685
- *
2686
- * @example
2687
- * program.nameFromFilename(require.main.filename);
2688
- *
2689
- * @param {string} filename
2690
- * @return {Command}
2691
- */
2692
- nameFromFilename(filename) {
2693
- this._name = path$2.basename(filename, path$2.extname(filename));
2694
- return this;
2695
- }
2696
- /**
2697
- * Get or set the directory for searching for executable subcommands of this command.
2698
- *
2699
- * @example
2700
- * program.executableDir(__dirname);
2701
- * // or
2702
- * program.executableDir('subcommands');
2703
- *
2704
- * @param {string} [path]
2705
- * @return {(string|null|Command)}
2706
- */
2707
- executableDir(path$3) {
2708
- if (path$3 === undefined) return this._executableDir;
2709
- this._executableDir = path$3;
2710
- return this;
2711
- }
2712
- /**
2713
- * Return program help documentation.
2714
- *
2715
- * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
2716
- * @return {string}
2717
- */
2718
- helpInformation(contextOptions) {
2719
- const helper = this.createHelp();
2720
- const context = this._getOutputContext(contextOptions);
2721
- helper.prepareContext({
2722
- error: context.error,
2723
- helpWidth: context.helpWidth,
2724
- outputHasColors: context.hasColors
2725
- });
2726
- const text$1 = helper.formatHelp(this, helper);
2727
- if (context.hasColors) return text$1;
2728
- return this._outputConfiguration.stripColor(text$1);
2729
- }
2730
- /**
2731
- * @typedef HelpContext
2732
- * @type {object}
2733
- * @property {boolean} error
2734
- * @property {number} helpWidth
2735
- * @property {boolean} hasColors
2736
- * @property {function} write - includes stripColor if needed
2737
- *
2738
- * @returns {HelpContext}
2739
- * @private
2740
- */
2741
- _getOutputContext(contextOptions) {
2742
- contextOptions = contextOptions || {};
2743
- const error = !!contextOptions.error;
2744
- let baseWrite;
2745
- let hasColors;
2746
- let helpWidth;
2747
- if (error) {
2748
- baseWrite = (str) => this._outputConfiguration.writeErr(str);
2749
- hasColors = this._outputConfiguration.getErrHasColors();
2750
- helpWidth = this._outputConfiguration.getErrHelpWidth();
2751
- } else {
2752
- baseWrite = (str) => this._outputConfiguration.writeOut(str);
2753
- hasColors = this._outputConfiguration.getOutHasColors();
2754
- helpWidth = this._outputConfiguration.getOutHelpWidth();
2755
- }
2756
- const write$1 = (str) => {
2757
- if (!hasColors) str = this._outputConfiguration.stripColor(str);
2758
- return baseWrite(str);
2759
- };
2760
- return {
2761
- error,
2762
- write: write$1,
2763
- hasColors,
2764
- helpWidth
2765
- };
2766
- }
2767
- /**
2768
- * Output help information for this command.
2769
- *
2770
- * Outputs built-in help, and custom text added using `.addHelpText()`.
2771
- *
2772
- * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2773
- */
2774
- outputHelp(contextOptions) {
2775
- let deprecatedCallback;
2776
- if (typeof contextOptions === "function") {
2777
- deprecatedCallback = contextOptions;
2778
- contextOptions = undefined;
2779
- }
2780
- const outputContext = this._getOutputContext(contextOptions);
2781
- /** @type {HelpTextEventContext} */
2782
- const eventContext = {
2783
- error: outputContext.error,
2784
- write: outputContext.write,
2785
- command: this
2786
- };
2787
- this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
2788
- this.emit("beforeHelp", eventContext);
2789
- let helpInformation = this.helpInformation({ error: outputContext.error });
2790
- if (deprecatedCallback) {
2791
- helpInformation = deprecatedCallback(helpInformation);
2792
- if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) throw new Error("outputHelp callback must return a string or a Buffer");
2793
- }
2794
- outputContext.write(helpInformation);
2795
- if (this._getHelpOption()?.long) this.emit(this._getHelpOption().long);
2796
- this.emit("afterHelp", eventContext);
2797
- this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
2798
- }
2799
- /**
2800
- * You can pass in flags and a description to customise the built-in help option.
2801
- * Pass in false to disable the built-in help option.
2802
- *
2803
- * @example
2804
- * program.helpOption('-?, --help' 'show help'); // customise
2805
- * program.helpOption(false); // disable
2806
- *
2807
- * @param {(string | boolean)} flags
2808
- * @param {string} [description]
2809
- * @return {Command} `this` command for chaining
2810
- */
2811
- helpOption(flags, description$1) {
2812
- if (typeof flags === "boolean") {
2813
- if (flags) this._helpOption = this._helpOption ?? undefined;
2814
- else this._helpOption = null;
2815
- return this;
2816
- }
2817
- flags = flags ?? "-h, --help";
2818
- description$1 = description$1 ?? "display help for command";
2819
- this._helpOption = this.createOption(flags, description$1);
2820
- return this;
2821
- }
2822
- /**
2823
- * Lazy create help option.
2824
- * Returns null if has been disabled with .helpOption(false).
2825
- *
2826
- * @returns {(Option | null)} the help option
2827
- * @package
2828
- */
2829
- _getHelpOption() {
2830
- if (this._helpOption === undefined) this.helpOption(undefined, undefined);
2831
- return this._helpOption;
2832
- }
2833
- /**
2834
- * Supply your own option to use for the built-in help option.
2835
- * This is an alternative to using helpOption() to customise the flags and description etc.
2836
- *
2837
- * @param {Option} option
2838
- * @return {Command} `this` command for chaining
2839
- */
2840
- addHelpOption(option) {
2841
- this._helpOption = option;
2842
- return this;
2843
- }
2844
- /**
2845
- * Output help information and exit.
2846
- *
2847
- * Outputs built-in help, and custom text added using `.addHelpText()`.
2848
- *
2849
- * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2850
- */
2851
- help(contextOptions) {
2852
- this.outputHelp(contextOptions);
2853
- let exitCode = Number(process$2.exitCode ?? 0);
2854
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) exitCode = 1;
2855
- this._exit(exitCode, "commander.help", "(outputHelp)");
2856
- }
2857
- /**
2858
- * // Do a little typing to coordinate emit and listener for the help text events.
2859
- * @typedef HelpTextEventContext
2860
- * @type {object}
2861
- * @property {boolean} error
2862
- * @property {Command} command
2863
- * @property {function} write
2864
- */
2865
- /**
2866
- * Add additional text to be displayed with the built-in help.
2867
- *
2868
- * Position is 'before' or 'after' to affect just this command,
2869
- * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
2870
- *
2871
- * @param {string} position - before or after built-in help
2872
- * @param {(string | Function)} text - string to add, or a function returning a string
2873
- * @return {Command} `this` command for chaining
2874
- */
2875
- addHelpText(position, text$1) {
2876
- const allowedValues = [
2877
- "beforeAll",
2878
- "before",
2879
- "after",
2880
- "afterAll"
2881
- ];
2882
- if (!allowedValues.includes(position)) throw new Error(`Unexpected value for position to addHelpText.
2883
- Expecting one of '${allowedValues.join("', '")}'`);
2884
- const helpEvent = `${position}Help`;
2885
- this.on(helpEvent, (context) => {
2886
- let helpStr;
2887
- if (typeof text$1 === "function") helpStr = text$1({
2888
- error: context.error,
2889
- command: context.command
2890
- });
2891
- else helpStr = text$1;
2892
- if (helpStr) context.write(`${helpStr}\n`);
2893
- });
2894
- return this;
2895
- }
2896
- /**
2897
- * Output help information if help flags specified
2898
- *
2899
- * @param {Array} args - array of options to search for help flags
2900
- * @private
2901
- */
2902
- _outputHelpIfRequested(args) {
2903
- const helpOption = this._getHelpOption();
2904
- const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
2905
- if (helpRequested) {
2906
- this.outputHelp();
2907
- this._exit(0, "commander.helpDisplayed", "(outputHelp)");
2908
- }
2909
- }
2910
- };
2911
- /**
2912
- * Scan arguments and increment port number for inspect calls (to avoid conflicts when spawning new command).
2913
- *
2914
- * @param {string[]} args - array of arguments from node.execArgv
2915
- * @returns {string[]}
2916
- * @private
2917
- */
2918
- function incrementNodeInspectorPort(args) {
2919
- return args.map((arg) => {
2920
- if (!arg.startsWith("--inspect")) return arg;
2921
- let debugOption;
2922
- let debugHost = "127.0.0.1";
2923
- let debugPort = "9229";
2924
- let match;
2925
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) debugOption = match[1];
2926
- else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2927
- debugOption = match[1];
2928
- if (/^\d+$/.test(match[3])) debugPort = match[3];
2929
- else debugHost = match[3];
2930
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2931
- debugOption = match[1];
2932
- debugHost = match[3];
2933
- debugPort = match[4];
2934
- }
2935
- if (debugOption && debugPort !== "0") return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
2936
- return arg;
2937
- });
2938
- }
2939
- /**
2940
- * @returns {boolean | undefined}
2941
- * @package
2942
- */
2943
- function useColor() {
2944
- if (process$2.env.NO_COLOR || process$2.env.FORCE_COLOR === "0" || process$2.env.FORCE_COLOR === "false") return false;
2945
- if (process$2.env.FORCE_COLOR || process$2.env.CLICOLOR_FORCE !== undefined) return true;
2946
- return undefined;
2947
- }
2948
- exports.Command = Command$2;
2949
- exports.useColor = useColor;
2950
- } });
2951
-
2952
- //#endregion
2953
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/index.js
2954
- var require_commander = __commonJS({ "node_modules/.pnpm/commander@13.0.0/node_modules/commander/index.js"(exports) {
2955
- const { Argument: Argument$1 } = require_argument();
2956
- const { Command: Command$1 } = require_command();
2957
- const { CommanderError: CommanderError$1, InvalidArgumentError: InvalidArgumentError$1 } = require_error();
2958
- const { Help: Help$1 } = require_help();
2959
- const { Option: Option$1 } = require_option();
2960
- exports.program = new Command$1();
2961
- exports.createCommand = (name$1) => new Command$1(name$1);
2962
- exports.createOption = (flags, description$1) => new Option$1(flags, description$1);
2963
- exports.createArgument = (name$1, description$1) => new Argument$1(name$1, description$1);
2964
- /**
2965
- * Expose classes
2966
- */
2967
- exports.Command = Command$1;
2968
- exports.Option = Option$1;
2969
- exports.Argument = Argument$1;
2970
- exports.Help = Help$1;
2971
- exports.CommanderError = CommanderError$1;
2972
- exports.InvalidArgumentError = InvalidArgumentError$1;
2973
- exports.InvalidOptionArgumentError = InvalidArgumentError$1;
2974
- } });
2975
-
2976
- //#endregion
2977
- //#region node_modules/.pnpm/commander@13.0.0/node_modules/commander/esm.mjs
2978
- var import_commander = __toESM(require_commander(), 1);
2979
- const { program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help } = import_commander.default;
2980
-
2981
- //#endregion
2982
- //#region node_modules/.pnpm/valibot@0.41.0_typescript@5.7.2/node_modules/valibot/dist/index.js
87
+ //#region node_modules/.pnpm/valibot@0.41.0_typescript@5.8.3/node_modules/valibot/dist/index.js
2983
88
  var store;
2984
89
  function getGlobalConfig(config2) {
2985
90
  return {
@@ -3385,7 +490,7 @@ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
3385
490
  var __getOwnPropNames$1 = Object.getOwnPropertyNames;
3386
491
  var __getProtoOf$1 = Object.getPrototypeOf;
3387
492
  var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
3388
- var __commonJS$1$1 = (cb, mod) => function() {
493
+ var __commonJS$1 = (cb, mod) => function() {
3389
494
  return mod || (0, cb[__getOwnPropNames$1(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
3390
495
  };
3391
496
  var __copyProps$1 = (to, from$2, except, desc) => {
@@ -3713,7 +818,7 @@ const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
3713
818
  var import_src$2 = __toESM$2(require_src$1(), 1);
3714
819
  const cancel$1 = Symbol("clack:cancel");
3715
820
  var import_src$1 = __toESM$2(require_src$1(), 1);
3716
- var require_picocolors$1 = __commonJS$2({ "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$2, module$1) {
821
+ var require_picocolors$1$1 = __commonJS$2({ "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$2, module$1) {
3717
822
  let p$1 = process || {}, argv$1 = p$1.argv || [], env$1 = p$1.env || {};
3718
823
  let isColorSupported$1 = !(!!env$1.NO_COLOR || argv$1.includes("--no-color")) && (!!env$1.FORCE_COLOR || argv$1.includes("--color") || p$1.platform === "win32" || (p$1.stdout || {}).isTTY && env$1.TERM !== "dumb" || !!env$1.CI);
3719
824
  let formatter$1 = (open, close, replace = open) => (input) => {
@@ -3779,22 +884,22 @@ var require_picocolors$1 = __commonJS$2({ "node_modules/.pnpm/picocolors@1.1.1/n
3779
884
  module$1.exports = createColors$1();
3780
885
  module$1.exports.createColors = createColors$1;
3781
886
  } });
3782
- var import_picocolors$1$1 = __toESM$2(require_picocolors$1(), 1);
3783
- var import_picocolors$2$1 = __toESM$2(require_picocolors$1(), 1);
887
+ var import_picocolors$1$1 = __toESM$2(require_picocolors$1$1(), 1);
888
+ var import_picocolors$2$1 = __toESM$2(require_picocolors$1$1(), 1);
3784
889
  var import_src$3 = __toESM$2(require_src$1(), 1);
3785
890
  const isWindows = process$1.platform.startsWith("win");
3786
891
  function isUnicodeSupported() {
3787
892
  if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
3788
893
  return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
3789
894
  }
3790
- var require_picocolors$2 = __commonJS$1$1({ "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$2, module$1) {
3791
- let p$1 = process || {}, argv$1 = p$1.argv || [], env$1 = p$1.env || {};
3792
- let isColorSupported$1 = !(!!env$1.NO_COLOR || argv$1.includes("--no-color")) && (!!env$1.FORCE_COLOR || argv$1.includes("--color") || p$1.platform === "win32" || (p$1.stdout || {}).isTTY && env$1.TERM !== "dumb" || !!env$1.CI);
3793
- let formatter$1 = (open, close, replace = open) => (input) => {
895
+ var require_picocolors$2 = __commonJS$1({ "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$2, module$1) {
896
+ let p = process || {}, argv = p.argv || [], env$1 = p.env || {};
897
+ let isColorSupported = !(!!env$1.NO_COLOR || argv.includes("--no-color")) && (!!env$1.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env$1.TERM !== "dumb" || !!env$1.CI);
898
+ let formatter = (open, close, replace = open) => (input) => {
3794
899
  let string$1 = "" + input, index = string$1.indexOf(close, open.length);
3795
- return ~index ? open + replaceClose$1(string$1, close, replace, index) + close : open + string$1 + close;
900
+ return ~index ? open + replaceClose(string$1, close, replace, index) + close : open + string$1 + close;
3796
901
  };
3797
- let replaceClose$1 = (string$1, close, replace, index) => {
902
+ let replaceClose = (string$1, close, replace, index) => {
3798
903
  let result = "", cursor$2 = 0;
3799
904
  do {
3800
905
  result += string$1.substring(cursor$2, index) + replace;
@@ -3803,8 +908,8 @@ var require_picocolors$2 = __commonJS$1$1({ "node_modules/.pnpm/picocolors@1.1.1
3803
908
  } while (~index);
3804
909
  return result + string$1.substring(cursor$2);
3805
910
  };
3806
- let createColors$1 = (enabled = isColorSupported$1) => {
3807
- let f = enabled ? formatter$1 : () => String;
911
+ let createColors = (enabled = isColorSupported) => {
912
+ let f = enabled ? formatter : () => String;
3808
913
  return {
3809
914
  isColorSupported: enabled,
3810
915
  reset: f("\x1B[0m", "\x1B[0m"),
@@ -3850,10 +955,10 @@ var require_picocolors$2 = __commonJS$1$1({ "node_modules/.pnpm/picocolors@1.1.1
3850
955
  bgWhiteBright: f("\x1B[107m", "\x1B[49m")
3851
956
  };
3852
957
  };
3853
- module$1.exports = createColors$1();
3854
- module$1.exports.createColors = createColors$1;
958
+ module$1.exports = createColors();
959
+ module$1.exports.createColors = createColors;
3855
960
  } });
3856
- var require_src = __commonJS$1$1({ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports$2, module$1) {
961
+ var require_src = __commonJS$1({ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports$2, module$1) {
3857
962
  const ESC = "\x1B";
3858
963
  const CSI = `${ESC}[`;
3859
964
  const beep = "\x07";
@@ -3960,72 +1065,6 @@ const log$1 = {
3960
1065
  log$1.message(message, { symbol: import_picocolors$3$1.default.red(S_ERROR) });
3961
1066
  }
3962
1067
  };
3963
- var require_picocolors$3 = __commonJS$1({ "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$2, module$1) {
3964
- let p = process || {}, argv = p.argv || [], env$1 = p.env || {};
3965
- let isColorSupported = !(!!env$1.NO_COLOR || argv.includes("--no-color")) && (!!env$1.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env$1.TERM !== "dumb" || !!env$1.CI);
3966
- let formatter = (open, close, replace = open) => (input) => {
3967
- let string$1 = "" + input, index = string$1.indexOf(close, open.length);
3968
- return ~index ? open + replaceClose(string$1, close, replace, index) + close : open + string$1 + close;
3969
- };
3970
- let replaceClose = (string$1, close, replace, index) => {
3971
- let result = "", cursor = 0;
3972
- do {
3973
- result += string$1.substring(cursor, index) + replace;
3974
- cursor = index + close.length;
3975
- index = string$1.indexOf(close, cursor);
3976
- } while (~index);
3977
- return result + string$1.substring(cursor);
3978
- };
3979
- let createColors = (enabled = isColorSupported) => {
3980
- let f = enabled ? formatter : () => String;
3981
- return {
3982
- isColorSupported: enabled,
3983
- reset: f("\x1B[0m", "\x1B[0m"),
3984
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
3985
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
3986
- italic: f("\x1B[3m", "\x1B[23m"),
3987
- underline: f("\x1B[4m", "\x1B[24m"),
3988
- inverse: f("\x1B[7m", "\x1B[27m"),
3989
- hidden: f("\x1B[8m", "\x1B[28m"),
3990
- strikethrough: f("\x1B[9m", "\x1B[29m"),
3991
- black: f("\x1B[30m", "\x1B[39m"),
3992
- red: f("\x1B[31m", "\x1B[39m"),
3993
- green: f("\x1B[32m", "\x1B[39m"),
3994
- yellow: f("\x1B[33m", "\x1B[39m"),
3995
- blue: f("\x1B[34m", "\x1B[39m"),
3996
- magenta: f("\x1B[35m", "\x1B[39m"),
3997
- cyan: f("\x1B[36m", "\x1B[39m"),
3998
- white: f("\x1B[37m", "\x1B[39m"),
3999
- gray: f("\x1B[90m", "\x1B[39m"),
4000
- bgBlack: f("\x1B[40m", "\x1B[49m"),
4001
- bgRed: f("\x1B[41m", "\x1B[49m"),
4002
- bgGreen: f("\x1B[42m", "\x1B[49m"),
4003
- bgYellow: f("\x1B[43m", "\x1B[49m"),
4004
- bgBlue: f("\x1B[44m", "\x1B[49m"),
4005
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
4006
- bgCyan: f("\x1B[46m", "\x1B[49m"),
4007
- bgWhite: f("\x1B[47m", "\x1B[49m"),
4008
- blackBright: f("\x1B[90m", "\x1B[39m"),
4009
- redBright: f("\x1B[91m", "\x1B[39m"),
4010
- greenBright: f("\x1B[92m", "\x1B[39m"),
4011
- yellowBright: f("\x1B[93m", "\x1B[39m"),
4012
- blueBright: f("\x1B[94m", "\x1B[39m"),
4013
- magentaBright: f("\x1B[95m", "\x1B[39m"),
4014
- cyanBright: f("\x1B[96m", "\x1B[39m"),
4015
- whiteBright: f("\x1B[97m", "\x1B[39m"),
4016
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
4017
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
4018
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
4019
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
4020
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
4021
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
4022
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
4023
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
4024
- };
4025
- };
4026
- module$1.exports = createColors();
4027
- module$1.exports.createColors = createColors;
4028
- } });
4029
1068
  var utils_exports = {};
4030
1069
  __export(utils_exports, { createPrinter: () => createPrinter });
4031
1070
  function createPrinter(...conditions) {
@@ -4034,7 +1073,7 @@ function createPrinter(...conditions) {
4034
1073
  });
4035
1074
  return printers;
4036
1075
  }
4037
- var import_picocolors$4 = __toESM$1(require_picocolors$3(), 1);
1076
+ var import_picocolors$4 = __toESM$1(require_picocolors(), 1);
4038
1077
  var colors = import_picocolors$4.default;
4039
1078
 
4040
1079
  //#endregion
@@ -4186,7 +1225,7 @@ var drizzle_default = defineAddon({
4186
1225
  return content;
4187
1226
  });
4188
1227
  sv.file("package.json", (content) => {
4189
- const { data, generateCode } = parseJson(content);
1228
+ const { data, generateCode } = parseJson$1(content);
4190
1229
  data.scripts ??= {};
4191
1230
  const scripts$1 = data.scripts;
4192
1231
  if (options$6.docker) scripts$1["db:start"] ??= "docker compose up";
@@ -4201,7 +1240,7 @@ var drizzle_default = defineAddon({
4201
1240
  return content;
4202
1241
  });
4203
1242
  sv.file(`drizzle.config.${ext}`, (content) => {
4204
- const { ast, generateCode } = parseScript(content);
1243
+ const { ast, generateCode } = parseScript$1(content);
4205
1244
  imports_exports.addNamed(ast, "drizzle-kit", { defineConfig: "defineConfig" });
4206
1245
  const envCheckStatement = common_exports.statementFromString("if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');");
4207
1246
  common_exports.addStatement(ast, envCheckStatement);
@@ -4232,7 +1271,7 @@ var drizzle_default = defineAddon({
4232
1271
  return generateCode();
4233
1272
  });
4234
1273
  sv.file(`${kit?.libDirectory}/server/db/schema.${ext}`, (content) => {
4235
- const { ast, generateCode } = parseScript(content);
1274
+ const { ast, generateCode } = parseScript$1(content);
4236
1275
  let userSchemaExpression;
4237
1276
  if (options$6.database === "sqlite") {
4238
1277
  imports_exports.addNamed(ast, "drizzle-orm/sqlite-core", {
@@ -4275,7 +1314,7 @@ var drizzle_default = defineAddon({
4275
1314
  return generateCode();
4276
1315
  });
4277
1316
  sv.file(`${kit?.libDirectory}/server/db/index.${ext}`, (content) => {
4278
- const { ast, generateCode } = parseScript(content);
1317
+ const { ast, generateCode } = parseScript$1(content);
4279
1318
  imports_exports.addNamed(ast, "$env/dynamic/private", { env: "env" });
4280
1319
  imports_exports.addNamespace(ast, "./schema", "schema");
4281
1320
  const dbURLCheck = common_exports.statementFromString("if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');");
@@ -4375,7 +1414,7 @@ function appendEnvContent(existing, content) {
4375
1414
  //#endregion
4376
1415
  //#region packages/addons/common.ts
4377
1416
  function addEslintConfigPrettier(content) {
4378
- const { ast, generateCode } = parseScript(content);
1417
+ const { ast, generateCode } = parseScript$1(content);
4379
1418
  const importNodes = ast.body.filter((n$1) => n$1.type === "ImportDeclaration");
4380
1419
  const sveltePluginImport = importNodes.find((n$1) => n$1.type === "ImportDeclaration" && n$1.source.value === "eslint-plugin-svelte" && n$1.specifiers?.some((n$2) => n$2.type === "ImportDefaultSpecifier"));
4381
1420
  let svelteImportName;
@@ -4399,11 +1438,11 @@ function addEslintConfigPrettier(content) {
4399
1438
  else elements.push(...nodesToInsert);
4400
1439
  return generateCode();
4401
1440
  }
4402
- function addToDemoPage(content, path$3) {
1441
+ function addToDemoPage(content, path$2) {
4403
1442
  const { template, generateCode } = parseSvelte(content);
4404
- for (const node of template.ast.childNodes) if (node.type === "tag" && node.attribs["href"] === `/demo/${path$3}`) return content;
1443
+ for (const node of template.ast.childNodes) if (node.type === "tag" && node.attribs["href"] === `/demo/${path$2}`) return content;
4405
1444
  const newLine = template.source ? "\n" : "";
4406
- const src = template.source + `${newLine}<a href="/demo/${path$3}">${path$3}</a>`;
1445
+ const src = template.source + `${newLine}<a href="/demo/${path$2}">${path$2}</a>`;
4407
1446
  return generateCode({ template: src });
4408
1447
  }
4409
1448
 
@@ -4424,7 +1463,7 @@ var eslint_default = defineAddon({
4424
1463
  if (typescript) sv.devDependency("typescript-eslint", "^8.20.0");
4425
1464
  if (prettierInstalled) sv.devDependency("eslint-config-prettier", "^10.0.1");
4426
1465
  sv.file("package.json", (content) => {
4427
- const { data, generateCode } = parseJson(content);
1466
+ const { data, generateCode } = parseJson$1(content);
4428
1467
  data.scripts ??= {};
4429
1468
  const scripts$1 = data.scripts;
4430
1469
  const LINT_CMD = "eslint .";
@@ -4434,13 +1473,13 @@ var eslint_default = defineAddon({
4434
1473
  });
4435
1474
  sv.file(".vscode/settings.json", (content) => {
4436
1475
  if (!content) return content;
4437
- const { data, generateCode } = parseJson(content);
1476
+ const { data, generateCode } = parseJson$1(content);
4438
1477
  const validate$1 = data["eslint.validate"];
4439
1478
  if (validate$1 && !validate$1.includes("svelte")) validate$1.push("svelte");
4440
1479
  return generateCode();
4441
1480
  });
4442
1481
  sv.file("eslint.config.js", (content) => {
4443
- const { ast, generateCode } = parseScript(content);
1482
+ const { ast, generateCode } = parseScript$1(content);
4444
1483
  const eslintConfigs = [];
4445
1484
  imports_exports.addDefault(ast, "./svelte.config.js", "svelteConfig");
4446
1485
  const gitIgnorePathStatement = common_exports.statementFromString("\nconst gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));");
@@ -4477,7 +1516,6 @@ var eslint_default = defineAddon({
4477
1516
  if (typescript) {
4478
1517
  const svelteTSParserConfig = object_exports.create({
4479
1518
  files: common_exports.expressionFromString("['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js']"),
4480
- ignores: common_exports.expressionFromString("['eslint.config.js', 'svelte.config.js']"),
4481
1519
  languageOptions: object_exports.create({ parserOptions: object_exports.create({
4482
1520
  projectService: common_exports.expressionFromString("true"),
4483
1521
  extraFileExtensions: common_exports.expressionFromString("['.svelte']"),
@@ -4527,12 +1565,12 @@ const adapters = [
4527
1565
  {
4528
1566
  id: "auto",
4529
1567
  package: "@sveltejs/adapter-auto",
4530
- version: "^4.0.0"
1568
+ version: "^6.0.0"
4531
1569
  },
4532
1570
  {
4533
1571
  id: "node",
4534
1572
  package: "@sveltejs/adapter-node",
4535
- version: "^5.2.11"
1573
+ version: "^5.2.12"
4536
1574
  },
4537
1575
  {
4538
1576
  id: "static",
@@ -4542,22 +1580,17 @@ const adapters = [
4542
1580
  {
4543
1581
  id: "vercel",
4544
1582
  package: "@sveltejs/adapter-vercel",
4545
- version: "^5.5.2"
1583
+ version: "^5.6.3"
4546
1584
  },
4547
1585
  {
4548
1586
  id: "cloudflare-pages",
4549
1587
  package: "@sveltejs/adapter-cloudflare",
4550
- version: "^5.0.1"
4551
- },
4552
- {
4553
- id: "cloudflare-workers",
4554
- package: "@sveltejs/adapter-cloudflare-workers",
4555
- version: "^2.7.0"
1588
+ version: "^7.0.0"
4556
1589
  },
4557
1590
  {
4558
1591
  id: "netlify",
4559
1592
  package: "@sveltejs/adapter-netlify",
4560
- version: "^4.4.0"
1593
+ version: "^5.0.0"
4561
1594
  }
4562
1595
  ];
4563
1596
  const options$4 = defineAddonOptions({ adapter: {
@@ -4582,14 +1615,14 @@ var sveltekit_adapter_default = defineAddon({
4582
1615
  run: ({ sv, options: options$6 }) => {
4583
1616
  const adapter = adapters.find((a) => a.id === options$6.adapter);
4584
1617
  sv.file("package.json", (content) => {
4585
- const { data, generateCode } = parseJson(content);
1618
+ const { data, generateCode } = parseJson$1(content);
4586
1619
  const devDeps = data["devDependencies"];
4587
1620
  for (const pkg of Object.keys(devDeps)) if (pkg.startsWith("@sveltejs/adapter-")) delete devDeps[pkg];
4588
1621
  return generateCode();
4589
1622
  });
4590
1623
  sv.devDependency(adapter.package, adapter.version);
4591
1624
  sv.file("svelte.config.js", (content) => {
4592
- const { ast, generateCode } = parseScript(content);
1625
+ const { ast, generateCode } = parseScript$1(content);
4593
1626
  const importDecls = ast.body.filter((n$1) => n$1.type === "ImportDeclaration");
4594
1627
  const adapterImportDecl = importDecls.find((importDecl) => typeof importDecl.source.value === "string" && importDecl.source.value.startsWith("@sveltejs/adapter-") && importDecl.importKind === "value");
4595
1628
  let adapterName = "adapter";
@@ -5653,7 +2686,7 @@ var lucia_default = defineAddon({
5653
2686
  sv.dependency("@oslojs/encoding", "^1.1.0");
5654
2687
  if (options$6.demo) sv.dependency("@node-rs/argon2", "^2.0.2");
5655
2688
  sv.file(`drizzle.config.${ext}`, (content) => {
5656
- const { ast, generateCode } = parseScript(content);
2689
+ const { ast, generateCode } = parseScript$1(content);
5657
2690
  const isProp = (name$1, node) => node.key.type === "Identifier" && node.key.name === name$1;
5658
2691
  walk_exports.walk(ast, null, { Property(node) {
5659
2692
  if (isProp("dialect", node) && node.value.type === "Literal" && typeof node.value.value === "string") drizzleDialect = node.value.value;
@@ -5664,7 +2697,7 @@ var lucia_default = defineAddon({
5664
2697
  return generateCode();
5665
2698
  });
5666
2699
  sv.file(schemaPath, (content) => {
5667
- const { ast, generateCode } = parseScript(content);
2700
+ const { ast, generateCode } = parseScript$1(content);
5668
2701
  const createTable = (name$1) => function_exports.call(TABLE_TYPE[drizzleDialect], [name$1]);
5669
2702
  const userDecl = variables_exports.declaration(ast, "const", "user", createTable("user"));
5670
2703
  const sessionDecl = variables_exports.declaration(ast, "const", "session", createTable("session"));
@@ -5737,7 +2770,7 @@ var lucia_default = defineAddon({
5737
2770
  return code;
5738
2771
  });
5739
2772
  sv.file(`${kit?.libDirectory}/server/auth.${ext}`, (content) => {
5740
- const { ast, generateCode } = parseScript(content);
2773
+ const { ast, generateCode } = parseScript$1(content);
5741
2774
  imports_exports.addNamespace(ast, "$lib/server/db/schema", "table");
5742
2775
  imports_exports.addNamed(ast, "$lib/server/db", { db: "db" });
5743
2776
  imports_exports.addNamed(ast, "@oslojs/encoding", {
@@ -5857,7 +2890,7 @@ var lucia_default = defineAddon({
5857
2890
  return ms.toString();
5858
2891
  });
5859
2892
  if (typescript) sv.file("src/app.d.ts", (content) => {
5860
- const { ast, generateCode } = parseScript(content);
2893
+ const { ast, generateCode } = parseScript$1(content);
5861
2894
  const locals = kit_exports.addGlobalAppInterface(ast, "Locals");
5862
2895
  if (!locals) throw new Error("Failed detecting `locals` interface in `src/app.d.ts`");
5863
2896
  const user = locals.body.body.find((prop) => common_exports.hasTypeProp("user", prop));
@@ -5867,7 +2900,7 @@ var lucia_default = defineAddon({
5867
2900
  return generateCode();
5868
2901
  });
5869
2902
  sv.file(`src/hooks.server.${ext}`, (content) => {
5870
- const { ast, generateCode } = parseScript(content);
2903
+ const { ast, generateCode } = parseScript$1(content);
5871
2904
  imports_exports.addNamespace(ast, "$lib/server/auth.js", "auth");
5872
2905
  kit_exports.addHooksHandle(ast, typescript, "handleAuth", getAuthHandleContent());
5873
2906
  return generateCode();
@@ -6164,7 +3197,7 @@ var mdsvex_default = defineAddon({
6164
3197
  run: ({ sv }) => {
6165
3198
  sv.devDependency("mdsvex", "^0.12.3");
6166
3199
  sv.file("svelte.config.js", (content) => {
6167
- const { ast, generateCode } = parseScript(content);
3200
+ const { ast, generateCode } = parseScript$1(content);
6168
3201
  imports_exports.addNamed(ast, "mdsvex", { mdsvex: "mdsvex" });
6169
3202
  const { value: exportDefault } = exports_exports.defaultExport(ast, object_exports.createEmpty());
6170
3203
  let preprocessorArray = object_exports.property(exportDefault, "preprocess", array_exports.createEmpty());
@@ -6188,7 +3221,7 @@ var mdsvex_default = defineAddon({
6188
3221
  //#endregion
6189
3222
  //#region packages/core/dist/html.js
6190
3223
  function element(tagName, attributes = {}) {
6191
- const element$1 = new Element(tagName, {}, undefined, esm_exports.Tag);
3224
+ const element$1 = new Element(tagName, {}, undefined, Tag);
6192
3225
  element$1.attribs = attributes;
6193
3226
  return element$1;
6194
3227
  }
@@ -6196,7 +3229,7 @@ function appendElement(childNodes, elementToAppend) {
6196
3229
  childNodes.push(elementToAppend);
6197
3230
  }
6198
3231
  function addFromRawHtml(childNodes, html) {
6199
- const document = parseHtml$1(html);
3232
+ const document = parseHtml(html);
6200
3233
  for (const childNode of document.childNodes) childNodes.push(childNode);
6201
3234
  }
6202
3235
  function addSlot(jsAst, htmlAst, svelteVersion) {
@@ -6257,7 +3290,7 @@ var paraglide_default = defineAddon({
6257
3290
  sv.dependency("@inlang/paraglide-js", "^2.0.0");
6258
3291
  sv.file("project.inlang/settings.json", (content) => {
6259
3292
  if (content) return content;
6260
- const { data, generateCode } = parseJson(content);
3293
+ const { data, generateCode } = parseJson$1(content);
6261
3294
  for (const key in DEFAULT_INLANG_PROJECT) data[key] = DEFAULT_INLANG_PROJECT[key];
6262
3295
  const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$6.availableLanguageTags);
6263
3296
  const baseLocale = validLanguageTags$1[0];
@@ -6266,7 +3299,7 @@ var paraglide_default = defineAddon({
6266
3299
  return generateCode();
6267
3300
  });
6268
3301
  sv.file(`vite.config.${ext}`, (content) => {
6269
- const { ast, generateCode } = parseScript(content);
3302
+ const { ast, generateCode } = parseScript$1(content);
6270
3303
  const vitePluginName = "paraglideVitePlugin";
6271
3304
  imports_exports.addNamed(ast, "@inlang/paraglide-js", { paraglideVitePlugin: vitePluginName });
6272
3305
  const { value: rootObject } = exports_exports.defaultExport(ast, function_exports.call("defineConfig", []));
@@ -6282,7 +3315,7 @@ var paraglide_default = defineAddon({
6282
3315
  return generateCode();
6283
3316
  });
6284
3317
  sv.file(`src/hooks.${ext}`, (content) => {
6285
- const { ast, generateCode } = parseScript(content);
3318
+ const { ast, generateCode } = parseScript$1(content);
6286
3319
  imports_exports.addNamed(ast, "$lib/paraglide/runtime", { deLocalizeUrl: "deLocalizeUrl" });
6287
3320
  const expression = common_exports.expressionFromString("(request) => deLocalizeUrl(request.url).pathname");
6288
3321
  const rerouteIdentifier = variables_exports.declaration(ast, "const", "reroute", expression);
@@ -6291,7 +3324,7 @@ var paraglide_default = defineAddon({
6291
3324
  return generateCode();
6292
3325
  });
6293
3326
  sv.file(`src/hooks.server.${ext}`, (content) => {
6294
- const { ast, generateCode } = parseScript(content);
3327
+ const { ast, generateCode } = parseScript$1(content);
6295
3328
  imports_exports.addNamed(ast, "$lib/paraglide/server", { paraglideMiddleware: "paraglideMiddleware" });
6296
3329
  const hookHandleContent = `({ event, resolve }) => paraglideMiddleware(event.request, ({ request, locale }) => {
6297
3330
  event.request = request;
@@ -6303,7 +3336,7 @@ var paraglide_default = defineAddon({
6303
3336
  return generateCode();
6304
3337
  });
6305
3338
  sv.file("src/app.html", (content) => {
6306
- const { ast, generateCode } = parseHtml(content);
3339
+ const { ast, generateCode } = parseHtml$1(content);
6307
3340
  const htmlNode = ast.children.find((child) => child.type === esm_exports.Tag && child.name === "html");
6308
3341
  if (!htmlNode) {
6309
3342
  log$1.warn("Could not find <html> node in app.html. You'll need to add the language placeholder manually");
@@ -6345,7 +3378,7 @@ var paraglide_default = defineAddon({
6345
3378
  }
6346
3379
  const { validLanguageTags } = parseLanguageTagInput(options$6.availableLanguageTags);
6347
3380
  for (const languageTag of validLanguageTags) sv.file(`messages/${languageTag}.json`, (content) => {
6348
- const { data, generateCode } = parseJson(content);
3381
+ const { data, generateCode } = parseJson$1(content);
6349
3382
  data["$schema"] = "https://inlang.com/schema/inlang-message-format";
6350
3383
  data.hello_world = `Hello, {name} from ${languageTag}!`;
6351
3384
  return generateCode();
@@ -6381,7 +3414,7 @@ var playwright_default = defineAddon({
6381
3414
  const ext = typescript ? "ts" : "js";
6382
3415
  sv.devDependency("@playwright/test", "^1.49.1");
6383
3416
  sv.file("package.json", (content) => {
6384
- const { data, generateCode } = parseJson(content);
3417
+ const { data, generateCode } = parseJson$1(content);
6385
3418
  data.scripts ??= {};
6386
3419
  const scripts$1 = data.scripts;
6387
3420
  const TEST_CMD = "playwright test";
@@ -6408,7 +3441,7 @@ var playwright_default = defineAddon({
6408
3441
  `;
6409
3442
  });
6410
3443
  sv.file(`playwright.config.${ext}`, (content) => {
6411
- const { ast, generateCode } = parseScript(content);
3444
+ const { ast, generateCode } = parseScript$1(content);
6412
3445
  const defineConfig = common_exports.expressionFromString("defineConfig({})");
6413
3446
  const defaultExport = exports_exports.defaultExport(ast, defineConfig);
6414
3447
  const config = {
@@ -6450,7 +3483,13 @@ var prettier_default = defineAddon({
6450
3483
  `;
6451
3484
  });
6452
3485
  sv.file(".prettierrc", (content) => {
6453
- const { data, generateCode } = parseJson(content);
3486
+ let data, generateCode;
3487
+ try {
3488
+ ({data, generateCode} = parseJson$1(content));
3489
+ } catch {
3490
+ log$1.warn(`A ${colors.yellow(".prettierrc")} config already exists and cannot be parsed as JSON. Skipping initialization.`);
3491
+ return content;
3492
+ }
6454
3493
  if (Object.keys(data).length === 0) {
6455
3494
  data.useTabs = true;
6456
3495
  data.singleQuote = true;
@@ -6472,7 +3511,7 @@ var prettier_default = defineAddon({
6472
3511
  const eslintVersion = dependencyVersion("eslint");
6473
3512
  const eslintInstalled = hasEslint(eslintVersion);
6474
3513
  sv.file("package.json", (content) => {
6475
- const { data, generateCode } = parseJson(content);
3514
+ const { data, generateCode } = parseJson$1(content);
6476
3515
  data.scripts ??= {};
6477
3516
  const scripts$1 = data.scripts;
6478
3517
  const CHECK_CMD = "prettier --check .";
@@ -6552,7 +3591,7 @@ var tailwindcss_default = defineAddon({
6552
3591
  sv.devDependency(plugin.package, plugin.version);
6553
3592
  }
6554
3593
  sv.file(`vite.config.${ext}`, (content) => {
6555
- const { ast, generateCode } = parseScript(content);
3594
+ const { ast, generateCode } = parseScript$1(content);
6556
3595
  const vitePluginName = "tailwindcss";
6557
3596
  imports_exports.addDefault(ast, "@tailwindcss/vite", vitePluginName);
6558
3597
  const { value: rootObject } = exports_exports.defaultExport(ast, function_exports.call("defineConfig", []));
@@ -6563,13 +3602,13 @@ var tailwindcss_default = defineAddon({
6563
3602
  return generateCode();
6564
3603
  });
6565
3604
  sv.file("src/app.css", (content) => {
6566
- let atRules = parseCss(content).ast.nodes.filter((node) => node.type === "atrule");
3605
+ let atRules = parseCss$1(content).ast.nodes.filter((node) => node.type === "atrule");
6567
3606
  const findAtRule = (name$1, params) => atRules.find((rule) => rule.name === name$1 && rule.params.replace(/['"]/g, "") === params);
6568
3607
  let code = content;
6569
3608
  const importsTailwind = findAtRule("import", "tailwindcss");
6570
3609
  if (!importsTailwind) {
6571
3610
  code = "@import 'tailwindcss';\n" + code;
6572
- atRules = parseCss(code).ast.nodes.filter((node) => node.type === "atrule");
3611
+ atRules = parseCss$1(code).ast.nodes.filter((node) => node.type === "atrule");
6573
3612
  }
6574
3613
  const lastAtRule = atRules.findLast((rule) => ["plugin", "import"].includes(rule.name));
6575
3614
  const pluginPos = lastAtRule.source.end.offset;
@@ -6602,7 +3641,7 @@ else sv.file(`${kit?.routesDirectory}/+layout.svelte`, (content) => {
6602
3641
  });
6603
3642
  });
6604
3643
  if (dependencyVersion("prettier")) sv.file(".prettierrc", (content) => {
6605
- const { data, generateCode } = parseJson(content);
3644
+ const { data, generateCode } = parseJson$1(content);
6606
3645
  const PLUGIN_NAME = "prettier-plugin-tailwindcss";
6607
3646
  data.plugins ??= [];
6608
3647
  const plugins$1 = data.plugins;
@@ -6626,7 +3665,7 @@ var vitest_addon_default = defineAddon({
6626
3665
  sv.devDependency("@testing-library/jest-dom", "^6.6.3");
6627
3666
  sv.devDependency("jsdom", "^26.0.0");
6628
3667
  sv.file("package.json", (content) => {
6629
- const { data, generateCode } = parseJson(content);
3668
+ const { data, generateCode } = parseJson$1(content);
6630
3669
  data.scripts ??= {};
6631
3670
  const scripts$1 = data.scripts;
6632
3671
  const TEST_CMD = "vitest";
@@ -6704,7 +3743,7 @@ else sv.file(`src/App.svelte.test.${ext}`, (content) => {
6704
3743
  `;
6705
3744
  });
6706
3745
  sv.file(`vite.config.${ext}`, (content) => {
6707
- const { ast, generateCode } = parseScript(content);
3746
+ const { ast, generateCode } = parseScript$1(content);
6708
3747
  imports_exports.addNamed(ast, "@testing-library/svelte/vite", { svelteTesting: "svelteTesting" });
6709
3748
  const clientObjectExpression = object_exports.create({
6710
3749
  extends: common_exports.createLiteral(`./vite.config.${ext}`),
@@ -6782,7 +3821,7 @@ var UnsupportedError = class extends Error {
6782
3821
 
6783
3822
  //#endregion
6784
3823
  //#region packages/cli/utils/common.ts
6785
- var import_picocolors$3 = __toESM(require_picocolors(), 1);
3824
+ var import_picocolors$3 = __toESM(require_picocolors$1(), 1);
6786
3825
  const NO_PREFIX = "--no-";
6787
3826
  let options = [];
6788
3827
  function getLongFlag(flags) {
@@ -6855,18 +3894,6 @@ function forwardExitCode(error) {
6855
3894
  else process$1.exit(1);
6856
3895
  }
6857
3896
 
6858
- //#endregion
6859
- //#region node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/queue-microtask.js
6860
- var require_queue_microtask = __commonJS({ "node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/queue-microtask.js"(exports, module) {
6861
- module.exports = typeof queueMicrotask === "function" ? queueMicrotask : (fn) => Promise.resolve().then(fn);
6862
- } });
6863
-
6864
- //#endregion
6865
- //#region node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/process-next-tick.js
6866
- var require_process_next_tick = __commonJS({ "node_modules/.pnpm/queue-tick@1.0.1/node_modules/queue-tick/process-next-tick.js"(exports, module) {
6867
- module.exports = typeof process !== "undefined" && typeof process.nextTick === "function" ? process.nextTick.bind(process) : require_queue_microtask();
6868
- } });
6869
-
6870
3897
  //#endregion
6871
3898
  //#region node_modules/.pnpm/fast-fifo@1.3.2/node_modules/fast-fifo/fixed-size.js
6872
3899
  var require_fixed_size = __commonJS({ "node_modules/.pnpm/fast-fifo@1.3.2/node_modules/fast-fifo/fixed-size.js"(exports, module) {
@@ -7263,12 +4290,11 @@ var require_text_decoder = __commonJS({ "node_modules/.pnpm/text-decoder@1.2.3/n
7263
4290
  } });
7264
4291
 
7265
4292
  //#endregion
7266
- //#region node_modules/.pnpm/streamx@2.21.1/node_modules/streamx/index.js
7267
- var require_streamx = __commonJS({ "node_modules/.pnpm/streamx@2.21.1/node_modules/streamx/index.js"(exports, module) {
4293
+ //#region node_modules/.pnpm/streamx@2.22.0/node_modules/streamx/index.js
4294
+ var require_streamx = __commonJS({ "node_modules/.pnpm/streamx@2.22.0/node_modules/streamx/index.js"(exports, module) {
7268
4295
  const { EventEmitter } = __require("events");
7269
4296
  const STREAM_DESTROYED = new Error("Stream was destroyed");
7270
4297
  const PREMATURE_CLOSE = new Error("Premature close");
7271
- const queueTick = require_process_next_tick();
7272
4298
  const FIFO$1 = require_fast_fifo();
7273
4299
  const TextDecoder$1 = require_text_decoder();
7274
4300
  const MAX = 536870911;
@@ -7450,7 +4476,7 @@ else this.updateNextTick();
7450
4476
  updateNextTick() {
7451
4477
  if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return;
7452
4478
  this.stream._duplexState |= WRITE_NEXT_TICK;
7453
- if ((this.stream._duplexState & WRITE_UPDATING) === 0) queueTick(this.afterUpdateNextTick);
4479
+ if ((this.stream._duplexState & WRITE_UPDATING) === 0) queueMicrotask(this.afterUpdateNextTick);
7454
4480
  }
7455
4481
  };
7456
4482
  var ReadableState = class {
@@ -7600,12 +4626,12 @@ else this.updateNextTick();
7600
4626
  updateNextTickIfOpen() {
7601
4627
  if ((this.stream._duplexState & READ_NEXT_TICK_OR_OPENING) !== 0) return;
7602
4628
  this.stream._duplexState |= READ_NEXT_TICK;
7603
- if ((this.stream._duplexState & READ_UPDATING) === 0) queueTick(this.afterUpdateNextTick);
4629
+ if ((this.stream._duplexState & READ_UPDATING) === 0) queueMicrotask(this.afterUpdateNextTick);
7604
4630
  }
7605
4631
  updateNextTick() {
7606
4632
  if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return;
7607
4633
  this.stream._duplexState |= READ_NEXT_TICK;
7608
- if ((this.stream._duplexState & READ_UPDATING) === 0) queueTick(this.afterUpdateNextTick);
4634
+ if ((this.stream._duplexState & READ_UPDATING) === 0) queueMicrotask(this.afterUpdateNextTick);
7609
4635
  }
7610
4636
  };
7611
4637
  var TransformState = class {
@@ -9246,8 +6272,8 @@ var require_pump = __commonJS({ "node_modules/.pnpm/pump@3.0.2/node_modules/pump
9246
6272
  } });
9247
6273
 
9248
6274
  //#endregion
9249
- //#region node_modules/.pnpm/tar-fs@3.0.6/node_modules/tar-fs/index.js
9250
- var require_tar_fs = __commonJS({ "node_modules/.pnpm/tar-fs@3.0.6/node_modules/tar-fs/index.js"(exports) {
6275
+ //#region node_modules/.pnpm/tar-fs@3.0.8/node_modules/tar-fs/index.js
6276
+ var require_tar_fs = __commonJS({ "node_modules/.pnpm/tar-fs@3.0.8/node_modules/tar-fs/index.js"(exports) {
9251
6277
  const tar = require_tar_stream();
9252
6278
  const pump = require_pump();
9253
6279
  const fs$1 = __require("fs");
@@ -9346,6 +6372,7 @@ var require_tar_fs = __commonJS({ "node_modules/.pnpm/tar-fs@3.0.6/node_modules/
9346
6372
  exports.extract = function extract$1(cwd, opts) {
9347
6373
  if (!cwd) cwd = ".";
9348
6374
  if (!opts) opts = {};
6375
+ cwd = path$1.resolve(cwd);
9349
6376
  const xfs = opts.fs || fs$1;
9350
6377
  const ignore = opts.ignore || opts.filter || noop;
9351
6378
  const mapStream = opts.mapStream || echo;
@@ -9421,22 +6448,27 @@ var require_tar_fs = __commonJS({ "node_modules/.pnpm/tar-fs@3.0.6/node_modules/
9421
6448
  function onsymlink() {
9422
6449
  if (win32) return next();
9423
6450
  xfs.unlink(name$1, function() {
6451
+ const dst = path$1.resolve(path$1.dirname(name$1), header.linkname);
6452
+ if (!inCwd(dst)) return next(new Error(name$1 + " is not a valid symlink"));
9424
6453
  xfs.symlink(header.linkname, name$1, stat);
9425
6454
  });
9426
6455
  }
9427
6456
  function onlink() {
9428
6457
  if (win32) return next();
9429
6458
  xfs.unlink(name$1, function() {
9430
- const srcpath = path$1.join(cwd, path$1.join("/", header.linkname));
9431
- xfs.link(srcpath, name$1, function(err) {
6459
+ const dst = path$1.join(cwd, path$1.join("/", header.linkname));
6460
+ xfs.link(dst, name$1, function(err) {
9432
6461
  if (err && err.code === "EPERM" && opts.hardlinkAsFilesFallback) {
9433
- stream = xfs.createReadStream(srcpath);
6462
+ stream = xfs.createReadStream(dst);
9434
6463
  return onfile();
9435
6464
  }
9436
6465
  stat(err);
9437
6466
  });
9438
6467
  });
9439
6468
  }
6469
+ function inCwd(dst) {
6470
+ return dst.startsWith(cwd);
6471
+ }
9440
6472
  function onfile() {
9441
6473
  const ws = xfs.createWriteStream(name$1);
9442
6474
  const rs = mapStream(stream, header);
@@ -9492,10 +6524,10 @@ else onchown(null);
9492
6524
  });
9493
6525
  }
9494
6526
  };
9495
- function validate(fs$4, name$1, root, cb) {
6527
+ function validate(fs$3, name$1, root, cb) {
9496
6528
  if (name$1 === root) return cb(null, true);
9497
- fs$4.lstat(name$1, function(err, st) {
9498
- if (err && err.code === "ENOENT") return validate(fs$4, path$1.join(name$1, ".."), root, cb);
6529
+ fs$3.lstat(name$1, function(err, st) {
6530
+ if (err && err.code === "ENOENT") return validate(fs$3, path$1.join(name$1, ".."), root, cb);
9499
6531
  else if (err) return cb(err);
9500
6532
  cb(null, st.isDirectory());
9501
6533
  });
@@ -9507,17 +6539,17 @@ else if (err) return cb(err);
9507
6539
  function normalize(name$1) {
9508
6540
  return win32 ? name$1.replace(/\\/g, "/").replace(/[:?<>|]/g, "_") : name$1;
9509
6541
  }
9510
- function statAll(fs$4, stat, cwd, ignore, entries, sort) {
6542
+ function statAll(fs$3, stat, cwd, ignore, entries, sort) {
9511
6543
  if (!entries) entries = ["."];
9512
6544
  const queue = entries.slice(0);
9513
6545
  return function loop(callback) {
9514
6546
  if (!queue.length) return callback(null);
9515
6547
  const next = queue.shift();
9516
6548
  const nextAbs = path$1.join(cwd, next);
9517
- stat.call(fs$4, nextAbs, function(err, stat$1) {
6549
+ stat.call(fs$3, nextAbs, function(err, stat$1) {
9518
6550
  if (err) return callback(entries.indexOf(next) === -1 && err.code === "ENOENT" ? null : err);
9519
6551
  if (!stat$1.isDirectory()) return callback(null, next, stat$1);
9520
- fs$4.readdir(nextAbs, function(err$1, files$1) {
6552
+ fs$3.readdir(nextAbs, function(err$1, files$1) {
9521
6553
  if (err$1) return callback(err$1);
9522
6554
  if (sort) files$1.sort();
9523
6555
  for (let i = 0; i < files$1.length; i++) if (!ignore(path$1.join(cwd, next, files$1[i]))) queue.push(path$1.join(next, files$1[i]));
@@ -9660,7 +6692,7 @@ function getGlobalPreconditions(cwd, addons, addonSetupResult) {
9660
6692
 
9661
6693
  //#endregion
9662
6694
  //#region packages/cli/commands/add/index.ts
9663
- var import_picocolors$2 = __toESM(require_picocolors(), 1);
6695
+ var import_picocolors$2 = __toESM(require_picocolors$1(), 1);
9664
6696
  const aliases = officialAddons.map((c) => c.alias).filter((v) => v !== undefined);
9665
6697
  const addonsOptions = getAddonOptionFlags();
9666
6698
  const communityDetails = [];
@@ -9670,14 +6702,14 @@ const AddonsSchema = array(string());
9670
6702
  const AddonOptionFlagsSchema = object(addonOptionFlags);
9671
6703
  const OptionsSchema$1 = strictObject({
9672
6704
  cwd: string(),
9673
- install: boolean(),
6705
+ install: union([boolean(), picklist(AGENT_NAMES)]),
9674
6706
  preconditions: boolean(),
9675
6707
  community: optional(union([AddonsSchema, boolean()])),
9676
6708
  ...AddonOptionFlagsSchema.entries
9677
6709
  });
9678
6710
  const defaultPkgPath = up$1();
9679
6711
  const defaultCwd = defaultPkgPath ? path.dirname(defaultPkgPath) : undefined;
9680
- const add = new Command("add").description("applies specified add-ons into a project").argument("[add-on...]", "add-ons to install").option("-C, --cwd <path>", "path to working directory", defaultCwd).option("--no-install", "skip installing dependencies").option("--no-preconditions", "skip validating preconditions").configureHelp(helpConfig).action((addonArgs, opts) => {
6712
+ const add = new Command("add").description("applies specified add-ons into a project").argument("[add-on...]", "add-ons to install").option("-C, --cwd <path>", "path to working directory", defaultCwd).option("--no-preconditions", "skip validating preconditions").option("--no-install", "skip installing dependencies").addOption(installOption).configureHelp(helpConfig).action((addonArgs, opts) => {
9681
6713
  if (opts.cwd === undefined) {
9682
6714
  console.error("Invalid workspace: Please verify that you are inside of a Svelte project. You can also specify the working directory with `--cwd <path>`");
9683
6715
  process$1.exit(1);
@@ -9940,10 +6972,10 @@ else if (official[addonId][id] !== undefined) throw new Error(`Incompatible '--$
9940
6972
  log.success("Successfully setup add-ons");
9941
6973
  let packageManager;
9942
6974
  if (options$6.install) {
9943
- packageManager = await packageManagerPrompt(options$6.cwd);
6975
+ packageManager = options$6.install === true ? await packageManagerPrompt(options$6.cwd) : options$6.install;
9944
6976
  if (packageManager) {
9945
6977
  workspace.packageManager = packageManager;
9946
- addPnpmBuildDependendencies(workspace.cwd, packageManager, ["esbuild", ...addonPnpmBuildDependencies]);
6978
+ addPnpmBuildDependencies(workspace.cwd, packageManager, ["esbuild", ...addonPnpmBuildDependencies]);
9947
6979
  await installDependencies(packageManager, options$6.cwd);
9948
6980
  }
9949
6981
  }
@@ -10052,7 +7084,7 @@ function getOptionChoices(details) {
10052
7084
 
10053
7085
  //#endregion
10054
7086
  //#region packages/cli/commands/create.ts
10055
- var import_picocolors$1 = __toESM(require_picocolors(), 1);
7087
+ var import_picocolors$1 = __toESM(require_picocolors$1(), 1);
10056
7088
  const langs = ["ts", "jsdoc"];
10057
7089
  const langMap = {
10058
7090
  ts: "typescript",
@@ -10066,10 +7098,10 @@ const ProjectPathSchema = optional(string());
10066
7098
  const OptionsSchema = strictObject({
10067
7099
  types: pipe$1(optional(union([picklist(langs), boolean()])), transform((lang) => langMap[String(lang)])),
10068
7100
  addOns: boolean(),
10069
- install: boolean(),
7101
+ install: union([boolean(), picklist(AGENT_NAMES)]),
10070
7102
  template: optional(picklist(templateChoices))
10071
7103
  });
10072
- const create$1 = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created").addOption(templateOption).addOption(langOption).option("--no-types").option("--no-add-ons", "skips interactive add-on installer").option("--no-install", "skip installing dependencies").configureHelp(helpConfig).action((projectPath, opts) => {
7104
+ const create$1 = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created").addOption(templateOption).addOption(langOption).option("--no-types").option("--no-add-ons", "skips interactive add-on installer").option("--no-install", "skip installing dependencies").addOption(installOption).configureHelp(helpConfig).action((projectPath, opts) => {
10073
7105
  const cwd = parse(ProjectPathSchema, projectPath);
10074
7106
  const options$6 = parse(OptionsSchema, opts);
10075
7107
  runCommand(async () => {
@@ -10171,9 +7203,9 @@ async function createProject(cwd, options$6) {
10171
7203
  log.success("Project created");
10172
7204
  let packageManager;
10173
7205
  let addOnNextSteps;
10174
- const installDeps = async () => {
10175
- packageManager = await packageManagerPrompt(projectPath);
10176
- addPnpmBuildDependendencies(projectPath, packageManager, ["esbuild"]);
7206
+ const installDeps = async (install) => {
7207
+ packageManager = install === true ? await packageManagerPrompt(projectPath) : install;
7208
+ addPnpmBuildDependencies(projectPath, packageManager, ["esbuild"]);
10177
7209
  if (packageManager) await installDependencies(packageManager, projectPath);
10178
7210
  };
10179
7211
  if (options$6.addOns) {
@@ -10185,8 +7217,8 @@ async function createProject(cwd, options$6) {
10185
7217
  }, []);
10186
7218
  packageManager = pm;
10187
7219
  addOnNextSteps = nextSteps;
10188
- } else if (options$6.install) await installDeps();
10189
- if (packageManager === null && options$6.install) await installDeps();
7220
+ } else if (options$6.install) await installDeps(options$6.install);
7221
+ if (packageManager === null && options$6.install) await installDeps(options$6.install);
10190
7222
  return {
10191
7223
  directory: projectPath,
10192
7224
  addOnNextSteps,
@@ -10219,7 +7251,7 @@ function runMigrate(cwd, args) {
10219
7251
 
10220
7252
  //#endregion
10221
7253
  //#region packages/cli/commands/check.ts
10222
- var import_picocolors = __toESM(require_picocolors(), 1);
7254
+ var import_picocolors = __toESM(require_picocolors$1(), 1);
10223
7255
  const check = new Command("check").description("a CLI for checking your Svelte code").allowUnknownOption(true).allowExcessArguments(true).option("-C, --cwd <path>", "path to working directory", process$1.cwd()).configureHelp({ formatHelp() {
10224
7256
  runCheck(process$1.cwd(), ["--help"]);
10225
7257
  return "";