create-awesome-node-app 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3659 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined")
12
+ return require.apply(this, arguments);
13
+ throw new Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+
35
+ // ../../node_modules/commander/index.js
36
+ var require_commander = __commonJS({
37
+ "../../node_modules/commander/index.js"(exports, module) {
38
+ var EventEmitter = __require("events").EventEmitter;
39
+ var childProcess = __require("child_process");
40
+ var path = __require("path");
41
+ var fs = __require("fs");
42
+ var Help = class {
43
+ constructor() {
44
+ this.helpWidth = void 0;
45
+ this.sortSubcommands = false;
46
+ this.sortOptions = false;
47
+ }
48
+ /**
49
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
50
+ *
51
+ * @param {Command} cmd
52
+ * @returns {Command[]}
53
+ */
54
+ visibleCommands(cmd) {
55
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
56
+ if (cmd._hasImplicitHelpCommand()) {
57
+ const args = cmd._helpCommandnameAndArgs.split(/ +/);
58
+ const helpCommand = cmd.createCommand(args.shift()).helpOption(false);
59
+ helpCommand.description(cmd._helpCommandDescription);
60
+ helpCommand._parseExpectedArgs(args);
61
+ visibleCommands.push(helpCommand);
62
+ }
63
+ if (this.sortSubcommands) {
64
+ visibleCommands.sort((a, b) => {
65
+ return a.name().localeCompare(b.name());
66
+ });
67
+ }
68
+ return visibleCommands;
69
+ }
70
+ /**
71
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
72
+ *
73
+ * @param {Command} cmd
74
+ * @returns {Option[]}
75
+ */
76
+ visibleOptions(cmd) {
77
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
78
+ const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
79
+ const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
80
+ if (showShortHelpFlag || showLongHelpFlag) {
81
+ let helpOption;
82
+ if (!showShortHelpFlag) {
83
+ helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
84
+ } else if (!showLongHelpFlag) {
85
+ helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
86
+ } else {
87
+ helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
88
+ }
89
+ visibleOptions.push(helpOption);
90
+ }
91
+ if (this.sortOptions) {
92
+ const getSortKey = (option) => {
93
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
94
+ };
95
+ visibleOptions.sort((a, b) => {
96
+ return getSortKey(a).localeCompare(getSortKey(b));
97
+ });
98
+ }
99
+ return visibleOptions;
100
+ }
101
+ /**
102
+ * Get an array of the arguments which have descriptions.
103
+ *
104
+ * @param {Command} cmd
105
+ * @returns {{ term: string, description:string }[]}
106
+ */
107
+ visibleArguments(cmd) {
108
+ if (cmd._argsDescription && cmd._args.length) {
109
+ return cmd._args.map((argument) => {
110
+ return { term: argument.name, description: cmd._argsDescription[argument.name] || "" };
111
+ }, 0);
112
+ }
113
+ return [];
114
+ }
115
+ /**
116
+ * Get the command term to show in the list of subcommands.
117
+ *
118
+ * @param {Command} cmd
119
+ * @returns {string}
120
+ */
121
+ subcommandTerm(cmd) {
122
+ const args = cmd._args.map((arg) => humanReadableArgName(arg)).join(" ");
123
+ return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
124
+ (args ? " " + args : "");
125
+ }
126
+ /**
127
+ * Get the option term to show in the list of options.
128
+ *
129
+ * @param {Option} option
130
+ * @returns {string}
131
+ */
132
+ optionTerm(option) {
133
+ return option.flags;
134
+ }
135
+ /**
136
+ * Get the longest command term length.
137
+ *
138
+ * @param {Command} cmd
139
+ * @param {Help} helper
140
+ * @returns {number}
141
+ */
142
+ longestSubcommandTermLength(cmd, helper) {
143
+ return helper.visibleCommands(cmd).reduce((max, command) => {
144
+ return Math.max(max, helper.subcommandTerm(command).length);
145
+ }, 0);
146
+ }
147
+ /**
148
+ * Get the longest option term length.
149
+ *
150
+ * @param {Command} cmd
151
+ * @param {Help} helper
152
+ * @returns {number}
153
+ */
154
+ longestOptionTermLength(cmd, helper) {
155
+ return helper.visibleOptions(cmd).reduce((max, option) => {
156
+ return Math.max(max, helper.optionTerm(option).length);
157
+ }, 0);
158
+ }
159
+ /**
160
+ * Get the longest argument term length.
161
+ *
162
+ * @param {Command} cmd
163
+ * @param {Help} helper
164
+ * @returns {number}
165
+ */
166
+ longestArgumentTermLength(cmd, helper) {
167
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
168
+ return Math.max(max, argument.term.length);
169
+ }, 0);
170
+ }
171
+ /**
172
+ * Get the command usage to be displayed at the top of the built-in help.
173
+ *
174
+ * @param {Command} cmd
175
+ * @returns {string}
176
+ */
177
+ commandUsage(cmd) {
178
+ let cmdName = cmd._name;
179
+ if (cmd._aliases[0]) {
180
+ cmdName = cmdName + "|" + cmd._aliases[0];
181
+ }
182
+ let parentCmdNames = "";
183
+ for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
184
+ parentCmdNames = parentCmd.name() + " " + parentCmdNames;
185
+ }
186
+ return parentCmdNames + cmdName + " " + cmd.usage();
187
+ }
188
+ /**
189
+ * Get the description for the command.
190
+ *
191
+ * @param {Command} cmd
192
+ * @returns {string}
193
+ */
194
+ commandDescription(cmd) {
195
+ return cmd.description();
196
+ }
197
+ /**
198
+ * Get the command description to show in the list of subcommands.
199
+ *
200
+ * @param {Command} cmd
201
+ * @returns {string}
202
+ */
203
+ subcommandDescription(cmd) {
204
+ return cmd.description();
205
+ }
206
+ /**
207
+ * Get the option description to show in the list of options.
208
+ *
209
+ * @param {Option} option
210
+ * @return {string}
211
+ */
212
+ optionDescription(option) {
213
+ if (option.negate) {
214
+ return option.description;
215
+ }
216
+ const extraInfo = [];
217
+ if (option.argChoices) {
218
+ extraInfo.push(
219
+ // use stringify to match the display of the default value
220
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
221
+ );
222
+ }
223
+ if (option.defaultValue !== void 0) {
224
+ extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
225
+ }
226
+ if (extraInfo.length > 0) {
227
+ return `${option.description} (${extraInfo.join(", ")})`;
228
+ }
229
+ return option.description;
230
+ }
231
+ /**
232
+ * Generate the built-in help text.
233
+ *
234
+ * @param {Command} cmd
235
+ * @param {Help} helper
236
+ * @returns {string}
237
+ */
238
+ formatHelp(cmd, helper) {
239
+ const termWidth = helper.padWidth(cmd, helper);
240
+ const helpWidth = helper.helpWidth || 80;
241
+ const itemIndentWidth = 2;
242
+ const itemSeparatorWidth = 2;
243
+ function formatItem(term, description) {
244
+ if (description) {
245
+ const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
246
+ return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
247
+ }
248
+ return term;
249
+ }
250
+ ;
251
+ function formatList(textArray) {
252
+ return textArray.join("\n").replace(/^/gm, " ".repeat(itemIndentWidth));
253
+ }
254
+ let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
255
+ const commandDescription = helper.commandDescription(cmd);
256
+ if (commandDescription.length > 0) {
257
+ output = output.concat([commandDescription, ""]);
258
+ }
259
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
260
+ return formatItem(argument.term, argument.description);
261
+ });
262
+ if (argumentList.length > 0) {
263
+ output = output.concat(["Arguments:", formatList(argumentList), ""]);
264
+ }
265
+ const optionList = helper.visibleOptions(cmd).map((option) => {
266
+ return formatItem(helper.optionTerm(option), helper.optionDescription(option));
267
+ });
268
+ if (optionList.length > 0) {
269
+ output = output.concat(["Options:", formatList(optionList), ""]);
270
+ }
271
+ const commandList = helper.visibleCommands(cmd).map((cmd2) => {
272
+ return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
273
+ });
274
+ if (commandList.length > 0) {
275
+ output = output.concat(["Commands:", formatList(commandList), ""]);
276
+ }
277
+ return output.join("\n");
278
+ }
279
+ /**
280
+ * Calculate the pad width from the maximum term length.
281
+ *
282
+ * @param {Command} cmd
283
+ * @param {Help} helper
284
+ * @returns {number}
285
+ */
286
+ padWidth(cmd, helper) {
287
+ return Math.max(
288
+ helper.longestOptionTermLength(cmd, helper),
289
+ helper.longestSubcommandTermLength(cmd, helper),
290
+ helper.longestArgumentTermLength(cmd, helper)
291
+ );
292
+ }
293
+ /**
294
+ * Wrap the given string to width characters per line, with lines after the first indented.
295
+ * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
296
+ *
297
+ * @param {string} str
298
+ * @param {number} width
299
+ * @param {number} indent
300
+ * @param {number} [minColumnWidth=40]
301
+ * @return {string}
302
+ *
303
+ */
304
+ wrap(str, width, indent, minColumnWidth = 40) {
305
+ if (str.match(/[\n]\s+/))
306
+ return str;
307
+ const columnWidth = width - indent;
308
+ if (columnWidth < minColumnWidth)
309
+ return str;
310
+ const leadingStr = str.substr(0, indent);
311
+ const columnText = str.substr(indent);
312
+ const indentString = " ".repeat(indent);
313
+ const regex = new RegExp(".{1," + (columnWidth - 1) + "}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)", "g");
314
+ const lines = columnText.match(regex) || [];
315
+ return leadingStr + lines.map((line, i) => {
316
+ if (line.slice(-1) === "\n") {
317
+ line = line.slice(0, line.length - 1);
318
+ }
319
+ return (i > 0 ? indentString : "") + line.trimRight();
320
+ }).join("\n");
321
+ }
322
+ };
323
+ var Option = class {
324
+ /**
325
+ * Initialize a new `Option` with the given `flags` and `description`.
326
+ *
327
+ * @param {string} flags
328
+ * @param {string} [description]
329
+ */
330
+ constructor(flags, description) {
331
+ this.flags = flags;
332
+ this.description = description || "";
333
+ this.required = flags.includes("<");
334
+ this.optional = flags.includes("[");
335
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
336
+ this.mandatory = false;
337
+ const optionFlags = _parseOptionFlags(flags);
338
+ this.short = optionFlags.shortFlag;
339
+ this.long = optionFlags.longFlag;
340
+ this.negate = false;
341
+ if (this.long) {
342
+ this.negate = this.long.startsWith("--no-");
343
+ }
344
+ this.defaultValue = void 0;
345
+ this.defaultValueDescription = void 0;
346
+ this.parseArg = void 0;
347
+ this.hidden = false;
348
+ this.argChoices = void 0;
349
+ }
350
+ /**
351
+ * Set the default value, and optionally supply the description to be displayed in the help.
352
+ *
353
+ * @param {any} value
354
+ * @param {string} [description]
355
+ * @return {Option}
356
+ */
357
+ default(value, description) {
358
+ this.defaultValue = value;
359
+ this.defaultValueDescription = description;
360
+ return this;
361
+ }
362
+ /**
363
+ * Set the custom handler for processing CLI option arguments into option values.
364
+ *
365
+ * @param {Function} [fn]
366
+ * @return {Option}
367
+ */
368
+ argParser(fn) {
369
+ this.parseArg = fn;
370
+ return this;
371
+ }
372
+ /**
373
+ * Whether the option is mandatory and must have a value after parsing.
374
+ *
375
+ * @param {boolean} [mandatory=true]
376
+ * @return {Option}
377
+ */
378
+ makeOptionMandatory(mandatory = true) {
379
+ this.mandatory = !!mandatory;
380
+ return this;
381
+ }
382
+ /**
383
+ * Hide option in help.
384
+ *
385
+ * @param {boolean} [hide=true]
386
+ * @return {Option}
387
+ */
388
+ hideHelp(hide = true) {
389
+ this.hidden = !!hide;
390
+ return this;
391
+ }
392
+ /**
393
+ * @api private
394
+ */
395
+ _concatValue(value, previous) {
396
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
397
+ return [value];
398
+ }
399
+ return previous.concat(value);
400
+ }
401
+ /**
402
+ * Only allow option value to be one of choices.
403
+ *
404
+ * @param {string[]} values
405
+ * @return {Option}
406
+ */
407
+ choices(values) {
408
+ this.argChoices = values;
409
+ this.parseArg = (arg, previous) => {
410
+ if (!values.includes(arg)) {
411
+ throw new InvalidOptionArgumentError(`Allowed choices are ${values.join(", ")}.`);
412
+ }
413
+ if (this.variadic) {
414
+ return this._concatValue(arg, previous);
415
+ }
416
+ return arg;
417
+ };
418
+ return this;
419
+ }
420
+ /**
421
+ * Return option name.
422
+ *
423
+ * @return {string}
424
+ */
425
+ name() {
426
+ if (this.long) {
427
+ return this.long.replace(/^--/, "");
428
+ }
429
+ return this.short.replace(/^-/, "");
430
+ }
431
+ /**
432
+ * Return option name, in a camelcase format that can be used
433
+ * as a object attribute key.
434
+ *
435
+ * @return {string}
436
+ * @api private
437
+ */
438
+ attributeName() {
439
+ return camelcase(this.name().replace(/^no-/, ""));
440
+ }
441
+ /**
442
+ * Check if `arg` matches the short or long flag.
443
+ *
444
+ * @param {string} arg
445
+ * @return {boolean}
446
+ * @api private
447
+ */
448
+ is(arg) {
449
+ return this.short === arg || this.long === arg;
450
+ }
451
+ };
452
+ var CommanderError = class extends Error {
453
+ /**
454
+ * Constructs the CommanderError class
455
+ * @param {number} exitCode suggested exit code which could be used with process.exit
456
+ * @param {string} code an id string representing the error
457
+ * @param {string} message human-readable description of the error
458
+ * @constructor
459
+ */
460
+ constructor(exitCode, code, message) {
461
+ super(message);
462
+ Error.captureStackTrace(this, this.constructor);
463
+ this.name = this.constructor.name;
464
+ this.code = code;
465
+ this.exitCode = exitCode;
466
+ this.nestedError = void 0;
467
+ }
468
+ };
469
+ var InvalidOptionArgumentError = class extends CommanderError {
470
+ /**
471
+ * Constructs the InvalidOptionArgumentError class
472
+ * @param {string} [message] explanation of why argument is invalid
473
+ * @constructor
474
+ */
475
+ constructor(message) {
476
+ super(1, "commander.invalidOptionArgument", message);
477
+ Error.captureStackTrace(this, this.constructor);
478
+ this.name = this.constructor.name;
479
+ }
480
+ };
481
+ var Command = class extends EventEmitter {
482
+ /**
483
+ * Initialize a new `Command`.
484
+ *
485
+ * @param {string} [name]
486
+ */
487
+ constructor(name) {
488
+ super();
489
+ this.commands = [];
490
+ this.options = [];
491
+ this.parent = null;
492
+ this._allowUnknownOption = false;
493
+ this._allowExcessArguments = true;
494
+ this._args = [];
495
+ this.rawArgs = null;
496
+ this._scriptPath = null;
497
+ this._name = name || "";
498
+ this._optionValues = {};
499
+ this._storeOptionsAsProperties = false;
500
+ this._actionResults = [];
501
+ this._actionHandler = null;
502
+ this._executableHandler = false;
503
+ this._executableFile = null;
504
+ this._defaultCommandName = null;
505
+ this._exitCallback = null;
506
+ this._aliases = [];
507
+ this._combineFlagAndOptionalValue = true;
508
+ this._description = "";
509
+ this._argsDescription = void 0;
510
+ this._enablePositionalOptions = false;
511
+ this._passThroughOptions = false;
512
+ this._outputConfiguration = {
513
+ writeOut: (str) => process.stdout.write(str),
514
+ writeErr: (str) => process.stderr.write(str),
515
+ getOutHelpWidth: () => process.stdout.isTTY ? process.stdout.columns : void 0,
516
+ getErrHelpWidth: () => process.stderr.isTTY ? process.stderr.columns : void 0,
517
+ outputError: (str, write) => write(str)
518
+ };
519
+ this._hidden = false;
520
+ this._hasHelpOption = true;
521
+ this._helpFlags = "-h, --help";
522
+ this._helpDescription = "display help for command";
523
+ this._helpShortFlag = "-h";
524
+ this._helpLongFlag = "--help";
525
+ this._addImplicitHelpCommand = void 0;
526
+ this._helpCommandName = "help";
527
+ this._helpCommandnameAndArgs = "help [command]";
528
+ this._helpCommandDescription = "display help for command";
529
+ this._helpConfiguration = {};
530
+ }
531
+ /**
532
+ * Define a command.
533
+ *
534
+ * There are two styles of command: pay attention to where to put the description.
535
+ *
536
+ * Examples:
537
+ *
538
+ * // Command implemented using action handler (description is supplied separately to `.command`)
539
+ * program
540
+ * .command('clone <source> [destination]')
541
+ * .description('clone a repository into a newly created directory')
542
+ * .action((source, destination) => {
543
+ * console.log('clone command called');
544
+ * });
545
+ *
546
+ * // Command implemented using separate executable file (description is second parameter to `.command`)
547
+ * program
548
+ * .command('start <service>', 'start named service')
549
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
550
+ *
551
+ * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
552
+ * @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
553
+ * @param {Object} [execOpts] - configuration options (for executable)
554
+ * @return {Command} returns new command for action handler, or `this` for executable command
555
+ */
556
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
557
+ let desc = actionOptsOrExecDesc;
558
+ let opts = execOpts;
559
+ if (typeof desc === "object" && desc !== null) {
560
+ opts = desc;
561
+ desc = null;
562
+ }
563
+ opts = opts || {};
564
+ const args = nameAndArgs.split(/ +/);
565
+ const cmd = this.createCommand(args.shift());
566
+ if (desc) {
567
+ cmd.description(desc);
568
+ cmd._executableHandler = true;
569
+ }
570
+ if (opts.isDefault)
571
+ this._defaultCommandName = cmd._name;
572
+ cmd._outputConfiguration = this._outputConfiguration;
573
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
574
+ cmd._hasHelpOption = this._hasHelpOption;
575
+ cmd._helpFlags = this._helpFlags;
576
+ cmd._helpDescription = this._helpDescription;
577
+ cmd._helpShortFlag = this._helpShortFlag;
578
+ cmd._helpLongFlag = this._helpLongFlag;
579
+ cmd._helpCommandName = this._helpCommandName;
580
+ cmd._helpCommandnameAndArgs = this._helpCommandnameAndArgs;
581
+ cmd._helpCommandDescription = this._helpCommandDescription;
582
+ cmd._helpConfiguration = this._helpConfiguration;
583
+ cmd._exitCallback = this._exitCallback;
584
+ cmd._storeOptionsAsProperties = this._storeOptionsAsProperties;
585
+ cmd._combineFlagAndOptionalValue = this._combineFlagAndOptionalValue;
586
+ cmd._allowExcessArguments = this._allowExcessArguments;
587
+ cmd._enablePositionalOptions = this._enablePositionalOptions;
588
+ cmd._executableFile = opts.executableFile || null;
589
+ this.commands.push(cmd);
590
+ cmd._parseExpectedArgs(args);
591
+ cmd.parent = this;
592
+ if (desc)
593
+ return this;
594
+ return cmd;
595
+ }
596
+ /**
597
+ * Factory routine to create a new unattached command.
598
+ *
599
+ * See .command() for creating an attached subcommand, which uses this routine to
600
+ * create the command. You can override createCommand to customise subcommands.
601
+ *
602
+ * @param {string} [name]
603
+ * @return {Command} new command
604
+ */
605
+ createCommand(name) {
606
+ return new Command(name);
607
+ }
608
+ /**
609
+ * You can customise the help with a subclass of Help by overriding createHelp,
610
+ * or by overriding Help properties using configureHelp().
611
+ *
612
+ * @return {Help}
613
+ */
614
+ createHelp() {
615
+ return Object.assign(new Help(), this.configureHelp());
616
+ }
617
+ /**
618
+ * You can customise the help by overriding Help properties using configureHelp(),
619
+ * or with a subclass of Help by overriding createHelp().
620
+ *
621
+ * @param {Object} [configuration] - configuration options
622
+ * @return {Command|Object} `this` command for chaining, or stored configuration
623
+ */
624
+ configureHelp(configuration) {
625
+ if (configuration === void 0)
626
+ return this._helpConfiguration;
627
+ this._helpConfiguration = configuration;
628
+ return this;
629
+ }
630
+ /**
631
+ * The default output goes to stdout and stderr. You can customise this for special
632
+ * applications. You can also customise the display of errors by overriding outputError.
633
+ *
634
+ * The configuration properties are all functions:
635
+ *
636
+ * // functions to change where being written, stdout and stderr
637
+ * writeOut(str)
638
+ * writeErr(str)
639
+ * // matching functions to specify width for wrapping help
640
+ * getOutHelpWidth()
641
+ * getErrHelpWidth()
642
+ * // functions based on what is being written out
643
+ * outputError(str, write) // used for displaying errors, and not used for displaying help
644
+ *
645
+ * @param {Object} [configuration] - configuration options
646
+ * @return {Command|Object} `this` command for chaining, or stored configuration
647
+ */
648
+ configureOutput(configuration) {
649
+ if (configuration === void 0)
650
+ return this._outputConfiguration;
651
+ Object.assign(this._outputConfiguration, configuration);
652
+ return this;
653
+ }
654
+ /**
655
+ * Add a prepared subcommand.
656
+ *
657
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
658
+ *
659
+ * @param {Command} cmd - new subcommand
660
+ * @param {Object} [opts] - configuration options
661
+ * @return {Command} `this` command for chaining
662
+ */
663
+ addCommand(cmd, opts) {
664
+ if (!cmd._name)
665
+ throw new Error("Command passed to .addCommand() must have a name");
666
+ function checkExplicitNames(commandArray) {
667
+ commandArray.forEach((cmd2) => {
668
+ if (cmd2._executableHandler && !cmd2._executableFile) {
669
+ throw new Error(`Must specify executableFile for deeply nested executable: ${cmd2.name()}`);
670
+ }
671
+ checkExplicitNames(cmd2.commands);
672
+ });
673
+ }
674
+ checkExplicitNames(cmd.commands);
675
+ opts = opts || {};
676
+ if (opts.isDefault)
677
+ this._defaultCommandName = cmd._name;
678
+ if (opts.noHelp || opts.hidden)
679
+ cmd._hidden = true;
680
+ this.commands.push(cmd);
681
+ cmd.parent = this;
682
+ return this;
683
+ }
684
+ /**
685
+ * Define argument syntax for the command.
686
+ */
687
+ arguments(desc) {
688
+ return this._parseExpectedArgs(desc.split(/ +/));
689
+ }
690
+ /**
691
+ * Override default decision whether to add implicit help command.
692
+ *
693
+ * addHelpCommand() // force on
694
+ * addHelpCommand(false); // force off
695
+ * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
696
+ *
697
+ * @return {Command} `this` command for chaining
698
+ */
699
+ addHelpCommand(enableOrNameAndArgs, description) {
700
+ if (enableOrNameAndArgs === false) {
701
+ this._addImplicitHelpCommand = false;
702
+ } else {
703
+ this._addImplicitHelpCommand = true;
704
+ if (typeof enableOrNameAndArgs === "string") {
705
+ this._helpCommandName = enableOrNameAndArgs.split(" ")[0];
706
+ this._helpCommandnameAndArgs = enableOrNameAndArgs;
707
+ }
708
+ this._helpCommandDescription = description || this._helpCommandDescription;
709
+ }
710
+ return this;
711
+ }
712
+ /**
713
+ * @return {boolean}
714
+ * @api private
715
+ */
716
+ _hasImplicitHelpCommand() {
717
+ if (this._addImplicitHelpCommand === void 0) {
718
+ return this.commands.length && !this._actionHandler && !this._findCommand("help");
719
+ }
720
+ return this._addImplicitHelpCommand;
721
+ }
722
+ /**
723
+ * Parse expected `args`.
724
+ *
725
+ * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
726
+ *
727
+ * @param {Array} args
728
+ * @return {Command} `this` command for chaining
729
+ * @api private
730
+ */
731
+ _parseExpectedArgs(args) {
732
+ if (!args.length)
733
+ return;
734
+ args.forEach((arg) => {
735
+ const argDetails = {
736
+ required: false,
737
+ name: "",
738
+ variadic: false
739
+ };
740
+ switch (arg[0]) {
741
+ case "<":
742
+ argDetails.required = true;
743
+ argDetails.name = arg.slice(1, -1);
744
+ break;
745
+ case "[":
746
+ argDetails.name = arg.slice(1, -1);
747
+ break;
748
+ }
749
+ if (argDetails.name.length > 3 && argDetails.name.slice(-3) === "...") {
750
+ argDetails.variadic = true;
751
+ argDetails.name = argDetails.name.slice(0, -3);
752
+ }
753
+ if (argDetails.name) {
754
+ this._args.push(argDetails);
755
+ }
756
+ });
757
+ this._args.forEach((arg, i) => {
758
+ if (arg.variadic && i < this._args.length - 1) {
759
+ throw new Error(`only the last argument can be variadic '${arg.name}'`);
760
+ }
761
+ });
762
+ return this;
763
+ }
764
+ /**
765
+ * Register callback to use as replacement for calling process.exit.
766
+ *
767
+ * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
768
+ * @return {Command} `this` command for chaining
769
+ */
770
+ exitOverride(fn) {
771
+ if (fn) {
772
+ this._exitCallback = fn;
773
+ } else {
774
+ this._exitCallback = (err) => {
775
+ if (err.code !== "commander.executeSubCommandAsync") {
776
+ throw err;
777
+ } else {
778
+ }
779
+ };
780
+ }
781
+ return this;
782
+ }
783
+ /**
784
+ * Call process.exit, and _exitCallback if defined.
785
+ *
786
+ * @param {number} exitCode exit code for using with process.exit
787
+ * @param {string} code an id string representing the error
788
+ * @param {string} message human-readable description of the error
789
+ * @return never
790
+ * @api private
791
+ */
792
+ _exit(exitCode, code, message) {
793
+ if (this._exitCallback) {
794
+ this._exitCallback(new CommanderError(exitCode, code, message));
795
+ }
796
+ process.exit(exitCode);
797
+ }
798
+ /**
799
+ * Register callback `fn` for the command.
800
+ *
801
+ * Examples:
802
+ *
803
+ * program
804
+ * .command('help')
805
+ * .description('display verbose help')
806
+ * .action(function() {
807
+ * // output help here
808
+ * });
809
+ *
810
+ * @param {Function} fn
811
+ * @return {Command} `this` command for chaining
812
+ */
813
+ action(fn) {
814
+ const listener = (args) => {
815
+ const expectedArgsCount = this._args.length;
816
+ const actionArgs = args.slice(0, expectedArgsCount);
817
+ if (this._storeOptionsAsProperties) {
818
+ actionArgs[expectedArgsCount] = this;
819
+ } else {
820
+ actionArgs[expectedArgsCount] = this.opts();
821
+ }
822
+ actionArgs.push(this);
823
+ const actionResult = fn.apply(this, actionArgs);
824
+ let rootCommand = this;
825
+ while (rootCommand.parent) {
826
+ rootCommand = rootCommand.parent;
827
+ }
828
+ rootCommand._actionResults.push(actionResult);
829
+ };
830
+ this._actionHandler = listener;
831
+ return this;
832
+ }
833
+ /**
834
+ * Factory routine to create a new unattached option.
835
+ *
836
+ * See .option() for creating an attached option, which uses this routine to
837
+ * create the option. You can override createOption to return a custom option.
838
+ *
839
+ * @param {string} flags
840
+ * @param {string} [description]
841
+ * @return {Option} new option
842
+ */
843
+ createOption(flags, description) {
844
+ return new Option(flags, description);
845
+ }
846
+ /**
847
+ * Add an option.
848
+ *
849
+ * @param {Option} option
850
+ * @return {Command} `this` command for chaining
851
+ */
852
+ addOption(option) {
853
+ const oname = option.name();
854
+ const name = option.attributeName();
855
+ let defaultValue = option.defaultValue;
856
+ if (option.negate || option.optional || option.required || typeof defaultValue === "boolean") {
857
+ if (option.negate) {
858
+ const positiveLongFlag = option.long.replace(/^--no-/, "--");
859
+ defaultValue = this._findOption(positiveLongFlag) ? this._getOptionValue(name) : true;
860
+ }
861
+ if (defaultValue !== void 0) {
862
+ this._setOptionValue(name, defaultValue);
863
+ }
864
+ }
865
+ this.options.push(option);
866
+ this.on("option:" + oname, (val) => {
867
+ const oldValue = this._getOptionValue(name);
868
+ if (val !== null && option.parseArg) {
869
+ try {
870
+ val = option.parseArg(val, oldValue === void 0 ? defaultValue : oldValue);
871
+ } catch (err) {
872
+ if (err.code === "commander.invalidOptionArgument") {
873
+ const message = `error: option '${option.flags}' argument '${val}' is invalid. ${err.message}`;
874
+ this._displayError(err.exitCode, err.code, message);
875
+ }
876
+ throw err;
877
+ }
878
+ } else if (val !== null && option.variadic) {
879
+ val = option._concatValue(val, oldValue);
880
+ }
881
+ if (typeof oldValue === "boolean" || typeof oldValue === "undefined") {
882
+ if (val == null) {
883
+ this._setOptionValue(name, option.negate ? false : defaultValue || true);
884
+ } else {
885
+ this._setOptionValue(name, val);
886
+ }
887
+ } else if (val !== null) {
888
+ this._setOptionValue(name, option.negate ? false : val);
889
+ }
890
+ });
891
+ return this;
892
+ }
893
+ /**
894
+ * Internal implementation shared by .option() and .requiredOption()
895
+ *
896
+ * @api private
897
+ */
898
+ _optionEx(config, flags, description, fn, defaultValue) {
899
+ const option = this.createOption(flags, description);
900
+ option.makeOptionMandatory(!!config.mandatory);
901
+ if (typeof fn === "function") {
902
+ option.default(defaultValue).argParser(fn);
903
+ } else if (fn instanceof RegExp) {
904
+ const regex = fn;
905
+ fn = (val, def) => {
906
+ const m = regex.exec(val);
907
+ return m ? m[0] : def;
908
+ };
909
+ option.default(defaultValue).argParser(fn);
910
+ } else {
911
+ option.default(fn);
912
+ }
913
+ return this.addOption(option);
914
+ }
915
+ /**
916
+ * Define option with `flags`, `description` and optional
917
+ * coercion `fn`.
918
+ *
919
+ * The `flags` string contains the short and/or long flags,
920
+ * separated by comma, a pipe or space. The following are all valid
921
+ * all will output this way when `--help` is used.
922
+ *
923
+ * "-p, --pepper"
924
+ * "-p|--pepper"
925
+ * "-p --pepper"
926
+ *
927
+ * Examples:
928
+ *
929
+ * // simple boolean defaulting to undefined
930
+ * program.option('-p, --pepper', 'add pepper');
931
+ *
932
+ * program.pepper
933
+ * // => undefined
934
+ *
935
+ * --pepper
936
+ * program.pepper
937
+ * // => true
938
+ *
939
+ * // simple boolean defaulting to true (unless non-negated option is also defined)
940
+ * program.option('-C, --no-cheese', 'remove cheese');
941
+ *
942
+ * program.cheese
943
+ * // => true
944
+ *
945
+ * --no-cheese
946
+ * program.cheese
947
+ * // => false
948
+ *
949
+ * // required argument
950
+ * program.option('-C, --chdir <path>', 'change the working directory');
951
+ *
952
+ * --chdir /tmp
953
+ * program.chdir
954
+ * // => "/tmp"
955
+ *
956
+ * // optional argument
957
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
958
+ *
959
+ * @param {string} flags
960
+ * @param {string} [description]
961
+ * @param {Function|*} [fn] - custom option processing function or default value
962
+ * @param {*} [defaultValue]
963
+ * @return {Command} `this` command for chaining
964
+ */
965
+ option(flags, description, fn, defaultValue) {
966
+ return this._optionEx({}, flags, description, fn, defaultValue);
967
+ }
968
+ /**
969
+ * Add a required option which must have a value after parsing. This usually means
970
+ * the option must be specified on the command line. (Otherwise the same as .option().)
971
+ *
972
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
973
+ *
974
+ * @param {string} flags
975
+ * @param {string} [description]
976
+ * @param {Function|*} [fn] - custom option processing function or default value
977
+ * @param {*} [defaultValue]
978
+ * @return {Command} `this` command for chaining
979
+ */
980
+ requiredOption(flags, description, fn, defaultValue) {
981
+ return this._optionEx({ mandatory: true }, flags, description, fn, defaultValue);
982
+ }
983
+ /**
984
+ * Alter parsing of short flags with optional values.
985
+ *
986
+ * Examples:
987
+ *
988
+ * // for `.option('-f,--flag [value]'):
989
+ * .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
990
+ * .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
991
+ *
992
+ * @param {Boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.
993
+ */
994
+ combineFlagAndOptionalValue(combine = true) {
995
+ this._combineFlagAndOptionalValue = !!combine;
996
+ return this;
997
+ }
998
+ /**
999
+ * Allow unknown options on the command line.
1000
+ *
1001
+ * @param {Boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown
1002
+ * for unknown options.
1003
+ */
1004
+ allowUnknownOption(allowUnknown = true) {
1005
+ this._allowUnknownOption = !!allowUnknown;
1006
+ return this;
1007
+ }
1008
+ /**
1009
+ * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1010
+ *
1011
+ * @param {Boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown
1012
+ * for excess arguments.
1013
+ */
1014
+ allowExcessArguments(allowExcess = true) {
1015
+ this._allowExcessArguments = !!allowExcess;
1016
+ return this;
1017
+ }
1018
+ /**
1019
+ * Enable positional options. Positional means global options are specified before subcommands which lets
1020
+ * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1021
+ * The default behaviour is non-positional and global options may appear anywhere on the command line.
1022
+ *
1023
+ * @param {Boolean} [positional=true]
1024
+ */
1025
+ enablePositionalOptions(positional = true) {
1026
+ this._enablePositionalOptions = !!positional;
1027
+ return this;
1028
+ }
1029
+ /**
1030
+ * Pass through options that come after command-arguments rather than treat them as command-options,
1031
+ * so actual command-options come before command-arguments. Turning this on for a subcommand requires
1032
+ * positional options to have been enabled on the program (parent commands).
1033
+ * The default behaviour is non-positional and options may appear before or after command-arguments.
1034
+ *
1035
+ * @param {Boolean} [passThrough=true]
1036
+ * for unknown options.
1037
+ */
1038
+ passThroughOptions(passThrough = true) {
1039
+ this._passThroughOptions = !!passThrough;
1040
+ if (!!this.parent && passThrough && !this.parent._enablePositionalOptions) {
1041
+ throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
1042
+ }
1043
+ return this;
1044
+ }
1045
+ /**
1046
+ * Whether to store option values as properties on command object,
1047
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
1048
+ *
1049
+ * @param {boolean} [storeAsProperties=true]
1050
+ * @return {Command} `this` command for chaining
1051
+ */
1052
+ storeOptionsAsProperties(storeAsProperties = true) {
1053
+ this._storeOptionsAsProperties = !!storeAsProperties;
1054
+ if (this.options.length) {
1055
+ throw new Error("call .storeOptionsAsProperties() before adding options");
1056
+ }
1057
+ return this;
1058
+ }
1059
+ /**
1060
+ * Store option value
1061
+ *
1062
+ * @param {string} key
1063
+ * @param {Object} value
1064
+ * @api private
1065
+ */
1066
+ _setOptionValue(key, value) {
1067
+ if (this._storeOptionsAsProperties) {
1068
+ this[key] = value;
1069
+ } else {
1070
+ this._optionValues[key] = value;
1071
+ }
1072
+ }
1073
+ /**
1074
+ * Retrieve option value
1075
+ *
1076
+ * @param {string} key
1077
+ * @return {Object} value
1078
+ * @api private
1079
+ */
1080
+ _getOptionValue(key) {
1081
+ if (this._storeOptionsAsProperties) {
1082
+ return this[key];
1083
+ }
1084
+ return this._optionValues[key];
1085
+ }
1086
+ /**
1087
+ * Parse `argv`, setting options and invoking commands when defined.
1088
+ *
1089
+ * The default expectation is that the arguments are from node and have the application as argv[0]
1090
+ * and the script being run in argv[1], with user parameters after that.
1091
+ *
1092
+ * Examples:
1093
+ *
1094
+ * program.parse(process.argv);
1095
+ * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
1096
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1097
+ *
1098
+ * @param {string[]} [argv] - optional, defaults to process.argv
1099
+ * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
1100
+ * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
1101
+ * @return {Command} `this` command for chaining
1102
+ */
1103
+ parse(argv, parseOptions) {
1104
+ if (argv !== void 0 && !Array.isArray(argv)) {
1105
+ throw new Error("first parameter to parse must be array or undefined");
1106
+ }
1107
+ parseOptions = parseOptions || {};
1108
+ if (argv === void 0) {
1109
+ argv = process.argv;
1110
+ if (process.versions && process.versions.electron) {
1111
+ parseOptions.from = "electron";
1112
+ }
1113
+ }
1114
+ this.rawArgs = argv.slice();
1115
+ let userArgs;
1116
+ switch (parseOptions.from) {
1117
+ case void 0:
1118
+ case "node":
1119
+ this._scriptPath = argv[1];
1120
+ userArgs = argv.slice(2);
1121
+ break;
1122
+ case "electron":
1123
+ if (process.defaultApp) {
1124
+ this._scriptPath = argv[1];
1125
+ userArgs = argv.slice(2);
1126
+ } else {
1127
+ userArgs = argv.slice(1);
1128
+ }
1129
+ break;
1130
+ case "user":
1131
+ userArgs = argv.slice(0);
1132
+ break;
1133
+ default:
1134
+ throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
1135
+ }
1136
+ if (!this._scriptPath && __require.main) {
1137
+ this._scriptPath = __require.main.filename;
1138
+ }
1139
+ this._name = this._name || this._scriptPath && path.basename(this._scriptPath, path.extname(this._scriptPath));
1140
+ this._parseCommand([], userArgs);
1141
+ return this;
1142
+ }
1143
+ /**
1144
+ * Parse `argv`, setting options and invoking commands when defined.
1145
+ *
1146
+ * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
1147
+ *
1148
+ * The default expectation is that the arguments are from node and have the application as argv[0]
1149
+ * and the script being run in argv[1], with user parameters after that.
1150
+ *
1151
+ * Examples:
1152
+ *
1153
+ * program.parseAsync(process.argv);
1154
+ * program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
1155
+ * program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1156
+ *
1157
+ * @param {string[]} [argv]
1158
+ * @param {Object} [parseOptions]
1159
+ * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
1160
+ * @return {Promise}
1161
+ */
1162
+ parseAsync(argv, parseOptions) {
1163
+ this.parse(argv, parseOptions);
1164
+ return Promise.all(this._actionResults).then(() => this);
1165
+ }
1166
+ /**
1167
+ * Execute a sub-command executable.
1168
+ *
1169
+ * @api private
1170
+ */
1171
+ _executeSubCommand(subcommand, args) {
1172
+ args = args.slice();
1173
+ let launchWithNode = false;
1174
+ const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1175
+ this._checkForMissingMandatoryOptions();
1176
+ let scriptPath = this._scriptPath;
1177
+ if (!scriptPath && __require.main) {
1178
+ scriptPath = __require.main.filename;
1179
+ }
1180
+ let baseDir;
1181
+ try {
1182
+ const resolvedLink = fs.realpathSync(scriptPath);
1183
+ baseDir = path.dirname(resolvedLink);
1184
+ } catch (e) {
1185
+ baseDir = ".";
1186
+ }
1187
+ let bin = path.basename(scriptPath, path.extname(scriptPath)) + "-" + subcommand._name;
1188
+ if (subcommand._executableFile) {
1189
+ bin = subcommand._executableFile;
1190
+ }
1191
+ const localBin = path.join(baseDir, bin);
1192
+ if (fs.existsSync(localBin)) {
1193
+ bin = localBin;
1194
+ } else {
1195
+ sourceExt.forEach((ext) => {
1196
+ if (fs.existsSync(`${localBin}${ext}`)) {
1197
+ bin = `${localBin}${ext}`;
1198
+ }
1199
+ });
1200
+ }
1201
+ launchWithNode = sourceExt.includes(path.extname(bin));
1202
+ let proc;
1203
+ if (process.platform !== "win32") {
1204
+ if (launchWithNode) {
1205
+ args.unshift(bin);
1206
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
1207
+ proc = childProcess.spawn(process.argv[0], args, { stdio: "inherit" });
1208
+ } else {
1209
+ proc = childProcess.spawn(bin, args, { stdio: "inherit" });
1210
+ }
1211
+ } else {
1212
+ args.unshift(bin);
1213
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
1214
+ proc = childProcess.spawn(process.execPath, args, { stdio: "inherit" });
1215
+ }
1216
+ const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1217
+ signals.forEach((signal) => {
1218
+ process.on(signal, () => {
1219
+ if (proc.killed === false && proc.exitCode === null) {
1220
+ proc.kill(signal);
1221
+ }
1222
+ });
1223
+ });
1224
+ const exitCallback = this._exitCallback;
1225
+ if (!exitCallback) {
1226
+ proc.on("close", process.exit.bind(process));
1227
+ } else {
1228
+ proc.on("close", () => {
1229
+ exitCallback(new CommanderError(process.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
1230
+ });
1231
+ }
1232
+ proc.on("error", (err) => {
1233
+ if (err.code === "ENOENT") {
1234
+ const executableMissing = `'${bin}' does not exist
1235
+ - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
1236
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name`;
1237
+ throw new Error(executableMissing);
1238
+ } else if (err.code === "EACCES") {
1239
+ throw new Error(`'${bin}' not executable`);
1240
+ }
1241
+ if (!exitCallback) {
1242
+ process.exit(1);
1243
+ } else {
1244
+ const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
1245
+ wrappedError.nestedError = err;
1246
+ exitCallback(wrappedError);
1247
+ }
1248
+ });
1249
+ this.runningCommand = proc;
1250
+ }
1251
+ /**
1252
+ * @api private
1253
+ */
1254
+ _dispatchSubcommand(commandName, operands, unknown) {
1255
+ const subCommand = this._findCommand(commandName);
1256
+ if (!subCommand)
1257
+ this.help({ error: true });
1258
+ if (subCommand._executableHandler) {
1259
+ this._executeSubCommand(subCommand, operands.concat(unknown));
1260
+ } else {
1261
+ subCommand._parseCommand(operands, unknown);
1262
+ }
1263
+ }
1264
+ /**
1265
+ * Process arguments in context of this command.
1266
+ *
1267
+ * @api private
1268
+ */
1269
+ _parseCommand(operands, unknown) {
1270
+ const parsed = this.parseOptions(unknown);
1271
+ operands = operands.concat(parsed.operands);
1272
+ unknown = parsed.unknown;
1273
+ this.args = operands.concat(unknown);
1274
+ if (operands && this._findCommand(operands[0])) {
1275
+ this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
1276
+ } else if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {
1277
+ if (operands.length === 1) {
1278
+ this.help();
1279
+ } else {
1280
+ this._dispatchSubcommand(operands[1], [], [this._helpLongFlag]);
1281
+ }
1282
+ } else if (this._defaultCommandName) {
1283
+ outputHelpIfRequested(this, unknown);
1284
+ this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
1285
+ } else {
1286
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
1287
+ this.help({ error: true });
1288
+ }
1289
+ outputHelpIfRequested(this, parsed.unknown);
1290
+ this._checkForMissingMandatoryOptions();
1291
+ const checkForUnknownOptions = () => {
1292
+ if (parsed.unknown.length > 0) {
1293
+ this.unknownOption(parsed.unknown[0]);
1294
+ }
1295
+ };
1296
+ const commandEvent = `command:${this.name()}`;
1297
+ if (this._actionHandler) {
1298
+ checkForUnknownOptions();
1299
+ const args = this.args.slice();
1300
+ this._args.forEach((arg, i) => {
1301
+ if (arg.required && args[i] == null) {
1302
+ this.missingArgument(arg.name);
1303
+ } else if (arg.variadic) {
1304
+ args[i] = args.splice(i);
1305
+ args.length = Math.min(i + 1, args.length);
1306
+ }
1307
+ });
1308
+ if (args.length > this._args.length) {
1309
+ this._excessArguments(args);
1310
+ }
1311
+ this._actionHandler(args);
1312
+ if (this.parent)
1313
+ this.parent.emit(commandEvent, operands, unknown);
1314
+ } else if (this.parent && this.parent.listenerCount(commandEvent)) {
1315
+ checkForUnknownOptions();
1316
+ this.parent.emit(commandEvent, operands, unknown);
1317
+ } else if (operands.length) {
1318
+ if (this._findCommand("*")) {
1319
+ this._dispatchSubcommand("*", operands, unknown);
1320
+ } else if (this.listenerCount("command:*")) {
1321
+ this.emit("command:*", operands, unknown);
1322
+ } else if (this.commands.length) {
1323
+ this.unknownCommand();
1324
+ } else {
1325
+ checkForUnknownOptions();
1326
+ }
1327
+ } else if (this.commands.length) {
1328
+ this.help({ error: true });
1329
+ } else {
1330
+ checkForUnknownOptions();
1331
+ }
1332
+ }
1333
+ }
1334
+ /**
1335
+ * Find matching command.
1336
+ *
1337
+ * @api private
1338
+ */
1339
+ _findCommand(name) {
1340
+ if (!name)
1341
+ return void 0;
1342
+ return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
1343
+ }
1344
+ /**
1345
+ * Return an option matching `arg` if any.
1346
+ *
1347
+ * @param {string} arg
1348
+ * @return {Option}
1349
+ * @api private
1350
+ */
1351
+ _findOption(arg) {
1352
+ return this.options.find((option) => option.is(arg));
1353
+ }
1354
+ /**
1355
+ * Display an error message if a mandatory option does not have a value.
1356
+ * Lazy calling after checking for help flags from leaf subcommand.
1357
+ *
1358
+ * @api private
1359
+ */
1360
+ _checkForMissingMandatoryOptions() {
1361
+ for (let cmd = this; cmd; cmd = cmd.parent) {
1362
+ cmd.options.forEach((anOption) => {
1363
+ if (anOption.mandatory && cmd._getOptionValue(anOption.attributeName()) === void 0) {
1364
+ cmd.missingMandatoryOptionValue(anOption);
1365
+ }
1366
+ });
1367
+ }
1368
+ }
1369
+ /**
1370
+ * Parse options from `argv` removing known options,
1371
+ * and return argv split into operands and unknown arguments.
1372
+ *
1373
+ * Examples:
1374
+ *
1375
+ * argv => operands, unknown
1376
+ * --known kkk op => [op], []
1377
+ * op --known kkk => [op], []
1378
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
1379
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
1380
+ *
1381
+ * @param {String[]} argv
1382
+ * @return {{operands: String[], unknown: String[]}}
1383
+ */
1384
+ parseOptions(argv) {
1385
+ const operands = [];
1386
+ const unknown = [];
1387
+ let dest = operands;
1388
+ const args = argv.slice();
1389
+ function maybeOption(arg) {
1390
+ return arg.length > 1 && arg[0] === "-";
1391
+ }
1392
+ let activeVariadicOption = null;
1393
+ while (args.length) {
1394
+ const arg = args.shift();
1395
+ if (arg === "--") {
1396
+ if (dest === unknown)
1397
+ dest.push(arg);
1398
+ dest.push(...args);
1399
+ break;
1400
+ }
1401
+ if (activeVariadicOption && !maybeOption(arg)) {
1402
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
1403
+ continue;
1404
+ }
1405
+ activeVariadicOption = null;
1406
+ if (maybeOption(arg)) {
1407
+ const option = this._findOption(arg);
1408
+ if (option) {
1409
+ if (option.required) {
1410
+ const value = args.shift();
1411
+ if (value === void 0)
1412
+ this.optionMissingArgument(option);
1413
+ this.emit(`option:${option.name()}`, value);
1414
+ } else if (option.optional) {
1415
+ let value = null;
1416
+ if (args.length > 0 && !maybeOption(args[0])) {
1417
+ value = args.shift();
1418
+ }
1419
+ this.emit(`option:${option.name()}`, value);
1420
+ } else {
1421
+ this.emit(`option:${option.name()}`);
1422
+ }
1423
+ activeVariadicOption = option.variadic ? option : null;
1424
+ continue;
1425
+ }
1426
+ }
1427
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
1428
+ const option = this._findOption(`-${arg[1]}`);
1429
+ if (option) {
1430
+ if (option.required || option.optional && this._combineFlagAndOptionalValue) {
1431
+ this.emit(`option:${option.name()}`, arg.slice(2));
1432
+ } else {
1433
+ this.emit(`option:${option.name()}`);
1434
+ args.unshift(`-${arg.slice(2)}`);
1435
+ }
1436
+ continue;
1437
+ }
1438
+ }
1439
+ if (/^--[^=]+=/.test(arg)) {
1440
+ const index = arg.indexOf("=");
1441
+ const option = this._findOption(arg.slice(0, index));
1442
+ if (option && (option.required || option.optional)) {
1443
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
1444
+ continue;
1445
+ }
1446
+ }
1447
+ if (maybeOption(arg)) {
1448
+ dest = unknown;
1449
+ }
1450
+ if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
1451
+ if (this._findCommand(arg)) {
1452
+ operands.push(arg);
1453
+ if (args.length > 0)
1454
+ unknown.push(...args);
1455
+ break;
1456
+ } else if (arg === this._helpCommandName && this._hasImplicitHelpCommand()) {
1457
+ operands.push(arg);
1458
+ if (args.length > 0)
1459
+ operands.push(...args);
1460
+ break;
1461
+ } else if (this._defaultCommandName) {
1462
+ unknown.push(arg);
1463
+ if (args.length > 0)
1464
+ unknown.push(...args);
1465
+ break;
1466
+ }
1467
+ }
1468
+ if (this._passThroughOptions) {
1469
+ dest.push(arg);
1470
+ if (args.length > 0)
1471
+ dest.push(...args);
1472
+ break;
1473
+ }
1474
+ dest.push(arg);
1475
+ }
1476
+ return { operands, unknown };
1477
+ }
1478
+ /**
1479
+ * Return an object containing options as key-value pairs
1480
+ *
1481
+ * @return {Object}
1482
+ */
1483
+ opts() {
1484
+ if (this._storeOptionsAsProperties) {
1485
+ const result = {};
1486
+ const len = this.options.length;
1487
+ for (let i = 0; i < len; i++) {
1488
+ const key = this.options[i].attributeName();
1489
+ result[key] = key === this._versionOptionName ? this._version : this[key];
1490
+ }
1491
+ return result;
1492
+ }
1493
+ return this._optionValues;
1494
+ }
1495
+ /**
1496
+ * Internal bottleneck for handling of parsing errors.
1497
+ *
1498
+ * @api private
1499
+ */
1500
+ _displayError(exitCode, code, message) {
1501
+ this._outputConfiguration.outputError(`${message}
1502
+ `, this._outputConfiguration.writeErr);
1503
+ this._exit(exitCode, code, message);
1504
+ }
1505
+ /**
1506
+ * Argument `name` is missing.
1507
+ *
1508
+ * @param {string} name
1509
+ * @api private
1510
+ */
1511
+ missingArgument(name) {
1512
+ const message = `error: missing required argument '${name}'`;
1513
+ this._displayError(1, "commander.missingArgument", message);
1514
+ }
1515
+ /**
1516
+ * `Option` is missing an argument.
1517
+ *
1518
+ * @param {Option} option
1519
+ * @api private
1520
+ */
1521
+ optionMissingArgument(option) {
1522
+ const message = `error: option '${option.flags}' argument missing`;
1523
+ this._displayError(1, "commander.optionMissingArgument", message);
1524
+ }
1525
+ /**
1526
+ * `Option` does not have a value, and is a mandatory option.
1527
+ *
1528
+ * @param {Option} option
1529
+ * @api private
1530
+ */
1531
+ missingMandatoryOptionValue(option) {
1532
+ const message = `error: required option '${option.flags}' not specified`;
1533
+ this._displayError(1, "commander.missingMandatoryOptionValue", message);
1534
+ }
1535
+ /**
1536
+ * Unknown option `flag`.
1537
+ *
1538
+ * @param {string} flag
1539
+ * @api private
1540
+ */
1541
+ unknownOption(flag) {
1542
+ if (this._allowUnknownOption)
1543
+ return;
1544
+ const message = `error: unknown option '${flag}'`;
1545
+ this._displayError(1, "commander.unknownOption", message);
1546
+ }
1547
+ /**
1548
+ * Excess arguments, more than expected.
1549
+ *
1550
+ * @param {string[]} receivedArgs
1551
+ * @api private
1552
+ */
1553
+ _excessArguments(receivedArgs) {
1554
+ if (this._allowExcessArguments)
1555
+ return;
1556
+ const expected = this._args.length;
1557
+ const s = expected === 1 ? "" : "s";
1558
+ const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
1559
+ const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
1560
+ this._displayError(1, "commander.excessArguments", message);
1561
+ }
1562
+ /**
1563
+ * Unknown command.
1564
+ *
1565
+ * @api private
1566
+ */
1567
+ unknownCommand() {
1568
+ const partCommands = [this.name()];
1569
+ for (let parentCmd = this.parent; parentCmd; parentCmd = parentCmd.parent) {
1570
+ partCommands.unshift(parentCmd.name());
1571
+ }
1572
+ const fullCommand = partCommands.join(" ");
1573
+ const message = `error: unknown command '${this.args[0]}'.` + (this._hasHelpOption ? ` See '${fullCommand} ${this._helpLongFlag}'.` : "");
1574
+ this._displayError(1, "commander.unknownCommand", message);
1575
+ }
1576
+ /**
1577
+ * Set the program version to `str`.
1578
+ *
1579
+ * This method auto-registers the "-V, --version" flag
1580
+ * which will print the version number when passed.
1581
+ *
1582
+ * You can optionally supply the flags and description to override the defaults.
1583
+ *
1584
+ * @param {string} str
1585
+ * @param {string} [flags]
1586
+ * @param {string} [description]
1587
+ * @return {this | string} `this` command for chaining, or version string if no arguments
1588
+ */
1589
+ version(str, flags, description) {
1590
+ if (str === void 0)
1591
+ return this._version;
1592
+ this._version = str;
1593
+ flags = flags || "-V, --version";
1594
+ description = description || "output the version number";
1595
+ const versionOption = this.createOption(flags, description);
1596
+ this._versionOptionName = versionOption.attributeName();
1597
+ this.options.push(versionOption);
1598
+ this.on("option:" + versionOption.name(), () => {
1599
+ this._outputConfiguration.writeOut(`${str}
1600
+ `);
1601
+ this._exit(0, "commander.version", str);
1602
+ });
1603
+ return this;
1604
+ }
1605
+ /**
1606
+ * Set the description to `str`.
1607
+ *
1608
+ * @param {string} [str]
1609
+ * @param {Object} [argsDescription]
1610
+ * @return {string|Command}
1611
+ */
1612
+ description(str, argsDescription) {
1613
+ if (str === void 0 && argsDescription === void 0)
1614
+ return this._description;
1615
+ this._description = str;
1616
+ this._argsDescription = argsDescription;
1617
+ return this;
1618
+ }
1619
+ /**
1620
+ * Set an alias for the command.
1621
+ *
1622
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
1623
+ *
1624
+ * @param {string} [alias]
1625
+ * @return {string|Command}
1626
+ */
1627
+ alias(alias) {
1628
+ if (alias === void 0)
1629
+ return this._aliases[0];
1630
+ let command = this;
1631
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
1632
+ command = this.commands[this.commands.length - 1];
1633
+ }
1634
+ if (alias === command._name)
1635
+ throw new Error("Command alias can't be the same as its name");
1636
+ command._aliases.push(alias);
1637
+ return this;
1638
+ }
1639
+ /**
1640
+ * Set aliases for the command.
1641
+ *
1642
+ * Only the first alias is shown in the auto-generated help.
1643
+ *
1644
+ * @param {string[]} [aliases]
1645
+ * @return {string[]|Command}
1646
+ */
1647
+ aliases(aliases) {
1648
+ if (aliases === void 0)
1649
+ return this._aliases;
1650
+ aliases.forEach((alias) => this.alias(alias));
1651
+ return this;
1652
+ }
1653
+ /**
1654
+ * Set / get the command usage `str`.
1655
+ *
1656
+ * @param {string} [str]
1657
+ * @return {String|Command}
1658
+ */
1659
+ usage(str) {
1660
+ if (str === void 0) {
1661
+ if (this._usage)
1662
+ return this._usage;
1663
+ const args = this._args.map((arg) => {
1664
+ return humanReadableArgName(arg);
1665
+ });
1666
+ return [].concat(
1667
+ this.options.length || this._hasHelpOption ? "[options]" : [],
1668
+ this.commands.length ? "[command]" : [],
1669
+ this._args.length ? args : []
1670
+ ).join(" ");
1671
+ }
1672
+ this._usage = str;
1673
+ return this;
1674
+ }
1675
+ /**
1676
+ * Get or set the name of the command
1677
+ *
1678
+ * @param {string} [str]
1679
+ * @return {string|Command}
1680
+ */
1681
+ name(str) {
1682
+ if (str === void 0)
1683
+ return this._name;
1684
+ this._name = str;
1685
+ return this;
1686
+ }
1687
+ /**
1688
+ * Return program help documentation.
1689
+ *
1690
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
1691
+ * @return {string}
1692
+ */
1693
+ helpInformation(contextOptions) {
1694
+ const helper = this.createHelp();
1695
+ if (helper.helpWidth === void 0) {
1696
+ helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
1697
+ }
1698
+ return helper.formatHelp(this, helper);
1699
+ }
1700
+ /**
1701
+ * @api private
1702
+ */
1703
+ _getHelpContext(contextOptions) {
1704
+ contextOptions = contextOptions || {};
1705
+ const context = { error: !!contextOptions.error };
1706
+ let write;
1707
+ if (context.error) {
1708
+ write = (arg) => this._outputConfiguration.writeErr(arg);
1709
+ } else {
1710
+ write = (arg) => this._outputConfiguration.writeOut(arg);
1711
+ }
1712
+ context.write = contextOptions.write || write;
1713
+ context.command = this;
1714
+ return context;
1715
+ }
1716
+ /**
1717
+ * Output help information for this command.
1718
+ *
1719
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
1720
+ *
1721
+ * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
1722
+ */
1723
+ outputHelp(contextOptions) {
1724
+ let deprecatedCallback;
1725
+ if (typeof contextOptions === "function") {
1726
+ deprecatedCallback = contextOptions;
1727
+ contextOptions = void 0;
1728
+ }
1729
+ const context = this._getHelpContext(contextOptions);
1730
+ const groupListeners = [];
1731
+ let command = this;
1732
+ while (command) {
1733
+ groupListeners.push(command);
1734
+ command = command.parent;
1735
+ }
1736
+ groupListeners.slice().reverse().forEach((command2) => command2.emit("beforeAllHelp", context));
1737
+ this.emit("beforeHelp", context);
1738
+ let helpInformation = this.helpInformation(context);
1739
+ if (deprecatedCallback) {
1740
+ helpInformation = deprecatedCallback(helpInformation);
1741
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
1742
+ throw new Error("outputHelp callback must return a string or a Buffer");
1743
+ }
1744
+ }
1745
+ context.write(helpInformation);
1746
+ this.emit(this._helpLongFlag);
1747
+ this.emit("afterHelp", context);
1748
+ groupListeners.forEach((command2) => command2.emit("afterAllHelp", context));
1749
+ }
1750
+ /**
1751
+ * You can pass in flags and a description to override the help
1752
+ * flags and help description for your command. Pass in false to
1753
+ * disable the built-in help option.
1754
+ *
1755
+ * @param {string | boolean} [flags]
1756
+ * @param {string} [description]
1757
+ * @return {Command} `this` command for chaining
1758
+ */
1759
+ helpOption(flags, description) {
1760
+ if (typeof flags === "boolean") {
1761
+ this._hasHelpOption = flags;
1762
+ return this;
1763
+ }
1764
+ this._helpFlags = flags || this._helpFlags;
1765
+ this._helpDescription = description || this._helpDescription;
1766
+ const helpFlags = _parseOptionFlags(this._helpFlags);
1767
+ this._helpShortFlag = helpFlags.shortFlag;
1768
+ this._helpLongFlag = helpFlags.longFlag;
1769
+ return this;
1770
+ }
1771
+ /**
1772
+ * Output help information and exit.
1773
+ *
1774
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
1775
+ *
1776
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
1777
+ */
1778
+ help(contextOptions) {
1779
+ this.outputHelp(contextOptions);
1780
+ let exitCode = process.exitCode || 0;
1781
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
1782
+ exitCode = 1;
1783
+ }
1784
+ this._exit(exitCode, "commander.help", "(outputHelp)");
1785
+ }
1786
+ /**
1787
+ * Add additional text to be displayed with the built-in help.
1788
+ *
1789
+ * Position is 'before' or 'after' to affect just this command,
1790
+ * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
1791
+ *
1792
+ * @param {string} position - before or after built-in help
1793
+ * @param {string | Function} text - string to add, or a function returning a string
1794
+ * @return {Command} `this` command for chaining
1795
+ */
1796
+ addHelpText(position, text) {
1797
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
1798
+ if (!allowedValues.includes(position)) {
1799
+ throw new Error(`Unexpected value for position to addHelpText.
1800
+ Expecting one of '${allowedValues.join("', '")}'`);
1801
+ }
1802
+ const helpEvent = `${position}Help`;
1803
+ this.on(helpEvent, (context) => {
1804
+ let helpStr;
1805
+ if (typeof text === "function") {
1806
+ helpStr = text({ error: context.error, command: context.command });
1807
+ } else {
1808
+ helpStr = text;
1809
+ }
1810
+ if (helpStr) {
1811
+ context.write(`${helpStr}
1812
+ `);
1813
+ }
1814
+ });
1815
+ return this;
1816
+ }
1817
+ };
1818
+ exports = module.exports = new Command();
1819
+ exports.program = exports;
1820
+ exports.Command = Command;
1821
+ exports.Option = Option;
1822
+ exports.CommanderError = CommanderError;
1823
+ exports.InvalidOptionArgumentError = InvalidOptionArgumentError;
1824
+ exports.Help = Help;
1825
+ function camelcase(flag) {
1826
+ return flag.split("-").reduce((str, word) => {
1827
+ return str + word[0].toUpperCase() + word.slice(1);
1828
+ });
1829
+ }
1830
+ function outputHelpIfRequested(cmd, args) {
1831
+ const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
1832
+ if (helpOption) {
1833
+ cmd.outputHelp();
1834
+ cmd._exit(0, "commander.helpDisplayed", "(outputHelp)");
1835
+ }
1836
+ }
1837
+ function humanReadableArgName(arg) {
1838
+ const nameOutput = arg.name + (arg.variadic === true ? "..." : "");
1839
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
1840
+ }
1841
+ function _parseOptionFlags(flags) {
1842
+ let shortFlag;
1843
+ let longFlag;
1844
+ const flagParts = flags.split(/[ |,]+/);
1845
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
1846
+ shortFlag = flagParts.shift();
1847
+ longFlag = flagParts.shift();
1848
+ if (!shortFlag && /^-[^-]$/.test(longFlag)) {
1849
+ shortFlag = longFlag;
1850
+ longFlag = void 0;
1851
+ }
1852
+ return { shortFlag, longFlag };
1853
+ }
1854
+ function incrementNodeInspectorPort(args) {
1855
+ return args.map((arg) => {
1856
+ if (!arg.startsWith("--inspect")) {
1857
+ return arg;
1858
+ }
1859
+ let debugOption;
1860
+ let debugHost = "127.0.0.1";
1861
+ let debugPort = "9229";
1862
+ let match;
1863
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
1864
+ debugOption = match[1];
1865
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
1866
+ debugOption = match[1];
1867
+ if (/^\d+$/.test(match[3])) {
1868
+ debugPort = match[3];
1869
+ } else {
1870
+ debugHost = match[3];
1871
+ }
1872
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
1873
+ debugOption = match[1];
1874
+ debugHost = match[3];
1875
+ debugPort = match[4];
1876
+ }
1877
+ if (debugOption && debugPort !== "0") {
1878
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
1879
+ }
1880
+ return arg;
1881
+ });
1882
+ }
1883
+ }
1884
+ });
1885
+
1886
+ // ../../node_modules/escape-string-regexp/index.js
1887
+ var require_escape_string_regexp = __commonJS({
1888
+ "../../node_modules/escape-string-regexp/index.js"(exports, module) {
1889
+ "use strict";
1890
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
1891
+ module.exports = function(str) {
1892
+ if (typeof str !== "string") {
1893
+ throw new TypeError("Expected a string");
1894
+ }
1895
+ return str.replace(matchOperatorsRe, "\\$&");
1896
+ };
1897
+ }
1898
+ });
1899
+
1900
+ // ../../node_modules/color-name/index.js
1901
+ var require_color_name = __commonJS({
1902
+ "../../node_modules/color-name/index.js"(exports, module) {
1903
+ "use strict";
1904
+ module.exports = {
1905
+ "aliceblue": [240, 248, 255],
1906
+ "antiquewhite": [250, 235, 215],
1907
+ "aqua": [0, 255, 255],
1908
+ "aquamarine": [127, 255, 212],
1909
+ "azure": [240, 255, 255],
1910
+ "beige": [245, 245, 220],
1911
+ "bisque": [255, 228, 196],
1912
+ "black": [0, 0, 0],
1913
+ "blanchedalmond": [255, 235, 205],
1914
+ "blue": [0, 0, 255],
1915
+ "blueviolet": [138, 43, 226],
1916
+ "brown": [165, 42, 42],
1917
+ "burlywood": [222, 184, 135],
1918
+ "cadetblue": [95, 158, 160],
1919
+ "chartreuse": [127, 255, 0],
1920
+ "chocolate": [210, 105, 30],
1921
+ "coral": [255, 127, 80],
1922
+ "cornflowerblue": [100, 149, 237],
1923
+ "cornsilk": [255, 248, 220],
1924
+ "crimson": [220, 20, 60],
1925
+ "cyan": [0, 255, 255],
1926
+ "darkblue": [0, 0, 139],
1927
+ "darkcyan": [0, 139, 139],
1928
+ "darkgoldenrod": [184, 134, 11],
1929
+ "darkgray": [169, 169, 169],
1930
+ "darkgreen": [0, 100, 0],
1931
+ "darkgrey": [169, 169, 169],
1932
+ "darkkhaki": [189, 183, 107],
1933
+ "darkmagenta": [139, 0, 139],
1934
+ "darkolivegreen": [85, 107, 47],
1935
+ "darkorange": [255, 140, 0],
1936
+ "darkorchid": [153, 50, 204],
1937
+ "darkred": [139, 0, 0],
1938
+ "darksalmon": [233, 150, 122],
1939
+ "darkseagreen": [143, 188, 143],
1940
+ "darkslateblue": [72, 61, 139],
1941
+ "darkslategray": [47, 79, 79],
1942
+ "darkslategrey": [47, 79, 79],
1943
+ "darkturquoise": [0, 206, 209],
1944
+ "darkviolet": [148, 0, 211],
1945
+ "deeppink": [255, 20, 147],
1946
+ "deepskyblue": [0, 191, 255],
1947
+ "dimgray": [105, 105, 105],
1948
+ "dimgrey": [105, 105, 105],
1949
+ "dodgerblue": [30, 144, 255],
1950
+ "firebrick": [178, 34, 34],
1951
+ "floralwhite": [255, 250, 240],
1952
+ "forestgreen": [34, 139, 34],
1953
+ "fuchsia": [255, 0, 255],
1954
+ "gainsboro": [220, 220, 220],
1955
+ "ghostwhite": [248, 248, 255],
1956
+ "gold": [255, 215, 0],
1957
+ "goldenrod": [218, 165, 32],
1958
+ "gray": [128, 128, 128],
1959
+ "green": [0, 128, 0],
1960
+ "greenyellow": [173, 255, 47],
1961
+ "grey": [128, 128, 128],
1962
+ "honeydew": [240, 255, 240],
1963
+ "hotpink": [255, 105, 180],
1964
+ "indianred": [205, 92, 92],
1965
+ "indigo": [75, 0, 130],
1966
+ "ivory": [255, 255, 240],
1967
+ "khaki": [240, 230, 140],
1968
+ "lavender": [230, 230, 250],
1969
+ "lavenderblush": [255, 240, 245],
1970
+ "lawngreen": [124, 252, 0],
1971
+ "lemonchiffon": [255, 250, 205],
1972
+ "lightblue": [173, 216, 230],
1973
+ "lightcoral": [240, 128, 128],
1974
+ "lightcyan": [224, 255, 255],
1975
+ "lightgoldenrodyellow": [250, 250, 210],
1976
+ "lightgray": [211, 211, 211],
1977
+ "lightgreen": [144, 238, 144],
1978
+ "lightgrey": [211, 211, 211],
1979
+ "lightpink": [255, 182, 193],
1980
+ "lightsalmon": [255, 160, 122],
1981
+ "lightseagreen": [32, 178, 170],
1982
+ "lightskyblue": [135, 206, 250],
1983
+ "lightslategray": [119, 136, 153],
1984
+ "lightslategrey": [119, 136, 153],
1985
+ "lightsteelblue": [176, 196, 222],
1986
+ "lightyellow": [255, 255, 224],
1987
+ "lime": [0, 255, 0],
1988
+ "limegreen": [50, 205, 50],
1989
+ "linen": [250, 240, 230],
1990
+ "magenta": [255, 0, 255],
1991
+ "maroon": [128, 0, 0],
1992
+ "mediumaquamarine": [102, 205, 170],
1993
+ "mediumblue": [0, 0, 205],
1994
+ "mediumorchid": [186, 85, 211],
1995
+ "mediumpurple": [147, 112, 219],
1996
+ "mediumseagreen": [60, 179, 113],
1997
+ "mediumslateblue": [123, 104, 238],
1998
+ "mediumspringgreen": [0, 250, 154],
1999
+ "mediumturquoise": [72, 209, 204],
2000
+ "mediumvioletred": [199, 21, 133],
2001
+ "midnightblue": [25, 25, 112],
2002
+ "mintcream": [245, 255, 250],
2003
+ "mistyrose": [255, 228, 225],
2004
+ "moccasin": [255, 228, 181],
2005
+ "navajowhite": [255, 222, 173],
2006
+ "navy": [0, 0, 128],
2007
+ "oldlace": [253, 245, 230],
2008
+ "olive": [128, 128, 0],
2009
+ "olivedrab": [107, 142, 35],
2010
+ "orange": [255, 165, 0],
2011
+ "orangered": [255, 69, 0],
2012
+ "orchid": [218, 112, 214],
2013
+ "palegoldenrod": [238, 232, 170],
2014
+ "palegreen": [152, 251, 152],
2015
+ "paleturquoise": [175, 238, 238],
2016
+ "palevioletred": [219, 112, 147],
2017
+ "papayawhip": [255, 239, 213],
2018
+ "peachpuff": [255, 218, 185],
2019
+ "peru": [205, 133, 63],
2020
+ "pink": [255, 192, 203],
2021
+ "plum": [221, 160, 221],
2022
+ "powderblue": [176, 224, 230],
2023
+ "purple": [128, 0, 128],
2024
+ "rebeccapurple": [102, 51, 153],
2025
+ "red": [255, 0, 0],
2026
+ "rosybrown": [188, 143, 143],
2027
+ "royalblue": [65, 105, 225],
2028
+ "saddlebrown": [139, 69, 19],
2029
+ "salmon": [250, 128, 114],
2030
+ "sandybrown": [244, 164, 96],
2031
+ "seagreen": [46, 139, 87],
2032
+ "seashell": [255, 245, 238],
2033
+ "sienna": [160, 82, 45],
2034
+ "silver": [192, 192, 192],
2035
+ "skyblue": [135, 206, 235],
2036
+ "slateblue": [106, 90, 205],
2037
+ "slategray": [112, 128, 144],
2038
+ "slategrey": [112, 128, 144],
2039
+ "snow": [255, 250, 250],
2040
+ "springgreen": [0, 255, 127],
2041
+ "steelblue": [70, 130, 180],
2042
+ "tan": [210, 180, 140],
2043
+ "teal": [0, 128, 128],
2044
+ "thistle": [216, 191, 216],
2045
+ "tomato": [255, 99, 71],
2046
+ "turquoise": [64, 224, 208],
2047
+ "violet": [238, 130, 238],
2048
+ "wheat": [245, 222, 179],
2049
+ "white": [255, 255, 255],
2050
+ "whitesmoke": [245, 245, 245],
2051
+ "yellow": [255, 255, 0],
2052
+ "yellowgreen": [154, 205, 50]
2053
+ };
2054
+ }
2055
+ });
2056
+
2057
+ // ../../node_modules/color-convert/conversions.js
2058
+ var require_conversions = __commonJS({
2059
+ "../../node_modules/color-convert/conversions.js"(exports, module) {
2060
+ var cssKeywords = require_color_name();
2061
+ var reverseKeywords = {};
2062
+ for (key in cssKeywords) {
2063
+ if (cssKeywords.hasOwnProperty(key)) {
2064
+ reverseKeywords[cssKeywords[key]] = key;
2065
+ }
2066
+ }
2067
+ var key;
2068
+ var convert = module.exports = {
2069
+ rgb: { channels: 3, labels: "rgb" },
2070
+ hsl: { channels: 3, labels: "hsl" },
2071
+ hsv: { channels: 3, labels: "hsv" },
2072
+ hwb: { channels: 3, labels: "hwb" },
2073
+ cmyk: { channels: 4, labels: "cmyk" },
2074
+ xyz: { channels: 3, labels: "xyz" },
2075
+ lab: { channels: 3, labels: "lab" },
2076
+ lch: { channels: 3, labels: "lch" },
2077
+ hex: { channels: 1, labels: ["hex"] },
2078
+ keyword: { channels: 1, labels: ["keyword"] },
2079
+ ansi16: { channels: 1, labels: ["ansi16"] },
2080
+ ansi256: { channels: 1, labels: ["ansi256"] },
2081
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
2082
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
2083
+ gray: { channels: 1, labels: ["gray"] }
2084
+ };
2085
+ for (model in convert) {
2086
+ if (convert.hasOwnProperty(model)) {
2087
+ if (!("channels" in convert[model])) {
2088
+ throw new Error("missing channels property: " + model);
2089
+ }
2090
+ if (!("labels" in convert[model])) {
2091
+ throw new Error("missing channel labels property: " + model);
2092
+ }
2093
+ if (convert[model].labels.length !== convert[model].channels) {
2094
+ throw new Error("channel and label counts mismatch: " + model);
2095
+ }
2096
+ channels = convert[model].channels;
2097
+ labels = convert[model].labels;
2098
+ delete convert[model].channels;
2099
+ delete convert[model].labels;
2100
+ Object.defineProperty(convert[model], "channels", { value: channels });
2101
+ Object.defineProperty(convert[model], "labels", { value: labels });
2102
+ }
2103
+ }
2104
+ var channels;
2105
+ var labels;
2106
+ var model;
2107
+ convert.rgb.hsl = function(rgb) {
2108
+ var r = rgb[0] / 255;
2109
+ var g = rgb[1] / 255;
2110
+ var b = rgb[2] / 255;
2111
+ var min = Math.min(r, g, b);
2112
+ var max = Math.max(r, g, b);
2113
+ var delta = max - min;
2114
+ var h;
2115
+ var s;
2116
+ var l;
2117
+ if (max === min) {
2118
+ h = 0;
2119
+ } else if (r === max) {
2120
+ h = (g - b) / delta;
2121
+ } else if (g === max) {
2122
+ h = 2 + (b - r) / delta;
2123
+ } else if (b === max) {
2124
+ h = 4 + (r - g) / delta;
2125
+ }
2126
+ h = Math.min(h * 60, 360);
2127
+ if (h < 0) {
2128
+ h += 360;
2129
+ }
2130
+ l = (min + max) / 2;
2131
+ if (max === min) {
2132
+ s = 0;
2133
+ } else if (l <= 0.5) {
2134
+ s = delta / (max + min);
2135
+ } else {
2136
+ s = delta / (2 - max - min);
2137
+ }
2138
+ return [h, s * 100, l * 100];
2139
+ };
2140
+ convert.rgb.hsv = function(rgb) {
2141
+ var rdif;
2142
+ var gdif;
2143
+ var bdif;
2144
+ var h;
2145
+ var s;
2146
+ var r = rgb[0] / 255;
2147
+ var g = rgb[1] / 255;
2148
+ var b = rgb[2] / 255;
2149
+ var v = Math.max(r, g, b);
2150
+ var diff = v - Math.min(r, g, b);
2151
+ var diffc = function(c) {
2152
+ return (v - c) / 6 / diff + 1 / 2;
2153
+ };
2154
+ if (diff === 0) {
2155
+ h = s = 0;
2156
+ } else {
2157
+ s = diff / v;
2158
+ rdif = diffc(r);
2159
+ gdif = diffc(g);
2160
+ bdif = diffc(b);
2161
+ if (r === v) {
2162
+ h = bdif - gdif;
2163
+ } else if (g === v) {
2164
+ h = 1 / 3 + rdif - bdif;
2165
+ } else if (b === v) {
2166
+ h = 2 / 3 + gdif - rdif;
2167
+ }
2168
+ if (h < 0) {
2169
+ h += 1;
2170
+ } else if (h > 1) {
2171
+ h -= 1;
2172
+ }
2173
+ }
2174
+ return [
2175
+ h * 360,
2176
+ s * 100,
2177
+ v * 100
2178
+ ];
2179
+ };
2180
+ convert.rgb.hwb = function(rgb) {
2181
+ var r = rgb[0];
2182
+ var g = rgb[1];
2183
+ var b = rgb[2];
2184
+ var h = convert.rgb.hsl(rgb)[0];
2185
+ var w = 1 / 255 * Math.min(r, Math.min(g, b));
2186
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
2187
+ return [h, w * 100, b * 100];
2188
+ };
2189
+ convert.rgb.cmyk = function(rgb) {
2190
+ var r = rgb[0] / 255;
2191
+ var g = rgb[1] / 255;
2192
+ var b = rgb[2] / 255;
2193
+ var c;
2194
+ var m;
2195
+ var y;
2196
+ var k;
2197
+ k = Math.min(1 - r, 1 - g, 1 - b);
2198
+ c = (1 - r - k) / (1 - k) || 0;
2199
+ m = (1 - g - k) / (1 - k) || 0;
2200
+ y = (1 - b - k) / (1 - k) || 0;
2201
+ return [c * 100, m * 100, y * 100, k * 100];
2202
+ };
2203
+ function comparativeDistance(x, y) {
2204
+ return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
2205
+ }
2206
+ convert.rgb.keyword = function(rgb) {
2207
+ var reversed = reverseKeywords[rgb];
2208
+ if (reversed) {
2209
+ return reversed;
2210
+ }
2211
+ var currentClosestDistance = Infinity;
2212
+ var currentClosestKeyword;
2213
+ for (var keyword in cssKeywords) {
2214
+ if (cssKeywords.hasOwnProperty(keyword)) {
2215
+ var value = cssKeywords[keyword];
2216
+ var distance = comparativeDistance(rgb, value);
2217
+ if (distance < currentClosestDistance) {
2218
+ currentClosestDistance = distance;
2219
+ currentClosestKeyword = keyword;
2220
+ }
2221
+ }
2222
+ }
2223
+ return currentClosestKeyword;
2224
+ };
2225
+ convert.keyword.rgb = function(keyword) {
2226
+ return cssKeywords[keyword];
2227
+ };
2228
+ convert.rgb.xyz = function(rgb) {
2229
+ var r = rgb[0] / 255;
2230
+ var g = rgb[1] / 255;
2231
+ var b = rgb[2] / 255;
2232
+ r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
2233
+ g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
2234
+ b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
2235
+ var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
2236
+ var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
2237
+ var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
2238
+ return [x * 100, y * 100, z * 100];
2239
+ };
2240
+ convert.rgb.lab = function(rgb) {
2241
+ var xyz = convert.rgb.xyz(rgb);
2242
+ var x = xyz[0];
2243
+ var y = xyz[1];
2244
+ var z = xyz[2];
2245
+ var l;
2246
+ var a;
2247
+ var b;
2248
+ x /= 95.047;
2249
+ y /= 100;
2250
+ z /= 108.883;
2251
+ x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
2252
+ y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
2253
+ z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
2254
+ l = 116 * y - 16;
2255
+ a = 500 * (x - y);
2256
+ b = 200 * (y - z);
2257
+ return [l, a, b];
2258
+ };
2259
+ convert.hsl.rgb = function(hsl) {
2260
+ var h = hsl[0] / 360;
2261
+ var s = hsl[1] / 100;
2262
+ var l = hsl[2] / 100;
2263
+ var t1;
2264
+ var t2;
2265
+ var t3;
2266
+ var rgb;
2267
+ var val;
2268
+ if (s === 0) {
2269
+ val = l * 255;
2270
+ return [val, val, val];
2271
+ }
2272
+ if (l < 0.5) {
2273
+ t2 = l * (1 + s);
2274
+ } else {
2275
+ t2 = l + s - l * s;
2276
+ }
2277
+ t1 = 2 * l - t2;
2278
+ rgb = [0, 0, 0];
2279
+ for (var i = 0; i < 3; i++) {
2280
+ t3 = h + 1 / 3 * -(i - 1);
2281
+ if (t3 < 0) {
2282
+ t3++;
2283
+ }
2284
+ if (t3 > 1) {
2285
+ t3--;
2286
+ }
2287
+ if (6 * t3 < 1) {
2288
+ val = t1 + (t2 - t1) * 6 * t3;
2289
+ } else if (2 * t3 < 1) {
2290
+ val = t2;
2291
+ } else if (3 * t3 < 2) {
2292
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
2293
+ } else {
2294
+ val = t1;
2295
+ }
2296
+ rgb[i] = val * 255;
2297
+ }
2298
+ return rgb;
2299
+ };
2300
+ convert.hsl.hsv = function(hsl) {
2301
+ var h = hsl[0];
2302
+ var s = hsl[1] / 100;
2303
+ var l = hsl[2] / 100;
2304
+ var smin = s;
2305
+ var lmin = Math.max(l, 0.01);
2306
+ var sv;
2307
+ var v;
2308
+ l *= 2;
2309
+ s *= l <= 1 ? l : 2 - l;
2310
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
2311
+ v = (l + s) / 2;
2312
+ sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
2313
+ return [h, sv * 100, v * 100];
2314
+ };
2315
+ convert.hsv.rgb = function(hsv) {
2316
+ var h = hsv[0] / 60;
2317
+ var s = hsv[1] / 100;
2318
+ var v = hsv[2] / 100;
2319
+ var hi = Math.floor(h) % 6;
2320
+ var f = h - Math.floor(h);
2321
+ var p = 255 * v * (1 - s);
2322
+ var q = 255 * v * (1 - s * f);
2323
+ var t = 255 * v * (1 - s * (1 - f));
2324
+ v *= 255;
2325
+ switch (hi) {
2326
+ case 0:
2327
+ return [v, t, p];
2328
+ case 1:
2329
+ return [q, v, p];
2330
+ case 2:
2331
+ return [p, v, t];
2332
+ case 3:
2333
+ return [p, q, v];
2334
+ case 4:
2335
+ return [t, p, v];
2336
+ case 5:
2337
+ return [v, p, q];
2338
+ }
2339
+ };
2340
+ convert.hsv.hsl = function(hsv) {
2341
+ var h = hsv[0];
2342
+ var s = hsv[1] / 100;
2343
+ var v = hsv[2] / 100;
2344
+ var vmin = Math.max(v, 0.01);
2345
+ var lmin;
2346
+ var sl;
2347
+ var l;
2348
+ l = (2 - s) * v;
2349
+ lmin = (2 - s) * vmin;
2350
+ sl = s * vmin;
2351
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
2352
+ sl = sl || 0;
2353
+ l /= 2;
2354
+ return [h, sl * 100, l * 100];
2355
+ };
2356
+ convert.hwb.rgb = function(hwb) {
2357
+ var h = hwb[0] / 360;
2358
+ var wh = hwb[1] / 100;
2359
+ var bl = hwb[2] / 100;
2360
+ var ratio = wh + bl;
2361
+ var i;
2362
+ var v;
2363
+ var f;
2364
+ var n;
2365
+ if (ratio > 1) {
2366
+ wh /= ratio;
2367
+ bl /= ratio;
2368
+ }
2369
+ i = Math.floor(6 * h);
2370
+ v = 1 - bl;
2371
+ f = 6 * h - i;
2372
+ if ((i & 1) !== 0) {
2373
+ f = 1 - f;
2374
+ }
2375
+ n = wh + f * (v - wh);
2376
+ var r;
2377
+ var g;
2378
+ var b;
2379
+ switch (i) {
2380
+ default:
2381
+ case 6:
2382
+ case 0:
2383
+ r = v;
2384
+ g = n;
2385
+ b = wh;
2386
+ break;
2387
+ case 1:
2388
+ r = n;
2389
+ g = v;
2390
+ b = wh;
2391
+ break;
2392
+ case 2:
2393
+ r = wh;
2394
+ g = v;
2395
+ b = n;
2396
+ break;
2397
+ case 3:
2398
+ r = wh;
2399
+ g = n;
2400
+ b = v;
2401
+ break;
2402
+ case 4:
2403
+ r = n;
2404
+ g = wh;
2405
+ b = v;
2406
+ break;
2407
+ case 5:
2408
+ r = v;
2409
+ g = wh;
2410
+ b = n;
2411
+ break;
2412
+ }
2413
+ return [r * 255, g * 255, b * 255];
2414
+ };
2415
+ convert.cmyk.rgb = function(cmyk) {
2416
+ var c = cmyk[0] / 100;
2417
+ var m = cmyk[1] / 100;
2418
+ var y = cmyk[2] / 100;
2419
+ var k = cmyk[3] / 100;
2420
+ var r;
2421
+ var g;
2422
+ var b;
2423
+ r = 1 - Math.min(1, c * (1 - k) + k);
2424
+ g = 1 - Math.min(1, m * (1 - k) + k);
2425
+ b = 1 - Math.min(1, y * (1 - k) + k);
2426
+ return [r * 255, g * 255, b * 255];
2427
+ };
2428
+ convert.xyz.rgb = function(xyz) {
2429
+ var x = xyz[0] / 100;
2430
+ var y = xyz[1] / 100;
2431
+ var z = xyz[2] / 100;
2432
+ var r;
2433
+ var g;
2434
+ var b;
2435
+ r = x * 3.2406 + y * -1.5372 + z * -0.4986;
2436
+ g = x * -0.9689 + y * 1.8758 + z * 0.0415;
2437
+ b = x * 0.0557 + y * -0.204 + z * 1.057;
2438
+ r = r > 31308e-7 ? 1.055 * Math.pow(r, 1 / 2.4) - 0.055 : r * 12.92;
2439
+ g = g > 31308e-7 ? 1.055 * Math.pow(g, 1 / 2.4) - 0.055 : g * 12.92;
2440
+ b = b > 31308e-7 ? 1.055 * Math.pow(b, 1 / 2.4) - 0.055 : b * 12.92;
2441
+ r = Math.min(Math.max(0, r), 1);
2442
+ g = Math.min(Math.max(0, g), 1);
2443
+ b = Math.min(Math.max(0, b), 1);
2444
+ return [r * 255, g * 255, b * 255];
2445
+ };
2446
+ convert.xyz.lab = function(xyz) {
2447
+ var x = xyz[0];
2448
+ var y = xyz[1];
2449
+ var z = xyz[2];
2450
+ var l;
2451
+ var a;
2452
+ var b;
2453
+ x /= 95.047;
2454
+ y /= 100;
2455
+ z /= 108.883;
2456
+ x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
2457
+ y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
2458
+ z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
2459
+ l = 116 * y - 16;
2460
+ a = 500 * (x - y);
2461
+ b = 200 * (y - z);
2462
+ return [l, a, b];
2463
+ };
2464
+ convert.lab.xyz = function(lab) {
2465
+ var l = lab[0];
2466
+ var a = lab[1];
2467
+ var b = lab[2];
2468
+ var x;
2469
+ var y;
2470
+ var z;
2471
+ y = (l + 16) / 116;
2472
+ x = a / 500 + y;
2473
+ z = y - b / 200;
2474
+ var y2 = Math.pow(y, 3);
2475
+ var x2 = Math.pow(x, 3);
2476
+ var z2 = Math.pow(z, 3);
2477
+ y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
2478
+ x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
2479
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
2480
+ x *= 95.047;
2481
+ y *= 100;
2482
+ z *= 108.883;
2483
+ return [x, y, z];
2484
+ };
2485
+ convert.lab.lch = function(lab) {
2486
+ var l = lab[0];
2487
+ var a = lab[1];
2488
+ var b = lab[2];
2489
+ var hr;
2490
+ var h;
2491
+ var c;
2492
+ hr = Math.atan2(b, a);
2493
+ h = hr * 360 / 2 / Math.PI;
2494
+ if (h < 0) {
2495
+ h += 360;
2496
+ }
2497
+ c = Math.sqrt(a * a + b * b);
2498
+ return [l, c, h];
2499
+ };
2500
+ convert.lch.lab = function(lch) {
2501
+ var l = lch[0];
2502
+ var c = lch[1];
2503
+ var h = lch[2];
2504
+ var a;
2505
+ var b;
2506
+ var hr;
2507
+ hr = h / 360 * 2 * Math.PI;
2508
+ a = c * Math.cos(hr);
2509
+ b = c * Math.sin(hr);
2510
+ return [l, a, b];
2511
+ };
2512
+ convert.rgb.ansi16 = function(args) {
2513
+ var r = args[0];
2514
+ var g = args[1];
2515
+ var b = args[2];
2516
+ var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2];
2517
+ value = Math.round(value / 50);
2518
+ if (value === 0) {
2519
+ return 30;
2520
+ }
2521
+ var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
2522
+ if (value === 2) {
2523
+ ansi += 60;
2524
+ }
2525
+ return ansi;
2526
+ };
2527
+ convert.hsv.ansi16 = function(args) {
2528
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
2529
+ };
2530
+ convert.rgb.ansi256 = function(args) {
2531
+ var r = args[0];
2532
+ var g = args[1];
2533
+ var b = args[2];
2534
+ if (r === g && g === b) {
2535
+ if (r < 8) {
2536
+ return 16;
2537
+ }
2538
+ if (r > 248) {
2539
+ return 231;
2540
+ }
2541
+ return Math.round((r - 8) / 247 * 24) + 232;
2542
+ }
2543
+ var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
2544
+ return ansi;
2545
+ };
2546
+ convert.ansi16.rgb = function(args) {
2547
+ var color = args % 10;
2548
+ if (color === 0 || color === 7) {
2549
+ if (args > 50) {
2550
+ color += 3.5;
2551
+ }
2552
+ color = color / 10.5 * 255;
2553
+ return [color, color, color];
2554
+ }
2555
+ var mult = (~~(args > 50) + 1) * 0.5;
2556
+ var r = (color & 1) * mult * 255;
2557
+ var g = (color >> 1 & 1) * mult * 255;
2558
+ var b = (color >> 2 & 1) * mult * 255;
2559
+ return [r, g, b];
2560
+ };
2561
+ convert.ansi256.rgb = function(args) {
2562
+ if (args >= 232) {
2563
+ var c = (args - 232) * 10 + 8;
2564
+ return [c, c, c];
2565
+ }
2566
+ args -= 16;
2567
+ var rem;
2568
+ var r = Math.floor(args / 36) / 5 * 255;
2569
+ var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
2570
+ var b = rem % 6 / 5 * 255;
2571
+ return [r, g, b];
2572
+ };
2573
+ convert.rgb.hex = function(args) {
2574
+ var integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
2575
+ var string = integer.toString(16).toUpperCase();
2576
+ return "000000".substring(string.length) + string;
2577
+ };
2578
+ convert.hex.rgb = function(args) {
2579
+ var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
2580
+ if (!match) {
2581
+ return [0, 0, 0];
2582
+ }
2583
+ var colorString = match[0];
2584
+ if (match[0].length === 3) {
2585
+ colorString = colorString.split("").map(function(char) {
2586
+ return char + char;
2587
+ }).join("");
2588
+ }
2589
+ var integer = parseInt(colorString, 16);
2590
+ var r = integer >> 16 & 255;
2591
+ var g = integer >> 8 & 255;
2592
+ var b = integer & 255;
2593
+ return [r, g, b];
2594
+ };
2595
+ convert.rgb.hcg = function(rgb) {
2596
+ var r = rgb[0] / 255;
2597
+ var g = rgb[1] / 255;
2598
+ var b = rgb[2] / 255;
2599
+ var max = Math.max(Math.max(r, g), b);
2600
+ var min = Math.min(Math.min(r, g), b);
2601
+ var chroma = max - min;
2602
+ var grayscale;
2603
+ var hue;
2604
+ if (chroma < 1) {
2605
+ grayscale = min / (1 - chroma);
2606
+ } else {
2607
+ grayscale = 0;
2608
+ }
2609
+ if (chroma <= 0) {
2610
+ hue = 0;
2611
+ } else if (max === r) {
2612
+ hue = (g - b) / chroma % 6;
2613
+ } else if (max === g) {
2614
+ hue = 2 + (b - r) / chroma;
2615
+ } else {
2616
+ hue = 4 + (r - g) / chroma + 4;
2617
+ }
2618
+ hue /= 6;
2619
+ hue %= 1;
2620
+ return [hue * 360, chroma * 100, grayscale * 100];
2621
+ };
2622
+ convert.hsl.hcg = function(hsl) {
2623
+ var s = hsl[1] / 100;
2624
+ var l = hsl[2] / 100;
2625
+ var c = 1;
2626
+ var f = 0;
2627
+ if (l < 0.5) {
2628
+ c = 2 * s * l;
2629
+ } else {
2630
+ c = 2 * s * (1 - l);
2631
+ }
2632
+ if (c < 1) {
2633
+ f = (l - 0.5 * c) / (1 - c);
2634
+ }
2635
+ return [hsl[0], c * 100, f * 100];
2636
+ };
2637
+ convert.hsv.hcg = function(hsv) {
2638
+ var s = hsv[1] / 100;
2639
+ var v = hsv[2] / 100;
2640
+ var c = s * v;
2641
+ var f = 0;
2642
+ if (c < 1) {
2643
+ f = (v - c) / (1 - c);
2644
+ }
2645
+ return [hsv[0], c * 100, f * 100];
2646
+ };
2647
+ convert.hcg.rgb = function(hcg) {
2648
+ var h = hcg[0] / 360;
2649
+ var c = hcg[1] / 100;
2650
+ var g = hcg[2] / 100;
2651
+ if (c === 0) {
2652
+ return [g * 255, g * 255, g * 255];
2653
+ }
2654
+ var pure = [0, 0, 0];
2655
+ var hi = h % 1 * 6;
2656
+ var v = hi % 1;
2657
+ var w = 1 - v;
2658
+ var mg = 0;
2659
+ switch (Math.floor(hi)) {
2660
+ case 0:
2661
+ pure[0] = 1;
2662
+ pure[1] = v;
2663
+ pure[2] = 0;
2664
+ break;
2665
+ case 1:
2666
+ pure[0] = w;
2667
+ pure[1] = 1;
2668
+ pure[2] = 0;
2669
+ break;
2670
+ case 2:
2671
+ pure[0] = 0;
2672
+ pure[1] = 1;
2673
+ pure[2] = v;
2674
+ break;
2675
+ case 3:
2676
+ pure[0] = 0;
2677
+ pure[1] = w;
2678
+ pure[2] = 1;
2679
+ break;
2680
+ case 4:
2681
+ pure[0] = v;
2682
+ pure[1] = 0;
2683
+ pure[2] = 1;
2684
+ break;
2685
+ default:
2686
+ pure[0] = 1;
2687
+ pure[1] = 0;
2688
+ pure[2] = w;
2689
+ }
2690
+ mg = (1 - c) * g;
2691
+ return [
2692
+ (c * pure[0] + mg) * 255,
2693
+ (c * pure[1] + mg) * 255,
2694
+ (c * pure[2] + mg) * 255
2695
+ ];
2696
+ };
2697
+ convert.hcg.hsv = function(hcg) {
2698
+ var c = hcg[1] / 100;
2699
+ var g = hcg[2] / 100;
2700
+ var v = c + g * (1 - c);
2701
+ var f = 0;
2702
+ if (v > 0) {
2703
+ f = c / v;
2704
+ }
2705
+ return [hcg[0], f * 100, v * 100];
2706
+ };
2707
+ convert.hcg.hsl = function(hcg) {
2708
+ var c = hcg[1] / 100;
2709
+ var g = hcg[2] / 100;
2710
+ var l = g * (1 - c) + 0.5 * c;
2711
+ var s = 0;
2712
+ if (l > 0 && l < 0.5) {
2713
+ s = c / (2 * l);
2714
+ } else if (l >= 0.5 && l < 1) {
2715
+ s = c / (2 * (1 - l));
2716
+ }
2717
+ return [hcg[0], s * 100, l * 100];
2718
+ };
2719
+ convert.hcg.hwb = function(hcg) {
2720
+ var c = hcg[1] / 100;
2721
+ var g = hcg[2] / 100;
2722
+ var v = c + g * (1 - c);
2723
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
2724
+ };
2725
+ convert.hwb.hcg = function(hwb) {
2726
+ var w = hwb[1] / 100;
2727
+ var b = hwb[2] / 100;
2728
+ var v = 1 - b;
2729
+ var c = v - w;
2730
+ var g = 0;
2731
+ if (c < 1) {
2732
+ g = (v - c) / (1 - c);
2733
+ }
2734
+ return [hwb[0], c * 100, g * 100];
2735
+ };
2736
+ convert.apple.rgb = function(apple) {
2737
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
2738
+ };
2739
+ convert.rgb.apple = function(rgb) {
2740
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
2741
+ };
2742
+ convert.gray.rgb = function(args) {
2743
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
2744
+ };
2745
+ convert.gray.hsl = convert.gray.hsv = function(args) {
2746
+ return [0, 0, args[0]];
2747
+ };
2748
+ convert.gray.hwb = function(gray) {
2749
+ return [0, 100, gray[0]];
2750
+ };
2751
+ convert.gray.cmyk = function(gray) {
2752
+ return [0, 0, 0, gray[0]];
2753
+ };
2754
+ convert.gray.lab = function(gray) {
2755
+ return [gray[0], 0, 0];
2756
+ };
2757
+ convert.gray.hex = function(gray) {
2758
+ var val = Math.round(gray[0] / 100 * 255) & 255;
2759
+ var integer = (val << 16) + (val << 8) + val;
2760
+ var string = integer.toString(16).toUpperCase();
2761
+ return "000000".substring(string.length) + string;
2762
+ };
2763
+ convert.rgb.gray = function(rgb) {
2764
+ var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
2765
+ return [val / 255 * 100];
2766
+ };
2767
+ }
2768
+ });
2769
+
2770
+ // ../../node_modules/color-convert/route.js
2771
+ var require_route = __commonJS({
2772
+ "../../node_modules/color-convert/route.js"(exports, module) {
2773
+ var conversions = require_conversions();
2774
+ function buildGraph() {
2775
+ var graph = {};
2776
+ var models = Object.keys(conversions);
2777
+ for (var len = models.length, i = 0; i < len; i++) {
2778
+ graph[models[i]] = {
2779
+ // http://jsperf.com/1-vs-infinity
2780
+ // micro-opt, but this is simple.
2781
+ distance: -1,
2782
+ parent: null
2783
+ };
2784
+ }
2785
+ return graph;
2786
+ }
2787
+ function deriveBFS(fromModel) {
2788
+ var graph = buildGraph();
2789
+ var queue = [fromModel];
2790
+ graph[fromModel].distance = 0;
2791
+ while (queue.length) {
2792
+ var current = queue.pop();
2793
+ var adjacents = Object.keys(conversions[current]);
2794
+ for (var len = adjacents.length, i = 0; i < len; i++) {
2795
+ var adjacent = adjacents[i];
2796
+ var node = graph[adjacent];
2797
+ if (node.distance === -1) {
2798
+ node.distance = graph[current].distance + 1;
2799
+ node.parent = current;
2800
+ queue.unshift(adjacent);
2801
+ }
2802
+ }
2803
+ }
2804
+ return graph;
2805
+ }
2806
+ function link(from, to) {
2807
+ return function(args) {
2808
+ return to(from(args));
2809
+ };
2810
+ }
2811
+ function wrapConversion(toModel, graph) {
2812
+ var path = [graph[toModel].parent, toModel];
2813
+ var fn = conversions[graph[toModel].parent][toModel];
2814
+ var cur = graph[toModel].parent;
2815
+ while (graph[cur].parent) {
2816
+ path.unshift(graph[cur].parent);
2817
+ fn = link(conversions[graph[cur].parent][cur], fn);
2818
+ cur = graph[cur].parent;
2819
+ }
2820
+ fn.conversion = path;
2821
+ return fn;
2822
+ }
2823
+ module.exports = function(fromModel) {
2824
+ var graph = deriveBFS(fromModel);
2825
+ var conversion = {};
2826
+ var models = Object.keys(graph);
2827
+ for (var len = models.length, i = 0; i < len; i++) {
2828
+ var toModel = models[i];
2829
+ var node = graph[toModel];
2830
+ if (node.parent === null) {
2831
+ continue;
2832
+ }
2833
+ conversion[toModel] = wrapConversion(toModel, graph);
2834
+ }
2835
+ return conversion;
2836
+ };
2837
+ }
2838
+ });
2839
+
2840
+ // ../../node_modules/color-convert/index.js
2841
+ var require_color_convert = __commonJS({
2842
+ "../../node_modules/color-convert/index.js"(exports, module) {
2843
+ var conversions = require_conversions();
2844
+ var route = require_route();
2845
+ var convert = {};
2846
+ var models = Object.keys(conversions);
2847
+ function wrapRaw(fn) {
2848
+ var wrappedFn = function(args) {
2849
+ if (args === void 0 || args === null) {
2850
+ return args;
2851
+ }
2852
+ if (arguments.length > 1) {
2853
+ args = Array.prototype.slice.call(arguments);
2854
+ }
2855
+ return fn(args);
2856
+ };
2857
+ if ("conversion" in fn) {
2858
+ wrappedFn.conversion = fn.conversion;
2859
+ }
2860
+ return wrappedFn;
2861
+ }
2862
+ function wrapRounded(fn) {
2863
+ var wrappedFn = function(args) {
2864
+ if (args === void 0 || args === null) {
2865
+ return args;
2866
+ }
2867
+ if (arguments.length > 1) {
2868
+ args = Array.prototype.slice.call(arguments);
2869
+ }
2870
+ var result = fn(args);
2871
+ if (typeof result === "object") {
2872
+ for (var len = result.length, i = 0; i < len; i++) {
2873
+ result[i] = Math.round(result[i]);
2874
+ }
2875
+ }
2876
+ return result;
2877
+ };
2878
+ if ("conversion" in fn) {
2879
+ wrappedFn.conversion = fn.conversion;
2880
+ }
2881
+ return wrappedFn;
2882
+ }
2883
+ models.forEach(function(fromModel) {
2884
+ convert[fromModel] = {};
2885
+ Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
2886
+ Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
2887
+ var routes = route(fromModel);
2888
+ var routeModels = Object.keys(routes);
2889
+ routeModels.forEach(function(toModel) {
2890
+ var fn = routes[toModel];
2891
+ convert[fromModel][toModel] = wrapRounded(fn);
2892
+ convert[fromModel][toModel].raw = wrapRaw(fn);
2893
+ });
2894
+ });
2895
+ module.exports = convert;
2896
+ }
2897
+ });
2898
+
2899
+ // ../../node_modules/ansi-styles/index.js
2900
+ var require_ansi_styles = __commonJS({
2901
+ "../../node_modules/ansi-styles/index.js"(exports, module) {
2902
+ "use strict";
2903
+ var colorConvert = require_color_convert();
2904
+ var wrapAnsi16 = (fn, offset) => function() {
2905
+ const code = fn.apply(colorConvert, arguments);
2906
+ return `\x1B[${code + offset}m`;
2907
+ };
2908
+ var wrapAnsi256 = (fn, offset) => function() {
2909
+ const code = fn.apply(colorConvert, arguments);
2910
+ return `\x1B[${38 + offset};5;${code}m`;
2911
+ };
2912
+ var wrapAnsi16m = (fn, offset) => function() {
2913
+ const rgb = fn.apply(colorConvert, arguments);
2914
+ return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
2915
+ };
2916
+ function assembleStyles() {
2917
+ const codes = /* @__PURE__ */ new Map();
2918
+ const styles = {
2919
+ modifier: {
2920
+ reset: [0, 0],
2921
+ // 21 isn't widely supported and 22 does the same thing
2922
+ bold: [1, 22],
2923
+ dim: [2, 22],
2924
+ italic: [3, 23],
2925
+ underline: [4, 24],
2926
+ inverse: [7, 27],
2927
+ hidden: [8, 28],
2928
+ strikethrough: [9, 29]
2929
+ },
2930
+ color: {
2931
+ black: [30, 39],
2932
+ red: [31, 39],
2933
+ green: [32, 39],
2934
+ yellow: [33, 39],
2935
+ blue: [34, 39],
2936
+ magenta: [35, 39],
2937
+ cyan: [36, 39],
2938
+ white: [37, 39],
2939
+ gray: [90, 39],
2940
+ // Bright color
2941
+ redBright: [91, 39],
2942
+ greenBright: [92, 39],
2943
+ yellowBright: [93, 39],
2944
+ blueBright: [94, 39],
2945
+ magentaBright: [95, 39],
2946
+ cyanBright: [96, 39],
2947
+ whiteBright: [97, 39]
2948
+ },
2949
+ bgColor: {
2950
+ bgBlack: [40, 49],
2951
+ bgRed: [41, 49],
2952
+ bgGreen: [42, 49],
2953
+ bgYellow: [43, 49],
2954
+ bgBlue: [44, 49],
2955
+ bgMagenta: [45, 49],
2956
+ bgCyan: [46, 49],
2957
+ bgWhite: [47, 49],
2958
+ // Bright color
2959
+ bgBlackBright: [100, 49],
2960
+ bgRedBright: [101, 49],
2961
+ bgGreenBright: [102, 49],
2962
+ bgYellowBright: [103, 49],
2963
+ bgBlueBright: [104, 49],
2964
+ bgMagentaBright: [105, 49],
2965
+ bgCyanBright: [106, 49],
2966
+ bgWhiteBright: [107, 49]
2967
+ }
2968
+ };
2969
+ styles.color.grey = styles.color.gray;
2970
+ for (const groupName of Object.keys(styles)) {
2971
+ const group = styles[groupName];
2972
+ for (const styleName of Object.keys(group)) {
2973
+ const style = group[styleName];
2974
+ styles[styleName] = {
2975
+ open: `\x1B[${style[0]}m`,
2976
+ close: `\x1B[${style[1]}m`
2977
+ };
2978
+ group[styleName] = styles[styleName];
2979
+ codes.set(style[0], style[1]);
2980
+ }
2981
+ Object.defineProperty(styles, groupName, {
2982
+ value: group,
2983
+ enumerable: false
2984
+ });
2985
+ Object.defineProperty(styles, "codes", {
2986
+ value: codes,
2987
+ enumerable: false
2988
+ });
2989
+ }
2990
+ const ansi2ansi = (n) => n;
2991
+ const rgb2rgb = (r, g, b) => [r, g, b];
2992
+ styles.color.close = "\x1B[39m";
2993
+ styles.bgColor.close = "\x1B[49m";
2994
+ styles.color.ansi = {
2995
+ ansi: wrapAnsi16(ansi2ansi, 0)
2996
+ };
2997
+ styles.color.ansi256 = {
2998
+ ansi256: wrapAnsi256(ansi2ansi, 0)
2999
+ };
3000
+ styles.color.ansi16m = {
3001
+ rgb: wrapAnsi16m(rgb2rgb, 0)
3002
+ };
3003
+ styles.bgColor.ansi = {
3004
+ ansi: wrapAnsi16(ansi2ansi, 10)
3005
+ };
3006
+ styles.bgColor.ansi256 = {
3007
+ ansi256: wrapAnsi256(ansi2ansi, 10)
3008
+ };
3009
+ styles.bgColor.ansi16m = {
3010
+ rgb: wrapAnsi16m(rgb2rgb, 10)
3011
+ };
3012
+ for (let key of Object.keys(colorConvert)) {
3013
+ if (typeof colorConvert[key] !== "object") {
3014
+ continue;
3015
+ }
3016
+ const suite = colorConvert[key];
3017
+ if (key === "ansi16") {
3018
+ key = "ansi";
3019
+ }
3020
+ if ("ansi16" in suite) {
3021
+ styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
3022
+ styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
3023
+ }
3024
+ if ("ansi256" in suite) {
3025
+ styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
3026
+ styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
3027
+ }
3028
+ if ("rgb" in suite) {
3029
+ styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
3030
+ styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
3031
+ }
3032
+ }
3033
+ return styles;
3034
+ }
3035
+ Object.defineProperty(module, "exports", {
3036
+ enumerable: true,
3037
+ get: assembleStyles
3038
+ });
3039
+ }
3040
+ });
3041
+
3042
+ // ../../node_modules/has-flag/index.js
3043
+ var require_has_flag = __commonJS({
3044
+ "../../node_modules/has-flag/index.js"(exports, module) {
3045
+ "use strict";
3046
+ module.exports = (flag, argv) => {
3047
+ argv = argv || process.argv;
3048
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
3049
+ const pos = argv.indexOf(prefix + flag);
3050
+ const terminatorPos = argv.indexOf("--");
3051
+ return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
3052
+ };
3053
+ }
3054
+ });
3055
+
3056
+ // ../../node_modules/supports-color/index.js
3057
+ var require_supports_color = __commonJS({
3058
+ "../../node_modules/supports-color/index.js"(exports, module) {
3059
+ "use strict";
3060
+ var os = __require("os");
3061
+ var hasFlag = require_has_flag();
3062
+ var env = process.env;
3063
+ var forceColor;
3064
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
3065
+ forceColor = false;
3066
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
3067
+ forceColor = true;
3068
+ }
3069
+ if ("FORCE_COLOR" in env) {
3070
+ forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
3071
+ }
3072
+ function translateLevel(level) {
3073
+ if (level === 0) {
3074
+ return false;
3075
+ }
3076
+ return {
3077
+ level,
3078
+ hasBasic: true,
3079
+ has256: level >= 2,
3080
+ has16m: level >= 3
3081
+ };
3082
+ }
3083
+ function supportsColor(stream) {
3084
+ if (forceColor === false) {
3085
+ return 0;
3086
+ }
3087
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
3088
+ return 3;
3089
+ }
3090
+ if (hasFlag("color=256")) {
3091
+ return 2;
3092
+ }
3093
+ if (stream && !stream.isTTY && forceColor !== true) {
3094
+ return 0;
3095
+ }
3096
+ const min = forceColor ? 1 : 0;
3097
+ if (process.platform === "win32") {
3098
+ const osRelease = os.release().split(".");
3099
+ if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
3100
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
3101
+ }
3102
+ return 1;
3103
+ }
3104
+ if ("CI" in env) {
3105
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
3106
+ return 1;
3107
+ }
3108
+ return min;
3109
+ }
3110
+ if ("TEAMCITY_VERSION" in env) {
3111
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
3112
+ }
3113
+ if (env.COLORTERM === "truecolor") {
3114
+ return 3;
3115
+ }
3116
+ if ("TERM_PROGRAM" in env) {
3117
+ const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
3118
+ switch (env.TERM_PROGRAM) {
3119
+ case "iTerm.app":
3120
+ return version >= 3 ? 3 : 2;
3121
+ case "Apple_Terminal":
3122
+ return 2;
3123
+ }
3124
+ }
3125
+ if (/-256(color)?$/i.test(env.TERM)) {
3126
+ return 2;
3127
+ }
3128
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
3129
+ return 1;
3130
+ }
3131
+ if ("COLORTERM" in env) {
3132
+ return 1;
3133
+ }
3134
+ if (env.TERM === "dumb") {
3135
+ return min;
3136
+ }
3137
+ return min;
3138
+ }
3139
+ function getSupportLevel(stream) {
3140
+ const level = supportsColor(stream);
3141
+ return translateLevel(level);
3142
+ }
3143
+ module.exports = {
3144
+ supportsColor: getSupportLevel,
3145
+ stdout: getSupportLevel(process.stdout),
3146
+ stderr: getSupportLevel(process.stderr)
3147
+ };
3148
+ }
3149
+ });
3150
+
3151
+ // ../../node_modules/chalk/templates.js
3152
+ var require_templates = __commonJS({
3153
+ "../../node_modules/chalk/templates.js"(exports, module) {
3154
+ "use strict";
3155
+ var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
3156
+ var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
3157
+ var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
3158
+ var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
3159
+ var ESCAPES = /* @__PURE__ */ new Map([
3160
+ ["n", "\n"],
3161
+ ["r", "\r"],
3162
+ ["t", " "],
3163
+ ["b", "\b"],
3164
+ ["f", "\f"],
3165
+ ["v", "\v"],
3166
+ ["0", "\0"],
3167
+ ["\\", "\\"],
3168
+ ["e", "\x1B"],
3169
+ ["a", "\x07"]
3170
+ ]);
3171
+ function unescape(c) {
3172
+ if (c[0] === "u" && c.length === 5 || c[0] === "x" && c.length === 3) {
3173
+ return String.fromCharCode(parseInt(c.slice(1), 16));
3174
+ }
3175
+ return ESCAPES.get(c) || c;
3176
+ }
3177
+ function parseArguments(name, args) {
3178
+ const results = [];
3179
+ const chunks = args.trim().split(/\s*,\s*/g);
3180
+ let matches;
3181
+ for (const chunk of chunks) {
3182
+ if (!isNaN(chunk)) {
3183
+ results.push(Number(chunk));
3184
+ } else if (matches = chunk.match(STRING_REGEX)) {
3185
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
3186
+ } else {
3187
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
3188
+ }
3189
+ }
3190
+ return results;
3191
+ }
3192
+ function parseStyle(style) {
3193
+ STYLE_REGEX.lastIndex = 0;
3194
+ const results = [];
3195
+ let matches;
3196
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
3197
+ const name = matches[1];
3198
+ if (matches[2]) {
3199
+ const args = parseArguments(name, matches[2]);
3200
+ results.push([name].concat(args));
3201
+ } else {
3202
+ results.push([name]);
3203
+ }
3204
+ }
3205
+ return results;
3206
+ }
3207
+ function buildStyle(chalk2, styles) {
3208
+ const enabled = {};
3209
+ for (const layer of styles) {
3210
+ for (const style of layer.styles) {
3211
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
3212
+ }
3213
+ }
3214
+ let current = chalk2;
3215
+ for (const styleName of Object.keys(enabled)) {
3216
+ if (Array.isArray(enabled[styleName])) {
3217
+ if (!(styleName in current)) {
3218
+ throw new Error(`Unknown Chalk style: ${styleName}`);
3219
+ }
3220
+ if (enabled[styleName].length > 0) {
3221
+ current = current[styleName].apply(current, enabled[styleName]);
3222
+ } else {
3223
+ current = current[styleName];
3224
+ }
3225
+ }
3226
+ }
3227
+ return current;
3228
+ }
3229
+ module.exports = (chalk2, tmp) => {
3230
+ const styles = [];
3231
+ const chunks = [];
3232
+ let chunk = [];
3233
+ tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
3234
+ if (escapeChar) {
3235
+ chunk.push(unescape(escapeChar));
3236
+ } else if (style) {
3237
+ const str = chunk.join("");
3238
+ chunk = [];
3239
+ chunks.push(styles.length === 0 ? str : buildStyle(chalk2, styles)(str));
3240
+ styles.push({ inverse, styles: parseStyle(style) });
3241
+ } else if (close) {
3242
+ if (styles.length === 0) {
3243
+ throw new Error("Found extraneous } in Chalk template literal");
3244
+ }
3245
+ chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
3246
+ chunk = [];
3247
+ styles.pop();
3248
+ } else {
3249
+ chunk.push(chr);
3250
+ }
3251
+ });
3252
+ chunks.push(chunk.join(""));
3253
+ if (styles.length > 0) {
3254
+ const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
3255
+ throw new Error(errMsg);
3256
+ }
3257
+ return chunks.join("");
3258
+ };
3259
+ }
3260
+ });
3261
+
3262
+ // ../../node_modules/chalk/index.js
3263
+ var require_chalk = __commonJS({
3264
+ "../../node_modules/chalk/index.js"(exports, module) {
3265
+ "use strict";
3266
+ var escapeStringRegexp = require_escape_string_regexp();
3267
+ var ansiStyles = require_ansi_styles();
3268
+ var stdoutColor = require_supports_color().stdout;
3269
+ var template = require_templates();
3270
+ var isSimpleWindowsTerm = process.platform === "win32" && !(process.env.TERM || "").toLowerCase().startsWith("xterm");
3271
+ var levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"];
3272
+ var skipModels = /* @__PURE__ */ new Set(["gray"]);
3273
+ var styles = /* @__PURE__ */ Object.create(null);
3274
+ function applyOptions(obj, options) {
3275
+ options = options || {};
3276
+ const scLevel = stdoutColor ? stdoutColor.level : 0;
3277
+ obj.level = options.level === void 0 ? scLevel : options.level;
3278
+ obj.enabled = "enabled" in options ? options.enabled : obj.level > 0;
3279
+ }
3280
+ function Chalk(options) {
3281
+ if (!this || !(this instanceof Chalk) || this.template) {
3282
+ const chalk2 = {};
3283
+ applyOptions(chalk2, options);
3284
+ chalk2.template = function() {
3285
+ const args = [].slice.call(arguments);
3286
+ return chalkTag.apply(null, [chalk2.template].concat(args));
3287
+ };
3288
+ Object.setPrototypeOf(chalk2, Chalk.prototype);
3289
+ Object.setPrototypeOf(chalk2.template, chalk2);
3290
+ chalk2.template.constructor = Chalk;
3291
+ return chalk2.template;
3292
+ }
3293
+ applyOptions(this, options);
3294
+ }
3295
+ if (isSimpleWindowsTerm) {
3296
+ ansiStyles.blue.open = "\x1B[94m";
3297
+ }
3298
+ for (const key of Object.keys(ansiStyles)) {
3299
+ ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g");
3300
+ styles[key] = {
3301
+ get() {
3302
+ const codes = ansiStyles[key];
3303
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
3304
+ }
3305
+ };
3306
+ }
3307
+ styles.visible = {
3308
+ get() {
3309
+ return build.call(this, this._styles || [], true, "visible");
3310
+ }
3311
+ };
3312
+ ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), "g");
3313
+ for (const model of Object.keys(ansiStyles.color.ansi)) {
3314
+ if (skipModels.has(model)) {
3315
+ continue;
3316
+ }
3317
+ styles[model] = {
3318
+ get() {
3319
+ const level = this.level;
3320
+ return function() {
3321
+ const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
3322
+ const codes = {
3323
+ open,
3324
+ close: ansiStyles.color.close,
3325
+ closeRe: ansiStyles.color.closeRe
3326
+ };
3327
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
3328
+ };
3329
+ }
3330
+ };
3331
+ }
3332
+ ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), "g");
3333
+ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
3334
+ if (skipModels.has(model)) {
3335
+ continue;
3336
+ }
3337
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
3338
+ styles[bgModel] = {
3339
+ get() {
3340
+ const level = this.level;
3341
+ return function() {
3342
+ const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
3343
+ const codes = {
3344
+ open,
3345
+ close: ansiStyles.bgColor.close,
3346
+ closeRe: ansiStyles.bgColor.closeRe
3347
+ };
3348
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
3349
+ };
3350
+ }
3351
+ };
3352
+ }
3353
+ var proto = Object.defineProperties(() => {
3354
+ }, styles);
3355
+ function build(_styles, _empty, key) {
3356
+ const builder = function() {
3357
+ return applyStyle.apply(builder, arguments);
3358
+ };
3359
+ builder._styles = _styles;
3360
+ builder._empty = _empty;
3361
+ const self = this;
3362
+ Object.defineProperty(builder, "level", {
3363
+ enumerable: true,
3364
+ get() {
3365
+ return self.level;
3366
+ },
3367
+ set(level) {
3368
+ self.level = level;
3369
+ }
3370
+ });
3371
+ Object.defineProperty(builder, "enabled", {
3372
+ enumerable: true,
3373
+ get() {
3374
+ return self.enabled;
3375
+ },
3376
+ set(enabled) {
3377
+ self.enabled = enabled;
3378
+ }
3379
+ });
3380
+ builder.hasGrey = this.hasGrey || key === "gray" || key === "grey";
3381
+ builder.__proto__ = proto;
3382
+ return builder;
3383
+ }
3384
+ function applyStyle() {
3385
+ const args = arguments;
3386
+ const argsLen = args.length;
3387
+ let str = String(arguments[0]);
3388
+ if (argsLen === 0) {
3389
+ return "";
3390
+ }
3391
+ if (argsLen > 1) {
3392
+ for (let a = 1; a < argsLen; a++) {
3393
+ str += " " + args[a];
3394
+ }
3395
+ }
3396
+ if (!this.enabled || this.level <= 0 || !str) {
3397
+ return this._empty ? "" : str;
3398
+ }
3399
+ const originalDim = ansiStyles.dim.open;
3400
+ if (isSimpleWindowsTerm && this.hasGrey) {
3401
+ ansiStyles.dim.open = "";
3402
+ }
3403
+ for (const code of this._styles.slice().reverse()) {
3404
+ str = code.open + str.replace(code.closeRe, code.open) + code.close;
3405
+ str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
3406
+ }
3407
+ ansiStyles.dim.open = originalDim;
3408
+ return str;
3409
+ }
3410
+ function chalkTag(chalk2, strings) {
3411
+ if (!Array.isArray(strings)) {
3412
+ return [].slice.call(arguments, 1).join(" ");
3413
+ }
3414
+ const args = [].slice.call(arguments, 2);
3415
+ const parts = [strings.raw[0]];
3416
+ for (let i = 1; i < strings.length; i++) {
3417
+ parts.push(String(args[i - 1]).replace(/[{}\\]/g, "\\$&"));
3418
+ parts.push(String(strings.raw[i]));
3419
+ }
3420
+ return template(chalk2, parts.join(""));
3421
+ }
3422
+ Object.defineProperties(Chalk.prototype, styles);
3423
+ module.exports = Chalk();
3424
+ module.exports.supportsColor = stdoutColor;
3425
+ module.exports.default = module.exports;
3426
+ }
3427
+ });
3428
+
3429
+ // src/index.ts
3430
+ var import_commander = __toESM(require_commander(), 1);
3431
+ var import_chalk = __toESM(require_chalk(), 1);
3432
+ import { createNodeApp } from "@create-node-app/core";
3433
+
3434
+ // src/options.ts
3435
+ import prompts from "prompts";
3436
+ import yargs from "yargs";
3437
+
3438
+ // src/templates.ts
3439
+ var TEMPLATE_DATA_FILE_URL = "https://raw.githubusercontent.com/Create-Node-App/cna-templates/main/templates.json";
3440
+ var templateDataMap = /* @__PURE__ */ new Map();
3441
+ var getTemplateData = async () => {
3442
+ if (templateDataMap.has(TEMPLATE_DATA_FILE_URL)) {
3443
+ return templateDataMap.get(TEMPLATE_DATA_FILE_URL);
3444
+ }
3445
+ const templateDataFile = await fetch(TEMPLATE_DATA_FILE_URL);
3446
+ const templateData = await templateDataFile.json();
3447
+ templateDataMap.set(TEMPLATE_DATA_FILE_URL, templateData);
3448
+ return templateData;
3449
+ };
3450
+ var getBaseTemplates = async () => {
3451
+ const templateData = await getTemplateData();
3452
+ return templateData.templates;
3453
+ };
3454
+ var getCnaExtensions = async (appType) => {
3455
+ const templateData = await getTemplateData();
3456
+ return templateData.extensions.filter(
3457
+ (extension) => extension.type === appType
3458
+ );
3459
+ };
3460
+
3461
+ // src/options.ts
3462
+ prompts.override(yargs.argv);
3463
+ var getCnaOptions = async (options) => {
3464
+ var _a;
3465
+ const templates = await getBaseTemplates();
3466
+ const appTypeOptions = templates.map((template) => {
3467
+ var _a2;
3468
+ return {
3469
+ title: template.name,
3470
+ value: template.type,
3471
+ description: template.description + " - " + ((_a2 = template.labels) == null ? void 0 : _a2.join(", "))
3472
+ };
3473
+ });
3474
+ const baseInput = await prompts([
3475
+ {
3476
+ type: "text",
3477
+ name: "projectName",
3478
+ message: `What's your project name?`,
3479
+ initial: options.projectName
3480
+ },
3481
+ {
3482
+ type: "toggle",
3483
+ name: "useNpm",
3484
+ message: "Use `npm` mandatorily?",
3485
+ initial: options.useNpm,
3486
+ active: "yes",
3487
+ inactive: "no"
3488
+ },
3489
+ {
3490
+ type: "select",
3491
+ name: "appType",
3492
+ message: "What type of app do you want to create?",
3493
+ choices: appTypeOptions,
3494
+ initial: 0
3495
+ },
3496
+ {
3497
+ type: "text",
3498
+ name: "template",
3499
+ message: "Template to use to bootstrap application. e.g: https://github.com/username/repository/tree/main/subdir",
3500
+ initial: ""
3501
+ }
3502
+ ]);
3503
+ const extensions = await getCnaExtensions(baseInput.appType);
3504
+ const defaultSrcDir = options.srcDir;
3505
+ const appConfig = await prompts([
3506
+ {
3507
+ type: "text",
3508
+ name: "srcDir",
3509
+ message: "Sub directory to put all source content (.e.g. `src`, `app`). Leave blank to use the root directory.",
3510
+ initial: defaultSrcDir
3511
+ },
3512
+ {
3513
+ type: "text",
3514
+ name: "alias",
3515
+ message: "Import alias to use for the project, e.g. `@`",
3516
+ initial: options.alias
3517
+ },
3518
+ {
3519
+ type: "multiselect",
3520
+ name: "addons",
3521
+ message: `Select extensions to extend your ${baseInput.appType} project`,
3522
+ hint: "- Space to select. Return to submit",
3523
+ choices: extensions.map((option) => {
3524
+ var _a2;
3525
+ return {
3526
+ title: option.name,
3527
+ value: option.url,
3528
+ description: option.description + " - " + ((_a2 = option.labels) == null ? void 0 : _a2.join(", "))
3529
+ };
3530
+ })
3531
+ },
3532
+ {
3533
+ type: "list",
3534
+ name: "extend",
3535
+ message: "Enter extra extensions separater by comma. e.g: https://github.com/username/repository/tree/main/extension1,https://github.com/username/repository/tree/main/extension2",
3536
+ initial: "",
3537
+ separator: ","
3538
+ }
3539
+ ]);
3540
+ const { ...nextAppOptions } = {
3541
+ ...options,
3542
+ ...baseInput,
3543
+ ...appConfig
3544
+ };
3545
+ const templateAddon = baseInput.template || ((_a = templates.find((template) => template.type === nextAppOptions.appType)) == null ? void 0 : _a.url);
3546
+ const addons = [
3547
+ templateAddon,
3548
+ ...nextAppOptions.addons,
3549
+ ...nextAppOptions.extend
3550
+ ].filter(Boolean).map((addon) => ({ url: addon }));
3551
+ const nextOptions = { ...nextAppOptions, addons };
3552
+ if (nextAppOptions.verbose) {
3553
+ console.log(JSON.stringify(nextOptions, null, 2));
3554
+ }
3555
+ return nextOptions;
3556
+ };
3557
+
3558
+ // package.json
3559
+ var package_default = {
3560
+ name: "create-awesome-node-app",
3561
+ version: "0.0.0",
3562
+ type: "module",
3563
+ description: "Command line tool to create Node apps with a lot of different addons.",
3564
+ license: "MIT",
3565
+ repository: {
3566
+ type: "git",
3567
+ url: "git+https://github.com/Create-Node-App/create-node-app.git"
3568
+ },
3569
+ bugs: {
3570
+ url: "https://github.com/Create-Node-App/create-node-app/issues"
3571
+ },
3572
+ homepage: "https://github.com/Create-Node-App/create-node-app#readme",
3573
+ keywords: [
3574
+ "code generator"
3575
+ ],
3576
+ authors: [
3577
+ {
3578
+ name: "Ulises Jeremias Cornejo Fandos",
3579
+ email: "ulisescf.24@gmail.com"
3580
+ }
3581
+ ],
3582
+ engines: {
3583
+ node: ">=18.0.0"
3584
+ },
3585
+ main: "index.js",
3586
+ files: [
3587
+ "index.js",
3588
+ "dist/**"
3589
+ ],
3590
+ bin: {
3591
+ "create-awesome-node-app": "index.js"
3592
+ },
3593
+ publishConfig: {
3594
+ access: "public",
3595
+ registry: "https://registry.npmjs.org/",
3596
+ scope: "@create-node-app"
3597
+ },
3598
+ scripts: {
3599
+ build: "tsup src/index.ts --format cjs,esm --dts",
3600
+ dev: "tsup src/index.ts --watch --format cjs,esm --dts",
3601
+ typecheck: "tsc --noEmit",
3602
+ lint: "eslint .",
3603
+ "lint:fix": "eslint . --fix"
3604
+ },
3605
+ dependencies: {
3606
+ "@create-node-app/core": "*",
3607
+ prompts: "^2.4.1",
3608
+ yargs: "^17.0.1"
3609
+ },
3610
+ devDependencies: {
3611
+ "@create-node-app/eslint-config-ts": "*",
3612
+ "@types/node": "^18.14.6",
3613
+ "@types/prompts": "^2.4.2",
3614
+ "@types/yargs": "^17.0.22",
3615
+ eslint: "^7.9.0",
3616
+ tsup: "^6.2.3"
3617
+ }
3618
+ };
3619
+
3620
+ // src/index.ts
3621
+ var main = async () => {
3622
+ let projectName = "my-project";
3623
+ import_commander.default.version(package_default.version).arguments("[project-directory]").usage(`${import_chalk.default.green("[project-directory]")} [options]`).action((name) => {
3624
+ projectName = name || projectName;
3625
+ }).option("--verbose", "print additional logs").option("--info", "print environment debug info").option("--use-npm", "use npm mandatorily").option(
3626
+ "--template <template>",
3627
+ "specify template to use for initial setup"
3628
+ ).option(
3629
+ "--extend <repos...>",
3630
+ "git repositories to extend your boilerplate"
3631
+ ).option("-a, --alias <alias>", "Import alias to use for the project", "@").option(
3632
+ "--src-dir <src-dir>",
3633
+ "dir name to put content under [src]/",
3634
+ "src"
3635
+ ).option(
3636
+ "--nodeps",
3637
+ "generate package.json file without installing dependencies"
3638
+ ).option("--inplace", "apply setup to an existing project");
3639
+ import_commander.default.allowUnknownOption().on("--help", () => {
3640
+ console.log();
3641
+ console.log(
3642
+ ` Only ${import_chalk.default.green("[project-directory]")} is required.`
3643
+ );
3644
+ console.log();
3645
+ console.log(
3646
+ ` If you have any problems, do not hesitate to file an issue:`
3647
+ );
3648
+ console.log(` ${import_chalk.default.cyan(`${package_default.bugs.url}/new`)}`);
3649
+ }).parse(process.argv);
3650
+ return createNodeApp(
3651
+ projectName,
3652
+ { ...import_commander.default.opts(), projectName },
3653
+ getCnaOptions
3654
+ );
3655
+ };
3656
+ main().catch((err) => {
3657
+ console.error(err);
3658
+ process.exit(1);
3659
+ });