monocart-coverage-reports 2.8.5 → 2.8.6
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 +1 -1
- package/README.zh-Hans.md +1 -1
- package/lib/converter/collect-source-maps.js +15 -22
- package/lib/converter/converter.js +31 -15
- package/lib/converter/find-original-range.js +81 -33
- package/lib/default/template.html +1 -1
- package/lib/generate.js +161 -71
- package/lib/index.js +20 -40
- package/lib/istanbul/istanbul.js +2 -0
- package/lib/packages/monocart-coverage-app.js +1 -1
- package/lib/packages/monocart-coverage-vendor.js +26 -23
- package/lib/platform/share.js +7 -10
- package/lib/utils/util.js +13 -7
- package/lib/v8/v8.js +23 -4
- package/package.json +4 -4
package/lib/platform/share.js
CHANGED
|
@@ -347,12 +347,13 @@ const Util = {
|
|
|
347
347
|
// 2, uncovered entire and pieces
|
|
348
348
|
if (count > 0) {
|
|
349
349
|
lineItem.coveredCount = Math.max(lineItem.coveredCount, count);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (it.entire) {
|
|
354
|
+
lineItem.uncoveredEntire = it;
|
|
350
355
|
} else {
|
|
351
|
-
|
|
352
|
-
lineItem.uncoveredEntire = it;
|
|
353
|
-
} else {
|
|
354
|
-
lineItem.uncoveredPieces.push(it);
|
|
355
|
-
}
|
|
356
|
+
lineItem.uncoveredPieces.push(it);
|
|
356
357
|
}
|
|
357
358
|
|
|
358
359
|
});
|
|
@@ -458,11 +459,7 @@ const Util = {
|
|
|
458
459
|
}
|
|
459
460
|
|
|
460
461
|
if (ms < 60 * 1000) {
|
|
461
|
-
const ss =
|
|
462
|
-
const sms = Math.round((ms - ss * 1000) / 100);
|
|
463
|
-
if (sms) {
|
|
464
|
-
return `${ss}.${sms}${space}s`;
|
|
465
|
-
}
|
|
462
|
+
const ss = parseFloat((ms / 1000).toFixed(1));
|
|
466
463
|
return `${ss}${space}s`;
|
|
467
464
|
}
|
|
468
465
|
|
package/lib/utils/util.js
CHANGED
|
@@ -117,12 +117,6 @@ const Util = {
|
|
|
117
117
|
return url;
|
|
118
118
|
},
|
|
119
119
|
|
|
120
|
-
resolveCacheSourcePath: (cacheDir, id) => {
|
|
121
|
-
const filename = `source-${id}.json`;
|
|
122
|
-
const sourcePath = path.resolve(cacheDir, filename);
|
|
123
|
-
return sourcePath;
|
|
124
|
-
},
|
|
125
|
-
|
|
126
120
|
resolveWatermarks: (defaultWatermarks, watermarks) => {
|
|
127
121
|
if (watermarks) {
|
|
128
122
|
if (Array.isArray(watermarks)) {
|
|
@@ -191,6 +185,15 @@ const Util = {
|
|
|
191
185
|
return path.resolve(__dirname, '../packages', p);
|
|
192
186
|
},
|
|
193
187
|
|
|
188
|
+
getCacheFileInfo: (type, id, cacheDir) => {
|
|
189
|
+
const cacheName = `${type}-${id}.json`;
|
|
190
|
+
const cachePath = path.resolve(cacheDir, cacheName);
|
|
191
|
+
return {
|
|
192
|
+
cacheName,
|
|
193
|
+
cachePath
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
|
|
194
197
|
findUpConfig: (customConfigFile) => {
|
|
195
198
|
if (customConfigFile) {
|
|
196
199
|
if (fs.existsSync(customConfigFile)) {
|
|
@@ -548,6 +551,9 @@ const Util = {
|
|
|
548
551
|
info: 'info',
|
|
549
552
|
debug: 'debug'
|
|
550
553
|
};
|
|
554
|
+
|
|
555
|
+
level = level || process.env.MCR_LOGGING;
|
|
556
|
+
|
|
551
557
|
const type = types[level] || types.info;
|
|
552
558
|
Util.loggingType = type;
|
|
553
559
|
Util.loggingLevel = Util.loggingLevels[type];
|
|
@@ -600,7 +606,7 @@ const Util = {
|
|
|
600
606
|
|
|
601
607
|
// time is debug level, fix the log info, for checking snapshot
|
|
602
608
|
logTime: (message, time_start) => {
|
|
603
|
-
if (Util.loggingLevel < Util.loggingLevels.debug) {
|
|
609
|
+
if (Util.loggingLevel < Util.loggingLevels.debug && !process.env.MCR_LOG_TIME) {
|
|
604
610
|
return;
|
|
605
611
|
}
|
|
606
612
|
const duration = Date.now() - time_start;
|
package/lib/v8/v8.js
CHANGED
|
@@ -65,7 +65,9 @@ const getEntryFilter = (options) => {
|
|
|
65
65
|
return () => true;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const initV8ListAndSourcemap = async (
|
|
68
|
+
const initV8ListAndSourcemap = async (mcr, v8list) => {
|
|
69
|
+
|
|
70
|
+
const { options } = mcr;
|
|
69
71
|
|
|
70
72
|
// entry filter
|
|
71
73
|
const entryFilter = getEntryFilter(options);
|
|
@@ -172,13 +174,28 @@ const initV8ListAndSourcemap = async (v8list, options) => {
|
|
|
172
174
|
|
|
173
175
|
// collect sourcemap first
|
|
174
176
|
const time_start = Date.now();
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
+
const { sourceList, sourcemapList } = await collectSourceMaps(v8list, options);
|
|
178
|
+
if (sourcemapList.length) {
|
|
177
179
|
// debug level time
|
|
178
|
-
Util.logTime(`loaded sourcemaps: ${
|
|
180
|
+
Util.logTime(`loaded sourcemaps: ${sourcemapList.length}`, time_start);
|
|
179
181
|
// console.log(smList);
|
|
180
182
|
}
|
|
181
183
|
|
|
184
|
+
// save source list
|
|
185
|
+
for (const sourceData of sourceList) {
|
|
186
|
+
|
|
187
|
+
const { cacheName, cachePath } = Util.getCacheFileInfo('source', sourceData.id, options.cacheDir);
|
|
188
|
+
mcr.fileCache.set(cacheName, sourceData);
|
|
189
|
+
await Util.writeFile(cachePath, JSON.stringify(sourceData));
|
|
190
|
+
|
|
191
|
+
// save source and sourcemap file for debug
|
|
192
|
+
// https://evanw.github.io/source-map-visualization
|
|
193
|
+
// if (sourceData.sourceMap) {
|
|
194
|
+
// await Util.writeFile(`${sourcePath}.js`, sourceData.source);
|
|
195
|
+
// await Util.writeFile(`${sourcePath}.js.map`, JSON.stringify(sourceData.sourceMap));
|
|
196
|
+
// }
|
|
197
|
+
}
|
|
198
|
+
|
|
182
199
|
return v8list;
|
|
183
200
|
};
|
|
184
201
|
|
|
@@ -391,11 +408,13 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
|
|
|
391
408
|
for (const reportName of v8Reports) {
|
|
392
409
|
const reportOptions = v8Group[reportName];
|
|
393
410
|
const buildInHandler = buildInV8Reports[reportName];
|
|
411
|
+
const t1 = Date.now();
|
|
394
412
|
if (buildInHandler) {
|
|
395
413
|
outputs[reportName] = await buildInHandler(reportData, reportOptions, options);
|
|
396
414
|
} else {
|
|
397
415
|
outputs[reportName] = await Util.runCustomReporter(reportName, reportData, reportOptions, options);
|
|
398
416
|
}
|
|
417
|
+
Util.logTime(`┌ [generate] saved report: ${reportName}`, t1);
|
|
399
418
|
}
|
|
400
419
|
}
|
|
401
420
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-coverage-reports",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.6",
|
|
4
4
|
"description": "A code coverage tool to generate native V8 reports or Istanbul reports.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -88,17 +88,17 @@
|
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"commander": "^12.1.0",
|
|
90
90
|
"esbuild": "^0.21.5",
|
|
91
|
-
"eslint": "~9.
|
|
91
|
+
"eslint": "~9.6.0",
|
|
92
92
|
"eslint-config-plus": "^2.0.2",
|
|
93
93
|
"eslint-plugin-html": "^8.1.1",
|
|
94
94
|
"eslint-plugin-vue": "^9.26.0",
|
|
95
95
|
"find-up": "^7.0.0",
|
|
96
|
-
"minimatch": "^9.0.
|
|
96
|
+
"minimatch": "^9.0.5",
|
|
97
97
|
"starfall-cli": "^2.0.19",
|
|
98
98
|
"stylelint": "^16.6.1",
|
|
99
99
|
"stylelint-config-plus": "^1.1.2",
|
|
100
100
|
"supports-color": "^9.4.0",
|
|
101
|
-
"tsx": "^4.
|
|
101
|
+
"tsx": "^4.16.0",
|
|
102
102
|
"ws": "^8.17.1"
|
|
103
103
|
}
|
|
104
104
|
}
|