js-code-detector 0.0.32 → 0.0.33
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
|
@@ -48,6 +48,6 @@ export declare function gitDiffDetectByUrl(inputUrl: string): Promise<{
|
|
|
48
48
|
filePath: string;
|
|
49
49
|
}[];
|
|
50
50
|
} | undefined>;
|
|
51
|
-
export declare function getUpstreamDependenceJson(inputUrl: string): Promise<{
|
|
51
|
+
export declare function getUpstreamDependenceJson(inputUrl: string, cloneType?: 'ssh'): Promise<{
|
|
52
52
|
[k: string]: string[];
|
|
53
53
|
} | undefined>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -75,9 +75,9 @@ async function gitDiffDetectByUrl(inputUrl) {
|
|
|
75
75
|
const gitInfo = (0, import_parseGitLabDiffUril.parseGitLabCompareUrl)(inputUrl);
|
|
76
76
|
return (0, import_gitDiffTool.gitDiffTool)({ ...gitInfo, tempDirPath: today, generateFile: [] });
|
|
77
77
|
}
|
|
78
|
-
async function getUpstreamDependenceJson(inputUrl) {
|
|
78
|
+
async function getUpstreamDependenceJson(inputUrl, cloneType) {
|
|
79
79
|
const gitInfo = (0, import_parseGitLabDiffUril.parseGitLabCompareUrl)(inputUrl);
|
|
80
|
-
return (0, import_gitDiffTool.cloneGitRepoAndGetDiff)(gitInfo.gitRepoUrl, gitInfo.targetBranch);
|
|
80
|
+
return (0, import_gitDiffTool.cloneGitRepoAndGetDiff)(gitInfo.gitRepoUrl, gitInfo.targetBranch, cloneType);
|
|
81
81
|
}
|
|
82
82
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
83
|
0 && (module.exports = {
|
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/util/parseGitLabDiffUril.ts
|
|
20
20
|
var parseGitLabDiffUril_exports = {};
|
|
21
21
|
__export(parseGitLabDiffUril_exports, {
|
|
22
|
+
getSshGitRepoUrl: () => getSshGitRepoUrl,
|
|
22
23
|
parseGitLabCompareUrl: () => parseGitLabCompareUrl
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(parseGitLabDiffUril_exports);
|
|
@@ -57,7 +58,11 @@ function parseGitLabCompareUrl(compareUrl) {
|
|
|
57
58
|
targetBranch
|
|
58
59
|
};
|
|
59
60
|
}
|
|
61
|
+
function getSshGitRepoUrl(gitRepoUrl) {
|
|
62
|
+
return gitRepoUrl.replace(/https?:\/\/[^/]+/, "git@");
|
|
63
|
+
}
|
|
60
64
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
65
|
0 && (module.exports = {
|
|
66
|
+
getSshGitRepoUrl,
|
|
62
67
|
parseGitLabCompareUrl
|
|
63
68
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { generateGitDiffReport } from "../report_util/generateGitDiffReport";
|
|
2
|
-
export declare function cloneGitRepo(gitUrl: string, branchName: string, tempDirPath: string, folder: string): Promise<{
|
|
2
|
+
export declare function cloneGitRepo(gitUrl: string, branchName: string, tempDirPath: string, folder: string, cloneType?: 'ssh'): Promise<{
|
|
3
3
|
failed: boolean;
|
|
4
4
|
stderr: string;
|
|
5
5
|
}>;
|
|
6
|
-
export declare function cloneGitRepoAndGetDiff(gitRepoUrl: string, branchName: string): Promise<{
|
|
6
|
+
export declare function cloneGitRepoAndGetDiff(gitRepoUrl: string, branchName: string, cloneType?: 'ssh'): Promise<{
|
|
7
7
|
[k: string]: string[];
|
|
8
8
|
} | undefined>;
|
|
9
9
|
export declare function gitDiffTool(arg: {
|
|
@@ -34,6 +34,7 @@ __export(gitDiffTool_exports, {
|
|
|
34
34
|
gitDiffTool: () => gitDiffTool
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(gitDiffTool_exports);
|
|
37
|
+
var import_parseGitLabDiffUril = require("../parseGitLabDiffUril");
|
|
37
38
|
var import_utils = require("@umijs/utils");
|
|
38
39
|
var import_await_to_js = __toESM(require("await-to-js"));
|
|
39
40
|
var import_constants = require("../constants");
|
|
@@ -47,10 +48,15 @@ var import__ = require("../../index");
|
|
|
47
48
|
var import_dayjs = __toESM(require("dayjs"));
|
|
48
49
|
var import_fs = require("fs");
|
|
49
50
|
var import_format_git_diff_content = require("../format_git_diff_content");
|
|
50
|
-
async function cloneGitRepo(gitUrl, branchName, tempDirPath, folder) {
|
|
51
|
+
async function cloneGitRepo(gitUrl, branchName, tempDirPath, folder, cloneType) {
|
|
51
52
|
import_utils.logger.ready(`准备clone 源代码到临时目录下的 ${tempDirPath}/${folder} 文件夹`);
|
|
52
53
|
let stderr, failed;
|
|
53
|
-
|
|
54
|
+
if (cloneType === "ssh") {
|
|
55
|
+
const sshGitRepoUrl = (0, import_parseGitLabDiffUril.getSshGitRepoUrl)(gitUrl);
|
|
56
|
+
({ stderr, failed } = await import_utils.execa.execa(`git clone ${sshGitRepoUrl} ${tempDirPath}/${folder}`, { shell: true }));
|
|
57
|
+
} else {
|
|
58
|
+
({ stderr, failed } = await import_utils.execa.execa(`git clone ${gitUrl} ${tempDirPath}/${folder}`, { shell: true }));
|
|
59
|
+
}
|
|
54
60
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
55
61
|
import_utils.logger.info("源代码clone完成");
|
|
56
62
|
if (branchName !== "master") {
|
|
@@ -61,7 +67,7 @@ async function cloneGitRepo(gitUrl, branchName, tempDirPath, folder) {
|
|
|
61
67
|
}
|
|
62
68
|
return { failed, stderr };
|
|
63
69
|
}
|
|
64
|
-
async function cloneGitRepoAndGetDiff(gitRepoUrl, branchName) {
|
|
70
|
+
async function cloneGitRepoAndGetDiff(gitRepoUrl, branchName, cloneType) {
|
|
65
71
|
const today = (0, import_dayjs.default)().format("YYYYMDD_HHmmss") + Math.random().toString(36).slice(-5);
|
|
66
72
|
import_utils.logger.ready("准备生成临时工作目录...");
|
|
67
73
|
const [err] = await (0, import_await_to_js.default)(import_utils.execa.execa(`rm -rf ${today}`, { shell: true }));
|
|
@@ -72,7 +78,7 @@ async function cloneGitRepoAndGetDiff(gitRepoUrl, branchName) {
|
|
|
72
78
|
import_utils.logger.info("临时目录建立完成");
|
|
73
79
|
try {
|
|
74
80
|
let stderr, failed;
|
|
75
|
-
({ stderr, failed } = await cloneGitRepo(gitRepoUrl, branchName, today, import_constants.TARGET));
|
|
81
|
+
({ stderr, failed } = await cloneGitRepo(gitRepoUrl, branchName, today, import_constants.TARGET, cloneType));
|
|
76
82
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
77
83
|
import_utils.logger.ready("准备生成git_diff.txt文件");
|
|
78
84
|
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff master..${branchName} --unified=0 --output=${import__.gitDiffFileName}`, { shell: true }));
|