@rsdoctor/utils 1.5.0 → 1.5.2-beta.0
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/common.cjs +5 -5
- package/dist/common.js +5 -5
- package/dist/error.cjs +11 -6
- package/dist/error.js +10 -6
- package/package.json +3 -3
package/dist/common.cjs
CHANGED
|
@@ -873,8 +873,8 @@ for(var __rspack_i in (()=>{
|
|
|
873
873
|
total: diffAssetsByExtensions(baseline, current)
|
|
874
874
|
},
|
|
875
875
|
js: {
|
|
876
|
-
total: diffAssetsByExtensions(baseline, current, types_.Constants.
|
|
877
|
-
initial: diffAssetsByExtensions(baseline, current, types_.Constants.
|
|
876
|
+
total: diffAssetsByExtensions(baseline, current, types_.Constants.JSExtensions),
|
|
877
|
+
initial: diffAssetsByExtensions(baseline, current, types_.Constants.JSExtensions, !0)
|
|
878
878
|
},
|
|
879
879
|
css: {
|
|
880
880
|
total: diffAssetsByExtensions(baseline, current, types_.Constants.CSSExtension),
|
|
@@ -894,7 +894,7 @@ for(var __rspack_i in (()=>{
|
|
|
894
894
|
},
|
|
895
895
|
others: {
|
|
896
896
|
total: diffAssetsByExtensions(baseline, current, (asset)=>!isAssetMatchExtensions(asset, [
|
|
897
|
-
types_.Constants.
|
|
897
|
+
...types_.Constants.JSExtensions,
|
|
898
898
|
types_.Constants.CSSExtension,
|
|
899
899
|
types_.Constants.HtmlExtension
|
|
900
900
|
].concat(types_.Constants.ImgExtensions, types_.Constants.MediaExtensions, types_.Constants.FontExtensions, types_.Constants.MapExtensions)))
|
|
@@ -940,7 +940,7 @@ for(var __rspack_i in (()=>{
|
|
|
940
940
|
function getAssetsSummary(assets, chunks, options = {}) {
|
|
941
941
|
let jsOpt = {
|
|
942
942
|
...options,
|
|
943
|
-
filterOrExtensions: types_.Constants.
|
|
943
|
+
filterOrExtensions: types_.Constants.JSExtensions
|
|
944
944
|
}, cssOpt = {
|
|
945
945
|
...options,
|
|
946
946
|
filterOrExtensions: types_.Constants.CSSExtension
|
|
@@ -959,7 +959,7 @@ for(var __rspack_i in (()=>{
|
|
|
959
959
|
}, otherOpt = {
|
|
960
960
|
...options,
|
|
961
961
|
filterOrExtensions: (asset)=>!isAssetMatchExtensions(asset, [
|
|
962
|
-
types_.Constants.
|
|
962
|
+
...types_.Constants.JSExtensions,
|
|
963
963
|
types_.Constants.CSSExtension,
|
|
964
964
|
types_.Constants.HtmlExtension
|
|
965
965
|
].concat(types_.Constants.ImgExtensions, types_.Constants.MediaExtensions, types_.Constants.FontExtensions, types_.Constants.MapExtensions))
|
package/dist/common.js
CHANGED
|
@@ -662,8 +662,8 @@ function getAssetsDiffResult(baseline, current) {
|
|
|
662
662
|
total: diffAssetsByExtensions(baseline, current)
|
|
663
663
|
},
|
|
664
664
|
js: {
|
|
665
|
-
total: diffAssetsByExtensions(baseline, current, types_Constants.
|
|
666
|
-
initial: diffAssetsByExtensions(baseline, current, types_Constants.
|
|
665
|
+
total: diffAssetsByExtensions(baseline, current, types_Constants.JSExtensions),
|
|
666
|
+
initial: diffAssetsByExtensions(baseline, current, types_Constants.JSExtensions, !0)
|
|
667
667
|
},
|
|
668
668
|
css: {
|
|
669
669
|
total: diffAssetsByExtensions(baseline, current, types_Constants.CSSExtension),
|
|
@@ -683,7 +683,7 @@ function getAssetsDiffResult(baseline, current) {
|
|
|
683
683
|
},
|
|
684
684
|
others: {
|
|
685
685
|
total: diffAssetsByExtensions(baseline, current, (asset)=>!isAssetMatchExtensions(asset, [
|
|
686
|
-
types_Constants.
|
|
686
|
+
...types_Constants.JSExtensions,
|
|
687
687
|
types_Constants.CSSExtension,
|
|
688
688
|
types_Constants.HtmlExtension
|
|
689
689
|
].concat(types_Constants.ImgExtensions, types_Constants.MediaExtensions, types_Constants.FontExtensions, types_Constants.MapExtensions)))
|
|
@@ -729,7 +729,7 @@ function diffAssetsByExtensions(baseline, current, filterOrExtensions, isInitial
|
|
|
729
729
|
function getAssetsSummary(assets, chunks, options = {}) {
|
|
730
730
|
let jsOpt = {
|
|
731
731
|
...options,
|
|
732
|
-
filterOrExtensions: types_Constants.
|
|
732
|
+
filterOrExtensions: types_Constants.JSExtensions
|
|
733
733
|
}, cssOpt = {
|
|
734
734
|
...options,
|
|
735
735
|
filterOrExtensions: types_Constants.CSSExtension
|
|
@@ -748,7 +748,7 @@ function getAssetsSummary(assets, chunks, options = {}) {
|
|
|
748
748
|
}, otherOpt = {
|
|
749
749
|
...options,
|
|
750
750
|
filterOrExtensions: (asset)=>!isAssetMatchExtensions(asset, [
|
|
751
|
-
types_Constants.
|
|
751
|
+
...types_Constants.JSExtensions,
|
|
752
752
|
types_Constants.CSSExtension,
|
|
753
753
|
types_Constants.HtmlExtension
|
|
754
754
|
].concat(types_Constants.ImgExtensions, types_Constants.MediaExtensions, types_Constants.FontExtensions, types_Constants.MapExtensions))
|
package/dist/error.cjs
CHANGED
|
@@ -27,6 +27,11 @@ const code_frame_namespaceObject = require("@babel/code-frame"), types_namespace
|
|
|
27
27
|
var external_deep_eql_default = __webpack_require__.n(external_deep_eql_namespaceObject);
|
|
28
28
|
const external_strip_ansi_namespaceObject = require("strip-ansi");
|
|
29
29
|
var external_strip_ansi_default = __webpack_require__.n(external_strip_ansi_namespaceObject);
|
|
30
|
+
const MAX_ERROR_MESSAGE_LENGTH = 1000;
|
|
31
|
+
function truncateMessage(input, maxLen = 1000) {
|
|
32
|
+
let str = 'string' == typeof input ? input : String(input ?? '');
|
|
33
|
+
return str.length > maxLen ? str.slice(0, maxLen) : str;
|
|
34
|
+
}
|
|
30
35
|
function isEsbuildError(err) {
|
|
31
36
|
return 'pluginName' in err && 'text' in err && 'location' in err;
|
|
32
37
|
}
|
|
@@ -37,7 +42,7 @@ function isDiagnosticError(err) {
|
|
|
37
42
|
return 'severity' in err && 'title' in err;
|
|
38
43
|
}
|
|
39
44
|
function parseBabelErrorMessage(input) {
|
|
40
|
-
let lines = external_strip_ansi_default()(input).split('\n'), filePath = lines[0].replace(/^([^:]+):.*/, '$1');
|
|
45
|
+
let lines = external_strip_ansi_default()(truncateMessage(input)).split('\n'), filePath = lines[0].replace(/^([^:]+):.*/, '$1');
|
|
41
46
|
return {
|
|
42
47
|
message: lines[0].replace(/.*: (.*) \(\d+:\d+\)*/, '$1'),
|
|
43
48
|
filePath,
|
|
@@ -45,7 +50,7 @@ function parseBabelErrorMessage(input) {
|
|
|
45
50
|
};
|
|
46
51
|
}
|
|
47
52
|
function clearMessage(str) {
|
|
48
|
-
return external_strip_ansi_default()(str).replace(/.*: (.*)\n\n[\s\S]*/g, '$1');
|
|
53
|
+
return external_strip_ansi_default()(truncateMessage(str)).replace(/.*: (.*)\n\n[\s\S]*/g, '$1');
|
|
49
54
|
}
|
|
50
55
|
function clearStack(str) {
|
|
51
56
|
return str.slice(str.indexOf(' at')).replace(/\s*at(.*) \((.*)\)/g, '$1\n$2\n');
|
|
@@ -72,7 +77,7 @@ function transformEsbuildError(err, opt) {
|
|
|
72
77
|
}
|
|
73
78
|
function transformBabelError(err, opt) {
|
|
74
79
|
if (isBabelError(err)) {
|
|
75
|
-
let errorCode = opt?.code ?? err.code ?? 'BABEL', title = err.reasonCode, errorParsed = parseBabelErrorMessage(err.message), speedyError = new DevToolError(title, errorParsed.message, {
|
|
80
|
+
let errorCode = opt?.code ?? err.code ?? 'BABEL', title = err.reasonCode, errorParsed = parseBabelErrorMessage(err.message), speedyError = new DevToolError(title, truncateMessage(errorParsed.message), {
|
|
76
81
|
...opt,
|
|
77
82
|
code: errorCode,
|
|
78
83
|
stack: err.stack && clearStack(err.stack)
|
|
@@ -100,8 +105,8 @@ function transformNormalError(err, opt) {
|
|
|
100
105
|
}
|
|
101
106
|
function transformErrorLike(err, opt) {
|
|
102
107
|
if (err && 'object' == typeof err && err.message) {
|
|
103
|
-
let filePath = [][0]?.getFileName?.();
|
|
104
|
-
return new DevToolError(err.name || 'UNKNOWN_ERROR', clearMessage(
|
|
108
|
+
let filePath = [][0]?.getFileName?.(), message = truncateMessage(err.message);
|
|
109
|
+
return new DevToolError(err.name || 'UNKNOWN_ERROR', clearMessage(message), {
|
|
105
110
|
...opt,
|
|
106
111
|
codeFrame: filePath ? {
|
|
107
112
|
filePath
|
|
@@ -111,7 +116,7 @@ function transformErrorLike(err, opt) {
|
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
118
|
function transformDiagnostic(err, opt) {
|
|
114
|
-
if (isDiagnosticError(err)) return new DevToolError(err.title, err.message, {
|
|
119
|
+
if (isDiagnosticError(err)) return new DevToolError(err.title, truncateMessage(err.message), {
|
|
115
120
|
...err,
|
|
116
121
|
...opt,
|
|
117
122
|
hint: err.suggestions?.description,
|
package/dist/error.js
CHANGED
|
@@ -3,8 +3,12 @@ import { Err, Linter } from "@rsdoctor/types";
|
|
|
3
3
|
import { createColors } from "picocolors";
|
|
4
4
|
import deep_eql from "deep-eql";
|
|
5
5
|
import strip_ansi from "strip-ansi";
|
|
6
|
+
function truncateMessage(input, maxLen = 1000) {
|
|
7
|
+
let str = 'string' == typeof input ? input : String(input ?? '');
|
|
8
|
+
return str.length > maxLen ? str.slice(0, maxLen) : str;
|
|
9
|
+
}
|
|
6
10
|
function clearMessage(str) {
|
|
7
|
-
return strip_ansi(str).replace(/.*: (.*)\n\n[\s\S]*/g, '$1');
|
|
11
|
+
return strip_ansi(truncateMessage(str)).replace(/.*: (.*)\n\n[\s\S]*/g, '$1');
|
|
8
12
|
}
|
|
9
13
|
function clearStack(str) {
|
|
10
14
|
return str.slice(str.indexOf(' at')).replace(/\s*at(.*) \((.*)\)/g, '$1\n$2\n');
|
|
@@ -31,11 +35,11 @@ function transformEsbuildError(err, opt) {
|
|
|
31
35
|
}
|
|
32
36
|
function transformBabelError(err, opt) {
|
|
33
37
|
if ('code' in err && 'reasonCode' in err) {
|
|
34
|
-
let lines, filePath, errorCode = opt?.code ?? err.code ?? 'BABEL', title = err.reasonCode, errorParsed = (filePath = (lines = strip_ansi(err.message).split('\n'))[0].replace(/^([^:]+):.*/, '$1'), {
|
|
38
|
+
let lines, filePath, errorCode = opt?.code ?? err.code ?? 'BABEL', title = err.reasonCode, errorParsed = (filePath = (lines = strip_ansi(truncateMessage(err.message)).split('\n'))[0].replace(/^([^:]+):.*/, '$1'), {
|
|
35
39
|
message: lines[0].replace(/.*: (.*) \(\d+:\d+\)*/, '$1'),
|
|
36
40
|
filePath,
|
|
37
41
|
lineText: lines.find((line)=>line.startsWith('> '))?.replace(/> \d+ \| /, '') ?? ''
|
|
38
|
-
}), speedyError = new DevToolError(title, errorParsed.message, {
|
|
42
|
+
}), speedyError = new DevToolError(title, truncateMessage(errorParsed.message), {
|
|
39
43
|
...opt,
|
|
40
44
|
code: errorCode,
|
|
41
45
|
stack: err.stack && clearStack(err.stack)
|
|
@@ -63,8 +67,8 @@ function transformNormalError(err, opt) {
|
|
|
63
67
|
}
|
|
64
68
|
function transformErrorLike(err, opt) {
|
|
65
69
|
if (err && 'object' == typeof err && err.message) {
|
|
66
|
-
let filePath = [][0]?.getFileName?.();
|
|
67
|
-
return new DevToolError(err.name || 'UNKNOWN_ERROR', clearMessage(
|
|
70
|
+
let filePath = [][0]?.getFileName?.(), message = truncateMessage(err.message);
|
|
71
|
+
return new DevToolError(err.name || 'UNKNOWN_ERROR', clearMessage(message), {
|
|
68
72
|
...opt,
|
|
69
73
|
codeFrame: filePath ? {
|
|
70
74
|
filePath
|
|
@@ -74,7 +78,7 @@ function transformErrorLike(err, opt) {
|
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
function transformDiagnostic(err, opt) {
|
|
77
|
-
if ('severity' in err && 'title' in err) return new DevToolError(err.title, err.message, {
|
|
81
|
+
if ('severity' in err && 'title' in err) return new DevToolError(err.title, truncateMessage(err.message), {
|
|
78
82
|
...err,
|
|
79
83
|
...opt,
|
|
80
84
|
hint: err.suggestions?.description,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/utils",
|
|
3
|
-
"version": "1.5.0",
|
|
3
|
+
"version": "1.5.2-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
"picocolors": "^1.1.1",
|
|
77
77
|
"rslog": "^1.2.11",
|
|
78
78
|
"strip-ansi": "^6.0.1",
|
|
79
|
-
"@rsdoctor/types": "1.5.0"
|
|
79
|
+
"@rsdoctor/types": "1.5.2-beta.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@types/babel__code-frame": "7.0
|
|
82
|
+
"@types/babel__code-frame": "7.27.0",
|
|
83
83
|
"@types/connect": "3.4.38",
|
|
84
84
|
"@types/deep-eql": "4.0.2",
|
|
85
85
|
"@types/envinfo": "7.8.4",
|