@unpackjs/core 1.7.3 → 1.7.5
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/compiled/commander/index.d.ts +88 -12
- package/compiled/commander/index.js +367 -129
- package/compiled/commander/package.json +1 -1
- package/compiled/css-loader/index.js +22 -24
- package/compiled/less-loader/index.js +8 -8
- package/compiled/postcss-loader/index.js +10 -10
- package/compiled/sass-loader/index.js +9 -8
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/style-loader/index.js +10 -10
- package/dist/bundler-config/chunkSplit.cjs +0 -4
- package/dist/bundler-config/chunkSplit.d.ts.map +1 -1
- package/dist/bundler-config/chunkSplit.js +0 -4
- package/dist/bundler-config/css.cjs +1 -2
- package/dist/bundler-config/css.d.ts.map +1 -1
- package/dist/bundler-config/css.js +1 -2
- package/dist/bundler-config/experimentCss.cjs +4 -1
- package/dist/bundler-config/experimentCss.d.ts.map +1 -1
- package/dist/bundler-config/experimentCss.js +4 -1
- package/dist/bundler-config/index.cjs +2 -1
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +2 -1
- package/dist/bundler-config/jsMinify.cjs +1 -1
- package/dist/bundler-config/jsMinify.js +1 -1
- package/dist/createUnpack.cjs +2 -2
- package/dist/createUnpack.js +2 -2
- package/dist/plugin-progress/webpack.d.ts.map +1 -1
- package/dist/prebundleDeps.cjs +2 -1
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +2 -1
- package/dist/run/dev.cjs +1 -1
- package/dist/run/dev.js +1 -1
- package/dist/types/config.d.ts +1 -6
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +10 -11
- package/dist/thread-loader/WorkerError.cjs +0 -41
- package/dist/thread-loader/WorkerError.js +0 -31
- package/dist/thread-loader/WorkerPool.cjs +0 -407
- package/dist/thread-loader/WorkerPool.js +0 -387
- package/dist/thread-loader/index.cjs +0 -100
- package/dist/thread-loader/index.js +0 -85
- package/dist/thread-loader/readBuffer.cjs +0 -55
- package/dist/thread-loader/readBuffer.js +0 -45
- package/dist/thread-loader/serializer.cjs +0 -46
- package/dist/thread-loader/serializer.js +0 -31
- package/dist/thread-loader/utils.cjs +0 -84
- package/dist/thread-loader/utils.js +0 -60
- package/dist/thread-loader/worker.cjs +0 -377
- package/dist/thread-loader/worker.js +0 -382
- package/dist/thread-loader/workerPools.cjs +0 -57
- package/dist/thread-loader/workerPools.js +0 -33
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"use strict";
|
|
21
21
|
module.exports = require("node:process");
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
const { InvalidArgumentError } = __nccwpck_require__(
|
|
23
|
+
429: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
24
|
+
const { InvalidArgumentError } = __nccwpck_require__(848);
|
|
25
25
|
class Argument {
|
|
26
26
|
constructor(name, description) {
|
|
27
27
|
this.description = description || "";
|
|
@@ -98,17 +98,17 @@
|
|
|
98
98
|
exports.Argument = Argument;
|
|
99
99
|
exports.humanReadableArgName = humanReadableArgName;
|
|
100
100
|
},
|
|
101
|
-
|
|
101
|
+
745: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
102
102
|
const EventEmitter = __nccwpck_require__(673).EventEmitter;
|
|
103
103
|
const childProcess = __nccwpck_require__(718);
|
|
104
104
|
const path = __nccwpck_require__(411);
|
|
105
105
|
const fs = __nccwpck_require__(561);
|
|
106
106
|
const process = __nccwpck_require__(742);
|
|
107
|
-
const { Argument, humanReadableArgName } = __nccwpck_require__(
|
|
108
|
-
const { CommanderError } = __nccwpck_require__(
|
|
109
|
-
const { Help } = __nccwpck_require__(
|
|
110
|
-
const { Option, DualOptions } = __nccwpck_require__(
|
|
111
|
-
const { suggestSimilar } = __nccwpck_require__(
|
|
107
|
+
const { Argument, humanReadableArgName } = __nccwpck_require__(429);
|
|
108
|
+
const { CommanderError } = __nccwpck_require__(848);
|
|
109
|
+
const { Help, stripColor } = __nccwpck_require__(613);
|
|
110
|
+
const { Option, DualOptions } = __nccwpck_require__(234);
|
|
111
|
+
const { suggestSimilar } = __nccwpck_require__(824);
|
|
112
112
|
class Command extends EventEmitter {
|
|
113
113
|
constructor(name) {
|
|
114
114
|
super();
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
this.options = [];
|
|
117
117
|
this.parent = null;
|
|
118
118
|
this._allowUnknownOption = false;
|
|
119
|
-
this._allowExcessArguments =
|
|
119
|
+
this._allowExcessArguments = false;
|
|
120
120
|
this.registeredArguments = [];
|
|
121
121
|
this._args = this.registeredArguments;
|
|
122
122
|
this.args = [];
|
|
@@ -143,14 +143,22 @@
|
|
|
143
143
|
this._lifeCycleHooks = {};
|
|
144
144
|
this._showHelpAfterError = false;
|
|
145
145
|
this._showSuggestionAfterError = true;
|
|
146
|
+
this._savedState = null;
|
|
146
147
|
this._outputConfiguration = {
|
|
147
148
|
writeOut: (str) => process.stdout.write(str),
|
|
148
149
|
writeErr: (str) => process.stderr.write(str),
|
|
150
|
+
outputError: (str, write) => write(str),
|
|
149
151
|
getOutHelpWidth: () =>
|
|
150
152
|
process.stdout.isTTY ? process.stdout.columns : undefined,
|
|
151
153
|
getErrHelpWidth: () =>
|
|
152
154
|
process.stderr.isTTY ? process.stderr.columns : undefined,
|
|
153
|
-
|
|
155
|
+
getOutHasColors: () =>
|
|
156
|
+
useColor() ??
|
|
157
|
+
(process.stdout.isTTY && process.stdout.hasColors?.()),
|
|
158
|
+
getErrHasColors: () =>
|
|
159
|
+
useColor() ??
|
|
160
|
+
(process.stderr.isTTY && process.stderr.hasColors?.()),
|
|
161
|
+
stripColor: (str) => stripColor(str),
|
|
154
162
|
};
|
|
155
163
|
this._hidden = false;
|
|
156
164
|
this._helpOption = undefined;
|
|
@@ -641,15 +649,58 @@
|
|
|
641
649
|
return userArgs;
|
|
642
650
|
}
|
|
643
651
|
parse(argv, parseOptions) {
|
|
652
|
+
this._prepareForParse();
|
|
644
653
|
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
645
654
|
this._parseCommand([], userArgs);
|
|
646
655
|
return this;
|
|
647
656
|
}
|
|
648
657
|
async parseAsync(argv, parseOptions) {
|
|
658
|
+
this._prepareForParse();
|
|
649
659
|
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
650
660
|
await this._parseCommand([], userArgs);
|
|
651
661
|
return this;
|
|
652
662
|
}
|
|
663
|
+
_prepareForParse() {
|
|
664
|
+
if (this._savedState === null) {
|
|
665
|
+
this.saveStateBeforeParse();
|
|
666
|
+
} else {
|
|
667
|
+
this.restoreStateBeforeParse();
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
saveStateBeforeParse() {
|
|
671
|
+
this._savedState = {
|
|
672
|
+
_name: this._name,
|
|
673
|
+
_optionValues: { ...this._optionValues },
|
|
674
|
+
_optionValueSources: { ...this._optionValueSources },
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
restoreStateBeforeParse() {
|
|
678
|
+
if (this._storeOptionsAsProperties)
|
|
679
|
+
throw new Error(
|
|
680
|
+
`Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties`,
|
|
681
|
+
);
|
|
682
|
+
this._name = this._savedState._name;
|
|
683
|
+
this._scriptPath = null;
|
|
684
|
+
this.rawArgs = [];
|
|
685
|
+
this._optionValues = { ...this._savedState._optionValues };
|
|
686
|
+
this._optionValueSources = {
|
|
687
|
+
...this._savedState._optionValueSources,
|
|
688
|
+
};
|
|
689
|
+
this.args = [];
|
|
690
|
+
this.processedArgs = [];
|
|
691
|
+
}
|
|
692
|
+
_checkForMissingExecutable(
|
|
693
|
+
executableFile,
|
|
694
|
+
executableDir,
|
|
695
|
+
subcommandName,
|
|
696
|
+
) {
|
|
697
|
+
if (fs.existsSync(executableFile)) return;
|
|
698
|
+
const executableDirMessage = executableDir
|
|
699
|
+
? `searched for local subcommand relative to directory '${executableDir}'`
|
|
700
|
+
: "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
701
|
+
const executableMissing = `'${executableFile}' does not exist\n - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${executableDirMessage}`;
|
|
702
|
+
throw new Error(executableMissing);
|
|
703
|
+
}
|
|
653
704
|
_executeSubCommand(subcommand, args) {
|
|
654
705
|
args = args.slice();
|
|
655
706
|
let launchWithNode = false;
|
|
@@ -673,7 +724,7 @@
|
|
|
673
724
|
let resolvedScriptPath;
|
|
674
725
|
try {
|
|
675
726
|
resolvedScriptPath = fs.realpathSync(this._scriptPath);
|
|
676
|
-
} catch
|
|
727
|
+
} catch {
|
|
677
728
|
resolvedScriptPath = this._scriptPath;
|
|
678
729
|
}
|
|
679
730
|
executableDir = path.resolve(
|
|
@@ -712,6 +763,11 @@
|
|
|
712
763
|
});
|
|
713
764
|
}
|
|
714
765
|
} else {
|
|
766
|
+
this._checkForMissingExecutable(
|
|
767
|
+
executableFile,
|
|
768
|
+
executableDir,
|
|
769
|
+
subcommand._name,
|
|
770
|
+
);
|
|
715
771
|
args.unshift(executableFile);
|
|
716
772
|
args = incrementNodeInspectorPort(process.execArgv).concat(args);
|
|
717
773
|
proc = childProcess.spawn(process.execPath, args, {
|
|
@@ -751,11 +807,11 @@
|
|
|
751
807
|
});
|
|
752
808
|
proc.on("error", (err) => {
|
|
753
809
|
if (err.code === "ENOENT") {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
810
|
+
this._checkForMissingExecutable(
|
|
811
|
+
executableFile,
|
|
812
|
+
executableDir,
|
|
813
|
+
subcommand._name,
|
|
814
|
+
);
|
|
759
815
|
} else if (err.code === "EACCES") {
|
|
760
816
|
throw new Error(`'${executableFile}' not executable`);
|
|
761
817
|
}
|
|
@@ -776,6 +832,7 @@
|
|
|
776
832
|
_dispatchSubcommand(commandName, operands, unknown) {
|
|
777
833
|
const subCommand = this._findCommand(commandName);
|
|
778
834
|
if (!subCommand) this.help({ error: true });
|
|
835
|
+
subCommand._prepareForParse();
|
|
779
836
|
let promiseChain;
|
|
780
837
|
promiseChain = this._chainOrCallSubCommandHook(
|
|
781
838
|
promiseChain,
|
|
@@ -1406,26 +1463,36 @@
|
|
|
1406
1463
|
}
|
|
1407
1464
|
helpInformation(contextOptions) {
|
|
1408
1465
|
const helper = this.createHelp();
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1466
|
+
const context = this._getOutputContext(contextOptions);
|
|
1467
|
+
helper.prepareContext({
|
|
1468
|
+
error: context.error,
|
|
1469
|
+
helpWidth: context.helpWidth,
|
|
1470
|
+
outputHasColors: context.hasColors,
|
|
1471
|
+
});
|
|
1472
|
+
const text = helper.formatHelp(this, helper);
|
|
1473
|
+
if (context.hasColors) return text;
|
|
1474
|
+
return this._outputConfiguration.stripColor(text);
|
|
1416
1475
|
}
|
|
1417
|
-
|
|
1476
|
+
_getOutputContext(contextOptions) {
|
|
1418
1477
|
contextOptions = contextOptions || {};
|
|
1419
|
-
const
|
|
1420
|
-
let
|
|
1421
|
-
|
|
1422
|
-
|
|
1478
|
+
const error = !!contextOptions.error;
|
|
1479
|
+
let baseWrite;
|
|
1480
|
+
let hasColors;
|
|
1481
|
+
let helpWidth;
|
|
1482
|
+
if (error) {
|
|
1483
|
+
baseWrite = (str) => this._outputConfiguration.writeErr(str);
|
|
1484
|
+
hasColors = this._outputConfiguration.getErrHasColors();
|
|
1485
|
+
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
1423
1486
|
} else {
|
|
1424
|
-
|
|
1487
|
+
baseWrite = (str) => this._outputConfiguration.writeOut(str);
|
|
1488
|
+
hasColors = this._outputConfiguration.getOutHasColors();
|
|
1489
|
+
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
1425
1490
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1491
|
+
const write = (str) => {
|
|
1492
|
+
if (!hasColors) str = this._outputConfiguration.stripColor(str);
|
|
1493
|
+
return baseWrite(str);
|
|
1494
|
+
};
|
|
1495
|
+
return { error, write, hasColors, helpWidth };
|
|
1429
1496
|
}
|
|
1430
1497
|
outputHelp(contextOptions) {
|
|
1431
1498
|
let deprecatedCallback;
|
|
@@ -1433,12 +1500,19 @@
|
|
|
1433
1500
|
deprecatedCallback = contextOptions;
|
|
1434
1501
|
contextOptions = undefined;
|
|
1435
1502
|
}
|
|
1436
|
-
const
|
|
1503
|
+
const outputContext = this._getOutputContext(contextOptions);
|
|
1504
|
+
const eventContext = {
|
|
1505
|
+
error: outputContext.error,
|
|
1506
|
+
write: outputContext.write,
|
|
1507
|
+
command: this,
|
|
1508
|
+
};
|
|
1437
1509
|
this._getCommandAndAncestors()
|
|
1438
1510
|
.reverse()
|
|
1439
|
-
.forEach((command) => command.emit("beforeAllHelp",
|
|
1440
|
-
this.emit("beforeHelp",
|
|
1441
|
-
let helpInformation = this.helpInformation(
|
|
1511
|
+
.forEach((command) => command.emit("beforeAllHelp", eventContext));
|
|
1512
|
+
this.emit("beforeHelp", eventContext);
|
|
1513
|
+
let helpInformation = this.helpInformation({
|
|
1514
|
+
error: outputContext.error,
|
|
1515
|
+
});
|
|
1442
1516
|
if (deprecatedCallback) {
|
|
1443
1517
|
helpInformation = deprecatedCallback(helpInformation);
|
|
1444
1518
|
if (
|
|
@@ -1450,13 +1524,13 @@
|
|
|
1450
1524
|
);
|
|
1451
1525
|
}
|
|
1452
1526
|
}
|
|
1453
|
-
|
|
1527
|
+
outputContext.write(helpInformation);
|
|
1454
1528
|
if (this._getHelpOption()?.long) {
|
|
1455
1529
|
this.emit(this._getHelpOption().long);
|
|
1456
1530
|
}
|
|
1457
|
-
this.emit("afterHelp",
|
|
1531
|
+
this.emit("afterHelp", eventContext);
|
|
1458
1532
|
this._getCommandAndAncestors().forEach((command) =>
|
|
1459
|
-
command.emit("afterAllHelp",
|
|
1533
|
+
command.emit("afterAllHelp", eventContext),
|
|
1460
1534
|
);
|
|
1461
1535
|
}
|
|
1462
1536
|
helpOption(flags, description) {
|
|
@@ -1485,7 +1559,7 @@
|
|
|
1485
1559
|
}
|
|
1486
1560
|
help(contextOptions) {
|
|
1487
1561
|
this.outputHelp(contextOptions);
|
|
1488
|
-
let exitCode = process.exitCode
|
|
1562
|
+
let exitCode = Number(process.exitCode ?? 0);
|
|
1489
1563
|
if (
|
|
1490
1564
|
exitCode === 0 &&
|
|
1491
1565
|
contextOptions &&
|
|
@@ -1564,9 +1638,21 @@
|
|
|
1564
1638
|
return arg;
|
|
1565
1639
|
});
|
|
1566
1640
|
}
|
|
1641
|
+
function useColor() {
|
|
1642
|
+
if (
|
|
1643
|
+
process.env.NO_COLOR ||
|
|
1644
|
+
process.env.FORCE_COLOR === "0" ||
|
|
1645
|
+
process.env.FORCE_COLOR === "false"
|
|
1646
|
+
)
|
|
1647
|
+
return false;
|
|
1648
|
+
if (process.env.FORCE_COLOR || process.env.CLICOLOR_FORCE !== undefined)
|
|
1649
|
+
return true;
|
|
1650
|
+
return undefined;
|
|
1651
|
+
}
|
|
1567
1652
|
exports.Command = Command;
|
|
1653
|
+
exports.useColor = useColor;
|
|
1568
1654
|
},
|
|
1569
|
-
|
|
1655
|
+
848: (__unused_webpack_module, exports) => {
|
|
1570
1656
|
class CommanderError extends Error {
|
|
1571
1657
|
constructor(exitCode, code, message) {
|
|
1572
1658
|
super(message);
|
|
@@ -1587,15 +1673,19 @@
|
|
|
1587
1673
|
exports.CommanderError = CommanderError;
|
|
1588
1674
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
1589
1675
|
},
|
|
1590
|
-
|
|
1591
|
-
const { humanReadableArgName } = __nccwpck_require__(
|
|
1676
|
+
613: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1677
|
+
const { humanReadableArgName } = __nccwpck_require__(429);
|
|
1592
1678
|
class Help {
|
|
1593
1679
|
constructor() {
|
|
1594
1680
|
this.helpWidth = undefined;
|
|
1681
|
+
this.minWidthToWrap = 40;
|
|
1595
1682
|
this.sortSubcommands = false;
|
|
1596
1683
|
this.sortOptions = false;
|
|
1597
1684
|
this.showGlobalOptions = false;
|
|
1598
1685
|
}
|
|
1686
|
+
prepareContext(contextOptions) {
|
|
1687
|
+
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
1688
|
+
}
|
|
1599
1689
|
visibleCommands(cmd) {
|
|
1600
1690
|
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
|
|
1601
1691
|
const helpCommand = cmd._getHelpCommand();
|
|
@@ -1695,7 +1785,12 @@
|
|
|
1695
1785
|
.visibleCommands(cmd)
|
|
1696
1786
|
.reduce(
|
|
1697
1787
|
(max, command) =>
|
|
1698
|
-
Math.max(
|
|
1788
|
+
Math.max(
|
|
1789
|
+
max,
|
|
1790
|
+
this.displayWidth(
|
|
1791
|
+
helper.styleSubcommandTerm(helper.subcommandTerm(command)),
|
|
1792
|
+
),
|
|
1793
|
+
),
|
|
1699
1794
|
0,
|
|
1700
1795
|
);
|
|
1701
1796
|
}
|
|
@@ -1703,7 +1798,13 @@
|
|
|
1703
1798
|
return helper
|
|
1704
1799
|
.visibleOptions(cmd)
|
|
1705
1800
|
.reduce(
|
|
1706
|
-
(max, option) =>
|
|
1801
|
+
(max, option) =>
|
|
1802
|
+
Math.max(
|
|
1803
|
+
max,
|
|
1804
|
+
this.displayWidth(
|
|
1805
|
+
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
1806
|
+
),
|
|
1807
|
+
),
|
|
1707
1808
|
0,
|
|
1708
1809
|
);
|
|
1709
1810
|
}
|
|
@@ -1711,7 +1812,13 @@
|
|
|
1711
1812
|
return helper
|
|
1712
1813
|
.visibleGlobalOptions(cmd)
|
|
1713
1814
|
.reduce(
|
|
1714
|
-
(max, option) =>
|
|
1815
|
+
(max, option) =>
|
|
1816
|
+
Math.max(
|
|
1817
|
+
max,
|
|
1818
|
+
this.displayWidth(
|
|
1819
|
+
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
1820
|
+
),
|
|
1821
|
+
),
|
|
1715
1822
|
0,
|
|
1716
1823
|
);
|
|
1717
1824
|
}
|
|
@@ -1720,7 +1827,12 @@
|
|
|
1720
1827
|
.visibleArguments(cmd)
|
|
1721
1828
|
.reduce(
|
|
1722
1829
|
(max, argument) =>
|
|
1723
|
-
Math.max(
|
|
1830
|
+
Math.max(
|
|
1831
|
+
max,
|
|
1832
|
+
this.displayWidth(
|
|
1833
|
+
helper.styleArgumentTerm(helper.argumentTerm(argument)),
|
|
1834
|
+
),
|
|
1835
|
+
),
|
|
1724
1836
|
0,
|
|
1725
1837
|
);
|
|
1726
1838
|
}
|
|
@@ -1787,82 +1899,81 @@
|
|
|
1787
1899
|
);
|
|
1788
1900
|
}
|
|
1789
1901
|
if (extraInfo.length > 0) {
|
|
1790
|
-
const
|
|
1902
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
1791
1903
|
if (argument.description) {
|
|
1792
|
-
return `${argument.description} ${
|
|
1904
|
+
return `${argument.description} ${extraDescription}`;
|
|
1793
1905
|
}
|
|
1794
|
-
return
|
|
1906
|
+
return extraDescription;
|
|
1795
1907
|
}
|
|
1796
1908
|
return argument.description;
|
|
1797
1909
|
}
|
|
1798
1910
|
formatHelp(cmd, helper) {
|
|
1799
1911
|
const termWidth = helper.padWidth(cmd, helper);
|
|
1800
|
-
const helpWidth = helper.helpWidth
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
helpWidth - itemIndentWidth,
|
|
1809
|
-
termWidth + itemSeparatorWidth,
|
|
1810
|
-
);
|
|
1811
|
-
}
|
|
1812
|
-
return term;
|
|
1813
|
-
}
|
|
1814
|
-
function formatList(textArray) {
|
|
1815
|
-
return textArray
|
|
1816
|
-
.join("\n")
|
|
1817
|
-
.replace(/^/gm, " ".repeat(itemIndentWidth));
|
|
1818
|
-
}
|
|
1819
|
-
let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
|
|
1912
|
+
const helpWidth = helper.helpWidth ?? 80;
|
|
1913
|
+
function callFormatItem(term, description) {
|
|
1914
|
+
return helper.formatItem(term, termWidth, description, helper);
|
|
1915
|
+
}
|
|
1916
|
+
let output = [
|
|
1917
|
+
`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
|
|
1918
|
+
"",
|
|
1919
|
+
];
|
|
1820
1920
|
const commandDescription = helper.commandDescription(cmd);
|
|
1821
1921
|
if (commandDescription.length > 0) {
|
|
1822
1922
|
output = output.concat([
|
|
1823
|
-
helper.
|
|
1923
|
+
helper.boxWrap(
|
|
1924
|
+
helper.styleCommandDescription(commandDescription),
|
|
1925
|
+
helpWidth,
|
|
1926
|
+
),
|
|
1824
1927
|
"",
|
|
1825
1928
|
]);
|
|
1826
1929
|
}
|
|
1827
1930
|
const argumentList = helper
|
|
1828
1931
|
.visibleArguments(cmd)
|
|
1829
1932
|
.map((argument) =>
|
|
1830
|
-
|
|
1831
|
-
helper.argumentTerm(argument),
|
|
1832
|
-
helper.
|
|
1933
|
+
callFormatItem(
|
|
1934
|
+
helper.styleArgumentTerm(helper.argumentTerm(argument)),
|
|
1935
|
+
helper.styleArgumentDescription(
|
|
1936
|
+
helper.argumentDescription(argument),
|
|
1937
|
+
),
|
|
1833
1938
|
),
|
|
1834
1939
|
);
|
|
1835
1940
|
if (argumentList.length > 0) {
|
|
1836
1941
|
output = output.concat([
|
|
1837
|
-
"Arguments:",
|
|
1838
|
-
|
|
1942
|
+
helper.styleTitle("Arguments:"),
|
|
1943
|
+
...argumentList,
|
|
1839
1944
|
"",
|
|
1840
1945
|
]);
|
|
1841
1946
|
}
|
|
1842
1947
|
const optionList = helper
|
|
1843
1948
|
.visibleOptions(cmd)
|
|
1844
1949
|
.map((option) =>
|
|
1845
|
-
|
|
1846
|
-
helper.optionTerm(option),
|
|
1847
|
-
helper.optionDescription(option),
|
|
1950
|
+
callFormatItem(
|
|
1951
|
+
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
1952
|
+
helper.styleOptionDescription(helper.optionDescription(option)),
|
|
1848
1953
|
),
|
|
1849
1954
|
);
|
|
1850
1955
|
if (optionList.length > 0) {
|
|
1851
|
-
output = output.concat([
|
|
1956
|
+
output = output.concat([
|
|
1957
|
+
helper.styleTitle("Options:"),
|
|
1958
|
+
...optionList,
|
|
1959
|
+
"",
|
|
1960
|
+
]);
|
|
1852
1961
|
}
|
|
1853
|
-
if (
|
|
1962
|
+
if (helper.showGlobalOptions) {
|
|
1854
1963
|
const globalOptionList = helper
|
|
1855
1964
|
.visibleGlobalOptions(cmd)
|
|
1856
1965
|
.map((option) =>
|
|
1857
|
-
|
|
1858
|
-
helper.optionTerm(option),
|
|
1859
|
-
helper.
|
|
1966
|
+
callFormatItem(
|
|
1967
|
+
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
1968
|
+
helper.styleOptionDescription(
|
|
1969
|
+
helper.optionDescription(option),
|
|
1970
|
+
),
|
|
1860
1971
|
),
|
|
1861
1972
|
);
|
|
1862
1973
|
if (globalOptionList.length > 0) {
|
|
1863
1974
|
output = output.concat([
|
|
1864
|
-
"Global Options:",
|
|
1865
|
-
|
|
1975
|
+
helper.styleTitle("Global Options:"),
|
|
1976
|
+
...globalOptionList,
|
|
1866
1977
|
"",
|
|
1867
1978
|
]);
|
|
1868
1979
|
}
|
|
@@ -1870,16 +1981,84 @@
|
|
|
1870
1981
|
const commandList = helper
|
|
1871
1982
|
.visibleCommands(cmd)
|
|
1872
1983
|
.map((cmd) =>
|
|
1873
|
-
|
|
1874
|
-
helper.subcommandTerm(cmd),
|
|
1875
|
-
helper.
|
|
1984
|
+
callFormatItem(
|
|
1985
|
+
helper.styleSubcommandTerm(helper.subcommandTerm(cmd)),
|
|
1986
|
+
helper.styleSubcommandDescription(
|
|
1987
|
+
helper.subcommandDescription(cmd),
|
|
1988
|
+
),
|
|
1876
1989
|
),
|
|
1877
1990
|
);
|
|
1878
1991
|
if (commandList.length > 0) {
|
|
1879
|
-
output = output.concat([
|
|
1992
|
+
output = output.concat([
|
|
1993
|
+
helper.styleTitle("Commands:"),
|
|
1994
|
+
...commandList,
|
|
1995
|
+
"",
|
|
1996
|
+
]);
|
|
1880
1997
|
}
|
|
1881
1998
|
return output.join("\n");
|
|
1882
1999
|
}
|
|
2000
|
+
displayWidth(str) {
|
|
2001
|
+
return stripColor(str).length;
|
|
2002
|
+
}
|
|
2003
|
+
styleTitle(str) {
|
|
2004
|
+
return str;
|
|
2005
|
+
}
|
|
2006
|
+
styleUsage(str) {
|
|
2007
|
+
return str
|
|
2008
|
+
.split(" ")
|
|
2009
|
+
.map((word) => {
|
|
2010
|
+
if (word === "[options]") return this.styleOptionText(word);
|
|
2011
|
+
if (word === "[command]") return this.styleSubcommandText(word);
|
|
2012
|
+
if (word[0] === "[" || word[0] === "<")
|
|
2013
|
+
return this.styleArgumentText(word);
|
|
2014
|
+
return this.styleCommandText(word);
|
|
2015
|
+
})
|
|
2016
|
+
.join(" ");
|
|
2017
|
+
}
|
|
2018
|
+
styleCommandDescription(str) {
|
|
2019
|
+
return this.styleDescriptionText(str);
|
|
2020
|
+
}
|
|
2021
|
+
styleOptionDescription(str) {
|
|
2022
|
+
return this.styleDescriptionText(str);
|
|
2023
|
+
}
|
|
2024
|
+
styleSubcommandDescription(str) {
|
|
2025
|
+
return this.styleDescriptionText(str);
|
|
2026
|
+
}
|
|
2027
|
+
styleArgumentDescription(str) {
|
|
2028
|
+
return this.styleDescriptionText(str);
|
|
2029
|
+
}
|
|
2030
|
+
styleDescriptionText(str) {
|
|
2031
|
+
return str;
|
|
2032
|
+
}
|
|
2033
|
+
styleOptionTerm(str) {
|
|
2034
|
+
return this.styleOptionText(str);
|
|
2035
|
+
}
|
|
2036
|
+
styleSubcommandTerm(str) {
|
|
2037
|
+
return str
|
|
2038
|
+
.split(" ")
|
|
2039
|
+
.map((word) => {
|
|
2040
|
+
if (word === "[options]") return this.styleOptionText(word);
|
|
2041
|
+
if (word[0] === "[" || word[0] === "<")
|
|
2042
|
+
return this.styleArgumentText(word);
|
|
2043
|
+
return this.styleSubcommandText(word);
|
|
2044
|
+
})
|
|
2045
|
+
.join(" ");
|
|
2046
|
+
}
|
|
2047
|
+
styleArgumentTerm(str) {
|
|
2048
|
+
return this.styleArgumentText(str);
|
|
2049
|
+
}
|
|
2050
|
+
styleOptionText(str) {
|
|
2051
|
+
return str;
|
|
2052
|
+
}
|
|
2053
|
+
styleArgumentText(str) {
|
|
2054
|
+
return str;
|
|
2055
|
+
}
|
|
2056
|
+
styleSubcommandText(str) {
|
|
2057
|
+
return str;
|
|
2058
|
+
}
|
|
2059
|
+
styleCommandText(str) {
|
|
2060
|
+
return str;
|
|
2061
|
+
}
|
|
1883
2062
|
padWidth(cmd, helper) {
|
|
1884
2063
|
return Math.max(
|
|
1885
2064
|
helper.longestOptionTermLength(cmd, helper),
|
|
@@ -1888,37 +2067,82 @@
|
|
|
1888
2067
|
helper.longestArgumentTermLength(cmd, helper),
|
|
1889
2068
|
);
|
|
1890
2069
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
const
|
|
1899
|
-
|
|
1900
|
-
const zeroWidthSpace = "";
|
|
1901
|
-
const breaks = `\\s${zeroWidthSpace}`;
|
|
1902
|
-
const regex = new RegExp(
|
|
1903
|
-
`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
|
|
1904
|
-
"g",
|
|
2070
|
+
preformatted(str) {
|
|
2071
|
+
return /\n[^\S\r\n]/.test(str);
|
|
2072
|
+
}
|
|
2073
|
+
formatItem(term, termWidth, description, helper) {
|
|
2074
|
+
const itemIndent = 2;
|
|
2075
|
+
const itemIndentStr = " ".repeat(itemIndent);
|
|
2076
|
+
if (!description) return itemIndentStr + term;
|
|
2077
|
+
const paddedTerm = term.padEnd(
|
|
2078
|
+
termWidth + term.length - helper.displayWidth(term),
|
|
1905
2079
|
);
|
|
1906
|
-
const
|
|
2080
|
+
const spacerWidth = 2;
|
|
2081
|
+
const helpWidth = this.helpWidth ?? 80;
|
|
2082
|
+
const remainingWidth =
|
|
2083
|
+
helpWidth - termWidth - spacerWidth - itemIndent;
|
|
2084
|
+
let formattedDescription;
|
|
2085
|
+
if (
|
|
2086
|
+
remainingWidth < this.minWidthToWrap ||
|
|
2087
|
+
helper.preformatted(description)
|
|
2088
|
+
) {
|
|
2089
|
+
formattedDescription = description;
|
|
2090
|
+
} else {
|
|
2091
|
+
const wrappedDescription = helper.boxWrap(
|
|
2092
|
+
description,
|
|
2093
|
+
remainingWidth,
|
|
2094
|
+
);
|
|
2095
|
+
formattedDescription = wrappedDescription.replace(
|
|
2096
|
+
/\n/g,
|
|
2097
|
+
"\n" + " ".repeat(termWidth + spacerWidth),
|
|
2098
|
+
);
|
|
2099
|
+
}
|
|
1907
2100
|
return (
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
return (i > 0 ? indentString : "") + line.trimEnd();
|
|
1913
|
-
})
|
|
1914
|
-
.join("\n")
|
|
2101
|
+
itemIndentStr +
|
|
2102
|
+
paddedTerm +
|
|
2103
|
+
" ".repeat(spacerWidth) +
|
|
2104
|
+
formattedDescription.replace(/\n/g, `\n${itemIndentStr}`)
|
|
1915
2105
|
);
|
|
1916
2106
|
}
|
|
2107
|
+
boxWrap(str, width) {
|
|
2108
|
+
if (width < this.minWidthToWrap) return str;
|
|
2109
|
+
const rawLines = str.split(/\r\n|\n/);
|
|
2110
|
+
const chunkPattern = /[\s]*[^\s]+/g;
|
|
2111
|
+
const wrappedLines = [];
|
|
2112
|
+
rawLines.forEach((line) => {
|
|
2113
|
+
const chunks = line.match(chunkPattern);
|
|
2114
|
+
if (chunks === null) {
|
|
2115
|
+
wrappedLines.push("");
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2118
|
+
let sumChunks = [chunks.shift()];
|
|
2119
|
+
let sumWidth = this.displayWidth(sumChunks[0]);
|
|
2120
|
+
chunks.forEach((chunk) => {
|
|
2121
|
+
const visibleWidth = this.displayWidth(chunk);
|
|
2122
|
+
if (sumWidth + visibleWidth <= width) {
|
|
2123
|
+
sumChunks.push(chunk);
|
|
2124
|
+
sumWidth += visibleWidth;
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
wrappedLines.push(sumChunks.join(""));
|
|
2128
|
+
const nextChunk = chunk.trimStart();
|
|
2129
|
+
sumChunks = [nextChunk];
|
|
2130
|
+
sumWidth = this.displayWidth(nextChunk);
|
|
2131
|
+
});
|
|
2132
|
+
wrappedLines.push(sumChunks.join(""));
|
|
2133
|
+
});
|
|
2134
|
+
return wrappedLines.join("\n");
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
function stripColor(str) {
|
|
2138
|
+
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
2139
|
+
return str.replace(sgrPattern, "");
|
|
1917
2140
|
}
|
|
1918
2141
|
exports.Help = Help;
|
|
2142
|
+
exports.stripColor = stripColor;
|
|
1919
2143
|
},
|
|
1920
|
-
|
|
1921
|
-
const { InvalidArgumentError } = __nccwpck_require__(
|
|
2144
|
+
234: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2145
|
+
const { InvalidArgumentError } = __nccwpck_require__(848);
|
|
1922
2146
|
class Option {
|
|
1923
2147
|
constructor(flags, description) {
|
|
1924
2148
|
this.flags = flags;
|
|
@@ -2009,7 +2233,10 @@
|
|
|
2009
2233
|
return this.short.replace(/^-/, "");
|
|
2010
2234
|
}
|
|
2011
2235
|
attributeName() {
|
|
2012
|
-
|
|
2236
|
+
if (this.negate) {
|
|
2237
|
+
return camelcase(this.name().replace(/^no-/, ""));
|
|
2238
|
+
}
|
|
2239
|
+
return camelcase(this.name());
|
|
2013
2240
|
}
|
|
2014
2241
|
is(arg) {
|
|
2015
2242
|
return this.short === arg || this.long === arg;
|
|
@@ -2052,20 +2279,31 @@
|
|
|
2052
2279
|
function splitOptionFlags(flags) {
|
|
2053
2280
|
let shortFlag;
|
|
2054
2281
|
let longFlag;
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
if (
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2282
|
+
const shortFlagExp = /^-[^-]$/;
|
|
2283
|
+
const longFlagExp = /^--[^-]/;
|
|
2284
|
+
const flagParts = flags.split(/[ |,]+/).concat("guard");
|
|
2285
|
+
if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
|
|
2286
|
+
if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
|
|
2287
|
+
if (/^-[^-][^-]/.test(flagParts[0]))
|
|
2288
|
+
throw new Error(
|
|
2289
|
+
`invalid Option flags, short option is dash and single character: '${flags}'`,
|
|
2290
|
+
);
|
|
2291
|
+
if (shortFlag && shortFlagExp.test(flagParts[0]))
|
|
2292
|
+
throw new Error(
|
|
2293
|
+
`invalid Option flags, more than one short flag: '${flags}'`,
|
|
2294
|
+
);
|
|
2295
|
+
if (longFlag && longFlagExp.test(flagParts[0]))
|
|
2296
|
+
throw new Error(
|
|
2297
|
+
`invalid Option flags, more than one long flag: '${flags}'`,
|
|
2298
|
+
);
|
|
2299
|
+
if (!(shortFlag || longFlag) || flagParts[0].startsWith("-"))
|
|
2300
|
+
throw new Error(`invalid Option flags: '${flags}'`);
|
|
2063
2301
|
return { shortFlag, longFlag };
|
|
2064
2302
|
}
|
|
2065
2303
|
exports.Option = Option;
|
|
2066
2304
|
exports.DualOptions = DualOptions;
|
|
2067
2305
|
},
|
|
2068
|
-
|
|
2306
|
+
824: (__unused_webpack_module, exports) => {
|
|
2069
2307
|
const maxDistance = 3;
|
|
2070
2308
|
function editDistance(a, b) {
|
|
2071
2309
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -2167,11 +2405,11 @@
|
|
|
2167
2405
|
var __webpack_exports__ = {};
|
|
2168
2406
|
(() => {
|
|
2169
2407
|
var exports = __webpack_exports__;
|
|
2170
|
-
const { Argument } = __nccwpck_require__(
|
|
2171
|
-
const { Command } = __nccwpck_require__(
|
|
2172
|
-
const { CommanderError, InvalidArgumentError } = __nccwpck_require__(
|
|
2173
|
-
const { Help } = __nccwpck_require__(
|
|
2174
|
-
const { Option } = __nccwpck_require__(
|
|
2408
|
+
const { Argument } = __nccwpck_require__(429);
|
|
2409
|
+
const { Command } = __nccwpck_require__(745);
|
|
2410
|
+
const { CommanderError, InvalidArgumentError } = __nccwpck_require__(848);
|
|
2411
|
+
const { Help } = __nccwpck_require__(613);
|
|
2412
|
+
const { Option } = __nccwpck_require__(234);
|
|
2175
2413
|
exports.program = new Command();
|
|
2176
2414
|
exports.createCommand = (name) => new Command(name);
|
|
2177
2415
|
exports.createOption = (flags, description) =>
|