@formatjs/cli 6.8.7 → 6.9.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/bin/formatjs +407 -209
- package/package.json +3 -3
package/bin/formatjs
CHANGED
|
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
// node_modules/.aspect_rules_js/commander@
|
|
35
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/error.js
|
|
36
36
|
var require_error = __commonJS({
|
|
37
|
-
"node_modules/.aspect_rules_js/commander@
|
|
37
|
+
"node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/error.js"(exports) {
|
|
38
38
|
var CommanderError2 = class extends Error {
|
|
39
39
|
/**
|
|
40
40
|
* Constructs the CommanderError class
|
|
@@ -67,9 +67,9 @@ var require_error = __commonJS({
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
// node_modules/.aspect_rules_js/commander@
|
|
70
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/argument.js
|
|
71
71
|
var require_argument = __commonJS({
|
|
72
|
-
"node_modules/.aspect_rules_js/commander@
|
|
72
|
+
"node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/argument.js"(exports) {
|
|
73
73
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
74
74
|
var Argument2 = class {
|
|
75
75
|
/**
|
|
@@ -101,7 +101,7 @@ var require_argument = __commonJS({
|
|
|
101
101
|
this._name = name;
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
|
-
if (this._name.
|
|
104
|
+
if (this._name.endsWith("...")) {
|
|
105
105
|
this.variadic = true;
|
|
106
106
|
this._name = this._name.slice(0, -3);
|
|
107
107
|
}
|
|
@@ -117,11 +117,12 @@ var require_argument = __commonJS({
|
|
|
117
117
|
/**
|
|
118
118
|
* @package
|
|
119
119
|
*/
|
|
120
|
-
|
|
120
|
+
_collectValue(value, previous) {
|
|
121
121
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
122
122
|
return [value];
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
previous.push(value);
|
|
125
|
+
return previous;
|
|
125
126
|
}
|
|
126
127
|
/**
|
|
127
128
|
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
@@ -160,7 +161,7 @@ var require_argument = __commonJS({
|
|
|
160
161
|
);
|
|
161
162
|
}
|
|
162
163
|
if (this.variadic) {
|
|
163
|
-
return this.
|
|
164
|
+
return this._collectValue(arg, previous);
|
|
164
165
|
}
|
|
165
166
|
return arg;
|
|
166
167
|
};
|
|
@@ -194,9 +195,9 @@ var require_argument = __commonJS({
|
|
|
194
195
|
}
|
|
195
196
|
});
|
|
196
197
|
|
|
197
|
-
// node_modules/.aspect_rules_js/commander@
|
|
198
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/help.js
|
|
198
199
|
var require_help = __commonJS({
|
|
199
|
-
"node_modules/.aspect_rules_js/commander@
|
|
200
|
+
"node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/help.js"(exports) {
|
|
200
201
|
var { humanReadableArgName } = require_argument();
|
|
201
202
|
var Help2 = class {
|
|
202
203
|
constructor() {
|
|
@@ -474,7 +475,11 @@ var require_help = __commonJS({
|
|
|
474
475
|
extraInfo.push(`env: ${option.envVar}`);
|
|
475
476
|
}
|
|
476
477
|
if (extraInfo.length > 0) {
|
|
477
|
-
|
|
478
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
479
|
+
if (option.description) {
|
|
480
|
+
return `${option.description} ${extraDescription}`;
|
|
481
|
+
}
|
|
482
|
+
return extraDescription;
|
|
478
483
|
}
|
|
479
484
|
return option.description;
|
|
480
485
|
}
|
|
@@ -506,6 +511,43 @@ var require_help = __commonJS({
|
|
|
506
511
|
}
|
|
507
512
|
return argument.description;
|
|
508
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Format a list of items, given a heading and an array of formatted items.
|
|
516
|
+
*
|
|
517
|
+
* @param {string} heading
|
|
518
|
+
* @param {string[]} items
|
|
519
|
+
* @param {Help} helper
|
|
520
|
+
* @returns string[]
|
|
521
|
+
*/
|
|
522
|
+
formatItemList(heading, items, helper) {
|
|
523
|
+
if (items.length === 0)
|
|
524
|
+
return [];
|
|
525
|
+
return [helper.styleTitle(heading), ...items, ""];
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Group items by their help group heading.
|
|
529
|
+
*
|
|
530
|
+
* @param {Command[] | Option[]} unsortedItems
|
|
531
|
+
* @param {Command[] | Option[]} visibleItems
|
|
532
|
+
* @param {Function} getGroup
|
|
533
|
+
* @returns {Map<string, Command[] | Option[]>}
|
|
534
|
+
*/
|
|
535
|
+
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
536
|
+
const result = /* @__PURE__ */ new Map();
|
|
537
|
+
unsortedItems.forEach((item) => {
|
|
538
|
+
const group = getGroup(item);
|
|
539
|
+
if (!result.has(group))
|
|
540
|
+
result.set(group, []);
|
|
541
|
+
});
|
|
542
|
+
visibleItems.forEach((item) => {
|
|
543
|
+
const group = getGroup(item);
|
|
544
|
+
if (!result.has(group)) {
|
|
545
|
+
result.set(group, []);
|
|
546
|
+
}
|
|
547
|
+
result.get(group).push(item);
|
|
548
|
+
});
|
|
549
|
+
return result;
|
|
550
|
+
}
|
|
509
551
|
/**
|
|
510
552
|
* Generate the built-in help text.
|
|
511
553
|
*
|
|
@@ -539,26 +581,23 @@ var require_help = __commonJS({
|
|
|
539
581
|
helper.styleArgumentDescription(helper.argumentDescription(argument))
|
|
540
582
|
);
|
|
541
583
|
});
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
584
|
+
output = output.concat(
|
|
585
|
+
this.formatItemList("Arguments:", argumentList, helper)
|
|
586
|
+
);
|
|
587
|
+
const optionGroups = this.groupItems(
|
|
588
|
+
cmd.options,
|
|
589
|
+
helper.visibleOptions(cmd),
|
|
590
|
+
(option) => option.helpGroupHeading ?? "Options:"
|
|
591
|
+
);
|
|
592
|
+
optionGroups.forEach((options, group) => {
|
|
593
|
+
const optionList = options.map((option) => {
|
|
594
|
+
return callFormatItem(
|
|
595
|
+
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
596
|
+
helper.styleOptionDescription(helper.optionDescription(option))
|
|
597
|
+
);
|
|
598
|
+
});
|
|
599
|
+
output = output.concat(this.formatItemList(group, optionList, helper));
|
|
554
600
|
});
|
|
555
|
-
if (optionList.length > 0) {
|
|
556
|
-
output = output.concat([
|
|
557
|
-
helper.styleTitle("Options:"),
|
|
558
|
-
...optionList,
|
|
559
|
-
""
|
|
560
|
-
]);
|
|
561
|
-
}
|
|
562
601
|
if (helper.showGlobalOptions) {
|
|
563
602
|
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
564
603
|
return callFormatItem(
|
|
@@ -566,27 +605,24 @@ var require_help = __commonJS({
|
|
|
566
605
|
helper.styleOptionDescription(helper.optionDescription(option))
|
|
567
606
|
);
|
|
568
607
|
});
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
helper.styleTitle("Global Options:"),
|
|
572
|
-
...globalOptionList,
|
|
573
|
-
""
|
|
574
|
-
]);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
const commandList = helper.visibleCommands(cmd).map((cmd2) => {
|
|
578
|
-
return callFormatItem(
|
|
579
|
-
helper.styleSubcommandTerm(helper.subcommandTerm(cmd2)),
|
|
580
|
-
helper.styleSubcommandDescription(helper.subcommandDescription(cmd2))
|
|
608
|
+
output = output.concat(
|
|
609
|
+
this.formatItemList("Global Options:", globalOptionList, helper)
|
|
581
610
|
);
|
|
582
|
-
});
|
|
583
|
-
if (commandList.length > 0) {
|
|
584
|
-
output = output.concat([
|
|
585
|
-
helper.styleTitle("Commands:"),
|
|
586
|
-
...commandList,
|
|
587
|
-
""
|
|
588
|
-
]);
|
|
589
611
|
}
|
|
612
|
+
const commandGroups = this.groupItems(
|
|
613
|
+
cmd.commands,
|
|
614
|
+
helper.visibleCommands(cmd),
|
|
615
|
+
(sub) => sub.helpGroup() || "Commands:"
|
|
616
|
+
);
|
|
617
|
+
commandGroups.forEach((commands, group) => {
|
|
618
|
+
const commandList = commands.map((sub) => {
|
|
619
|
+
return callFormatItem(
|
|
620
|
+
helper.styleSubcommandTerm(helper.subcommandTerm(sub)),
|
|
621
|
+
helper.styleSubcommandDescription(helper.subcommandDescription(sub))
|
|
622
|
+
);
|
|
623
|
+
});
|
|
624
|
+
output = output.concat(this.formatItemList(group, commandList, helper));
|
|
625
|
+
});
|
|
590
626
|
return output.join("\n");
|
|
591
627
|
}
|
|
592
628
|
/**
|
|
@@ -769,9 +805,9 @@ ${itemIndentStr}`);
|
|
|
769
805
|
}
|
|
770
806
|
});
|
|
771
807
|
|
|
772
|
-
// node_modules/.aspect_rules_js/commander@
|
|
808
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/option.js
|
|
773
809
|
var require_option = __commonJS({
|
|
774
|
-
"node_modules/.aspect_rules_js/commander@
|
|
810
|
+
"node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/option.js"(exports) {
|
|
775
811
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
776
812
|
var Option2 = class {
|
|
777
813
|
/**
|
|
@@ -803,6 +839,7 @@ var require_option = __commonJS({
|
|
|
803
839
|
this.argChoices = void 0;
|
|
804
840
|
this.conflictsWith = [];
|
|
805
841
|
this.implied = void 0;
|
|
842
|
+
this.helpGroupHeading = void 0;
|
|
806
843
|
}
|
|
807
844
|
/**
|
|
808
845
|
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
@@ -913,11 +950,12 @@ var require_option = __commonJS({
|
|
|
913
950
|
/**
|
|
914
951
|
* @package
|
|
915
952
|
*/
|
|
916
|
-
|
|
953
|
+
_collectValue(value, previous) {
|
|
917
954
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
918
955
|
return [value];
|
|
919
956
|
}
|
|
920
|
-
|
|
957
|
+
previous.push(value);
|
|
958
|
+
return previous;
|
|
921
959
|
}
|
|
922
960
|
/**
|
|
923
961
|
* Only allow option value to be one of choices.
|
|
@@ -934,7 +972,7 @@ var require_option = __commonJS({
|
|
|
934
972
|
);
|
|
935
973
|
}
|
|
936
974
|
if (this.variadic) {
|
|
937
|
-
return this.
|
|
975
|
+
return this._collectValue(arg, previous);
|
|
938
976
|
}
|
|
939
977
|
return arg;
|
|
940
978
|
};
|
|
@@ -963,6 +1001,16 @@ var require_option = __commonJS({
|
|
|
963
1001
|
}
|
|
964
1002
|
return camelcase(this.name());
|
|
965
1003
|
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Set the help group heading.
|
|
1006
|
+
*
|
|
1007
|
+
* @param {string} heading
|
|
1008
|
+
* @return {Option}
|
|
1009
|
+
*/
|
|
1010
|
+
helpGroup(heading) {
|
|
1011
|
+
this.helpGroupHeading = heading;
|
|
1012
|
+
return this;
|
|
1013
|
+
}
|
|
966
1014
|
/**
|
|
967
1015
|
* Check if `arg` matches the short or long flag.
|
|
968
1016
|
*
|
|
@@ -1073,9 +1121,9 @@ var require_option = __commonJS({
|
|
|
1073
1121
|
}
|
|
1074
1122
|
});
|
|
1075
1123
|
|
|
1076
|
-
// node_modules/.aspect_rules_js/commander@
|
|
1124
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/suggestSimilar.js
|
|
1077
1125
|
var require_suggestSimilar = __commonJS({
|
|
1078
|
-
"node_modules/.aspect_rules_js/commander@
|
|
1126
|
+
"node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/suggestSimilar.js"(exports) {
|
|
1079
1127
|
var maxDistance = 3;
|
|
1080
1128
|
function editDistance(a, b) {
|
|
1081
1129
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -1155,9 +1203,9 @@ var require_suggestSimilar = __commonJS({
|
|
|
1155
1203
|
}
|
|
1156
1204
|
});
|
|
1157
1205
|
|
|
1158
|
-
// node_modules/.aspect_rules_js/commander@
|
|
1206
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/command.js
|
|
1159
1207
|
var require_command = __commonJS({
|
|
1160
|
-
"node_modules/.aspect_rules_js/commander@
|
|
1208
|
+
"node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/lib/command.js"(exports) {
|
|
1161
1209
|
var EventEmitter = require("node:events").EventEmitter;
|
|
1162
1210
|
var childProcess = require("node:child_process");
|
|
1163
1211
|
var path2 = require("node:path");
|
|
@@ -1229,6 +1277,9 @@ var require_command = __commonJS({
|
|
|
1229
1277
|
this._addImplicitHelpCommand = void 0;
|
|
1230
1278
|
this._helpCommand = void 0;
|
|
1231
1279
|
this._helpConfiguration = {};
|
|
1280
|
+
this._helpGroupHeading = void 0;
|
|
1281
|
+
this._defaultCommandGroup = void 0;
|
|
1282
|
+
this._defaultOptionGroup = void 0;
|
|
1232
1283
|
}
|
|
1233
1284
|
/**
|
|
1234
1285
|
* Copy settings that are useful to have in common across root command and subcommands.
|
|
@@ -1373,7 +1424,10 @@ var require_command = __commonJS({
|
|
|
1373
1424
|
configureOutput(configuration) {
|
|
1374
1425
|
if (configuration === void 0)
|
|
1375
1426
|
return this._outputConfiguration;
|
|
1376
|
-
|
|
1427
|
+
this._outputConfiguration = {
|
|
1428
|
+
...this._outputConfiguration,
|
|
1429
|
+
...configuration
|
|
1430
|
+
};
|
|
1377
1431
|
return this;
|
|
1378
1432
|
}
|
|
1379
1433
|
/**
|
|
@@ -1447,16 +1501,16 @@ var require_command = __commonJS({
|
|
|
1447
1501
|
*
|
|
1448
1502
|
* @param {string} name
|
|
1449
1503
|
* @param {string} [description]
|
|
1450
|
-
* @param {(Function|*)} [
|
|
1504
|
+
* @param {(Function|*)} [parseArg] - custom argument processing function or default value
|
|
1451
1505
|
* @param {*} [defaultValue]
|
|
1452
1506
|
* @return {Command} `this` command for chaining
|
|
1453
1507
|
*/
|
|
1454
|
-
argument(name, description,
|
|
1508
|
+
argument(name, description, parseArg, defaultValue) {
|
|
1455
1509
|
const argument = this.createArgument(name, description);
|
|
1456
|
-
if (typeof
|
|
1457
|
-
argument.default(defaultValue).argParser(
|
|
1510
|
+
if (typeof parseArg === "function") {
|
|
1511
|
+
argument.default(defaultValue).argParser(parseArg);
|
|
1458
1512
|
} else {
|
|
1459
|
-
argument.default(
|
|
1513
|
+
argument.default(parseArg);
|
|
1460
1514
|
}
|
|
1461
1515
|
this.addArgument(argument);
|
|
1462
1516
|
return this;
|
|
@@ -1486,7 +1540,7 @@ var require_command = __commonJS({
|
|
|
1486
1540
|
*/
|
|
1487
1541
|
addArgument(argument) {
|
|
1488
1542
|
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
1489
|
-
if (previousArgument
|
|
1543
|
+
if (previousArgument == null ? void 0 : previousArgument.variadic) {
|
|
1490
1544
|
throw new Error(
|
|
1491
1545
|
`only the last argument can be variadic '${previousArgument.name()}'`
|
|
1492
1546
|
);
|
|
@@ -1515,10 +1569,13 @@ var require_command = __commonJS({
|
|
|
1515
1569
|
helpCommand(enableOrNameAndArgs, description) {
|
|
1516
1570
|
if (typeof enableOrNameAndArgs === "boolean") {
|
|
1517
1571
|
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
1572
|
+
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
1573
|
+
this._initCommandGroup(this._getHelpCommand());
|
|
1574
|
+
}
|
|
1518
1575
|
return this;
|
|
1519
1576
|
}
|
|
1520
|
-
|
|
1521
|
-
const [, helpName, helpArgs] =
|
|
1577
|
+
const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
|
|
1578
|
+
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1522
1579
|
const helpDescription = description ?? "display help for command";
|
|
1523
1580
|
const helpCommand = this.createCommand(helpName);
|
|
1524
1581
|
helpCommand.helpOption(false);
|
|
@@ -1528,6 +1585,8 @@ var require_command = __commonJS({
|
|
|
1528
1585
|
helpCommand.description(helpDescription);
|
|
1529
1586
|
this._addImplicitHelpCommand = true;
|
|
1530
1587
|
this._helpCommand = helpCommand;
|
|
1588
|
+
if (enableOrNameAndArgs || description)
|
|
1589
|
+
this._initCommandGroup(helpCommand);
|
|
1531
1590
|
return this;
|
|
1532
1591
|
}
|
|
1533
1592
|
/**
|
|
@@ -1544,6 +1603,7 @@ var require_command = __commonJS({
|
|
|
1544
1603
|
}
|
|
1545
1604
|
this._addImplicitHelpCommand = true;
|
|
1546
1605
|
this._helpCommand = helpCommand;
|
|
1606
|
+
this._initCommandGroup(helpCommand);
|
|
1547
1607
|
return this;
|
|
1548
1608
|
}
|
|
1549
1609
|
/**
|
|
@@ -1692,6 +1752,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1692
1752
|
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
1693
1753
|
- already used by option '${matchingOption.flags}'`);
|
|
1694
1754
|
}
|
|
1755
|
+
this._initOptionGroup(option);
|
|
1695
1756
|
this.options.push(option);
|
|
1696
1757
|
}
|
|
1697
1758
|
/**
|
|
@@ -1715,6 +1776,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1715
1776
|
`cannot add command '${newCmd}' as already have command '${existingCmd}'`
|
|
1716
1777
|
);
|
|
1717
1778
|
}
|
|
1779
|
+
this._initCommandGroup(command);
|
|
1718
1780
|
this.commands.push(command);
|
|
1719
1781
|
}
|
|
1720
1782
|
/**
|
|
@@ -1747,7 +1809,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1747
1809
|
if (val !== null && option.parseArg) {
|
|
1748
1810
|
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
1749
1811
|
} else if (val !== null && option.variadic) {
|
|
1750
|
-
val = option.
|
|
1812
|
+
val = option._collectValue(val, oldValue);
|
|
1751
1813
|
}
|
|
1752
1814
|
if (val == null) {
|
|
1753
1815
|
if (option.negate) {
|
|
@@ -2406,7 +2468,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2406
2468
|
* @private
|
|
2407
2469
|
*/
|
|
2408
2470
|
_chainOrCall(promise, fn) {
|
|
2409
|
-
if (promise
|
|
2471
|
+
if ((promise == null ? void 0 : promise.then) && typeof promise.then === "function") {
|
|
2410
2472
|
return promise.then(() => fn());
|
|
2411
2473
|
}
|
|
2412
2474
|
return fn();
|
|
@@ -2462,6 +2524,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2462
2524
|
* @private
|
|
2463
2525
|
*/
|
|
2464
2526
|
_parseCommand(operands, unknown) {
|
|
2527
|
+
var _a;
|
|
2465
2528
|
const parsed = this.parseOptions(unknown);
|
|
2466
2529
|
this._parseOptionsEnv();
|
|
2467
2530
|
this._parseOptionsImplied();
|
|
@@ -2511,7 +2574,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2511
2574
|
promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
|
|
2512
2575
|
return promiseChain;
|
|
2513
2576
|
}
|
|
2514
|
-
if (this.parent
|
|
2577
|
+
if ((_a = this.parent) == null ? void 0 : _a.listenerCount(commandEvent)) {
|
|
2515
2578
|
checkForUnknownOptions();
|
|
2516
2579
|
this._processArguments();
|
|
2517
2580
|
this.parent.emit(commandEvent, operands, unknown);
|
|
@@ -2623,27 +2686,36 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2623
2686
|
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
|
2624
2687
|
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
|
2625
2688
|
*
|
|
2626
|
-
* @param {string[]}
|
|
2689
|
+
* @param {string[]} args
|
|
2627
2690
|
* @return {{operands: string[], unknown: string[]}}
|
|
2628
2691
|
*/
|
|
2629
|
-
parseOptions(
|
|
2692
|
+
parseOptions(args) {
|
|
2630
2693
|
const operands = [];
|
|
2631
2694
|
const unknown = [];
|
|
2632
2695
|
let dest = operands;
|
|
2633
|
-
const args = argv.slice();
|
|
2634
2696
|
function maybeOption(arg) {
|
|
2635
2697
|
return arg.length > 1 && arg[0] === "-";
|
|
2636
2698
|
}
|
|
2699
|
+
const negativeNumberArg = (arg) => {
|
|
2700
|
+
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
|
|
2701
|
+
return false;
|
|
2702
|
+
return !this._getCommandAndAncestors().some(
|
|
2703
|
+
(cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short))
|
|
2704
|
+
);
|
|
2705
|
+
};
|
|
2637
2706
|
let activeVariadicOption = null;
|
|
2638
|
-
|
|
2639
|
-
|
|
2707
|
+
let activeGroup = null;
|
|
2708
|
+
let i = 0;
|
|
2709
|
+
while (i < args.length || activeGroup) {
|
|
2710
|
+
const arg = activeGroup ?? args[i++];
|
|
2711
|
+
activeGroup = null;
|
|
2640
2712
|
if (arg === "--") {
|
|
2641
2713
|
if (dest === unknown)
|
|
2642
2714
|
dest.push(arg);
|
|
2643
|
-
dest.push(...args);
|
|
2715
|
+
dest.push(...args.slice(i));
|
|
2644
2716
|
break;
|
|
2645
2717
|
}
|
|
2646
|
-
if (activeVariadicOption && !maybeOption(arg)) {
|
|
2718
|
+
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
2647
2719
|
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
2648
2720
|
continue;
|
|
2649
2721
|
}
|
|
@@ -2652,14 +2724,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2652
2724
|
const option = this._findOption(arg);
|
|
2653
2725
|
if (option) {
|
|
2654
2726
|
if (option.required) {
|
|
2655
|
-
const value = args
|
|
2727
|
+
const value = args[i++];
|
|
2656
2728
|
if (value === void 0)
|
|
2657
2729
|
this.optionMissingArgument(option);
|
|
2658
2730
|
this.emit(`option:${option.name()}`, value);
|
|
2659
2731
|
} else if (option.optional) {
|
|
2660
2732
|
let value = null;
|
|
2661
|
-
if (args.length
|
|
2662
|
-
value = args
|
|
2733
|
+
if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
|
|
2734
|
+
value = args[i++];
|
|
2663
2735
|
}
|
|
2664
2736
|
this.emit(`option:${option.name()}`, value);
|
|
2665
2737
|
} else {
|
|
@@ -2676,7 +2748,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2676
2748
|
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
2677
2749
|
} else {
|
|
2678
2750
|
this.emit(`option:${option.name()}`);
|
|
2679
|
-
|
|
2751
|
+
activeGroup = `-${arg.slice(2)}`;
|
|
2680
2752
|
}
|
|
2681
2753
|
continue;
|
|
2682
2754
|
}
|
|
@@ -2689,31 +2761,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2689
2761
|
continue;
|
|
2690
2762
|
}
|
|
2691
2763
|
}
|
|
2692
|
-
if (maybeOption(arg)) {
|
|
2764
|
+
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
2693
2765
|
dest = unknown;
|
|
2694
2766
|
}
|
|
2695
2767
|
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
|
|
2696
2768
|
if (this._findCommand(arg)) {
|
|
2697
2769
|
operands.push(arg);
|
|
2698
|
-
|
|
2699
|
-
unknown.push(...args);
|
|
2770
|
+
unknown.push(...args.slice(i));
|
|
2700
2771
|
break;
|
|
2701
2772
|
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
2702
|
-
operands.push(arg);
|
|
2703
|
-
if (args.length > 0)
|
|
2704
|
-
operands.push(...args);
|
|
2773
|
+
operands.push(arg, ...args.slice(i));
|
|
2705
2774
|
break;
|
|
2706
2775
|
} else if (this._defaultCommandName) {
|
|
2707
|
-
unknown.push(arg);
|
|
2708
|
-
if (args.length > 0)
|
|
2709
|
-
unknown.push(...args);
|
|
2776
|
+
unknown.push(arg, ...args.slice(i));
|
|
2710
2777
|
break;
|
|
2711
2778
|
}
|
|
2712
2779
|
}
|
|
2713
2780
|
if (this._passThroughOptions) {
|
|
2714
|
-
dest.push(arg);
|
|
2715
|
-
if (args.length > 0)
|
|
2716
|
-
dest.push(...args);
|
|
2781
|
+
dest.push(arg, ...args.slice(i));
|
|
2717
2782
|
break;
|
|
2718
2783
|
}
|
|
2719
2784
|
dest.push(arg);
|
|
@@ -3075,6 +3140,72 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3075
3140
|
this._name = str;
|
|
3076
3141
|
return this;
|
|
3077
3142
|
}
|
|
3143
|
+
/**
|
|
3144
|
+
* Set/get the help group heading for this subcommand in parent command's help.
|
|
3145
|
+
*
|
|
3146
|
+
* @param {string} [heading]
|
|
3147
|
+
* @return {Command | string}
|
|
3148
|
+
*/
|
|
3149
|
+
helpGroup(heading) {
|
|
3150
|
+
if (heading === void 0)
|
|
3151
|
+
return this._helpGroupHeading ?? "";
|
|
3152
|
+
this._helpGroupHeading = heading;
|
|
3153
|
+
return this;
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* Set/get the default help group heading for subcommands added to this command.
|
|
3157
|
+
* (This does not override a group set directly on the subcommand using .helpGroup().)
|
|
3158
|
+
*
|
|
3159
|
+
* @example
|
|
3160
|
+
* program.commandsGroup('Development Commands:);
|
|
3161
|
+
* program.command('watch')...
|
|
3162
|
+
* program.command('lint')...
|
|
3163
|
+
* ...
|
|
3164
|
+
*
|
|
3165
|
+
* @param {string} [heading]
|
|
3166
|
+
* @returns {Command | string}
|
|
3167
|
+
*/
|
|
3168
|
+
commandsGroup(heading) {
|
|
3169
|
+
if (heading === void 0)
|
|
3170
|
+
return this._defaultCommandGroup ?? "";
|
|
3171
|
+
this._defaultCommandGroup = heading;
|
|
3172
|
+
return this;
|
|
3173
|
+
}
|
|
3174
|
+
/**
|
|
3175
|
+
* Set/get the default help group heading for options added to this command.
|
|
3176
|
+
* (This does not override a group set directly on the option using .helpGroup().)
|
|
3177
|
+
*
|
|
3178
|
+
* @example
|
|
3179
|
+
* program
|
|
3180
|
+
* .optionsGroup('Development Options:')
|
|
3181
|
+
* .option('-d, --debug', 'output extra debugging')
|
|
3182
|
+
* .option('-p, --profile', 'output profiling information')
|
|
3183
|
+
*
|
|
3184
|
+
* @param {string} [heading]
|
|
3185
|
+
* @returns {Command | string}
|
|
3186
|
+
*/
|
|
3187
|
+
optionsGroup(heading) {
|
|
3188
|
+
if (heading === void 0)
|
|
3189
|
+
return this._defaultOptionGroup ?? "";
|
|
3190
|
+
this._defaultOptionGroup = heading;
|
|
3191
|
+
return this;
|
|
3192
|
+
}
|
|
3193
|
+
/**
|
|
3194
|
+
* @param {Option} option
|
|
3195
|
+
* @private
|
|
3196
|
+
*/
|
|
3197
|
+
_initOptionGroup(option) {
|
|
3198
|
+
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
3199
|
+
option.helpGroup(this._defaultOptionGroup);
|
|
3200
|
+
}
|
|
3201
|
+
/**
|
|
3202
|
+
* @param {Command} cmd
|
|
3203
|
+
* @private
|
|
3204
|
+
*/
|
|
3205
|
+
_initCommandGroup(cmd) {
|
|
3206
|
+
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
3207
|
+
cmd.helpGroup(this._defaultCommandGroup);
|
|
3208
|
+
}
|
|
3078
3209
|
/**
|
|
3079
3210
|
* Set the name of the command from script filename, such as process.argv[1],
|
|
3080
3211
|
* or require.main.filename, or __filename.
|
|
@@ -3213,15 +3344,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3213
3344
|
helpOption(flags, description) {
|
|
3214
3345
|
if (typeof flags === "boolean") {
|
|
3215
3346
|
if (flags) {
|
|
3216
|
-
|
|
3347
|
+
if (this._helpOption === null)
|
|
3348
|
+
this._helpOption = void 0;
|
|
3349
|
+
if (this._defaultOptionGroup) {
|
|
3350
|
+
this._initOptionGroup(this._getHelpOption());
|
|
3351
|
+
}
|
|
3217
3352
|
} else {
|
|
3218
3353
|
this._helpOption = null;
|
|
3219
3354
|
}
|
|
3220
3355
|
return this;
|
|
3221
3356
|
}
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3357
|
+
this._helpOption = this.createOption(
|
|
3358
|
+
flags ?? "-h, --help",
|
|
3359
|
+
description ?? "display help for command"
|
|
3360
|
+
);
|
|
3361
|
+
if (flags || description)
|
|
3362
|
+
this._initOptionGroup(this._helpOption);
|
|
3225
3363
|
return this;
|
|
3226
3364
|
}
|
|
3227
3365
|
/**
|
|
@@ -3246,6 +3384,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3246
3384
|
*/
|
|
3247
3385
|
addHelpOption(option) {
|
|
3248
3386
|
this._helpOption = option;
|
|
3387
|
+
this._initOptionGroup(option);
|
|
3249
3388
|
return this;
|
|
3250
3389
|
}
|
|
3251
3390
|
/**
|
|
@@ -3358,9 +3497,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3358
3497
|
}
|
|
3359
3498
|
});
|
|
3360
3499
|
|
|
3361
|
-
// node_modules/.aspect_rules_js/commander@
|
|
3500
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/index.js
|
|
3362
3501
|
var require_commander = __commonJS({
|
|
3363
|
-
"node_modules/.aspect_rules_js/commander@
|
|
3502
|
+
"node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/index.js"(exports) {
|
|
3364
3503
|
var { Argument: Argument2 } = require_argument();
|
|
3365
3504
|
var { Command: Command2 } = require_command();
|
|
3366
3505
|
var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
@@ -12010,11 +12149,43 @@ function cloneDeep(obj) {
|
|
|
12010
12149
|
}
|
|
12011
12150
|
return obj;
|
|
12012
12151
|
}
|
|
12152
|
+
function replacePoundWithArgument(ast, variableName) {
|
|
12153
|
+
return ast.map(function(el) {
|
|
12154
|
+
if (isPoundElement(el)) {
|
|
12155
|
+
return {
|
|
12156
|
+
type: TYPE.number,
|
|
12157
|
+
value: variableName,
|
|
12158
|
+
style: null,
|
|
12159
|
+
location: el.location
|
|
12160
|
+
};
|
|
12161
|
+
}
|
|
12162
|
+
if (isPluralElement(el) || isSelectElement(el)) {
|
|
12163
|
+
var newOptions = {};
|
|
12164
|
+
for (var _i = 0, _a = Object.keys(el.options); _i < _a.length; _i++) {
|
|
12165
|
+
var key = _a[_i];
|
|
12166
|
+
newOptions[key] = {
|
|
12167
|
+
value: replacePoundWithArgument(el.options[key].value, variableName)
|
|
12168
|
+
};
|
|
12169
|
+
}
|
|
12170
|
+
return __assign(__assign({}, el), { options: newOptions });
|
|
12171
|
+
}
|
|
12172
|
+
if (isTagElement(el)) {
|
|
12173
|
+
return __assign(__assign({}, el), { children: replacePoundWithArgument(el.children, variableName) });
|
|
12174
|
+
}
|
|
12175
|
+
return el;
|
|
12176
|
+
});
|
|
12177
|
+
}
|
|
12013
12178
|
function hoistPluralOrSelectElement(ast, el, positionToInject) {
|
|
12014
12179
|
var cloned = cloneDeep(el);
|
|
12015
12180
|
var options = cloned.options;
|
|
12181
|
+
var afterElements = ast.slice(positionToInject + 1);
|
|
12182
|
+
var hasSubsequentPluralOrSelect = afterElements.some(isPluralOrSelectElement);
|
|
12016
12183
|
cloned.options = Object.keys(options).reduce(function(all, k) {
|
|
12017
|
-
var
|
|
12184
|
+
var optionValue = options[k].value;
|
|
12185
|
+
if (hasSubsequentPluralOrSelect && isPluralElement(el)) {
|
|
12186
|
+
optionValue = replacePoundWithArgument(optionValue, el.value);
|
|
12187
|
+
}
|
|
12188
|
+
var newValue = hoistSelectors(__spreadArray(__spreadArray(__spreadArray([], ast.slice(0, positionToInject), true), optionValue, true), afterElements, true));
|
|
12018
12189
|
all[k] = {
|
|
12019
12190
|
value: newValue
|
|
12020
12191
|
};
|
|
@@ -17644,6 +17815,109 @@ var init_console_utils = __esm({
|
|
|
17644
17815
|
}
|
|
17645
17816
|
});
|
|
17646
17817
|
|
|
17818
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/printer.js
|
|
17819
|
+
function printAST(ast) {
|
|
17820
|
+
return doPrintAST(ast, false);
|
|
17821
|
+
}
|
|
17822
|
+
function doPrintAST(ast, isInPlural) {
|
|
17823
|
+
var printedNodes = ast.map(function(el, i) {
|
|
17824
|
+
if (isLiteralElement(el)) {
|
|
17825
|
+
return printLiteralElement(el, isInPlural, i === 0, i === ast.length - 1);
|
|
17826
|
+
}
|
|
17827
|
+
if (isArgumentElement(el)) {
|
|
17828
|
+
return printArgumentElement(el);
|
|
17829
|
+
}
|
|
17830
|
+
if (isDateElement(el) || isTimeElement(el) || isNumberElement(el)) {
|
|
17831
|
+
return printSimpleFormatElement(el);
|
|
17832
|
+
}
|
|
17833
|
+
if (isPluralElement(el)) {
|
|
17834
|
+
return printPluralElement(el);
|
|
17835
|
+
}
|
|
17836
|
+
if (isSelectElement(el)) {
|
|
17837
|
+
return printSelectElement(el);
|
|
17838
|
+
}
|
|
17839
|
+
if (isPoundElement(el)) {
|
|
17840
|
+
return "#";
|
|
17841
|
+
}
|
|
17842
|
+
if (isTagElement(el)) {
|
|
17843
|
+
return printTagElement(el);
|
|
17844
|
+
}
|
|
17845
|
+
});
|
|
17846
|
+
return printedNodes.join("");
|
|
17847
|
+
}
|
|
17848
|
+
function printTagElement(el) {
|
|
17849
|
+
return "<".concat(el.value, ">").concat(printAST(el.children), "</").concat(el.value, ">");
|
|
17850
|
+
}
|
|
17851
|
+
function printEscapedMessage(message) {
|
|
17852
|
+
return message.replace(/([{}](?:[\s\S]*[{}])?)/, "'$1'");
|
|
17853
|
+
}
|
|
17854
|
+
function printLiteralElement(_a, isInPlural, isFirstEl, isLastEl) {
|
|
17855
|
+
var value = _a.value;
|
|
17856
|
+
var escaped = value;
|
|
17857
|
+
if (!isFirstEl && escaped[0] === "'") {
|
|
17858
|
+
escaped = "''".concat(escaped.slice(1));
|
|
17859
|
+
}
|
|
17860
|
+
if (!isLastEl && escaped[escaped.length - 1] === "'") {
|
|
17861
|
+
escaped = "".concat(escaped.slice(0, escaped.length - 1), "''");
|
|
17862
|
+
}
|
|
17863
|
+
escaped = printEscapedMessage(escaped);
|
|
17864
|
+
return isInPlural ? escaped.replace("#", "'#'") : escaped;
|
|
17865
|
+
}
|
|
17866
|
+
function printArgumentElement(_a) {
|
|
17867
|
+
var value = _a.value;
|
|
17868
|
+
return "{".concat(value, "}");
|
|
17869
|
+
}
|
|
17870
|
+
function printSimpleFormatElement(el) {
|
|
17871
|
+
return "{".concat(el.value, ", ").concat(TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : "", "}");
|
|
17872
|
+
}
|
|
17873
|
+
function printNumberSkeletonToken(token) {
|
|
17874
|
+
var stem = token.stem, options = token.options;
|
|
17875
|
+
return options.length === 0 ? stem : "".concat(stem).concat(options.map(function(o) {
|
|
17876
|
+
return "/".concat(o);
|
|
17877
|
+
}).join(""));
|
|
17878
|
+
}
|
|
17879
|
+
function printArgumentStyle(style) {
|
|
17880
|
+
if (typeof style === "string") {
|
|
17881
|
+
return printEscapedMessage(style);
|
|
17882
|
+
} else if (style.type === SKELETON_TYPE.dateTime) {
|
|
17883
|
+
return "::".concat(printDateTimeSkeleton(style));
|
|
17884
|
+
} else {
|
|
17885
|
+
return "::".concat(style.tokens.map(printNumberSkeletonToken).join(" "));
|
|
17886
|
+
}
|
|
17887
|
+
}
|
|
17888
|
+
function printDateTimeSkeleton(style) {
|
|
17889
|
+
return style.pattern;
|
|
17890
|
+
}
|
|
17891
|
+
function printSelectElement(el) {
|
|
17892
|
+
var msg = [
|
|
17893
|
+
el.value,
|
|
17894
|
+
"select",
|
|
17895
|
+
Object.keys(el.options).map(function(id) {
|
|
17896
|
+
return "".concat(id, "{").concat(doPrintAST(el.options[id].value, false), "}");
|
|
17897
|
+
}).join(" ")
|
|
17898
|
+
].join(",");
|
|
17899
|
+
return "{".concat(msg, "}");
|
|
17900
|
+
}
|
|
17901
|
+
function printPluralElement(el) {
|
|
17902
|
+
var type = el.pluralType === "cardinal" ? "plural" : "selectordinal";
|
|
17903
|
+
var msg = [
|
|
17904
|
+
el.value,
|
|
17905
|
+
type,
|
|
17906
|
+
__spreadArray([
|
|
17907
|
+
el.offset ? "offset:".concat(el.offset) : ""
|
|
17908
|
+
], Object.keys(el.options).map(function(id) {
|
|
17909
|
+
return "".concat(id, "{").concat(doPrintAST(el.options[id].value, true), "}");
|
|
17910
|
+
}), true).filter(Boolean).join(" ")
|
|
17911
|
+
].join(",");
|
|
17912
|
+
return "{".concat(msg, "}");
|
|
17913
|
+
}
|
|
17914
|
+
var init_printer = __esm({
|
|
17915
|
+
"node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/printer.js"() {
|
|
17916
|
+
init_tslib_es6();
|
|
17917
|
+
init_types();
|
|
17918
|
+
}
|
|
17919
|
+
});
|
|
17920
|
+
|
|
17647
17921
|
// node_modules/.aspect_rules_js/typescript@5.8.3/node_modules/typescript/lib/typescript.js
|
|
17648
17922
|
var require_typescript = __commonJS({
|
|
17649
17923
|
"node_modules/.aspect_rules_js/typescript@5.8.3/node_modules/typescript/lib/typescript.js"(exports, module2) {
|
|
@@ -229209,7 +229483,7 @@ function evaluateStringConcat(ts2, node) {
|
|
|
229209
229483
|
}
|
|
229210
229484
|
return ["", false];
|
|
229211
229485
|
}
|
|
229212
|
-
function extractMessageDescriptor(ts2, node, { overrideIdFn, extractSourceLocation, preserveWhitespace }, sf) {
|
|
229486
|
+
function extractMessageDescriptor(ts2, node, { overrideIdFn, extractSourceLocation, preserveWhitespace, flatten: flatten2 }, sf) {
|
|
229213
229487
|
let properties = void 0;
|
|
229214
229488
|
if (ts2.isObjectLiteralExpression(node)) {
|
|
229215
229489
|
properties = node.properties;
|
|
@@ -229249,6 +229523,10 @@ function extractMessageDescriptor(ts2, node, { overrideIdFn, extractSourceLocati
|
|
|
229249
229523
|
break;
|
|
229250
229524
|
}
|
|
229251
229525
|
} else if (ts2.isTaggedTemplateExpression(initializer)) {
|
|
229526
|
+
const isMessageProp = name.text === "id" || name.text === "defaultMessage" || name.text === "description";
|
|
229527
|
+
if (!isMessageProp) {
|
|
229528
|
+
return;
|
|
229529
|
+
}
|
|
229252
229530
|
const { template } = initializer;
|
|
229253
229531
|
if (!ts2.isNoSubstitutionTemplateLiteral(template)) {
|
|
229254
229532
|
throw new Error("Tagged template expression must be no substitution");
|
|
@@ -229293,6 +229571,10 @@ function extractMessageDescriptor(ts2, node, { overrideIdFn, extractSourceLocati
|
|
|
229293
229571
|
break;
|
|
229294
229572
|
}
|
|
229295
229573
|
} else if (ts2.isTaggedTemplateExpression(initializer.expression)) {
|
|
229574
|
+
const isMessageProp = name.text === "id" || name.text === "defaultMessage" || name.text === "description";
|
|
229575
|
+
if (!isMessageProp) {
|
|
229576
|
+
return;
|
|
229577
|
+
}
|
|
229296
229578
|
const { expression: { template } } = initializer;
|
|
229297
229579
|
if (!ts2.isNoSubstitutionTemplateLiteral(template)) {
|
|
229298
229580
|
throw new Error("Tagged template expression must be no substitution");
|
|
@@ -229323,7 +229605,11 @@ function extractMessageDescriptor(ts2, node, { overrideIdFn, extractSourceLocati
|
|
|
229323
229605
|
msg.description = result;
|
|
229324
229606
|
break;
|
|
229325
229607
|
}
|
|
229608
|
+
} else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
|
|
229609
|
+
throw new Error(`[FormatJS] \`${name.text}\` must be a string literal or statically evaluable expression to be extracted.`);
|
|
229326
229610
|
}
|
|
229611
|
+
} else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
|
|
229612
|
+
throw new Error(`[FormatJS] \`${name.text}\` must be a string literal to be extracted.`);
|
|
229327
229613
|
}
|
|
229328
229614
|
} else if (ts2.isBinaryExpression(initializer)) {
|
|
229329
229615
|
const [result, isStatic] = evaluateStringConcat(ts2, initializer);
|
|
@@ -229339,9 +229625,13 @@ function extractMessageDescriptor(ts2, node, { overrideIdFn, extractSourceLocati
|
|
|
229339
229625
|
msg.description = result;
|
|
229340
229626
|
break;
|
|
229341
229627
|
}
|
|
229628
|
+
} else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
|
|
229629
|
+
throw new Error(`[FormatJS] \`${name.text}\` must be a string literal or statically evaluable expression to be extracted.`);
|
|
229342
229630
|
}
|
|
229343
229631
|
} else if (ts2.isObjectLiteralExpression(initializer) && name.text === "description") {
|
|
229344
229632
|
msg.description = objectLiteralExpressionToObj(ts2, initializer);
|
|
229633
|
+
} else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
|
|
229634
|
+
throw new Error(`[FormatJS] \`${name.text}\` must be a string literal to be extracted.`);
|
|
229345
229635
|
}
|
|
229346
229636
|
}
|
|
229347
229637
|
});
|
|
@@ -229351,6 +229641,12 @@ function extractMessageDescriptor(ts2, node, { overrideIdFn, extractSourceLocati
|
|
|
229351
229641
|
if (msg.defaultMessage && !preserveWhitespace) {
|
|
229352
229642
|
msg.defaultMessage = msg.defaultMessage.trim().replace(/\s+/gm, " ");
|
|
229353
229643
|
}
|
|
229644
|
+
if (flatten2 && msg.defaultMessage) {
|
|
229645
|
+
try {
|
|
229646
|
+
msg.defaultMessage = printAST(hoistSelectors(parse(msg.defaultMessage)));
|
|
229647
|
+
} catch (e) {
|
|
229648
|
+
}
|
|
229649
|
+
}
|
|
229354
229650
|
if (msg.defaultMessage && overrideIdFn) {
|
|
229355
229651
|
switch (typeof overrideIdFn) {
|
|
229356
229652
|
case "string":
|
|
@@ -229385,6 +229681,12 @@ function isMemberMethodFormatMessageCall(ts2, node, additionalFunctionNames) {
|
|
|
229385
229681
|
if (ts2.isPropertyAccessExpression(method)) {
|
|
229386
229682
|
return fnNames.has(method.name.text);
|
|
229387
229683
|
}
|
|
229684
|
+
if (ts2.isExpressionWithTypeArguments && ts2.isExpressionWithTypeArguments(method)) {
|
|
229685
|
+
const expr = method.expression;
|
|
229686
|
+
if (ts2.isPropertyAccessExpression(expr)) {
|
|
229687
|
+
return fnNames.has(expr.name.text);
|
|
229688
|
+
}
|
|
229689
|
+
}
|
|
229388
229690
|
return ts2.isIdentifier(method) && fnNames.has(method.text);
|
|
229389
229691
|
}
|
|
229390
229692
|
function extractMessageFromJsxComponent(ts2, factory, node, opts, sf) {
|
|
@@ -229534,6 +229836,8 @@ var stringifyNs2, typescript, stringify2, MESSAGE_DESC_KEYS, DEFAULT_OPTS, PRAGM
|
|
|
229534
229836
|
var init_transform = __esm({
|
|
229535
229837
|
"node_modules/.aspect_rules_js/@formatjs+ts-transformer@0.0.0/node_modules/@formatjs/ts-transformer/src/transform.js"() {
|
|
229536
229838
|
init_icu_messageformat_parser();
|
|
229839
|
+
init_manipulator();
|
|
229840
|
+
init_printer();
|
|
229537
229841
|
stringifyNs2 = __toESM(require_json_stable_stringify());
|
|
229538
229842
|
typescript = __toESM(require_typescript());
|
|
229539
229843
|
init_console_utils2();
|
|
@@ -229768,7 +230072,7 @@ var init_gts_extractor = __esm({
|
|
|
229768
230072
|
}
|
|
229769
230073
|
});
|
|
229770
230074
|
|
|
229771
|
-
// node_modules/.aspect_rules_js/commander@
|
|
230075
|
+
// node_modules/.aspect_rules_js/commander@14.0.2/node_modules/commander/esm.mjs
|
|
229772
230076
|
var import_index = __toESM(require_commander(), 1);
|
|
229773
230077
|
var {
|
|
229774
230078
|
program,
|
|
@@ -230236,109 +230540,6 @@ init_console_utils();
|
|
|
230236
230540
|
init_ts_transformer();
|
|
230237
230541
|
init_console_utils();
|
|
230238
230542
|
var stringifyNs3 = __toESM(require_json_stable_stringify());
|
|
230239
|
-
init_icu_messageformat_parser();
|
|
230240
|
-
init_manipulator();
|
|
230241
|
-
|
|
230242
|
-
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/printer.js
|
|
230243
|
-
init_tslib_es6();
|
|
230244
|
-
init_types();
|
|
230245
|
-
function printAST(ast) {
|
|
230246
|
-
return doPrintAST(ast, false);
|
|
230247
|
-
}
|
|
230248
|
-
function doPrintAST(ast, isInPlural) {
|
|
230249
|
-
var printedNodes = ast.map(function(el, i) {
|
|
230250
|
-
if (isLiteralElement(el)) {
|
|
230251
|
-
return printLiteralElement(el, isInPlural, i === 0, i === ast.length - 1);
|
|
230252
|
-
}
|
|
230253
|
-
if (isArgumentElement(el)) {
|
|
230254
|
-
return printArgumentElement(el);
|
|
230255
|
-
}
|
|
230256
|
-
if (isDateElement(el) || isTimeElement(el) || isNumberElement(el)) {
|
|
230257
|
-
return printSimpleFormatElement(el);
|
|
230258
|
-
}
|
|
230259
|
-
if (isPluralElement(el)) {
|
|
230260
|
-
return printPluralElement(el);
|
|
230261
|
-
}
|
|
230262
|
-
if (isSelectElement(el)) {
|
|
230263
|
-
return printSelectElement(el);
|
|
230264
|
-
}
|
|
230265
|
-
if (isPoundElement(el)) {
|
|
230266
|
-
return "#";
|
|
230267
|
-
}
|
|
230268
|
-
if (isTagElement(el)) {
|
|
230269
|
-
return printTagElement(el);
|
|
230270
|
-
}
|
|
230271
|
-
});
|
|
230272
|
-
return printedNodes.join("");
|
|
230273
|
-
}
|
|
230274
|
-
function printTagElement(el) {
|
|
230275
|
-
return "<".concat(el.value, ">").concat(printAST(el.children), "</").concat(el.value, ">");
|
|
230276
|
-
}
|
|
230277
|
-
function printEscapedMessage(message) {
|
|
230278
|
-
return message.replace(/([{}](?:[\s\S]*[{}])?)/, "'$1'");
|
|
230279
|
-
}
|
|
230280
|
-
function printLiteralElement(_a, isInPlural, isFirstEl, isLastEl) {
|
|
230281
|
-
var value = _a.value;
|
|
230282
|
-
var escaped = value;
|
|
230283
|
-
if (!isFirstEl && escaped[0] === "'") {
|
|
230284
|
-
escaped = "''".concat(escaped.slice(1));
|
|
230285
|
-
}
|
|
230286
|
-
if (!isLastEl && escaped[escaped.length - 1] === "'") {
|
|
230287
|
-
escaped = "".concat(escaped.slice(0, escaped.length - 1), "''");
|
|
230288
|
-
}
|
|
230289
|
-
escaped = printEscapedMessage(escaped);
|
|
230290
|
-
return isInPlural ? escaped.replace("#", "'#'") : escaped;
|
|
230291
|
-
}
|
|
230292
|
-
function printArgumentElement(_a) {
|
|
230293
|
-
var value = _a.value;
|
|
230294
|
-
return "{".concat(value, "}");
|
|
230295
|
-
}
|
|
230296
|
-
function printSimpleFormatElement(el) {
|
|
230297
|
-
return "{".concat(el.value, ", ").concat(TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : "", "}");
|
|
230298
|
-
}
|
|
230299
|
-
function printNumberSkeletonToken(token) {
|
|
230300
|
-
var stem = token.stem, options = token.options;
|
|
230301
|
-
return options.length === 0 ? stem : "".concat(stem).concat(options.map(function(o) {
|
|
230302
|
-
return "/".concat(o);
|
|
230303
|
-
}).join(""));
|
|
230304
|
-
}
|
|
230305
|
-
function printArgumentStyle(style) {
|
|
230306
|
-
if (typeof style === "string") {
|
|
230307
|
-
return printEscapedMessage(style);
|
|
230308
|
-
} else if (style.type === SKELETON_TYPE.dateTime) {
|
|
230309
|
-
return "::".concat(printDateTimeSkeleton(style));
|
|
230310
|
-
} else {
|
|
230311
|
-
return "::".concat(style.tokens.map(printNumberSkeletonToken).join(" "));
|
|
230312
|
-
}
|
|
230313
|
-
}
|
|
230314
|
-
function printDateTimeSkeleton(style) {
|
|
230315
|
-
return style.pattern;
|
|
230316
|
-
}
|
|
230317
|
-
function printSelectElement(el) {
|
|
230318
|
-
var msg = [
|
|
230319
|
-
el.value,
|
|
230320
|
-
"select",
|
|
230321
|
-
Object.keys(el.options).map(function(id) {
|
|
230322
|
-
return "".concat(id, "{").concat(doPrintAST(el.options[id].value, false), "}");
|
|
230323
|
-
}).join(" ")
|
|
230324
|
-
].join(",");
|
|
230325
|
-
return "{".concat(msg, "}");
|
|
230326
|
-
}
|
|
230327
|
-
function printPluralElement(el) {
|
|
230328
|
-
var type = el.pluralType === "cardinal" ? "plural" : "selectordinal";
|
|
230329
|
-
var msg = [
|
|
230330
|
-
el.value,
|
|
230331
|
-
type,
|
|
230332
|
-
__spreadArray([
|
|
230333
|
-
el.offset ? "offset:".concat(el.offset) : ""
|
|
230334
|
-
], Object.keys(el.options).map(function(id) {
|
|
230335
|
-
return "".concat(id, "{").concat(doPrintAST(el.options[id].value, true), "}");
|
|
230336
|
-
}), true).filter(Boolean).join(" ")
|
|
230337
|
-
].join(",");
|
|
230338
|
-
return "{".concat(msg, "}");
|
|
230339
|
-
}
|
|
230340
|
-
|
|
230341
|
-
// packages/cli-lib/src/extract.ts
|
|
230342
230543
|
init_parse_script();
|
|
230343
230544
|
var import_promises = require("fs/promises");
|
|
230344
230545
|
var stringify3 = stringifyNs3.default || stringifyNs3;
|
|
@@ -230421,7 +230622,7 @@ async function processFile(source, fn, { idInterpolationPattern, ...opts }) {
|
|
|
230421
230622
|
return { messages, meta };
|
|
230422
230623
|
}
|
|
230423
230624
|
async function extract(files, extractOpts) {
|
|
230424
|
-
const { throws, readFromStdin,
|
|
230625
|
+
const { throws, readFromStdin, ...opts } = extractOpts;
|
|
230425
230626
|
let rawResults = [];
|
|
230426
230627
|
try {
|
|
230427
230628
|
if (readFromStdin) {
|
|
@@ -230486,9 +230687,6 @@ ${JSON.stringify(message, void 0, 2)}`
|
|
|
230486
230687
|
const results = {};
|
|
230487
230688
|
const messages = Array.from(extractedMessages.values());
|
|
230488
230689
|
for (const { id, ...msg } of messages) {
|
|
230489
|
-
if (flatten2 && msg.defaultMessage) {
|
|
230490
|
-
msg.defaultMessage = printAST(hoistSelectors(parse(msg.defaultMessage)));
|
|
230491
|
-
}
|
|
230492
230690
|
results[id] = msg;
|
|
230493
230691
|
}
|
|
230494
230692
|
if (typeof formatter.serialize === "function") {
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/cli",
|
|
3
3
|
"description": "A CLI for formatjs.",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.9.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Linjie Ding <linjie@airtable.com>",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">= 16"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@formatjs/cli-lib": "8.0
|
|
11
|
+
"@formatjs/cli-lib": "8.1.0"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@glimmer/syntax": "^0.95.0",
|
|
15
15
|
"@vue/compiler-core": "^3.5.12",
|
|
16
|
-
"content-tag": "
|
|
16
|
+
"content-tag": "4",
|
|
17
17
|
"ember-template-recast": "^6.1.5",
|
|
18
18
|
"vue": "^3.5.12"
|
|
19
19
|
},
|