js-code-detector 0.0.51 → 0.0.53

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 (79) hide show
  1. package/dist/cjs/services/DetectService.js +7 -1
  2. package/dist/cjs/services/projectServiceClass/UmiProjectService.js +5 -0
  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.d.ts +3 -0
  6. package/dist/cjs/services/projectServiceClass/VueProjectService.js +32 -6
  7. package/dist/cjs/util/ast_util/AstKit.d.ts +5 -21
  8. package/dist/cjs/util/ast_util/AstKit.js +33 -524
  9. package/dist/cjs/util/ast_util/AstUtil.d.ts +2 -1
  10. package/dist/cjs/util/ast_util/AstUtil.js +14 -9
  11. package/dist/cjs/util/ast_util/getAstKitByFilePath.d.ts +1 -1
  12. package/dist/cjs/util/ast_util/getAstKitByFilePath.js +1 -1
  13. package/dist/cjs/util/ast_util/helper/collectDeclarationIdentifiers.d.ts +2 -0
  14. package/dist/cjs/util/ast_util/helper/collectDeclarationIdentifiers.js +31 -0
  15. package/dist/cjs/util/ast_util/helper/collectDependenceIds.d.ts +2 -0
  16. package/dist/cjs/util/ast_util/helper/collectDependenceIds.js +90 -0
  17. package/dist/cjs/util/ast_util/helper/collectDependenceIdsOfExportMembers.d.ts +2 -0
  18. package/dist/cjs/util/ast_util/helper/collectDependenceIdsOfExportMembers.js +44 -0
  19. package/dist/cjs/util/ast_util/helper/collectEffectId.d.ts +2 -0
  20. package/dist/cjs/util/ast_util/helper/collectEffectId.js +26 -0
  21. package/dist/cjs/util/ast_util/helper/collectExpressionIdentifiersShallow.d.ts +2 -0
  22. package/dist/cjs/util/ast_util/helper/collectExpressionIdentifiersShallow.js +39 -0
  23. package/dist/cjs/util/ast_util/helper/collectHoldingIds.d.ts +4 -0
  24. package/dist/cjs/util/ast_util/helper/collectHoldingIds.js +110 -0
  25. package/dist/cjs/util/ast_util/helper/collectImportDeclarationIdentifiers.d.ts +2 -0
  26. package/dist/cjs/util/ast_util/helper/collectImportDeclarationIdentifiers.js +38 -0
  27. package/dist/cjs/util/ast_util/helper/collectVariableDeclarationIdentifiers.d.ts +2 -0
  28. package/dist/cjs/util/ast_util/helper/collectVariableDeclarationIdentifiers.js +43 -0
  29. package/dist/cjs/util/ast_util/helper/createAstNodeExt.d.ts +40 -0
  30. package/dist/cjs/util/ast_util/helper/createAstNodeExt.js +54 -0
  31. package/dist/cjs/util/ast_util/helper/deepFirstTravel.d.ts +9 -0
  32. package/dist/cjs/util/ast_util/helper/deepFirstTravel.js +142 -0
  33. package/dist/cjs/util/ast_util/helper/deepSearchParamsIdentifier.d.ts +2 -0
  34. package/dist/cjs/util/ast_util/helper/deepSearchParamsIdentifier.js +55 -0
  35. package/dist/cjs/util/ast_util/helper/findOrCreateExportedMember.d.ts +9 -0
  36. package/dist/cjs/util/ast_util/helper/findOrCreateExportedMember.js +32 -0
  37. package/dist/cjs/util/ast_util/helper/findOrCreateImportedMember.d.ts +8 -0
  38. package/dist/cjs/util/ast_util/helper/findOrCreateImportedMember.js +32 -0
  39. package/dist/cjs/util/ast_util/helper/getExportedNameOfAncestor.d.ts +2 -0
  40. package/dist/cjs/util/ast_util/helper/getExportedNameOfAncestor.js +113 -0
  41. package/dist/cjs/util/ast_util/helper/getExportedNameOfDeclarationIdentifier.d.ts +2 -0
  42. package/dist/cjs/util/ast_util/helper/getExportedNameOfDeclarationIdentifier.js +40 -0
  43. package/dist/cjs/util/ast_util/helper/getImpactedNode.d.ts +2 -0
  44. package/dist/cjs/util/ast_util/helper/getImpactedNode.js +50 -0
  45. package/dist/cjs/util/ast_util/helper/getNearestImpactedNode.d.ts +2 -0
  46. package/dist/cjs/util/ast_util/helper/getNearestImpactedNode.js +43 -0
  47. package/dist/cjs/util/ast_util/helper/getNodePath.d.ts +2 -0
  48. package/dist/cjs/util/ast_util/helper/getNodePath.js +27 -0
  49. package/dist/cjs/util/ast_util/helper/getShortNodeMsg.d.ts +2 -0
  50. package/dist/cjs/util/ast_util/helper/getShortNodeMsg.js +38 -0
  51. package/dist/cjs/util/ast_util/helper/getTopScopeNodesByLineNumberRange.d.ts +2 -0
  52. package/dist/cjs/util/ast_util/helper/getTopScopeNodesByLineNumberRange.js +51 -0
  53. package/dist/cjs/util/ast_util/helper/isIdentifierUntracked.d.ts +2 -0
  54. package/dist/cjs/util/ast_util/helper/isIdentifierUntracked.js +39 -0
  55. package/dist/cjs/util/ast_util/helper/isValidArrayNodeCollect.d.ts +2 -0
  56. package/dist/cjs/util/ast_util/helper/isValidArrayNodeCollect.js +27 -0
  57. package/dist/cjs/util/ast_util/helper/isValidNodeCollect.d.ts +2 -0
  58. package/dist/cjs/util/ast_util/helper/isValidNodeCollect.js +27 -0
  59. package/dist/cjs/util/ast_util/helper/syncTravel.d.ts +11 -0
  60. package/dist/cjs/util/ast_util/helper/syncTravel.js +325 -0
  61. package/dist/cjs/util/ast_util/helper/updateImportedAndExportedMember.d.ts +2 -0
  62. package/dist/cjs/util/ast_util/helper/updateImportedAndExportedMember.js +135 -0
  63. package/dist/cjs/util/ast_util/helper/updateLoc.d.ts +6 -0
  64. package/dist/cjs/util/ast_util/helper/updateLoc.js +74 -0
  65. package/dist/cjs/util/project_umi_util/isVueEntryFile.d.ts +1 -0
  66. package/dist/cjs/util/project_umi_util/isVueEntryFile.js +57 -0
  67. package/dist/cjs/util/project_umi_util/tsConfigPathsToWebpackAlias.d.ts +10 -0
  68. package/dist/cjs/util/project_umi_util/tsConfigPathsToWebpackAlias.js +80 -0
  69. package/dist/cjs/util/report_util/filterEffectedCode.d.ts +1 -1
  70. package/dist/cjs/util/report_util/filterEffectedExportMember.d.ts +2 -0
  71. package/dist/cjs/util/report_util/filterEffectedExportMember.js +10 -2
  72. package/dist/cjs/util/report_util/generateGitDiffReport.d.ts +1 -1
  73. package/dist/cjs/util/report_util/resolveImportPath.js +1 -1
  74. package/dist/cjs/util/report_util.d.ts +1 -1
  75. package/dist/cjs/util/shared/getMajorVersion.d.ts +1 -0
  76. package/dist/cjs/util/shared/getMajorVersion.js +37 -0
  77. package/dist/cjs/util/shared/getRepoSupportFlag.d.ts +1 -1
  78. package/dist/cjs/util/shared/getRepoSupportFlag.js +8 -3
  79. package/package.json +1 -1
@@ -44,6 +44,7 @@ var import_UmiProjectService = __toESM(require("./projectServiceClass/UmiProject
44
44
  var import_perf_hooks = require("perf_hooks");
45
45
  var import_cloneRepoWithBranchAndDefault = __toESM(require("../util/git_util/cloneRepoWithBranchAndDefault"));
46
46
  var import_VueProjectService = __toESM(require("./projectServiceClass/VueProjectService"));
47
+ var import_ViteProjectService = __toESM(require("./projectServiceClass/ViteProjectService"));
47
48
  var DetectService = class {
48
49
  constructor(option) {
49
50
  this.directoryInfo = {
@@ -158,7 +159,7 @@ var DetectService = class {
158
159
  await (0, import_execGitDiff.default)(targetDirPath, baseBranch, targetBranch);
159
160
  const repoType = await (0, import_getRepoSupportFlag.getRepoType)((0, import_path.join)(targetDirPath, "package.json"));
160
161
  this.gitInfo.repoType = repoType;
161
- import_utils.logger.info("克隆仓库成功");
162
+ import_utils.logger.info(`克隆仓库成功, repoType: ${repoType}`);
162
163
  }
163
164
  async move() {
164
165
  const repoType = this.gitInfo.repoType;
@@ -172,7 +173,9 @@ var DetectService = class {
172
173
  async projectHandle() {
173
174
  var _a;
174
175
  const { repoType } = this.gitInfo;
176
+ import_utils.logger.info("开始处理项目" + repoType);
175
177
  if (!(0, import_getRepoSupportFlag.isRepoTypeSupported)(repoType)) {
178
+ import_utils.logger.info("不支持的 repoType:" + repoType);
176
179
  return;
177
180
  }
178
181
  if (repoType === "umi") {
@@ -181,6 +184,9 @@ var DetectService = class {
181
184
  if (repoType === "vue2") {
182
185
  this.projectService = new import_VueProjectService.default(this);
183
186
  }
187
+ if (repoType === "vite") {
188
+ this.projectService = new import_ViteProjectService.default(this);
189
+ }
184
190
  await ((_a = this.projectService) == null ? void 0 : _a.run());
185
191
  }
186
192
  formatResult() {
@@ -96,5 +96,10 @@ var UmiProjectService = class {
96
96
  return effectedExportNames.includes(value);
97
97
  });
98
98
  this.outputResult.effectedImportUsage = effectedImportUsage;
99
+ const token = this.detectService.gitInfo.token;
100
+ if (!token) {
101
+ const pwd = (0, import_path.join)(this.detectService.directoryInfo.tmpWorkDir, "..");
102
+ (0, import_fs.writeFileSync)((0, import_path.join)(pwd, "effectedImportUsage.json"), JSON.stringify({ tree: madgeResult == null ? void 0 : madgeResult.tree, projectFileList, possibleEffectedFiles, gitDiffDetailFiles: gitDiffDetail.map((e) => e.filePath), validGitDiffDetail, effectedImportUsage }, null, 2));
103
+ }
99
104
  }
100
105
  };
@@ -0,0 +1,23 @@
1
+ import { GitDiffDetail } from "../../util/format_git_diff_content";
2
+ import { ProjectService } from "../ProjectService";
3
+ import { DetectService } from "../DetectService";
4
+ import { IMadgeInstance } from "../../util/report_util/getMadgeInstance";
5
+ export default class ViteProjectService implements ProjectService {
6
+ detectService: DetectService;
7
+ gitDiffDetail: GitDiffDetail[];
8
+ helpInfo: ProjectService['helpInfo'];
9
+ outputResult: ProjectService['outputResult'];
10
+ viteHelpInfo: {
11
+ madgeResult: IMadgeInstance | null;
12
+ tsConfigPath: string;
13
+ entryFiles: string[];
14
+ extensions: string[];
15
+ };
16
+ constructor(detectService: DetectService);
17
+ run(): Promise<void>;
18
+ parseGitDiffContent(): Promise<void>;
19
+ setAlias(): Promise<void>;
20
+ readSrcDirFilesAndSetEntries(): Promise<void>;
21
+ getMadgeResult(): Promise<void>;
22
+ collectEffectedFiles(): Promise<void>;
23
+ }
@@ -0,0 +1,142 @@
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/services/projectServiceClass/ViteProjectService.ts
30
+ var ViteProjectService_exports = {};
31
+ __export(ViteProjectService_exports, {
32
+ default: () => ViteProjectService
33
+ });
34
+ module.exports = __toCommonJS(ViteProjectService_exports);
35
+ var import_format_git_diff_content = require("../../util/format_git_diff_content");
36
+ var import_fs = require("fs");
37
+ var import_path = require("path");
38
+ var import_constants = require("../../util/constants");
39
+ var import_utils = require("@umijs/utils");
40
+ var import_madge = __toESM(require("madge"));
41
+ var import_collectUpstreamFiles = __toESM(require("../../util/shared/collectUpstreamFiles"));
42
+ var import_createDependenceMap = require("../../util/report_util/createDependenceMap");
43
+ var import_filterEffectedExportMember = __toESM(require("../../util/report_util/filterEffectedExportMember"));
44
+ var import_isVueEntryFile = __toESM(require("../../util/project_umi_util/isVueEntryFile"));
45
+ var import_tsConfigPathsToWebpackAlias = require("../../util/project_umi_util/tsConfigPathsToWebpackAlias");
46
+ var ViteProjectService = class {
47
+ constructor(detectService) {
48
+ this.detectService = detectService;
49
+ this.gitDiffDetail = [];
50
+ this.helpInfo = {
51
+ projectFileList: [],
52
+ parsedAlias: {}
53
+ };
54
+ this.outputResult = {
55
+ effectedImportUsage: [],
56
+ error: null
57
+ };
58
+ this.viteHelpInfo = {
59
+ madgeResult: null,
60
+ tsConfigPath: "",
61
+ entryFiles: [],
62
+ extensions: []
63
+ };
64
+ this.detectService = detectService;
65
+ }
66
+ async run() {
67
+ import_utils.logger.info("格式化 git diff 内容...");
68
+ await this.parseGitDiffContent();
69
+ import_utils.logger.info("获取 Alias 配置...");
70
+ await this.setAlias();
71
+ import_utils.logger.info("读取 src 目录文件...");
72
+ await this.readSrcDirFilesAndSetEntries();
73
+ import_utils.logger.info("获取 madge 结果...");
74
+ await this.getMadgeResult();
75
+ import_utils.logger.info("收集受影响的文件...");
76
+ await this.collectEffectedFiles();
77
+ }
78
+ async parseGitDiffContent() {
79
+ const targetDirPath = this.detectService.directoryInfo.targetBranchDir;
80
+ const diff_txt = (0, import_fs.readFileSync)((0, import_path.join)(targetDirPath, import_constants.gitDiffFileName), "utf-8");
81
+ this.gitDiffDetail = (0, import_format_git_diff_content.formatGitDiffContent)(diff_txt);
82
+ }
83
+ async setAlias() {
84
+ const targetDirPath = this.detectService.directoryInfo.targetBranchDir;
85
+ this.helpInfo.parsedAlias = await (0, import_tsConfigPathsToWebpackAlias.tsConfigPathsToWebpackAlias)({
86
+ tsconfigPath: (0, import_path.join)(targetDirPath, "tsConfig.json"),
87
+ projectRoot: targetDirPath,
88
+ excludeTypeOnly: false
89
+ });
90
+ }
91
+ async readSrcDirFilesAndSetEntries() {
92
+ const targetDirPath = this.detectService.directoryInfo.targetBranchDir;
93
+ const projectFileList = (0, import_utils.readDirFiles)({ dir: (0, import_path.join)(targetDirPath, "src") }).filter((e) => e.filePath.endsWith(".ts") || e.filePath.endsWith(".js"));
94
+ this.viteHelpInfo.entryFiles = projectFileList.filter((file) => (0, import_isVueEntryFile.default)(file.filePath)).map((e) => e.filePath);
95
+ }
96
+ async getMadgeResult() {
97
+ const targetBranchDir = this.detectService.directoryInfo.targetBranchDir;
98
+ const entryFilePath = this.viteHelpInfo.entryFiles;
99
+ const tsConfig = (0, import_path.join)(targetBranchDir, "tsconfig.json");
100
+ const madgeConfig = {
101
+ baseDir: targetBranchDir,
102
+ fileExtensions: ["vue", "ts", "js"],
103
+ tsConfig,
104
+ excludeRegExp: [/node_modules/, /\.d\.ts$/]
105
+ };
106
+ const res = await (0, import_madge.default)(entryFilePath, madgeConfig);
107
+ this.viteHelpInfo.madgeResult = res;
108
+ this.helpInfo.projectFileList = Object.keys(res.tree);
109
+ }
110
+ async collectEffectedFiles() {
111
+ const { parsedAlias } = this.helpInfo;
112
+ const { madgeResult } = this.viteHelpInfo;
113
+ const projectFileList = this.helpInfo.projectFileList;
114
+ const targetBranchDir = this.detectService.directoryInfo.targetBranchDir;
115
+ const absPathPrefix = (0, import_path.join)(targetBranchDir, "/");
116
+ const validModifiedFiles = this.gitDiffDetail.reduce((acc, item) => {
117
+ const { filePath } = item;
118
+ this.helpInfo.projectFileList.includes(filePath) && acc.push(filePath);
119
+ return acc;
120
+ }, []);
121
+ const possibleEffectedFiles = (0, import_collectUpstreamFiles.default)(madgeResult, validModifiedFiles);
122
+ const possibleEffectedFilesFullPath = possibleEffectedFiles.map((file) => (0, import_path.join)(absPathPrefix, file));
123
+ const mapRef = (0, import_createDependenceMap.createExportedNameToReferenceLocalSet)(possibleEffectedFilesFullPath, parsedAlias, absPathPrefix, projectFileList);
124
+ const { import2export, indirectExportMembers } = mapRef;
125
+ const gitDiffDetail = this.gitDiffDetail;
126
+ const validGitDiffDetail = gitDiffDetail.filter((item) => possibleEffectedFiles.includes(item.filePath));
127
+ const effectedExportNames = validGitDiffDetail.map((item) => {
128
+ const { filePath, newBranchLineScope, startLineOfNew } = item;
129
+ const exportedNames = (0, import_filterEffectedExportMember.default)((0, import_path.join)(absPathPrefix, filePath), absPathPrefix, Number(startLineOfNew), Number(startLineOfNew) + Number(newBranchLineScope));
130
+ return exportedNames.map((name) => [filePath, name].join("#"));
131
+ }).flat();
132
+ const effectedImportUsage = [...Object.entries(import2export), ...Object.entries(indirectExportMembers)].filter(([_, value]) => {
133
+ return effectedExportNames.includes(value);
134
+ });
135
+ this.outputResult.effectedImportUsage = effectedImportUsage;
136
+ const token = this.detectService.gitInfo.token;
137
+ if (!token) {
138
+ const pwd = (0, import_path.join)(this.detectService.directoryInfo.tmpWorkDir, "..");
139
+ (0, import_fs.writeFileSync)((0, import_path.join)(pwd, "effectedImportUsage.json"), JSON.stringify({ tree: madgeResult == null ? void 0 : madgeResult.tree, projectFileList, possibleEffectedFiles, gitDiffDetailFiles: gitDiffDetail.map((e) => e.filePath), validGitDiffDetail, effectedImportUsage, ...mapRef }, null, 2));
140
+ }
141
+ }
142
+ };
@@ -12,6 +12,7 @@ export default class VueProjectService implements ProjectService {
12
12
  webpackConfigPath: string;
13
13
  webpackConfigTextLines: string[];
14
14
  entryFiles: string[];
15
+ extensions: string[];
15
16
  };
16
17
  constructor(detectService: DetectService);
17
18
  run(): Promise<void>;
@@ -22,9 +23,11 @@ export default class VueProjectService implements ProjectService {
22
23
  createSimpleWebpackConfig(): {
23
24
  resolve: {
24
25
  alias: Record<string, any>;
26
+ extensions: string[];
25
27
  };
26
28
  };
27
29
  getEntryFiles(): void;
30
+ getWebpackExtensions(): void;
28
31
  getWebpackAlias(): void;
29
32
  getMadgeResult(): Promise<void>;
30
33
  collectEffectedFiles(): Promise<void>;
@@ -58,7 +58,8 @@ var VueProjectService = class {
58
58
  madgeResult: null,
59
59
  webpackConfigPath: "",
60
60
  webpackConfigTextLines: [],
61
- entryFiles: []
61
+ entryFiles: [],
62
+ extensions: []
62
63
  };
63
64
  this.detectService = detectService;
64
65
  }
@@ -82,13 +83,16 @@ var VueProjectService = class {
82
83
  const targetDirPath = this.detectService.directoryInfo.targetBranchDir;
83
84
  this.vueHelpInfo.webpackConfigTextLines = webpackConfigText.split("\n");
84
85
  this.getWebpackAlias();
86
+ this.getWebpackExtensions();
85
87
  this.getEntryFiles();
88
+ import_utils.logger.info("生成简单的 webpack 配置...");
86
89
  const wb = this.createSimpleWebpackConfig();
87
90
  (0, import_fs.writeFileSync)(this.vueHelpInfo.webpackConfigPath = (0, import_path.join)(targetDirPath, "webpack.config.js"), `module.exports = ${JSON.stringify(wb, null, 2)}`, "utf-8");
88
91
  await this.getMadgeResult();
89
92
  }
90
93
  async getWebpackConfigText() {
91
94
  const targetDirPath = this.detectService.directoryInfo.targetBranchDir;
95
+ import_utils.logger.info("执行 npx vue-cli-service inspect");
92
96
  let [err, data] = await (0, import_await_to_js.default)(import_utils.execa.execa(`cd ${targetDirPath} && npx vue-cli-service inspect`, { shell: true }));
93
97
  if (err) {
94
98
  await import_utils.execa.execa(`cd ${targetDirPath} && yarn`, { shell: true });
@@ -103,7 +107,8 @@ var VueProjectService = class {
103
107
  createSimpleWebpackConfig() {
104
108
  return {
105
109
  resolve: {
106
- alias: this.helpInfo.parsedAlias
110
+ alias: this.helpInfo.parsedAlias,
111
+ extensions: this.vueHelpInfo.extensions
107
112
  }
108
113
  };
109
114
  }
@@ -127,7 +132,26 @@ var VueProjectService = class {
127
132
  entryObject = eval(`(${entryLinesJoin})`);
128
133
  this.vueHelpInfo.entryFiles = Object.values({ ...entryObject }).flat();
129
134
  }
135
+ getWebpackExtensions() {
136
+ import_utils.logger.info("获取 webpack extensions...");
137
+ const lines = this.vueHelpInfo.webpackConfigTextLines;
138
+ let extensions = "";
139
+ let extensionsFind = false;
140
+ for (const line of lines) {
141
+ if (!extensionsFind && line.trim().startsWith("extensions:")) {
142
+ extensionsFind = true;
143
+ extensions += line.trim().replace(/^\s*extensions:\s*/, "");
144
+ } else if (extensionsFind && line.trim().startsWith("]")) {
145
+ extensions += line.replace(/,/g, "");
146
+ break;
147
+ } else if (extensionsFind) {
148
+ extensions += line.trim();
149
+ }
150
+ }
151
+ this.vueHelpInfo.extensions = eval(`(${extensions})`);
152
+ }
130
153
  getWebpackAlias() {
154
+ import_utils.logger.info("获取 webpack alias...");
131
155
  const lines = this.vueHelpInfo.webpackConfigTextLines;
132
156
  const aliasLines = [];
133
157
  let aliasFind = false;
@@ -150,8 +174,9 @@ var VueProjectService = class {
150
174
  const entryFilePath = this.vueHelpInfo.entryFiles.map((file) => (0, import_path.join)(targetBranchDir, file));
151
175
  const madgeConfig = {
152
176
  baseDir: this.detectService.directoryInfo.targetBranchDir,
153
- fileExtensions: ["js", "ts", "jsx", "tsx", "vue"],
154
- webpackConfig: this.vueHelpInfo.webpackConfigPath
177
+ fileExtensions: this.vueHelpInfo.extensions.map((ext) => ext.replace(/^\./, "")),
178
+ webpackConfig: this.vueHelpInfo.webpackConfigPath,
179
+ excludeRegExp: [/node_modules/, /\.d\.ts$/]
155
180
  };
156
181
  const res = await (0, import_madge.default)(entryFilePath, madgeConfig);
157
182
  this.vueHelpInfo.madgeResult = res;
@@ -170,7 +195,8 @@ var VueProjectService = class {
170
195
  }, []);
171
196
  const possibleEffectedFiles = (0, import_collectUpstreamFiles.default)(madgeResult, validModifiedFiles);
172
197
  const possibleEffectedFilesFullPath = possibleEffectedFiles.map((file) => (0, import_path.join)(absPathPrefix, file));
173
- const { import2export, indirectExportMembers } = (0, import_createDependenceMap.createExportedNameToReferenceLocalSet)(possibleEffectedFilesFullPath, parsedAlias, absPathPrefix, projectFileList);
198
+ const mapRef = (0, import_createDependenceMap.createExportedNameToReferenceLocalSet)(possibleEffectedFilesFullPath, parsedAlias, absPathPrefix, projectFileList);
199
+ const { import2export, indirectExportMembers } = mapRef;
174
200
  const gitDiffDetail = this.gitDiffDetail;
175
201
  const validGitDiffDetail = gitDiffDetail.filter((item) => possibleEffectedFiles.includes(item.filePath));
176
202
  const effectedExportNames = validGitDiffDetail.map((item) => {
@@ -185,7 +211,7 @@ var VueProjectService = class {
185
211
  const token = this.detectService.gitInfo.token;
186
212
  if (!token) {
187
213
  const pwd = (0, import_path.join)(this.detectService.directoryInfo.tmpWorkDir, "..");
188
- (0, import_fs.writeFileSync)((0, import_path.join)(pwd, "effectedImportUsage.json"), JSON.stringify(effectedImportUsage, null, 2));
214
+ (0, import_fs.writeFileSync)((0, import_path.join)(pwd, "effectedImportUsage.json"), JSON.stringify({ webpackConfig: this.createSimpleWebpackConfig(), tree: madgeResult == null ? void 0 : madgeResult.tree, projectFileList, possibleEffectedFiles, gitDiffDetailFiles: gitDiffDetail.map((e) => e.filePath), validGitDiffDetail, effectedImportUsage, ...mapRef }, null, 2));
189
215
  }
190
216
  }
191
217
  };
@@ -1,30 +1,14 @@
1
1
  import { AstNode } from "./AstUtil";
2
2
  export declare class AstUtil {
3
- static invalidNodeKey: string[];
4
3
  static EXPORT_DECLARATION_TYPES: readonly ["FunctionDeclaration", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSTypeAliasDeclaration", "ClassDeclaration"];
5
4
  static windowProperties: string[];
6
5
  static intrinsicElements: string[];
7
- static standardAttributes: string[];
8
- static FUNCTION_TYPES: string[];
6
+ static isUntrackedId(id: AstNode): boolean;
9
7
  static getNodePath(node: AstNode): string;
10
8
  static getShortNodeMsg(node: AstNode, hideParentProperty?: boolean): string;
9
+ static findExportedMembersNameFromAncestors(node: AstNode | undefined | null): string[];
10
+ static getAncestorsFromBirth(occupationId: AstNode, sourceId: AstNode): AstNode[];
11
+ static getNearestImpactedNode(ancestors: AstNode[]): AstNode | undefined;
11
12
  static getTopScopeNodesByLineNumberRange(mapFileLineToNodeSet: Map<number, Set<AstNode>>, lineNumberStart: number, lineNumberEnd: number, loose?: boolean): AstNode[];
12
- private static isValidNodeCollect;
13
- private static isValidArrayNodeCollect;
14
- private static collectEffectId;
15
- private static findOrCreateImportedMember;
16
- private static findOrCreateExportedMember;
17
- private static updateImportedAndExportedMember;
18
- private static deepSearchParamsIdentifier;
19
- private static collectDependenceIdsOfExportMembers;
20
- private static collectExpressionIdentifiersShallow;
21
- private static _collectExpressionIdentifiersShallow;
22
- private static collectDependenceIds;
23
- private static updateLoc;
24
- private static collectVariableDeclarationIdentifiers;
25
- private static collectDeclarationIdentifiers;
26
- private static collectImportDeclarationIdentifiers;
27
- private static collectHoldingIds;
28
- static deepFirstTravel(node: AstNode, filePath: string, mapUuidToNode: Map<string, AstNode>, mapFileLineToNodeSet: Map<number, Set<AstNode>>, mapPathToNodeSet: Map<string, Set<AstNode>>, stopTravelCallback?: (node: AstNode) => boolean | void): AstNode | undefined;
29
- private static _deepFirstTravel;
13
+ static deepFirstTravel(node: AstNode, filePath: string, mapUuidToNode: Map<string, AstNode>, mapFileLineToNodeSet: Map<number, Set<AstNode>>, mapPathToNodeSet: Map<string, Set<AstNode>>, stopTravelCallback?: (node: AstNode) => boolean | void): void;
30
14
  }