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
package/lib/utils/markdown.js
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
|
-
|
|
3
|
-
const renderLine = (ls, padding) => {
|
|
4
|
-
const spacing = ''.padEnd(padding, ' ');
|
|
5
|
-
const line = ls.join(`${spacing}|${spacing}`);
|
|
6
|
-
return `|${spacing}${line}${spacing}|`;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const renderCell = (cellValue, column) => {
|
|
10
|
-
|
|
11
|
-
// To include a pipe | as content within your cell, use a \ before the pipe:
|
|
12
|
-
cellValue = cellValue.split(/\\?\|/g).join('\\|');
|
|
13
|
-
const valueWidth = cellValue.length;
|
|
14
|
-
const width = column.width;
|
|
15
|
-
|
|
16
|
-
if (width <= valueWidth) {
|
|
17
|
-
return cellValue;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const spacingWidth = width - valueWidth;
|
|
21
|
-
const spacing = ''.padEnd(spacingWidth, ' ');
|
|
22
|
-
|
|
23
|
-
const align = column.align;
|
|
24
|
-
|
|
25
|
-
if (align === 'right') {
|
|
26
|
-
return spacing + cellValue;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (align === 'center') {
|
|
30
|
-
const l = Math.round(spacingWidth * 0.5);
|
|
31
|
-
const r = spacingWidth - l;
|
|
32
|
-
const spacingL = ''.padEnd(l, ' ');
|
|
33
|
-
const spacingR = ''.padEnd(r, ' ');
|
|
34
|
-
return spacingL + cellValue + spacingR;
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return cellValue + spacing;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const renderHyphen = (column) => {
|
|
42
|
-
const width = column.width;
|
|
43
|
-
const align = column.align;
|
|
44
|
-
if (align === 'right') {
|
|
45
|
-
return ':'.padStart(width, '-');
|
|
46
|
-
}
|
|
47
|
-
if (align === 'center') {
|
|
48
|
-
const hyphen = ''.padEnd(width - 2, '-');
|
|
49
|
-
return `:${hyphen}:`;
|
|
50
|
-
}
|
|
51
|
-
// default to left
|
|
52
|
-
return ':'.padEnd(width, '-');
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const generateMarkdownGrid = (data) => {
|
|
56
|
-
|
|
57
|
-
const options = {
|
|
58
|
-
name: '',
|
|
59
|
-
padding: 1,
|
|
60
|
-
nullPlaceholder: '',
|
|
61
|
-
... data.options
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const padding = options.padding;
|
|
65
|
-
|
|
66
|
-
// console.log(data, options);
|
|
67
|
-
|
|
68
|
-
const lines = [];
|
|
69
|
-
|
|
70
|
-
if (options.name) {
|
|
71
|
-
lines.push(`## ${options.name}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// init columns
|
|
75
|
-
const columns = data.columns.map((item) => {
|
|
76
|
-
if (typeof item === 'string') {
|
|
77
|
-
item = {
|
|
78
|
-
name: item
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
const column = {
|
|
82
|
-
... item
|
|
83
|
-
};
|
|
84
|
-
column.name = `${column.name}`;
|
|
85
|
-
if (typeof column.width !== 'number') {
|
|
86
|
-
column.width = column.name.length;
|
|
87
|
-
}
|
|
88
|
-
column.width = Math.max(column.width, 3);
|
|
89
|
-
return column;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// header
|
|
93
|
-
const headers = [];
|
|
94
|
-
columns.forEach((column) => {
|
|
95
|
-
headers.push(renderCell(column.name, column));
|
|
96
|
-
});
|
|
97
|
-
lines.push(renderLine(headers, padding));
|
|
98
|
-
|
|
99
|
-
const hyphens = [];
|
|
100
|
-
columns.forEach((column) => {
|
|
101
|
-
hyphens.push(renderHyphen(column));
|
|
102
|
-
});
|
|
103
|
-
lines.push(renderLine(hyphens, padding));
|
|
104
|
-
|
|
105
|
-
// rows
|
|
106
|
-
data.rows.forEach((row) => {
|
|
107
|
-
const cells = [];
|
|
108
|
-
columns.forEach((column, i) => {
|
|
109
|
-
let cellValue = '';
|
|
110
|
-
if (Array.isArray(row)) {
|
|
111
|
-
cellValue += row[i];
|
|
112
|
-
} else {
|
|
113
|
-
let v = row[column.id];
|
|
114
|
-
if (typeof v === 'undefined' || v === null) {
|
|
115
|
-
v = options.nullPlaceholder;
|
|
116
|
-
}
|
|
117
|
-
if (column.formatter) {
|
|
118
|
-
v = column.formatter(v, row, column);
|
|
119
|
-
}
|
|
120
|
-
cellValue += v;
|
|
121
|
-
}
|
|
122
|
-
cells.push(renderCell(cellValue, column));
|
|
123
|
-
});
|
|
124
|
-
lines.push(renderLine(cells, padding));
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
return lines.join(os.EOL) + os.EOL;
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
module.exports = generateMarkdownGrid;
|
|
1
|
+
const os = require('os');
|
|
2
|
+
|
|
3
|
+
const renderLine = (ls, padding) => {
|
|
4
|
+
const spacing = ''.padEnd(padding, ' ');
|
|
5
|
+
const line = ls.join(`${spacing}|${spacing}`);
|
|
6
|
+
return `|${spacing}${line}${spacing}|`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const renderCell = (cellValue, column) => {
|
|
10
|
+
|
|
11
|
+
// To include a pipe | as content within your cell, use a \ before the pipe:
|
|
12
|
+
cellValue = cellValue.split(/\\?\|/g).join('\\|');
|
|
13
|
+
const valueWidth = cellValue.length;
|
|
14
|
+
const width = column.width;
|
|
15
|
+
|
|
16
|
+
if (width <= valueWidth) {
|
|
17
|
+
return cellValue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const spacingWidth = width - valueWidth;
|
|
21
|
+
const spacing = ''.padEnd(spacingWidth, ' ');
|
|
22
|
+
|
|
23
|
+
const align = column.align;
|
|
24
|
+
|
|
25
|
+
if (align === 'right') {
|
|
26
|
+
return spacing + cellValue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (align === 'center') {
|
|
30
|
+
const l = Math.round(spacingWidth * 0.5);
|
|
31
|
+
const r = spacingWidth - l;
|
|
32
|
+
const spacingL = ''.padEnd(l, ' ');
|
|
33
|
+
const spacingR = ''.padEnd(r, ' ');
|
|
34
|
+
return spacingL + cellValue + spacingR;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return cellValue + spacing;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const renderHyphen = (column) => {
|
|
42
|
+
const width = column.width;
|
|
43
|
+
const align = column.align;
|
|
44
|
+
if (align === 'right') {
|
|
45
|
+
return ':'.padStart(width, '-');
|
|
46
|
+
}
|
|
47
|
+
if (align === 'center') {
|
|
48
|
+
const hyphen = ''.padEnd(width - 2, '-');
|
|
49
|
+
return `:${hyphen}:`;
|
|
50
|
+
}
|
|
51
|
+
// default to left
|
|
52
|
+
return ':'.padEnd(width, '-');
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const generateMarkdownGrid = (data) => {
|
|
56
|
+
|
|
57
|
+
const options = {
|
|
58
|
+
name: '',
|
|
59
|
+
padding: 1,
|
|
60
|
+
nullPlaceholder: '',
|
|
61
|
+
... data.options
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const padding = options.padding;
|
|
65
|
+
|
|
66
|
+
// console.log(data, options);
|
|
67
|
+
|
|
68
|
+
const lines = [];
|
|
69
|
+
|
|
70
|
+
if (options.name) {
|
|
71
|
+
lines.push(`## ${options.name}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// init columns
|
|
75
|
+
const columns = data.columns.map((item) => {
|
|
76
|
+
if (typeof item === 'string') {
|
|
77
|
+
item = {
|
|
78
|
+
name: item
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const column = {
|
|
82
|
+
... item
|
|
83
|
+
};
|
|
84
|
+
column.name = `${column.name}`;
|
|
85
|
+
if (typeof column.width !== 'number') {
|
|
86
|
+
column.width = column.name.length;
|
|
87
|
+
}
|
|
88
|
+
column.width = Math.max(column.width, 3);
|
|
89
|
+
return column;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// header
|
|
93
|
+
const headers = [];
|
|
94
|
+
columns.forEach((column) => {
|
|
95
|
+
headers.push(renderCell(column.name, column));
|
|
96
|
+
});
|
|
97
|
+
lines.push(renderLine(headers, padding));
|
|
98
|
+
|
|
99
|
+
const hyphens = [];
|
|
100
|
+
columns.forEach((column) => {
|
|
101
|
+
hyphens.push(renderHyphen(column));
|
|
102
|
+
});
|
|
103
|
+
lines.push(renderLine(hyphens, padding));
|
|
104
|
+
|
|
105
|
+
// rows
|
|
106
|
+
data.rows.forEach((row) => {
|
|
107
|
+
const cells = [];
|
|
108
|
+
columns.forEach((column, i) => {
|
|
109
|
+
let cellValue = '';
|
|
110
|
+
if (Array.isArray(row)) {
|
|
111
|
+
cellValue += row[i];
|
|
112
|
+
} else {
|
|
113
|
+
let v = row[column.id];
|
|
114
|
+
if (typeof v === 'undefined' || v === null) {
|
|
115
|
+
v = options.nullPlaceholder;
|
|
116
|
+
}
|
|
117
|
+
if (column.formatter) {
|
|
118
|
+
v = column.formatter(v, row, column);
|
|
119
|
+
}
|
|
120
|
+
cellValue += v;
|
|
121
|
+
}
|
|
122
|
+
cells.push(renderCell(cellValue, column));
|
|
123
|
+
});
|
|
124
|
+
lines.push(renderLine(cells, padding));
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return lines.join(os.EOL) + os.EOL;
|
|
128
|
+
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
module.exports = generateMarkdownGrid;
|
package/lib/utils/util.js
CHANGED
|
@@ -8,10 +8,8 @@ const EC = require('eight-colors');
|
|
|
8
8
|
const CG = require('console-grid');
|
|
9
9
|
const Share = require('../platform/share.js');
|
|
10
10
|
const request = require('./request.js');
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const version = require('../../package.json').version;
|
|
13
12
|
const acornWalk = require('acorn-walk');
|
|
14
|
-
|
|
15
13
|
const { findUpSync, supportsColor } = require('../packages/monocart-coverage-vendor.js');
|
|
16
14
|
|
|
17
15
|
// https://github.com/chalk/supports-color
|
|
@@ -21,6 +19,8 @@ if (!supportsColor.stdout) {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
const Util = {
|
|
22
|
+
version,
|
|
23
|
+
|
|
24
24
|
... Share,
|
|
25
25
|
|
|
26
26
|
EC,
|
|
@@ -149,42 +149,6 @@ const Util = {
|
|
|
149
149
|
return htmlPathHandler();
|
|
150
150
|
},
|
|
151
151
|
|
|
152
|
-
resolveNodeModule: (id) => {
|
|
153
|
-
|
|
154
|
-
// for deno npm module
|
|
155
|
-
const mp = require.resolve(id);
|
|
156
|
-
if (fs.existsSync(mp)) {
|
|
157
|
-
return mp;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const p = `${it}/dist/${it}.js`;
|
|
161
|
-
// root
|
|
162
|
-
const cwd = path.resolve('node_modules', p);
|
|
163
|
-
if (fs.existsSync(cwd)) {
|
|
164
|
-
return cwd;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// sub node modules
|
|
168
|
-
const sub = path.resolve(__dirname, '../../node_modules', p);
|
|
169
|
-
if (fs.existsSync(sub)) {
|
|
170
|
-
return sub;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// same level dep
|
|
174
|
-
const dep = path.resolve(__dirname, '../../../', p);
|
|
175
|
-
if (fs.existsSync(dep)) {
|
|
176
|
-
return dep;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
Util.logError(`Not found module: ${p}`);
|
|
180
|
-
|
|
181
|
-
return cwd;
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
resolvePackage: (p) => {
|
|
185
|
-
return path.resolve(__dirname, '../packages', p);
|
|
186
|
-
},
|
|
187
|
-
|
|
188
152
|
getCacheFileInfo: (type, id, cacheDir) => {
|
|
189
153
|
const cacheName = `${type}-${id}.json`;
|
|
190
154
|
const cachePath = path.resolve(cacheDir, cacheName);
|
|
@@ -219,76 +183,6 @@ const Util = {
|
|
|
219
183
|
// default config not found
|
|
220
184
|
},
|
|
221
185
|
|
|
222
|
-
saveHtmlReport: async (options) => {
|
|
223
|
-
|
|
224
|
-
const {
|
|
225
|
-
inline,
|
|
226
|
-
reportData,
|
|
227
|
-
jsFiles,
|
|
228
|
-
assetsPath,
|
|
229
|
-
outputDir,
|
|
230
|
-
htmlFile,
|
|
231
|
-
|
|
232
|
-
reportDataFile
|
|
233
|
-
} = options;
|
|
234
|
-
|
|
235
|
-
// report data
|
|
236
|
-
const reportDataCompressed = deflateSync(JSON.stringify(reportData));
|
|
237
|
-
const reportDataStr = `window.reportData = '${reportDataCompressed}';`;
|
|
238
|
-
|
|
239
|
-
// js libs
|
|
240
|
-
const jsList = [];
|
|
241
|
-
for (const jsFile of jsFiles) {
|
|
242
|
-
const jsStr = await Util.readFile(jsFile);
|
|
243
|
-
jsList.push({
|
|
244
|
-
filename: path.basename(jsFile),
|
|
245
|
-
str: jsStr
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// html content
|
|
250
|
-
let htmlStr = '';
|
|
251
|
-
const EOL = Util.getEOL();
|
|
252
|
-
if (inline) {
|
|
253
|
-
htmlStr = [
|
|
254
|
-
'<script>',
|
|
255
|
-
reportDataStr,
|
|
256
|
-
... jsList.map((it) => it.str),
|
|
257
|
-
'</script>'
|
|
258
|
-
].join(EOL);
|
|
259
|
-
} else {
|
|
260
|
-
|
|
261
|
-
await Util.writeFile(path.resolve(outputDir, reportDataFile), reportDataStr);
|
|
262
|
-
|
|
263
|
-
const assetsDir = path.resolve(outputDir, assetsPath);
|
|
264
|
-
const relAssetsDir = Util.relativePath(assetsDir, outputDir);
|
|
265
|
-
|
|
266
|
-
for (const item of jsList) {
|
|
267
|
-
const filePath = path.resolve(assetsDir, item.filename);
|
|
268
|
-
if (!fs.existsSync(filePath)) {
|
|
269
|
-
await Util.writeFile(filePath, item.str);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
htmlStr = [
|
|
274
|
-
`<script src="${reportDataFile}"></script>`,
|
|
275
|
-
... jsList.map((it) => `<script src="${relAssetsDir}/${it.filename}"></script>`)
|
|
276
|
-
].join(EOL);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// html
|
|
280
|
-
const htmlPath = path.resolve(outputDir, htmlFile);
|
|
281
|
-
const template = Util.getTemplate(path.resolve(__dirname, '../default/template.html'));
|
|
282
|
-
const html = Util.replace(template, {
|
|
283
|
-
title: reportData.title,
|
|
284
|
-
content: htmlStr
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
await Util.writeFile(htmlPath, html);
|
|
288
|
-
|
|
289
|
-
return Util.relativePath(htmlPath);
|
|
290
|
-
},
|
|
291
|
-
|
|
292
186
|
runCustomReporter: async (reportName, reportData, reportOptions, globalOptions) => {
|
|
293
187
|
let CustomReporter;
|
|
294
188
|
let err;
|
|
@@ -485,26 +379,16 @@ const Util = {
|
|
|
485
379
|
}
|
|
486
380
|
},
|
|
487
381
|
|
|
488
|
-
getTemplate: function(templatePath) {
|
|
489
|
-
if (!Util.templateCache) {
|
|
490
|
-
Util.templateCache = {};
|
|
491
|
-
}
|
|
492
|
-
let template = Util.templateCache[templatePath];
|
|
493
|
-
if (!template) {
|
|
494
|
-
template = Util.readFileSync(templatePath);
|
|
495
|
-
if (template) {
|
|
496
|
-
Util.templateCache[templatePath] = template;
|
|
497
|
-
} else {
|
|
498
|
-
Util.logError(`not found template: ${templatePath}`);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return template;
|
|
502
|
-
},
|
|
503
|
-
|
|
504
382
|
normalizeColorType: (color) => {
|
|
505
383
|
return `${color}`.trim().toLowerCase();
|
|
506
384
|
},
|
|
507
385
|
|
|
386
|
+
normalizeMaxCols: (maxCols, min = 1) => {
|
|
387
|
+
if (Util.isNum(maxCols)) {
|
|
388
|
+
return Math.max(maxCols, min);
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
|
|
508
392
|
getColorStrByStatus: (str, status, color = '') => {
|
|
509
393
|
|
|
510
394
|
const colorHandlers = {
|
|
@@ -545,7 +429,7 @@ const Util = {
|
|
|
545
429
|
return str;
|
|
546
430
|
},
|
|
547
431
|
'tex': () => {
|
|
548
|
-
const texStr = str.replace(
|
|
432
|
+
const texStr = str.replace(/%/g, '\\\\%');
|
|
549
433
|
if (status === 'low') {
|
|
550
434
|
return `$\\color{red}{\\textsf{${texStr}}}$`;
|
|
551
435
|
}
|
package/lib/v8/v8.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
1
|
const EC = require('eight-colors');
|
|
3
|
-
const { minimatch } = require('minimatch');
|
|
4
2
|
const { mergeScriptCovs } = require('@bcoe/v8-coverage');
|
|
5
|
-
|
|
6
3
|
const Util = require('../utils/util.js');
|
|
7
4
|
const { getV8Summary } = require('./v8-summary.js');
|
|
8
5
|
const { dedupeFlatRanges } = require('../utils/dedupe.js');
|
|
@@ -10,7 +7,10 @@ const {
|
|
|
10
7
|
resolveAnonymousUrl, normalizeSourcePath, getSourcePathReplacer
|
|
11
8
|
} = require('../utils/source-path.js');
|
|
12
9
|
const { collectSourceMaps } = require('../converter/collect-source-maps.js');
|
|
13
|
-
const
|
|
10
|
+
const { minimatch } = require('../packages/monocart-coverage-vendor.js');
|
|
11
|
+
|
|
12
|
+
const { v8Report } = require('../reports/v8.js');
|
|
13
|
+
const { v8JsonReport } = require('../reports/v8-json.js');
|
|
14
14
|
|
|
15
15
|
const getWrapperSource = (offset, source) => {
|
|
16
16
|
// NO \n because it break line number in mappings
|
|
@@ -313,68 +313,6 @@ const mergeV8Coverage = async (dataList, sourceCache, options) => {
|
|
|
313
313
|
|
|
314
314
|
// ============================================================
|
|
315
315
|
|
|
316
|
-
const handleV8JsonReport = async (reportData, reportOptions, options) => {
|
|
317
|
-
const v8JsonOptions = {
|
|
318
|
-
outputFile: 'coverage-report.json',
|
|
319
|
-
... reportOptions
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
// console.log(mergedOptions);
|
|
323
|
-
const jsonPath = path.resolve(options.outputDir, v8JsonOptions.outputFile);
|
|
324
|
-
await Util.writeFile(jsonPath, JSON.stringify(reportData));
|
|
325
|
-
return Util.relativePath(jsonPath);
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
const handleV8HtmlReport = async (reportData, reportOptions, options) => {
|
|
330
|
-
|
|
331
|
-
// V8 only options, merged with root options
|
|
332
|
-
const v8HtmlOptions = {
|
|
333
|
-
outputFile: options.outputFile,
|
|
334
|
-
inline: options.inline,
|
|
335
|
-
assetsPath: options.assetsPath,
|
|
336
|
-
metrics: options.metrics,
|
|
337
|
-
... reportOptions
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
// add metrics to data for UI
|
|
341
|
-
reportData.metrics = v8HtmlOptions.metrics;
|
|
342
|
-
|
|
343
|
-
const {
|
|
344
|
-
outputFile, inline, assetsPath
|
|
345
|
-
} = v8HtmlOptions;
|
|
346
|
-
|
|
347
|
-
// resolve full report path
|
|
348
|
-
const reportPath = path.resolve(options.outputDir, outputFile);
|
|
349
|
-
const outputDir = path.dirname(reportPath);
|
|
350
|
-
const htmlFile = path.basename(reportPath);
|
|
351
|
-
|
|
352
|
-
// deps
|
|
353
|
-
const jsFiles = ['monocart-code-viewer', 'monocart-formatter', 'turbogrid'].map((id) => {
|
|
354
|
-
return Util.resolveNodeModule(id);
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
// package app ui
|
|
358
|
-
jsFiles.push(Util.resolvePackage('monocart-coverage-app.js'));
|
|
359
|
-
|
|
360
|
-
// console.log(jsFiles);
|
|
361
|
-
|
|
362
|
-
const htmlOptions = {
|
|
363
|
-
reportData,
|
|
364
|
-
jsFiles,
|
|
365
|
-
inline,
|
|
366
|
-
assetsPath,
|
|
367
|
-
outputDir,
|
|
368
|
-
htmlFile,
|
|
369
|
-
|
|
370
|
-
reportDataFile: 'coverage-data.js'
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
const htmlPath = await Util.saveHtmlReport(htmlOptions);
|
|
374
|
-
|
|
375
|
-
return htmlPath;
|
|
376
|
-
};
|
|
377
|
-
|
|
378
316
|
const saveV8Report = async (v8list, options, istanbulReportPath) => {
|
|
379
317
|
|
|
380
318
|
const defaultWatermarks = {
|
|
@@ -389,8 +327,11 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
|
|
|
389
327
|
const summary = getV8Summary(v8list, watermarks);
|
|
390
328
|
|
|
391
329
|
const reportData = {
|
|
330
|
+
type: 'v8',
|
|
331
|
+
// override with saved file path
|
|
332
|
+
reportPath: '',
|
|
333
|
+
version: Util.version,
|
|
392
334
|
name: options.name,
|
|
393
|
-
version,
|
|
394
335
|
watermarks,
|
|
395
336
|
summary,
|
|
396
337
|
files: v8list
|
|
@@ -398,17 +339,15 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
|
|
|
398
339
|
|
|
399
340
|
// v8 only reports
|
|
400
341
|
const buildInV8Reports = {
|
|
401
|
-
'v8':
|
|
402
|
-
'v8-json':
|
|
342
|
+
'v8': v8Report,
|
|
343
|
+
'v8-json': v8JsonReport
|
|
403
344
|
};
|
|
404
345
|
|
|
405
346
|
const outputs = {};
|
|
406
|
-
const v8Group = options.reportGroup.v8;
|
|
347
|
+
const v8Group = options.reportGroup.get('v8');
|
|
407
348
|
// could be no v8 only reports, but have `both` data reports
|
|
408
349
|
if (v8Group) {
|
|
409
|
-
const
|
|
410
|
-
for (const reportName of v8Reports) {
|
|
411
|
-
const reportOptions = v8Group[reportName];
|
|
350
|
+
for (const [reportName, reportOptions] of v8Group) {
|
|
412
351
|
const buildInHandler = buildInV8Reports[reportName];
|
|
413
352
|
const t1 = Date.now();
|
|
414
353
|
if (buildInHandler) {
|
|
@@ -431,7 +370,9 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
|
|
|
431
370
|
|
|
432
371
|
const coverageResults = {
|
|
433
372
|
type: 'v8',
|
|
373
|
+
// html or json
|
|
434
374
|
reportPath,
|
|
375
|
+
version: Util.version,
|
|
435
376
|
name: options.name,
|
|
436
377
|
watermarks,
|
|
437
378
|
summary,
|