js-code-detector 0.0.38 → 0.0.39

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,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
  });
@@ -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.39",
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",