monocart-coverage-reports 2.9.3 → 2.10.1

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/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,11 @@ 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 version = require('../../package.json').version;
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
+ const { customReport } = require('../reports/custom.js');
14
15
 
15
16
  const getWrapperSource = (offset, source) => {
16
17
  // NO \n because it break line number in mappings
@@ -313,68 +314,6 @@ const mergeV8Coverage = async (dataList, sourceCache, options) => {
313
314
 
314
315
  // ============================================================
315
316
 
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
317
  const saveV8Report = async (v8list, options, istanbulReportPath) => {
379
318
 
380
319
  const defaultWatermarks = {
@@ -389,8 +328,11 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
389
328
  const summary = getV8Summary(v8list, watermarks);
390
329
 
391
330
  const reportData = {
331
+ type: 'v8',
332
+ // override with saved file path
333
+ reportPath: '',
334
+ version: Util.version,
392
335
  name: options.name,
393
- version,
394
336
  watermarks,
395
337
  summary,
396
338
  files: v8list
@@ -398,23 +340,21 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
398
340
 
399
341
  // v8 only reports
400
342
  const buildInV8Reports = {
401
- 'v8': handleV8HtmlReport,
402
- 'v8-json': handleV8JsonReport
343
+ 'v8': v8Report,
344
+ 'v8-json': v8JsonReport
403
345
  };
404
346
 
405
347
  const outputs = {};
406
- const v8Group = options.reportGroup.v8;
348
+ const v8Group = options.reportGroup.get('v8');
407
349
  // could be no v8 only reports, but have `both` data reports
408
350
  if (v8Group) {
409
- const v8Reports = Object.keys(v8Group);
410
- for (const reportName of v8Reports) {
411
- const reportOptions = v8Group[reportName];
351
+ for (const [reportName, reportOptions] of v8Group) {
412
352
  const buildInHandler = buildInV8Reports[reportName];
413
353
  const t1 = Date.now();
414
354
  if (buildInHandler) {
415
355
  outputs[reportName] = await buildInHandler(reportData, reportOptions, options);
416
356
  } else {
417
- outputs[reportName] = await Util.runCustomReporter(reportName, reportData, reportOptions, options);
357
+ outputs[reportName] = await customReport(reportName, reportData, reportOptions, options);
418
358
  }
419
359
  Util.logTime(`┌ [generate] saved report: ${reportName}`, t1);
420
360
  }
@@ -431,7 +371,9 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
431
371
 
432
372
  const coverageResults = {
433
373
  type: 'v8',
374
+ // html or json
434
375
  reportPath,
376
+ version: Util.version,
435
377
  name: options.name,
436
378
  watermarks,
437
379
  summary,
package/package.json CHANGED
@@ -1,112 +1,116 @@
1
- {
2
- "name": "monocart-coverage-reports",
3
- "version": "2.9.3",
4
- "description": "A code coverage tool to generate native V8 reports or Istanbul 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
- "./register": {
17
- "import": "./lib/register/register.mjs",
18
- "require": "./lib/register/register.js",
19
- "default": "./lib/register/register.js"
20
- },
21
- "./converter": "./lib/converter/converter.js",
22
- "./util": "./lib/utils/util.js",
23
- "./package.json": "./package.json"
24
- },
25
- "types": "./lib/index.d.ts",
26
- "scripts": {
27
- "build-test": "node ./test/build/build-test.js",
28
- "build": "npx sf lint && npx sf b -p && npm run build-test",
29
- "test-unit": "mocha --parallel test/unit/*.test.js",
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
- "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
32
- "test-node-ins": "node ./test/test-node-ins.js",
33
- "test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
34
- "test-node-vm": "node ./test/test-node-vm.js",
35
- "test-node-koa": "node ./test/test-node-koa.js",
36
- "test-node-fgc": "node ./test/test-node-fgc.js",
37
- "test-node": "node ./test/test.js --node",
38
- "test-istanbul": "node ./test/test-istanbul.js",
39
- "test-v8": "node ./test/test-v8.js",
40
- "test-puppeteer": "node ./test/test-puppeteer.js",
41
- "test-anonymous": "node ./test/test-anonymous.js",
42
- "test-css": "node ./test/test-css.js",
43
- "test-minify": "node ./test/test-minify.js",
44
- "test-esbuild": "node ./test/test-esbuild.js",
45
- "test-rollup": "node ./test/test-rollup.js",
46
- "test-sections": "node ./test/test-sections.js",
47
- "test-swc": "node ./test/test-swc.js",
48
- "test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
49
- "test-browser": "node ./test/test.js --browser",
50
- "test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
51
- "test-tsx": "npx mcr tsx ./test/specs/tsx.test.ts -c test/mcr.config.tsx.js",
52
- "test-demo": "node ./test/test-demo.js",
53
- "test-merge": "node ./test/test-merge.js",
54
- "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
55
- "test-client": "node ./test/test-client.js",
56
- "test-all": "node ./test/test.js && node ./scripts/docs.js",
57
- "test": "npm run test-unit && npx mcr npm run test-all -c test/mcr.config.mcr.js",
58
- "test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
59
- "dev": "npx sf d app",
60
- "open": "node ./scripts/open.js",
61
- "eol": "git rm -rf --cached . && git reset --hard HEAD",
62
- "patch": "npm run build && npm run test && npx sf publish patch -r"
63
- },
64
- "workspaces": [
65
- "packages/*",
66
- "test"
67
- ],
68
- "files": [
69
- "lib",
70
- "README.zh-Hans.md"
71
- ],
72
- "license": "MIT",
73
- "repository": {
74
- "type": "git",
75
- "url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
76
- },
77
- "dependencies": {
78
- "@bcoe/v8-coverage": "^0.2.3",
79
- "@jridgewell/sourcemap-codec": "^1.5.0",
80
- "acorn": "^8.12.1",
81
- "acorn-loose": "^8.4.0",
82
- "acorn-walk": "^8.3.3",
83
- "commander": "^12.1.0",
84
- "console-grid": "^2.2.2",
85
- "diff-sequences": "^29.6.3",
86
- "eight-colors": "^1.3.0",
87
- "foreground-child": "^3.2.1",
88
- "istanbul-lib-coverage": "^3.2.2",
89
- "istanbul-lib-report": "^3.0.1",
90
- "istanbul-reports": "^3.1.7",
91
- "lz-utils": "^2.0.2",
92
- "minimatch": "9.0.5",
93
- "monocart-code-viewer": "^1.1.4",
94
- "monocart-formatter": "^3.0.0",
95
- "monocart-locator": "^1.0.2",
96
- "turbogrid": "^3.2.0"
97
- },
98
- "devDependencies": {
99
- "esbuild": "^0.23.0",
100
- "eslint": "~9.7.0",
101
- "eslint-config-plus": "^2.0.2",
102
- "eslint-plugin-html": "^8.1.1",
103
- "eslint-plugin-vue": "^9.27.0",
104
- "find-up": "^7.0.0",
105
- "starfall-cli": "^2.0.20",
106
- "stylelint": "^16.7.0",
107
- "stylelint-config-plus": "^1.1.2",
108
- "supports-color": "^9.4.0",
109
- "tsx": "^4.16.2",
110
- "ws": "^8.18.0"
111
- }
112
- }
1
+ {
2
+ "name": "monocart-coverage-reports",
3
+ "version": "2.10.1",
4
+ "description": "A code coverage tool to generate native V8 reports or Istanbul 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
+ "./register": {
17
+ "import": "./lib/register/register.mjs",
18
+ "require": "./lib/register/register.js",
19
+ "default": "./lib/register/register.js"
20
+ },
21
+ "./converter": "./lib/converter/converter.js",
22
+ "./util": "./lib/utils/util.js",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "types": "./lib/index.d.ts",
26
+ "scripts": {
27
+ "build-test": "node ./test/build/build-test.js",
28
+ "build": "npx sf lint && npx sf b -p && npm run build-test",
29
+ "test-unit": "mocha --parallel test/unit/*.test.js",
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
+ "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
32
+ "test-node-ins": "node ./test/test-node-ins.js",
33
+ "test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
34
+ "test-node-vm": "node ./test/test-node-vm.js",
35
+ "test-node-koa": "node ./test/test-node-koa.js",
36
+ "test-node-fgc": "node ./test/test-node-fgc.js",
37
+ "test-node": "node ./test/test.js --node",
38
+ "test-istanbul": "node ./test/test-istanbul.js",
39
+ "test-v8": "node ./test/test-v8.js",
40
+ "test-puppeteer": "node ./test/test-puppeteer.js",
41
+ "test-anonymous": "node ./test/test-anonymous.js",
42
+ "test-css": "node ./test/test-css.js",
43
+ "test-minify": "node ./test/test-minify.js",
44
+ "test-esbuild": "node ./test/test-esbuild.js",
45
+ "test-rollup": "node ./test/test-rollup.js",
46
+ "test-sections": "node ./test/test-sections.js",
47
+ "test-swc": "node ./test/test-swc.js",
48
+ "test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
49
+ "test-browser": "node ./test/test.js --browser",
50
+ "test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
51
+ "test-tsx": "npx mcr tsx ./test/specs/tsx.test.ts -c test/mcr.config.tsx.js",
52
+ "test-demo": "node ./test/test-demo.js",
53
+ "test-merge": "node ./test/test-merge.js",
54
+ "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
55
+ "test-client": "node ./test/test-client.js",
56
+ "test-all": "node ./test/test.js",
57
+ "test-pr": "node --inspect=9230 ./test/test-pr.js",
58
+ "test": "npm run test-unit && npx mcr npm run test-all -c test/mcr.config.mcr.js && node ./scripts/docs.js",
59
+ "test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
60
+ "dev": "npx sf d app",
61
+ "open": "node ./scripts/open.js",
62
+ "eol": "git rm -rf --cached . && git reset --hard HEAD",
63
+ "patch": "npm run build && npm run test && npx sf publish patch -r"
64
+ },
65
+ "workspaces": [
66
+ "test"
67
+ ],
68
+ "files": [
69
+ "lib",
70
+ "README.zh-Hans.md"
71
+ ],
72
+ "license": "MIT",
73
+ "repository": {
74
+ "type": "git",
75
+ "url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
76
+ },
77
+ "dependencies": {
78
+ "@bcoe/v8-coverage": "^0.2.3",
79
+ "@jridgewell/sourcemap-codec": "^1.5.0",
80
+ "acorn": "^8.12.1",
81
+ "acorn-loose": "^8.4.0",
82
+ "acorn-walk": "^8.3.3",
83
+ "commander": "^12.1.0",
84
+ "console-grid": "^2.2.2",
85
+ "eight-colors": "^1.3.0",
86
+ "foreground-child": "^3.2.1",
87
+ "istanbul-lib-coverage": "^3.2.2",
88
+ "istanbul-lib-report": "^3.0.1",
89
+ "istanbul-reports": "^3.1.7",
90
+ "lz-utils": "^2.1.0",
91
+ "monocart-locator": "^1.0.2"
92
+ },
93
+ "devDependencies": {
94
+ "async-tick": "^1.0.0",
95
+ "convert-source-map": "^2.0.0",
96
+ "diff-sequences": "^29.6.3",
97
+ "esbuild": "^0.23.0",
98
+ "eslint": "~9.8.0",
99
+ "eslint-config-plus": "^2.0.2",
100
+ "eslint-plugin-html": "^8.1.1",
101
+ "eslint-plugin-vue": "^9.27.0",
102
+ "find-up": "^7.0.0",
103
+ "minimatch": "^9.0.5",
104
+ "monocart-code-viewer": "^1.1.4",
105
+ "monocart-formatter": "^3.0.0",
106
+ "postcss": "^8.4.40",
107
+ "starfall-cli": "^2.0.20",
108
+ "stylelint": "^16.8.1",
109
+ "stylelint-config-plus": "^1.1.2",
110
+ "supports-color": "^9.4.0",
111
+ "tsx": "^4.16.5",
112
+ "turbogrid": "^3.2.0",
113
+ "vine-ui": "^3.1.16",
114
+ "ws": "^8.18.0"
115
+ }
116
+ }