monocart-coverage-reports 2.3.4 → 2.4.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 +3 -1
- package/lib/converter/ast-visitor.js +646 -0
- package/lib/converter/ast.js +115 -135
- package/lib/converter/collect-source-maps.js +1 -1
- package/lib/converter/converter.js +288 -197
- package/lib/converter/find-original-range.js +471 -411
- package/lib/converter/info-branch.js +13 -2
- package/lib/converter/info-function.js +29 -6
- package/lib/converter/info-statement.js +43 -0
- package/lib/default/options.js +1 -1
- package/lib/generate.js +2 -2
- package/lib/index.d.ts +24 -13
- package/lib/istanbul/istanbul.js +1 -1
- package/lib/packages/monocart-coverage-v8.js +1 -1
- package/lib/packages/monocart-coverage-vendor.js +38 -37
- package/lib/utils/util.js +8 -2
- package/lib/v8/v8-summary.js +5 -1
- package/lib/v8/v8.js +4 -1
- package/package.json +3 -3
- package/lib/converter/branches.js +0 -440
- package/lib/converter/info-line.js +0 -23
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
const Util = require('../utils/util.js');
|
|
2
2
|
module.exports = class InfoBranch {
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(data, original) {
|
|
4
|
+
const {
|
|
5
|
+
start, end, locations, type
|
|
6
|
+
} = data;
|
|
7
|
+
|
|
4
8
|
this.start = start;
|
|
5
9
|
this.end = end;
|
|
6
10
|
this.locations = locations;
|
|
7
|
-
this.type = type
|
|
11
|
+
this.type = type;
|
|
12
|
+
this.data = data;
|
|
13
|
+
this.original = original;
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
getRanges() {
|
|
@@ -20,6 +26,11 @@ module.exports = class InfoBranch {
|
|
|
20
26
|
if (item.ignored) {
|
|
21
27
|
range.ignored = true;
|
|
22
28
|
}
|
|
29
|
+
// for debug
|
|
30
|
+
if (Util.isDebug() && this.original) {
|
|
31
|
+
range.generatedStart = item.generatedStart;
|
|
32
|
+
range.generatedEnd = item.generatedEnd;
|
|
33
|
+
}
|
|
23
34
|
return range;
|
|
24
35
|
});
|
|
25
36
|
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
const Util = require('../utils/util.js');
|
|
2
2
|
module.exports = class InfoFunction {
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(data, original) {
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
start, end, bodyStart, bodyEnd, functionName, count
|
|
7
|
+
} = data;
|
|
8
|
+
|
|
4
9
|
this.start = start;
|
|
5
10
|
this.end = end;
|
|
11
|
+
this.bodyStart = bodyStart;
|
|
12
|
+
this.bodyEnd = bodyEnd;
|
|
6
13
|
this.count = count;
|
|
7
|
-
this.
|
|
14
|
+
this.functionName = functionName;
|
|
15
|
+
this.data = data;
|
|
16
|
+
this.original = original;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
getRange() {
|
|
@@ -16,13 +25,25 @@ module.exports = class InfoFunction {
|
|
|
16
25
|
if (this.ignored) {
|
|
17
26
|
range.ignored = true;
|
|
18
27
|
}
|
|
28
|
+
// for debug
|
|
29
|
+
if (Util.isDebug() && this.original) {
|
|
30
|
+
range.generatedStart = this.data.generatedStart;
|
|
31
|
+
range.generatedEnd = this.data.generatedEnd;
|
|
32
|
+
}
|
|
19
33
|
return range;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
generate(locator) {
|
|
36
|
+
generate(locator, index) {
|
|
23
37
|
|
|
24
|
-
const
|
|
38
|
+
const decl = {
|
|
25
39
|
start: this.start,
|
|
40
|
+
end: this.bodyStart
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Util.updateOffsetToLocation(locator, decl);
|
|
44
|
+
|
|
45
|
+
const loc = {
|
|
46
|
+
start: this.bodyStart,
|
|
26
47
|
end: this.end
|
|
27
48
|
};
|
|
28
49
|
|
|
@@ -30,9 +51,11 @@ module.exports = class InfoFunction {
|
|
|
30
51
|
|
|
31
52
|
const line = loc.start.line;
|
|
32
53
|
|
|
54
|
+
const functionName = this.functionName || `(anonymous_${index})`;
|
|
55
|
+
|
|
33
56
|
return {
|
|
34
|
-
name:
|
|
35
|
-
decl:
|
|
57
|
+
name: functionName,
|
|
58
|
+
decl: decl,
|
|
36
59
|
loc: loc,
|
|
37
60
|
line: line
|
|
38
61
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const Util = require('../utils/util.js');
|
|
2
|
+
module.exports = class InfoStatement {
|
|
3
|
+
constructor(data, original) {
|
|
4
|
+
const {
|
|
5
|
+
start, end, count
|
|
6
|
+
} = data;
|
|
7
|
+
|
|
8
|
+
this.start = start;
|
|
9
|
+
this.end = end;
|
|
10
|
+
this.count = count;
|
|
11
|
+
this.data = data;
|
|
12
|
+
this.original = original;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getRange() {
|
|
16
|
+
const range = {
|
|
17
|
+
start: this.start,
|
|
18
|
+
end: this.end,
|
|
19
|
+
count: this.count
|
|
20
|
+
};
|
|
21
|
+
if (this.ignored) {
|
|
22
|
+
range.ignored = true;
|
|
23
|
+
}
|
|
24
|
+
// for debug
|
|
25
|
+
if (Util.isDebug() && this.original) {
|
|
26
|
+
range.generatedStart = this.data.generatedStart;
|
|
27
|
+
range.generatedEnd = this.data.generatedEnd;
|
|
28
|
+
}
|
|
29
|
+
return range;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
generate(locator) {
|
|
33
|
+
|
|
34
|
+
const loc = {
|
|
35
|
+
start: this.start,
|
|
36
|
+
end: this.end
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Util.updateOffsetToLocation(locator, loc);
|
|
40
|
+
|
|
41
|
+
return loc;
|
|
42
|
+
}
|
|
43
|
+
};
|
package/lib/default/options.js
CHANGED
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
|
62
62
|
reportPath: null,
|
|
63
63
|
|
|
64
64
|
// {array} watermarks for low/medium/high. Defaults to [50, 80]
|
|
65
|
-
// {object}
|
|
65
|
+
// {object} { bytes:[50,80], statements:[50,80], branches:[50,80], functions:[50,80], lines:[50,80] }
|
|
66
66
|
watermarks: [50, 80],
|
|
67
67
|
|
|
68
68
|
// {function} onEnd hook
|
package/lib/generate.js
CHANGED
|
@@ -166,8 +166,8 @@ const showConsoleSummary = (reportData, reportOptions, options) => {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
const allMetrics = {
|
|
169
|
-
v8: ['bytes', '
|
|
170
|
-
istanbul: ['statements', '
|
|
169
|
+
v8: ['bytes', 'statements', 'branches', 'functions', 'lines'],
|
|
170
|
+
istanbul: ['statements', 'branches', 'functions', 'lines']
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
let list = allMetrics[type];
|
package/lib/index.d.ts
CHANGED
|
@@ -15,13 +15,12 @@ declare namespace MCR {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export type Watermarks = [number, number] | {
|
|
18
|
-
functions?: [number, number];
|
|
19
|
-
branches?: [number, number];
|
|
20
|
-
lines?: [number, number];
|
|
21
18
|
/** V8 only */
|
|
22
19
|
bytes?: [number, number];
|
|
23
|
-
/** Istanbul only */
|
|
24
20
|
statements?: [number, number];
|
|
21
|
+
branches?: [number, number];
|
|
22
|
+
functions?: [number, number];
|
|
23
|
+
lines?: [number, number];
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export type ReportDescription =
|
|
@@ -29,7 +28,7 @@ declare namespace MCR {
|
|
|
29
28
|
outputFile?: string;
|
|
30
29
|
inline?: boolean;
|
|
31
30
|
assetsPath?: string;
|
|
32
|
-
metrics?: Array<"bytes" | "
|
|
31
|
+
metrics?: Array<"bytes" | "statements" | "branches" | "functions" | "lines">;
|
|
33
32
|
}] |
|
|
34
33
|
['v8-json'] | ["v8-json", {
|
|
35
34
|
outputFile?: string;
|
|
@@ -56,7 +55,7 @@ declare namespace MCR {
|
|
|
56
55
|
verbose?: boolean;
|
|
57
56
|
linkMapper?: any;
|
|
58
57
|
skipEmpty?: boolean;
|
|
59
|
-
metricsToShow?: Array<"
|
|
58
|
+
metricsToShow?: Array<"statements" | "branches" | "functions" | "lines">;
|
|
60
59
|
}] |
|
|
61
60
|
['json'] | ['json', {
|
|
62
61
|
file?: string;
|
|
@@ -90,7 +89,7 @@ declare namespace MCR {
|
|
|
90
89
|
file?: string;
|
|
91
90
|
}] |
|
|
92
91
|
['console-summary'] | ['console-summary', {
|
|
93
|
-
metrics?: Array<"bytes" | "
|
|
92
|
+
metrics?: Array<"bytes" | "statements" | "branches" | "functions" | "lines">;
|
|
94
93
|
}] |
|
|
95
94
|
['raw'] | ['raw', {
|
|
96
95
|
outputDir?: string;
|
|
@@ -121,13 +120,12 @@ declare namespace MCR {
|
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
export interface CoverageSummary {
|
|
124
|
-
functions: MetricsSummary;
|
|
125
|
-
branches: MetricsSummary;
|
|
126
|
-
lines: MetricsSummary;
|
|
127
123
|
/** V8 only */
|
|
128
124
|
bytes?: MetricsSummary;
|
|
129
|
-
/** Istanbul only */
|
|
130
125
|
statements?: MetricsSummary;
|
|
126
|
+
branches: MetricsSummary;
|
|
127
|
+
functions: MetricsSummary;
|
|
128
|
+
lines: MetricsSummary;
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
/** V8 only */
|
|
@@ -139,6 +137,13 @@ declare namespace MCR {
|
|
|
139
137
|
none?: boolean;
|
|
140
138
|
}
|
|
141
139
|
|
|
140
|
+
export interface IgnoredRange {
|
|
141
|
+
start: number;
|
|
142
|
+
end: number;
|
|
143
|
+
type: string;
|
|
144
|
+
n?: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
142
147
|
export interface CoverageFile {
|
|
143
148
|
sourcePath: string;
|
|
144
149
|
summary: CoverageSummary;
|
|
@@ -157,8 +162,14 @@ declare namespace MCR {
|
|
|
157
162
|
/** V8 only */
|
|
158
163
|
data?: {
|
|
159
164
|
bytes: CoverageRange[];
|
|
160
|
-
|
|
165
|
+
statements: CoverageRange[];
|
|
161
166
|
branches: CoverageRange[];
|
|
167
|
+
functions: CoverageRange[];
|
|
168
|
+
ignores?: IgnoredRange[];
|
|
169
|
+
/** codecov json format */
|
|
170
|
+
lines: {
|
|
171
|
+
[key: string]: number | string
|
|
172
|
+
};
|
|
162
173
|
}
|
|
163
174
|
}
|
|
164
175
|
|
|
@@ -218,7 +229,7 @@ declare namespace MCR {
|
|
|
218
229
|
reportPath?: string | (() => string);
|
|
219
230
|
|
|
220
231
|
/** {array} watermarks for low/medium/high. Defaults to [50, 80]
|
|
221
|
-
* {object} {
|
|
232
|
+
* {object} { bytes:[50,80], statements:[50,80], branches:[50,80], functions:[50,80], lines:[50,80] } */
|
|
222
233
|
watermarks?: Watermarks;
|
|
223
234
|
|
|
224
235
|
/** {function} onEnd hook */
|
package/lib/istanbul/istanbul.js
CHANGED
|
@@ -39,8 +39,8 @@ const saveIstanbulReports = (coverageData, fileSources, options) => {
|
|
|
39
39
|
|
|
40
40
|
const defaultWatermarks = {
|
|
41
41
|
statements: [50, 80],
|
|
42
|
-
functions: [50, 80],
|
|
43
42
|
branches: [50, 80],
|
|
43
|
+
functions: [50, 80],
|
|
44
44
|
lines: [50, 80]
|
|
45
45
|
};
|
|
46
46
|
const watermarks = Util.resolveWatermarks(defaultWatermarks, options.watermarks);
|