js-code-detector 0.0.47 → 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 +1 -44
- package/dist/cjs/index.js +3 -25
- package/dist/cjs/services/DetectService.d.ts +2 -2
- package/dist/cjs/services/DetectService.js +11 -6
- package/dist/cjs/services/ProjectService.d.ts +1 -1
- package/dist/cjs/services/projectServiceClass/UmiProjectService.js +6 -7
- 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
|
@@ -24,7 +24,14 @@ __export(AstUtil_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(AstUtil_exports);
|
|
25
25
|
var import_windowProperties = require("./windowProperties");
|
|
26
26
|
var import_intrinsicElements = require("./intrinsicElements");
|
|
27
|
+
var import_SHARED_CONSTANTS = require("./SHARED_CONSTANTS");
|
|
27
28
|
var _AstUtil = class {
|
|
29
|
+
static isValidNodeCollect(astNode) {
|
|
30
|
+
return typeof (astNode == null ? void 0 : astNode.type) === "string";
|
|
31
|
+
}
|
|
32
|
+
static isValidArrayNodeCollect(astNode) {
|
|
33
|
+
return Array.isArray(astNode) && astNode.some((v) => typeof (v == null ? void 0 : v.type) === "string");
|
|
34
|
+
}
|
|
28
35
|
static getNodePath(node) {
|
|
29
36
|
return [...node._util.ancestors, node].map((n) => n.type).join(":") + ":" + node.name;
|
|
30
37
|
}
|
|
@@ -895,12 +902,6 @@ var _AstUtil = class {
|
|
|
895
902
|
});
|
|
896
903
|
}
|
|
897
904
|
}
|
|
898
|
-
static isValidArrayNodeCollect(astNode) {
|
|
899
|
-
return Array.isArray(astNode) && astNode.some((v) => typeof (v == null ? void 0 : v.type) === "string");
|
|
900
|
-
}
|
|
901
|
-
static isValidNodeCollect(astNode) {
|
|
902
|
-
return typeof (astNode == null ? void 0 : astNode.type) === "string";
|
|
903
|
-
}
|
|
904
905
|
static isUntrackedId(id) {
|
|
905
906
|
return id._util.variableScope.length === 0 && !this.isPropertyOfGlobal(id) && !this.isIntrinsicElement(id) && !this.isStandardAttribute(id);
|
|
906
907
|
}
|
|
@@ -943,11 +944,8 @@ var _AstUtil = class {
|
|
|
943
944
|
}
|
|
944
945
|
};
|
|
945
946
|
var AstUtil = _AstUtil;
|
|
946
|
-
AstUtil.invalidNodeKey =
|
|
947
|
-
|
|
948
|
-
"tokens"
|
|
949
|
-
];
|
|
950
|
-
AstUtil.EXPORT_DECLARATION_TYPES = ["FunctionDeclaration", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSTypeAliasDeclaration", "ClassDeclaration"];
|
|
947
|
+
AstUtil.invalidNodeKey = import_SHARED_CONSTANTS.INVALID_NODE_KEY;
|
|
948
|
+
AstUtil.EXPORT_DECLARATION_TYPES = import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES;
|
|
951
949
|
AstUtil.windowProperties = import_windowProperties.windowProperties;
|
|
952
950
|
AstUtil.intrinsicElements = import_intrinsicElements.intrinsicElements;
|
|
953
951
|
AstUtil.standardAttributes = import_intrinsicElements.standardAttributes;
|
|
@@ -0,0 +1,35 @@
|
|
|
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/ast_util/SHARED_CONSTANTS.ts
|
|
20
|
+
var SHARED_CONSTANTS_exports = {};
|
|
21
|
+
__export(SHARED_CONSTANTS_exports, {
|
|
22
|
+
EXPORT_DECLARATION_TYPES: () => EXPORT_DECLARATION_TYPES,
|
|
23
|
+
FUNCTION_TYPES: () => FUNCTION_TYPES,
|
|
24
|
+
INVALID_NODE_KEY: () => INVALID_NODE_KEY
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(SHARED_CONSTANTS_exports);
|
|
27
|
+
var INVALID_NODE_KEY = ["comments", "tokens"];
|
|
28
|
+
var EXPORT_DECLARATION_TYPES = ["FunctionDeclaration", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSTypeAliasDeclaration", "ClassDeclaration"];
|
|
29
|
+
var FUNCTION_TYPES = ["FunctionDeclaration", "ArrowFunctionExpression", "FunctionExpression", "ObjectMethod", "ClassMethod"];
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
EXPORT_DECLARATION_TYPES,
|
|
33
|
+
FUNCTION_TYPES,
|
|
34
|
+
INVALID_NODE_KEY
|
|
35
|
+
});
|
|
@@ -20,13 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var constants_exports = {};
|
|
21
21
|
__export(constants_exports, {
|
|
22
22
|
SOURCE: () => SOURCE,
|
|
23
|
-
TARGET: () => TARGET
|
|
23
|
+
TARGET: () => TARGET,
|
|
24
|
+
gitDiffFileName: () => gitDiffFileName
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(constants_exports);
|
|
26
27
|
var SOURCE = "source";
|
|
27
28
|
var TARGET = "target";
|
|
29
|
+
var gitDiffFileName = "git_diff.txt";
|
|
28
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
31
|
0 && (module.exports = {
|
|
30
32
|
SOURCE,
|
|
31
|
-
TARGET
|
|
33
|
+
TARGET,
|
|
34
|
+
gitDiffFileName
|
|
32
35
|
});
|
|
@@ -5,8 +5,4 @@
|
|
|
5
5
|
* @param {string} targetDir - 本地目标目录
|
|
6
6
|
* @returns {Promise<string>} 克隆目录路径
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
/**
|
|
10
|
-
* 执行 baseBranch 和 targetBranch 的 diff
|
|
11
|
-
*/
|
|
12
|
-
export declare function execGitDiff(targetDir: string, baseBranch: string, targetBranch: string): Promise<any>;
|
|
8
|
+
export default function cloneRepoWithBranchAndDefault(repoUrl: string, targetBranch: string, targetDir: string): Promise<string>;
|
|
@@ -16,14 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/util/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
23
|
-
execGitDiff: () => execGitDiff
|
|
19
|
+
// src/util/git_util/cloneRepoWithBranchAndDefault.ts
|
|
20
|
+
var cloneRepoWithBranchAndDefault_exports = {};
|
|
21
|
+
__export(cloneRepoWithBranchAndDefault_exports, {
|
|
22
|
+
default: () => cloneRepoWithBranchAndDefault
|
|
24
23
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
26
|
-
var import__ = require("../../index");
|
|
24
|
+
module.exports = __toCommonJS(cloneRepoWithBranchAndDefault_exports);
|
|
27
25
|
var simpleGit = require("simple-git");
|
|
28
26
|
async function cloneRepoWithBranchAndDefault(repoUrl, targetBranch, targetDir) {
|
|
29
27
|
try {
|
|
@@ -47,21 +45,3 @@ async function cloneRepoWithBranchAndDefault(repoUrl, targetBranch, targetDir) {
|
|
|
47
45
|
throw error;
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
async function execGitDiff(targetDir, baseBranch, targetBranch) {
|
|
51
|
-
try {
|
|
52
|
-
const repoGit = simpleGit(targetDir);
|
|
53
|
-
await repoGit.checkout(targetBranch);
|
|
54
|
-
await repoGit.pull("origin", targetBranch);
|
|
55
|
-
const diffFiles = await repoGit.diffSummary([baseBranch, "--unified=0", `--output=${import__.gitDiffFileName}`]);
|
|
56
|
-
console.log(`${targetBranch} 与 ${baseBranch} 的差异:`, diffFiles);
|
|
57
|
-
return diffFiles;
|
|
58
|
-
} catch (error) {
|
|
59
|
-
console.error(`获取差异失败:${error.message}`);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
cloneRepoWithBranchAndDefault,
|
|
66
|
-
execGitDiff
|
|
67
|
-
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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/git_util/execGitDiff.ts
|
|
20
|
+
var execGitDiff_exports = {};
|
|
21
|
+
__export(execGitDiff_exports, {
|
|
22
|
+
default: () => execGitDiff
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(execGitDiff_exports);
|
|
25
|
+
var import_constants = require("../constants");
|
|
26
|
+
var simpleGit = require("simple-git");
|
|
27
|
+
async function execGitDiff(targetDir, baseBranch, targetBranch) {
|
|
28
|
+
try {
|
|
29
|
+
const repoGit = simpleGit(targetDir);
|
|
30
|
+
await repoGit.checkout(targetBranch);
|
|
31
|
+
await repoGit.pull("origin", targetBranch);
|
|
32
|
+
const diffFiles = await repoGit.diffSummary([baseBranch, "--unified=0", `--output=${import_constants.gitDiffFileName}`]);
|
|
33
|
+
console.log(`${targetBranch} 与 ${baseBranch} 的差异:`, diffFiles);
|
|
34
|
+
return diffFiles;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error(`获取差异失败:${error.message}`);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/cjs/util/{report_util/getFileDepends.js → git_util/getGitRepositoryAndBranch.js}
RENAMED
|
@@ -16,23 +16,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/util/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
default: () =>
|
|
19
|
+
// src/util/git_util/getGitRepositoryAndBranch.ts
|
|
20
|
+
var getGitRepositoryAndBranch_exports = {};
|
|
21
|
+
__export(getGitRepositoryAndBranch_exports, {
|
|
22
|
+
default: () => getGitRepositoryAndBranch
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return;
|
|
36
|
-
getFileDependsRecursive(res, depends, treeEntries, maxTry - 1);
|
|
37
|
-
}
|
|
24
|
+
module.exports = __toCommonJS(getGitRepositoryAndBranch_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
async function getGitRepositoryAndBranch() {
|
|
27
|
+
const res = await import_utils.execa.execa("git remote get-url origin", { shell: true });
|
|
28
|
+
import_utils.chalk.green(["仓库地址:", res.stdout]);
|
|
29
|
+
const branch = await import_utils.execa.execa("git rev-parse --abbrev-ref HEAD", { shell: true });
|
|
30
|
+
import_utils.chalk.green(["分支名称:", branch.stdout]);
|
|
31
|
+
return {
|
|
32
|
+
gitUrl: res.stdout,
|
|
33
|
+
branchName: branch.stdout
|
|
34
|
+
};
|
|
38
35
|
}
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/util/parseGitLabDiffUril.ts
|
|
19
|
+
// src/util/git_util/parseGitLabDiffUril.ts
|
|
20
20
|
var parseGitLabDiffUril_exports = {};
|
|
21
21
|
__export(parseGitLabDiffUril_exports, {
|
|
22
22
|
getGitRepoUrlByToken: () => getGitRepoUrlByToken,
|
|
@@ -72,7 +72,7 @@ function getGitRepoUrlByToken(gitRepoUrl, gitlabToken) {
|
|
|
72
72
|
if (!projectPath) {
|
|
73
73
|
throw new Error("请传入 GitLab 项目路径(如 dev-team/my-project)");
|
|
74
74
|
}
|
|
75
|
-
return `http://oauth:${gitlabToken}@${gitlabDomain}
|
|
75
|
+
return `http://oauth:${gitlabToken}@${gitlabDomain}${projectPath}.git`;
|
|
76
76
|
}
|
|
77
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
78
|
0 && (module.exports = {
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/util/
|
|
19
|
+
// src/util/project_umi_util/umi4ProjectUtil.ts
|
|
20
20
|
var umi4ProjectUtil_exports = {};
|
|
21
21
|
__export(umi4ProjectUtil_exports, {
|
|
22
22
|
umi4SetUp: () => umi4SetUp
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/util/
|
|
19
|
+
// src/util/project_umi_util/vueProjectUtil.ts
|
|
20
20
|
var vueProjectUtil_exports = {};
|
|
21
21
|
__export(vueProjectUtil_exports, {
|
|
22
22
|
vueSetUp: () => vueSetUp
|
|
@@ -33,8 +33,8 @@ __export(createDependenceMap_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(createDependenceMap_exports);
|
|
35
35
|
var import_getAstKitByFilePath = __toESM(require("../ast_util/getAstKitByFilePath"));
|
|
36
|
-
var import_filePathResolver = require("../ast_util/filePathResolver");
|
|
37
36
|
var import_path = require("path");
|
|
37
|
+
var import_resolveImportPath = __toESM(require("./resolveImportPath"));
|
|
38
38
|
function createExportedNameToReferenceLocalSet(upstreamFileFullPaths, parsedAlias, absPathPrefix, projectFilePaths) {
|
|
39
39
|
const cwd = process.cwd();
|
|
40
40
|
const systemAbsPathPrefix = absPathPrefix.startsWith(cwd) ? absPathPrefix : (0, import_path.join)(cwd, absPathPrefix);
|
|
@@ -52,7 +52,7 @@ function createExportedNameToReferenceLocalSet(upstreamFileFullPaths, parsedAlia
|
|
|
52
52
|
const { importedMember, exportedMember } = programNode._util;
|
|
53
53
|
const relativeFilePath = absFilePath.replace(absPathPrefix, "");
|
|
54
54
|
for (const { sourcePath, members } of importedMember) {
|
|
55
|
-
const { fullPath, isExternal } = (0,
|
|
55
|
+
const { fullPath, isExternal } = (0, import_resolveImportPath.default)(localAlias, sourcePath, relativeFilePath);
|
|
56
56
|
const finalSourcePath = createRealSourcePath(sourcePath, isExternal, projectFilePaths, fullPath);
|
|
57
57
|
for (const { importedName: imported, localName: local } of members) {
|
|
58
58
|
const importLocal = `${relativeFilePath}#${local}`;
|
|
@@ -64,7 +64,7 @@ function createExportedNameToReferenceLocalSet(upstreamFileFullPaths, parsedAlia
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
for (const { sourcePath, members, ExportAllDeclaration } of exportedMember) {
|
|
67
|
-
const { fullPath, isExternal } = (0,
|
|
67
|
+
const { fullPath, isExternal } = (0, import_resolveImportPath.default)(localAlias, sourcePath, relativeFilePath);
|
|
68
68
|
const finalSourcePath = createRealSourcePath(sourcePath, isExternal, projectFilePaths, fullPath);
|
|
69
69
|
for (const { exportedName: exported, localName: local } of members) {
|
|
70
70
|
const exportedName = `${relativeFilePath}#${exported}`;
|
|
@@ -26,7 +26,7 @@ export declare function generateGitDiffReport(arg: {
|
|
|
26
26
|
effectsDownstream: string[];
|
|
27
27
|
}[];
|
|
28
28
|
}[];
|
|
29
|
-
type: "
|
|
29
|
+
type: "delete" | "modify" | "add";
|
|
30
30
|
filesDependsOnMe: string[];
|
|
31
31
|
undefinedIdentifiers: string[];
|
|
32
32
|
filePath: string;
|
|
@@ -34,7 +34,7 @@ __export(generateGitDiffReport_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(generateGitDiffReport_exports);
|
|
35
35
|
var import_fs = require("fs");
|
|
36
36
|
var import_path = require("path");
|
|
37
|
-
var
|
|
37
|
+
var import_constants = require("../constants");
|
|
38
38
|
var import_format_git_diff_content = require("../format_git_diff_content");
|
|
39
39
|
var import_utils = require("@umijs/utils");
|
|
40
40
|
var import_report_util = require("../report_util");
|
|
@@ -49,7 +49,7 @@ async function generateGitDiffReport(arg) {
|
|
|
49
49
|
const { tree } = madgeResult;
|
|
50
50
|
const projectFilePaths = Object.keys(tree);
|
|
51
51
|
import_utils.logger.info("读取 git diff 内容,生成 json 文件");
|
|
52
|
-
const diff_txt = (0, import_fs.readFileSync)((0, import_path.join)(targetDirPath,
|
|
52
|
+
const diff_txt = (0, import_fs.readFileSync)((0, import_path.join)(targetDirPath, import_constants.gitDiffFileName), "utf-8");
|
|
53
53
|
const gitDiffDetail = (0, import_format_git_diff_content.formatGitDiffContent)(diff_txt);
|
|
54
54
|
const modifiedFilePaths = gitDiffDetail.map((item) => item.filePath);
|
|
55
55
|
const upstreamFilePaths = (0, import_collectUpstreamFiles.default)(madgeResult, modifiedFilePaths);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {string[]} [extensions=['.js', '.ts', '.jsx', '.tsx']] - 可能的文件扩展名
|
|
7
7
|
* @returns {Object} 包含全路径和是否为外部路径的对象
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export default function resolveImportPath(alias: Record<string, string>, importPath: string, currentFilePath: string, extensions?: string[]): {
|
|
10
10
|
fullPath: string[];
|
|
11
11
|
isExternal: boolean;
|
|
12
12
|
} | {
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/util/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
19
|
+
// src/util/report_util/resolveImportPath.ts
|
|
20
|
+
var resolveImportPath_exports = {};
|
|
21
|
+
__export(resolveImportPath_exports, {
|
|
22
|
+
default: () => resolveImportPath
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(resolveImportPath_exports);
|
|
25
25
|
function joinPath(...paths) {
|
|
26
26
|
const isAbsolute = paths.some(
|
|
27
27
|
(path) => path.startsWith("/") || path.startsWith("\\") || path.length >= 2 && path[1] === ":"
|
|
@@ -125,7 +125,3 @@ function resolveImportPath(alias, importPath, currentFilePath, extensions = [".j
|
|
|
125
125
|
isExternal: false
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
-
0 && (module.exports = {
|
|
130
|
-
resolveImportPath
|
|
131
|
-
});
|
|
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// src/util/createRandomStr.ts
|
|
29
|
+
// src/util/shared/createRandomStr.ts
|
|
30
30
|
var createRandomStr_exports = {};
|
|
31
31
|
__export(createRandomStr_exports, {
|
|
32
32
|
default: () => createRandomStr
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { semver } from "@umijs/utils";
|
|
2
1
|
export declare function isRepoTypeSupported(repoType: string): boolean;
|
|
3
2
|
export declare function getRepoType(jsonPath: string): "unknown" | "umi" | "vue2";
|
|
4
|
-
export declare function getMinVersion(jsonPath: string, depName: string): semver.SemVer | null | undefined;
|
|
@@ -19,7 +19,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/util/shared/getRepoSupportFlag.ts
|
|
20
20
|
var getRepoSupportFlag_exports = {};
|
|
21
21
|
__export(getRepoSupportFlag_exports, {
|
|
22
|
-
getMinVersion: () => getMinVersion,
|
|
23
22
|
getRepoType: () => getRepoType,
|
|
24
23
|
isRepoTypeSupported: () => isRepoTypeSupported
|
|
25
24
|
});
|
|
@@ -50,24 +49,8 @@ function getRepoType(jsonPath) {
|
|
|
50
49
|
}
|
|
51
50
|
return "unknown";
|
|
52
51
|
}
|
|
53
|
-
function getMinVersion(jsonPath, depName) {
|
|
54
|
-
var _a, _b;
|
|
55
|
-
const packageJson = (0, import_fs.readFileSync)(jsonPath, "utf-8");
|
|
56
|
-
if (!packageJson)
|
|
57
|
-
return null;
|
|
58
|
-
try {
|
|
59
|
-
const packageJsonObj = JSON.parse(packageJson);
|
|
60
|
-
const v = ((_a = packageJsonObj == null ? void 0 : packageJsonObj.dependencies) == null ? void 0 : _a[depName]) || ((_b = packageJsonObj == null ? void 0 : packageJsonObj.devDependencies) == null ? void 0 : _b[depName]);
|
|
61
|
-
if (v) {
|
|
62
|
-
return import_utils.semver.minVersion(v);
|
|
63
|
-
}
|
|
64
|
-
} catch (e) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
53
|
0 && (module.exports = {
|
|
70
|
-
getMinVersion,
|
|
71
54
|
getRepoType,
|
|
72
55
|
isRepoTypeSupported
|
|
73
56
|
});
|
|
@@ -1,44 +1,4 @@
|
|
|
1
1
|
import { generateGitDiffReport } from "../report_util/generateGitDiffReport";
|
|
2
|
-
export declare function cloneGitRepoAndGetDiff(gitRepoUrl: string, branchName: string, extra?: {
|
|
3
|
-
token?: string;
|
|
4
|
-
jsonKeys?: (keyof Awaited<ReturnType<typeof cloneGitRepoAndGetDiff>>)[];
|
|
5
|
-
}): Promise<{
|
|
6
|
-
reports: {
|
|
7
|
-
dangerIdentifiers: string[];
|
|
8
|
-
topEffectedExportsAdded: string[];
|
|
9
|
-
topEffectedExportsRemoved: string[];
|
|
10
|
-
blockReports: {
|
|
11
|
-
diff_txt: string[];
|
|
12
|
-
infos: {
|
|
13
|
-
causeBy: string;
|
|
14
|
-
effectsUpstream: string[];
|
|
15
|
-
occupations: string[];
|
|
16
|
-
effectsDownstream: string[];
|
|
17
|
-
}[];
|
|
18
|
-
}[];
|
|
19
|
-
type: "modify" | "add" | "delete";
|
|
20
|
-
filesDependsOnMe: string[];
|
|
21
|
-
undefinedIdentifiers: string[];
|
|
22
|
-
filePath: string;
|
|
23
|
-
}[];
|
|
24
|
-
dependenceJson: {
|
|
25
|
-
import2export: Record<string, string>;
|
|
26
|
-
export2export: Record<string, string>;
|
|
27
|
-
mapFilePathToExportAllSources: Record<string, string[]>;
|
|
28
|
-
indirectExportMembers: Record<string, string>;
|
|
29
|
-
};
|
|
30
|
-
effectedCode: Record<string, any>;
|
|
31
|
-
upstreamDependenceJson: {};
|
|
32
|
-
repoType: string;
|
|
33
|
-
message: string;
|
|
34
|
-
} | {
|
|
35
|
-
effectedCode: Record<string, any>;
|
|
36
|
-
upstreamDependenceJson: {};
|
|
37
|
-
repoType: string;
|
|
38
|
-
message: any;
|
|
39
|
-
reports?: undefined;
|
|
40
|
-
dependenceJson?: undefined;
|
|
41
|
-
}>;
|
|
42
2
|
export declare function gitDiffTool(arg: {
|
|
43
3
|
gitRepoUrl: string;
|
|
44
4
|
baseBranch: string;
|