@ant-design/cli 6.6.0 → 6.6.1

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/data/v5.json.gz CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/data/v6.json.gz CHANGED
Binary file
@@ -68,6 +68,6 @@
68
68
  "6.2": "6.2.3",
69
69
  "6.4": "6.4.5",
70
70
  "6.5": "6.5.4",
71
- "6.6": "6.6.0"
71
+ "6.6": "6.6.1"
72
72
  }
73
73
  }
package/dist/index.js CHANGED
@@ -7970,7 +7970,12 @@ var require_fast_uri = __commonJS({
7970
7970
  }
7971
7971
  function resolve3(baseURI, relativeURI, options) {
7972
7972
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
7973
- const resolved = resolveComponent2(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
7973
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
7974
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
7975
+ if (baseMalformed || relativeMalformed) {
7976
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
7977
+ }
7978
+ const resolved = resolveComponent2(baseParsed, relativeParsed, schemelessOptions, true);
7974
7979
  schemelessOptions.skipEscape = true;
7975
7980
  return serialize(resolved, schemelessOptions);
7976
7981
  }
@@ -8096,6 +8101,7 @@ var require_fast_uri = __commonJS({
8096
8101
  }
8097
8102
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
8098
8103
  var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
8104
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
8099
8105
  function getParseError(parsed, matches) {
8100
8106
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
8101
8107
  return 'URI path must start with "/" when authority is present.';
@@ -8130,6 +8136,20 @@ var require_fast_uri = __commonJS({
8130
8136
  parsed.error = "URI authority must not contain a literal backslash.";
8131
8137
  malformedAuthorityOrPort = true;
8132
8138
  }
8139
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
8140
+ if (introducerMatch !== null) {
8141
+ const region = introducerMatch[1];
8142
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
8143
+ if (normalizedRegion.length >= 2) {
8144
+ if (normalizedRegion.slice(0, 2) !== "//") {
8145
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
8146
+ malformedAuthorityOrPort = true;
8147
+ } else if (region.length !== normalizedRegion.length) {
8148
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
8149
+ malformedAuthorityOrPort = true;
8150
+ }
8151
+ }
8152
+ }
8133
8153
  const matches = uri.match(URI_PARSE);
8134
8154
  if (matches) {
8135
8155
  parsed.scheme = matches[1];
@@ -17478,6 +17498,28 @@ function getDeprecatedProps(store) {
17478
17498
  }
17479
17499
  return result;
17480
17500
  }
17501
+ function extractDeprecatedNotice(source) {
17502
+ const notice = source?.match(
17503
+ /:::warning\{\s*title\s*=\s*["']?(?:Deprecated Notice|废弃提示)["']?\s*\}\s*([\s\S]*?)\s*:::/
17504
+ );
17505
+ return notice?.[1]?.replace(/\s+/g, " ").trim();
17506
+ }
17507
+ function getDeprecatedComponents(store, lang) {
17508
+ const result = /* @__PURE__ */ new Map();
17509
+ for (const comp of store.components) {
17510
+ const englishDetail = extractDeprecatedNotice(comp.whenToUse);
17511
+ const chineseDetail = extractDeprecatedNotice(comp.whenToUseZh);
17512
+ const englishMessage = englishDetail && `\`${comp.name}\` is deprecated. ${englishDetail}`;
17513
+ const chineseMessage = chineseDetail && `\`${comp.name}\` \u5DF2\u5E9F\u5F03\u3002${chineseDetail}`;
17514
+ const fallbackMessage = englishMessage ?? chineseMessage;
17515
+ if (!fallbackMessage) continue;
17516
+ result.set(
17517
+ comp.name,
17518
+ localize(englishMessage ?? fallbackMessage, chineseMessage ?? fallbackMessage, lang)
17519
+ );
17520
+ }
17521
+ return result;
17522
+ }
17481
17523
  function findAttr(attrs, name) {
17482
17524
  return attrs.find((a) => a.type === "JSXAttribute" && a.name?.name === name) ?? null;
17483
17525
  }
@@ -17553,6 +17595,110 @@ function collectPatternNames(pattern, names = []) {
17553
17595
  }
17554
17596
  return names;
17555
17597
  }
17598
+ function collectScopeBindings(program2) {
17599
+ const bindings = /* @__PURE__ */ new Map();
17600
+ const scopeStack = [];
17601
+ const pushScope = (node, kind) => {
17602
+ bindings.set(node, /* @__PURE__ */ new Set());
17603
+ scopeStack.push({ node, kind });
17604
+ };
17605
+ const declareIn = (scope, pattern) => {
17606
+ const names = bindings.get(scope.node);
17607
+ for (const name of collectPatternNames(pattern)) names.add(name);
17608
+ };
17609
+ const currentScope = () => scopeStack[scopeStack.length - 1];
17610
+ const nearestFunctionScope = () => [...scopeStack].reverse().find(
17611
+ ({ kind }) => kind === "function" || kind === "program" || kind === "static"
17612
+ );
17613
+ const pushFunctionScope = (node) => {
17614
+ pushScope(node, "function");
17615
+ if (node.type === "FunctionExpression" && node.id) declareIn(currentScope(), node.id);
17616
+ for (const param of node.params ?? []) declareIn(currentScope(), param);
17617
+ };
17618
+ pushScope(program2, "program");
17619
+ const visitor = new Visitor2({
17620
+ BlockStatement(node) {
17621
+ pushScope(node, "block");
17622
+ },
17623
+ "BlockStatement:exit"() {
17624
+ scopeStack.pop();
17625
+ },
17626
+ FunctionDeclaration(node) {
17627
+ declareIn(currentScope(), node.id);
17628
+ pushFunctionScope(node);
17629
+ },
17630
+ "FunctionDeclaration:exit"() {
17631
+ scopeStack.pop();
17632
+ },
17633
+ FunctionExpression: pushFunctionScope,
17634
+ "FunctionExpression:exit"() {
17635
+ scopeStack.pop();
17636
+ },
17637
+ ArrowFunctionExpression: pushFunctionScope,
17638
+ "ArrowFunctionExpression:exit"() {
17639
+ scopeStack.pop();
17640
+ },
17641
+ ClassDeclaration(node) {
17642
+ declareIn(currentScope(), node.id);
17643
+ pushScope(node, "class");
17644
+ declareIn(currentScope(), node.id);
17645
+ },
17646
+ "ClassDeclaration:exit"() {
17647
+ scopeStack.pop();
17648
+ },
17649
+ ClassExpression(node) {
17650
+ pushScope(node, "class");
17651
+ if (node.id) declareIn(currentScope(), node.id);
17652
+ },
17653
+ "ClassExpression:exit"() {
17654
+ scopeStack.pop();
17655
+ },
17656
+ ForStatement(node) {
17657
+ pushScope(node, "loop");
17658
+ },
17659
+ "ForStatement:exit"() {
17660
+ scopeStack.pop();
17661
+ },
17662
+ ForInStatement(node) {
17663
+ pushScope(node, "loop");
17664
+ },
17665
+ "ForInStatement:exit"() {
17666
+ scopeStack.pop();
17667
+ },
17668
+ ForOfStatement(node) {
17669
+ pushScope(node, "loop");
17670
+ },
17671
+ "ForOfStatement:exit"() {
17672
+ scopeStack.pop();
17673
+ },
17674
+ SwitchStatement(node) {
17675
+ pushScope(node, "switch");
17676
+ },
17677
+ "SwitchStatement:exit"() {
17678
+ scopeStack.pop();
17679
+ },
17680
+ StaticBlock(node) {
17681
+ pushScope(node, "static");
17682
+ },
17683
+ "StaticBlock:exit"() {
17684
+ scopeStack.pop();
17685
+ },
17686
+ CatchClause(node) {
17687
+ pushScope(node, "catch");
17688
+ if (node.param) declareIn(currentScope(), node.param);
17689
+ },
17690
+ "CatchClause:exit"() {
17691
+ scopeStack.pop();
17692
+ },
17693
+ VariableDeclaration(node) {
17694
+ const target = node.kind === "var" ? nearestFunctionScope() : currentScope();
17695
+ for (const declaration of node.declarations ?? []) declareIn(target, declaration.id);
17696
+ }
17697
+ });
17698
+ visitor.visit(program2);
17699
+ scopeStack.pop();
17700
+ return bindings;
17701
+ }
17556
17702
  var STATIC_FEEDBACK_METHODS = {
17557
17703
  message: ["open", "success", "error", "info", "warning", "warn", "loading"],
17558
17704
  notification: ["open", "success", "error", "info", "warning", "warn"],
@@ -17580,6 +17726,17 @@ function normalizeAntdAliases(antdAliases) {
17580
17726
  function matchesAntdAlias(source, antdAliases) {
17581
17727
  return antdAliases.some((antdAlias) => source === antdAlias || source.startsWith(`${antdAlias}/`));
17582
17728
  }
17729
+ function getComponentFromSubpath(source, antdAliases, componentBySubpath) {
17730
+ const matchedAlias = [...antdAliases].sort((a, b) => b.length - a.length).find((antdAlias) => source.startsWith(`${antdAlias}/`));
17731
+ const parts = source.slice(matchedAlias.length + 1).split("/");
17732
+ const componentParts = parts[0] === "es" || parts[0] === "lib" ? parts.slice(1) : parts;
17733
+ if (componentParts.includes("style") || componentParts.includes("locale")) return void 0;
17734
+ for (let i = componentParts.length - 1; i >= 0; i--) {
17735
+ const componentName = componentBySubpath.get(normalizeComponentKey(componentParts[i]));
17736
+ if (componentName) return componentName;
17737
+ }
17738
+ return void 0;
17739
+ }
17583
17740
  function isLocalePath(source, antdAliases) {
17584
17741
  return antdAliases.some(
17585
17742
  (alias) => source.startsWith(`${alias}/locale/`) || source.startsWith(`${alias}/es/locale/`) || source.startsWith(`${alias}/lib/locale/`)
@@ -17591,6 +17748,54 @@ function isNonModuleSource(source) {
17591
17748
  if (!match) return false;
17592
17749
  return !MODULE_EXTENSIONS.has(match[1].toLowerCase());
17593
17750
  }
17751
+ function collectAntdImports(program2, antdAliases, componentBySubpath) {
17752
+ const importedComponents = /* @__PURE__ */ new Set();
17753
+ const antdImportLocals = /* @__PURE__ */ new Map();
17754
+ const antdRootImportLocals = /* @__PURE__ */ new Set();
17755
+ const performanceImports = [];
17756
+ const visitor = new Visitor2({
17757
+ ImportDeclaration(node) {
17758
+ const source = node.source.value;
17759
+ if (!matchesAntdAlias(source, antdAliases) || node.importKind === "type") return;
17760
+ const isRootImport = antdAliases.includes(source);
17761
+ for (const spec of node.specifiers) {
17762
+ if (spec.type === "ImportSpecifier" && spec.importKind !== "type") {
17763
+ const name = spec.imported?.name || spec.local?.name;
17764
+ const localName = spec.local?.name || name;
17765
+ if (name) importedComponents.add(name);
17766
+ if (name && localName) antdImportLocals.set(localName, name);
17767
+ }
17768
+ if (spec.type === "ImportNamespaceSpecifier" && isRootImport) {
17769
+ antdRootImportLocals.add(spec.local?.name ?? "");
17770
+ }
17771
+ if (spec.type === "ImportDefaultSpecifier") {
17772
+ const localName = spec.local?.name;
17773
+ if (localName && isRootImport) {
17774
+ antdRootImportLocals.add(localName);
17775
+ } else if (localName) {
17776
+ const componentName = getComponentFromSubpath(source, antdAliases, componentBySubpath);
17777
+ if (componentName) {
17778
+ importedComponents.add(componentName);
17779
+ antdImportLocals.set(localName, componentName);
17780
+ }
17781
+ }
17782
+ }
17783
+ const isNamespace = spec.type === "ImportNamespaceSpecifier";
17784
+ const isDefault = spec.type === "ImportDefaultSpecifier";
17785
+ if ((isNamespace || isDefault) && !isLocalePath(source, antdAliases) && !isNonModuleSource(source)) {
17786
+ performanceImports.push({
17787
+ node,
17788
+ source,
17789
+ localName: spec.local?.name ?? "",
17790
+ kind: isNamespace ? "namespace" : "default"
17791
+ });
17792
+ }
17793
+ }
17794
+ }
17795
+ });
17796
+ visitor.visit(program2);
17797
+ return { importedComponents, antdImportLocals, antdRootImportLocals, performanceImports };
17798
+ }
17594
17799
  function mayContainAntdAlias(content, antdAliases) {
17595
17800
  return antdAliases.some((antdAlias) => content.includes(antdAlias));
17596
17801
  }
@@ -17656,7 +17861,7 @@ function collectGitFiles(targetPath, mode, diff) {
17656
17861
  const args = mode === "staged" ? ["diff", "--name-only", "--cached", "--diff-filter=ACMR", "--", pathspec] : ["diff", "--name-only", "--diff-filter=ACMR", resolveDiffBase(repoRoot, diff), "--", pathspec];
17657
17862
  return execGit(repoRoot, args).split("\n").map((file2) => file2.trim()).filter(Boolean).filter((file2) => isLintableSource(join5(repoRoot, file2), file2)).map((file2) => join5(repoRoot, file2));
17658
17863
  }
17659
- function lintFile(filePath, deprecatedMap, antdAliases, antdMajor, only) {
17864
+ function lintFile(filePath, deprecatedMap, deprecatedComponents, componentBySubpath, antdAliases, antdMajor, only) {
17660
17865
  let content;
17661
17866
  try {
17662
17867
  content = readFileSync7(filePath, "utf-8");
@@ -17683,8 +17888,12 @@ function lintFile(filePath, deprecatedMap, antdAliases, antdMajor, only) {
17683
17888
  };
17684
17889
  }
17685
17890
  const issues = [];
17686
- const importedComponents = /* @__PURE__ */ new Set();
17687
- const antdImportLocals = /* @__PURE__ */ new Map();
17891
+ const {
17892
+ importedComponents,
17893
+ antdImportLocals,
17894
+ antdRootImportLocals,
17895
+ performanceImports
17896
+ } = collectAntdImports(result.program, antdAliases, componentBySubpath);
17688
17897
  const offsetToLine = createLineMapper(content);
17689
17898
  const enableV5UsageRules = antdMajor >= 5;
17690
17899
  const lineOf = (node) => {
@@ -17696,48 +17905,74 @@ function lintFile(filePath, deprecatedMap, antdAliases, antdMajor, only) {
17696
17905
  };
17697
17906
  const jsxAncestorStack = [];
17698
17907
  const isInsideComponent = (name) => jsxAncestorStack.includes(name);
17699
- const pendingPerformanceIssues = [];
17700
- const namespaceMemberUsage = /* @__PURE__ */ new Map();
17701
- const scopeStack = [/* @__PURE__ */ new Set()];
17702
- const declarePattern = (pattern) => {
17703
- const currentScope = scopeStack[scopeStack.length - 1];
17704
- for (const name of collectPatternNames(pattern)) {
17705
- currentScope.add(name);
17706
- }
17707
- };
17908
+ const pendingPerformanceIssues = !only || only === "performance" ? performanceImports.map(({ node, ...item }) => ({ line: lineOf(node), ...item })) : [];
17909
+ const namespaceMemberUsage = new Map(
17910
+ pendingPerformanceIssues.map((item) => [item.localName, /* @__PURE__ */ new Set()])
17911
+ );
17912
+ const scopeBindings = collectScopeBindings(result.program);
17913
+ const scopeStack = [scopeBindings.get(result.program) ?? /* @__PURE__ */ new Set()];
17914
+ const pushScope = (node) => scopeStack.push(scopeBindings.get(node) ?? /* @__PURE__ */ new Set());
17708
17915
  const isShadowed = (name) => scopeStack.some((scope) => scope.has(name));
17709
- const pushFunctionScope = (node) => {
17710
- scopeStack.push(/* @__PURE__ */ new Set());
17711
- for (const param of node.params ?? []) declarePattern(param);
17916
+ const resolveCanonicalComponent = (compName) => {
17917
+ const [localRoot, ...members] = compName.split(".");
17918
+ if (!localRoot || isShadowed(localRoot)) return null;
17919
+ const importedRoot = antdImportLocals.get(localRoot);
17920
+ if (importedRoot) {
17921
+ return { root: importedRoot, full: [importedRoot, ...members].join(".") };
17922
+ }
17923
+ if (antdRootImportLocals.has(localRoot) && members.length > 0) {
17924
+ return { root: members[0], full: members.join(".") };
17925
+ }
17926
+ return null;
17712
17927
  };
17713
17928
  const visitor = new Visitor2({
17714
- BlockStatement() {
17715
- scopeStack.push(/* @__PURE__ */ new Set());
17716
- },
17929
+ BlockStatement: pushScope,
17717
17930
  "BlockStatement:exit"() {
17718
17931
  scopeStack.pop();
17719
17932
  },
17720
- FunctionDeclaration: pushFunctionScope,
17933
+ FunctionDeclaration: pushScope,
17721
17934
  "FunctionDeclaration:exit"() {
17722
17935
  scopeStack.pop();
17723
17936
  },
17724
- FunctionExpression: pushFunctionScope,
17937
+ FunctionExpression: pushScope,
17725
17938
  "FunctionExpression:exit"() {
17726
17939
  scopeStack.pop();
17727
17940
  },
17728
- ArrowFunctionExpression: pushFunctionScope,
17941
+ ArrowFunctionExpression: pushScope,
17729
17942
  "ArrowFunctionExpression:exit"() {
17730
17943
  scopeStack.pop();
17731
17944
  },
17732
- CatchClause(node) {
17733
- scopeStack.push(/* @__PURE__ */ new Set());
17734
- if (node.param) declarePattern(node.param);
17945
+ ClassDeclaration: pushScope,
17946
+ "ClassDeclaration:exit"() {
17947
+ scopeStack.pop();
17735
17948
  },
17736
- "CatchClause:exit"() {
17949
+ ClassExpression: pushScope,
17950
+ "ClassExpression:exit"() {
17951
+ scopeStack.pop();
17952
+ },
17953
+ ForStatement: pushScope,
17954
+ "ForStatement:exit"() {
17955
+ scopeStack.pop();
17956
+ },
17957
+ ForInStatement: pushScope,
17958
+ "ForInStatement:exit"() {
17959
+ scopeStack.pop();
17960
+ },
17961
+ ForOfStatement: pushScope,
17962
+ "ForOfStatement:exit"() {
17737
17963
  scopeStack.pop();
17738
17964
  },
17739
- VariableDeclarator(node) {
17740
- declarePattern(node.id);
17965
+ SwitchStatement: pushScope,
17966
+ "SwitchStatement:exit"() {
17967
+ scopeStack.pop();
17968
+ },
17969
+ StaticBlock: pushScope,
17970
+ "StaticBlock:exit"() {
17971
+ scopeStack.pop();
17972
+ },
17973
+ CatchClause: pushScope,
17974
+ "CatchClause:exit"() {
17975
+ scopeStack.pop();
17741
17976
  },
17742
17977
  JSXElement(node) {
17743
17978
  const elName = getJSXElementName(node.openingElement?.name);
@@ -17746,34 +17981,6 @@ function lintFile(filePath, deprecatedMap, antdAliases, antdMajor, only) {
17746
17981
  "JSXElement:exit"() {
17747
17982
  jsxAncestorStack.pop();
17748
17983
  },
17749
- ImportDeclaration(node) {
17750
- const source = node.source.value;
17751
- if (!matchesAntdAlias(source, antdAliases)) return;
17752
- if (node.importKind === "type") return;
17753
- for (const spec of node.specifiers) {
17754
- if (spec.type === "ImportSpecifier") {
17755
- if (spec.importKind === "type") continue;
17756
- const name = spec.imported?.name || spec.local?.name;
17757
- const localName = spec.local?.name || name;
17758
- if (name) importedComponents.add(name);
17759
- if (name && localName) antdImportLocals.set(localName, name);
17760
- }
17761
- if (!only || only === "performance") {
17762
- const isNamespace = spec.type === "ImportNamespaceSpecifier";
17763
- const isDefault = spec.type === "ImportDefaultSpecifier";
17764
- if ((isNamespace || isDefault) && !isLocalePath(source, antdAliases) && !isNonModuleSource(source)) {
17765
- const localName = spec.local?.name ?? "";
17766
- pendingPerformanceIssues.push({
17767
- line: lineOf(node),
17768
- source,
17769
- localName,
17770
- kind: isNamespace ? "namespace" : "default"
17771
- });
17772
- namespaceMemberUsage.set(localName, /* @__PURE__ */ new Set());
17773
- }
17774
- }
17775
- }
17776
- },
17777
17984
  CallExpression(node) {
17778
17985
  if (only && only !== "usage") return;
17779
17986
  if (!enableV5UsageRules) return;
@@ -17800,25 +18007,29 @@ function lintFile(filePath, deprecatedMap, antdAliases, antdMajor, only) {
17800
18007
  }
17801
18008
  }
17802
18009
  if (!only || only === "deprecated") {
17803
- if (compName === "BackTop" && importedComponents.has("BackTop")) {
18010
+ const canonicalComponent = resolveCanonicalComponent(compName);
18011
+ if (canonicalComponent?.full === "BackTop") {
17804
18012
  report("deprecated", "warning", line, "`BackTop` is deprecated, use `FloatButton.BackTop` instead");
17805
18013
  }
17806
- if (compName === "Button.Group" && importedComponents.has("Button")) {
18014
+ if (canonicalComponent?.full === "Button.Group") {
17807
18015
  report("deprecated", "warning", line, "`Button.Group` is deprecated, use `Space.Compact` instead");
17808
18016
  }
17809
- if (compName === "Input.Group" && importedComponents.has("Input")) {
18017
+ if (canonicalComponent?.full === "Input.Group") {
17810
18018
  report("deprecated", "warning", line, "`Input.Group` is deprecated, use `Space.Compact` instead");
17811
18019
  }
17812
- const baseName = compName.includes(".") ? compName.split(".")[0] : compName;
17813
- if (importedComponents.has(baseName) || importedComponents.has(compName)) {
17814
- const deprecations = deprecatedMap.get(compName);
18020
+ if (canonicalComponent) {
18021
+ const componentNotice = deprecatedComponents.get(canonicalComponent.root);
18022
+ if (componentNotice) {
18023
+ report("deprecated", "warning", line, componentNotice);
18024
+ }
18025
+ const deprecations = deprecatedMap.get(canonicalComponent.full);
17815
18026
  if (deprecations) {
17816
18027
  for (const attr of attrs) {
17817
18028
  if (attr.type !== "JSXAttribute") continue;
17818
18029
  const propName = attr.name?.name;
17819
18030
  const dep = deprecations.find((d) => d.prop === propName);
17820
18031
  if (dep) {
17821
- report("deprecated", "warning", lineOf(attr) || line, `${compName} ${dep.message}`);
18032
+ report("deprecated", "warning", lineOf(attr) || line, `${canonicalComponent.full} ${dep.message}`);
17822
18033
  }
17823
18034
  }
17824
18035
  }
@@ -17953,6 +18164,10 @@ function registerLintCommand(program2) {
17953
18164
  const versionInfo = detectVersion(opts.version);
17954
18165
  const store = loadMetadataForVersion(versionInfo.version);
17955
18166
  const deprecatedMap = getDeprecatedProps(store);
18167
+ const deprecatedComponents = getDeprecatedComponents(store, opts.lang);
18168
+ const componentBySubpath = new Map(
18169
+ store.components.map((component) => [normalizeComponentKey(component.name), component.name])
18170
+ );
17956
18171
  const antdAliases = normalizeAntdAliases(cmdOpts.antdAlias);
17957
18172
  let files;
17958
18173
  try {
@@ -17963,7 +18178,7 @@ function registerLintCommand(program2) {
17963
18178
  const allIssues = [];
17964
18179
  const skippedFiles = [];
17965
18180
  for (const file2 of files) {
17966
- const result = lintFile(file2, deprecatedMap, antdAliases, parseInt(versionInfo.majorVersion.slice(1), 10), cmdOpts.only);
18181
+ const result = lintFile(file2, deprecatedMap, deprecatedComponents, componentBySubpath, antdAliases, parseInt(versionInfo.majorVersion.slice(1), 10), cmdOpts.only);
17967
18182
  allIssues.push(...result.issues);
17968
18183
  if (result.skipped) skippedFiles.push(result.skipped);
17969
18184
  }
@@ -18876,32 +19091,6 @@ var V5_TO_V6_STEPS = [
18876
19091
  <Button variant="link">Link</Button>
18877
19092
  <Button variant="text">Text</Button>`
18878
19093
  },
18879
- {
18880
- component: "Button",
18881
- breaking: true,
18882
- description: 'Prop `danger` removed. Use `color="danger"` instead.',
18883
- autoFixable: true,
18884
- codemod: "v6-danger-migration",
18885
- searchPattern: `<Button[^>]*\\bdanger\\b`,
18886
- before: `<Button danger>Delete</Button>
18887
- <Button type="primary" danger>Delete</Button>`,
18888
- after: `<Button color="danger">Delete</Button>
18889
- <Button color="danger" variant="solid">Delete</Button>`,
18890
- migrationGuide: `Search for all Button components with \`danger\` prop. Replace with \`color="danger"\`. If the button also had \`type="primary"\`, add \`variant="solid"\`.`
18891
- },
18892
- {
18893
- component: "Button",
18894
- breaking: true,
18895
- description: 'Prop `ghost` removed. Use `variant="outlined"` instead.',
18896
- autoFixable: true,
18897
- codemod: "v6-ghost-migration",
18898
- searchPattern: `<Button[^>]*\\bghost\\b`,
18899
- before: `<Button ghost>Ghost</Button>
18900
- <Button type="primary" ghost>Ghost Primary</Button>`,
18901
- after: `<Button variant="outlined">Ghost</Button>
18902
- <Button color="primary" variant="outlined">Ghost Primary</Button>`,
18903
- migrationGuide: `Search for all Button components with \`ghost\` prop. Replace with \`variant="outlined"\`. Preserve the color from the original \`type\` prop.`
18904
- },
18905
19094
  {
18906
19095
  component: "Button",
18907
19096
  breaking: false,
@@ -19551,7 +19740,7 @@ function collectAntdEnv(cwd, versionOverride) {
19551
19740
  function collectCliEnv() {
19552
19741
  let cliVersion;
19553
19742
  try {
19554
- cliVersion = "6.6.0";
19743
+ cliVersion = "6.6.1";
19555
19744
  } catch (err) {
19556
19745
  console.error("Failed to get CLI version:", err);
19557
19746
  cliVersion = "unknown";
@@ -20030,11 +20219,15 @@ import { execFile, spawn } from "child_process";
20030
20219
 
20031
20220
  // src/utils/detect-pm.ts
20032
20221
  import { execFileSync as execFileSync4 } from "child_process";
20222
+ var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun", "cnpm", "utoo"];
20033
20223
  var PM_RULES = [
20034
20224
  { pm: "utoo", keywords: [".utoo", "utoo/global"] },
20035
20225
  { pm: "cnpm", keywords: [".cnpm", "cnpm/global"] },
20036
- { pm: "yarn", keywords: ["yarn/global"] },
20037
- { pm: "pnpm", keywords: [".pnpm-global", "pnpm/global"] },
20226
+ {
20227
+ pm: "yarn",
20228
+ keywords: ["yarn/global", "/.yarn/bin/", "/yarn/bin/", "/yarn/data/global/", "/yarn/config/global/"]
20229
+ },
20230
+ { pm: "pnpm", keywords: [".pnpm-global", "pnpm/global", "/pnpm/"] },
20038
20231
  { pm: "bun", keywords: [".bun", "bun/install/global"] }
20039
20232
  ];
20040
20233
  var UPGRADE_COMMANDS = {
@@ -20045,8 +20238,11 @@ var UPGRADE_COMMANDS = {
20045
20238
  cnpm: { cmd: "cnpm", args: ["install", "-g", "@ant-design/cli@latest"] },
20046
20239
  utoo: { cmd: "ut", args: ["install", "-g", "@ant-design/cli@latest"] }
20047
20240
  };
20241
+ function isPackageManager(value) {
20242
+ return typeof value === "string" && PACKAGE_MANAGERS.includes(value);
20243
+ }
20048
20244
  function inferPackageManagerFromPath(binPath) {
20049
- const normalized = binPath.replace(/\\/g, "/");
20245
+ const normalized = binPath.replace(/\\/g, "/").toLowerCase();
20050
20246
  for (const rule of PM_RULES) {
20051
20247
  for (const keyword of rule.keywords) {
20052
20248
  if (normalized.includes(keyword)) return rule.pm;
@@ -20054,7 +20250,15 @@ function inferPackageManagerFromPath(binPath) {
20054
20250
  }
20055
20251
  return "npm";
20056
20252
  }
20057
- function detectPackageManager() {
20253
+ function isAntdCliPath(entryPath) {
20254
+ const normalized = entryPath.replace(/\\/g, "/").toLowerCase();
20255
+ const fileName = normalized.split("/").pop();
20256
+ return fileName === "antd" || fileName === "antd.cmd" || fileName === "antd.exe" || normalized.endsWith("/@ant-design/cli/dist/index.js");
20257
+ }
20258
+ function findAntdBinaryPath(invocationPath = process.argv[1]) {
20259
+ if (invocationPath && isAntdCliPath(invocationPath)) {
20260
+ return invocationPath;
20261
+ }
20058
20262
  const isWin = process.platform === "win32";
20059
20263
  try {
20060
20264
  const binPath = execFileSync4(isWin ? "where" : "which", ["antd"], {
@@ -20062,12 +20266,18 @@ function detectPackageManager() {
20062
20266
  timeout: 5e3
20063
20267
  }).trim();
20064
20268
  if (!binPath) return null;
20065
- const firstPath = binPath.split("\n")[0].trim();
20066
- return inferPackageManagerFromPath(firstPath);
20269
+ return binPath.split(/\r?\n/)[0].trim() || null;
20067
20270
  } catch {
20068
20271
  return null;
20069
20272
  }
20070
20273
  }
20274
+ function detectPackageManager() {
20275
+ const binPath = findAntdBinaryPath();
20276
+ return binPath ? inferPackageManagerFromPath(binPath) : null;
20277
+ }
20278
+
20279
+ // src/utils/update-check.ts
20280
+ import stringWidth3 from "string-width";
20071
20281
 
20072
20282
  // node_modules/conf/dist/source/index.js
20073
20283
  import { isDeepStrictEqual } from "util";
@@ -21745,26 +21955,29 @@ async function fetchLatestVersion() {
21745
21955
  }
21746
21956
  function printUpdateNotice(currentVersion, latestVersion) {
21747
21957
  const line = ` Update available: ${currentVersion} \u2192 ${latestVersion} `;
21958
+ const binPath = findAntdBinaryPath();
21959
+ const packageManager = binPath ? inferPackageManagerFromPath(binPath) : "npm";
21960
+ const upgrade = UPGRADE_COMMANDS[packageManager];
21961
+ const running = binPath ? ` Running: ${binPath} ` : null;
21748
21962
  const cmd = " Run: antd upgrade ";
21749
- const install = " Or: npm i -g @ant-design/cli ";
21750
- const width = Math.max(line.length, cmd.length, install.length);
21751
- const pad = (s) => s + " ".repeat(width - s.length);
21963
+ const install = ` Or: ${upgrade.cmd} ${upgrade.args.join(" ")} `;
21964
+ const lines = [line, running, cmd, install].filter((item) => item !== null);
21965
+ const width = Math.max(...lines.map((item) => stringWidth3(item)));
21966
+ const pad = (s) => s + " ".repeat(width - stringWidth3(s));
21752
21967
  const bar = "\u2500".repeat(width);
21753
21968
  process.stderr.write(`
21754
21969
  \u256D${bar}\u256E
21755
21970
  `);
21756
- process.stderr.write(`\u2502${pad(line)}\u2502
21757
- `);
21758
- process.stderr.write(`\u2502${pad(cmd)}\u2502
21759
- `);
21760
- process.stderr.write(`\u2502${pad(install)}\u2502
21971
+ for (const item of lines) {
21972
+ process.stderr.write(`\u2502${pad(item)}\u2502
21761
21973
  `);
21974
+ }
21762
21975
  process.stderr.write(`\u2570${bar}\u256F
21763
21976
  `);
21764
21977
  }
21765
21978
  async function checkForUpdate() {
21766
21979
  if (process.env.CI || process.env.NO_UPDATE_CHECK) return;
21767
- const currentVersion = "6.6.0";
21980
+ const currentVersion = "6.6.1";
21768
21981
  if (!valid(currentVersion)) return;
21769
21982
  const now = Date.now();
21770
21983
  const cache = cacheStore.get("updateCache") ?? null;
@@ -21815,9 +22028,14 @@ function runUpgrade(cmd, args) {
21815
22028
  });
21816
22029
  }
21817
22030
  function registerUpgradeCommand(program2) {
21818
- program2.command("upgrade").description("Upgrade the CLI to the latest version").action(async () => {
22031
+ program2.command("upgrade").description("Upgrade the CLI to the latest version").addOption(
22032
+ new Option("--package-manager <manager>", "Package manager to use and remember for future upgrades").choices(PACKAGE_MANAGERS)
22033
+ ).action(async (cmdOpts) => {
21819
22034
  const opts = program2.opts();
21820
- const currentVersion = "6.6.0";
22035
+ const currentVersion = "6.6.1";
22036
+ if (cmdOpts.packageManager) {
22037
+ configStore.set("packageManager", cmdOpts.packageManager);
22038
+ }
21821
22039
  let latestVersion;
21822
22040
  try {
21823
22041
  latestVersion = await fetchLatestVersion();
@@ -21872,7 +22090,11 @@ function registerUpgradeCommand(program2) {
21872
22090
  }
21873
22091
  return;
21874
22092
  }
21875
- const pm = detectPackageManager();
22093
+ let pm = cmdOpts.packageManager;
22094
+ if (!pm) {
22095
+ const savedPackageManager = configStore.get("packageManager");
22096
+ pm = isPackageManager(savedPackageManager) ? savedPackageManager : detectPackageManager() ?? void 0;
22097
+ }
21876
22098
  if (!pm) {
21877
22099
  const err = createError(
21878
22100
  ErrorCodes.PM_NOT_FOUND,
@@ -36270,7 +36492,7 @@ function registerMcpCommand(program2) {
36270
36492
  const opts = program2.opts();
36271
36493
  const versionInfo = detectVersion(opts.version);
36272
36494
  const server = new Server(
36273
- { name: "antd", version: "6.6.0" },
36495
+ { name: "antd", version: "6.6.1" },
36274
36496
  { capabilities: { tools: {}, prompts: {} } }
36275
36497
  );
36276
36498
  const handleTool = createToolHandler({
@@ -36949,7 +37171,7 @@ ${wordmarkLines.join("\n")}`;
36949
37171
  }
36950
37172
 
36951
37173
  // src/index.ts
36952
- var CLI_VERSION = "6.6.0";
37174
+ var CLI_VERSION = "6.6.1";
36953
37175
  function createProgram() {
36954
37176
  const program2 = new Command();
36955
37177
  let displayedRootHelp = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/cli",
3
- "version": "6.6.0",
3
+ "version": "6.6.1",
4
4
  "description": "CLI tool for querying antd knowledge and analyzing antd usage in projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,7 +51,7 @@
51
51
  "cfonts": "^3.3.1",
52
52
  "fast-glob": "^3.3.3",
53
53
  "fast-levenshtein": "^3.0.0",
54
- "oxc-parser": "^0.138.0",
54
+ "oxc-parser": "^0.144.0",
55
55
  "semver": "^7.8.0",
56
56
  "string-width": "^8.2.1"
57
57
  },
Binary file