monocart-coverage-reports 2.8.4 → 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.
@@ -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
- if (it.entire) {
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 = Math.floor(ms / 1000);
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
 
@@ -247,6 +247,9 @@ const getSnapshot = (reportData) => {
247
247
 
248
248
  addPercent(snapshot.summary, summary);
249
249
 
250
+ files.sort((a, b) => {
251
+ return a.sourcePath - b.sourcePath;
252
+ });
250
253
  files.forEach((file) => {
251
254
  // do NOT add debug file
252
255
  if (file.debug) {
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 (v8list, options) => {
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 smList = await collectSourceMaps(v8list, options);
176
- if (smList.length) {
177
+ const { sourceList, sourcemapList } = await collectSourceMaps(v8list, options);
178
+ if (sourcemapList.length) {
177
179
  // debug level time
178
- Util.logTime(`loaded sourcemaps: ${smList.length}`, time_start);
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.4",
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": {
@@ -25,7 +25,7 @@
25
25
  "types": "./lib/index.d.ts",
26
26
  "scripts": {
27
27
  "build-test": "node ./test/build/build-test.js",
28
- "build": "sf lint && sf b -p && npm run build-test",
28
+ "build": "npx sf lint && npx sf b -p && npm run build-test",
29
29
  "test-unit": "mocha --parallel test/unit/*.test.js",
30
30
  "test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
31
31
  "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
@@ -55,10 +55,10 @@
55
55
  "test-all": "node ./test/test.js && node ./scripts/docs.js",
56
56
  "test": "npm run test-unit && npx mcr npm run test-all -c test/mcr.config.mcr.js",
57
57
  "test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
58
- "dev": "sf d app",
58
+ "dev": "npx sf d app",
59
59
  "open": "node ./scripts/open.js",
60
60
  "eol": "git rm -rf --cached . && git reset --hard HEAD",
61
- "patch": "npm run build && npm run test && sf publish patch -r"
61
+ "patch": "npm run build && npm run test && npx sf publish patch -r"
62
62
  },
63
63
  "workspaces": [
64
64
  "packages/*",
@@ -83,21 +83,22 @@
83
83
  "monocart-code-viewer": "^1.1.4",
84
84
  "monocart-formatter": "^3.0.0",
85
85
  "monocart-locator": "^1.0.0",
86
- "turbogrid": "^3.1.0"
86
+ "turbogrid": "^3.2.0"
87
87
  },
88
88
  "devDependencies": {
89
89
  "commander": "^12.1.0",
90
90
  "esbuild": "^0.21.5",
91
- "eslint": "~9.5.0",
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.4",
96
+ "minimatch": "^9.0.5",
97
+ "starfall-cli": "^2.0.19",
97
98
  "stylelint": "^16.6.1",
98
99
  "stylelint-config-plus": "^1.1.2",
99
100
  "supports-color": "^9.4.0",
100
- "tsx": "^4.15.5",
101
- "ws": "^8.17.0"
101
+ "tsx": "^4.16.0",
102
+ "ws": "^8.17.1"
102
103
  }
103
104
  }