js-code-detector 0.0.48 → 0.0.50
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/dist/cjs/index.d.ts +0 -43
- package/dist/cjs/index.js +3 -25
- package/dist/cjs/services/DetectService.d.ts +1 -1
- package/dist/cjs/services/DetectService.js +11 -6
- package/dist/cjs/services/projectServiceClass/UmiProjectService.js +3 -3
- package/dist/cjs/util/ast_util/AstFeatUtil.js +2 -4
- package/dist/cjs/util/ast_util/AstKit.d.ts +24 -0
- package/dist/cjs/util/ast_util/AstKit.js +345 -0
- package/dist/cjs/util/ast_util/AstUtil.d.ts +7 -7
- package/dist/cjs/util/ast_util/AstUtil.js +9 -11
- package/dist/cjs/util/ast_util/SHARED_CONSTANTS.d.ts +3 -0
- package/dist/cjs/util/ast_util/SHARED_CONSTANTS.js +35 -0
- package/dist/cjs/util/constants.d.ts +1 -0
- package/dist/cjs/util/constants.js +5 -2
- package/dist/cjs/util/{shared/gitUtil.d.ts → git_util/cloneRepoWithBranchAndDefault.d.ts} +1 -5
- package/dist/cjs/util/{shared/gitUtil.js → git_util/cloneRepoWithBranchAndDefault.js} +5 -25
- package/dist/cjs/util/git_util/execGitDiff.d.ts +4 -0
- package/dist/cjs/util/git_util/execGitDiff.js +39 -0
- package/dist/cjs/util/git_util/getGitRepositoryAndBranch.d.ts +4 -0
- package/dist/cjs/util/{report_util/getFileDepends.js → git_util/getGitRepositoryAndBranch.js} +15 -18
- package/dist/cjs/util/{parseGitLabDiffUril.js → git_util/parseGitLabDiffUril.js} +2 -2
- package/dist/cjs/util/{shared → project_umi_util}/umi4ProjectUtil.js +1 -1
- package/dist/cjs/util/{shared → project_umi_util}/vueProjectUtil.js +1 -1
- package/dist/cjs/util/report_util/createDependenceMap.js +3 -3
- package/dist/cjs/util/report_util/filterEffectedCode.d.ts +1 -1
- package/dist/cjs/util/report_util/generateGitDiffReport.d.ts +1 -1
- package/dist/cjs/util/report_util/generateGitDiffReport.js +2 -2
- package/dist/cjs/util/{ast_util/filePathResolver.d.ts → report_util/resolveImportPath.d.ts} +1 -1
- package/dist/cjs/util/{ast_util/filePathResolver.js → report_util/resolveImportPath.js} +5 -9
- package/dist/cjs/util/{createRandomStr.js → shared/createRandomStr.js} +1 -1
- package/dist/cjs/util/shared/getRepoSupportFlag.d.ts +0 -2
- package/dist/cjs/util/shared/getRepoSupportFlag.js +0 -17
- package/dist/cjs/util/shared/gitDiffTool.d.ts +0 -40
- package/dist/cjs/util/shared/gitDiffTool.js +7 -116
- package/package.json +5 -1
- package/dist/cjs/util/madge_util.d.ts +0 -12
- package/dist/cjs/util/madge_util.js +0 -120
- package/dist/cjs/util/report_util/getFileDepends.d.ts +0 -1
- /package/dist/cjs/util/{parseGitLabDiffUril.d.ts → git_util/parseGitLabDiffUril.d.ts} +0 -0
- /package/dist/cjs/util/{shared → project_umi_util}/umi4ProjectUtil.d.ts +0 -0
- /package/dist/cjs/util/{shared → project_umi_util}/vueProjectUtil.d.ts +0 -0
- /package/dist/cjs/util/{createRandomStr.d.ts → shared/createRandomStr.d.ts} +0 -0
|
@@ -29,128 +29,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/util/shared/gitDiffTool.ts
|
|
30
30
|
var gitDiffTool_exports = {};
|
|
31
31
|
__export(gitDiffTool_exports, {
|
|
32
|
-
cloneGitRepoAndGetDiff: () => cloneGitRepoAndGetDiff,
|
|
33
32
|
gitDiffTool: () => gitDiffTool
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(gitDiffTool_exports);
|
|
36
|
-
var import_parseGitLabDiffUril = require("../parseGitLabDiffUril");
|
|
37
35
|
var import_utils = require("@umijs/utils");
|
|
38
36
|
var import_await_to_js = __toESM(require("await-to-js"));
|
|
39
37
|
var import_constants = require("../constants");
|
|
40
38
|
var import_handleExecaError = require("./handleExecaError");
|
|
41
39
|
var import_getRepoSupportFlag = require("./getRepoSupportFlag");
|
|
42
40
|
var import_path = require("path");
|
|
43
|
-
var import_umi4ProjectUtil = require("
|
|
41
|
+
var import_umi4ProjectUtil = require("../project_umi_util/umi4ProjectUtil");
|
|
44
42
|
var import_generateGitDiffReport = require("../report_util/generateGitDiffReport");
|
|
45
|
-
var import_vueProjectUtil = require("
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var import_format_git_diff_content = require("../format_git_diff_content");
|
|
49
|
-
var import_gitUtil = require("./gitUtil");
|
|
50
|
-
var import_perf_hooks = require("perf_hooks");
|
|
51
|
-
var import_createDependenceMap = require("../report_util/createDependenceMap");
|
|
52
|
-
var import_collectUpstreamFiles = __toESM(require("./collectUpstreamFiles"));
|
|
53
|
-
var import_filterEffectedCode = __toESM(require("../report_util/filterEffectedCode"));
|
|
54
|
-
var import_report_util = require("../report_util");
|
|
55
|
-
var import_createRandomStr = __toESM(require("../createRandomStr"));
|
|
56
|
-
async function cloneGitRepoAndGetDiff(gitRepoUrl, branchName, extra = {}) {
|
|
57
|
-
import_perf_hooks.performance.mark("stage 0");
|
|
58
|
-
const { token, jsonKeys = ["upstreamDependenceJson"] } = extra;
|
|
59
|
-
const today = (0, import_createRandomStr.default)();
|
|
60
|
-
import_utils.logger.ready("准备生成临时工作目录...");
|
|
61
|
-
const [err] = await (0, import_await_to_js.default)(import_utils.execa.execa(`rm -rf ${today}`, { shell: true }));
|
|
62
|
-
if (err) {
|
|
63
|
-
import_utils.logger.error("临时目录删除失败");
|
|
64
|
-
}
|
|
65
|
-
let stderr, failed;
|
|
66
|
-
({ stderr, failed } = await import_utils.execa.execa(`mkdir -p ${today}`, { shell: true }));
|
|
67
|
-
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
68
|
-
import_utils.logger.info("临时目录建立完成");
|
|
69
|
-
let upstreamDependenceJson = {};
|
|
70
|
-
let dependenceJson = {
|
|
71
|
-
indirectExportMembers: {},
|
|
72
|
-
import2export: {},
|
|
73
|
-
export2export: {},
|
|
74
|
-
mapFilePathToExportAllSources: {}
|
|
75
|
-
};
|
|
76
|
-
let effectedCode = {};
|
|
77
|
-
let reports = [];
|
|
78
|
-
try {
|
|
79
|
-
import_utils.logger.ready(`准备clone 源代码到临时目录下的 ${today}/${import_constants.TARGET} 文件夹`);
|
|
80
|
-
const repoUrl = (0, import_parseGitLabDiffUril.getGitRepoUrlByToken)(gitRepoUrl, token || "");
|
|
81
|
-
import_perf_hooks.performance.mark("stage 1");
|
|
82
|
-
await (0, import_gitUtil.cloneRepoWithBranchAndDefault)(repoUrl, branchName, (0, import_path.join)(today, import_constants.TARGET));
|
|
83
|
-
import_perf_hooks.performance.mark("stage 2");
|
|
84
|
-
import_utils.logger.info(`stage 1 --> stage 2 耗时: ${import_perf_hooks.performance.measure("stage 1 --> stage 2", "stage 1", "stage 2").duration}ms`);
|
|
85
|
-
await (0, import_gitUtil.cloneRepoWithBranchAndDefault)(repoUrl, "master", (0, import_path.join)(today, import_constants.SOURCE));
|
|
86
|
-
import_perf_hooks.performance.mark("stage 3");
|
|
87
|
-
import_utils.logger.info(`stage 2 --> stage 3 耗时: ${import_perf_hooks.performance.measure("stage 2 --> stage 3", "stage 2", "stage 3").duration}ms`);
|
|
88
|
-
import_utils.logger.ready("准备生成git_diff.txt文件");
|
|
89
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff master..${branchName} --unified=0 --output=${import__.gitDiffFileName}`, { shell: true }));
|
|
90
|
-
import_perf_hooks.performance.mark("stage 4");
|
|
91
|
-
import_utils.logger.info(`stage 3 --> stage 4 耗时: ${import_perf_hooks.performance.measure("stage 3 --> stage 4", "stage 3", "stage 4").duration}ms`);
|
|
92
|
-
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
93
|
-
const repoType = await (0, import_getRepoSupportFlag.getRepoType)((0, import_path.join)(process.cwd(), today, import_constants.TARGET, "package.json"));
|
|
94
|
-
import_utils.logger.info(`项目类型为: ${repoType}`);
|
|
95
|
-
if (repoType === "umi") {
|
|
96
|
-
const { madgeResult, shellExeResult, parsedAlias } = await (0, import_umi4ProjectUtil.umi4SetUp)({ targetDirPath: (0, import_path.join)(process.cwd(), today, import_constants.TARGET), invokeType: "remote" });
|
|
97
|
-
import_perf_hooks.performance.mark("stage 5");
|
|
98
|
-
import_utils.logger.info(`stage 4 --> stage 5 耗时: ${import_perf_hooks.performance.measure("stage 4 --> stage 5", "stage 4", "stage 5").duration}ms`);
|
|
99
|
-
({ stderr, failed } = shellExeResult);
|
|
100
|
-
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
101
|
-
const targetDirPath = (0, import_path.join)(process.cwd(), today, import_constants.TARGET);
|
|
102
|
-
const diff_txt = (0, import_fs.readFileSync)((0, import_path.join)(targetDirPath, import__.gitDiffFileName), "utf-8");
|
|
103
|
-
const gitDiffDetail = (0, import_format_git_diff_content.formatGitDiffContent)(diff_txt);
|
|
104
|
-
const usingFileNoPrefix = Object.keys(madgeResult.tree);
|
|
105
|
-
const groupGitDiffLines = gitDiffDetail.filter((item) => usingFileNoPrefix.includes(item.filePath));
|
|
106
|
-
const changedFilePaths = groupGitDiffLines.map((item) => item.filePath);
|
|
107
|
-
upstreamDependenceJson = Object.fromEntries(changedFilePaths.map((p) => [p, madgeResult.depends(p)]));
|
|
108
|
-
const absPathPrefix = targetDirPath + "/";
|
|
109
|
-
const modifiedFilePaths = gitDiffDetail.map((item) => item.filePath);
|
|
110
|
-
import_perf_hooks.performance.mark("stage 6");
|
|
111
|
-
import_utils.logger.info(`stage 5 --> stage 6 耗时: ${import_perf_hooks.performance.measure("stage 5 --> stage 6", "stage 5", "stage 6").duration}ms`);
|
|
112
|
-
const effectedFilePaths = (0, import_collectUpstreamFiles.default)(madgeResult, modifiedFilePaths).map((item) => (0, import_utils.winPath)((0, import_path.join)(absPathPrefix, item)));
|
|
113
|
-
import_perf_hooks.performance.mark("stage 7");
|
|
114
|
-
import_utils.logger.info(`stage 6 --> stage 7 耗时: ${import_perf_hooks.performance.measure("stage 6 --> stage 7", "stage 6", "stage 7").duration}ms`);
|
|
115
|
-
if (jsonKeys.includes("dependenceJson")) {
|
|
116
|
-
dependenceJson = (0, import_createDependenceMap.createExportedNameToReferenceLocalSet)(effectedFilePaths, parsedAlias, absPathPrefix, Object.keys(madgeResult.tree));
|
|
117
|
-
}
|
|
118
|
-
import_perf_hooks.performance.mark("stage 8");
|
|
119
|
-
import_utils.logger.info(`stage 7 --> stage 8 耗时: ${import_perf_hooks.performance.measure("stage 7 --> stage 8", "stage 7", "stage 8").duration}ms`);
|
|
120
|
-
if (jsonKeys.includes("reports")) {
|
|
121
|
-
reports = (0, import_report_util.createDetectReport)({ groupGitDiffLines, tree: madgeResult.tree, absPathPrefix });
|
|
122
|
-
}
|
|
123
|
-
import_perf_hooks.performance.mark("stage 9");
|
|
124
|
-
import_utils.logger.info(`stage 8 --> stage 9 耗时: ${import_perf_hooks.performance.measure("stage 8 --> stage 9", "stage 8", "stage 9").duration}ms`);
|
|
125
|
-
if (jsonKeys.includes("effectedCode")) {
|
|
126
|
-
effectedCode = (0, import_filterEffectedCode.default)(reports, dependenceJson);
|
|
127
|
-
}
|
|
128
|
-
import_perf_hooks.performance.mark("stage 10");
|
|
129
|
-
import_utils.logger.info(`stage 9 --> stage 10 耗时: ${import_perf_hooks.performance.measure("stage 9 --> stage 10", "stage 9", "stage 10").duration}ms`);
|
|
130
|
-
import_utils.logger.info(`total 耗时: ${import_perf_hooks.performance.measure("stage 0 --> stage 10", "stage 0", "stage 10").duration}ms`);
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
reports,
|
|
134
|
-
dependenceJson,
|
|
135
|
-
effectedCode,
|
|
136
|
-
upstreamDependenceJson,
|
|
137
|
-
repoType,
|
|
138
|
-
message: ""
|
|
139
|
-
};
|
|
140
|
-
} catch (error) {
|
|
141
|
-
import_utils.logger.error(error);
|
|
142
|
-
return {
|
|
143
|
-
effectedCode,
|
|
144
|
-
upstreamDependenceJson,
|
|
145
|
-
repoType: "",
|
|
146
|
-
message: error.message
|
|
147
|
-
};
|
|
148
|
-
} finally {
|
|
149
|
-
(0, import_utils.rimraf)((0, import_path.join)(process.cwd(), today), () => {
|
|
150
|
-
import_utils.logger.info("临时目录已删除");
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
43
|
+
var import_vueProjectUtil = require("../project_umi_util/vueProjectUtil");
|
|
44
|
+
var import_constants2 = require("../constants");
|
|
45
|
+
var import_cloneRepoWithBranchAndDefault = __toESM(require("../git_util/cloneRepoWithBranchAndDefault"));
|
|
154
46
|
async function gitDiffTool(arg) {
|
|
155
47
|
const { gitRepoUrl: gitUrl, baseBranch, targetBranch: branchName, tempDirPath: today, generateFile } = arg;
|
|
156
48
|
import_utils.logger.ready("准备生成临时工作目录...");
|
|
@@ -162,7 +54,7 @@ async function gitDiffTool(arg) {
|
|
|
162
54
|
import_utils.logger.info("临时目录建立完成");
|
|
163
55
|
try {
|
|
164
56
|
import_utils.logger.ready(`准备clone 源代码 分支:${branchName} 到临时目录下的 ${import_constants.TARGET} 文件夹`);
|
|
165
|
-
await (0,
|
|
57
|
+
await (0, import_cloneRepoWithBranchAndDefault.default)(gitUrl, branchName, (0, import_path.join)(process.cwd(), today, import_constants.TARGET));
|
|
166
58
|
let stderr, failed;
|
|
167
59
|
import_utils.logger.info("源代码clone完成");
|
|
168
60
|
import_utils.logger.wait("检测项目类型");
|
|
@@ -176,10 +68,10 @@ async function gitDiffTool(arg) {
|
|
|
176
68
|
return;
|
|
177
69
|
}
|
|
178
70
|
import_utils.logger.ready(`准备clone 源代码 分支:master 到临时目录下的 ${import_constants.SOURCE} 文件夹`);
|
|
179
|
-
await (0,
|
|
71
|
+
await (0, import_cloneRepoWithBranchAndDefault.default)(gitUrl, "master", (0, import_path.join)(process.cwd(), today, import_constants.SOURCE));
|
|
180
72
|
import_utils.logger.info(`分支 ${branchName} 代码 clone 完成`);
|
|
181
73
|
import_utils.logger.ready("准备生成git_diff.txt文件");
|
|
182
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff ${baseBranch}..${branchName} --unified=0 --output=${
|
|
74
|
+
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff ${baseBranch}..${branchName} --unified=0 --output=${import_constants2.gitDiffFileName}`, { shell: true }));
|
|
183
75
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
184
76
|
import_utils.logger.info("git_diff.txt文件生成完成");
|
|
185
77
|
if (repoType === "umi") {
|
|
@@ -204,6 +96,5 @@ async function gitDiffTool(arg) {
|
|
|
204
96
|
}
|
|
205
97
|
// Annotate the CommonJS export names for ESM import in node:
|
|
206
98
|
0 && (module.exports = {
|
|
207
|
-
cloneGitRepoAndGetDiff,
|
|
208
99
|
gitDiffTool
|
|
209
100
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-code-detector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"types": "dist/cjs/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"test": "jest",
|
|
8
9
|
"dev": "father dev",
|
|
9
10
|
"build": "father build",
|
|
10
11
|
"build:deps": "father prebundle",
|
|
@@ -29,9 +30,12 @@
|
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/crypto-js": "^4.2.2",
|
|
33
|
+
"@types/jest": "^30.0.0",
|
|
32
34
|
"@types/lodash": "^4.17.20",
|
|
33
35
|
"@types/madge": "^5.0.3",
|
|
34
36
|
"father": "^4.6.3",
|
|
37
|
+
"jest": "^30.2.0",
|
|
38
|
+
"ts-jest": "^29.4.5",
|
|
35
39
|
"tsx": "^4.20.6"
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MadgeInstance } from "madge";
|
|
2
|
-
interface IMadgeInstance extends MadgeInstance {
|
|
3
|
-
tree: Record<string, string[]>;
|
|
4
|
-
}
|
|
5
|
-
export default function (api: any): Promise<{
|
|
6
|
-
usingFiles: {
|
|
7
|
-
filePath: string;
|
|
8
|
-
name: string;
|
|
9
|
-
}[];
|
|
10
|
-
madgeInstance: IMadgeInstance;
|
|
11
|
-
} | undefined>;
|
|
12
|
-
export {};
|
|
@@ -1,120 +0,0 @@
|
|
|
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/madge_util.ts
|
|
20
|
-
var madge_util_exports = {};
|
|
21
|
-
__export(madge_util_exports, {
|
|
22
|
-
default: () => madge_util_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(madge_util_exports);
|
|
25
|
-
var import_path = require("path");
|
|
26
|
-
var import_utils = require("@umijs/utils");
|
|
27
|
-
var MADGE_NAME = "madge";
|
|
28
|
-
async function madge_util_default(api) {
|
|
29
|
-
var _a, _b;
|
|
30
|
-
const userAlias = api.config.alias;
|
|
31
|
-
if (!userAlias) {
|
|
32
|
-
console.log("userAlias -> null");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const cwd = api.cwd;
|
|
36
|
-
const tsconfig = await import_utils.tsconfigPaths.loadConfig(cwd);
|
|
37
|
-
const exclude = [/node_modules/, /\.d\.ts$/, /\.umi/];
|
|
38
|
-
const isExclude = (path) => {
|
|
39
|
-
return exclude.some((reg) => reg.test(path));
|
|
40
|
-
};
|
|
41
|
-
const parsedAlias = import_utils.aliasUtils.parseCircleAlias({
|
|
42
|
-
alias: userAlias
|
|
43
|
-
});
|
|
44
|
-
const filteredAlias = Object.keys(parsedAlias).reduce(
|
|
45
|
-
(acc, key) => {
|
|
46
|
-
var _a2, _b2;
|
|
47
|
-
const value = parsedAlias[key];
|
|
48
|
-
if (isExclude(value)) {
|
|
49
|
-
return acc;
|
|
50
|
-
}
|
|
51
|
-
if ((_a2 = tsconfig.paths) == null ? void 0 : _a2[key]) {
|
|
52
|
-
return acc;
|
|
53
|
-
}
|
|
54
|
-
const tsconfigValue = [(0, import_path.join)((0, import_path.relative)(cwd, value), "/*")];
|
|
55
|
-
const tsconfigKey = `${key}/*`;
|
|
56
|
-
if ((_b2 = tsconfig.paths) == null ? void 0 : _b2[tsconfigKey]) {
|
|
57
|
-
return acc;
|
|
58
|
-
}
|
|
59
|
-
acc[tsconfigKey] = tsconfigValue;
|
|
60
|
-
return acc;
|
|
61
|
-
},
|
|
62
|
-
{}
|
|
63
|
-
);
|
|
64
|
-
const devTmpDir = (0, import_path.join)(api.paths.absSrcPath, ".umi");
|
|
65
|
-
const entryFile = (0, import_path.join)(devTmpDir, "umi.ts");
|
|
66
|
-
const exportsFile = (0, import_path.join)(devTmpDir, "exports.ts");
|
|
67
|
-
const madgePkg = (0, import_path.dirname)(
|
|
68
|
-
import_utils.resolve.sync(`${MADGE_NAME}/package.json`, {
|
|
69
|
-
basedir: cwd
|
|
70
|
-
})
|
|
71
|
-
);
|
|
72
|
-
const madge = require(madgePkg);
|
|
73
|
-
const madgeConfig = {
|
|
74
|
-
tsConfig: {
|
|
75
|
-
compilerOptions: {
|
|
76
|
-
baseUrl: tsconfig.baseUrl,
|
|
77
|
-
paths: {
|
|
78
|
-
...filteredAlias,
|
|
79
|
-
...tsconfig.paths,
|
|
80
|
-
umi: [exportsFile],
|
|
81
|
-
"@umijs/max": [exportsFile],
|
|
82
|
-
// 适配 bigfish
|
|
83
|
-
...((_b = (_a = api.appData) == null ? void 0 : _a.umi) == null ? void 0 : _b.importSource) ? {
|
|
84
|
-
[api.appData.umi.importSource]: [exportsFile]
|
|
85
|
-
} : {}
|
|
86
|
-
},
|
|
87
|
-
target: "esnext",
|
|
88
|
-
module: "esnext",
|
|
89
|
-
moduleResolution: "node",
|
|
90
|
-
importHelpers: true,
|
|
91
|
-
jsx: "react-jsx",
|
|
92
|
-
esModuleInterop: true,
|
|
93
|
-
strict: true,
|
|
94
|
-
resolveJsonModule: true,
|
|
95
|
-
allowSyntheticDefaultImports: true
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
fileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
99
|
-
excludeRegExp: exclude,
|
|
100
|
-
baseDir: cwd
|
|
101
|
-
};
|
|
102
|
-
const res = await madge(entryFile, madgeConfig);
|
|
103
|
-
const treeMap = res.tree;
|
|
104
|
-
const dependenceMap = Object.keys(treeMap).reduce(
|
|
105
|
-
(acc, key) => {
|
|
106
|
-
const path = (0, import_utils.winPath)((0, import_path.join)(api.paths.cwd, key));
|
|
107
|
-
acc[path] = true;
|
|
108
|
-
return acc;
|
|
109
|
-
},
|
|
110
|
-
{}
|
|
111
|
-
);
|
|
112
|
-
const usingFiles = (0, import_utils.readDirFiles)({
|
|
113
|
-
dir: api.paths.absSrcPath,
|
|
114
|
-
exclude
|
|
115
|
-
}).filter(({ filePath }) => dependenceMap[filePath]);
|
|
116
|
-
return {
|
|
117
|
-
usingFiles,
|
|
118
|
-
madgeInstance: res
|
|
119
|
-
};
|
|
120
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getFileDepends(filePath: string, tree: Record<string, string[]>): string[][];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|