js-code-detector 0.0.38 → 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.
@@ -20,7 +20,7 @@ export declare function gitDiffDetect(): Promise<{
20
20
  effectsDownstream: string[];
21
21
  }[];
22
22
  }[];
23
- type: "modify" | "add" | "delete";
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: "modify" | "add" | "delete";
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: "modify" | "add" | "delete";
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: "modify" | "add" | "delete";
38
+ type: "add" | "delete" | "modify";
39
39
  filesDependsOnMe: string[];
40
40
  undefinedIdentifiers: string[];
41
41
  filePath: string;
@@ -1,2 +1,3 @@
1
+ import { semver } from "@umijs/utils";
1
2
  export declare function getRepoType(jsonPath: string): "umi" | null | undefined;
2
- export declare function getRepoSupportFlag(jsonPath: string): boolean;
3
+ export declare function getMinVersion(jsonPath: string, depName: string): semver.SemVer | null | undefined;
@@ -19,11 +19,12 @@ 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
- getRepoSupportFlag: () => getRepoSupportFlag,
22
+ getMinVersion: () => getMinVersion,
23
23
  getRepoType: () => getRepoType
24
24
  });
25
25
  module.exports = __toCommonJS(getRepoSupportFlag_exports);
26
26
  var import_fs = require("fs");
27
+ var import_utils = require("@umijs/utils");
27
28
  function getRepoType(jsonPath) {
28
29
  var _a;
29
30
  const isExist = (0, import_fs.existsSync)(jsonPath);
@@ -41,24 +42,23 @@ function getRepoType(jsonPath) {
41
42
  return null;
42
43
  }
43
44
  }
44
- function getRepoSupportFlag(jsonPath) {
45
- var _a;
46
- const isExist = (0, import_fs.existsSync)(jsonPath);
47
- if (!isExist)
48
- return false;
45
+ function getMinVersion(jsonPath, depName) {
46
+ var _a, _b;
49
47
  const packageJson = (0, import_fs.readFileSync)(jsonPath, "utf-8");
50
48
  if (!packageJson)
51
- return false;
49
+ return null;
52
50
  try {
53
51
  const packageJsonObj = JSON.parse(packageJson);
54
- const supportFlag = !!((_a = packageJsonObj.dependencies) == null ? void 0 : _a["@umijs/max"]);
55
- return supportFlag;
52
+ 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]);
53
+ if (v) {
54
+ return import_utils.semver.minVersion(v);
55
+ }
56
56
  } catch (e) {
57
- return false;
57
+ return null;
58
58
  }
59
59
  }
60
60
  // Annotate the CommonJS export names for ESM import in node:
61
61
  0 && (module.exports = {
62
- getRepoSupportFlag,
62
+ getMinVersion,
63
63
  getRepoType
64
64
  });
@@ -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: "modify" | "add" | "delete";
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 { cloneType, token } = extra;
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
- ({ stderr, failed } = await cloneGitRepo(gitRepoUrl, branchName, today, import_constants.TARGET, { cloneType, token }));
88
- (0, import_handleExecaError.handleExecaError)({ failed, stderr });
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
  });
@@ -26,6 +26,7 @@ var import_utils = require("@umijs/utils");
26
26
  var import_fs = require("fs");
27
27
  var import_path = require("path");
28
28
  var import_getMadgeInstance = require("../report_util/getMadgeInstance");
29
+ var import_getRepoSupportFlag = require("./getRepoSupportFlag");
29
30
  var userAliasGetter = (cwd, appData) => {
30
31
  var _a;
31
32
  return ((_a = appData.config) == null ? void 0 : _a.alias) || {
@@ -36,11 +37,13 @@ var userAliasGetter = (cwd, appData) => {
36
37
  };
37
38
  };
38
39
  async function umi4SetUp({ targetDirPath }) {
39
- const shellExeResult = await import_utils.execa.execa(`cd ${targetDirPath} && npx max setup`, { shell: true });
40
+ const minVersion = (0, import_getRepoSupportFlag.getMinVersion)((0, import_path.join)(targetDirPath, "package.json"), "@umijs/max");
41
+ import_utils.logger.info(`正在安装 @umijs/max@ 并执行 setup 脚本...`);
42
+ const shellExeResult = await import_utils.execa.execa(`cd ${targetDirPath} && yarn remove @umijs/max && yarn add @umijs/max && npx max setup`, { shell: true });
40
43
  const tsconfig = await import_utils.tsconfigPaths.loadConfig(targetDirPath);
41
- const appDataContent = (0, import_fs.readFileSync)((0, import_path.join)(targetDirPath, "src", ".umi", "appData.json"), "utf-8");
42
44
  let appData = { config: null };
43
45
  try {
46
+ const appDataContent = (0, import_fs.readFileSync)((0, import_path.join)(targetDirPath, "src", ".umi", "appData.json"), "utf-8");
44
47
  appData = JSON.parse(appDataContent);
45
48
  } catch (e) {
46
49
  console.warn("appData.json 解析失败,将使用默认别名");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-code-detector",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -35,7 +35,6 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/parser": "^7.28.3",
38
- "@umijs/max": "^4.5.3",
39
38
  "@umijs/utils": "^4.4.12",
40
39
  "await-to-js": "^3.0.0",
41
40
  "crypto-js": "^4.2.0",