monocart-coverage-reports 2.6.2 → 2.6.3
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 +10 -2
- package/lib/cli.js +54 -33
- package/lib/converter/converter.js +6 -1
- package/lib/generate.js +4 -8
- package/lib/index.d.ts +34 -3
- package/lib/index.js +19 -6
- package/lib/utils/source-path.js +7 -0
- package/lib/v8/v8.js +38 -27
- package/package.json +81 -81
package/README.md
CHANGED
|
@@ -258,16 +258,19 @@ const coverageOptions = {
|
|
|
258
258
|
|
|
259
259
|
## `mcr` CLI
|
|
260
260
|
> The CLI will run the program as a [child process](https://nodejs.org/docs/latest/api/child_process.html) with `NODE_V8_COVERAGE=dir` until it exits gracefully, and generate the coverage report with the coverage data from the `dir`.
|
|
261
|
+
|
|
261
262
|
- Installing globally
|
|
262
263
|
```sh
|
|
263
264
|
npm i monocart-coverage-reports -g
|
|
264
|
-
mcr node ./test/
|
|
265
|
+
mcr node ./test/specs/node.test.js -r v8,console-summary --lcov
|
|
265
266
|
```
|
|
267
|
+
|
|
266
268
|
- Locally in your project
|
|
267
269
|
```sh
|
|
268
270
|
npm i monocart-coverage-reports
|
|
269
|
-
npx mcr node ./test/
|
|
271
|
+
npx mcr node ./test/specs/node.test.js -r v8,console-summary --lcov
|
|
270
272
|
```
|
|
273
|
+
|
|
271
274
|
- CLI Options
|
|
272
275
|
```sh
|
|
273
276
|
Usage: mcr [options] <command>
|
|
@@ -293,17 +296,22 @@ Options:
|
|
|
293
296
|
--logging <logging> off, error, info, debug
|
|
294
297
|
-h, --help display help for command
|
|
295
298
|
```
|
|
299
|
+
|
|
296
300
|
- Loading default configuration file
|
|
297
301
|
- `.mcrrc`
|
|
298
302
|
- `mcr.config.json`
|
|
299
303
|
- `mcr.config.mjs`
|
|
300
304
|
- `mcr.config.cjs`
|
|
301
305
|
- `mcr.config.js`
|
|
306
|
+
- `mcr.config.ts`
|
|
307
|
+
|
|
302
308
|
- Or loading custom configuration file with `-c` or `--config`
|
|
303
309
|
```sh
|
|
304
310
|
mcr node ./test.js -c path-to/my-custom-config.js
|
|
305
311
|
```
|
|
306
312
|
|
|
313
|
+
- Work with `ts-node`, see [mcr-ts-node](https://github.com/cenfun/mcr-ts-node)
|
|
314
|
+
|
|
307
315
|
## Compare Reports
|
|
308
316
|
| | Istanbul | V8 | V8 to Istanbul |
|
|
309
317
|
| :--------------| :------ | :------ | :---------------------- |
|
package/lib/cli.js
CHANGED
|
@@ -17,10 +17,6 @@ const { resolveSourceMap } = require('./converter/collect-source-maps.js');
|
|
|
17
17
|
|
|
18
18
|
const version = require('../package.json').version;
|
|
19
19
|
|
|
20
|
-
const cleanDir = (dir) => {
|
|
21
|
-
Util.rmSync(dir);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
20
|
const resolveConfigPath = (customConfigPath) => {
|
|
25
21
|
|
|
26
22
|
const configList = [
|
|
@@ -28,7 +24,8 @@ const resolveConfigPath = (customConfigPath) => {
|
|
|
28
24
|
'mcr.config.json',
|
|
29
25
|
'mcr.config.mjs',
|
|
30
26
|
'mcr.config.cjs',
|
|
31
|
-
'mcr.config.js'
|
|
27
|
+
'mcr.config.js',
|
|
28
|
+
'mcr.config.ts'
|
|
32
29
|
];
|
|
33
30
|
|
|
34
31
|
if (customConfigPath) {
|
|
@@ -63,8 +60,8 @@ const resolveConfigOptions = async (configPath) => {
|
|
|
63
60
|
err = ee;
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
if (!configOptions) {
|
|
67
|
-
Util.logError(`ERROR: failed to import "${configPath}" ${err.message} `);
|
|
63
|
+
if (err || !configOptions) {
|
|
64
|
+
Util.logError(`ERROR: failed to import "${configPath}": ${err && err.message} `);
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
67
|
|
|
@@ -88,13 +85,9 @@ const initOptions = async (cliOptions) => {
|
|
|
88
85
|
|
|
89
86
|
// report options
|
|
90
87
|
const options = {
|
|
91
|
-
... defaultOptions
|
|
88
|
+
... defaultOptions,
|
|
89
|
+
... cliOptions
|
|
92
90
|
};
|
|
93
|
-
Object.keys(cliOptions).forEach((k) => {
|
|
94
|
-
if (Util.hasOwn(options, k)) {
|
|
95
|
-
options[k] = cliOptions[k];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
91
|
|
|
99
92
|
return options;
|
|
100
93
|
};
|
|
@@ -142,7 +135,7 @@ const resolveEntrySourceMap = (entry, sourceMapCache = {}) => {
|
|
|
142
135
|
}
|
|
143
136
|
};
|
|
144
137
|
|
|
145
|
-
const collectCoverageData = (coverageList,
|
|
138
|
+
const collectCoverageData = (coverageList, entryFilter, sourceMapCache = {}) => {
|
|
146
139
|
|
|
147
140
|
if (!Util.isList(coverageList)) {
|
|
148
141
|
return;
|
|
@@ -150,7 +143,7 @@ const collectCoverageData = (coverageList, entryFilterHandler, sourceMapCache =
|
|
|
150
143
|
|
|
151
144
|
// filter node internal files
|
|
152
145
|
coverageList = coverageList.filter((entry) => entry.url && entry.url.startsWith('file:'));
|
|
153
|
-
coverageList = coverageList.filter(
|
|
146
|
+
coverageList = coverageList.filter(entryFilter);
|
|
154
147
|
|
|
155
148
|
if (!Util.isList(coverageList)) {
|
|
156
149
|
return;
|
|
@@ -164,6 +157,35 @@ const collectCoverageData = (coverageList, entryFilterHandler, sourceMapCache =
|
|
|
164
157
|
return coverageList;
|
|
165
158
|
};
|
|
166
159
|
|
|
160
|
+
const addCoverageData = async (coverageReport, nodeV8CoverageDir) => {
|
|
161
|
+
|
|
162
|
+
let added = false;
|
|
163
|
+
|
|
164
|
+
const files = fs.readdirSync(nodeV8CoverageDir);
|
|
165
|
+
if (!files.length) {
|
|
166
|
+
return added;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// filter before adding
|
|
170
|
+
const entryFilter = coverageReport.getEntryFilter();
|
|
171
|
+
for (const filename of files) {
|
|
172
|
+
const filePath = path.resolve(nodeV8CoverageDir, filename);
|
|
173
|
+
const content = fs.readFileSync(filePath).toString('utf-8');
|
|
174
|
+
if (content) {
|
|
175
|
+
const json = JSON.parse(content);
|
|
176
|
+
const coverageList = json.result;
|
|
177
|
+
const sourceMapCache = json['source-map-cache'];
|
|
178
|
+
const coverageData = collectCoverageData(coverageList, entryFilter, sourceMapCache);
|
|
179
|
+
if (coverageData) {
|
|
180
|
+
await coverageReport.add(coverageData);
|
|
181
|
+
added = true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return added;
|
|
187
|
+
};
|
|
188
|
+
|
|
167
189
|
const executeCommand = async (command, cliOptions) => {
|
|
168
190
|
|
|
169
191
|
const options = await initOptions(cliOptions);
|
|
@@ -174,20 +196,23 @@ const executeCommand = async (command, cliOptions) => {
|
|
|
174
196
|
const nodeV8CoverageDir = path.resolve(options.outputDir, '.v8-coverage');
|
|
175
197
|
process.env.NODE_V8_COVERAGE = nodeV8CoverageDir;
|
|
176
198
|
|
|
177
|
-
|
|
199
|
+
// clean v8 cache before running
|
|
200
|
+
Util.rmSync(nodeV8CoverageDir);
|
|
178
201
|
|
|
179
202
|
// console.log('nodeV8CoverageDir', nodeV8CoverageDir);
|
|
180
203
|
|
|
181
204
|
const coverageReport = MCR(options);
|
|
182
205
|
coverageReport.cleanCache();
|
|
183
206
|
|
|
184
|
-
//
|
|
185
|
-
|
|
207
|
+
// =========================================
|
|
208
|
+
// onStart hook
|
|
209
|
+
const onStart = options.onStart;
|
|
186
210
|
if (typeof onStart === 'function') {
|
|
187
211
|
await onStart(coverageReport);
|
|
188
212
|
}
|
|
213
|
+
// =========================================
|
|
189
214
|
|
|
190
|
-
foregroundChild(command, {
|
|
215
|
+
const subprocess = foregroundChild(command, {
|
|
191
216
|
shell: true
|
|
192
217
|
}, async () => {
|
|
193
218
|
|
|
@@ -196,25 +221,21 @@ const executeCommand = async (command, cliOptions) => {
|
|
|
196
221
|
return 1;
|
|
197
222
|
}
|
|
198
223
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const coverageList = json.result;
|
|
206
|
-
const sourceMapCache = json['source-map-cache'];
|
|
207
|
-
const coverageData = await collectCoverageData(coverageList, entryFilterHandler, sourceMapCache);
|
|
208
|
-
if (coverageData) {
|
|
209
|
-
await coverageReport.add(coverageData);
|
|
210
|
-
}
|
|
224
|
+
// =========================================
|
|
225
|
+
// onReady hook before adding coverage data.
|
|
226
|
+
// Sometimes, the child process has not yet finished writing the coverage data, and it needs to wait here.
|
|
227
|
+
const onReady = options.onReady;
|
|
228
|
+
if (typeof onReady === 'function') {
|
|
229
|
+
await onReady(coverageReport, nodeV8CoverageDir, subprocess);
|
|
211
230
|
}
|
|
231
|
+
// =========================================
|
|
212
232
|
|
|
233
|
+
await addCoverageData(coverageReport, nodeV8CoverageDir);
|
|
213
234
|
await coverageReport.generate();
|
|
214
235
|
|
|
215
236
|
// remove nodeV8CoverageDir
|
|
216
|
-
if (
|
|
217
|
-
|
|
237
|
+
if (!Util.isDebug()) {
|
|
238
|
+
Util.rmSync(nodeV8CoverageDir);
|
|
218
239
|
}
|
|
219
240
|
|
|
220
241
|
return process.exitCode;
|
|
@@ -369,7 +369,8 @@ const addJsBytesCoverage = (state, range) => {
|
|
|
369
369
|
// add bytes range
|
|
370
370
|
const byte = {
|
|
371
371
|
start: startOffset,
|
|
372
|
-
end
|
|
372
|
+
// the end could be > source.length
|
|
373
|
+
end: Math.min(endOffset, state.maxContentLength),
|
|
373
374
|
count
|
|
374
375
|
};
|
|
375
376
|
// for debug
|
|
@@ -982,6 +983,7 @@ const initOriginalList = (state, originalDecodedMap, options) => {
|
|
|
982
983
|
}
|
|
983
984
|
|
|
984
985
|
const locator = new Locator(sourceContent);
|
|
986
|
+
const maxContentLength = sourceContent.length;
|
|
985
987
|
|
|
986
988
|
const decodedMappings = getOriginalDecodedMappings(originalDecodedMap, sourceIndex, locator);
|
|
987
989
|
|
|
@@ -997,6 +999,7 @@ const initOriginalList = (state, originalDecodedMap, options) => {
|
|
|
997
999
|
source: sourceContent,
|
|
998
1000
|
sourcePath,
|
|
999
1001
|
locator,
|
|
1002
|
+
maxContentLength,
|
|
1000
1003
|
decodedMappings,
|
|
1001
1004
|
// coverage info
|
|
1002
1005
|
bytes: [],
|
|
@@ -1411,6 +1414,7 @@ const convertV8List = (v8list, options) => {
|
|
|
1411
1414
|
|
|
1412
1415
|
// source mapping
|
|
1413
1416
|
const locator = new Locator(source);
|
|
1417
|
+
const maxContentLength = source.length;
|
|
1414
1418
|
|
|
1415
1419
|
// ============================
|
|
1416
1420
|
// move sourceMap
|
|
@@ -1453,6 +1457,7 @@ const convertV8List = (v8list, options) => {
|
|
|
1453
1457
|
sourcePath,
|
|
1454
1458
|
sourceMap,
|
|
1455
1459
|
locator,
|
|
1460
|
+
maxContentLength,
|
|
1456
1461
|
decodedMappings: [],
|
|
1457
1462
|
// coverage info
|
|
1458
1463
|
bytes: [],
|
package/lib/generate.js
CHANGED
|
@@ -21,20 +21,16 @@ const { getGroupedRows } = require('./utils/snapshot.js');
|
|
|
21
21
|
// maybe v8 or to istanbul reports
|
|
22
22
|
const generateV8ListReports = async (v8list, coverageData, fileSources, options) => {
|
|
23
23
|
|
|
24
|
-
let
|
|
24
|
+
let istanbulReportPath;
|
|
25
25
|
// v8 to istanbul reports
|
|
26
26
|
if (options.reportGroup.istanbul) {
|
|
27
|
-
istanbulCoverageResults = await saveIstanbulReports(coverageData, fileSources, options);
|
|
27
|
+
const istanbulCoverageResults = await saveIstanbulReports(coverageData, fileSources, options);
|
|
28
|
+
istanbulReportPath = istanbulCoverageResults.reportPath;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
// v8 reports and v8 coverage results
|
|
31
32
|
// could be no v8 or v8-json, but requires v8 coverage results
|
|
32
|
-
const v8CoverageResults = await saveV8Report(v8list, options);
|
|
33
|
-
|
|
34
|
-
// fix reportPath
|
|
35
|
-
if (!v8CoverageResults.reportPath && istanbulCoverageResults) {
|
|
36
|
-
v8CoverageResults.reportPath = istanbulCoverageResults.reportPath;
|
|
37
|
-
}
|
|
33
|
+
const v8CoverageResults = await saveV8Report(v8list, options, istanbulReportPath);
|
|
38
34
|
|
|
39
35
|
return v8CoverageResults;
|
|
40
36
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -2,16 +2,35 @@ declare namespace MCR {
|
|
|
2
2
|
|
|
3
3
|
export interface V8CoverageEntry {
|
|
4
4
|
url: string;
|
|
5
|
+
|
|
6
|
+
/** entry type */
|
|
7
|
+
type?: "js" | "css";
|
|
8
|
+
|
|
5
9
|
/** css only */
|
|
6
10
|
text?: string;
|
|
7
11
|
/** css only */
|
|
8
12
|
ranges?: any[];
|
|
9
|
-
|
|
10
|
-
scriptId?: string;
|
|
13
|
+
|
|
11
14
|
/** js only */
|
|
12
15
|
source?: string;
|
|
13
16
|
/** js only */
|
|
17
|
+
scriptId?: string;
|
|
18
|
+
/** js only */
|
|
14
19
|
functions?: any[];
|
|
20
|
+
|
|
21
|
+
/** js only */
|
|
22
|
+
sourceMap?: any;
|
|
23
|
+
/** js only */
|
|
24
|
+
scriptOffset?: number;
|
|
25
|
+
/** js only */
|
|
26
|
+
distFile?: string;
|
|
27
|
+
|
|
28
|
+
/** empty coverage */
|
|
29
|
+
empty?: boolean;
|
|
30
|
+
/** fake source */
|
|
31
|
+
fake?: boolean;
|
|
32
|
+
|
|
33
|
+
[key: string]: any;
|
|
15
34
|
}
|
|
16
35
|
|
|
17
36
|
export type Watermarks = [number, number] | {
|
|
@@ -290,13 +309,25 @@ declare namespace MCR {
|
|
|
290
309
|
*/
|
|
291
310
|
cleanCache?: boolean;
|
|
292
311
|
|
|
312
|
+
/** (V8 only) {function} onEntry hook */
|
|
313
|
+
onEntry?: (entry: V8CoverageEntry) => Promise<void>;
|
|
314
|
+
|
|
293
315
|
/** {function} onEnd hook */
|
|
294
316
|
onEnd?: (coverageResults: CoverageResults) => Promise<void>;
|
|
317
|
+
|
|
295
318
|
}
|
|
296
319
|
|
|
297
320
|
export interface McrCliOptions extends CoverageReportOptions {
|
|
298
|
-
|
|
321
|
+
|
|
322
|
+
/** (cli only) {function} onStart hook */
|
|
299
323
|
onStart?: (coverageReport: CoverageReport) => Promise<void>;
|
|
324
|
+
|
|
325
|
+
/** (cli only) {function} onReady hook before adding coverage data.
|
|
326
|
+
*
|
|
327
|
+
* Sometimes, the child process has not yet finished writing the coverage data, and it needs to wait here.
|
|
328
|
+
*/
|
|
329
|
+
onReady?: (coverageReport: CoverageReport, nodeV8CoverageDir: string, subprocess: any) => Promise<void>;
|
|
330
|
+
|
|
300
331
|
}
|
|
301
332
|
|
|
302
333
|
export class CoverageReport {
|
package/lib/index.js
CHANGED
|
@@ -125,12 +125,7 @@ class CoverageReport {
|
|
|
125
125
|
if (fs.existsSync(outputDir)) {
|
|
126
126
|
// if assets dir is out of output dir will be ignore
|
|
127
127
|
if (this.options.clean) {
|
|
128
|
-
|
|
129
|
-
if (itemName === this.cacheDirName) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
Util.rmSync(path.resolve(outputDir, itemName));
|
|
133
|
-
});
|
|
128
|
+
this.cleanFiles();
|
|
134
129
|
}
|
|
135
130
|
} else {
|
|
136
131
|
fs.mkdirSync(outputDir, {
|
|
@@ -170,6 +165,24 @@ class CoverageReport {
|
|
|
170
165
|
return false;
|
|
171
166
|
}
|
|
172
167
|
|
|
168
|
+
cleanFiles() {
|
|
169
|
+
const outputDir = this.options.outputDir;
|
|
170
|
+
let v8DirName;
|
|
171
|
+
const nodeV8CoverageDir = process.env.NODE_V8_COVERAGE;
|
|
172
|
+
if (nodeV8CoverageDir) {
|
|
173
|
+
v8DirName = path.relative(outputDir, nodeV8CoverageDir);
|
|
174
|
+
}
|
|
175
|
+
fs.readdirSync(outputDir).forEach((itemName) => {
|
|
176
|
+
if (itemName === this.cacheDirName) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (itemName === v8DirName) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
Util.rmSync(path.resolve(outputDir, itemName));
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
173
186
|
getEntryFilter() {
|
|
174
187
|
return getEntryFilter(this.options);
|
|
175
188
|
}
|
package/lib/utils/source-path.js
CHANGED
|
@@ -154,6 +154,13 @@ const initSourceMapSourcePath = (sourceMap, fileUrls, sourcePathHandler) => {
|
|
|
154
154
|
sourceMap.sourceRoot = '';
|
|
155
155
|
|
|
156
156
|
sourceMap.sources = sourceMap.sources.map((sourceName, i) => {
|
|
157
|
+
|
|
158
|
+
// the sourceName could be absolute path
|
|
159
|
+
// c:\\workspace\test\\selenium.spec.js
|
|
160
|
+
// console.log(sourceName);
|
|
161
|
+
sourceName = Util.formatPath(sourceName);
|
|
162
|
+
// console.log(sourceName);
|
|
163
|
+
|
|
157
164
|
const sourceUrl = mergeSourceRoot(sourceRoot, sourceName);
|
|
158
165
|
|
|
159
166
|
let sourcePath = getSourcePath(sourceUrl, i + 1);
|
package/lib/v8/v8.js
CHANGED
|
@@ -62,75 +62,82 @@ const initV8ListAndSourcemap = async (v8list, options) => {
|
|
|
62
62
|
// filter no source or text
|
|
63
63
|
// init type and css source from text
|
|
64
64
|
// keep functions
|
|
65
|
-
v8list = v8list.filter((
|
|
65
|
+
v8list = v8list.filter((entry) => {
|
|
66
66
|
|
|
67
67
|
// filter entry
|
|
68
|
-
if (!entryFilter(
|
|
69
|
-
// console.log('-',
|
|
68
|
+
if (!entryFilter(entry)) {
|
|
69
|
+
// console.log('-', entry.url);
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
|
-
// console.log(
|
|
72
|
+
// console.log(entry.url);
|
|
73
73
|
|
|
74
|
-
if (typeof
|
|
75
|
-
|
|
74
|
+
if (typeof entry.source === 'string' && entry.functions) {
|
|
75
|
+
entry.type = 'js';
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
|
-
if (typeof
|
|
79
|
-
|
|
78
|
+
if (typeof entry.text === 'string' && entry.ranges) {
|
|
79
|
+
entry.type = 'css';
|
|
80
80
|
return true;
|
|
81
81
|
}
|
|
82
82
|
// allow empty coverage
|
|
83
|
-
if (
|
|
84
|
-
if (!['js', 'css'].includes(
|
|
85
|
-
|
|
83
|
+
if (entry.empty) {
|
|
84
|
+
if (!['js', 'css'].includes(entry.type)) {
|
|
85
|
+
entry.type = 'js';
|
|
86
86
|
}
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
89
|
// 404 css, text will be empty
|
|
90
|
-
// Util.logError(`Invalid source: ${
|
|
91
|
-
// console.log(
|
|
90
|
+
// Util.logError(`Invalid source: ${entry.url}`);
|
|
91
|
+
// console.log(entry);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
//
|
|
95
|
+
// onEntry hook
|
|
96
|
+
// after filter but before init, because id depends source and sourcePath
|
|
97
|
+
const onEntry = options.onEntry;
|
|
98
|
+
if (typeof onEntry === 'function') {
|
|
99
|
+
for (const entry of v8list) {
|
|
100
|
+
await onEntry(entry);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
96
103
|
|
|
97
104
|
const sourcePathHandler = getSourcePathHandler(options);
|
|
98
105
|
|
|
99
106
|
// init id, sourcePath
|
|
100
|
-
v8list = v8list.map((
|
|
107
|
+
v8list = v8list.map((entry, i) => {
|
|
101
108
|
|
|
102
109
|
// it could be a empty file
|
|
103
|
-
let source = `${
|
|
110
|
+
let source = `${entry.source || entry.text || ''}`;
|
|
104
111
|
|
|
105
112
|
// fix source with script offset
|
|
106
113
|
let scriptOffset;
|
|
107
|
-
const offset = Util.toNum(
|
|
114
|
+
const offset = Util.toNum(entry.scriptOffset, true);
|
|
108
115
|
if (offset > 0) {
|
|
109
116
|
scriptOffset = offset;
|
|
110
117
|
source = getWrapperSource(offset, source);
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
const data = {
|
|
114
|
-
url:
|
|
115
|
-
type:
|
|
121
|
+
url: entry.url,
|
|
122
|
+
type: entry.type,
|
|
116
123
|
source,
|
|
117
124
|
// script offset >= 0, for vm script
|
|
118
125
|
scriptOffset,
|
|
119
126
|
// Manually Resolve the Sourcemap
|
|
120
|
-
sourceMap:
|
|
127
|
+
sourceMap: entry.sourceMap,
|
|
121
128
|
// fake source with `lineLengths`
|
|
122
|
-
fake:
|
|
129
|
+
fake: entry.fake,
|
|
123
130
|
// empty coverage
|
|
124
|
-
empty:
|
|
131
|
+
empty: entry.empty,
|
|
125
132
|
// match source if using empty coverage
|
|
126
|
-
distFile:
|
|
133
|
+
distFile: entry.distFile
|
|
127
134
|
};
|
|
128
135
|
|
|
129
136
|
// coverage
|
|
130
137
|
if (data.type === 'js') {
|
|
131
|
-
data.functions =
|
|
138
|
+
data.functions = entry.functions;
|
|
132
139
|
} else {
|
|
133
|
-
data.ranges =
|
|
140
|
+
data.ranges = entry.ranges;
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
// resolve source path
|
|
@@ -335,7 +342,7 @@ const handleV8HtmlReport = async (reportData, reportOptions, options) => {
|
|
|
335
342
|
return htmlPath;
|
|
336
343
|
};
|
|
337
344
|
|
|
338
|
-
const saveV8Report = async (v8list, options) => {
|
|
345
|
+
const saveV8Report = async (v8list, options, istanbulReportPath) => {
|
|
339
346
|
|
|
340
347
|
const defaultWatermarks = {
|
|
341
348
|
bytes: [50, 80],
|
|
@@ -378,9 +385,13 @@ const saveV8Report = async (v8list, options) => {
|
|
|
378
385
|
}
|
|
379
386
|
}
|
|
380
387
|
|
|
388
|
+
if (istanbulReportPath) {
|
|
389
|
+
outputs.istanbul = istanbulReportPath;
|
|
390
|
+
}
|
|
391
|
+
|
|
381
392
|
// outputPath, should be html or json
|
|
382
393
|
const reportPath = Util.resolveReportPath(options, () => {
|
|
383
|
-
return outputs.v8 || outputs
|
|
394
|
+
return outputs.v8 || outputs.istanbul || Object.values(outputs).filter((it) => it && typeof it === 'string').shift();
|
|
384
395
|
});
|
|
385
396
|
|
|
386
397
|
const coverageResults = {
|
package/package.json
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "monocart-coverage-reports",
|
|
3
|
-
"version": "2.6.
|
|
4
|
-
"description": "Monocart coverage reports",
|
|
5
|
-
"main": "./lib/index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"mcr": "./lib/cli.js"
|
|
8
|
-
},
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./lib/index.d.ts",
|
|
12
|
-
"import": "./lib/index.mjs",
|
|
13
|
-
"require": "./lib/index.js",
|
|
14
|
-
"default": "./lib/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./package.json": "./package.json"
|
|
17
|
-
},
|
|
18
|
-
"types": "./lib/index.d.ts",
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build-docs": "node ./scripts/build-docs.js",
|
|
21
|
-
"build-test": "node ./scripts/build-test.js",
|
|
22
|
-
"build": "sf lint && sf b -p && npm run build-test",
|
|
23
|
-
"test-node": "npm run test-node-env && npm run test-node-api && npm run test-node-ins && npm run test-node-cdp && npm run test-node-koa && npm run test-node-vm",
|
|
24
|
-
"test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
|
|
25
|
-
"test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
|
|
26
|
-
"test-node-fgc": "node ./test/test-node-fgc.js",
|
|
27
|
-
"test-node-ins": "node ./test/test-node-ins.js",
|
|
28
|
-
"test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
|
|
29
|
-
"test-node-koa": "node ./test/test-node-koa.js",
|
|
30
|
-
"test-node-vm": "node ./test/test-node-vm.js",
|
|
31
|
-
"test-istanbul": "node ./test/test-istanbul.js",
|
|
32
|
-
"test-v8": "node ./test/test-v8.js",
|
|
33
|
-
"test-puppeteer": "node ./test/test-puppeteer.js",
|
|
34
|
-
"test-browser": "node ./test/test-browser.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
|
|
35
|
-
"test-anonymous": "node ./test/test-anonymous.js",
|
|
36
|
-
"test-css": "node ./test/test-css.js",
|
|
37
|
-
"test-cli": "npx mcr node ./test/
|
|
38
|
-
"test-merge": "node ./test/test-merge.js",
|
|
39
|
-
"test-merge-istanbul": "node ./test/test-merge-istanbul.js",
|
|
40
|
-
"test-all": "npm run test-browser && npm run test-node && npm run test-cli && npm run test-merge && npm run build-docs",
|
|
41
|
-
"test": "npx mcr npm run test-all -c test/mcr
|
|
42
|
-
"test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
|
|
43
|
-
"dev": "sf d v8",
|
|
44
|
-
"open": "node ./scripts/open.js",
|
|
45
|
-
"patch": "npm run build && sf publish patch -r"
|
|
46
|
-
},
|
|
47
|
-
"workspaces": [
|
|
48
|
-
"packages/*",
|
|
49
|
-
"test"
|
|
50
|
-
],
|
|
51
|
-
"files": [
|
|
52
|
-
"lib"
|
|
53
|
-
],
|
|
54
|
-
"license": "MIT",
|
|
55
|
-
"repository": {
|
|
56
|
-
"type": "git",
|
|
57
|
-
"url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
|
|
58
|
-
},
|
|
59
|
-
"dependencies": {
|
|
60
|
-
"console-grid": "~2.2.2",
|
|
61
|
-
"eight-colors": "~1.3.0",
|
|
62
|
-
"istanbul-lib-coverage": "~3.2.2",
|
|
63
|
-
"istanbul-lib-report": "~3.0.1",
|
|
64
|
-
"istanbul-reports": "~3.1.7",
|
|
65
|
-
"lz-utils": "~2.0.2",
|
|
66
|
-
"monocart-code-viewer": "~1.1.1",
|
|
67
|
-
"monocart-formatter": "~2.3.2",
|
|
68
|
-
"turbogrid": "~3.0.13"
|
|
69
|
-
},
|
|
70
|
-
"devDependencies": {
|
|
71
|
-
"commander": "^12.0.0",
|
|
72
|
-
"eslint": "^8.57.0",
|
|
73
|
-
"eslint-config-plus": "^1.0.6",
|
|
74
|
-
"eslint-plugin-html": "^8.0.0",
|
|
75
|
-
"eslint-plugin-vue": "^9.22.0",
|
|
76
|
-
"minimatch": "^9.0.3",
|
|
77
|
-
"stylelint": "^15.11.0",
|
|
78
|
-
"stylelint-config-plus": "^1.0.4",
|
|
79
|
-
"supports-color": "^9.4.0"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "monocart-coverage-reports",
|
|
3
|
+
"version": "2.6.3",
|
|
4
|
+
"description": "Monocart coverage reports",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mcr": "./lib/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"import": "./lib/index.mjs",
|
|
13
|
+
"require": "./lib/index.js",
|
|
14
|
+
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build-docs": "node ./scripts/build-docs.js",
|
|
21
|
+
"build-test": "node ./scripts/build-test.js",
|
|
22
|
+
"build": "sf lint && sf b -p && npm run build-test",
|
|
23
|
+
"test-node": "npm run test-node-env && npm run test-node-api && npm run test-node-ins && npm run test-node-cdp && npm run test-node-koa && npm run test-node-vm",
|
|
24
|
+
"test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
|
|
25
|
+
"test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
|
|
26
|
+
"test-node-fgc": "node ./test/test-node-fgc.js",
|
|
27
|
+
"test-node-ins": "node ./test/test-node-ins.js",
|
|
28
|
+
"test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
|
|
29
|
+
"test-node-koa": "node ./test/test-node-koa.js",
|
|
30
|
+
"test-node-vm": "node ./test/test-node-vm.js",
|
|
31
|
+
"test-istanbul": "node ./test/test-istanbul.js",
|
|
32
|
+
"test-v8": "node ./test/test-v8.js",
|
|
33
|
+
"test-puppeteer": "node ./test/test-puppeteer.js",
|
|
34
|
+
"test-browser": "node ./test/test-browser.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
|
|
35
|
+
"test-anonymous": "node ./test/test-anonymous.js",
|
|
36
|
+
"test-css": "node ./test/test-css.js",
|
|
37
|
+
"test-cli": "npx mcr node ./test/specs/node.test.js -o docs/cli -c test/mcr.config.cli.js",
|
|
38
|
+
"test-merge": "node ./test/test-merge.js",
|
|
39
|
+
"test-merge-istanbul": "node ./test/test-merge-istanbul.js",
|
|
40
|
+
"test-all": "npm run test-browser && npm run test-node && npm run test-cli && npm run test-merge && npm run build-docs",
|
|
41
|
+
"test": "npx mcr npm run test-all -c test/mcr.config.mcr.js",
|
|
42
|
+
"test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
|
|
43
|
+
"dev": "sf d v8",
|
|
44
|
+
"open": "node ./scripts/open.js",
|
|
45
|
+
"patch": "npm run build && sf publish patch -r"
|
|
46
|
+
},
|
|
47
|
+
"workspaces": [
|
|
48
|
+
"packages/*",
|
|
49
|
+
"test"
|
|
50
|
+
],
|
|
51
|
+
"files": [
|
|
52
|
+
"lib"
|
|
53
|
+
],
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"console-grid": "~2.2.2",
|
|
61
|
+
"eight-colors": "~1.3.0",
|
|
62
|
+
"istanbul-lib-coverage": "~3.2.2",
|
|
63
|
+
"istanbul-lib-report": "~3.0.1",
|
|
64
|
+
"istanbul-reports": "~3.1.7",
|
|
65
|
+
"lz-utils": "~2.0.2",
|
|
66
|
+
"monocart-code-viewer": "~1.1.1",
|
|
67
|
+
"monocart-formatter": "~2.3.2",
|
|
68
|
+
"turbogrid": "~3.0.13"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"commander": "^12.0.0",
|
|
72
|
+
"eslint": "^8.57.0",
|
|
73
|
+
"eslint-config-plus": "^1.0.6",
|
|
74
|
+
"eslint-plugin-html": "^8.0.0",
|
|
75
|
+
"eslint-plugin-vue": "^9.22.0",
|
|
76
|
+
"minimatch": "^9.0.3",
|
|
77
|
+
"stylelint": "^15.11.0",
|
|
78
|
+
"stylelint-config-plus": "^1.0.4",
|
|
79
|
+
"supports-color": "^9.4.0"
|
|
80
|
+
}
|
|
81
|
+
}
|