js-code-detector 0.0.1

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.
@@ -0,0 +1,142 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/ast_util/FileUtil.ts
30
+ var FileUtil_exports = {};
31
+ __export(FileUtil_exports, {
32
+ default: () => FileUtil,
33
+ extensions: () => extensions,
34
+ extensionsOfJs: () => extensionsOfJs
35
+ });
36
+ module.exports = __toCommonJS(FileUtil_exports);
37
+ var babelParse = __toESM(require("@babel/parser"));
38
+ var vueParse = __toESM(require("vue-eslint-parser"));
39
+ var extensionsOfJs = [".js", ".jsx", ".ts", ".tsx"];
40
+ var extensions = [...extensionsOfJs, ".vue"];
41
+ var commonParsePlugins = [
42
+ "jsx",
43
+ "typescript",
44
+ "asyncDoExpressions",
45
+ "decimal",
46
+ "decorators",
47
+ "decoratorAutoAccessors",
48
+ "deferredImportEvaluation",
49
+ "destructuringPrivate",
50
+ "doExpressions",
51
+ "explicitResourceManagement",
52
+ "exportDefaultFrom",
53
+ "functionBind",
54
+ "functionSent",
55
+ "importAttributes",
56
+ "importReflection",
57
+ "moduleBlocks",
58
+ ["optionalChainingAssign", {
59
+ version: "2023-07"
60
+ }],
61
+ "partialApplication",
62
+ ["pipelineOperator", {
63
+ proposal: "hack",
64
+ topicToken: "^^"
65
+ }],
66
+ "recordAndTuple",
67
+ "sourcePhaseImports",
68
+ "throwExpressions"
69
+ ];
70
+ var FileUtil = class {
71
+ static parseVue(filePath, fileContent) {
72
+ return vueParse.parse(fileContent, {
73
+ vueFeatures: {
74
+ styleCSSVariableInjection: false,
75
+ filter: false
76
+ },
77
+ parser: {
78
+ parse: (...arg) => {
79
+ const ast = babelParse.parse(...arg);
80
+ return ast.program;
81
+ }
82
+ },
83
+ range: true,
84
+ ranges: true,
85
+ sourceType: "module",
86
+ // 指定源代码类型,这里是模块
87
+ filePath,
88
+ ecmaVersion: "latest",
89
+ "ecmaFeatures": {
90
+ "globalReturn": true,
91
+ "impliedStrict": true,
92
+ "jsx": true,
93
+ "tsx": true
94
+ },
95
+ plugins: commonParsePlugins
96
+ });
97
+ }
98
+ static parseJsxLike(filePath, fileContent) {
99
+ return babelParse.parse(fileContent, {
100
+ ranges: true,
101
+ allowReturnOutsideFunction: true,
102
+ allowImportExportEverywhere: true,
103
+ sourceType: "module",
104
+ sourceFilename: filePath,
105
+ plugins: commonParsePlugins
106
+ });
107
+ }
108
+ static createMapFilePathToDetail(list) {
109
+ return new Map(list.map(({ filePath, fileContent }) => {
110
+ const lines = fileContent.split("\n");
111
+ return [
112
+ filePath,
113
+ {
114
+ lines,
115
+ filePath,
116
+ fileContent
117
+ }
118
+ ];
119
+ }));
120
+ }
121
+ static parseFile(filePath, fileContent) {
122
+ try {
123
+ if (filePath.endsWith(".vue")) {
124
+ return ["", this.parseVue(filePath, fileContent)];
125
+ } else if (extensionsOfJs.some((ext) => filePath.endsWith(ext))) {
126
+ return ["", this.parseJsxLike(filePath, fileContent)];
127
+ }
128
+ } catch (e) {
129
+ return [filePath + "解析AST出错: " + e.message, null];
130
+ }
131
+ return ["", null];
132
+ }
133
+ static getASTByFilePath(filePath) {
134
+ const fileContent = require("fs").readFileSync(filePath, "utf8");
135
+ return this.parseFile(filePath, fileContent)[1];
136
+ }
137
+ };
138
+ // Annotate the CommonJS export names for ESM import in node:
139
+ 0 && (module.exports = {
140
+ extensions,
141
+ extensionsOfJs
142
+ });
@@ -0,0 +1,5 @@
1
+ import { AstNode } from "./AstUtil";
2
+ export default function getAstKitByFilePath(filePath: string, absPathPrefix: string): {
3
+ mapFileLineToNodeSet: Map<number, Set<AstNode>>;
4
+ mapUuidToNode: Map<string, AstNode>;
5
+ };
@@ -0,0 +1,52 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/ast_util/getAstKitByFilePath.ts
30
+ var getAstKitByFilePath_exports = {};
31
+ __export(getAstKitByFilePath_exports, {
32
+ default: () => getAstKitByFilePath
33
+ });
34
+ module.exports = __toCommonJS(getAstKitByFilePath_exports);
35
+ var import_AstUtil = __toESM(require("./AstUtil"));
36
+ var import_FileUtil = __toESM(require("./FileUtil"));
37
+ var mapFilePathToTools = /* @__PURE__ */ new Map();
38
+ var createMapFileLineToNodeSet = (file, absPathPrefix) => {
39
+ const ast = import_FileUtil.default.getASTByFilePath(file);
40
+ const mapUuidToNode = /* @__PURE__ */ new Map();
41
+ const mapFileLineToNodeSet = /* @__PURE__ */ new Map();
42
+ const filePathRelative = file.replace(absPathPrefix, "");
43
+ import_AstUtil.default.deepFirstTravel(ast, filePathRelative, mapUuidToNode, mapFileLineToNodeSet);
44
+ return { mapFileLineToNodeSet, mapUuidToNode };
45
+ };
46
+ function getAstKitByFilePath(filePath, absPathPrefix) {
47
+ let tools = mapFilePathToTools.get(filePath);
48
+ if (!tools) {
49
+ mapFilePathToTools.set(filePath, tools = createMapFileLineToNodeSet(filePath, absPathPrefix));
50
+ }
51
+ return tools;
52
+ }
@@ -0,0 +1 @@
1
+ export declare const windowProperties: string[];
@@ -0,0 +1,228 @@
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/ast_util/windowProperties.ts
20
+ var windowProperties_exports = {};
21
+ __export(windowProperties_exports, {
22
+ windowProperties: () => windowProperties
23
+ });
24
+ module.exports = __toCommonJS(windowProperties_exports);
25
+ var windowProperties = [
26
+ "close",
27
+ "stop",
28
+ "focus",
29
+ "blur",
30
+ "open",
31
+ "alert",
32
+ "confirm",
33
+ "prompt",
34
+ "print",
35
+ "postMessage",
36
+ "captureEvents",
37
+ "releaseEvents",
38
+ "getSelection",
39
+ "getComputedStyle",
40
+ "matchMedia",
41
+ "moveTo",
42
+ "moveBy",
43
+ "resizeTo",
44
+ "resizeBy",
45
+ "scroll",
46
+ "scrollTo",
47
+ "scrollBy",
48
+ "find",
49
+ "requestIdleCallback",
50
+ "cancelIdleCallback",
51
+ "requestAnimationFrame",
52
+ "cancelAnimationFrame",
53
+ "reportError",
54
+ "btoa",
55
+ "atob",
56
+ "setTimeout",
57
+ "clearTimeout",
58
+ "setInterval",
59
+ "clearInterval",
60
+ "queueMicrotask",
61
+ "createImageBitmap",
62
+ "structuredClone",
63
+ "fetch",
64
+ "self",
65
+ "name",
66
+ "history",
67
+ "customElements",
68
+ "locationbar",
69
+ "menubar",
70
+ "personalbar",
71
+ "scrollbars",
72
+ "statusbar",
73
+ "toolbar",
74
+ "status",
75
+ "closed",
76
+ "event",
77
+ "frames",
78
+ "length",
79
+ "opener",
80
+ "parent",
81
+ "frameElement",
82
+ "navigator",
83
+ "clientInformation",
84
+ "external",
85
+ "screen",
86
+ "innerWidth",
87
+ "innerHeight",
88
+ "scrollX",
89
+ "pageXOffset",
90
+ "scrollY",
91
+ "pageYOffset",
92
+ "screenLeft",
93
+ "screenTop",
94
+ "screenX",
95
+ "screenY",
96
+ "outerWidth",
97
+ "outerHeight",
98
+ "performance",
99
+ "devicePixelRatio",
100
+ "ondevicemotion",
101
+ "ondeviceorientation",
102
+ "ondeviceorientationabsolute",
103
+ "visualViewport",
104
+ "crypto",
105
+ "onabort",
106
+ "onblur",
107
+ "onfocus",
108
+ "oncancel",
109
+ "onauxclick",
110
+ "onbeforeinput",
111
+ "onbeforetoggle",
112
+ "oncanplay",
113
+ "oncanplaythrough",
114
+ "onchange",
115
+ "onclick",
116
+ "onclose",
117
+ "oncontentvisibilityautostatechange",
118
+ "oncontextlost",
119
+ "oncontextmenu",
120
+ "oncontextrestored",
121
+ "oncuechange",
122
+ "ondblclick",
123
+ "ondrag",
124
+ "ondragend",
125
+ "ondragenter",
126
+ "ondragleave",
127
+ "ondragover",
128
+ "ondragstart",
129
+ "ondrop",
130
+ "ondurationchange",
131
+ "onemptied",
132
+ "onended",
133
+ "onformdata",
134
+ "oninput",
135
+ "oninvalid",
136
+ "onkeydown",
137
+ "onkeypress",
138
+ "onkeyup",
139
+ "onload",
140
+ "onloadeddata",
141
+ "onloadedmetadata",
142
+ "onloadstart",
143
+ "onmousedown",
144
+ "onmouseenter",
145
+ "onmouseleave",
146
+ "onmousemove",
147
+ "onmouseout",
148
+ "onmouseover",
149
+ "onmouseup",
150
+ "onwheel",
151
+ "onpause",
152
+ "onplay",
153
+ "onplaying",
154
+ "onprogress",
155
+ "onratechange",
156
+ "onreset",
157
+ "onresize",
158
+ "onscroll",
159
+ "onscrollend",
160
+ "onsecuritypolicyviolation",
161
+ "onseeked",
162
+ "onseeking",
163
+ "onselect",
164
+ "onslotchange",
165
+ "onstalled",
166
+ "onsubmit",
167
+ "onsuspend",
168
+ "ontimeupdate",
169
+ "onvolumechange",
170
+ "onwaiting",
171
+ "onselectstart",
172
+ "onselectionchange",
173
+ "ontoggle",
174
+ "onpointercancel",
175
+ "onpointerdown",
176
+ "onpointerup",
177
+ "onpointermove",
178
+ "onpointerout",
179
+ "onpointerover",
180
+ "onpointerenter",
181
+ "onpointerleave",
182
+ "ongotpointercapture",
183
+ "onlostpointercapture",
184
+ "onanimationend",
185
+ "onanimationiteration",
186
+ "onanimationstart",
187
+ "ontransitioncancel",
188
+ "ontransitionend",
189
+ "ontransitionrun",
190
+ "ontransitionstart",
191
+ "onwebkitanimationend",
192
+ "onwebkitanimationiteration",
193
+ "onwebkitanimationstart",
194
+ "onwebkittransitionend",
195
+ "onerror",
196
+ "speechSynthesis",
197
+ "onafterprint",
198
+ "onbeforeprint",
199
+ "onbeforeunload",
200
+ "onhashchange",
201
+ "onlanguagechange",
202
+ "onmessage",
203
+ "onmessageerror",
204
+ "onoffline",
205
+ "ononline",
206
+ "onpagehide",
207
+ "onpageshow",
208
+ "onpopstate",
209
+ "onrejectionhandled",
210
+ "onstorage",
211
+ "onunhandledrejection",
212
+ "onunload",
213
+ "localStorage",
214
+ "origin",
215
+ "crossOriginIsolated",
216
+ "isSecureContext",
217
+ "indexedDB",
218
+ "caches",
219
+ "sessionStorage",
220
+ "window",
221
+ "document",
222
+ "location",
223
+ "top"
224
+ ];
225
+ // Annotate the CommonJS export names for ESM import in node:
226
+ 0 && (module.exports = {
227
+ windowProperties
228
+ });
@@ -0,0 +1,11 @@
1
+ export type GitDiffDetail = {
2
+ filePath: string;
3
+ type: "add" | "delete" | "modify";
4
+ subType: "add" | "delete" | "modify";
5
+ startLineOfNew: string;
6
+ oldBranchLineScope: string;
7
+ startLineOfOld: string;
8
+ newBranchLineScope: string;
9
+ items: string[];
10
+ };
11
+ export declare function formatGitDiffContent(modifyContent: string): GitDiffDetail[];
@@ -0,0 +1,70 @@
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/format_git_diff_content.ts
20
+ var format_git_diff_content_exports = {};
21
+ __export(format_git_diff_content_exports, {
22
+ formatGitDiffContent: () => formatGitDiffContent
23
+ });
24
+ module.exports = __toCommonJS(format_git_diff_content_exports);
25
+ function formatGitDiffContent(modifyContent) {
26
+ const detailList = [];
27
+ if (typeof modifyContent !== "string") {
28
+ return detailList;
29
+ }
30
+ const lines = modifyContent.split(/\n/);
31
+ let filePath = "";
32
+ let mainType = "modify";
33
+ let subType = "modify";
34
+ lines.forEach((line, index) => {
35
+ var _a, _b;
36
+ if (line.startsWith("diff --git")) {
37
+ filePath = line.split(/\s+/)[2].slice(2);
38
+ mainType = ((_a = lines[index + 1]) == null ? void 0 : _a.startsWith("new file")) ? "add" : ((_b = lines[index + 1]) == null ? void 0 : _b.startsWith("deleted")) ? "delete" : "modify";
39
+ }
40
+ if (line.startsWith("@@")) {
41
+ const [, startLineOfOld, oldBranchLineScope, startLineOfNew, newBranchLineScope] = line.match(/@@ -(\d+),?(\d*) \+(\d+),?(\d*)/) || [];
42
+ if (newBranchLineScope === "0") {
43
+ subType = "delete";
44
+ } else if (oldBranchLineScope === "0") {
45
+ subType = "add";
46
+ } else {
47
+ subType = "modify";
48
+ }
49
+ detailList.push({
50
+ filePath,
51
+ type: mainType,
52
+ subType,
53
+ startLineOfNew,
54
+ newBranchLineScope: newBranchLineScope ? newBranchLineScope : "1",
55
+ startLineOfOld,
56
+ oldBranchLineScope: oldBranchLineScope ? oldBranchLineScope : "1",
57
+ items: []
58
+ });
59
+ }
60
+ if (line.startsWith("+") && !line.startsWith("+++") || line.startsWith("-") && !line.startsWith("---")) {
61
+ const lastItem = detailList[detailList.length - 1];
62
+ lastItem.type !== "delete" && lastItem.items.push(line);
63
+ }
64
+ });
65
+ return detailList;
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ formatGitDiffContent
70
+ });
@@ -0,0 +1,12 @@
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 {};
@@ -0,0 +1,120 @@
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
+ }
@@ -0,0 +1,27 @@
1
+ import { AstNode } from "../ast_util/AstUtil";
2
+ import { GitDiffDetail } from "../format_git_diff_content";
3
+ type BlockReportKind = "Import" | "Declaration" | "Assignment" | "SelfUpdate" | "Invoke" | "Other" | "Never";
4
+ type EffectItem = {
5
+ causeBy: AstNode;
6
+ effects: AstNode[];
7
+ };
8
+ export type BlockReport = {
9
+ kind: BlockReportKind;
10
+ diff_txt: string[];
11
+ topAdded: AstNode[];
12
+ topRemoved: AstNode[];
13
+ added: string[];
14
+ addedNotUsed: string[];
15
+ addedNotFound: string[];
16
+ addedEffects: EffectItem[];
17
+ removed: string[];
18
+ removedStillUsing: string[];
19
+ removedEffects: EffectItem[];
20
+ };
21
+ type Arg = {
22
+ gitDiffItem: GitDiffDetail;
23
+ absPathPrefix: string;
24
+ blockReports: BlockReport[];
25
+ };
26
+ export default function codeBlockDetect(arg: Arg): void;
27
+ export {};