js-code-detector 0.0.31 → 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 +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/util/parseGitLabDiffUril.d.ts +1 -0
- package/dist/cjs/util/parseGitLabDiffUril.js +5 -0
- package/dist/cjs/util/shared/gitDiffTool.d.ts +2 -2
- package/dist/cjs/util/shared/gitDiffTool.js +21 -15
- package/dist/cjs/util/shared/umi4ProjectUtil.js +1 -1
- package/dist/cjs/util/shared/vueProjectUtil.js +1 -1
- package/package.json +1 -1
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
|
@@ -47,9 +47,9 @@ var import_parseGitLabDiffUril = require("./util/parseGitLabDiffUril");
|
|
|
47
47
|
var import_gitDiffTool = require("./util/shared/gitDiffTool");
|
|
48
48
|
var gitDiffFileName = "git_diff.txt";
|
|
49
49
|
async function getGitRepositoryAndBranch() {
|
|
50
|
-
const res = await import_utils.execa.execa("git remote get-url origin", { shell:
|
|
50
|
+
const res = await import_utils.execa.execa("git remote get-url origin", { shell: true });
|
|
51
51
|
import_utils.chalk.green(["仓库地址:", res.stdout]);
|
|
52
|
-
const branch = await import_utils.execa.execa("git rev-parse --abbrev-ref HEAD", { shell:
|
|
52
|
+
const branch = await import_utils.execa.execa("git rev-parse --abbrev-ref HEAD", { shell: true });
|
|
53
53
|
import_utils.chalk.green(["分支名称:", branch.stdout]);
|
|
54
54
|
return {
|
|
55
55
|
gitUrl: res.stdout,
|
|
@@ -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,35 +48,40 @@ 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") {
|
|
57
63
|
import_utils.logger.ready("准备切换到分支");
|
|
58
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${tempDirPath}/${folder} && git fetch origin ${branchName}:${branchName} && git checkout ${branchName}`, { shell:
|
|
64
|
+
({ stderr, failed } = await import_utils.execa.execa(`cd ${tempDirPath}/${folder} && git fetch origin ${branchName}:${branchName} && git checkout ${branchName}`, { shell: true }));
|
|
59
65
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
60
66
|
import_utils.logger.info("源代码切换分支完成");
|
|
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
|
-
const [err] = await (0, import_await_to_js.default)(import_utils.execa.execa(`rm -rf ${today}`, { shell:
|
|
73
|
+
const [err] = await (0, import_await_to_js.default)(import_utils.execa.execa(`rm -rf ${today}`, { shell: true }));
|
|
68
74
|
if (err) {
|
|
69
75
|
import_utils.logger.error("临时目录删除失败");
|
|
70
76
|
}
|
|
71
|
-
await import_utils.execa.execa(`mkdir -p ${today}`, { shell:
|
|
77
|
+
await import_utils.execa.execa(`mkdir -p ${today}`, { shell: true });
|
|
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
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff master..${branchName} --unified=0 --output=${import__.gitDiffFileName}`, { shell:
|
|
84
|
+
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff master..${branchName} --unified=0 --output=${import__.gitDiffFileName}`, { shell: true }));
|
|
79
85
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
80
86
|
const repoType = await (0, import_getRepoSupportFlag.getRepoType)((0, import_path.join)(process.cwd(), today, import_constants.TARGET, "package.json"));
|
|
81
87
|
import_utils.logger.info(`项目类型为: ${repoType}`);
|
|
@@ -103,16 +109,16 @@ async function cloneGitRepoAndGetDiff(gitRepoUrl, branchName) {
|
|
|
103
109
|
async function gitDiffTool(arg) {
|
|
104
110
|
const { gitRepoUrl: gitUrl, baseBranch, targetBranch: branchName, tempDirPath: today, generateFile } = arg;
|
|
105
111
|
import_utils.logger.ready("准备生成临时工作目录...");
|
|
106
|
-
const [err] = await (0, import_await_to_js.default)(import_utils.execa.execa(`rm -rf ${today}`, { shell:
|
|
112
|
+
const [err] = await (0, import_await_to_js.default)(import_utils.execa.execa(`rm -rf ${today}`, { shell: true }));
|
|
107
113
|
if (err) {
|
|
108
114
|
import_utils.logger.error("临时目录删除失败");
|
|
109
115
|
}
|
|
110
|
-
await import_utils.execa.execa(`mkdir -p ${today}`, { shell:
|
|
116
|
+
await import_utils.execa.execa(`mkdir -p ${today}`, { shell: true });
|
|
111
117
|
import_utils.logger.info("临时目录建立完成");
|
|
112
118
|
try {
|
|
113
119
|
import_utils.logger.ready(`准备clone 源代码到临时目录下的 ${import_constants.TARGET} 文件夹`);
|
|
114
120
|
let stderr, failed;
|
|
115
|
-
({ stderr, failed } = await import_utils.execa.execa(`git clone ${gitUrl} ${today}/${import_constants.TARGET}`, { shell:
|
|
121
|
+
({ stderr, failed } = await import_utils.execa.execa(`git clone ${gitUrl} ${today}/${import_constants.TARGET}`, { shell: true }));
|
|
116
122
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
117
123
|
import_utils.logger.info("源代码clone完成");
|
|
118
124
|
import_utils.logger.wait("检测项目类型");
|
|
@@ -126,21 +132,21 @@ async function gitDiffTool(arg) {
|
|
|
126
132
|
return;
|
|
127
133
|
}
|
|
128
134
|
import_utils.logger.ready(`准备clone 源代码到临时目录下的 ${import_constants.SOURCE} 文件夹`);
|
|
129
|
-
({ stderr, failed } = await import_utils.execa.execa(`git clone ${gitUrl} ${today}/${import_constants.SOURCE}`, { shell:
|
|
135
|
+
({ stderr, failed } = await import_utils.execa.execa(`git clone ${gitUrl} ${today}/${import_constants.SOURCE}`, { shell: true }));
|
|
130
136
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
131
137
|
import_utils.logger.info("源代码clone完成");
|
|
132
138
|
if (baseBranch !== "master") {
|
|
133
139
|
import_utils.logger.ready("准备切换到基准分支");
|
|
134
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.SOURCE} && git fetch origin ${baseBranch}:${baseBranch} && git checkout ${baseBranch}`, { shell:
|
|
140
|
+
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.SOURCE} && git fetch origin ${baseBranch}:${baseBranch} && git checkout ${baseBranch}`, { shell: true }));
|
|
135
141
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
136
142
|
import_utils.logger.info("源代码切换到基准分支完成");
|
|
137
143
|
}
|
|
138
144
|
import_utils.logger.ready("准备切换到目标分支");
|
|
139
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git fetch origin ${branchName}:${branchName} && git checkout ${branchName}`, { shell:
|
|
145
|
+
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git fetch origin ${branchName}:${branchName} && git checkout ${branchName}`, { shell: true }));
|
|
140
146
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
141
147
|
import_utils.logger.info("分支切换完成");
|
|
142
148
|
import_utils.logger.ready("准备生成git_diff.txt文件");
|
|
143
|
-
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff ${baseBranch}..${branchName} --unified=0 --output=${import__.gitDiffFileName}`, { shell:
|
|
149
|
+
({ stderr, failed } = await import_utils.execa.execa(`cd ${today}/${import_constants.TARGET} && git diff ${baseBranch}..${branchName} --unified=0 --output=${import__.gitDiffFileName}`, { shell: true }));
|
|
144
150
|
(0, import_handleExecaError.handleExecaError)({ failed, stderr });
|
|
145
151
|
import_utils.logger.info("git_diff.txt文件生成完成");
|
|
146
152
|
if (repoType === "umi") {
|
|
@@ -36,7 +36,7 @@ var userAliasGetter = (cwd, appData) => {
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
async function umi4SetUp({ targetDirPath }) {
|
|
39
|
-
const shellExeResult = await import_utils.execa.execa(`cd ${targetDirPath} && npx max setup`, { shell:
|
|
39
|
+
const shellExeResult = await import_utils.execa.execa(`cd ${targetDirPath} && npx max setup`, { shell: true });
|
|
40
40
|
const tsconfig = await import_utils.tsconfigPaths.loadConfig(targetDirPath);
|
|
41
41
|
const appDataContent = (0, import_fs.readFileSync)((0, import_path.join)(targetDirPath, "src", ".umi", "appData.json"), "utf-8");
|
|
42
42
|
let appData = { config: null };
|
|
@@ -27,7 +27,7 @@ var import_fs = require("fs");
|
|
|
27
27
|
var import_utils = require("@umijs/utils");
|
|
28
28
|
var webpackConfigFileName = "__webpack.config.js";
|
|
29
29
|
async function vueSetUp({ targetDir }) {
|
|
30
|
-
const shellExeResult = await import_utils.execa.execa(`cd ${targetDir} && npx vue-cli-service inspect --verbose`, { shell:
|
|
30
|
+
const shellExeResult = await import_utils.execa.execa(`cd ${targetDir} && npx vue-cli-service inspect --verbose`, { shell: true });
|
|
31
31
|
const { failed, stdout } = shellExeResult;
|
|
32
32
|
const filePath = (0, import_path.join)(targetDir, webpackConfigFileName);
|
|
33
33
|
if (!failed) {
|