@maizzle/framework 6.0.0-rc.0 → 6.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/maizzle.mjs +1 -1
- package/dist/build.mjs +25 -7
- package/dist/build.mjs.map +1 -1
- package/dist/config/index.mjs +25 -1
- package/dist/config/index.mjs.map +1 -1
- package/dist/render/createRenderer.d.mts +4 -0
- package/dist/render/createRenderer.d.mts.map +1 -1
- package/dist/render/createRenderer.mjs +10 -4
- package/dist/render/createRenderer.mjs.map +1 -1
- package/dist/render/index.mjs +5 -1
- package/dist/render/index.mjs.map +1 -1
- package/dist/serve.mjs +4 -1
- package/dist/serve.mjs.map +1 -1
- package/dist/types/config.d.mts +20 -0
- package/dist/types/config.d.mts.map +1 -1
- package/node_modules/@clack/core/CHANGELOG.md +87 -4
- package/node_modules/@clack/core/README.md +1 -1
- package/node_modules/@clack/core/dist/index.d.mts +186 -48
- package/node_modules/@clack/core/dist/index.mjs +10 -14
- package/node_modules/@clack/core/dist/index.mjs.map +1 -1
- package/node_modules/@clack/core/package.json +7 -9
- package/node_modules/@clack/prompts/CHANGELOG.md +171 -7
- package/node_modules/@clack/prompts/README.md +66 -3
- package/node_modules/@clack/prompts/dist/index.d.mts +302 -76
- package/node_modules/@clack/prompts/dist/index.mjs +134 -84
- package/node_modules/@clack/prompts/dist/index.mjs.map +1 -1
- package/node_modules/@clack/prompts/package.json +14 -10
- package/node_modules/citty/LICENSE +0 -15
- package/node_modules/citty/README.md +166 -69
- package/node_modules/citty/dist/index.d.mts +88 -56
- package/node_modules/citty/dist/index.mjs +399 -437
- package/node_modules/citty/package.json +28 -35
- package/node_modules/giget/README.md +59 -11
- package/node_modules/giget/dist/THIRD-PARTY-LICENSES.md +205 -0
- package/node_modules/giget/dist/_chunks/giget.mjs +508 -0
- package/node_modules/giget/dist/_chunks/libs/citty.mjs +269 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.d.mts +1 -0
- package/node_modules/giget/dist/_chunks/libs/nypm.mjs +669 -0
- package/node_modules/giget/dist/_chunks/libs/tar.mjs +2931 -0
- package/node_modules/giget/dist/_chunks/rolldown-runtime.mjs +14 -0
- package/node_modules/giget/dist/cli.d.mts +1 -0
- package/node_modules/giget/dist/cli.mjs +89 -111
- package/node_modules/giget/dist/index.d.mts +46 -35
- package/node_modules/giget/dist/index.mjs +2 -22
- package/node_modules/giget/package.json +32 -45
- package/node_modules/maizzle/README.md +140 -0
- package/node_modules/maizzle/bin/maizzle.mjs +5 -0
- package/node_modules/maizzle/dist/commands/new.d.mts +7 -0
- package/node_modules/maizzle/dist/commands/new.mjs +278 -0
- package/node_modules/{@maizzle/cli → maizzle}/dist/index.d.mts +1 -1
- package/node_modules/maizzle/dist/index.mjs +44 -0
- package/node_modules/{commander → maizzle/node_modules/commander}/Readme.md +94 -67
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/argument.js +5 -4
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/command.js +154 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/help.js +77 -39
- package/node_modules/{commander → maizzle/node_modules/commander}/lib/option.js +16 -3
- package/node_modules/{commander → maizzle/node_modules/commander}/package-support.json +4 -1
- package/node_modules/{commander → maizzle/node_modules/commander}/package.json +8 -8
- package/node_modules/{commander → maizzle/node_modules/commander}/typings/index.d.ts +71 -3
- package/node_modules/{@maizzle/cli → maizzle}/package.json +13 -11
- package/node_modules/tinyexec/README.md +49 -3
- package/node_modules/tinyexec/dist/main.d.mts +25 -14
- package/node_modules/tinyexec/dist/main.mjs +148 -100
- package/node_modules/tinyexec/package.json +9 -8
- package/package.json +3 -3
- package/node_modules/@clack/core/dist/index.cjs +0 -15
- package/node_modules/@clack/core/dist/index.cjs.map +0 -1
- package/node_modules/@clack/core/dist/index.d.cts +0 -211
- package/node_modules/@clack/core/dist/index.d.ts +0 -211
- package/node_modules/@clack/prompts/dist/index.cjs +0 -87
- package/node_modules/@clack/prompts/dist/index.cjs.map +0 -1
- package/node_modules/@clack/prompts/dist/index.d.cts +0 -165
- package/node_modules/@clack/prompts/dist/index.d.ts +0 -165
- package/node_modules/@maizzle/cli/README.md +0 -58
- package/node_modules/@maizzle/cli/dist/index.mjs +0 -42
- package/node_modules/citty/dist/index.cjs +0 -475
- package/node_modules/citty/dist/index.d.cts +0 -80
- package/node_modules/citty/dist/index.d.ts +0 -80
- package/node_modules/consola/LICENSE +0 -47
- package/node_modules/consola/README.md +0 -352
- package/node_modules/consola/basic.d.ts +0 -1
- package/node_modules/consola/browser.d.ts +0 -1
- package/node_modules/consola/core.d.ts +0 -1
- package/node_modules/consola/dist/basic.cjs +0 -32
- package/node_modules/consola/dist/basic.d.cts +0 -23
- package/node_modules/consola/dist/basic.d.mts +0 -21
- package/node_modules/consola/dist/basic.d.ts +0 -23
- package/node_modules/consola/dist/basic.mjs +0 -24
- package/node_modules/consola/dist/browser.cjs +0 -84
- package/node_modules/consola/dist/browser.d.cts +0 -23
- package/node_modules/consola/dist/browser.d.mts +0 -21
- package/node_modules/consola/dist/browser.d.ts +0 -23
- package/node_modules/consola/dist/browser.mjs +0 -76
- package/node_modules/consola/dist/chunks/prompt.cjs +0 -288
- package/node_modules/consola/dist/chunks/prompt.mjs +0 -280
- package/node_modules/consola/dist/core.cjs +0 -517
- package/node_modules/consola/dist/core.d.cts +0 -459
- package/node_modules/consola/dist/core.d.mts +0 -459
- package/node_modules/consola/dist/core.d.ts +0 -459
- package/node_modules/consola/dist/core.mjs +0 -512
- package/node_modules/consola/dist/index.cjs +0 -663
- package/node_modules/consola/dist/index.d.cts +0 -24
- package/node_modules/consola/dist/index.d.mts +0 -22
- package/node_modules/consola/dist/index.d.ts +0 -24
- package/node_modules/consola/dist/index.mjs +0 -651
- package/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +0 -75
- package/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +0 -72
- package/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +0 -288
- package/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +0 -312
- package/node_modules/consola/dist/utils.cjs +0 -64
- package/node_modules/consola/dist/utils.d.cts +0 -286
- package/node_modules/consola/dist/utils.d.mts +0 -286
- package/node_modules/consola/dist/utils.d.ts +0 -286
- package/node_modules/consola/dist/utils.mjs +0 -54
- package/node_modules/consola/lib/index.cjs +0 -10
- package/node_modules/consola/package.json +0 -136
- package/node_modules/consola/utils.d.ts +0 -1
- package/node_modules/create-maizzle/README.md +0 -86
- package/node_modules/create-maizzle/bin/create-maizzle.mjs +0 -4
- package/node_modules/create-maizzle/node_modules/@clack/core/CHANGELOG.md +0 -340
- package/node_modules/create-maizzle/node_modules/@clack/core/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/core/README.md +0 -22
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.d.mts +0 -349
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs +0 -11
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/core/package.json +0 -60
- package/node_modules/create-maizzle/node_modules/@clack/prompts/CHANGELOG.md +0 -576
- package/node_modules/create-maizzle/node_modules/@clack/prompts/LICENSE +0 -9
- package/node_modules/create-maizzle/node_modules/@clack/prompts/README.md +0 -270
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.d.mts +0 -391
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs +0 -137
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
- package/node_modules/create-maizzle/node_modules/@clack/prompts/package.json +0 -65
- package/node_modules/create-maizzle/package.json +0 -47
- package/node_modules/create-maizzle/src/index.js +0 -242
- package/node_modules/defu/LICENSE +0 -21
- package/node_modules/defu/README.md +0 -171
- package/node_modules/defu/dist/defu.cjs +0 -77
- package/node_modules/defu/dist/defu.d.cts +0 -31
- package/node_modules/defu/dist/defu.d.mts +0 -29
- package/node_modules/defu/dist/defu.d.ts +0 -31
- package/node_modules/defu/dist/defu.mjs +0 -69
- package/node_modules/defu/lib/defu.cjs +0 -10
- package/node_modules/defu/lib/defu.d.cts +0 -12
- package/node_modules/defu/package.json +0 -48
- package/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -468
- package/node_modules/node-fetch-native/LICENSE +0 -114
- package/node_modules/node-fetch-native/README.md +0 -225
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -2
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -2
- package/node_modules/node-fetch-native/dist/index.cjs +0 -1
- package/node_modules/node-fetch-native/dist/index.mjs +0 -1
- package/node_modules/node-fetch-native/dist/native.cjs +0 -1
- package/node_modules/node-fetch-native/dist/native.mjs +0 -1
- package/node_modules/node-fetch-native/dist/node.cjs +0 -19
- package/node_modules/node-fetch-native/dist/node.mjs +0 -19
- package/node_modules/node-fetch-native/dist/polyfill.cjs +0 -1
- package/node_modules/node-fetch-native/dist/polyfill.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.cjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy-stub.mjs +0 -1
- package/node_modules/node-fetch-native/dist/proxy.cjs +0 -58
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +0 -1
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -1
- package/node_modules/node-fetch-native/index.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/empty.cjs +0 -0
- package/node_modules/node-fetch-native/lib/empty.mjs +0 -0
- package/node_modules/node-fetch-native/lib/index.cjs +0 -11
- package/node_modules/node-fetch-native/lib/index.d.cts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.mts +0 -10
- package/node_modules/node-fetch-native/lib/index.d.ts +0 -10
- package/node_modules/node-fetch-native/lib/native.cjs +0 -11
- package/node_modules/node-fetch-native/lib/polyfill.d.cts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.mts +0 -1
- package/node_modules/node-fetch-native/lib/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/lib/proxy.d.ts +0 -32
- package/node_modules/node-fetch-native/node.d.ts +0 -1
- package/node_modules/node-fetch-native/package.json +0 -138
- package/node_modules/node-fetch-native/polyfill.d.ts +0 -1
- package/node_modules/node-fetch-native/proxy.d.ts +0 -1
- package/node_modules/nypm/node_modules/citty/LICENSE +0 -21
- package/node_modules/nypm/node_modules/citty/README.md +0 -231
- package/node_modules/nypm/node_modules/citty/dist/index.d.mts +0 -112
- package/node_modules/nypm/node_modules/citty/dist/index.mjs +0 -425
- package/node_modules/nypm/node_modules/citty/package.json +0 -42
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/THIRD-PARTY-LICENSES.md +0 -0
- /package/node_modules/{nypm/node_modules/citty → citty}/dist/_chunks/libs/scule.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/LICENSE +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/component.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/config.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/layout.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/scaffold.mjs +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/component.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/config.ts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/layout.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/stubs/template.vue +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.d.mts +0 -0
- /package/node_modules/{@maizzle/cli → maizzle}/dist/commands/make/template.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/LICENSE +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/esm.mjs +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/index.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/error.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/lib/suggestSimilar.js +0 -0
- /package/node_modules/{commander → maizzle/node_modules/commander}/typings/esm.d.mts +0 -0
|
@@ -80,6 +80,12 @@ class Command extends EventEmitter {
|
|
|
80
80
|
/** @type {Command} */
|
|
81
81
|
this._helpCommand = undefined; // lazy initialised, inherited
|
|
82
82
|
this._helpConfiguration = {};
|
|
83
|
+
/** @type {string | undefined} */
|
|
84
|
+
this._helpGroupHeading = undefined; // soft initialised when added to parent
|
|
85
|
+
/** @type {string | undefined} */
|
|
86
|
+
this._defaultCommandGroup = undefined;
|
|
87
|
+
/** @type {string | undefined} */
|
|
88
|
+
this._defaultOptionGroup = undefined;
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
/**
|
|
@@ -239,7 +245,10 @@ class Command extends EventEmitter {
|
|
|
239
245
|
configureOutput(configuration) {
|
|
240
246
|
if (configuration === undefined) return this._outputConfiguration;
|
|
241
247
|
|
|
242
|
-
|
|
248
|
+
this._outputConfiguration = {
|
|
249
|
+
...this._outputConfiguration,
|
|
250
|
+
...configuration,
|
|
251
|
+
};
|
|
243
252
|
return this;
|
|
244
253
|
}
|
|
245
254
|
|
|
@@ -320,16 +329,16 @@ class Command extends EventEmitter {
|
|
|
320
329
|
*
|
|
321
330
|
* @param {string} name
|
|
322
331
|
* @param {string} [description]
|
|
323
|
-
* @param {(Function|*)} [
|
|
332
|
+
* @param {(Function|*)} [parseArg] - custom argument processing function or default value
|
|
324
333
|
* @param {*} [defaultValue]
|
|
325
334
|
* @return {Command} `this` command for chaining
|
|
326
335
|
*/
|
|
327
|
-
argument(name, description,
|
|
336
|
+
argument(name, description, parseArg, defaultValue) {
|
|
328
337
|
const argument = this.createArgument(name, description);
|
|
329
|
-
if (typeof
|
|
330
|
-
argument.default(defaultValue).argParser(
|
|
338
|
+
if (typeof parseArg === 'function') {
|
|
339
|
+
argument.default(defaultValue).argParser(parseArg);
|
|
331
340
|
} else {
|
|
332
|
-
argument.default(
|
|
341
|
+
argument.default(parseArg);
|
|
333
342
|
}
|
|
334
343
|
this.addArgument(argument);
|
|
335
344
|
return this;
|
|
@@ -365,7 +374,7 @@ class Command extends EventEmitter {
|
|
|
365
374
|
*/
|
|
366
375
|
addArgument(argument) {
|
|
367
376
|
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
368
|
-
if (previousArgument
|
|
377
|
+
if (previousArgument?.variadic) {
|
|
369
378
|
throw new Error(
|
|
370
379
|
`only the last argument can be variadic '${previousArgument.name()}'`,
|
|
371
380
|
);
|
|
@@ -400,11 +409,15 @@ class Command extends EventEmitter {
|
|
|
400
409
|
helpCommand(enableOrNameAndArgs, description) {
|
|
401
410
|
if (typeof enableOrNameAndArgs === 'boolean') {
|
|
402
411
|
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
412
|
+
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
413
|
+
// make the command to store the group
|
|
414
|
+
this._initCommandGroup(this._getHelpCommand());
|
|
415
|
+
}
|
|
403
416
|
return this;
|
|
404
417
|
}
|
|
405
418
|
|
|
406
|
-
|
|
407
|
-
const [, helpName, helpArgs] =
|
|
419
|
+
const nameAndArgs = enableOrNameAndArgs ?? 'help [command]';
|
|
420
|
+
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
408
421
|
const helpDescription = description ?? 'display help for command';
|
|
409
422
|
|
|
410
423
|
const helpCommand = this.createCommand(helpName);
|
|
@@ -414,6 +427,8 @@ class Command extends EventEmitter {
|
|
|
414
427
|
|
|
415
428
|
this._addImplicitHelpCommand = true;
|
|
416
429
|
this._helpCommand = helpCommand;
|
|
430
|
+
// init group unless lazy create
|
|
431
|
+
if (enableOrNameAndArgs || description) this._initCommandGroup(helpCommand);
|
|
417
432
|
|
|
418
433
|
return this;
|
|
419
434
|
}
|
|
@@ -435,6 +450,7 @@ class Command extends EventEmitter {
|
|
|
435
450
|
|
|
436
451
|
this._addImplicitHelpCommand = true;
|
|
437
452
|
this._helpCommand = helpCommand;
|
|
453
|
+
this._initCommandGroup(helpCommand);
|
|
438
454
|
return this;
|
|
439
455
|
}
|
|
440
456
|
|
|
@@ -613,6 +629,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
613
629
|
- already used by option '${matchingOption.flags}'`);
|
|
614
630
|
}
|
|
615
631
|
|
|
632
|
+
this._initOptionGroup(option);
|
|
616
633
|
this.options.push(option);
|
|
617
634
|
}
|
|
618
635
|
|
|
@@ -640,6 +657,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
640
657
|
);
|
|
641
658
|
}
|
|
642
659
|
|
|
660
|
+
this._initCommandGroup(command);
|
|
643
661
|
this.commands.push(command);
|
|
644
662
|
}
|
|
645
663
|
|
|
@@ -683,7 +701,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
683
701
|
if (val !== null && option.parseArg) {
|
|
684
702
|
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
685
703
|
} else if (val !== null && option.variadic) {
|
|
686
|
-
val = option.
|
|
704
|
+
val = option._collectValue(val, oldValue);
|
|
687
705
|
}
|
|
688
706
|
|
|
689
707
|
// Fill-in appropriate missing values. Long winded but easy to follow.
|
|
@@ -1462,7 +1480,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1462
1480
|
|
|
1463
1481
|
_chainOrCall(promise, fn) {
|
|
1464
1482
|
// thenable
|
|
1465
|
-
if (promise
|
|
1483
|
+
if (promise?.then && typeof promise.then === 'function') {
|
|
1466
1484
|
// already have a promise, chain callback
|
|
1467
1485
|
return promise.then(() => fn());
|
|
1468
1486
|
}
|
|
@@ -1593,7 +1611,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1593
1611
|
promiseChain = this._chainOrCallHooks(promiseChain, 'postAction');
|
|
1594
1612
|
return promiseChain;
|
|
1595
1613
|
}
|
|
1596
|
-
if (this.parent
|
|
1614
|
+
if (this.parent?.listenerCount(commandEvent)) {
|
|
1597
1615
|
checkForUnknownOptions();
|
|
1598
1616
|
this._processArguments();
|
|
1599
1617
|
this.parent.emit(commandEvent, operands, unknown); // legacy
|
|
@@ -1723,33 +1741,49 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1723
1741
|
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
|
1724
1742
|
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
|
1725
1743
|
*
|
|
1726
|
-
* @param {string[]}
|
|
1744
|
+
* @param {string[]} args
|
|
1727
1745
|
* @return {{operands: string[], unknown: string[]}}
|
|
1728
1746
|
*/
|
|
1729
1747
|
|
|
1730
|
-
parseOptions(
|
|
1748
|
+
parseOptions(args) {
|
|
1731
1749
|
const operands = []; // operands, not options or values
|
|
1732
1750
|
const unknown = []; // first unknown option and remaining unknown args
|
|
1733
1751
|
let dest = operands;
|
|
1734
|
-
const args = argv.slice();
|
|
1735
1752
|
|
|
1736
1753
|
function maybeOption(arg) {
|
|
1737
1754
|
return arg.length > 1 && arg[0] === '-';
|
|
1738
1755
|
}
|
|
1739
1756
|
|
|
1757
|
+
const negativeNumberArg = (arg) => {
|
|
1758
|
+
// return false if not a negative number
|
|
1759
|
+
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
|
|
1760
|
+
// negative number is ok unless digit used as an option in command hierarchy
|
|
1761
|
+
return !this._getCommandAndAncestors().some((cmd) =>
|
|
1762
|
+
cmd.options
|
|
1763
|
+
.map((opt) => opt.short)
|
|
1764
|
+
.some((short) => /^-\d$/.test(short)),
|
|
1765
|
+
);
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1740
1768
|
// parse options
|
|
1741
1769
|
let activeVariadicOption = null;
|
|
1742
|
-
|
|
1743
|
-
|
|
1770
|
+
let activeGroup = null; // working through group of short options, like -abc
|
|
1771
|
+
let i = 0;
|
|
1772
|
+
while (i < args.length || activeGroup) {
|
|
1773
|
+
const arg = activeGroup ?? args[i++];
|
|
1774
|
+
activeGroup = null;
|
|
1744
1775
|
|
|
1745
1776
|
// literal
|
|
1746
1777
|
if (arg === '--') {
|
|
1747
1778
|
if (dest === unknown) dest.push(arg);
|
|
1748
|
-
dest.push(...args);
|
|
1779
|
+
dest.push(...args.slice(i));
|
|
1749
1780
|
break;
|
|
1750
1781
|
}
|
|
1751
1782
|
|
|
1752
|
-
if (
|
|
1783
|
+
if (
|
|
1784
|
+
activeVariadicOption &&
|
|
1785
|
+
(!maybeOption(arg) || negativeNumberArg(arg))
|
|
1786
|
+
) {
|
|
1753
1787
|
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
1754
1788
|
continue;
|
|
1755
1789
|
}
|
|
@@ -1760,14 +1794,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1760
1794
|
// recognised option, call listener to assign value with possible custom processing
|
|
1761
1795
|
if (option) {
|
|
1762
1796
|
if (option.required) {
|
|
1763
|
-
const value = args
|
|
1797
|
+
const value = args[i++];
|
|
1764
1798
|
if (value === undefined) this.optionMissingArgument(option);
|
|
1765
1799
|
this.emit(`option:${option.name()}`, value);
|
|
1766
1800
|
} else if (option.optional) {
|
|
1767
1801
|
let value = null;
|
|
1768
1802
|
// historical behaviour is optional value is following arg unless an option
|
|
1769
|
-
if (
|
|
1770
|
-
|
|
1803
|
+
if (
|
|
1804
|
+
i < args.length &&
|
|
1805
|
+
(!maybeOption(args[i]) || negativeNumberArg(args[i]))
|
|
1806
|
+
) {
|
|
1807
|
+
value = args[i++];
|
|
1771
1808
|
}
|
|
1772
1809
|
this.emit(`option:${option.name()}`, value);
|
|
1773
1810
|
} else {
|
|
@@ -1790,9 +1827,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1790
1827
|
// option with value following in same argument
|
|
1791
1828
|
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
1792
1829
|
} else {
|
|
1793
|
-
// boolean option
|
|
1830
|
+
// boolean option
|
|
1794
1831
|
this.emit(`option:${option.name()}`);
|
|
1795
|
-
|
|
1832
|
+
// remove the processed option and keep processing group
|
|
1833
|
+
activeGroup = `-${arg.slice(2)}`;
|
|
1796
1834
|
}
|
|
1797
1835
|
continue;
|
|
1798
1836
|
}
|
|
@@ -1812,7 +1850,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1812
1850
|
// Might be a command-argument, or subcommand option, or unknown option, or help command or option.
|
|
1813
1851
|
|
|
1814
1852
|
// An unknown option means further arguments also classified as unknown so can be reprocessed by subcommands.
|
|
1815
|
-
|
|
1853
|
+
// A negative number in a leaf command is not an unknown option.
|
|
1854
|
+
if (
|
|
1855
|
+
dest === operands &&
|
|
1856
|
+
maybeOption(arg) &&
|
|
1857
|
+
!(this.commands.length === 0 && negativeNumberArg(arg))
|
|
1858
|
+
) {
|
|
1816
1859
|
dest = unknown;
|
|
1817
1860
|
}
|
|
1818
1861
|
|
|
@@ -1824,26 +1867,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1824
1867
|
) {
|
|
1825
1868
|
if (this._findCommand(arg)) {
|
|
1826
1869
|
operands.push(arg);
|
|
1827
|
-
|
|
1870
|
+
unknown.push(...args.slice(i));
|
|
1828
1871
|
break;
|
|
1829
1872
|
} else if (
|
|
1830
1873
|
this._getHelpCommand() &&
|
|
1831
1874
|
arg === this._getHelpCommand().name()
|
|
1832
1875
|
) {
|
|
1833
|
-
operands.push(arg);
|
|
1834
|
-
if (args.length > 0) operands.push(...args);
|
|
1876
|
+
operands.push(arg, ...args.slice(i));
|
|
1835
1877
|
break;
|
|
1836
1878
|
} else if (this._defaultCommandName) {
|
|
1837
|
-
unknown.push(arg);
|
|
1838
|
-
if (args.length > 0) unknown.push(...args);
|
|
1879
|
+
unknown.push(arg, ...args.slice(i));
|
|
1839
1880
|
break;
|
|
1840
1881
|
}
|
|
1841
1882
|
}
|
|
1842
1883
|
|
|
1843
1884
|
// If using passThroughOptions, stop processing options at first command-argument.
|
|
1844
1885
|
if (this._passThroughOptions) {
|
|
1845
|
-
dest.push(arg);
|
|
1846
|
-
if (args.length > 0) dest.push(...args);
|
|
1886
|
+
dest.push(arg, ...args.slice(i));
|
|
1847
1887
|
break;
|
|
1848
1888
|
}
|
|
1849
1889
|
|
|
@@ -2294,6 +2334,75 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2294
2334
|
return this;
|
|
2295
2335
|
}
|
|
2296
2336
|
|
|
2337
|
+
/**
|
|
2338
|
+
* Set/get the help group heading for this subcommand in parent command's help.
|
|
2339
|
+
*
|
|
2340
|
+
* @param {string} [heading]
|
|
2341
|
+
* @return {Command | string}
|
|
2342
|
+
*/
|
|
2343
|
+
|
|
2344
|
+
helpGroup(heading) {
|
|
2345
|
+
if (heading === undefined) return this._helpGroupHeading ?? '';
|
|
2346
|
+
this._helpGroupHeading = heading;
|
|
2347
|
+
return this;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* Set/get the default help group heading for subcommands added to this command.
|
|
2352
|
+
* (This does not override a group set directly on the subcommand using .helpGroup().)
|
|
2353
|
+
*
|
|
2354
|
+
* @example
|
|
2355
|
+
* program.commandsGroup('Development Commands:);
|
|
2356
|
+
* program.command('watch')...
|
|
2357
|
+
* program.command('lint')...
|
|
2358
|
+
* ...
|
|
2359
|
+
*
|
|
2360
|
+
* @param {string} [heading]
|
|
2361
|
+
* @returns {Command | string}
|
|
2362
|
+
*/
|
|
2363
|
+
commandsGroup(heading) {
|
|
2364
|
+
if (heading === undefined) return this._defaultCommandGroup ?? '';
|
|
2365
|
+
this._defaultCommandGroup = heading;
|
|
2366
|
+
return this;
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
/**
|
|
2370
|
+
* Set/get the default help group heading for options added to this command.
|
|
2371
|
+
* (This does not override a group set directly on the option using .helpGroup().)
|
|
2372
|
+
*
|
|
2373
|
+
* @example
|
|
2374
|
+
* program
|
|
2375
|
+
* .optionsGroup('Development Options:')
|
|
2376
|
+
* .option('-d, --debug', 'output extra debugging')
|
|
2377
|
+
* .option('-p, --profile', 'output profiling information')
|
|
2378
|
+
*
|
|
2379
|
+
* @param {string} [heading]
|
|
2380
|
+
* @returns {Command | string}
|
|
2381
|
+
*/
|
|
2382
|
+
optionsGroup(heading) {
|
|
2383
|
+
if (heading === undefined) return this._defaultOptionGroup ?? '';
|
|
2384
|
+
this._defaultOptionGroup = heading;
|
|
2385
|
+
return this;
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
/**
|
|
2389
|
+
* @param {Option} option
|
|
2390
|
+
* @private
|
|
2391
|
+
*/
|
|
2392
|
+
_initOptionGroup(option) {
|
|
2393
|
+
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
2394
|
+
option.helpGroup(this._defaultOptionGroup);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
/**
|
|
2398
|
+
* @param {Command} cmd
|
|
2399
|
+
* @private
|
|
2400
|
+
*/
|
|
2401
|
+
_initCommandGroup(cmd) {
|
|
2402
|
+
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
2403
|
+
cmd.helpGroup(this._defaultCommandGroup);
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2297
2406
|
/**
|
|
2298
2407
|
* Set the name of the command from script filename, such as process.argv[1],
|
|
2299
2408
|
* or require.main.filename, or __filename.
|
|
@@ -2448,12 +2557,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2448
2557
|
*/
|
|
2449
2558
|
|
|
2450
2559
|
helpOption(flags, description) {
|
|
2451
|
-
// Support disabling built-in help option.
|
|
2560
|
+
// Support enabling/disabling built-in help option.
|
|
2452
2561
|
if (typeof flags === 'boolean') {
|
|
2453
|
-
// true is not an expected value. Do something sensible but no unit-test.
|
|
2454
|
-
// istanbul ignore if
|
|
2455
2562
|
if (flags) {
|
|
2456
|
-
this._helpOption
|
|
2563
|
+
if (this._helpOption === null) this._helpOption = undefined; // reenable
|
|
2564
|
+
if (this._defaultOptionGroup) {
|
|
2565
|
+
// make the option to store the group
|
|
2566
|
+
this._initOptionGroup(this._getHelpOption());
|
|
2567
|
+
}
|
|
2457
2568
|
} else {
|
|
2458
2569
|
this._helpOption = null; // disable
|
|
2459
2570
|
}
|
|
@@ -2461,9 +2572,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2461
2572
|
}
|
|
2462
2573
|
|
|
2463
2574
|
// Customise flags and description.
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2575
|
+
this._helpOption = this.createOption(
|
|
2576
|
+
flags ?? '-h, --help',
|
|
2577
|
+
description ?? 'display help for command',
|
|
2578
|
+
);
|
|
2579
|
+
// init group unless lazy create
|
|
2580
|
+
if (flags || description) this._initOptionGroup(this._helpOption);
|
|
2467
2581
|
|
|
2468
2582
|
return this;
|
|
2469
2583
|
}
|
|
@@ -2492,6 +2606,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2492
2606
|
*/
|
|
2493
2607
|
addHelpOption(option) {
|
|
2494
2608
|
this._helpOption = option;
|
|
2609
|
+
this._initOptionGroup(option);
|
|
2495
2610
|
return this;
|
|
2496
2611
|
}
|
|
2497
2612
|
|
|
@@ -352,7 +352,11 @@ class Help {
|
|
|
352
352
|
extraInfo.push(`env: ${option.envVar}`);
|
|
353
353
|
}
|
|
354
354
|
if (extraInfo.length > 0) {
|
|
355
|
-
|
|
355
|
+
const extraDescription = `(${extraInfo.join(', ')})`;
|
|
356
|
+
if (option.description) {
|
|
357
|
+
return `${option.description} ${extraDescription}`;
|
|
358
|
+
}
|
|
359
|
+
return extraDescription;
|
|
356
360
|
}
|
|
357
361
|
|
|
358
362
|
return option.description;
|
|
@@ -388,6 +392,46 @@ class Help {
|
|
|
388
392
|
return argument.description;
|
|
389
393
|
}
|
|
390
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Format a list of items, given a heading and an array of formatted items.
|
|
397
|
+
*
|
|
398
|
+
* @param {string} heading
|
|
399
|
+
* @param {string[]} items
|
|
400
|
+
* @param {Help} helper
|
|
401
|
+
* @returns string[]
|
|
402
|
+
*/
|
|
403
|
+
formatItemList(heading, items, helper) {
|
|
404
|
+
if (items.length === 0) return [];
|
|
405
|
+
|
|
406
|
+
return [helper.styleTitle(heading), ...items, ''];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Group items by their help group heading.
|
|
411
|
+
*
|
|
412
|
+
* @param {Command[] | Option[]} unsortedItems
|
|
413
|
+
* @param {Command[] | Option[]} visibleItems
|
|
414
|
+
* @param {Function} getGroup
|
|
415
|
+
* @returns {Map<string, Command[] | Option[]>}
|
|
416
|
+
*/
|
|
417
|
+
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
418
|
+
const result = new Map();
|
|
419
|
+
// Add groups in order of appearance in unsortedItems.
|
|
420
|
+
unsortedItems.forEach((item) => {
|
|
421
|
+
const group = getGroup(item);
|
|
422
|
+
if (!result.has(group)) result.set(group, []);
|
|
423
|
+
});
|
|
424
|
+
// Add items in order of appearance in visibleItems.
|
|
425
|
+
visibleItems.forEach((item) => {
|
|
426
|
+
const group = getGroup(item);
|
|
427
|
+
if (!result.has(group)) {
|
|
428
|
+
result.set(group, []);
|
|
429
|
+
}
|
|
430
|
+
result.get(group).push(item);
|
|
431
|
+
});
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
|
|
391
435
|
/**
|
|
392
436
|
* Generate the built-in help text.
|
|
393
437
|
*
|
|
@@ -429,28 +473,25 @@ class Help {
|
|
|
429
473
|
helper.styleArgumentDescription(helper.argumentDescription(argument)),
|
|
430
474
|
);
|
|
431
475
|
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
...argumentList,
|
|
436
|
-
'',
|
|
437
|
-
]);
|
|
438
|
-
}
|
|
476
|
+
output = output.concat(
|
|
477
|
+
this.formatItemList('Arguments:', argumentList, helper),
|
|
478
|
+
);
|
|
439
479
|
|
|
440
480
|
// Options
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
481
|
+
const optionGroups = this.groupItems(
|
|
482
|
+
cmd.options,
|
|
483
|
+
helper.visibleOptions(cmd),
|
|
484
|
+
(option) => option.helpGroupHeading ?? 'Options:',
|
|
485
|
+
);
|
|
486
|
+
optionGroups.forEach((options, group) => {
|
|
487
|
+
const optionList = options.map((option) => {
|
|
488
|
+
return callFormatItem(
|
|
489
|
+
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
490
|
+
helper.styleOptionDescription(helper.optionDescription(option)),
|
|
491
|
+
);
|
|
492
|
+
});
|
|
493
|
+
output = output.concat(this.formatItemList(group, optionList, helper));
|
|
446
494
|
});
|
|
447
|
-
if (optionList.length > 0) {
|
|
448
|
-
output = output.concat([
|
|
449
|
-
helper.styleTitle('Options:'),
|
|
450
|
-
...optionList,
|
|
451
|
-
'',
|
|
452
|
-
]);
|
|
453
|
-
}
|
|
454
495
|
|
|
455
496
|
if (helper.showGlobalOptions) {
|
|
456
497
|
const globalOptionList = helper
|
|
@@ -461,29 +502,26 @@ class Help {
|
|
|
461
502
|
helper.styleOptionDescription(helper.optionDescription(option)),
|
|
462
503
|
);
|
|
463
504
|
});
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
...globalOptionList,
|
|
468
|
-
'',
|
|
469
|
-
]);
|
|
470
|
-
}
|
|
505
|
+
output = output.concat(
|
|
506
|
+
this.formatItemList('Global Options:', globalOptionList, helper),
|
|
507
|
+
);
|
|
471
508
|
}
|
|
472
509
|
|
|
473
510
|
// Commands
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
511
|
+
const commandGroups = this.groupItems(
|
|
512
|
+
cmd.commands,
|
|
513
|
+
helper.visibleCommands(cmd),
|
|
514
|
+
(sub) => sub.helpGroup() || 'Commands:',
|
|
515
|
+
);
|
|
516
|
+
commandGroups.forEach((commands, group) => {
|
|
517
|
+
const commandList = commands.map((sub) => {
|
|
518
|
+
return callFormatItem(
|
|
519
|
+
helper.styleSubcommandTerm(helper.subcommandTerm(sub)),
|
|
520
|
+
helper.styleSubcommandDescription(helper.subcommandDescription(sub)),
|
|
521
|
+
);
|
|
522
|
+
});
|
|
523
|
+
output = output.concat(this.formatItemList(group, commandList, helper));
|
|
479
524
|
});
|
|
480
|
-
if (commandList.length > 0) {
|
|
481
|
-
output = output.concat([
|
|
482
|
-
helper.styleTitle('Commands:'),
|
|
483
|
-
...commandList,
|
|
484
|
-
'',
|
|
485
|
-
]);
|
|
486
|
-
}
|
|
487
525
|
|
|
488
526
|
return output.join('\n');
|
|
489
527
|
}
|
|
@@ -33,6 +33,7 @@ class Option {
|
|
|
33
33
|
this.argChoices = undefined;
|
|
34
34
|
this.conflictsWith = [];
|
|
35
35
|
this.implied = undefined;
|
|
36
|
+
this.helpGroupHeading = undefined; // soft initialised when option added to command
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -161,12 +162,13 @@ class Option {
|
|
|
161
162
|
* @package
|
|
162
163
|
*/
|
|
163
164
|
|
|
164
|
-
|
|
165
|
+
_collectValue(value, previous) {
|
|
165
166
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
166
167
|
return [value];
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
|
|
170
|
+
previous.push(value);
|
|
171
|
+
return previous;
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
/**
|
|
@@ -185,7 +187,7 @@ class Option {
|
|
|
185
187
|
);
|
|
186
188
|
}
|
|
187
189
|
if (this.variadic) {
|
|
188
|
-
return this.
|
|
190
|
+
return this._collectValue(arg, previous);
|
|
189
191
|
}
|
|
190
192
|
return arg;
|
|
191
193
|
};
|
|
@@ -219,6 +221,17 @@ class Option {
|
|
|
219
221
|
return camelcase(this.name());
|
|
220
222
|
}
|
|
221
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Set the help group heading.
|
|
226
|
+
*
|
|
227
|
+
* @param {string} heading
|
|
228
|
+
* @return {Option}
|
|
229
|
+
*/
|
|
230
|
+
helpGroup(heading) {
|
|
231
|
+
this.helpGroupHeading = heading;
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
|
|
222
235
|
/**
|
|
223
236
|
* Check if `arg` matches the short or long flag.
|
|
224
237
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commander",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.3",
|
|
4
4
|
"description": "the complete solution for node.js command-line programs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"commander",
|
|
@@ -61,22 +61,22 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@eslint/js": "^9.4.0",
|
|
64
|
-
"@types/jest": "^
|
|
64
|
+
"@types/jest": "^30.0.0",
|
|
65
65
|
"@types/node": "^22.7.4",
|
|
66
66
|
"eslint": "^9.17.0",
|
|
67
|
-
"eslint-config-prettier": "^
|
|
68
|
-
"eslint-plugin-jest": "^
|
|
69
|
-
"globals": "^
|
|
70
|
-
"jest": "^
|
|
67
|
+
"eslint-config-prettier": "^10.0.1",
|
|
68
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
69
|
+
"globals": "^16.0.0",
|
|
70
|
+
"jest": "^30.0.3",
|
|
71
71
|
"prettier": "^3.2.5",
|
|
72
72
|
"ts-jest": "^29.0.3",
|
|
73
|
-
"tsd": "^0.
|
|
73
|
+
"tsd": "^0.33.0",
|
|
74
74
|
"typescript": "^5.0.4",
|
|
75
75
|
"typescript-eslint": "^8.12.2"
|
|
76
76
|
},
|
|
77
77
|
"types": "typings/index.d.ts",
|
|
78
78
|
"engines": {
|
|
79
|
-
"node": ">=
|
|
79
|
+
"node": ">=20"
|
|
80
80
|
},
|
|
81
81
|
"support": true
|
|
82
82
|
}
|