js-code-detector 0.0.39 → 0.0.40
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
CHANGED
|
@@ -20,7 +20,7 @@ export declare function gitDiffDetect(): Promise<{
|
|
|
20
20
|
effectsDownstream: string[];
|
|
21
21
|
}[];
|
|
22
22
|
}[];
|
|
23
|
-
type: "
|
|
23
|
+
type: "add" | "delete" | "modify";
|
|
24
24
|
filesDependsOnMe: string[];
|
|
25
25
|
undefinedIdentifiers: string[];
|
|
26
26
|
filePath: string;
|
|
@@ -42,7 +42,7 @@ export declare function gitDiffDetectByUrl(inputUrl: string): Promise<{
|
|
|
42
42
|
effectsDownstream: string[];
|
|
43
43
|
}[];
|
|
44
44
|
}[];
|
|
45
|
-
type: "
|
|
45
|
+
type: "add" | "delete" | "modify";
|
|
46
46
|
filesDependsOnMe: string[];
|
|
47
47
|
undefinedIdentifiers: string[];
|
|
48
48
|
filePath: string;
|
|
@@ -21,7 +21,7 @@ export declare function generateGitDiffReport(arg: {
|
|
|
21
21
|
effectsDownstream: string[];
|
|
22
22
|
}[];
|
|
23
23
|
}[];
|
|
24
|
-
type: "
|
|
24
|
+
type: "add" | "delete" | "modify";
|
|
25
25
|
filesDependsOnMe: string[];
|
|
26
26
|
undefinedIdentifiers: string[];
|
|
27
27
|
filePath: string;
|
|
@@ -35,7 +35,7 @@ export declare function createDetectReport(arg: Arg): {
|
|
|
35
35
|
effectsDownstream: string[];
|
|
36
36
|
}[];
|
|
37
37
|
}[];
|
|
38
|
-
type: "
|
|
38
|
+
type: "add" | "delete" | "modify";
|
|
39
39
|
filesDependsOnMe: string[];
|
|
40
40
|
undefinedIdentifiers: string[];
|
|
41
41
|
filePath: string;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { generateGitDiffReport } from "../report_util/generateGitDiffReport";
|
|
2
2
|
export type CloneType = 'ssh' | 'token';
|
|
3
|
-
export declare function cloneGitRepo(gitUrl: string, branchName: string, tempDirPath: string, folder: string, extra?: {
|
|
4
|
-
cloneType?: CloneType;
|
|
5
|
-
token?: string;
|
|
6
|
-
}): Promise<{
|
|
7
|
-
failed: boolean | undefined;
|
|
8
|
-
stderr: string | undefined;
|
|
9
|
-
}>;
|
|
10
3
|
export declare function cloneGitRepoAndGetDiff(gitRepoUrl: string, branchName: string, extra?: {
|
|
11
4
|
cloneType?: CloneType;
|
|
12
5
|
token?: string;
|
|
@@ -35,7 +28,7 @@ export declare function gitDiffTool(arg: {
|
|
|
35
28
|
effectsDownstream: string[];
|
|
36
29
|
}[];
|
|
37
30
|
}[];
|
|
38
|
-
type: "
|
|
31
|
+
type: "add" | "delete" | "modify";
|
|
39
32
|
filesDependsOnMe: string[];
|
|
40
33
|
undefinedIdentifiers: string[];
|
|
41
34
|
filePath: string;
|
|
@@ -29,7 +29,6 @@ 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
|
-
cloneGitRepo: () => cloneGitRepo,
|
|
33
32
|
cloneGitRepoAndGetDiff: () => cloneGitRepoAndGetDiff,
|
|
34
33
|
gitDiffTool: () => gitDiffTool
|
|
35
34
|
});
|
|
@@ -49,31 +48,8 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
49
48
|
var import_fs = require("fs");
|
|
50
49
|
var import_format_git_diff_content = require("../format_git_diff_content");
|
|
51
50
|
var import_gitUtil = require("./gitUtil");
|
|
52
|
-
async function cloneGitRepo(gitUrl, branchName, tempDirPath, folder, extra = {}) {
|
|
53
|
-
const { cloneType, token = "" } = extra;
|
|
54
|
-
import_utils.logger.ready(`准备clone 源代码到临时目录下的 ${tempDirPath}/${folder} 文件夹`);
|
|
55
|
-
let stderr, failed;
|
|
56
|
-
if (cloneType === "ssh") {
|
|
57
|
-
const sshGitRepoUrl = (0, import_parseGitLabDiffUril.getSshGitRepoUrl)(gitUrl);
|
|
58
|
-
({ stderr, failed } = await import_utils.execa.execa(`git clone ${sshGitRepoUrl} ${tempDirPath}/${folder}`, { shell: true }));
|
|
59
|
-
} else if (cloneType === "token") {
|
|
60
|
-
const repoUrl = (0, import_parseGitLabDiffUril.getGitRepoUrlByToken)(gitUrl, token);
|
|
61
|
-
({ stderr, failed } = await import_utils.execa.execa(`git clone ${repoUrl} ${tempDirPath}/${folder}`, { shell: true }));
|
|
62
|
-
} else {
|
|
63
|
-
await (0, import_gitUtil.cloneRepoWithBranchAndDefault)(gitUrl, `${tempDirPath}/${folder}`, branchName);
|
|
64
|
-
}
|
|
65
|
-
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
66
|
-
import_utils.logger.info("源代码clone完成");
|
|
67
|
-
if (branchName !== "master") {
|
|
68
|
-
import_utils.logger.ready("准备切换到分支");
|
|
69
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${tempDirPath}/${folder} && git fetch origin ${branchName}:${branchName} && git checkout ${branchName}`, { shell: true }));
|
|
70
|
-
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
71
|
-
import_utils.logger.info("源代码切换分支完成");
|
|
72
|
-
}
|
|
73
|
-
return { failed, stderr };
|
|
74
|
-
}
|
|
75
51
|
async function cloneGitRepoAndGetDiff(gitRepoUrl, branchName, extra = {}) {
|
|
76
|
-
const {
|
|
52
|
+
const { token } = extra;
|
|
77
53
|
const today = (0, import_dayjs.default)().format("YYYYMDD_HHmmss") + Math.random().toString(36).slice(-5);
|
|
78
54
|
import_utils.logger.ready("准备生成临时工作目录...");
|
|
79
55
|
const [err] = await (0, import_await_to_js.default)(import_utils.execa.execa(`rm -rf ${today}`, { shell: true }));
|
|
@@ -84,8 +60,9 @@ async function cloneGitRepoAndGetDiff(gitRepoUrl, branchName, extra = {}) {
|
|
|
84
60
|
import_utils.logger.info("临时目录建立完成");
|
|
85
61
|
try {
|
|
86
62
|
let stderr, failed;
|
|
87
|
-
(
|
|
88
|
-
(0,
|
|
63
|
+
import_utils.logger.ready(`准备clone 源代码到临时目录下的 ${today}/${import_constants.TARGET} 文件夹`);
|
|
64
|
+
const repoUrl = (0, import_parseGitLabDiffUril.getGitRepoUrlByToken)(gitRepoUrl, token || "");
|
|
65
|
+
await (0, import_gitUtil.cloneRepoWithBranchAndDefault)(repoUrl, branchName, (0, import_path.join)(today, import_constants.TARGET));
|
|
89
66
|
import_utils.logger.ready("准备生成git_diff.txt文件");
|
|
90
67
|
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff master..${branchName} --unified=0 --output=${import__.gitDiffFileName}`, { shell: true }));
|
|
91
68
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
@@ -176,7 +153,6 @@ async function gitDiffTool(arg) {
|
|
|
176
153
|
}
|
|
177
154
|
// Annotate the CommonJS export names for ESM import in node:
|
|
178
155
|
0 && (module.exports = {
|
|
179
|
-
cloneGitRepo,
|
|
180
156
|
cloneGitRepoAndGetDiff,
|
|
181
157
|
gitDiffTool
|
|
182
158
|
});
|