@rsdoctor/core 2.0.0-alpha.1 → 2.0.0-alpha.2
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.
- package/dist/26.js +26163 -0
- package/dist/630.js +1269 -0
- package/dist/630.js.LICENSE.txt +7 -0
- package/dist/build-utils/build/chunks/assetsModules.d.ts +7 -1
- package/dist/build-utils/build/loader/probeLoader.d.ts +7 -2
- package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1725 -7
- package/dist/inner-plugins/constants.d.ts +1 -1
- package/dist/inner-plugins/plugins/base.d.ts +2 -2
- package/dist/logger.d.ts +2 -2
- package/dist/probe-loader.js +2 -0
- package/dist/proxy-loader.d.ts +1 -0
- package/dist/proxy-loader.js +48 -0
- package/dist/rslib-runtime.js +28 -0
- package/dist/rspack-plugin/constants.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/htmlParserStub.d.ts +3 -0
- package/dist/rules/rules/ecma-version-check/types.d.ts +13 -2
- package/dist/sdk/server/apis/base.d.ts +1 -1
- package/dist/sdk/server/socket/api.d.ts +1 -1
- package/dist/sdk/utils/date.d.ts +1 -0
- package/dist/types/loader.d.ts +1 -1
- package/package.json +20 -113
- package/dist/build-utils/build/chunks/assetsModules.js +0 -9
- package/dist/build-utils/build/chunks/index.js +0 -3
- package/dist/build-utils/build/chunks/rspack/transform.js +0 -44
- package/dist/build-utils/build/envinfo.js +0 -60
- package/dist/build-utils/build/file/cache.js +0 -24
- package/dist/build-utils/build/file/index.js +0 -5
- package/dist/build-utils/build/file/sharding.js +0 -38
- package/dist/build-utils/build/index.js +0 -12
- package/dist/build-utils/build/json.js +0 -67
- package/dist/build-utils/build/loader/index.js +0 -3
- package/dist/build-utils/build/loader/probeLoader.js +0 -44
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +0 -32
- package/dist/build-utils/build/module-graph/index.js +0 -2
- package/dist/build-utils/build/module-graph/parser.js +0 -13
- package/dist/build-utils/build/module-graph/rspack/transform.js +0 -111
- package/dist/build-utils/build/module-graph/utils.js +0 -60
- package/dist/build-utils/build/process.js +0 -18
- package/dist/build-utils/build/server.js +0 -107
- package/dist/build-utils/build/utils/index.js +0 -4
- package/dist/build-utils/build/utils/loader.js +0 -267
- package/dist/build-utils/build/utils/parseBundle.js +0 -238
- package/dist/build-utils/build/utils/plugin.js +0 -21
- package/dist/build-utils/index.js +0 -13
- package/dist/collection.d.ts +0 -1
- package/dist/collection.js +0 -2
- package/dist/common/file.js +0 -8
- package/dist/common/global-config.js +0 -33
- package/dist/common/index.d.ts +0 -4
- package/dist/common/index.js +0 -6
- package/dist/common-browser.d.ts +0 -1
- package/dist/common-browser.js +0 -2
- package/dist/error/error.js +0 -143
- package/dist/error/index.js +0 -3
- package/dist/error/transform.js +0 -138
- package/dist/error/utils.js +0 -23
- package/dist/graph/index.d.ts +0 -1
- package/dist/graph/index.js +0 -2
- package/dist/inner-plugins/constants.js +0 -19
- package/dist/inner-plugins/index.js +0 -3
- package/dist/inner-plugins/loaders/proxy.js +0 -65
- package/dist/inner-plugins/plugins/base.js +0 -20
- package/dist/inner-plugins/plugins/bundle.js +0 -63
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +0 -74
- package/dist/inner-plugins/plugins/errors.js +0 -65
- package/dist/inner-plugins/plugins/index.js +0 -11
- package/dist/inner-plugins/plugins/loader.js +0 -108
- package/dist/inner-plugins/plugins/plugins.js +0 -40
- package/dist/inner-plugins/plugins/progress.js +0 -35
- package/dist/inner-plugins/plugins/resolver.js +0 -57
- package/dist/inner-plugins/plugins/rspack.js +0 -99
- package/dist/inner-plugins/plugins/rules.js +0 -64
- package/dist/inner-plugins/plugins/sourcemapTool.js +0 -230
- package/dist/inner-plugins/plugins/summary.js +0 -92
- package/dist/inner-plugins/utils/circleDetect.js +0 -16
- package/dist/inner-plugins/utils/config.js +0 -141
- package/dist/inner-plugins/utils/index.js +0 -8
- package/dist/inner-plugins/utils/loader.js +0 -134
- package/dist/inner-plugins/utils/normalize-config.js +0 -77
- package/dist/inner-plugins/utils/openBrowser.js +0 -55
- package/dist/inner-plugins/utils/plugin-common.js +0 -94
- package/dist/inner-plugins/utils/plugin.js +0 -70
- package/dist/inner-plugins/utils/sdk.js +0 -19
- package/dist/logger.js +0 -51
- package/dist/rspack-plugin/constants.js +0 -23
- package/dist/rspack-plugin/index.js +0 -3
- package/dist/rspack-plugin/multiple.js +0 -39
- package/dist/rspack-plugin/plugin.js +0 -133
- package/dist/rule-utils/document/document.js +0 -46
- package/dist/rule-utils/document/index.js +0 -4
- package/dist/rule-utils/document/server.js +0 -13
- package/dist/rule-utils/document/types.js +0 -1
- package/dist/rule-utils/index.js +0 -3
- package/dist/rule-utils/parser/asserts.js +0 -105
- package/dist/rule-utils/parser/index.js +0 -5
- package/dist/rule-utils/parser/parser.js +0 -24
- package/dist/rule-utils/parser/types.js +0 -8
- package/dist/rule-utils/parser/utils.js +0 -106
- package/dist/rules/index.js +0 -4
- package/dist/rules/linter.js +0 -36
- package/dist/rules/rule.js +0 -101
- package/dist/rules/rules/cjs-require/index.js +0 -50
- package/dist/rules/rules/cjs-require/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/index.js +0 -41
- package/dist/rules/rules/cross-chunks-package/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/utils.js +0 -7
- package/dist/rules/rules/default-import-check/index.js +0 -83
- package/dist/rules/rules/default-import-check/types.js +0 -1
- package/dist/rules/rules/default-import-check/utils.js +0 -52
- package/dist/rules/rules/duplicate-package/index.js +0 -39
- package/dist/rules/rules/duplicate-package/types.js +0 -24
- package/dist/rules/rules/duplicate-package/utils.js +0 -38
- package/dist/rules/rules/ecma-version-check/index.js +0 -53
- package/dist/rules/rules/ecma-version-check/types.js +0 -1
- package/dist/rules/rules/ecma-version-check/utils.js +0 -6
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +0 -193
- package/dist/rules/rules/esm-resolved-to-cjs/types.js +0 -1
- package/dist/rules/rules/index.js +0 -22
- package/dist/rules/rules/loader-performance-optimization/index.js +0 -86
- package/dist/rules/rules/loader-performance-optimization/types.js +0 -1
- package/dist/rules/rules/loader-performance-optimization/utils.js +0 -10
- package/dist/rules/rules/module-mixed-chunks/index.js +0 -52
- package/dist/rules/rules/module-mixed-chunks/types.js +0 -1
- package/dist/rules/rules/side-effects-only-imports/index.js +0 -81
- package/dist/rules/rules/side-effects-only-imports/types.js +0 -1
- package/dist/rules/utils.js +0 -10
- package/dist/sdk/index.js +0 -3
- package/dist/sdk/multiple/controller.js +0 -42
- package/dist/sdk/multiple/index.js +0 -3
- package/dist/sdk/multiple/primary.js +0 -64
- package/dist/sdk/multiple/server.js +0 -14
- package/dist/sdk/sdk/core.js +0 -163
- package/dist/sdk/sdk/index.js +0 -435
- package/dist/sdk/sdk/types.js +0 -1
- package/dist/sdk/server/apis/alerts.js +0 -30
- package/dist/sdk/server/apis/base.js +0 -22
- package/dist/sdk/server/apis/bundle-diff.js +0 -51
- package/dist/sdk/server/apis/data.js +0 -44
- package/dist/sdk/server/apis/fs.js +0 -28
- package/dist/sdk/server/apis/graph.js +0 -116
- package/dist/sdk/server/apis/index.js +0 -11
- package/dist/sdk/server/apis/loader.js +0 -120
- package/dist/sdk/server/apis/plugin.js +0 -39
- package/dist/sdk/server/apis/project.js +0 -59
- package/dist/sdk/server/apis/renderer.js +0 -33
- package/dist/sdk/server/apis/resolver.js +0 -38
- package/dist/sdk/server/client.js +0 -8
- package/dist/sdk/server/fakeServer.js +0 -12
- package/dist/sdk/server/index.js +0 -292
- package/dist/sdk/server/json-body.js +0 -150
- package/dist/sdk/server/router.js +0 -83
- package/dist/sdk/server/security.js +0 -47
- package/dist/sdk/server/socket/api.js +0 -22
- package/dist/sdk/server/socket/index.js +0 -166
- package/dist/sdk/server/utils.js +0 -19
- package/dist/sdk/utils/base.js +0 -22
- package/dist/sdk/utils/constant.js +0 -4
- package/dist/sdk/utils/index.js +0 -4
- package/dist/sdk/utils/openBrowser.js +0 -53
- package/dist/sdk/utils/upload.js +0 -6
- package/dist/sdk.js +0 -2
- package/dist/types/index.js +0 -4
- package/dist/types/loader.js +0 -1
- package/dist/types/plugin.js +0 -1
- package/dist/types/rules.js +0 -1
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { find, mapValues } from "../../../collection.js";
|
|
4
|
-
import { filesize } from "filesize";
|
|
5
|
-
import { parser } from "../../../rule-utils/index.js";
|
|
6
|
-
import { extname } from "path";
|
|
7
|
-
import { Constants } from "@rsdoctor/shared/types";
|
|
8
|
-
import { logger } from "../../../logger.js";
|
|
9
|
-
const parseBundle = (bundlePath, modulesData)=>{
|
|
10
|
-
if (bundlePath.indexOf('.worker.') > 0) return {};
|
|
11
|
-
const ext = extname(bundlePath);
|
|
12
|
-
if (!Constants.JSExtensions.includes(ext)) return {};
|
|
13
|
-
let content = fs.readFileSync(bundlePath, 'utf8');
|
|
14
|
-
const tagCache = new Map();
|
|
15
|
-
const sourceMapRegex = /\/\/# sourceMappingURL=[^\n]*$/m;
|
|
16
|
-
content = content.replace(sourceMapRegex, '');
|
|
17
|
-
let hasBannerPlugin = content.indexOf('RSDOCTOR_START::') > 0;
|
|
18
|
-
if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
19
|
-
const tagMatchResult = getStringBetween(content, 0, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_START::(.*?)[;,]/, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_END::(.*?)\)/);
|
|
20
|
-
content = tagMatchResult.result?.trim() || content;
|
|
21
|
-
tagCache.set(bundlePath, tagMatchResult.loc);
|
|
22
|
-
hasBannerPlugin = true;
|
|
23
|
-
} else if (hasBannerPlugin && tagCache.get(bundlePath)) {
|
|
24
|
-
const loc = tagCache.get(bundlePath);
|
|
25
|
-
content = content.slice(loc.start, loc.end);
|
|
26
|
-
hasBannerPlugin = true;
|
|
27
|
-
}
|
|
28
|
-
const ast = parser.internal.parse(content, {
|
|
29
|
-
sourceType: "script",
|
|
30
|
-
ecmaVersion: 'latest'
|
|
31
|
-
});
|
|
32
|
-
const walkState = {
|
|
33
|
-
locations: null,
|
|
34
|
-
expressionStatementDepth: 0
|
|
35
|
-
};
|
|
36
|
-
parser.walk.recursive(ast, walkState, {
|
|
37
|
-
ExpressionStatement (node, state, c) {
|
|
38
|
-
if (state.locations) return;
|
|
39
|
-
state.expressionStatementDepth++;
|
|
40
|
-
try {
|
|
41
|
-
if (1 === state.expressionStatementDepth && isIIFE(node)) {
|
|
42
|
-
const fn = getIIFECallExpression(node);
|
|
43
|
-
if (0 === fn.arguments.length && 0 === fn.callee.params.length) {
|
|
44
|
-
const firstVariableDeclaration = fn.callee.body.body.find((node)=>'VariableDeclaration' === node.type);
|
|
45
|
-
if (firstVariableDeclaration) {
|
|
46
|
-
for (const declaration of firstVariableDeclaration.declarations)if (declaration.init) {
|
|
47
|
-
state.locations = getModulesLocations(declaration.init);
|
|
48
|
-
if (state.locations) break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (!state.locations) c(node.expression, state);
|
|
54
|
-
} catch (e) {
|
|
55
|
-
logger.debug(e);
|
|
56
|
-
}
|
|
57
|
-
state.expressionStatementDepth--;
|
|
58
|
-
},
|
|
59
|
-
Program (node, state, _c) {
|
|
60
|
-
if (state.locations) return;
|
|
61
|
-
try {
|
|
62
|
-
if (hasBannerPlugin) {
|
|
63
|
-
const firstVariableDeclaration = node.body.find((node)=>'VariableDeclaration' === node.type && node.declarations?.[0]?.init?.type === 'ObjectExpression' && node.declarations?.[0]?.init?.properties?.length);
|
|
64
|
-
if (firstVariableDeclaration) {
|
|
65
|
-
for (const declaration of firstVariableDeclaration.declarations)if (declaration.init) {
|
|
66
|
-
state.locations = getModulesLocations(declaration.init);
|
|
67
|
-
if (state.locations) break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!state.locations) node.body.forEach((n)=>_c(n, state));
|
|
72
|
-
} catch (e) {
|
|
73
|
-
logger.debug(e);
|
|
74
|
-
}
|
|
75
|
-
state.expressionStatementDepth--;
|
|
76
|
-
},
|
|
77
|
-
AssignmentExpression (node, state) {
|
|
78
|
-
if (state.locations) return;
|
|
79
|
-
const { left, right } = node;
|
|
80
|
-
if (left?.object && 'exports' === left.object.name && left.property && 'modules' === left.property.name && isModulesHash(right)) state.locations = getModulesLocations(right);
|
|
81
|
-
},
|
|
82
|
-
CallExpression (node, state, c) {
|
|
83
|
-
if (state.locations) return;
|
|
84
|
-
const args = node.arguments;
|
|
85
|
-
if ('FunctionExpression' === node.callee.type && !node.callee.id && 1 === args.length && isSimpleModulesList(args[0])) {
|
|
86
|
-
state.locations = getModulesLocations(args[0]);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if ('Identifier' === node.callee.type && mayBeAsyncChunkArguments(args) && isModulesList(args[1])) {
|
|
90
|
-
state.locations = getModulesLocations(args[1]);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (isAsyncChunkPushExpression(node)) {
|
|
94
|
-
state.locations = getModulesLocations(args[0].elements[1]);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (isAsyncWebWorkerChunkExpression(node)) {
|
|
98
|
-
state.locations = getModulesLocations(args[1]);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
args.forEach((arg)=>c(arg, state));
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
let modules;
|
|
105
|
-
modules = walkState.locations ? mapValues(walkState.locations, (loc)=>content.slice(loc.start, loc.end)) : {};
|
|
106
|
-
const modulesObj = {};
|
|
107
|
-
for(const module in modules){
|
|
108
|
-
if (!module) return {};
|
|
109
|
-
const moduleContent = modules[module];
|
|
110
|
-
const size = moduleContent && Buffer.byteLength(moduleContent);
|
|
111
|
-
const identifier = find(modulesData, (item)=>item.renderId === module)?.identifier || '';
|
|
112
|
-
modulesObj[identifier] = {
|
|
113
|
-
size,
|
|
114
|
-
sizeConvert: filesize(size || 0),
|
|
115
|
-
content: moduleContent
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
modules: modulesObj,
|
|
120
|
-
src: content,
|
|
121
|
-
runtimeSrc: getBundleRuntime(content, walkState.locations)
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
function getBundleRuntime(content, modulesLocations) {
|
|
125
|
-
const sortedLocations = Object.values(modulesLocations || {}).sort((a, b)=>a.start - b.start);
|
|
126
|
-
let result = '';
|
|
127
|
-
let lastIndex = 0;
|
|
128
|
-
for (const { start, end } of sortedLocations){
|
|
129
|
-
result += content.slice(lastIndex, start);
|
|
130
|
-
lastIndex = end;
|
|
131
|
-
}
|
|
132
|
-
return result + content.slice(lastIndex, content.length);
|
|
133
|
-
}
|
|
134
|
-
function isIIFE(node) {
|
|
135
|
-
return 'ExpressionStatement' === node.type && ('CallExpression' === node.expression.type || 'UnaryExpression' === node.expression.type && 'CallExpression' === node.expression.argument.type);
|
|
136
|
-
}
|
|
137
|
-
function getIIFECallExpression(node) {
|
|
138
|
-
if ('UnaryExpression' === node.expression.type) return node.expression.argument;
|
|
139
|
-
return node.expression;
|
|
140
|
-
}
|
|
141
|
-
function isModulesList(node) {
|
|
142
|
-
return isSimpleModulesList(node) || isOptimizedModulesArray(node);
|
|
143
|
-
}
|
|
144
|
-
function isSimpleModulesList(node) {
|
|
145
|
-
return isModulesHash(node) || isModulesArray(node);
|
|
146
|
-
}
|
|
147
|
-
function isModulesHash(node) {
|
|
148
|
-
return 'ObjectExpression' === node.type && node.properties.map((node)=>node.value).every(isModuleWrapper);
|
|
149
|
-
}
|
|
150
|
-
function isModulesArray(node) {
|
|
151
|
-
return 'ArrayExpression' === node.type && node.elements.every((elem)=>!elem || isModuleWrapper(elem));
|
|
152
|
-
}
|
|
153
|
-
function isOptimizedModulesArray(node) {
|
|
154
|
-
return 'CallExpression' === node.type && 'MemberExpression' === node.callee.type && 'CallExpression' === node.callee.object.type && 'Identifier' === node.callee.object.callee.type && 'Array' === node.callee.object.callee.name && 1 === node.callee.object.arguments.length && isNumericId(node.callee.object.arguments[0]) && 'Identifier' === node.callee.property.type && 'concat' === node.callee.property.name && 1 === node.arguments.length && isModulesArray(node.arguments[0]);
|
|
155
|
-
}
|
|
156
|
-
function isModuleWrapper(node) {
|
|
157
|
-
return ('FunctionExpression' === node.type || 'ArrowFunctionExpression' === node.type) && !node.id || isModuleId(node) || 'ArrayExpression' === node.type && node.elements.length > 1 && isModuleId(node.elements[0]);
|
|
158
|
-
}
|
|
159
|
-
function isModuleId(node) {
|
|
160
|
-
return 'Literal' === node.type && (isNumericId(node) || 'string' == typeof node.value);
|
|
161
|
-
}
|
|
162
|
-
function isNumericId(node) {
|
|
163
|
-
return 'Literal' === node.type && Number.isInteger(node.value) && node.value >= 0;
|
|
164
|
-
}
|
|
165
|
-
function isChunkIds(node) {
|
|
166
|
-
return 'ArrayExpression' === node.type && node.elements.every(isModuleId);
|
|
167
|
-
}
|
|
168
|
-
function isAsyncChunkPushExpression(node) {
|
|
169
|
-
const { callee, arguments: args } = node;
|
|
170
|
-
return 'MemberExpression' === callee.type && 'push' === callee.property.name && 'AssignmentExpression' === callee.object.type && 1 === args.length && 'ArrayExpression' === args[0].type && mayBeAsyncChunkArguments(args[0].elements) && isModulesList(args[0].elements[1]);
|
|
171
|
-
}
|
|
172
|
-
function mayBeAsyncChunkArguments(args) {
|
|
173
|
-
return args.length >= 2 && isChunkIds(args[0]);
|
|
174
|
-
}
|
|
175
|
-
function isAsyncWebWorkerChunkExpression(node) {
|
|
176
|
-
const { callee, type, arguments: args } = node;
|
|
177
|
-
return 'CallExpression' === type && 'MemberExpression' === callee.type && 2 === args.length && isChunkIds(args[0]) && isModulesList(args[1]);
|
|
178
|
-
}
|
|
179
|
-
function getModulesLocations(node) {
|
|
180
|
-
if ('ObjectExpression' === node.type) {
|
|
181
|
-
const modulesNodes = node.properties;
|
|
182
|
-
return modulesNodes.reduce((result, moduleNode)=>{
|
|
183
|
-
const moduleId = moduleNode.key.name || moduleNode.key.value;
|
|
184
|
-
result[moduleId] = getModuleLocation(moduleNode.value);
|
|
185
|
-
return result;
|
|
186
|
-
}, {});
|
|
187
|
-
}
|
|
188
|
-
const isOptimizedArray = 'CallExpression' === node.type;
|
|
189
|
-
if ('ArrayExpression' === node.type || isOptimizedArray) {
|
|
190
|
-
const minId = isOptimizedArray ? node.callee.object.arguments[0].value : 0;
|
|
191
|
-
const modulesNodes = isOptimizedArray ? node.arguments[0].elements : node.elements;
|
|
192
|
-
return modulesNodes.reduce((result, moduleNode, i)=>{
|
|
193
|
-
if (moduleNode) result[i + minId] = getModuleLocation(moduleNode);
|
|
194
|
-
return result;
|
|
195
|
-
}, {});
|
|
196
|
-
}
|
|
197
|
-
return {};
|
|
198
|
-
}
|
|
199
|
-
function getModuleLocation(node) {
|
|
200
|
-
return {
|
|
201
|
-
start: node.start,
|
|
202
|
-
end: node.end
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function getStringBetween(raw, position, start, end) {
|
|
206
|
-
try {
|
|
207
|
-
const matchStart = raw.match(start);
|
|
208
|
-
const startFlagIndex = matchStart?.length ? raw.indexOf(matchStart[0], position) : -1;
|
|
209
|
-
if (-1 === startFlagIndex || !matchStart?.length) return {
|
|
210
|
-
result: null,
|
|
211
|
-
remain: position
|
|
212
|
-
};
|
|
213
|
-
const startTagLength = matchStart[0].length;
|
|
214
|
-
const matchEnd = raw.match(end);
|
|
215
|
-
const endFlagIndex = matchEnd?.length ? raw.indexOf(matchEnd[0], startFlagIndex + startTagLength) : -1;
|
|
216
|
-
if (-1 === endFlagIndex || !matchEnd?.length) return {
|
|
217
|
-
result: null,
|
|
218
|
-
remain: position
|
|
219
|
-
};
|
|
220
|
-
let innerContent = raw.slice(startFlagIndex + startTagLength, endFlagIndex).trim();
|
|
221
|
-
if (innerContent.endsWith(',')) innerContent = innerContent.slice(0, -1);
|
|
222
|
-
return {
|
|
223
|
-
result: innerContent,
|
|
224
|
-
remain: matchEnd?.length ? endFlagIndex + matchEnd[0].length : endFlagIndex,
|
|
225
|
-
loc: {
|
|
226
|
-
start: startFlagIndex + startTagLength,
|
|
227
|
-
end: endFlagIndex
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
} catch (e) {
|
|
231
|
-
logger.debug(()=>e);
|
|
232
|
-
return {
|
|
233
|
-
result: null,
|
|
234
|
-
remain: position
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
export { parseBundle };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
function shouldInterceptPluginHook(hook) {
|
|
3
|
-
if (hook && hook._fakeHook) return false;
|
|
4
|
-
if (hook?.isUsed && 'function' == typeof hook.isUsed) return hook.isUsed();
|
|
5
|
-
if (hook?._map && 0 === hook._map.size) return false;
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
function interceptCompilerHooks(compiler, interceptor) {
|
|
9
|
-
Object.keys(compiler.hooks).forEach((hook)=>{
|
|
10
|
-
const v = compiler.hooks[hook];
|
|
11
|
-
if (shouldInterceptPluginHook(v)) interceptor(hook, v, 'compiler');
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function interceptCompilationHooks(compilation, interceptor) {
|
|
15
|
-
Object.keys(compilation.hooks).forEach((hook)=>{
|
|
16
|
-
if ('normalModuleLoader' === hook) return;
|
|
17
|
-
const v = compilation.hooks[hook];
|
|
18
|
-
if (shouldInterceptPluginHook(v)) interceptor(hook, v, 'compilation');
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
export { interceptCompilationHooks, interceptCompilerHooks, shouldInterceptPluginHook };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import * as __rspack_external__build_index_js_dd3d3112 from "./build/index.js";
|
|
3
|
-
import * as __rspack_external__build_envinfo_js_bb7cc383 from "./build/envinfo.js";
|
|
4
|
-
import * as __rspack_external__build_file_index_js_b486e89f from "./build/file/index.js";
|
|
5
|
-
import * as __rspack_external__build_json_js_4cd59ece from "./build/json.js";
|
|
6
|
-
import * as __rspack_external__build_process_js_dbdc7299 from "./build/process.js";
|
|
7
|
-
import * as __rspack_external__build_server_js_f760cf8d from "./build/server.js";
|
|
8
|
-
import * as __rspack_external__build_chunks_index_js_b63f9e6b from "./build/chunks/index.js";
|
|
9
|
-
import * as __rspack_external__build_utils_index_js_2ab2484c from "./build/utils/index.js";
|
|
10
|
-
import * as __rspack_external__build_loader_index_js_a995ea1e from "./build/loader/index.js";
|
|
11
|
-
import * as __rspack_external__types_index_js_b312a465 from "../types/index.js";
|
|
12
|
-
import * as __rspack_external__build_module_graph_index_js_808da562 from "./build/module-graph/index.js";
|
|
13
|
-
export { __rspack_external__build_chunks_index_js_b63f9e6b as Chunks, __rspack_external__build_envinfo_js_bb7cc383 as EnvInfo, __rspack_external__build_file_index_js_b486e89f as File, __rspack_external__build_index_js_dd3d3112 as Build, __rspack_external__build_json_js_4cd59ece as Json, __rspack_external__build_loader_index_js_a995ea1e as Loader, __rspack_external__build_module_graph_index_js_808da562 as ModuleGraph, __rspack_external__build_process_js_dbdc7299 as Process, __rspack_external__build_server_js_f760cf8d as Server, __rspack_external__build_utils_index_js_2ab2484c as Utils, __rspack_external__types_index_js_b312a465 as Types };
|
package/dist/collection.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@rsdoctor/shared/collection';
|
package/dist/collection.js
DELETED
package/dist/common/file.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import os from "os";
|
|
5
|
-
import { logger } from "../logger.js";
|
|
6
|
-
function writeMcpPort(port, builderName) {
|
|
7
|
-
const homeDir = os.homedir();
|
|
8
|
-
const rsdoctorDir = path.join(homeDir, '.cache/rsdoctor');
|
|
9
|
-
const mcpPortFilePath = path.join(rsdoctorDir, 'mcp.json');
|
|
10
|
-
if (!fs.existsSync(rsdoctorDir)) fs.mkdirSync(rsdoctorDir, {
|
|
11
|
-
recursive: true
|
|
12
|
-
});
|
|
13
|
-
let mcpJson = {
|
|
14
|
-
portList: {},
|
|
15
|
-
port: 0
|
|
16
|
-
};
|
|
17
|
-
if (fs.existsSync(mcpPortFilePath)) try {
|
|
18
|
-
mcpJson = JSON.parse(fs.readFileSync(mcpPortFilePath, 'utf8'));
|
|
19
|
-
} catch (error) {
|
|
20
|
-
logger.debug('Failed to parse mcp.json', error);
|
|
21
|
-
}
|
|
22
|
-
if (!mcpJson.portList) mcpJson.portList = {};
|
|
23
|
-
mcpJson.portList[builderName || 'builder'] = port;
|
|
24
|
-
mcpJson.port = port;
|
|
25
|
-
fs.writeFileSync(mcpPortFilePath, JSON.stringify(mcpJson, null, 2), 'utf8');
|
|
26
|
-
}
|
|
27
|
-
function getMcpConfigPath() {
|
|
28
|
-
const homeDir = os.homedir();
|
|
29
|
-
const rsdoctorDir = path.join(homeDir, '.cache/rsdoctor');
|
|
30
|
-
const mcpPortFilePath = path.join(rsdoctorDir, 'mcp.json');
|
|
31
|
-
return mcpPortFilePath;
|
|
32
|
-
}
|
|
33
|
-
export { getMcpConfigPath, writeMcpPort };
|
package/dist/common/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { Alerts, Algorithm, Bundle, Crypto, Data, Fetch, Graph, Loader, Lodash, Manifest, Package, Plugin, Resolver, Rspack, Summary, Time, Url, } from '@rsdoctor/shared/common-browser';
|
|
2
|
-
export * as GlobalConfig from './global-config.js';
|
|
3
|
-
export * as File from './file.js';
|
|
4
|
-
export * from '@rsdoctor/shared/common-browser';
|
package/dist/common/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import * as __rspack_external__file_js_9fa33ca6 from "./file.js";
|
|
3
|
-
import * as __rspack_external__global_config_js_a07079db from "./global-config.js";
|
|
4
|
-
export * from "@rsdoctor/shared/common-browser";
|
|
5
|
-
export { Alerts, Algorithm, Bundle, Crypto, Data, Fetch, Graph, Loader, Lodash, Manifest, Package, Plugin, Resolver, Rspack, Summary, Time, Url } from "@rsdoctor/shared/common-browser";
|
|
6
|
-
export { __rspack_external__file_js_9fa33ca6 as File, __rspack_external__global_config_js_a07079db as GlobalConfig };
|
package/dist/common-browser.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@rsdoctor/shared/common-browser';
|
package/dist/common-browser.js
DELETED
package/dist/error/error.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { codeFrameColumns } from "@babel/code-frame";
|
|
3
|
-
import { Lodash } from "../common/index.js";
|
|
4
|
-
import { Err } from "@rsdoctor/shared/types";
|
|
5
|
-
import { createColors } from "picocolors";
|
|
6
|
-
import deep_eql from "deep-eql";
|
|
7
|
-
import strip_ansi from "strip-ansi";
|
|
8
|
-
import { transform } from "./transform.js";
|
|
9
|
-
import { insertSpace, toLevel } from "./utils.js";
|
|
10
|
-
let id = 1;
|
|
11
|
-
class DevToolError extends Error {
|
|
12
|
-
static from(err, opt) {
|
|
13
|
-
if (err instanceof DevToolError) return err;
|
|
14
|
-
return transform(err, opt);
|
|
15
|
-
}
|
|
16
|
-
get level() {
|
|
17
|
-
return Err.ErrorLevel[this._level];
|
|
18
|
-
}
|
|
19
|
-
get path() {
|
|
20
|
-
return this._codeFrame?.filePath;
|
|
21
|
-
}
|
|
22
|
-
set path(file) {
|
|
23
|
-
if (!file) return;
|
|
24
|
-
if (this._codeFrame) {
|
|
25
|
-
this._codeFrame.filePath = file;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
this._codeFrame = {
|
|
29
|
-
filePath: file
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
get codeFrame() {
|
|
33
|
-
return this._codeFrame;
|
|
34
|
-
}
|
|
35
|
-
printCodeFrame(print) {
|
|
36
|
-
const msgs = [];
|
|
37
|
-
const { _codeFrame: codeFrameOpt, _controller: controller } = this;
|
|
38
|
-
if (!codeFrameOpt) return msgs;
|
|
39
|
-
if ('start' in codeFrameOpt && codeFrameOpt.start) {
|
|
40
|
-
const { filePath, start } = codeFrameOpt;
|
|
41
|
-
msgs.push(`\n ${print.red(print.bold('File: '))}${print.bold(filePath)}:${start.line}${start.column ? `:${start.column}` : ''}`);
|
|
42
|
-
if ('fileContent' in codeFrameOpt) {
|
|
43
|
-
const { end, fileContent } = codeFrameOpt;
|
|
44
|
-
msgs.push(codeFrameColumns(fileContent, {
|
|
45
|
-
start,
|
|
46
|
-
end
|
|
47
|
-
}, {
|
|
48
|
-
highlightCode: !controller.noColor
|
|
49
|
-
}));
|
|
50
|
-
} else if ('lineText' in codeFrameOpt) {
|
|
51
|
-
const { length, lineText } = codeFrameOpt;
|
|
52
|
-
let lineCodeFrame = codeFrameColumns(lineText, {
|
|
53
|
-
start: {
|
|
54
|
-
line: 1,
|
|
55
|
-
column: start.column
|
|
56
|
-
},
|
|
57
|
-
end: {
|
|
58
|
-
line: 1,
|
|
59
|
-
column: Lodash.isNil(start.column) || Lodash.isNil(length) ? void 0 : start.column + length
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
highlightCode: !controller.noColor
|
|
63
|
-
});
|
|
64
|
-
if (start.line > 1) {
|
|
65
|
-
lineCodeFrame = lineCodeFrame.replace(' 1 |', ` ${start.line} |`);
|
|
66
|
-
if (start.line >= 10) lineCodeFrame = insertSpace(lineCodeFrame, 2, String(start.line).length - 1);
|
|
67
|
-
}
|
|
68
|
-
msgs.push(lineCodeFrame);
|
|
69
|
-
}
|
|
70
|
-
} else msgs.push(`\n ${print.red(print.bold('File: '))}${print.bold(codeFrameOpt.filePath)}\n`);
|
|
71
|
-
return msgs;
|
|
72
|
-
}
|
|
73
|
-
toString() {
|
|
74
|
-
const msgs = [];
|
|
75
|
-
const { code, title, message, hint, referenceUrl, _controller: controller } = this;
|
|
76
|
-
const print = createColors(!controller.noColor);
|
|
77
|
-
const mainColorPrint = this._level === Err.ErrorLevel.Error ? print.red : print.yellow;
|
|
78
|
-
const codeText = code ? `${mainColorPrint(print.blue(code))}:` : '';
|
|
79
|
-
msgs.push(mainColorPrint(print.bold(`[${codeText}${this.level}:${title.toUpperCase()}] `) + message));
|
|
80
|
-
msgs.push(...this.printCodeFrame(print));
|
|
81
|
-
if (hint || referenceUrl) msgs.push('');
|
|
82
|
-
if (hint) msgs.push(` ${print.blue(`HINT: ${hint}`)}`);
|
|
83
|
-
if (referenceUrl) msgs.push(print.magenta(print.bold(` See: ${referenceUrl}`)));
|
|
84
|
-
if (!controller.noStack && this.stack) msgs.push(print.red(print.bold(` Error Stack:\n${this.stack}\n`)));
|
|
85
|
-
return msgs.join('\n');
|
|
86
|
-
}
|
|
87
|
-
toData() {
|
|
88
|
-
return {
|
|
89
|
-
...this.detail,
|
|
90
|
-
id: this.id,
|
|
91
|
-
category: this.category,
|
|
92
|
-
description: strip_ansi(this.detail?.description ?? this.message),
|
|
93
|
-
title: this.title.toUpperCase(),
|
|
94
|
-
code: this.code,
|
|
95
|
-
level: this.level.toLowerCase()
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
toError() {
|
|
99
|
-
const error = new Error();
|
|
100
|
-
error.message = this.toString();
|
|
101
|
-
error.name = this.name;
|
|
102
|
-
error.stack = this.stack;
|
|
103
|
-
return error;
|
|
104
|
-
}
|
|
105
|
-
toJSON() {
|
|
106
|
-
return {
|
|
107
|
-
message: this.toString(),
|
|
108
|
-
name: this.name,
|
|
109
|
-
stack: this.stack
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
setControllerOption(opt) {
|
|
113
|
-
this._controller = {
|
|
114
|
-
noStack: opt.noStack ?? this._controller.noStack ?? true,
|
|
115
|
-
noColor: opt.noColor ?? this._controller.noColor ?? false
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
setCodeFrame(opt) {
|
|
119
|
-
this._codeFrame = opt;
|
|
120
|
-
}
|
|
121
|
-
isSame(error) {
|
|
122
|
-
return this.code === error.code && this.message === error.message && this.hint === error.hint && this.level === error.level && this.title === error.title && this.referenceUrl === error.referenceUrl && this.code === error.code && deep_eql(this.codeFrame, error.codeFrame);
|
|
123
|
-
}
|
|
124
|
-
constructor(title, message, opts){
|
|
125
|
-
super(message), this._controller = {
|
|
126
|
-
noStack: true,
|
|
127
|
-
noColor: false
|
|
128
|
-
};
|
|
129
|
-
this.id = id++;
|
|
130
|
-
this.title = title;
|
|
131
|
-
this.code = opts?.code;
|
|
132
|
-
this.hint = opts?.hint;
|
|
133
|
-
this.stack = opts?.stack;
|
|
134
|
-
this.detail = opts?.detail;
|
|
135
|
-
this.fixData = opts?.fixData;
|
|
136
|
-
this.category = opts?.category;
|
|
137
|
-
this.referenceUrl = opts?.referenceUrl;
|
|
138
|
-
this._level = opts?.level ? toLevel(opts.level) : Err.ErrorLevel.Error;
|
|
139
|
-
this._codeFrame = opts?.codeFrame;
|
|
140
|
-
this.setControllerOption(opts?.controller ?? {});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
export { DevToolError };
|
package/dist/error/index.js
DELETED
package/dist/error/transform.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import strip_ansi from "strip-ansi";
|
|
3
|
-
import { Linter } from "@rsdoctor/shared/types";
|
|
4
|
-
import { DevToolError } from "./error.js";
|
|
5
|
-
const MAX_ERROR_MESSAGE_LENGTH = 1000;
|
|
6
|
-
function truncateMessage(input, maxLen = MAX_ERROR_MESSAGE_LENGTH) {
|
|
7
|
-
const str = 'string' == typeof input ? input : String(input ?? '');
|
|
8
|
-
return str.length > maxLen ? str.slice(0, maxLen) : str;
|
|
9
|
-
}
|
|
10
|
-
function isEsbuildError(err) {
|
|
11
|
-
return 'pluginName' in err && 'text' in err && 'location' in err;
|
|
12
|
-
}
|
|
13
|
-
function isBabelError(err) {
|
|
14
|
-
return 'code' in err && 'reasonCode' in err;
|
|
15
|
-
}
|
|
16
|
-
function isDiagnosticError(err) {
|
|
17
|
-
return 'severity' in err && 'title' in err;
|
|
18
|
-
}
|
|
19
|
-
function parseBabelErrorMessage(input) {
|
|
20
|
-
const lines = strip_ansi(truncateMessage(input)).split('\n');
|
|
21
|
-
const filePath = lines[0].replace(/^([^:]+):.*/, '$1');
|
|
22
|
-
const message = lines[0].replace(/.*: (.*) \(\d+:\d+\)*/, '$1');
|
|
23
|
-
const lineText = lines.find((line)=>line.startsWith('> '))?.replace(/> \d+ \| /, '') ?? '';
|
|
24
|
-
return {
|
|
25
|
-
message,
|
|
26
|
-
filePath,
|
|
27
|
-
lineText
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function clearMessage(str) {
|
|
31
|
-
return strip_ansi(truncateMessage(str)).replace(/.*: (.*)\n\n[\s\S]*/g, '$1');
|
|
32
|
-
}
|
|
33
|
-
function clearStack(str) {
|
|
34
|
-
return str.slice(str.indexOf(' at')).replace(/\s*at(.*) \((.*)\)/g, '$1\n$2\n');
|
|
35
|
-
}
|
|
36
|
-
function transformEsbuildError(err, opt) {
|
|
37
|
-
if (isEsbuildError(err)) {
|
|
38
|
-
const errorCode = opt?.code ?? 'ESBUILD_ERROR';
|
|
39
|
-
const speedyError = 'object' == typeof err.detail ? DevToolError.from(err.detail) : new DevToolError(errorCode, clearMessage(err.text), {
|
|
40
|
-
...opt,
|
|
41
|
-
hint: err.location?.suggestion,
|
|
42
|
-
codeFrame: {
|
|
43
|
-
filePath: err.text.split(':')[0]
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
if (err.location) speedyError.setCodeFrame({
|
|
47
|
-
filePath: err.location.file,
|
|
48
|
-
lineText: err.location.lineText,
|
|
49
|
-
length: err.location.length,
|
|
50
|
-
start: {
|
|
51
|
-
line: err.location.line,
|
|
52
|
-
column: err.location.column + 1
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return speedyError;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function transformBabelError(err, opt) {
|
|
59
|
-
if (isBabelError(err)) {
|
|
60
|
-
const errorCode = opt?.code ?? err.code ?? 'BABEL';
|
|
61
|
-
const title = err.reasonCode;
|
|
62
|
-
const errorParsed = parseBabelErrorMessage(err.message);
|
|
63
|
-
const speedyError = new DevToolError(title, truncateMessage(errorParsed.message), {
|
|
64
|
-
...opt,
|
|
65
|
-
code: errorCode,
|
|
66
|
-
stack: err.stack && clearStack(err.stack)
|
|
67
|
-
});
|
|
68
|
-
if (err.loc) speedyError.setCodeFrame({
|
|
69
|
-
...errorParsed,
|
|
70
|
-
start: {
|
|
71
|
-
line: err.loc.line,
|
|
72
|
-
column: err.loc.column + 1
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return speedyError;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function transformNormalError(err, opt) {
|
|
79
|
-
if (err instanceof Error) {
|
|
80
|
-
const stacks = [];
|
|
81
|
-
const filePath = stacks?.[0]?.getFileName?.();
|
|
82
|
-
return new DevToolError(err.name, clearMessage(err.message), {
|
|
83
|
-
...opt,
|
|
84
|
-
codeFrame: filePath ? {
|
|
85
|
-
filePath
|
|
86
|
-
} : void 0,
|
|
87
|
-
stack: err.stack && clearStack(err.stack)
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function transformErrorLike(err, opt) {
|
|
92
|
-
const isErrorLike = err && 'object' == typeof err && err.message;
|
|
93
|
-
if (isErrorLike) {
|
|
94
|
-
const stacks = [];
|
|
95
|
-
const filePath = stacks?.[0]?.getFileName?.();
|
|
96
|
-
const message = truncateMessage(err.message);
|
|
97
|
-
return new DevToolError(err.name || 'UNKNOWN_ERROR', clearMessage(message), {
|
|
98
|
-
...opt,
|
|
99
|
-
codeFrame: filePath ? {
|
|
100
|
-
filePath
|
|
101
|
-
} : void 0,
|
|
102
|
-
stack: err.stack && clearStack(err.stack)
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function transformDiagnostic(err, opt) {
|
|
107
|
-
if (isDiagnosticError(err)) return new DevToolError(err.title, truncateMessage(err.message), {
|
|
108
|
-
...err,
|
|
109
|
-
...opt,
|
|
110
|
-
hint: err.suggestions?.description,
|
|
111
|
-
fixData: err.suggestions?.fixData,
|
|
112
|
-
codeFrame: err.document ? {
|
|
113
|
-
filePath: err.document.path,
|
|
114
|
-
fileContent: err.document.content,
|
|
115
|
-
start: err.document.range.start,
|
|
116
|
-
end: err.document.range.end
|
|
117
|
-
} : void 0,
|
|
118
|
-
level: Linter.Severity[err.severity]
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function defaultError(err, opt) {
|
|
122
|
-
return new DevToolError('UNKNOWN_ERROR', JSON.stringify(err), opt);
|
|
123
|
-
}
|
|
124
|
-
function transform(err, opt) {
|
|
125
|
-
const transformers = [
|
|
126
|
-
transformEsbuildError,
|
|
127
|
-
transformBabelError,
|
|
128
|
-
transformDiagnostic,
|
|
129
|
-
transformNormalError,
|
|
130
|
-
transformErrorLike
|
|
131
|
-
];
|
|
132
|
-
for (const fn of transformers){
|
|
133
|
-
const result = fn(err, opt);
|
|
134
|
-
if (result) return result;
|
|
135
|
-
}
|
|
136
|
-
return defaultError(err, opt);
|
|
137
|
-
}
|
|
138
|
-
export { transform };
|
package/dist/error/utils.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { Err } from "@rsdoctor/shared/types";
|
|
3
|
-
function toLevel(level) {
|
|
4
|
-
return Err.ErrorLevel[level];
|
|
5
|
-
}
|
|
6
|
-
function insertSpace(rawLines, line, width) {
|
|
7
|
-
const lines = rawLines.split('\n');
|
|
8
|
-
lines[line - 1] = Array(width).fill(' ').join('') + lines[line - 1];
|
|
9
|
-
return lines.join('\n');
|
|
10
|
-
}
|
|
11
|
-
function printErrors({ errors, warnings }, logLevel = 'Error') {
|
|
12
|
-
const onlyError = 'Error' === logLevel;
|
|
13
|
-
if ('Silent' === logLevel) return '';
|
|
14
|
-
if (onlyError && 0 === errors.length || !onlyError && 0 === errors.length && 0 === warnings.length) return '';
|
|
15
|
-
const msgs = [];
|
|
16
|
-
if (onlyError) msgs.push(`Build failed with ${errors.length} error:`, ...errors.map((item)=>item.toString()), '');
|
|
17
|
-
else {
|
|
18
|
-
const title = 0 === errors.length ? `Build succuss with ${warnings.length} warning:` : `Build failed with ${errors.length} error, ${warnings.length} warning:`;
|
|
19
|
-
msgs.push(title, ...errors.map((item)=>item.toString()), ...warnings.map((item)=>item.toString()), '');
|
|
20
|
-
}
|
|
21
|
-
return msgs.join('\n\n');
|
|
22
|
-
}
|
|
23
|
-
export { insertSpace, printErrors, toLevel };
|
package/dist/graph/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@rsdoctor/shared/graph';
|
package/dist/graph/index.js
DELETED