js-code-detector 0.0.39 → 0.0.41

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.
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/util/report_util/getMadgeInstance.ts
@@ -23,16 +33,9 @@ __export(getMadgeInstance_exports, {
23
33
  });
24
34
  module.exports = __toCommonJS(getMadgeInstance_exports);
25
35
  var import_path = require("path");
26
- var import_utils = require("@umijs/utils");
27
- var MADGE_NAME = "madge";
36
+ var import_madge = __toESM(require("madge"));
28
37
  async function getMadgeInstance(devTmpDir, targetDirPath, exclude, filteredAlias, tsconfig = {}) {
29
38
  const exportsFile = (0, import_path.join)(devTmpDir, "exports.ts");
30
- const madgePkg = (0, import_path.dirname)(
31
- import_utils.resolve.sync(`${MADGE_NAME}/package.json`, {
32
- basedir: process.cwd()
33
- })
34
- );
35
- const madge = require(madgePkg);
36
39
  const madgeConfig = {
37
40
  tsConfig: {
38
41
  compilerOptions: {
@@ -58,7 +61,7 @@ async function getMadgeInstance(devTmpDir, targetDirPath, exclude, filteredAlias
58
61
  excludeRegExp: exclude,
59
62
  baseDir: targetDirPath
60
63
  };
61
- const res = await madge((0, import_path.join)(devTmpDir, "umi.ts"), madgeConfig);
64
+ const res = await (0, import_madge.default)((0, import_path.join)(devTmpDir, "umi.ts"), madgeConfig);
62
65
  return res;
63
66
  }
64
67
  // Annotate the CommonJS export names for ESM import in node:
@@ -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,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;
@@ -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,7 +26,6 @@ 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");
30
29
  var userAliasGetter = (cwd, appData) => {
31
30
  var _a;
32
31
  return ((_a = appData.config) == null ? void 0 : _a.alias) || {
@@ -37,7 +36,6 @@ var userAliasGetter = (cwd, appData) => {
37
36
  };
38
37
  };
39
38
  async function umi4SetUp({ targetDirPath }) {
40
- const minVersion = (0, import_getRepoSupportFlag.getMinVersion)((0, import_path.join)(targetDirPath, "package.json"), "@umijs/max");
41
39
  import_utils.logger.info(`正在安装 @umijs/max@ 并执行 setup 脚本...`);
42
40
  const shellExeResult = await import_utils.execa.execa(`cd ${targetDirPath} && yarn remove @umijs/max && yarn add @umijs/max && npx max setup`, { shell: true });
43
41
  const tsconfig = await import_utils.tsconfigPaths.loadConfig(targetDirPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-code-detector",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",