@ant-design/cli 6.3.5 → 6.3.6
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/README.md +15 -0
- package/README.zh-CN.md +15 -0
- package/data/v3.26.20.json.gz +0 -0
- package/data/v3.json.gz +0 -0
- package/data/v6.3.6.json.gz +0 -0
- package/data/v6.json.gz +0 -0
- package/data/versions.json +4 -1
- package/dist/index.js +741 -208
- package/package.json +8 -8
- package/skills/antd/SKILL.md +8 -20
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ var require_argument = __commonJS({
|
|
|
108
108
|
this._name = name;
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
|
-
if (this._name.
|
|
111
|
+
if (this._name.endsWith("...")) {
|
|
112
112
|
this.variadic = true;
|
|
113
113
|
this._name = this._name.slice(0, -3);
|
|
114
114
|
}
|
|
@@ -124,11 +124,12 @@ var require_argument = __commonJS({
|
|
|
124
124
|
/**
|
|
125
125
|
* @package
|
|
126
126
|
*/
|
|
127
|
-
|
|
127
|
+
_collectValue(value, previous) {
|
|
128
128
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
129
129
|
return [value];
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
previous.push(value);
|
|
132
|
+
return previous;
|
|
132
133
|
}
|
|
133
134
|
/**
|
|
134
135
|
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
@@ -167,7 +168,7 @@ var require_argument = __commonJS({
|
|
|
167
168
|
);
|
|
168
169
|
}
|
|
169
170
|
if (this.variadic) {
|
|
170
|
-
return this.
|
|
171
|
+
return this._collectValue(arg, previous);
|
|
171
172
|
}
|
|
172
173
|
return arg;
|
|
173
174
|
};
|
|
@@ -481,7 +482,11 @@ var require_help = __commonJS({
|
|
|
481
482
|
extraInfo.push(`env: ${option.envVar}`);
|
|
482
483
|
}
|
|
483
484
|
if (extraInfo.length > 0) {
|
|
484
|
-
|
|
485
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
486
|
+
if (option.description) {
|
|
487
|
+
return `${option.description} ${extraDescription}`;
|
|
488
|
+
}
|
|
489
|
+
return extraDescription;
|
|
485
490
|
}
|
|
486
491
|
return option.description;
|
|
487
492
|
}
|
|
@@ -513,6 +518,41 @@ var require_help = __commonJS({
|
|
|
513
518
|
}
|
|
514
519
|
return argument.description;
|
|
515
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* Format a list of items, given a heading and an array of formatted items.
|
|
523
|
+
*
|
|
524
|
+
* @param {string} heading
|
|
525
|
+
* @param {string[]} items
|
|
526
|
+
* @param {Help} helper
|
|
527
|
+
* @returns string[]
|
|
528
|
+
*/
|
|
529
|
+
formatItemList(heading, items, helper) {
|
|
530
|
+
if (items.length === 0) return [];
|
|
531
|
+
return [helper.styleTitle(heading), ...items, ""];
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Group items by their help group heading.
|
|
535
|
+
*
|
|
536
|
+
* @param {Command[] | Option[]} unsortedItems
|
|
537
|
+
* @param {Command[] | Option[]} visibleItems
|
|
538
|
+
* @param {Function} getGroup
|
|
539
|
+
* @returns {Map<string, Command[] | Option[]>}
|
|
540
|
+
*/
|
|
541
|
+
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
542
|
+
const result = /* @__PURE__ */ new Map();
|
|
543
|
+
unsortedItems.forEach((item) => {
|
|
544
|
+
const group = getGroup(item);
|
|
545
|
+
if (!result.has(group)) result.set(group, []);
|
|
546
|
+
});
|
|
547
|
+
visibleItems.forEach((item) => {
|
|
548
|
+
const group = getGroup(item);
|
|
549
|
+
if (!result.has(group)) {
|
|
550
|
+
result.set(group, []);
|
|
551
|
+
}
|
|
552
|
+
result.get(group).push(item);
|
|
553
|
+
});
|
|
554
|
+
return result;
|
|
555
|
+
}
|
|
516
556
|
/**
|
|
517
557
|
* Generate the built-in help text.
|
|
518
558
|
*
|
|
@@ -546,26 +586,23 @@ var require_help = __commonJS({
|
|
|
546
586
|
helper.styleArgumentDescription(helper.argumentDescription(argument))
|
|
547
587
|
);
|
|
548
588
|
});
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
589
|
+
output2 = output2.concat(
|
|
590
|
+
this.formatItemList("Arguments:", argumentList, helper)
|
|
591
|
+
);
|
|
592
|
+
const optionGroups = this.groupItems(
|
|
593
|
+
cmd.options,
|
|
594
|
+
helper.visibleOptions(cmd),
|
|
595
|
+
(option) => option.helpGroupHeading ?? "Options:"
|
|
596
|
+
);
|
|
597
|
+
optionGroups.forEach((options, group) => {
|
|
598
|
+
const optionList = options.map((option) => {
|
|
599
|
+
return callFormatItem(
|
|
600
|
+
helper.styleOptionTerm(helper.optionTerm(option)),
|
|
601
|
+
helper.styleOptionDescription(helper.optionDescription(option))
|
|
602
|
+
);
|
|
603
|
+
});
|
|
604
|
+
output2 = output2.concat(this.formatItemList(group, optionList, helper));
|
|
561
605
|
});
|
|
562
|
-
if (optionList.length > 0) {
|
|
563
|
-
output2 = output2.concat([
|
|
564
|
-
helper.styleTitle("Options:"),
|
|
565
|
-
...optionList,
|
|
566
|
-
""
|
|
567
|
-
]);
|
|
568
|
-
}
|
|
569
606
|
if (helper.showGlobalOptions) {
|
|
570
607
|
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
571
608
|
return callFormatItem(
|
|
@@ -573,27 +610,24 @@ var require_help = __commonJS({
|
|
|
573
610
|
helper.styleOptionDescription(helper.optionDescription(option))
|
|
574
611
|
);
|
|
575
612
|
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
helper.styleTitle("Global Options:"),
|
|
579
|
-
...globalOptionList,
|
|
580
|
-
""
|
|
581
|
-
]);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
const commandList = helper.visibleCommands(cmd).map((cmd2) => {
|
|
585
|
-
return callFormatItem(
|
|
586
|
-
helper.styleSubcommandTerm(helper.subcommandTerm(cmd2)),
|
|
587
|
-
helper.styleSubcommandDescription(helper.subcommandDescription(cmd2))
|
|
613
|
+
output2 = output2.concat(
|
|
614
|
+
this.formatItemList("Global Options:", globalOptionList, helper)
|
|
588
615
|
);
|
|
589
|
-
});
|
|
590
|
-
if (commandList.length > 0) {
|
|
591
|
-
output2 = output2.concat([
|
|
592
|
-
helper.styleTitle("Commands:"),
|
|
593
|
-
...commandList,
|
|
594
|
-
""
|
|
595
|
-
]);
|
|
596
616
|
}
|
|
617
|
+
const commandGroups = this.groupItems(
|
|
618
|
+
cmd.commands,
|
|
619
|
+
helper.visibleCommands(cmd),
|
|
620
|
+
(sub) => sub.helpGroup() || "Commands:"
|
|
621
|
+
);
|
|
622
|
+
commandGroups.forEach((commands, group) => {
|
|
623
|
+
const commandList = commands.map((sub) => {
|
|
624
|
+
return callFormatItem(
|
|
625
|
+
helper.styleSubcommandTerm(helper.subcommandTerm(sub)),
|
|
626
|
+
helper.styleSubcommandDescription(helper.subcommandDescription(sub))
|
|
627
|
+
);
|
|
628
|
+
});
|
|
629
|
+
output2 = output2.concat(this.formatItemList(group, commandList, helper));
|
|
630
|
+
});
|
|
597
631
|
return output2.join("\n");
|
|
598
632
|
}
|
|
599
633
|
/**
|
|
@@ -806,6 +840,7 @@ var require_option = __commonJS({
|
|
|
806
840
|
this.argChoices = void 0;
|
|
807
841
|
this.conflictsWith = [];
|
|
808
842
|
this.implied = void 0;
|
|
843
|
+
this.helpGroupHeading = void 0;
|
|
809
844
|
}
|
|
810
845
|
/**
|
|
811
846
|
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
@@ -916,11 +951,12 @@ var require_option = __commonJS({
|
|
|
916
951
|
/**
|
|
917
952
|
* @package
|
|
918
953
|
*/
|
|
919
|
-
|
|
954
|
+
_collectValue(value, previous) {
|
|
920
955
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
921
956
|
return [value];
|
|
922
957
|
}
|
|
923
|
-
|
|
958
|
+
previous.push(value);
|
|
959
|
+
return previous;
|
|
924
960
|
}
|
|
925
961
|
/**
|
|
926
962
|
* Only allow option value to be one of choices.
|
|
@@ -937,7 +973,7 @@ var require_option = __commonJS({
|
|
|
937
973
|
);
|
|
938
974
|
}
|
|
939
975
|
if (this.variadic) {
|
|
940
|
-
return this.
|
|
976
|
+
return this._collectValue(arg, previous);
|
|
941
977
|
}
|
|
942
978
|
return arg;
|
|
943
979
|
};
|
|
@@ -966,6 +1002,16 @@ var require_option = __commonJS({
|
|
|
966
1002
|
}
|
|
967
1003
|
return camelcase(this.name());
|
|
968
1004
|
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Set the help group heading.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {string} heading
|
|
1009
|
+
* @return {Option}
|
|
1010
|
+
*/
|
|
1011
|
+
helpGroup(heading) {
|
|
1012
|
+
this.helpGroupHeading = heading;
|
|
1013
|
+
return this;
|
|
1014
|
+
}
|
|
969
1015
|
/**
|
|
970
1016
|
* Check if `arg` matches the short or long flag.
|
|
971
1017
|
*
|
|
@@ -1223,6 +1269,9 @@ var require_command = __commonJS({
|
|
|
1223
1269
|
this._addImplicitHelpCommand = void 0;
|
|
1224
1270
|
this._helpCommand = void 0;
|
|
1225
1271
|
this._helpConfiguration = {};
|
|
1272
|
+
this._helpGroupHeading = void 0;
|
|
1273
|
+
this._defaultCommandGroup = void 0;
|
|
1274
|
+
this._defaultOptionGroup = void 0;
|
|
1226
1275
|
}
|
|
1227
1276
|
/**
|
|
1228
1277
|
* Copy settings that are useful to have in common across root command and subcommands.
|
|
@@ -1362,7 +1411,10 @@ var require_command = __commonJS({
|
|
|
1362
1411
|
*/
|
|
1363
1412
|
configureOutput(configuration) {
|
|
1364
1413
|
if (configuration === void 0) return this._outputConfiguration;
|
|
1365
|
-
|
|
1414
|
+
this._outputConfiguration = {
|
|
1415
|
+
...this._outputConfiguration,
|
|
1416
|
+
...configuration
|
|
1417
|
+
};
|
|
1366
1418
|
return this;
|
|
1367
1419
|
}
|
|
1368
1420
|
/**
|
|
@@ -1433,16 +1485,16 @@ var require_command = __commonJS({
|
|
|
1433
1485
|
*
|
|
1434
1486
|
* @param {string} name
|
|
1435
1487
|
* @param {string} [description]
|
|
1436
|
-
* @param {(Function|*)} [
|
|
1488
|
+
* @param {(Function|*)} [parseArg] - custom argument processing function or default value
|
|
1437
1489
|
* @param {*} [defaultValue]
|
|
1438
1490
|
* @return {Command} `this` command for chaining
|
|
1439
1491
|
*/
|
|
1440
|
-
argument(name, description,
|
|
1492
|
+
argument(name, description, parseArg, defaultValue) {
|
|
1441
1493
|
const argument = this.createArgument(name, description);
|
|
1442
|
-
if (typeof
|
|
1443
|
-
argument.default(defaultValue).argParser(
|
|
1494
|
+
if (typeof parseArg === "function") {
|
|
1495
|
+
argument.default(defaultValue).argParser(parseArg);
|
|
1444
1496
|
} else {
|
|
1445
|
-
argument.default(
|
|
1497
|
+
argument.default(parseArg);
|
|
1446
1498
|
}
|
|
1447
1499
|
this.addArgument(argument);
|
|
1448
1500
|
return this;
|
|
@@ -1472,7 +1524,7 @@ var require_command = __commonJS({
|
|
|
1472
1524
|
*/
|
|
1473
1525
|
addArgument(argument) {
|
|
1474
1526
|
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
1475
|
-
if (previousArgument
|
|
1527
|
+
if (previousArgument?.variadic) {
|
|
1476
1528
|
throw new Error(
|
|
1477
1529
|
`only the last argument can be variadic '${previousArgument.name()}'`
|
|
1478
1530
|
);
|
|
@@ -1501,10 +1553,13 @@ var require_command = __commonJS({
|
|
|
1501
1553
|
helpCommand(enableOrNameAndArgs, description) {
|
|
1502
1554
|
if (typeof enableOrNameAndArgs === "boolean") {
|
|
1503
1555
|
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
1556
|
+
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
1557
|
+
this._initCommandGroup(this._getHelpCommand());
|
|
1558
|
+
}
|
|
1504
1559
|
return this;
|
|
1505
1560
|
}
|
|
1506
|
-
|
|
1507
|
-
const [, helpName, helpArgs] =
|
|
1561
|
+
const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
|
|
1562
|
+
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1508
1563
|
const helpDescription = description ?? "display help for command";
|
|
1509
1564
|
const helpCommand = this.createCommand(helpName);
|
|
1510
1565
|
helpCommand.helpOption(false);
|
|
@@ -1512,6 +1567,7 @@ var require_command = __commonJS({
|
|
|
1512
1567
|
if (helpDescription) helpCommand.description(helpDescription);
|
|
1513
1568
|
this._addImplicitHelpCommand = true;
|
|
1514
1569
|
this._helpCommand = helpCommand;
|
|
1570
|
+
if (enableOrNameAndArgs || description) this._initCommandGroup(helpCommand);
|
|
1515
1571
|
return this;
|
|
1516
1572
|
}
|
|
1517
1573
|
/**
|
|
@@ -1528,6 +1584,7 @@ var require_command = __commonJS({
|
|
|
1528
1584
|
}
|
|
1529
1585
|
this._addImplicitHelpCommand = true;
|
|
1530
1586
|
this._helpCommand = helpCommand;
|
|
1587
|
+
this._initCommandGroup(helpCommand);
|
|
1531
1588
|
return this;
|
|
1532
1589
|
}
|
|
1533
1590
|
/**
|
|
@@ -1676,6 +1733,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1676
1733
|
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
1677
1734
|
- already used by option '${matchingOption.flags}'`);
|
|
1678
1735
|
}
|
|
1736
|
+
this._initOptionGroup(option);
|
|
1679
1737
|
this.options.push(option);
|
|
1680
1738
|
}
|
|
1681
1739
|
/**
|
|
@@ -1699,6 +1757,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1699
1757
|
`cannot add command '${newCmd}' as already have command '${existingCmd}'`
|
|
1700
1758
|
);
|
|
1701
1759
|
}
|
|
1760
|
+
this._initCommandGroup(command);
|
|
1702
1761
|
this.commands.push(command);
|
|
1703
1762
|
}
|
|
1704
1763
|
/**
|
|
@@ -1731,7 +1790,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1731
1790
|
if (val !== null && option.parseArg) {
|
|
1732
1791
|
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
1733
1792
|
} else if (val !== null && option.variadic) {
|
|
1734
|
-
val = option.
|
|
1793
|
+
val = option._collectValue(val, oldValue);
|
|
1735
1794
|
}
|
|
1736
1795
|
if (val == null) {
|
|
1737
1796
|
if (option.negate) {
|
|
@@ -2383,7 +2442,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2383
2442
|
* @private
|
|
2384
2443
|
*/
|
|
2385
2444
|
_chainOrCall(promise2, fn) {
|
|
2386
|
-
if (promise2
|
|
2445
|
+
if (promise2?.then && typeof promise2.then === "function") {
|
|
2387
2446
|
return promise2.then(() => fn());
|
|
2388
2447
|
}
|
|
2389
2448
|
return fn();
|
|
@@ -2488,7 +2547,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2488
2547
|
promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
|
|
2489
2548
|
return promiseChain;
|
|
2490
2549
|
}
|
|
2491
|
-
if (this.parent
|
|
2550
|
+
if (this.parent?.listenerCount(commandEvent)) {
|
|
2492
2551
|
checkForUnknownOptions();
|
|
2493
2552
|
this._processArguments();
|
|
2494
2553
|
this.parent.emit(commandEvent, operands, unknown2);
|
|
@@ -2599,26 +2658,34 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2599
2658
|
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
|
2600
2659
|
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
|
2601
2660
|
*
|
|
2602
|
-
* @param {string[]}
|
|
2661
|
+
* @param {string[]} args
|
|
2603
2662
|
* @return {{operands: string[], unknown: string[]}}
|
|
2604
2663
|
*/
|
|
2605
|
-
parseOptions(
|
|
2664
|
+
parseOptions(args) {
|
|
2606
2665
|
const operands = [];
|
|
2607
2666
|
const unknown2 = [];
|
|
2608
2667
|
let dest = operands;
|
|
2609
|
-
const args = argv.slice();
|
|
2610
2668
|
function maybeOption(arg) {
|
|
2611
2669
|
return arg.length > 1 && arg[0] === "-";
|
|
2612
2670
|
}
|
|
2671
|
+
const negativeNumberArg = (arg) => {
|
|
2672
|
+
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
|
|
2673
|
+
return !this._getCommandAndAncestors().some(
|
|
2674
|
+
(cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short))
|
|
2675
|
+
);
|
|
2676
|
+
};
|
|
2613
2677
|
let activeVariadicOption = null;
|
|
2614
|
-
|
|
2615
|
-
|
|
2678
|
+
let activeGroup = null;
|
|
2679
|
+
let i = 0;
|
|
2680
|
+
while (i < args.length || activeGroup) {
|
|
2681
|
+
const arg = activeGroup ?? args[i++];
|
|
2682
|
+
activeGroup = null;
|
|
2616
2683
|
if (arg === "--") {
|
|
2617
2684
|
if (dest === unknown2) dest.push(arg);
|
|
2618
|
-
dest.push(...args);
|
|
2685
|
+
dest.push(...args.slice(i));
|
|
2619
2686
|
break;
|
|
2620
2687
|
}
|
|
2621
|
-
if (activeVariadicOption && !maybeOption(arg)) {
|
|
2688
|
+
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
2622
2689
|
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
2623
2690
|
continue;
|
|
2624
2691
|
}
|
|
@@ -2627,13 +2694,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2627
2694
|
const option = this._findOption(arg);
|
|
2628
2695
|
if (option) {
|
|
2629
2696
|
if (option.required) {
|
|
2630
|
-
const value = args
|
|
2697
|
+
const value = args[i++];
|
|
2631
2698
|
if (value === void 0) this.optionMissingArgument(option);
|
|
2632
2699
|
this.emit(`option:${option.name()}`, value);
|
|
2633
2700
|
} else if (option.optional) {
|
|
2634
2701
|
let value = null;
|
|
2635
|
-
if (args.length
|
|
2636
|
-
value = args
|
|
2702
|
+
if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
|
|
2703
|
+
value = args[i++];
|
|
2637
2704
|
}
|
|
2638
2705
|
this.emit(`option:${option.name()}`, value);
|
|
2639
2706
|
} else {
|
|
@@ -2650,7 +2717,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2650
2717
|
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
2651
2718
|
} else {
|
|
2652
2719
|
this.emit(`option:${option.name()}`);
|
|
2653
|
-
|
|
2720
|
+
activeGroup = `-${arg.slice(2)}`;
|
|
2654
2721
|
}
|
|
2655
2722
|
continue;
|
|
2656
2723
|
}
|
|
@@ -2663,27 +2730,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2663
2730
|
continue;
|
|
2664
2731
|
}
|
|
2665
2732
|
}
|
|
2666
|
-
if (maybeOption(arg)) {
|
|
2733
|
+
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
2667
2734
|
dest = unknown2;
|
|
2668
2735
|
}
|
|
2669
2736
|
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown2.length === 0) {
|
|
2670
2737
|
if (this._findCommand(arg)) {
|
|
2671
2738
|
operands.push(arg);
|
|
2672
|
-
|
|
2739
|
+
unknown2.push(...args.slice(i));
|
|
2673
2740
|
break;
|
|
2674
2741
|
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
2675
|
-
operands.push(arg);
|
|
2676
|
-
if (args.length > 0) operands.push(...args);
|
|
2742
|
+
operands.push(arg, ...args.slice(i));
|
|
2677
2743
|
break;
|
|
2678
2744
|
} else if (this._defaultCommandName) {
|
|
2679
|
-
unknown2.push(arg);
|
|
2680
|
-
if (args.length > 0) unknown2.push(...args);
|
|
2745
|
+
unknown2.push(arg, ...args.slice(i));
|
|
2681
2746
|
break;
|
|
2682
2747
|
}
|
|
2683
2748
|
}
|
|
2684
2749
|
if (this._passThroughOptions) {
|
|
2685
|
-
dest.push(arg);
|
|
2686
|
-
if (args.length > 0) dest.push(...args);
|
|
2750
|
+
dest.push(arg, ...args.slice(i));
|
|
2687
2751
|
break;
|
|
2688
2752
|
}
|
|
2689
2753
|
dest.push(arg);
|
|
@@ -3035,6 +3099,69 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3035
3099
|
this._name = str;
|
|
3036
3100
|
return this;
|
|
3037
3101
|
}
|
|
3102
|
+
/**
|
|
3103
|
+
* Set/get the help group heading for this subcommand in parent command's help.
|
|
3104
|
+
*
|
|
3105
|
+
* @param {string} [heading]
|
|
3106
|
+
* @return {Command | string}
|
|
3107
|
+
*/
|
|
3108
|
+
helpGroup(heading) {
|
|
3109
|
+
if (heading === void 0) return this._helpGroupHeading ?? "";
|
|
3110
|
+
this._helpGroupHeading = heading;
|
|
3111
|
+
return this;
|
|
3112
|
+
}
|
|
3113
|
+
/**
|
|
3114
|
+
* Set/get the default help group heading for subcommands added to this command.
|
|
3115
|
+
* (This does not override a group set directly on the subcommand using .helpGroup().)
|
|
3116
|
+
*
|
|
3117
|
+
* @example
|
|
3118
|
+
* program.commandsGroup('Development Commands:);
|
|
3119
|
+
* program.command('watch')...
|
|
3120
|
+
* program.command('lint')...
|
|
3121
|
+
* ...
|
|
3122
|
+
*
|
|
3123
|
+
* @param {string} [heading]
|
|
3124
|
+
* @returns {Command | string}
|
|
3125
|
+
*/
|
|
3126
|
+
commandsGroup(heading) {
|
|
3127
|
+
if (heading === void 0) return this._defaultCommandGroup ?? "";
|
|
3128
|
+
this._defaultCommandGroup = heading;
|
|
3129
|
+
return this;
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Set/get the default help group heading for options added to this command.
|
|
3133
|
+
* (This does not override a group set directly on the option using .helpGroup().)
|
|
3134
|
+
*
|
|
3135
|
+
* @example
|
|
3136
|
+
* program
|
|
3137
|
+
* .optionsGroup('Development Options:')
|
|
3138
|
+
* .option('-d, --debug', 'output extra debugging')
|
|
3139
|
+
* .option('-p, --profile', 'output profiling information')
|
|
3140
|
+
*
|
|
3141
|
+
* @param {string} [heading]
|
|
3142
|
+
* @returns {Command | string}
|
|
3143
|
+
*/
|
|
3144
|
+
optionsGroup(heading) {
|
|
3145
|
+
if (heading === void 0) return this._defaultOptionGroup ?? "";
|
|
3146
|
+
this._defaultOptionGroup = heading;
|
|
3147
|
+
return this;
|
|
3148
|
+
}
|
|
3149
|
+
/**
|
|
3150
|
+
* @param {Option} option
|
|
3151
|
+
* @private
|
|
3152
|
+
*/
|
|
3153
|
+
_initOptionGroup(option) {
|
|
3154
|
+
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
3155
|
+
option.helpGroup(this._defaultOptionGroup);
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
* @param {Command} cmd
|
|
3159
|
+
* @private
|
|
3160
|
+
*/
|
|
3161
|
+
_initCommandGroup(cmd) {
|
|
3162
|
+
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
3163
|
+
cmd.helpGroup(this._defaultCommandGroup);
|
|
3164
|
+
}
|
|
3038
3165
|
/**
|
|
3039
3166
|
* Set the name of the command from script filename, such as process.argv[1],
|
|
3040
3167
|
* or require.main.filename, or __filename.
|
|
@@ -3169,15 +3296,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3169
3296
|
helpOption(flags, description) {
|
|
3170
3297
|
if (typeof flags === "boolean") {
|
|
3171
3298
|
if (flags) {
|
|
3172
|
-
this._helpOption
|
|
3299
|
+
if (this._helpOption === null) this._helpOption = void 0;
|
|
3300
|
+
if (this._defaultOptionGroup) {
|
|
3301
|
+
this._initOptionGroup(this._getHelpOption());
|
|
3302
|
+
}
|
|
3173
3303
|
} else {
|
|
3174
3304
|
this._helpOption = null;
|
|
3175
3305
|
}
|
|
3176
3306
|
return this;
|
|
3177
3307
|
}
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3308
|
+
this._helpOption = this.createOption(
|
|
3309
|
+
flags ?? "-h, --help",
|
|
3310
|
+
description ?? "display help for command"
|
|
3311
|
+
);
|
|
3312
|
+
if (flags || description) this._initOptionGroup(this._helpOption);
|
|
3181
3313
|
return this;
|
|
3182
3314
|
}
|
|
3183
3315
|
/**
|
|
@@ -3202,6 +3334,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3202
3334
|
*/
|
|
3203
3335
|
addHelpOption(option) {
|
|
3204
3336
|
this._helpOption = option;
|
|
3337
|
+
this._initOptionGroup(option);
|
|
3205
3338
|
return this;
|
|
3206
3339
|
}
|
|
3207
3340
|
/**
|
|
@@ -14743,7 +14876,52 @@ function satisfies(version2, range) {
|
|
|
14743
14876
|
return true;
|
|
14744
14877
|
}
|
|
14745
14878
|
|
|
14879
|
+
// src/types.ts
|
|
14880
|
+
function localize(en, zh, lang) {
|
|
14881
|
+
if (lang === "zh" && zh) return zh;
|
|
14882
|
+
return en || "";
|
|
14883
|
+
}
|
|
14884
|
+
|
|
14746
14885
|
// src/output/formatter.ts
|
|
14886
|
+
function outputTokens(result, options) {
|
|
14887
|
+
const { format, lang } = options;
|
|
14888
|
+
if (format === "json") {
|
|
14889
|
+
output(result, "json");
|
|
14890
|
+
return;
|
|
14891
|
+
}
|
|
14892
|
+
const isEmpty = result.tokens.length === 0;
|
|
14893
|
+
const isComponent = "component" in result;
|
|
14894
|
+
if (isEmpty) {
|
|
14895
|
+
const emptyMsg = isComponent ? localize(
|
|
14896
|
+
`No component tokens available for ${result.component}.`,
|
|
14897
|
+
`${result.component} \u7EC4\u4EF6\u6682\u65E0\u53EF\u7528 Token\u3002`,
|
|
14898
|
+
lang
|
|
14899
|
+
) : localize("No global token data available.", "\u6682\u65E0\u5168\u5C40 Token \u6570\u636E\u3002", lang);
|
|
14900
|
+
console.log(emptyMsg);
|
|
14901
|
+
return;
|
|
14902
|
+
}
|
|
14903
|
+
const title = isComponent ? localize(
|
|
14904
|
+
`${result.component} Component Tokens:`,
|
|
14905
|
+
`${result.component} \u7EC4\u4EF6 Token\uFF1A`,
|
|
14906
|
+
lang
|
|
14907
|
+
) : localize("Global Design Tokens:", "\u5168\u5C40 Design Tokens\uFF1A", lang);
|
|
14908
|
+
console.log(title);
|
|
14909
|
+
console.log("");
|
|
14910
|
+
const headers = isComponent ? [
|
|
14911
|
+
localize("Token", "Token", lang),
|
|
14912
|
+
localize("Type", "\u7C7B\u578B", lang),
|
|
14913
|
+
localize("Default", "\u9ED8\u8BA4\u503C", lang)
|
|
14914
|
+
] : [
|
|
14915
|
+
localize("Token", "Token", lang),
|
|
14916
|
+
localize("Type", "\u7C7B\u578B", lang),
|
|
14917
|
+
localize("Default", "\u9ED8\u8BA4\u503C", lang),
|
|
14918
|
+
localize("Description", "\u63CF\u8FF0", lang)
|
|
14919
|
+
];
|
|
14920
|
+
const rows = result.tokens.map(
|
|
14921
|
+
(t) => isComponent ? [t.name, t.type, t.default] : [t.name, t.type, t.default, localize(t.description, t.descriptionZh, lang) || "-"]
|
|
14922
|
+
);
|
|
14923
|
+
console.log(formatTable(headers, rows, format === "markdown" ? "markdown" : "text"));
|
|
14924
|
+
}
|
|
14747
14925
|
function formatOutput(data, format) {
|
|
14748
14926
|
switch (format) {
|
|
14749
14927
|
case "json":
|
|
@@ -14865,12 +15043,6 @@ function registerListCommand(program3) {
|
|
|
14865
15043
|
});
|
|
14866
15044
|
}
|
|
14867
15045
|
|
|
14868
|
-
// src/types.ts
|
|
14869
|
-
function localize(en, zh, lang) {
|
|
14870
|
-
if (lang === "zh" && zh) return zh;
|
|
14871
|
-
return en || "";
|
|
14872
|
-
}
|
|
14873
|
-
|
|
14874
15046
|
// src/commands/info.ts
|
|
14875
15047
|
function getComponentInfo(component, opts) {
|
|
14876
15048
|
const resolved = resolveComponent(component, opts.version);
|
|
@@ -15083,6 +15255,13 @@ function registerDemoCommand(program3) {
|
|
|
15083
15255
|
// src/commands/token.ts
|
|
15084
15256
|
function getTokens(component, opts) {
|
|
15085
15257
|
const major = `v${opts.version.split(".")[0]}`;
|
|
15258
|
+
if (major === "v3") {
|
|
15259
|
+
return createError(
|
|
15260
|
+
ErrorCodes.UNSUPPORTED_VERSION_FEATURE,
|
|
15261
|
+
"Design Tokens are only available in antd v5+",
|
|
15262
|
+
"v3 uses Less variables for theming. See: https://3x.ant.design/docs/react/customize-theme"
|
|
15263
|
+
);
|
|
15264
|
+
}
|
|
15086
15265
|
if (major === "v4") {
|
|
15087
15266
|
return createError(
|
|
15088
15267
|
ErrorCodes.UNSUPPORTED_VERSION_FEATURE,
|
|
@@ -15114,45 +15293,20 @@ function registerTokenCommand(program3) {
|
|
|
15114
15293
|
process.exitCode = 1;
|
|
15115
15294
|
return;
|
|
15116
15295
|
}
|
|
15117
|
-
|
|
15118
|
-
if (result.tokens.length === 0) {
|
|
15119
|
-
console.log(`No component tokens available for ${result.component}.`);
|
|
15120
|
-
return;
|
|
15121
|
-
}
|
|
15122
|
-
if (opts.format === "json") {
|
|
15123
|
-
output(result, "json");
|
|
15124
|
-
return;
|
|
15125
|
-
}
|
|
15126
|
-
console.log(`${result.component} Component Tokens:`);
|
|
15127
|
-
console.log("");
|
|
15128
|
-
const headers = ["Token", "Type", "Default"];
|
|
15129
|
-
const rows = result.tokens.map((t) => [t.name, t.type, t.default]);
|
|
15130
|
-
console.log(formatTable(headers, rows, opts.format === "markdown" ? "markdown" : "text"));
|
|
15131
|
-
} else {
|
|
15132
|
-
if (result.tokens.length === 0) {
|
|
15133
|
-
console.log("No global token data available.");
|
|
15134
|
-
return;
|
|
15135
|
-
}
|
|
15136
|
-
if (opts.format === "json") {
|
|
15137
|
-
output(result, "json");
|
|
15138
|
-
return;
|
|
15139
|
-
}
|
|
15140
|
-
console.log("Global Design Tokens:");
|
|
15141
|
-
console.log("");
|
|
15142
|
-
const headers = ["Token", "Type", "Default", "Description"];
|
|
15143
|
-
const rows = result.tokens.map((t) => [
|
|
15144
|
-
t.name,
|
|
15145
|
-
t.type,
|
|
15146
|
-
t.default,
|
|
15147
|
-
localize(t.description, t.descriptionZh, opts.lang) || "-"
|
|
15148
|
-
]);
|
|
15149
|
-
console.log(formatTable(headers, rows, opts.format === "markdown" ? "markdown" : "text"));
|
|
15150
|
-
}
|
|
15296
|
+
outputTokens(result, { format: opts.format, lang: opts.lang });
|
|
15151
15297
|
});
|
|
15152
15298
|
}
|
|
15153
15299
|
|
|
15154
15300
|
// src/commands/semantic.ts
|
|
15155
15301
|
function getSemanticStructure(component, opts) {
|
|
15302
|
+
const major = `v${opts.version.split(".")[0]}`;
|
|
15303
|
+
if (major === "v3" || major === "v4") {
|
|
15304
|
+
return createError(
|
|
15305
|
+
ErrorCodes.UNSUPPORTED_VERSION_FEATURE,
|
|
15306
|
+
"Semantic structure is only available in antd v5+",
|
|
15307
|
+
"The classNames/styles customization API was introduced in antd v5. See: https://ant.design/docs/react/customize-theme#use-classnames-and-styles"
|
|
15308
|
+
);
|
|
15309
|
+
}
|
|
15156
15310
|
const resolved = resolveComponent(component, opts.version);
|
|
15157
15311
|
if ("error" in resolved) return resolved;
|
|
15158
15312
|
const { comp } = resolved;
|
|
@@ -16002,14 +16156,27 @@ function createLineMapper(source) {
|
|
|
16002
16156
|
return lastLine;
|
|
16003
16157
|
};
|
|
16004
16158
|
}
|
|
16005
|
-
function
|
|
16159
|
+
function normalizeAntdAliases(antdAliases) {
|
|
16160
|
+
const normalized = (antdAliases ?? []).flatMap((source) => source.split(",")).map((source) => source.trim()).filter(Boolean);
|
|
16161
|
+
return Array.from(/* @__PURE__ */ new Set(["antd", ...normalized]));
|
|
16162
|
+
}
|
|
16163
|
+
function matchesAntdAlias(source, antdAliases) {
|
|
16164
|
+
return antdAliases.some((antdAlias) => source === antdAlias || source.startsWith(`${antdAlias}/`));
|
|
16165
|
+
}
|
|
16166
|
+
function mayContainAntdAlias(content, antdAliases) {
|
|
16167
|
+
return antdAliases.some((antdAlias) => content.includes(antdAlias));
|
|
16168
|
+
}
|
|
16169
|
+
function collectAntdAlias(source, previous) {
|
|
16170
|
+
return [...previous, source];
|
|
16171
|
+
}
|
|
16172
|
+
function lintFile(filePath, deprecatedMap, antdAliases, only) {
|
|
16006
16173
|
let content;
|
|
16007
16174
|
try {
|
|
16008
16175
|
content = readFileSync6(filePath, "utf-8");
|
|
16009
16176
|
} catch {
|
|
16010
16177
|
return [];
|
|
16011
16178
|
}
|
|
16012
|
-
if (!content
|
|
16179
|
+
if (!mayContainAntdAlias(content, antdAliases)) return [];
|
|
16013
16180
|
const result = parseSync2(filePath, content);
|
|
16014
16181
|
if (result.errors.length > 0) return [];
|
|
16015
16182
|
const issues = [];
|
|
@@ -16025,7 +16192,7 @@ function lintFile(filePath, deprecatedMap, only) {
|
|
|
16025
16192
|
const visitor = new Visitor2({
|
|
16026
16193
|
ImportDeclaration(node) {
|
|
16027
16194
|
const source = node.source.value;
|
|
16028
|
-
if (source
|
|
16195
|
+
if (!matchesAntdAlias(source, antdAliases)) return;
|
|
16029
16196
|
if (node.importKind === "type") return;
|
|
16030
16197
|
for (const spec of node.specifiers) {
|
|
16031
16198
|
if (spec.type === "ImportSpecifier") {
|
|
@@ -16038,7 +16205,7 @@ function lintFile(filePath, deprecatedMap, only) {
|
|
|
16038
16205
|
"performance",
|
|
16039
16206
|
"error",
|
|
16040
16207
|
lineOf(node),
|
|
16041
|
-
|
|
16208
|
+
`Avoid wildcard import from ${source}. Use named imports: \`import { Button } from '${source}'\``
|
|
16042
16209
|
);
|
|
16043
16210
|
}
|
|
16044
16211
|
}
|
|
@@ -16166,16 +16333,17 @@ function lintFile(filePath, deprecatedMap, only) {
|
|
|
16166
16333
|
return issues;
|
|
16167
16334
|
}
|
|
16168
16335
|
function registerLintCommand(program3) {
|
|
16169
|
-
program3.command("lint [target]").description("Check antd usage against best practices").option("--only <category>", "Only check specific category (deprecated, a11y, usage, performance)").action((target, cmdOpts) => {
|
|
16336
|
+
program3.command("lint [target]").description("Check antd usage against best practices").option("--only <category>", "Only check specific category (deprecated, a11y, usage, performance)").option("--antd-alias <source>", "Treat additional package names as aliases of antd imports", collectAntdAlias, []).action((target, cmdOpts) => {
|
|
16170
16337
|
const opts = program3.opts();
|
|
16171
16338
|
const targetPath = target || ".";
|
|
16172
16339
|
const versionInfo = detectVersion(opts.version);
|
|
16173
16340
|
const store = loadMetadataForVersion(versionInfo.version);
|
|
16174
16341
|
const deprecatedMap = getDeprecatedProps(store);
|
|
16342
|
+
const antdAliases = normalizeAntdAliases(cmdOpts.antdAlias);
|
|
16175
16343
|
const files = collectFiles(targetPath);
|
|
16176
16344
|
const allIssues = [];
|
|
16177
16345
|
for (const file2 of files) {
|
|
16178
|
-
allIssues.push(...lintFile(file2, deprecatedMap, cmdOpts.only));
|
|
16346
|
+
allIssues.push(...lintFile(file2, deprecatedMap, antdAliases, cmdOpts.only));
|
|
16179
16347
|
}
|
|
16180
16348
|
const summary = {
|
|
16181
16349
|
total: allIssues.length,
|
|
@@ -16204,6 +16372,341 @@ Summary: ${summary.deprecated} deprecated, ${summary.a11y} a11y, ${summary.usage
|
|
|
16204
16372
|
});
|
|
16205
16373
|
}
|
|
16206
16374
|
|
|
16375
|
+
// src/commands/migrate-v3-to-v4.ts
|
|
16376
|
+
var V3_TO_V4_STEPS = [
|
|
16377
|
+
// Global changes
|
|
16378
|
+
{
|
|
16379
|
+
component: "Global",
|
|
16380
|
+
breaking: true,
|
|
16381
|
+
description: "React 15 support dropped. Minimum React version is 16.0.0.",
|
|
16382
|
+
autoFixable: false,
|
|
16383
|
+
migrationGuide: `1. Upgrade React to 16.0.0 or higher
|
|
16384
|
+
2. Update related dependencies (react-dom, react-router, etc.)
|
|
16385
|
+
3. Refactor deprecated React 15 APIs if any (e.g., createClass \u2192 class)`
|
|
16386
|
+
},
|
|
16387
|
+
{
|
|
16388
|
+
component: "Global",
|
|
16389
|
+
breaking: true,
|
|
16390
|
+
description: "IE9/IE10 support dropped. IE11 is the minimum supported version.",
|
|
16391
|
+
autoFixable: false,
|
|
16392
|
+
migrationGuide: `If you need IE9/IE10 support, stay on antd v3.x.`
|
|
16393
|
+
},
|
|
16394
|
+
{
|
|
16395
|
+
component: "Global",
|
|
16396
|
+
breaking: true,
|
|
16397
|
+
description: "Less variables are no longer the primary customization method. v4 prepares for CSS-in-JS transition.",
|
|
16398
|
+
autoFixable: false,
|
|
16399
|
+
guide: "https://ant.design/docs/react/migration-v4",
|
|
16400
|
+
migrationGuide: `v4 still supports Less variables but encourages ConfigProvider theme mode.
|
|
16401
|
+
This is preparation for v5 where Less will be completely replaced.`
|
|
16402
|
+
},
|
|
16403
|
+
// Icon - Major breaking change
|
|
16404
|
+
{
|
|
16405
|
+
component: "Icon",
|
|
16406
|
+
breaking: true,
|
|
16407
|
+
description: "Icon with string `type` prop removed. Use @ant-design/icons components instead.",
|
|
16408
|
+
autoFixable: false,
|
|
16409
|
+
guide: "https://ant.design/docs/react/migrate-v4#icon",
|
|
16410
|
+
searchPattern: `<Icon\\s+type=`,
|
|
16411
|
+
migrationGuide: `1. Install @ant-design/icons: npm install @ant-design/icons
|
|
16412
|
+
2. Import specific icon components instead of using Icon with type prop
|
|
16413
|
+
3. Map string type to the corresponding icon component`,
|
|
16414
|
+
before: `import { Icon } from 'antd';
|
|
16415
|
+
|
|
16416
|
+
<Icon type="home" />
|
|
16417
|
+
<Icon type="search" />
|
|
16418
|
+
<Icon type="setting" theme="filled" />`,
|
|
16419
|
+
after: `import { HomeOutlined, SearchOutlined, SettingFilled } from '@ant-design/icons';
|
|
16420
|
+
|
|
16421
|
+
<HomeOutlined />
|
|
16422
|
+
<SearchOutlined />
|
|
16423
|
+
<SettingFilled />`
|
|
16424
|
+
},
|
|
16425
|
+
{
|
|
16426
|
+
component: "Icon",
|
|
16427
|
+
breaking: true,
|
|
16428
|
+
description: "Icon.createFromIconfontCN() moved to @ant-design/icons.",
|
|
16429
|
+
autoFixable: false,
|
|
16430
|
+
searchPattern: `Icon\\.createFromIconfontCN`,
|
|
16431
|
+
before: `import { Icon } from 'antd';
|
|
16432
|
+
const MyIcon = Icon.createFromIconfontCN({ scriptUrl: '...' });`,
|
|
16433
|
+
after: `import { createFromIconfontCN } from '@ant-design/icons';
|
|
16434
|
+
const MyIcon = createFromIconfontCN({ scriptUrl: '...' });`
|
|
16435
|
+
},
|
|
16436
|
+
// Mention
|
|
16437
|
+
{
|
|
16438
|
+
component: "Mention",
|
|
16439
|
+
breaking: true,
|
|
16440
|
+
description: "Mention component removed. Use Mentions instead.",
|
|
16441
|
+
autoFixable: false,
|
|
16442
|
+
guide: "https://ant.design/components/mentions",
|
|
16443
|
+
searchPattern: `import\\s*\\{[^}]*\\bMention\\b[^}]*\\}\\s*from\\s*['"]antd['"]`,
|
|
16444
|
+
migrationGuide: `1. Change import from Mention to Mentions
|
|
16445
|
+
2. Rename JSX tag from <Mention> to <Mentions>
|
|
16446
|
+
3. Update prop names: getSuggestionContainer \u2192 getPopupContainer`,
|
|
16447
|
+
before: `import { Mention } from 'antd';
|
|
16448
|
+
<Mention
|
|
16449
|
+
suggestions={['afc163', 'raoenhui']}
|
|
16450
|
+
getSuggestionContainer={() => document.body}
|
|
16451
|
+
/>`,
|
|
16452
|
+
after: `import { Mentions } from 'antd';
|
|
16453
|
+
<Mentions
|
|
16454
|
+
options={[
|
|
16455
|
+
{ value: 'afc163', label: 'afc163' },
|
|
16456
|
+
{ value: 'raoenhui', label: 'raoenhui' },
|
|
16457
|
+
]}
|
|
16458
|
+
getPopupContainer={() => document.body}
|
|
16459
|
+
/>`
|
|
16460
|
+
},
|
|
16461
|
+
// Form - Major changes
|
|
16462
|
+
{
|
|
16463
|
+
component: "Form",
|
|
16464
|
+
breaking: true,
|
|
16465
|
+
description: "Form.create() HOC removed. Use Form.useForm() hook instead.",
|
|
16466
|
+
autoFixable: false,
|
|
16467
|
+
guide: "https://ant.design/docs/react/migration-v4#form",
|
|
16468
|
+
searchPattern: `Form\\.create\\(`,
|
|
16469
|
+
migrationGuide: `1. Convert class components to functional components (recommended)
|
|
16470
|
+
2. Use Form.useForm() hook to get form instance
|
|
16471
|
+
3. Remove Form.create() wrapper`,
|
|
16472
|
+
before: `class MyForm extends React.Component {
|
|
16473
|
+
handleSubmit = () => {
|
|
16474
|
+
this.props.form.validateFields((err, values) => {
|
|
16475
|
+
// ...
|
|
16476
|
+
});
|
|
16477
|
+
}
|
|
16478
|
+
render() {
|
|
16479
|
+
const { form } = this.props;
|
|
16480
|
+
return <Form>{/* ... */}</Form>;
|
|
16481
|
+
}
|
|
16482
|
+
}
|
|
16483
|
+
export default Form.create()(MyForm);`,
|
|
16484
|
+
after: `const MyForm = () => {
|
|
16485
|
+
const [form] = Form.useForm();
|
|
16486
|
+
const handleSubmit = () => {
|
|
16487
|
+
form.validateFields().then(values => {
|
|
16488
|
+
// ...
|
|
16489
|
+
});
|
|
16490
|
+
};
|
|
16491
|
+
return <Form form={form}>{/* ... */}</Form>;
|
|
16492
|
+
};
|
|
16493
|
+
export default MyForm;`
|
|
16494
|
+
},
|
|
16495
|
+
{
|
|
16496
|
+
component: "Form",
|
|
16497
|
+
breaking: true,
|
|
16498
|
+
description: "getFieldDecorator removed. Use Form.Item name prop instead.",
|
|
16499
|
+
autoFixable: false,
|
|
16500
|
+
searchPattern: `getFieldDecorator\\(`,
|
|
16501
|
+
migrationGuide: `Replace getFieldDecorator with Form.Item name prop.
|
|
16502
|
+
The field value is now automatically managed by Form.`,
|
|
16503
|
+
before: `<Form.Item label="Username">
|
|
16504
|
+
{getFieldDecorator('username', {
|
|
16505
|
+
rules: [{ required: true }],
|
|
16506
|
+
})(<Input />)}
|
|
16507
|
+
</Form.Item>`,
|
|
16508
|
+
after: `<Form.Item label="Username" name="username" rules={[{ required: true }]}>
|
|
16509
|
+
<Input />
|
|
16510
|
+
</Form.Item>`
|
|
16511
|
+
},
|
|
16512
|
+
{
|
|
16513
|
+
component: "Form",
|
|
16514
|
+
breaking: true,
|
|
16515
|
+
description: "autoFormCreate prop removed from Form. Use Form.useForm() hook.",
|
|
16516
|
+
autoFixable: false,
|
|
16517
|
+
searchPattern: `autoFormCreate`
|
|
16518
|
+
},
|
|
16519
|
+
{
|
|
16520
|
+
component: "Form.Item",
|
|
16521
|
+
breaking: true,
|
|
16522
|
+
description: "fieldId prop removed. Form.Item automatically generates id.",
|
|
16523
|
+
autoFixable: false
|
|
16524
|
+
},
|
|
16525
|
+
// BackTop
|
|
16526
|
+
{
|
|
16527
|
+
component: "BackTop",
|
|
16528
|
+
breaking: false,
|
|
16529
|
+
description: "BackTop is still available in v4 but will be removed in v5. Consider using FloatButton.BackTop in v5.",
|
|
16530
|
+
autoFixable: false,
|
|
16531
|
+
guide: "https://ant.design/components/back-top",
|
|
16532
|
+
migrationGuide: `BackTop works in v4 but is deprecated in v5.
|
|
16533
|
+
Start migrating to FloatButton.BackTop when moving to v5.`
|
|
16534
|
+
},
|
|
16535
|
+
// Button.Group - Still exists in v4
|
|
16536
|
+
{
|
|
16537
|
+
component: "Button.Group",
|
|
16538
|
+
breaking: false,
|
|
16539
|
+
description: "Button.Group still exists in v4 but will be deprecated in v5. Use Space or Space.Compact instead.",
|
|
16540
|
+
autoFixable: false,
|
|
16541
|
+
migrationGuide: `v4: Button.Group works but start migrating to Space for consistency.
|
|
16542
|
+
v5: Button.Group removed, use Space.Compact instead.`
|
|
16543
|
+
},
|
|
16544
|
+
// Input.Group
|
|
16545
|
+
{
|
|
16546
|
+
component: "Input.Group",
|
|
16547
|
+
breaking: false,
|
|
16548
|
+
description: "Input.Group still exists in v4 but will be deprecated in v5. Use Space.Compact instead.",
|
|
16549
|
+
autoFixable: false,
|
|
16550
|
+
migrationGuide: `v4: Input.Group works but start migrating to Space.Compact.
|
|
16551
|
+
v5: Input.Group removed, use Space.Compact instead.`
|
|
16552
|
+
},
|
|
16553
|
+
// DatePicker
|
|
16554
|
+
{
|
|
16555
|
+
component: "DatePicker",
|
|
16556
|
+
breaking: true,
|
|
16557
|
+
description: "RangePicker props format changed. `format` should be an array for ranged dates.",
|
|
16558
|
+
autoFixable: false,
|
|
16559
|
+
searchPattern: `<DatePicker\\.RangePicker[^>]*format=`,
|
|
16560
|
+
before: `<DatePicker.RangePicker format="YYYY-MM-DD" />`,
|
|
16561
|
+
after: `<DatePicker.RangePicker format={['YYYY-MM-DD', 'YYYY-MM-DD']} />`
|
|
16562
|
+
},
|
|
16563
|
+
{
|
|
16564
|
+
component: "DatePicker",
|
|
16565
|
+
breaking: true,
|
|
16566
|
+
description: 'MonthPicker removed. Use DatePicker picker="month" instead.',
|
|
16567
|
+
autoFixable: true,
|
|
16568
|
+
codemod: "v4-component-rename",
|
|
16569
|
+
searchPattern: `<DatePicker\\.MonthPicker`,
|
|
16570
|
+
before: `<DatePicker.MonthPicker />`,
|
|
16571
|
+
after: `<DatePicker picker="month" />`
|
|
16572
|
+
},
|
|
16573
|
+
{
|
|
16574
|
+
component: "DatePicker",
|
|
16575
|
+
breaking: true,
|
|
16576
|
+
description: 'WeekPicker removed. Use DatePicker picker="week" instead.',
|
|
16577
|
+
autoFixable: true,
|
|
16578
|
+
codemod: "v4-component-rename",
|
|
16579
|
+
searchPattern: `<DatePicker\\.WeekPicker`,
|
|
16580
|
+
before: `<DatePicker.WeekPicker />`,
|
|
16581
|
+
after: `<DatePicker picker="week" />`
|
|
16582
|
+
},
|
|
16583
|
+
// TimePicker
|
|
16584
|
+
{
|
|
16585
|
+
component: "TimePicker",
|
|
16586
|
+
breaking: false,
|
|
16587
|
+
description: "addon prop moved under popupProps in v4.",
|
|
16588
|
+
autoFixable: false,
|
|
16589
|
+
before: `<TimePicker addon={() => <Button>OK</Button>} />`,
|
|
16590
|
+
after: `<TimePicker popupProps={{ addon: () => <Button>OK</Button> }} />`
|
|
16591
|
+
},
|
|
16592
|
+
// Table
|
|
16593
|
+
{
|
|
16594
|
+
component: "Table",
|
|
16595
|
+
breaking: false,
|
|
16596
|
+
description: "Column render callback signature unchanged. Internal pagination and filtering logic improved.",
|
|
16597
|
+
autoFixable: false,
|
|
16598
|
+
migrationGuide: `The render callback signature (text, record, index) => {} remains unchanged from v3 to v4.
|
|
16599
|
+
The main differences are internal improvements to pagination and filtering behavior.`
|
|
16600
|
+
},
|
|
16601
|
+
{
|
|
16602
|
+
component: "Table",
|
|
16603
|
+
breaking: false,
|
|
16604
|
+
description: "Table pagination now supports responsive layout by default.",
|
|
16605
|
+
autoFixable: false
|
|
16606
|
+
},
|
|
16607
|
+
// Tree
|
|
16608
|
+
{
|
|
16609
|
+
component: "Tree",
|
|
16610
|
+
breaking: true,
|
|
16611
|
+
description: "TreeNode export added at Tree.TreeNode. Previously only available as TreeNode direct import.",
|
|
16612
|
+
autoFixable: false,
|
|
16613
|
+
before: `import { Tree, TreeNode } from 'antd';`,
|
|
16614
|
+
after: `import { Tree } from 'antd';
|
|
16615
|
+
const { TreeNode } = Tree;`
|
|
16616
|
+
},
|
|
16617
|
+
// Upload
|
|
16618
|
+
{
|
|
16619
|
+
component: "Upload",
|
|
16620
|
+
breaking: true,
|
|
16621
|
+
description: "fileList type changed to UploadFile[] with stricter typing.",
|
|
16622
|
+
autoFixable: false
|
|
16623
|
+
},
|
|
16624
|
+
{
|
|
16625
|
+
component: "Upload",
|
|
16626
|
+
breaking: true,
|
|
16627
|
+
description: "`transformFile` added for transforming files before upload.",
|
|
16628
|
+
autoFixable: false
|
|
16629
|
+
},
|
|
16630
|
+
// TreeSelect
|
|
16631
|
+
{
|
|
16632
|
+
component: "TreeSelect",
|
|
16633
|
+
breaking: true,
|
|
16634
|
+
description: "`labelInValue` prop behavior changed. Value now includes halfChecked for tree nodes.",
|
|
16635
|
+
autoFixable: false
|
|
16636
|
+
},
|
|
16637
|
+
// Progress
|
|
16638
|
+
{
|
|
16639
|
+
component: "Progress",
|
|
16640
|
+
breaking: false,
|
|
16641
|
+
description: "`strokeWidth` now defaults to 10px for line type (was 6px in v3).",
|
|
16642
|
+
autoFixable: false
|
|
16643
|
+
},
|
|
16644
|
+
// Select
|
|
16645
|
+
{
|
|
16646
|
+
component: "Select",
|
|
16647
|
+
breaking: true,
|
|
16648
|
+
description: "`onChange` callback signature changed: now receives option as second param.",
|
|
16649
|
+
autoFixable: false,
|
|
16650
|
+
before: `onChange={(value) => {}`,
|
|
16651
|
+
after: `onChange={(value, option) => {}`
|
|
16652
|
+
},
|
|
16653
|
+
// Tooltip/Popover/Popconfirm alignment
|
|
16654
|
+
{
|
|
16655
|
+
component: "Tooltip",
|
|
16656
|
+
breaking: true,
|
|
16657
|
+
description: "Default `align` prop changed. Adjustments may be needed for precise positioning.",
|
|
16658
|
+
autoFixable: false
|
|
16659
|
+
},
|
|
16660
|
+
// Alert
|
|
16661
|
+
{
|
|
16662
|
+
component: "Alert",
|
|
16663
|
+
breaking: false,
|
|
16664
|
+
description: "`banner` mode now automatically applies proper styles for closable Alerts.",
|
|
16665
|
+
autoFixable: false
|
|
16666
|
+
},
|
|
16667
|
+
// Affix
|
|
16668
|
+
{
|
|
16669
|
+
component: "Affix",
|
|
16670
|
+
breaking: true,
|
|
16671
|
+
description: "offsetTop behavior changed to account for scroll containers correctly.",
|
|
16672
|
+
autoFixable: false,
|
|
16673
|
+
guide: "https://ant.design/components/affix"
|
|
16674
|
+
},
|
|
16675
|
+
// Less
|
|
16676
|
+
{
|
|
16677
|
+
component: "Global",
|
|
16678
|
+
breaking: false,
|
|
16679
|
+
description: "Less variable naming standardized. Some internal variables renamed.",
|
|
16680
|
+
autoFixable: false,
|
|
16681
|
+
guide: "https://ant.design/docs/react/customize-theme",
|
|
16682
|
+
migrationGuide: `Most Less variables remain compatible.
|
|
16683
|
+
Check your theme customizations for any renamed variables.`
|
|
16684
|
+
},
|
|
16685
|
+
// Locale
|
|
16686
|
+
{
|
|
16687
|
+
component: "Global",
|
|
16688
|
+
breaking: false,
|
|
16689
|
+
description: "Locale files restructured. Some locale keys changed.",
|
|
16690
|
+
autoFixable: false,
|
|
16691
|
+
migrationGuide: `If using custom locale files, verify keys match v4 structure.
|
|
16692
|
+
Default locales are bundled correctly.`
|
|
16693
|
+
},
|
|
16694
|
+
// ConfigProvider
|
|
16695
|
+
{
|
|
16696
|
+
component: "ConfigProvider",
|
|
16697
|
+
breaking: false,
|
|
16698
|
+
description: "ConfigProvider is introduced in v4 to replace LocaleProvider for global configuration.",
|
|
16699
|
+
autoFixable: false,
|
|
16700
|
+
migrationGuide: `v3: Use LocaleProvider for locale configuration
|
|
16701
|
+
v4: Use ConfigProvider for all global configuration (locale, prefixCls, etc.)
|
|
16702
|
+
ConfigProvider replaces LocaleProvider with enhanced capabilities.`,
|
|
16703
|
+
before: `import { LocaleProvider } from 'antd';
|
|
16704
|
+
<LocaleProvider locale={enUS}>`,
|
|
16705
|
+
after: `import { ConfigProvider } from 'antd';
|
|
16706
|
+
<ConfigProvider locale={enUS}>`
|
|
16707
|
+
}
|
|
16708
|
+
];
|
|
16709
|
+
|
|
16207
16710
|
// src/commands/migrate-v4-to-v5.ts
|
|
16208
16711
|
var V4_TO_V5_STEPS = [
|
|
16209
16712
|
// Global changes
|
|
@@ -17035,6 +17538,7 @@ You no longer need getFieldsValue({ strict: true }) to filter.`,
|
|
|
17035
17538
|
|
|
17036
17539
|
// src/commands/migrate.ts
|
|
17037
17540
|
var MIGRATION_GUIDES = {
|
|
17541
|
+
"3-4": V3_TO_V4_STEPS,
|
|
17038
17542
|
"4-5": V4_TO_V5_STEPS,
|
|
17039
17543
|
"5-6": V5_TO_V6_STEPS
|
|
17040
17544
|
};
|
|
@@ -17288,7 +17792,7 @@ function collectAntdEnv(cwd, versionOverride) {
|
|
|
17288
17792
|
function collectCliEnv() {
|
|
17289
17793
|
let cliVersion;
|
|
17290
17794
|
try {
|
|
17291
|
-
cliVersion = "6.3.
|
|
17795
|
+
cliVersion = "6.3.6";
|
|
17292
17796
|
} catch (err) {
|
|
17293
17797
|
console.error("Failed to get CLI version:", err);
|
|
17294
17798
|
cliVersion = "unknown";
|
|
@@ -17554,65 +18058,51 @@ function registerBugCliCommand(program3) {
|
|
|
17554
18058
|
}
|
|
17555
18059
|
|
|
17556
18060
|
// src/commands/env.ts
|
|
17557
|
-
import { platform as platform2, release as release2 } from "os";
|
|
17558
|
-
import { execFileSync as execFileSync2 } from "child_process";
|
|
17559
18061
|
import { readdirSync as readdirSync3 } from "fs";
|
|
18062
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
17560
18063
|
import { join as join6, isAbsolute } from "path";
|
|
17561
|
-
function
|
|
17562
|
-
const p = platform2();
|
|
17563
|
-
const r = release2();
|
|
17564
|
-
let os;
|
|
17565
|
-
if (p === "darwin") {
|
|
17566
|
-
const parts = r.split(".");
|
|
17567
|
-
const major = parseInt(parts[0], 10);
|
|
17568
|
-
const macMajor = major - 9;
|
|
17569
|
-
const macMinor = parts[1] || "0";
|
|
17570
|
-
os = `macOS ${macMajor}.${macMinor}`;
|
|
17571
|
-
} else if (p === "win32") {
|
|
17572
|
-
os = `Windows ${r}`;
|
|
17573
|
-
} else {
|
|
17574
|
-
os = `${p} ${r}`;
|
|
17575
|
-
}
|
|
17576
|
-
return { OS: os };
|
|
17577
|
-
}
|
|
17578
|
-
function tryExec(cmd, args) {
|
|
17579
|
-
try {
|
|
17580
|
-
return execFileSync2(cmd, args, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
17581
|
-
} catch {
|
|
17582
|
-
return null;
|
|
17583
|
-
}
|
|
17584
|
-
}
|
|
17585
|
-
function getVersion(cmd) {
|
|
17586
|
-
const out = tryExec(cmd, ["--version"]);
|
|
17587
|
-
if (!out) return null;
|
|
17588
|
-
const match = out.match(/(\d+\.\d+\.\d+[-\w.]*)/);
|
|
17589
|
-
return match ? match[1] : null;
|
|
17590
|
-
}
|
|
17591
|
-
function collectBinaries() {
|
|
17592
|
-
const result = {};
|
|
17593
|
-
result.Node = process.version.replace(/^v/, "");
|
|
17594
|
-
const managers = ["npm", "pnpm", "yarn", "bun"];
|
|
17595
|
-
for (const mgr of managers) {
|
|
17596
|
-
const ver = getVersion(mgr);
|
|
17597
|
-
if (ver) result[mgr] = ver;
|
|
17598
|
-
}
|
|
17599
|
-
const registry2 = tryExec("npm", ["config", "get", "registry"]);
|
|
17600
|
-
if (registry2) result.Registry = registry2;
|
|
17601
|
-
return result;
|
|
17602
|
-
}
|
|
17603
|
-
async function collectBrowsers() {
|
|
18064
|
+
async function collectEnvinfo(cwd) {
|
|
17604
18065
|
try {
|
|
17605
18066
|
const envinfo = await Promise.resolve().then(() => __toESM(require_envinfo(), 1));
|
|
17606
18067
|
const raw = await envinfo.default.run(
|
|
17607
|
-
{
|
|
18068
|
+
{
|
|
18069
|
+
System: ["OS", "CPU", "Memory", "Shell"],
|
|
18070
|
+
Binaries: ["Node", "Yarn", "npm", "pnpm", "bun", "Deno"],
|
|
18071
|
+
Managers: ["Cargo", "Homebrew", "pip3", "RubyGems"],
|
|
18072
|
+
Utilities: ["Make", "GCC", "Git", "Clang", "FFmpeg", "Curl", "OpenSSL"],
|
|
18073
|
+
Servers: ["Apache"],
|
|
18074
|
+
IDEs: ["VSCode", "Claude Code", "Vim", "Xcode"],
|
|
18075
|
+
Languages: ["Bash", "Perl", "Python3", "Ruby", "Rust"],
|
|
18076
|
+
Databases: ["SQLite"],
|
|
18077
|
+
Browsers: ["Chrome", "Firefox", "Safari", "Edge"]
|
|
18078
|
+
},
|
|
17608
18079
|
{ json: true }
|
|
17609
18080
|
);
|
|
17610
18081
|
const parsed = JSON.parse(raw);
|
|
17611
|
-
const browsers = parsed.Browsers || {};
|
|
17612
18082
|
const result = {};
|
|
17613
|
-
for (const [
|
|
17614
|
-
|
|
17615
|
-
|
|
18083
|
+
for (const [category, items] of Object.entries(parsed)) {
|
|
18084
|
+
result[category] = {};
|
|
18085
|
+
for (const [name, info] of Object.entries(items)) {
|
|
18086
|
+
if (typeof info === "string") {
|
|
18087
|
+
result[category][name] = info;
|
|
18088
|
+
} else if (info && typeof info === "object") {
|
|
18089
|
+
result[category][name] = info;
|
|
18090
|
+
} else {
|
|
18091
|
+
result[category][name] = null;
|
|
18092
|
+
}
|
|
18093
|
+
}
|
|
18094
|
+
}
|
|
18095
|
+
result.Binaries = result.Binaries || {};
|
|
18096
|
+
try {
|
|
18097
|
+
const registry2 = execFileSync2("npm", ["config", "get", "registry"], {
|
|
18098
|
+
cwd,
|
|
18099
|
+
encoding: "utf-8",
|
|
18100
|
+
timeout: 5e3,
|
|
18101
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
18102
|
+
}).trim();
|
|
18103
|
+
result.Binaries["Registry"] = registry2;
|
|
18104
|
+
} catch {
|
|
18105
|
+
result.Binaries["Registry"] = null;
|
|
17616
18106
|
}
|
|
17617
18107
|
return result;
|
|
17618
18108
|
} catch {
|
|
@@ -17687,6 +18177,7 @@ var BUILD_TOOLS = [
|
|
|
17687
18177
|
"styled-components",
|
|
17688
18178
|
"postcss"
|
|
17689
18179
|
];
|
|
18180
|
+
var ENVINFO_ORDER = ["System", "Binaries", "Managers", "Utilities", "Servers", "IDEs", "Languages", "Databases", "Browsers"];
|
|
17690
18181
|
function collectBuildTools(cwd) {
|
|
17691
18182
|
const result = {};
|
|
17692
18183
|
for (const tool of BUILD_TOOLS) {
|
|
@@ -17695,21 +18186,29 @@ function collectBuildTools(cwd) {
|
|
|
17695
18186
|
}
|
|
17696
18187
|
return result;
|
|
17697
18188
|
}
|
|
18189
|
+
function getDisplayValue(value) {
|
|
18190
|
+
if (value === null) return null;
|
|
18191
|
+
if (typeof value === "string") return value;
|
|
18192
|
+
return value.version || null;
|
|
18193
|
+
}
|
|
17698
18194
|
function formatText2(data) {
|
|
17699
18195
|
const lines = ["Environment", ""];
|
|
17700
18196
|
const section = (title, entries, showNull) => {
|
|
17701
|
-
const filtered = showNull ? Object.entries(entries) : Object.entries(entries).filter(([, v]) => v !== null);
|
|
18197
|
+
const filtered = showNull ? Object.entries(entries) : Object.entries(entries).filter(([, v]) => getDisplayValue(v) !== null);
|
|
17702
18198
|
if (filtered.length === 0) return;
|
|
17703
18199
|
lines.push(` ${title}:`);
|
|
17704
18200
|
const maxKey = Math.max(...filtered.map(([k]) => k.length));
|
|
17705
18201
|
for (const [key, value] of filtered) {
|
|
17706
|
-
|
|
18202
|
+
const display = getDisplayValue(value);
|
|
18203
|
+
lines.push(` ${key.padEnd(maxKey + 1)} ${display ?? "Not found"}`);
|
|
17707
18204
|
}
|
|
17708
18205
|
lines.push("");
|
|
17709
18206
|
};
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
18207
|
+
for (const cat of ENVINFO_ORDER) {
|
|
18208
|
+
if (data.envinfo[cat]) {
|
|
18209
|
+
section(cat, data.envinfo[cat], false);
|
|
18210
|
+
}
|
|
18211
|
+
}
|
|
17713
18212
|
section("Dependencies", data.dependencies, true);
|
|
17714
18213
|
section("Ecosystem", data.ecosystem, false);
|
|
17715
18214
|
section("Build Tools", data.buildTools, false);
|
|
@@ -17718,19 +18217,22 @@ function formatText2(data) {
|
|
|
17718
18217
|
function formatMarkdown2(data) {
|
|
17719
18218
|
const lines = ["## Environment", ""];
|
|
17720
18219
|
const table = (title, col1, col2, entries, showNull) => {
|
|
17721
|
-
const filtered = showNull ? Object.entries(entries) : Object.entries(entries).filter(([, v]) => v !== null);
|
|
18220
|
+
const filtered = showNull ? Object.entries(entries) : Object.entries(entries).filter(([, v]) => getDisplayValue(v) !== null);
|
|
17722
18221
|
if (filtered.length === 0) return;
|
|
17723
18222
|
lines.push(`### ${title}`, "");
|
|
17724
18223
|
lines.push(`| ${col1} | ${col2} |`);
|
|
17725
18224
|
lines.push("|------|---------|");
|
|
17726
18225
|
for (const [key, value] of filtered) {
|
|
17727
|
-
|
|
18226
|
+
const display = getDisplayValue(value);
|
|
18227
|
+
lines.push(`| ${key} | ${display ?? "Not found"} |`);
|
|
17728
18228
|
}
|
|
17729
18229
|
lines.push("");
|
|
17730
18230
|
};
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
18231
|
+
for (const cat of ENVINFO_ORDER) {
|
|
18232
|
+
if (data.envinfo[cat]) {
|
|
18233
|
+
table(cat, "Item", "Version", data.envinfo[cat], false);
|
|
18234
|
+
}
|
|
18235
|
+
}
|
|
17734
18236
|
table("Dependencies", "Package", "Version", data.dependencies, true);
|
|
17735
18237
|
table("Ecosystem", "Package", "Version", data.ecosystem, false);
|
|
17736
18238
|
table("Build Tools", "Package", "Version", data.buildTools, false);
|
|
@@ -17741,9 +18243,7 @@ function registerEnvCommand(program3) {
|
|
|
17741
18243
|
const opts = program3.opts();
|
|
17742
18244
|
const cwd = dir ? isAbsolute(dir) ? dir : join6(process.cwd(), dir) : process.cwd();
|
|
17743
18245
|
const data = {
|
|
17744
|
-
|
|
17745
|
-
binaries: collectBinaries(),
|
|
17746
|
-
browsers: await collectBrowsers(),
|
|
18246
|
+
envinfo: await collectEnvinfo(cwd),
|
|
17747
18247
|
dependencies: collectDependencies(cwd),
|
|
17748
18248
|
ecosystem: scanEcosystem(cwd),
|
|
17749
18249
|
buildTools: collectBuildTools(cwd)
|
|
@@ -28506,10 +29006,9 @@ var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
|
28506
29006
|
var CursorSchema = string2();
|
|
28507
29007
|
var TaskCreationParamsSchema = looseObject({
|
|
28508
29008
|
/**
|
|
28509
|
-
*
|
|
28510
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
29009
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
28511
29010
|
*/
|
|
28512
|
-
ttl:
|
|
29011
|
+
ttl: number2().optional(),
|
|
28513
29012
|
/**
|
|
28514
29013
|
* Time in milliseconds to wait between task status requests.
|
|
28515
29014
|
*/
|
|
@@ -28809,7 +29308,11 @@ var ClientCapabilitiesSchema = object2({
|
|
|
28809
29308
|
/**
|
|
28810
29309
|
* Present if the client supports task creation.
|
|
28811
29310
|
*/
|
|
28812
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
29311
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
29312
|
+
/**
|
|
29313
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
29314
|
+
*/
|
|
29315
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
28813
29316
|
});
|
|
28814
29317
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
28815
29318
|
/**
|
|
@@ -28870,7 +29373,11 @@ var ServerCapabilitiesSchema = object2({
|
|
|
28870
29373
|
/**
|
|
28871
29374
|
* Present if the server supports task creation.
|
|
28872
29375
|
*/
|
|
28873
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
29376
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
29377
|
+
/**
|
|
29378
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
29379
|
+
*/
|
|
29380
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
28874
29381
|
});
|
|
28875
29382
|
var InitializeResultSchema = ResultSchema.extend({
|
|
28876
29383
|
/**
|
|
@@ -29062,6 +29569,12 @@ var ResourceSchema = object2({
|
|
|
29062
29569
|
* The MIME type of this resource, if known.
|
|
29063
29570
|
*/
|
|
29064
29571
|
mimeType: optional(string2()),
|
|
29572
|
+
/**
|
|
29573
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
29574
|
+
*
|
|
29575
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
29576
|
+
*/
|
|
29577
|
+
size: optional(number2()),
|
|
29065
29578
|
/**
|
|
29066
29579
|
* Optional annotations for the client.
|
|
29067
29580
|
*/
|
|
@@ -30243,6 +30756,10 @@ var Protocol = class {
|
|
|
30243
30756
|
this._progressHandlers.clear();
|
|
30244
30757
|
this._taskProgressTokens.clear();
|
|
30245
30758
|
this._pendingDebouncedNotifications.clear();
|
|
30759
|
+
for (const info of this._timeoutInfo.values()) {
|
|
30760
|
+
clearTimeout(info.timeoutId);
|
|
30761
|
+
}
|
|
30762
|
+
this._timeoutInfo.clear();
|
|
30246
30763
|
for (const controller of this._requestHandlerAbortControllers.values()) {
|
|
30247
30764
|
controller.abort();
|
|
30248
30765
|
}
|
|
@@ -30373,7 +30890,9 @@ var Protocol = class {
|
|
|
30373
30890
|
await capturedTransport?.send(errorResponse);
|
|
30374
30891
|
}
|
|
30375
30892
|
}).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
|
|
30376
|
-
this._requestHandlerAbortControllers.
|
|
30893
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
30894
|
+
this._requestHandlerAbortControllers.delete(request.id);
|
|
30895
|
+
}
|
|
30377
30896
|
});
|
|
30378
30897
|
}
|
|
30379
30898
|
_onprogress(notification) {
|
|
@@ -31774,6 +32293,12 @@ function toMcpResult(data) {
|
|
|
31774
32293
|
}
|
|
31775
32294
|
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
31776
32295
|
}
|
|
32296
|
+
var TOOL_ANNOTATIONS = {
|
|
32297
|
+
readOnlyHint: true,
|
|
32298
|
+
destructiveHint: false,
|
|
32299
|
+
idempotentHint: true,
|
|
32300
|
+
openWorldHint: false
|
|
32301
|
+
};
|
|
31777
32302
|
var TOOL_DEFINITIONS = [
|
|
31778
32303
|
{
|
|
31779
32304
|
name: "antd_list",
|
|
@@ -31782,7 +32307,8 @@ var TOOL_DEFINITIONS = [
|
|
|
31782
32307
|
type: "object",
|
|
31783
32308
|
properties: {},
|
|
31784
32309
|
required: []
|
|
31785
|
-
}
|
|
32310
|
+
},
|
|
32311
|
+
annotations: { title: "List Components", ...TOOL_ANNOTATIONS }
|
|
31786
32312
|
},
|
|
31787
32313
|
{
|
|
31788
32314
|
name: "antd_info",
|
|
@@ -31794,7 +32320,8 @@ var TOOL_DEFINITIONS = [
|
|
|
31794
32320
|
detail: { type: "boolean", description: "Include full detail (whenToUse, methods, related, faq)" }
|
|
31795
32321
|
},
|
|
31796
32322
|
required: ["component"]
|
|
31797
|
-
}
|
|
32323
|
+
},
|
|
32324
|
+
annotations: { title: "Get Component Info", ...TOOL_ANNOTATIONS }
|
|
31798
32325
|
},
|
|
31799
32326
|
{
|
|
31800
32327
|
name: "antd_doc",
|
|
@@ -31805,7 +32332,8 @@ var TOOL_DEFINITIONS = [
|
|
|
31805
32332
|
component: { type: "string", description: "Component name (e.g. Button, Table)" }
|
|
31806
32333
|
},
|
|
31807
32334
|
required: ["component"]
|
|
31808
|
-
}
|
|
32335
|
+
},
|
|
32336
|
+
annotations: { title: "Get Component Doc", ...TOOL_ANNOTATIONS }
|
|
31809
32337
|
},
|
|
31810
32338
|
{
|
|
31811
32339
|
name: "antd_demo",
|
|
@@ -31817,7 +32345,8 @@ var TOOL_DEFINITIONS = [
|
|
|
31817
32345
|
name: { type: "string", description: "Demo name to get specific demo code" }
|
|
31818
32346
|
},
|
|
31819
32347
|
required: ["component"]
|
|
31820
|
-
}
|
|
32348
|
+
},
|
|
32349
|
+
annotations: { title: "Get Component Demo", ...TOOL_ANNOTATIONS }
|
|
31821
32350
|
},
|
|
31822
32351
|
{
|
|
31823
32352
|
name: "antd_token",
|
|
@@ -31828,7 +32357,8 @@ var TOOL_DEFINITIONS = [
|
|
|
31828
32357
|
component: { type: "string", description: "Component name for component-level tokens" }
|
|
31829
32358
|
},
|
|
31830
32359
|
required: []
|
|
31831
|
-
}
|
|
32360
|
+
},
|
|
32361
|
+
annotations: { title: "Query Design Tokens", ...TOOL_ANNOTATIONS }
|
|
31832
32362
|
},
|
|
31833
32363
|
{
|
|
31834
32364
|
name: "antd_semantic",
|
|
@@ -31839,7 +32369,8 @@ var TOOL_DEFINITIONS = [
|
|
|
31839
32369
|
component: { type: "string", description: "Component name (e.g. Button, Table)" }
|
|
31840
32370
|
},
|
|
31841
32371
|
required: ["component"]
|
|
31842
|
-
}
|
|
32372
|
+
},
|
|
32373
|
+
annotations: { title: "Query Semantic Structure", ...TOOL_ANNOTATIONS }
|
|
31843
32374
|
},
|
|
31844
32375
|
{
|
|
31845
32376
|
name: "antd_changelog",
|
|
@@ -31853,7 +32384,8 @@ var TOOL_DEFINITIONS = [
|
|
|
31853
32384
|
component: { type: "string", description: "Filter diff to a specific component" }
|
|
31854
32385
|
},
|
|
31855
32386
|
required: []
|
|
31856
|
-
}
|
|
32387
|
+
},
|
|
32388
|
+
annotations: { title: "Query Changelog", ...TOOL_ANNOTATIONS }
|
|
31857
32389
|
}
|
|
31858
32390
|
];
|
|
31859
32391
|
function createToolHandler(ctx) {
|
|
@@ -31953,7 +32485,8 @@ var SHARED_TOOL_WORKFLOW = `## Tool usage workflow
|
|
|
31953
32485
|
## Rules
|
|
31954
32486
|
- Avoid duplicate tool calls \u2014 do not call the same tool with the same parameters twice
|
|
31955
32487
|
- Always query component docs before generating code that uses the component
|
|
31956
|
-
- Prefer reading real documentation over guessing API usage
|
|
32488
|
+
- Prefer reading real documentation over guessing API usage
|
|
32489
|
+
- Do not suggest filing bug reports (antd bug / antd bug-cli) unless the user explicitly asks. If the user has set ANTD_NO_AUTO_REPORT=1, never suggest reporting.`;
|
|
31957
32490
|
var ANTD_EXPERT_PROMPT = `You are an expert assistant for Ant Design (antd), a React UI component library.
|
|
31958
32491
|
|
|
31959
32492
|
${SHARED_TOOL_WORKFLOW}
|
|
@@ -31974,7 +32507,7 @@ function registerMcpCommand(program3) {
|
|
|
31974
32507
|
const opts = program3.opts();
|
|
31975
32508
|
const versionInfo = detectVersion(opts.version);
|
|
31976
32509
|
const server = new Server(
|
|
31977
|
-
{ name: "antd", version: "6.3.
|
|
32510
|
+
{ name: "antd", version: "6.3.6" },
|
|
31978
32511
|
{ capabilities: { tools: {}, prompts: {} } }
|
|
31979
32512
|
);
|
|
31980
32513
|
const handleTool = createToolHandler({
|
|
@@ -32096,7 +32629,7 @@ function printUpdateNotice(currentVersion, latestVersion) {
|
|
|
32096
32629
|
}
|
|
32097
32630
|
async function checkForUpdate() {
|
|
32098
32631
|
if (process.env.CI || process.env.NO_UPDATE_CHECK) return;
|
|
32099
|
-
const currentVersion = "6.3.
|
|
32632
|
+
const currentVersion = "6.3.6";
|
|
32100
32633
|
if (!valid(currentVersion)) return;
|
|
32101
32634
|
const now = Date.now();
|
|
32102
32635
|
const cache = readCache();
|
|
@@ -32115,7 +32648,7 @@ async function checkForUpdate() {
|
|
|
32115
32648
|
}
|
|
32116
32649
|
|
|
32117
32650
|
// src/index.ts
|
|
32118
|
-
var CLI_VERSION = "6.3.
|
|
32651
|
+
var CLI_VERSION = "6.3.6";
|
|
32119
32652
|
var program2 = new Command();
|
|
32120
32653
|
program2.name("antd").description("CLI tool for querying antd knowledge and analyzing antd usage").option("--format <format>", "Output format: json, text, or markdown", "text").option("--version <version>", "Target antd version (e.g. 5.20.0)").option("--lang <lang>", "Output language: en or zh", "en").option("--detail", "Full information output", false);
|
|
32121
32654
|
program2.addOption(new Option("-V, --cli-version", "Output the CLI version number"));
|