js-code-detector 0.0.52 → 0.0.54

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.
Files changed (78) hide show
  1. package/dist/cjs/index.d.ts +1 -1
  2. package/dist/cjs/services/DetectService.js +7 -1
  3. package/dist/cjs/services/projectServiceClass/ViteProjectService.d.ts +23 -0
  4. package/dist/cjs/services/projectServiceClass/ViteProjectService.js +142 -0
  5. package/dist/cjs/services/projectServiceClass/VueProjectService.js +1 -1
  6. package/dist/cjs/util/ast_util/AstKit.d.ts +5 -21
  7. package/dist/cjs/util/ast_util/AstKit.js +33 -524
  8. package/dist/cjs/util/ast_util/AstUtil.d.ts +2 -1
  9. package/dist/cjs/util/ast_util/AstUtil.js +14 -9
  10. package/dist/cjs/util/ast_util/getAstKitByFilePath.d.ts +1 -1
  11. package/dist/cjs/util/ast_util/getAstKitByFilePath.js +1 -1
  12. package/dist/cjs/util/ast_util/helper/collectDeclarationIdentifiers.d.ts +2 -0
  13. package/dist/cjs/util/ast_util/helper/collectDeclarationIdentifiers.js +31 -0
  14. package/dist/cjs/util/ast_util/helper/collectDependenceIds.d.ts +2 -0
  15. package/dist/cjs/util/ast_util/helper/collectDependenceIds.js +90 -0
  16. package/dist/cjs/util/ast_util/helper/collectDependenceIdsOfExportMembers.d.ts +2 -0
  17. package/dist/cjs/util/ast_util/helper/collectDependenceIdsOfExportMembers.js +44 -0
  18. package/dist/cjs/util/ast_util/helper/collectEffectId.d.ts +2 -0
  19. package/dist/cjs/util/ast_util/helper/collectEffectId.js +26 -0
  20. package/dist/cjs/util/ast_util/helper/collectExpressionIdentifiersShallow.d.ts +2 -0
  21. package/dist/cjs/util/ast_util/helper/collectExpressionIdentifiersShallow.js +39 -0
  22. package/dist/cjs/util/ast_util/helper/collectHoldingIds.d.ts +4 -0
  23. package/dist/cjs/util/ast_util/helper/collectHoldingIds.js +110 -0
  24. package/dist/cjs/util/ast_util/helper/collectImportDeclarationIdentifiers.d.ts +2 -0
  25. package/dist/cjs/util/ast_util/helper/collectImportDeclarationIdentifiers.js +38 -0
  26. package/dist/cjs/util/ast_util/helper/collectVariableDeclarationIdentifiers.d.ts +2 -0
  27. package/dist/cjs/util/ast_util/helper/collectVariableDeclarationIdentifiers.js +43 -0
  28. package/dist/cjs/util/ast_util/helper/createAstNodeExt.d.ts +40 -0
  29. package/dist/cjs/util/ast_util/helper/createAstNodeExt.js +54 -0
  30. package/dist/cjs/util/ast_util/helper/deepFirstTravel.d.ts +9 -0
  31. package/dist/cjs/util/ast_util/helper/deepFirstTravel.js +142 -0
  32. package/dist/cjs/util/ast_util/helper/deepSearchParamsIdentifier.d.ts +2 -0
  33. package/dist/cjs/util/ast_util/helper/deepSearchParamsIdentifier.js +55 -0
  34. package/dist/cjs/util/ast_util/helper/findOrCreateExportedMember.d.ts +9 -0
  35. package/dist/cjs/util/ast_util/helper/findOrCreateExportedMember.js +32 -0
  36. package/dist/cjs/util/ast_util/helper/findOrCreateImportedMember.d.ts +8 -0
  37. package/dist/cjs/util/ast_util/helper/findOrCreateImportedMember.js +32 -0
  38. package/dist/cjs/util/ast_util/helper/getExportedNameOfAncestor.d.ts +2 -0
  39. package/dist/cjs/util/ast_util/helper/getExportedNameOfAncestor.js +113 -0
  40. package/dist/cjs/util/ast_util/helper/getExportedNameOfDeclarationIdentifier.d.ts +2 -0
  41. package/dist/cjs/util/ast_util/helper/getExportedNameOfDeclarationIdentifier.js +40 -0
  42. package/dist/cjs/util/ast_util/helper/getImpactedNode.d.ts +2 -0
  43. package/dist/cjs/util/ast_util/helper/getImpactedNode.js +50 -0
  44. package/dist/cjs/util/ast_util/helper/getNearestImpactedNode.d.ts +2 -0
  45. package/dist/cjs/util/ast_util/helper/getNearestImpactedNode.js +43 -0
  46. package/dist/cjs/util/ast_util/helper/getNodePath.d.ts +2 -0
  47. package/dist/cjs/util/ast_util/helper/getNodePath.js +27 -0
  48. package/dist/cjs/util/ast_util/helper/getShortNodeMsg.d.ts +2 -0
  49. package/dist/cjs/util/ast_util/helper/getShortNodeMsg.js +38 -0
  50. package/dist/cjs/util/ast_util/helper/getTopScopeNodesByLineNumberRange.d.ts +2 -0
  51. package/dist/cjs/util/ast_util/helper/getTopScopeNodesByLineNumberRange.js +51 -0
  52. package/dist/cjs/util/ast_util/helper/isIdentifierUntracked.d.ts +2 -0
  53. package/dist/cjs/util/ast_util/helper/isIdentifierUntracked.js +39 -0
  54. package/dist/cjs/util/ast_util/helper/isValidArrayNodeCollect.d.ts +2 -0
  55. package/dist/cjs/util/ast_util/helper/isValidArrayNodeCollect.js +27 -0
  56. package/dist/cjs/util/ast_util/helper/isValidNodeCollect.d.ts +2 -0
  57. package/dist/cjs/util/ast_util/helper/isValidNodeCollect.js +27 -0
  58. package/dist/cjs/util/ast_util/helper/syncTravel.d.ts +11 -0
  59. package/dist/cjs/util/ast_util/helper/syncTravel.js +325 -0
  60. package/dist/cjs/util/ast_util/helper/updateImportedAndExportedMember.d.ts +2 -0
  61. package/dist/cjs/util/ast_util/helper/updateImportedAndExportedMember.js +135 -0
  62. package/dist/cjs/util/ast_util/helper/updateLoc.d.ts +6 -0
  63. package/dist/cjs/util/ast_util/helper/updateLoc.js +74 -0
  64. package/dist/cjs/util/project_umi_util/isVueEntryFile.d.ts +1 -0
  65. package/dist/cjs/util/project_umi_util/isVueEntryFile.js +57 -0
  66. package/dist/cjs/util/project_umi_util/tsConfigPathsToWebpackAlias.d.ts +10 -0
  67. package/dist/cjs/util/project_umi_util/tsConfigPathsToWebpackAlias.js +80 -0
  68. package/dist/cjs/util/report_util/filterEffectedCode.d.ts +1 -1
  69. package/dist/cjs/util/report_util/filterEffectedExportMember.d.ts +2 -0
  70. package/dist/cjs/util/report_util/filterEffectedExportMember.js +9 -1
  71. package/dist/cjs/util/report_util/generateGitDiffReport.d.ts +1 -1
  72. package/dist/cjs/util/report_util.d.ts +1 -1
  73. package/dist/cjs/util/shared/getMajorVersion.d.ts +1 -0
  74. package/dist/cjs/util/shared/getMajorVersion.js +37 -0
  75. package/dist/cjs/util/shared/getRepoSupportFlag.d.ts +1 -1
  76. package/dist/cjs/util/shared/getRepoSupportFlag.js +8 -3
  77. package/dist/cjs/util/shared/gitDiffTool.d.ts +1 -1
  78. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/ast_util/helper/updateLoc.ts
30
+ var updateLoc_exports = {};
31
+ __export(updateLoc_exports, {
32
+ default: () => updateLoc
33
+ });
34
+ module.exports = __toCommonJS(updateLoc_exports);
35
+ var import_getNodePath = __toESM(require("./getNodePath"));
36
+ function updateLoc(astNode, extra) {
37
+ var _a, _b, _c, _d, _e, _f, _g;
38
+ const { _util, type, name } = astNode;
39
+ const { mapUuidToNode, mapFileLineToNodeSet, mapPathToNodeSet } = extra;
40
+ const { nodeCollection, filePath, parent } = _util;
41
+ _util.startLine = Math.min(...nodeCollection.map((n) => {
42
+ var _a2, _b2;
43
+ return (_b2 = (_a2 = n.loc) == null ? void 0 : _a2.start) == null ? void 0 : _b2.line;
44
+ }), (_a = astNode.loc) == null ? void 0 : _a.start.line);
45
+ _util.endLine = Math.max(...nodeCollection.map((n) => {
46
+ var _a2, _b2;
47
+ return (_b2 = (_a2 = n.loc) == null ? void 0 : _a2.end) == null ? void 0 : _b2.line;
48
+ }), (_b = astNode.loc) == null ? void 0 : _b.end.line);
49
+ _util.startColumn = ((_c = astNode.loc) == null ? void 0 : _c.start.column) ?? Math.min(...nodeCollection.map((n) => {
50
+ var _a2, _b2;
51
+ return (_b2 = (_a2 = n.loc) == null ? void 0 : _a2.start) == null ? void 0 : _b2.column;
52
+ }), (_d = astNode.loc) == null ? void 0 : _d.start.column);
53
+ _util.endColumn = ((_e = astNode.loc) == null ? void 0 : _e.end.column) ?? Math.max(...nodeCollection.map((n) => {
54
+ var _a2, _b2;
55
+ return (_b2 = (_a2 = n.loc) == null ? void 0 : _a2.end) == null ? void 0 : _b2.column;
56
+ }), (_f = astNode.loc) == null ? void 0 : _f.end.column);
57
+ _util.uuid = `${filePath}@${type}:${name}「${_util.startLine}:${_util.startColumn},${_util.endLine}:${_util.endColumn}」`;
58
+ mapUuidToNode.set(_util.uuid, astNode);
59
+ for (let i = _util.startLine; i <= _util.endLine; i++) {
60
+ mapFileLineToNodeSet.set(i, mapFileLineToNodeSet.get(i) || /* @__PURE__ */ new Set());
61
+ (_g = mapFileLineToNodeSet.get(i)) == null ? void 0 : _g.add(astNode);
62
+ }
63
+ if (astNode.type === "Program") {
64
+ mapUuidToNode.set(astNode.type, astNode);
65
+ }
66
+ if (parent === null) {
67
+ nodeCollection.forEach((n) => {
68
+ var _a2;
69
+ const path = (0, import_getNodePath.default)(n);
70
+ mapPathToNodeSet.set(path, mapPathToNodeSet.get(path) || /* @__PURE__ */ new Set());
71
+ (_a2 = mapPathToNodeSet.get(path)) == null ? void 0 : _a2.add(n);
72
+ });
73
+ }
74
+ }
@@ -0,0 +1 @@
1
+ export default function isVueEntryFile(filePath: string): boolean;
@@ -0,0 +1,57 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/project_umi_util/isVueEntryFile.ts
30
+ var isVueEntryFile_exports = {};
31
+ __export(isVueEntryFile_exports, {
32
+ default: () => isVueEntryFile
33
+ });
34
+ module.exports = __toCommonJS(isVueEntryFile_exports);
35
+ var import_getAstKitByFilePath = __toESM(require("../ast_util/getAstKitByFilePath"));
36
+ function isVueEntryFile(filePath) {
37
+ let astKit = null;
38
+ try {
39
+ astKit = (0, import_getAstKitByFilePath.default)(filePath);
40
+ } catch (e) {
41
+ console.error("isVueEntryFile", e, filePath);
42
+ return false;
43
+ }
44
+ const programNode = astKit.mapUuidToNode.get("Program");
45
+ if (!programNode)
46
+ return false;
47
+ const { children } = programNode._util;
48
+ return children.some((child) => isMountStatement(child));
49
+ }
50
+ function isMountStatement(astNode) {
51
+ var _a;
52
+ return astNode.type === "ExpressionStatement" && ((_a = astNode.expression) == null ? void 0 : _a.type) === "CallExpression" && (isMemberExpressionOfMountName(astNode.expression.callee) || astNode.expression.callee.name === "mount");
53
+ }
54
+ function isMemberExpressionOfMountName(astNode) {
55
+ var _a;
56
+ return astNode.type === "MemberExpression" && ((_a = astNode.property) == null ? void 0 : _a.name) === "mount";
57
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * TS Config paths 转 Webpack alias(完美适配你的配置场景)
3
+ * @param options 转换配置
4
+ * @returns Webpack resolve.alias 配置
5
+ */
6
+ export declare function tsConfigPathsToWebpackAlias(options?: {
7
+ tsconfigPath?: string;
8
+ projectRoot?: string;
9
+ excludeTypeOnly?: boolean;
10
+ }): Promise<Record<string, string>>;
@@ -0,0 +1,80 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/project_umi_util/tsConfigPathsToWebpackAlias.ts
30
+ var tsConfigPathsToWebpackAlias_exports = {};
31
+ __export(tsConfigPathsToWebpackAlias_exports, {
32
+ tsConfigPathsToWebpackAlias: () => tsConfigPathsToWebpackAlias
33
+ });
34
+ module.exports = __toCommonJS(tsConfigPathsToWebpackAlias_exports);
35
+ var fs = __toESM(require("fs"));
36
+ var path = __toESM(require("path"));
37
+ var import_utils = require("@umijs/utils");
38
+ async function tsConfigPathsToWebpackAlias(options = {}) {
39
+ const {
40
+ tsconfigPath = path.resolve(process.cwd(), "tsconfig.json"),
41
+ projectRoot = path.dirname(tsconfigPath),
42
+ excludeTypeOnly = true
43
+ } = options;
44
+ if (!fs.existsSync(tsconfigPath)) {
45
+ throw new Error(`未找到 tsconfig.json 文件:${tsconfigPath}`);
46
+ }
47
+ const tsconfig = await import_utils.tsconfigPaths.loadConfig(projectRoot);
48
+ const { paths = {}, baseUrl = "." } = tsconfig.compilerOptions || {};
49
+ const resolvedBaseUrl = path.isAbsolute(baseUrl) ? baseUrl : path.resolve(projectRoot, baseUrl);
50
+ const alias = {};
51
+ Object.entries(paths).forEach(([tsPath, tsPathTargets]) => {
52
+ if (excludeTypeOnly && /@types\/.+/.test(tsPath)) {
53
+ return;
54
+ }
55
+ tsPathTargets.forEach((targetPath) => {
56
+ const isWildcard = tsPath.endsWith("/*");
57
+ const targetIsWildcard = targetPath.endsWith("/*");
58
+ if (isWildcard !== targetIsWildcard) {
59
+ console.warn(`跳过无效映射:${tsPath} -> ${targetPath}(通配符不一致)`);
60
+ return;
61
+ }
62
+ const aliasKey = isWildcard ? tsPath.slice(0, -2) : tsPath;
63
+ let aliasValue;
64
+ if (targetPath.startsWith("node_modules/")) {
65
+ aliasValue = path.resolve(projectRoot, targetPath);
66
+ } else if (path.isAbsolute(targetPath)) {
67
+ aliasValue = targetPath;
68
+ } else {
69
+ const resolvedTarget = isWildcard ? targetPath.slice(0, -2) : targetPath;
70
+ aliasValue = path.resolve(resolvedBaseUrl, resolvedTarget);
71
+ }
72
+ alias[aliasKey] = aliasValue;
73
+ });
74
+ });
75
+ return alias;
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ tsConfigPathsToWebpackAlias
80
+ });
@@ -7,7 +7,7 @@ export default function filterEffectedCode(reports: ReturnType<typeof createDete
7
7
  usages: string[];
8
8
  } | {
9
9
  filePath: string;
10
- type: "delete" | "modify";
10
+ type: "modify" | "delete";
11
11
  effectedExports: string[];
12
12
  usages: string[];
13
13
  })[];
@@ -1 +1,3 @@
1
+ import { AstNode } from "../ast_util/AstUtil";
1
2
  export default function filterEffectedExportMember(filePath: string, absPathPrefix: string, startLine: number, endLine: number): string[];
3
+ export declare function extractEffectedExportMemberByLineRange(mapFileLineToNodeSet: Map<number, Set<AstNode>>, startLine: number, endLine: number, filePath: string): string[];
@@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/util/report_util/filterEffectedExportMember.ts
30
30
  var filterEffectedExportMember_exports = {};
31
31
  __export(filterEffectedExportMember_exports, {
32
- default: () => filterEffectedExportMember
32
+ default: () => filterEffectedExportMember,
33
+ extractEffectedExportMemberByLineRange: () => extractEffectedExportMemberByLineRange
33
34
  });
34
35
  module.exports = __toCommonJS(filterEffectedExportMember_exports);
35
36
  var import_getAstKitByFilePath = __toESM(require("../ast_util/getAstKitByFilePath"));
@@ -37,6 +38,9 @@ var import_AstUtil = __toESM(require("../ast_util/AstUtil"));
37
38
  function filterEffectedExportMember(filePath, absPathPrefix, startLine, endLine) {
38
39
  const astKit = (0, import_getAstKitByFilePath.default)(filePath, absPathPrefix, (travelNode) => ["VElement", "ImportDeclaration", "ExportAllDeclaration", "ExportNamedDeclaration", "ExportDefaultDeclaration"].includes(travelNode.type));
39
40
  const { mapFileLineToNodeSet } = astKit;
41
+ return extractEffectedExportMemberByLineRange(mapFileLineToNodeSet, startLine, endLine, filePath);
42
+ }
43
+ function extractEffectedExportMemberByLineRange(mapFileLineToNodeSet, startLine, endLine, filePath) {
40
44
  const topScopeNodes = import_AstUtil.default.getTopScopeNodesByLineNumberRange(mapFileLineToNodeSet, startLine, endLine);
41
45
  const exportMembers = topScopeNodes.map((node) => import_AstUtil.default.findExportedMembersNameFromAncestors(node)).flat();
42
46
  const res = [...new Set(exportMembers)];
@@ -45,3 +49,7 @@ function filterEffectedExportMember(filePath, absPathPrefix, startLine, endLine)
45
49
  }
46
50
  return res;
47
51
  }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ extractEffectedExportMemberByLineRange
55
+ });
@@ -26,7 +26,7 @@ export declare function generateGitDiffReport(arg: {
26
26
  effectsDownstream: string[];
27
27
  }[];
28
28
  }[];
29
- type: "add" | "delete" | "modify";
29
+ type: "modify" | "add" | "delete";
30
30
  filesDependsOnMe: string[];
31
31
  undefinedIdentifiers: string[];
32
32
  filePath: string;
@@ -37,7 +37,7 @@ export declare function createDetectReport(arg: Arg): {
37
37
  effectsDownstream: string[];
38
38
  }[];
39
39
  }[];
40
- type: "add" | "delete" | "modify";
40
+ type: "modify" | "add" | "delete";
41
41
  filesDependsOnMe: string[];
42
42
  undefinedIdentifiers: string[];
43
43
  filePath: string;
@@ -0,0 +1 @@
1
+ export declare function getMajorVersion(version: string): number;
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/shared/getMajorVersion.ts
20
+ var getMajorVersion_exports = {};
21
+ __export(getMajorVersion_exports, {
22
+ getMajorVersion: () => getMajorVersion
23
+ });
24
+ module.exports = __toCommonJS(getMajorVersion_exports);
25
+ var import_utils = require("@umijs/utils");
26
+ function getMajorVersion(version) {
27
+ const strippedVersion = version.replace(/^[\^~]/, "");
28
+ const cleanedVersion = import_utils.semver.clean(strippedVersion);
29
+ if (!cleanedVersion) {
30
+ throw new Error(`无效的版本号格式:${version}`);
31
+ }
32
+ return import_utils.semver.major(cleanedVersion);
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ getMajorVersion
37
+ });
@@ -1,2 +1,2 @@
1
1
  export declare function isRepoTypeSupported(repoType: string): boolean;
2
- export declare function getRepoType(jsonPath: string): "umi" | "vue2" | "unknown";
2
+ export declare function getRepoType(jsonPath: string): "umi" | "vue2" | "vite" | "unknown";
@@ -25,11 +25,12 @@ __export(getRepoSupportFlag_exports, {
25
25
  module.exports = __toCommonJS(getRepoSupportFlag_exports);
26
26
  var import_fs = require("fs");
27
27
  var import_utils = require("@umijs/utils");
28
+ var import_getMajorVersion = require("./getMajorVersion");
28
29
  function isRepoTypeSupported(repoType) {
29
- return ["umi", "vue2"].includes(repoType);
30
+ return ["umi", "vue2", "vite"].includes(repoType);
30
31
  }
31
32
  function getRepoType(jsonPath) {
32
- var _a, _b, _c;
33
+ var _a, _b, _c, _d;
33
34
  const isExist = (0, import_fs.existsSync)(jsonPath);
34
35
  if (!isExist)
35
36
  return "unknown";
@@ -41,7 +42,11 @@ function getRepoType(jsonPath) {
41
42
  if ((_a = packageJsonObj == null ? void 0 : packageJsonObj.dependencies) == null ? void 0 : _a["@umijs/max"]) {
42
43
  return "umi";
43
44
  }
44
- if (((_b = packageJsonObj == null ? void 0 : packageJsonObj.dependencies) == null ? void 0 : _b["@vue/cli-service"]) || ((_c = packageJsonObj == null ? void 0 : packageJsonObj.devDependencies) == null ? void 0 : _c["@vue/cli-service"])) {
45
+ if (((_b = packageJsonObj == null ? void 0 : packageJsonObj.dependencies) == null ? void 0 : _b["vite"]) || ((_c = packageJsonObj == null ? void 0 : packageJsonObj.devDependencies) == null ? void 0 : _c["vite"])) {
46
+ return "vite";
47
+ }
48
+ const vueVersion = (_d = packageJsonObj == null ? void 0 : packageJsonObj.dependencies) == null ? void 0 : _d["vue"];
49
+ if (vueVersion && (0, import_getMajorVersion.getMajorVersion)(vueVersion) === 2) {
45
50
  return "vue2";
46
51
  }
47
52
  } catch (e) {
@@ -26,7 +26,7 @@ export declare function gitDiffTool(arg: {
26
26
  effectsDownstream: string[];
27
27
  }[];
28
28
  }[];
29
- type: "add" | "delete" | "modify";
29
+ type: "modify" | "add" | "delete";
30
30
  filesDependsOnMe: string[];
31
31
  undefinedIdentifiers: string[];
32
32
  filePath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-code-detector",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",