js-code-detector 0.0.48 → 0.0.51

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.
Files changed (47) hide show
  1. package/dist/cjs/index.d.ts +1 -43
  2. package/dist/cjs/index.js +3 -25
  3. package/dist/cjs/services/DetectService.d.ts +3 -1
  4. package/dist/cjs/services/DetectService.js +30 -7
  5. package/dist/cjs/services/ProjectService.d.ts +1 -2
  6. package/dist/cjs/services/projectServiceClass/UmiProjectService.d.ts +4 -0
  7. package/dist/cjs/services/projectServiceClass/UmiProjectService.js +11 -7
  8. package/dist/cjs/services/projectServiceClass/VueProjectService.d.ts +31 -0
  9. package/dist/cjs/services/projectServiceClass/VueProjectService.js +191 -0
  10. package/dist/cjs/util/ast_util/AstFeatUtil.js +2 -4
  11. package/dist/cjs/util/ast_util/AstKit.d.ts +30 -0
  12. package/dist/cjs/util/ast_util/AstKit.js +574 -0
  13. package/dist/cjs/util/ast_util/AstUtil.d.ts +7 -7
  14. package/dist/cjs/util/ast_util/AstUtil.js +18 -14
  15. package/dist/cjs/util/ast_util/SHARED_CONSTANTS.d.ts +3 -0
  16. package/dist/cjs/util/ast_util/SHARED_CONSTANTS.js +35 -0
  17. package/dist/cjs/util/constants.d.ts +1 -0
  18. package/dist/cjs/util/constants.js +5 -2
  19. package/dist/cjs/util/{shared/gitUtil.d.ts → git_util/cloneRepoWithBranchAndDefault.d.ts} +1 -5
  20. package/dist/cjs/util/{shared/gitUtil.js → git_util/cloneRepoWithBranchAndDefault.js} +5 -25
  21. package/dist/cjs/util/git_util/execGitDiff.d.ts +4 -0
  22. package/dist/cjs/util/git_util/execGitDiff.js +39 -0
  23. package/dist/cjs/util/git_util/getGitRepositoryAndBranch.d.ts +4 -0
  24. package/dist/cjs/util/{report_util/getFileDepends.js → git_util/getGitRepositoryAndBranch.js} +15 -18
  25. package/dist/cjs/util/{parseGitLabDiffUril.js → git_util/parseGitLabDiffUril.js} +2 -2
  26. package/dist/cjs/util/{shared → project_umi_util}/umi4ProjectUtil.js +1 -1
  27. package/dist/cjs/util/{shared → project_umi_util}/vueProjectUtil.js +1 -1
  28. package/dist/cjs/util/report_util/createDependenceMap.js +3 -3
  29. package/dist/cjs/util/report_util/filterEffectedCode.d.ts +1 -1
  30. package/dist/cjs/util/report_util/filterEffectedExportMember.js +5 -1
  31. package/dist/cjs/util/report_util/generateGitDiffReport.d.ts +1 -1
  32. package/dist/cjs/util/report_util/generateGitDiffReport.js +2 -2
  33. package/dist/cjs/util/{ast_util/filePathResolver.d.ts → report_util/resolveImportPath.d.ts} +1 -1
  34. package/dist/cjs/util/{ast_util/filePathResolver.js → report_util/resolveImportPath.js} +5 -9
  35. package/dist/cjs/util/{createRandomStr.js → shared/createRandomStr.js} +1 -1
  36. package/dist/cjs/util/shared/getRepoSupportFlag.d.ts +1 -3
  37. package/dist/cjs/util/shared/getRepoSupportFlag.js +1 -18
  38. package/dist/cjs/util/shared/gitDiffTool.d.ts +0 -40
  39. package/dist/cjs/util/shared/gitDiffTool.js +7 -116
  40. package/package.json +5 -1
  41. package/dist/cjs/util/madge_util.d.ts +0 -12
  42. package/dist/cjs/util/madge_util.js +0 -120
  43. package/dist/cjs/util/report_util/getFileDepends.d.ts +0 -1
  44. /package/dist/cjs/util/{parseGitLabDiffUril.d.ts → git_util/parseGitLabDiffUril.d.ts} +0 -0
  45. /package/dist/cjs/util/{shared → project_umi_util}/umi4ProjectUtil.d.ts +0 -0
  46. /package/dist/cjs/util/{shared → project_umi_util}/vueProjectUtil.d.ts +0 -0
  47. /package/dist/cjs/util/{createRandomStr.d.ts → shared/createRandomStr.d.ts} +0 -0
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "js-code-detector",
3
- "version": "0.0.48",
3
+ "version": "0.0.51",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
7
7
  "scripts": {
8
+ "test": "jest",
8
9
  "dev": "father dev",
9
10
  "build": "father build",
10
11
  "build:deps": "father prebundle",
@@ -29,9 +30,12 @@
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/crypto-js": "^4.2.2",
33
+ "@types/jest": "^30.0.0",
32
34
  "@types/lodash": "^4.17.20",
33
35
  "@types/madge": "^5.0.3",
34
36
  "father": "^4.6.3",
37
+ "jest": "^30.2.0",
38
+ "ts-jest": "^29.4.5",
35
39
  "tsx": "^4.20.6"
36
40
  },
37
41
  "dependencies": {
@@ -1,12 +0,0 @@
1
- import { MadgeInstance } from "madge";
2
- interface IMadgeInstance extends MadgeInstance {
3
- tree: Record<string, string[]>;
4
- }
5
- export default function (api: any): Promise<{
6
- usingFiles: {
7
- filePath: string;
8
- name: string;
9
- }[];
10
- madgeInstance: IMadgeInstance;
11
- } | undefined>;
12
- export {};
@@ -1,120 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/util/madge_util.ts
20
- var madge_util_exports = {};
21
- __export(madge_util_exports, {
22
- default: () => madge_util_default
23
- });
24
- module.exports = __toCommonJS(madge_util_exports);
25
- var import_path = require("path");
26
- var import_utils = require("@umijs/utils");
27
- var MADGE_NAME = "madge";
28
- async function madge_util_default(api) {
29
- var _a, _b;
30
- const userAlias = api.config.alias;
31
- if (!userAlias) {
32
- console.log("userAlias -> null");
33
- return;
34
- }
35
- const cwd = api.cwd;
36
- const tsconfig = await import_utils.tsconfigPaths.loadConfig(cwd);
37
- const exclude = [/node_modules/, /\.d\.ts$/, /\.umi/];
38
- const isExclude = (path) => {
39
- return exclude.some((reg) => reg.test(path));
40
- };
41
- const parsedAlias = import_utils.aliasUtils.parseCircleAlias({
42
- alias: userAlias
43
- });
44
- const filteredAlias = Object.keys(parsedAlias).reduce(
45
- (acc, key) => {
46
- var _a2, _b2;
47
- const value = parsedAlias[key];
48
- if (isExclude(value)) {
49
- return acc;
50
- }
51
- if ((_a2 = tsconfig.paths) == null ? void 0 : _a2[key]) {
52
- return acc;
53
- }
54
- const tsconfigValue = [(0, import_path.join)((0, import_path.relative)(cwd, value), "/*")];
55
- const tsconfigKey = `${key}/*`;
56
- if ((_b2 = tsconfig.paths) == null ? void 0 : _b2[tsconfigKey]) {
57
- return acc;
58
- }
59
- acc[tsconfigKey] = tsconfigValue;
60
- return acc;
61
- },
62
- {}
63
- );
64
- const devTmpDir = (0, import_path.join)(api.paths.absSrcPath, ".umi");
65
- const entryFile = (0, import_path.join)(devTmpDir, "umi.ts");
66
- const exportsFile = (0, import_path.join)(devTmpDir, "exports.ts");
67
- const madgePkg = (0, import_path.dirname)(
68
- import_utils.resolve.sync(`${MADGE_NAME}/package.json`, {
69
- basedir: cwd
70
- })
71
- );
72
- const madge = require(madgePkg);
73
- const madgeConfig = {
74
- tsConfig: {
75
- compilerOptions: {
76
- baseUrl: tsconfig.baseUrl,
77
- paths: {
78
- ...filteredAlias,
79
- ...tsconfig.paths,
80
- umi: [exportsFile],
81
- "@umijs/max": [exportsFile],
82
- // 适配 bigfish
83
- ...((_b = (_a = api.appData) == null ? void 0 : _a.umi) == null ? void 0 : _b.importSource) ? {
84
- [api.appData.umi.importSource]: [exportsFile]
85
- } : {}
86
- },
87
- target: "esnext",
88
- module: "esnext",
89
- moduleResolution: "node",
90
- importHelpers: true,
91
- jsx: "react-jsx",
92
- esModuleInterop: true,
93
- strict: true,
94
- resolveJsonModule: true,
95
- allowSyntheticDefaultImports: true
96
- }
97
- },
98
- fileExtensions: ["ts", "tsx", "js", "jsx"],
99
- excludeRegExp: exclude,
100
- baseDir: cwd
101
- };
102
- const res = await madge(entryFile, madgeConfig);
103
- const treeMap = res.tree;
104
- const dependenceMap = Object.keys(treeMap).reduce(
105
- (acc, key) => {
106
- const path = (0, import_utils.winPath)((0, import_path.join)(api.paths.cwd, key));
107
- acc[path] = true;
108
- return acc;
109
- },
110
- {}
111
- );
112
- const usingFiles = (0, import_utils.readDirFiles)({
113
- dir: api.paths.absSrcPath,
114
- exclude
115
- }).filter(({ filePath }) => dependenceMap[filePath]);
116
- return {
117
- usingFiles,
118
- madgeInstance: res
119
- };
120
- }
@@ -1 +0,0 @@
1
- export default function getFileDepends(filePath: string, tree: Record<string, string[]>): string[][];