monocart-coverage-reports 2.9.2 → 2.10.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/README.md +5 -2
- package/README.zh-Hans.md +5 -2
- package/lib/assets.js +98 -0
- package/lib/converter/converter.js +21 -6
- package/lib/converter/find-original-range.js +19 -10
- package/lib/converter/flatten-source-maps.js +186 -166
- package/lib/converter/ignore.js +86 -24
- package/lib/converter/info-function.js +7 -4
- package/lib/generate.js +88 -475
- package/lib/index.d.ts +22 -1
- package/lib/istanbul/istanbul.js +11 -8
- package/lib/packages/monocart-coverage-assets.js +4 -0
- package/lib/packages/monocart-coverage-vendor.js +22 -20
- package/lib/platform/share.js +16 -0
- package/lib/reports/codacy.js +43 -0
- package/lib/reports/codecov.js +28 -0
- package/lib/reports/console-details.js +174 -0
- package/lib/reports/console-summary.js +83 -0
- package/lib/reports/markdown-details.js +121 -0
- package/lib/reports/markdown-summary.js +45 -0
- package/lib/reports/raw.js +33 -0
- package/lib/reports/v8-json.js +22 -0
- package/lib/reports/v8.js +51 -0
- package/lib/utils/markdown.js +132 -132
- package/lib/utils/util.js +10 -126
- package/lib/v8/v8.js +14 -73
- package/package.json +116 -112
- package/lib/packages/monocart-coverage-app.js +0 -1
|
@@ -1,166 +1,186 @@
|
|
|
1
|
-
const { decode } = require('@jridgewell/sourcemap-codec');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
input
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
input
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
1
|
+
const { decode } = require('@jridgewell/sourcemap-codec');
|
|
2
|
+
|
|
3
|
+
const COLUMN = 0;
|
|
4
|
+
const SOURCES_INDEX = 1;
|
|
5
|
+
const SOURCE_LINE = 2;
|
|
6
|
+
const SOURCE_COLUMN = 3;
|
|
7
|
+
const NAMES_INDEX = 4;
|
|
8
|
+
|
|
9
|
+
function getLine(arr, index) {
|
|
10
|
+
for (let i = arr.length; i <= index; i++) {
|
|
11
|
+
arr[i] = [];
|
|
12
|
+
}
|
|
13
|
+
return arr[index];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getMapping(seg, column, sourcesOffset, namesOffset) {
|
|
17
|
+
|
|
18
|
+
const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
|
|
19
|
+
const sourceLine = seg[SOURCE_LINE];
|
|
20
|
+
const sourceColumn = seg[SOURCE_COLUMN];
|
|
21
|
+
|
|
22
|
+
if (seg.length === 4) {
|
|
23
|
+
return [column, sourcesIndex, sourceLine, sourceColumn];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function addMappings(options, sourcesOffset, namesOffset) {
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
input,
|
|
33
|
+
lineOffset,
|
|
34
|
+
columnOffset,
|
|
35
|
+
stopLine,
|
|
36
|
+
stopColumn
|
|
37
|
+
} = options;
|
|
38
|
+
|
|
39
|
+
const decoded = decode(input.mappings);
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
42
|
+
const lineI = lineOffset + i;
|
|
43
|
+
|
|
44
|
+
if (lineI > stopLine) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const out = getLine(options.decodedMappings, lineI);
|
|
49
|
+
const cOffset = i === 0 ? columnOffset : 0;
|
|
50
|
+
|
|
51
|
+
const line = decoded[i];
|
|
52
|
+
for (let j = 0; j < line.length; j++) {
|
|
53
|
+
const seg = line[j];
|
|
54
|
+
const column = cOffset + seg[COLUMN];
|
|
55
|
+
|
|
56
|
+
if (lineI === stopLine && column >= stopColumn) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (seg.length === 1) {
|
|
61
|
+
out.push([column]);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
out.push(getMapping(seg, column, sourcesOffset, namesOffset));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function addSection(options) {
|
|
71
|
+
|
|
72
|
+
const { input } = options;
|
|
73
|
+
|
|
74
|
+
const { sections } = input;
|
|
75
|
+
if (sections) {
|
|
76
|
+
return flatten(options);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const sourcesOffset = options.sources.length;
|
|
80
|
+
const namesOffset = options.names.length;
|
|
81
|
+
|
|
82
|
+
// sources and sourcesContent
|
|
83
|
+
if (!input.sourcesContent) {
|
|
84
|
+
input.sourcesContent = [];
|
|
85
|
+
}
|
|
86
|
+
input.sources.forEach((src, i) => {
|
|
87
|
+
options.sources.push(src);
|
|
88
|
+
options.sourcesContent.push(input.sourcesContent[i] || null);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// names
|
|
92
|
+
if (input.names) {
|
|
93
|
+
input.names.forEach((n) => {
|
|
94
|
+
options.names.push(n);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
addMappings(options, sourcesOffset, namesOffset);
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function flatten(options) {
|
|
103
|
+
|
|
104
|
+
const {
|
|
105
|
+
input,
|
|
106
|
+
lineOffset,
|
|
107
|
+
columnOffset,
|
|
108
|
+
stopLine,
|
|
109
|
+
stopColumn
|
|
110
|
+
} = options;
|
|
111
|
+
|
|
112
|
+
const { sections } = input;
|
|
113
|
+
|
|
114
|
+
for (let i = 0, l = sections.length; i < l; i++) {
|
|
115
|
+
const { map, offset } = sections[i];
|
|
116
|
+
|
|
117
|
+
let sl = stopLine;
|
|
118
|
+
let sc = stopColumn;
|
|
119
|
+
if (i + 1 < sections.length) {
|
|
120
|
+
const nextOffset = sections[i + 1].offset;
|
|
121
|
+
sl = Math.min(stopLine, lineOffset + nextOffset.line);
|
|
122
|
+
|
|
123
|
+
if (sl === stopLine) {
|
|
124
|
+
sc = Math.min(stopColumn, columnOffset + nextOffset.column);
|
|
125
|
+
} else if (sl < stopLine) {
|
|
126
|
+
sc = columnOffset + nextOffset.column;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
options.input = map;
|
|
131
|
+
options.lineOffset = lineOffset + offset.line;
|
|
132
|
+
options.columnOffset = columnOffset + offset.column;
|
|
133
|
+
options.stopLine = sl;
|
|
134
|
+
options.stopColumn = sc;
|
|
135
|
+
|
|
136
|
+
addSection(options);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const flattenSourceMaps = function(indexedMap, mapUrl) {
|
|
141
|
+
|
|
142
|
+
const sections = indexedMap.sections;
|
|
143
|
+
if (!sections) {
|
|
144
|
+
return indexedMap;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const decodedMappings = [];
|
|
148
|
+
const sources = [];
|
|
149
|
+
const sourcesContent = [];
|
|
150
|
+
const names = [];
|
|
151
|
+
|
|
152
|
+
const lineOffset = 0;
|
|
153
|
+
const columnOffset = 0;
|
|
154
|
+
const stopLine = Infinity;
|
|
155
|
+
const stopColumn = Infinity;
|
|
156
|
+
|
|
157
|
+
flatten({
|
|
158
|
+
input: indexedMap,
|
|
159
|
+
|
|
160
|
+
mapUrl,
|
|
161
|
+
|
|
162
|
+
decodedMappings,
|
|
163
|
+
sources,
|
|
164
|
+
sourcesContent,
|
|
165
|
+
|
|
166
|
+
names,
|
|
167
|
+
|
|
168
|
+
lineOffset,
|
|
169
|
+
columnOffset,
|
|
170
|
+
stopLine,
|
|
171
|
+
stopColumn
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
indexedMap.sources = sources;
|
|
175
|
+
indexedMap.sourcesContent = sourcesContent;
|
|
176
|
+
indexedMap.names = names;
|
|
177
|
+
indexedMap.decodedMappings = decodedMappings;
|
|
178
|
+
|
|
179
|
+
// console.log(decodedMappings);
|
|
180
|
+
|
|
181
|
+
return indexedMap;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
module.exports = {
|
|
185
|
+
flattenSourceMaps
|
|
186
|
+
};
|
package/lib/converter/ignore.js
CHANGED
|
@@ -69,16 +69,77 @@ const addNextIgnore = (list, content, item, locator) => {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// both v8 or c8
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const getStartEndNextInfo = (content) => {
|
|
73
|
+
content = content.trim();
|
|
74
|
+
|
|
75
|
+
const start = 'start';
|
|
76
|
+
const stop = 'stop';
|
|
77
|
+
const next = 'next';
|
|
78
|
+
if (content.startsWith(start)) {
|
|
79
|
+
return {
|
|
80
|
+
type: 'range',
|
|
81
|
+
value: stop
|
|
82
|
+
};
|
|
76
83
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
if (content.startsWith(stop)) {
|
|
85
|
+
return {
|
|
86
|
+
type: 'range',
|
|
87
|
+
value: stop
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (content.startsWith(next)) {
|
|
91
|
+
return {
|
|
92
|
+
type: 'next',
|
|
93
|
+
value: content.slice(next.length)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const getDisableEnableNextInfo = (content) => {
|
|
99
|
+
content = content.trim();
|
|
100
|
+
|
|
101
|
+
const start = 'disable';
|
|
102
|
+
const stop = 'enable';
|
|
103
|
+
const next = 'ignore next';
|
|
104
|
+
if (content.startsWith(start)) {
|
|
105
|
+
return {
|
|
106
|
+
type: 'range',
|
|
107
|
+
value: stop
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (content.startsWith(stop)) {
|
|
111
|
+
return {
|
|
112
|
+
type: 'range',
|
|
113
|
+
value: stop
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (content.startsWith(next)) {
|
|
117
|
+
return {
|
|
118
|
+
type: 'next',
|
|
119
|
+
value: content.slice(next.length)
|
|
120
|
+
};
|
|
80
121
|
}
|
|
81
|
-
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
const getIgnoreInfo = (content) => {
|
|
126
|
+
content = content.trim();
|
|
127
|
+
|
|
128
|
+
const v8_ignore = 'v8 ignore';
|
|
129
|
+
if (content.startsWith(v8_ignore)) {
|
|
130
|
+
return getStartEndNextInfo(content.slice(v8_ignore.length));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const c8_ignore = 'c8 ignore';
|
|
134
|
+
if (content.startsWith(c8_ignore)) {
|
|
135
|
+
return getStartEndNextInfo(content.slice(c8_ignore.length));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const node_coverage = 'node:coverage';
|
|
139
|
+
if (content.startsWith(node_coverage)) {
|
|
140
|
+
return getDisableEnableNextInfo(content.slice(node_coverage.length));
|
|
141
|
+
}
|
|
142
|
+
|
|
82
143
|
};
|
|
83
144
|
|
|
84
145
|
const getIgnoredRanges = (locator, options) => {
|
|
@@ -101,42 +162,43 @@ const getIgnoredRanges = (locator, options) => {
|
|
|
101
162
|
const {
|
|
102
163
|
block, start, end, text
|
|
103
164
|
} = item;
|
|
104
|
-
let content = block ? text.slice(2, -2) : text.slice(2);
|
|
105
|
-
content = content.trim();
|
|
106
165
|
|
|
107
|
-
const
|
|
108
|
-
|
|
166
|
+
const content = block ? text.slice(2, -2) : text.slice(2);
|
|
167
|
+
const ignoreInfo = getIgnoreInfo(content);
|
|
168
|
+
if (!ignoreInfo) {
|
|
109
169
|
return;
|
|
110
170
|
}
|
|
111
171
|
|
|
112
|
-
|
|
172
|
+
const { type, value } = ignoreInfo;
|
|
113
173
|
|
|
114
174
|
if (ignoreStart) {
|
|
115
175
|
// v-8 ignore stop
|
|
116
|
-
if (
|
|
117
|
-
ignoreStart.end = extendEnd(end, source, maxLength);
|
|
176
|
+
if (type === 'range' && value === ignoreStart.value) {
|
|
177
|
+
ignoreStart.ignoreData.end = extendEnd(end, source, maxLength);
|
|
118
178
|
ignoreStart = null;
|
|
119
179
|
}
|
|
120
180
|
return;
|
|
121
181
|
}
|
|
122
182
|
|
|
123
183
|
// v-8 ignore start
|
|
124
|
-
if (
|
|
184
|
+
if (type === 'range') {
|
|
125
185
|
// add first for sort by start
|
|
126
|
-
|
|
127
|
-
type
|
|
186
|
+
const ignoreData = {
|
|
187
|
+
type,
|
|
128
188
|
start: extendStart(start, source),
|
|
129
189
|
end: start
|
|
130
190
|
};
|
|
131
|
-
list.push(
|
|
191
|
+
list.push(ignoreData);
|
|
192
|
+
ignoreStart = {
|
|
193
|
+
ignoreData,
|
|
194
|
+
value
|
|
195
|
+
};
|
|
132
196
|
return;
|
|
133
197
|
}
|
|
134
198
|
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
content = content.slice(nextKey.length).trim();
|
|
139
|
-
addNextIgnore(list, content, item, locator);
|
|
199
|
+
// next N
|
|
200
|
+
if (type === 'next') {
|
|
201
|
+
addNextIgnore(list, value.trim(), item, locator);
|
|
140
202
|
}
|
|
141
203
|
|
|
142
204
|
});
|
|
@@ -16,8 +16,13 @@ module.exports = class InfoFunction {
|
|
|
16
16
|
this.original = original;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
getName(index) {
|
|
20
|
+
return this.functionName || `(anonymous_${index})`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getRange(index) {
|
|
20
24
|
const range = {
|
|
25
|
+
name: this.getName(index),
|
|
21
26
|
start: this.start,
|
|
22
27
|
end: this.end,
|
|
23
28
|
count: this.count
|
|
@@ -51,10 +56,8 @@ module.exports = class InfoFunction {
|
|
|
51
56
|
|
|
52
57
|
const line = loc.start.line;
|
|
53
58
|
|
|
54
|
-
const functionName = this.functionName || `(anonymous_${index})`;
|
|
55
|
-
|
|
56
59
|
return {
|
|
57
|
-
name:
|
|
60
|
+
name: this.getName(index),
|
|
58
61
|
decl: decl,
|
|
59
62
|
loc: loc,
|
|
60
63
|
line: line
|