monocart-coverage-reports 2.10.9 → 2.11.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/lib/utils/util.js CHANGED
@@ -11,6 +11,7 @@ const Share = require('../platform/share.js');
11
11
  const request = require('./request.js');
12
12
  const version = require('../../package.json').version;
13
13
  const markdownGrid = require('./markdown.js');
14
+ const { mergeV8Coverage } = require('./merge/merge.js');
14
15
 
15
16
  const {
16
17
  findUpSync, supportsColor, minimatch
@@ -34,6 +35,7 @@ const Util = {
34
35
 
35
36
  request,
36
37
  markdownGrid,
38
+ mergeV8Coverage,
37
39
 
38
40
  relativePath: function(p, root) {
39
41
  p = `${p}`;
@@ -464,6 +466,13 @@ const Util = {
464
466
  }
465
467
  },
466
468
 
469
+ readJson: async (jsonPath) => {
470
+ const content = await Util.readFile(jsonPath);
471
+ if (content) {
472
+ return JSON.parse(content);
473
+ }
474
+ },
475
+
467
476
  writeFileSync: function(filePath, content) {
468
477
  if (!fs.existsSync(filePath)) {
469
478
  const p = path.dirname(filePath);
package/lib/v8/v8.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const EC = require('eight-colors');
2
- const { mergeScriptCovs } = require('@bcoe/v8-coverage');
3
2
  const Util = require('../utils/util.js');
4
3
  const { getV8Summary } = require('./v8-summary.js');
5
4
  const { dedupeFlatRanges } = require('../utils/dedupe.js');
@@ -169,18 +168,12 @@ const mergeCssRanges = (itemList) => {
169
168
  });
170
169
  };
171
170
 
172
- const mergeJsFunctions = (itemList) => {
173
- return new Promise((resolve) => {
174
-
175
- const res = mergeScriptCovs(itemList);
176
- const functions = res && res.functions;
177
-
178
- resolve(functions || []);
179
- });
171
+ const mergeJsFunctions = async (itemList) => {
172
+ const res = await Util.mergeV8Coverage(itemList);
173
+ return res.functions;
180
174
  };
181
175
 
182
- const mergeV8Coverage = async (dataList, sourceCache, options) => {
183
-
176
+ const mergeV8DataList = async (dataList) => {
184
177
  let allList = [];
185
178
  dataList.forEach((d) => {
186
179
  allList = allList.concat(d.data);
@@ -235,6 +228,14 @@ const mergeV8Coverage = async (dataList, sourceCache, options) => {
235
228
  // empty list + merged list
236
229
  const mergedList = emptyList.concat(Object.values(itemMap));
237
230
 
231
+
232
+ return mergedList;
233
+ };
234
+
235
+ const mergeV8Coverage = async (dataList, sourceCache, options) => {
236
+
237
+ const mergedList = await mergeV8DataList(dataList);
238
+
238
239
  // try to load coverage and source by id
239
240
  for (const entry of mergedList) {
240
241
  const json = sourceCache.get(entry.id);
@@ -329,6 +330,7 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
329
330
 
330
331
  module.exports = {
331
332
  initV8ListAndSourcemap,
333
+ mergeV8DataList,
332
334
  mergeV8Coverage,
333
335
  saveV8Report
334
336
  };
package/package.json CHANGED
@@ -1,115 +1,118 @@
1
- {
2
- "name": "monocart-coverage-reports",
3
- "version": "2.10.9",
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
- },
15
- "./register": {
16
- "import": "./lib/register/register.mjs",
17
- "require": "./lib/register/register.js"
18
- },
19
- "./converter": "./lib/converter/converter.js",
20
- "./util": "./lib/utils/util.js",
21
- "./package.json": "./package.json"
22
- },
23
- "types": "./lib/index.d.ts",
24
- "scripts": {
25
- "build-test": "node ./test/build/build-test.js",
26
- "build": "npx sf lint && npx sf b -p && npm run build-test",
27
- "test-unit": "mocha --parallel test/unit/*.test.js",
28
- "test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
29
- "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
30
- "test-node-ins": "node ./test/test-node-ins.js",
31
- "test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
32
- "test-node-vm": "node ./test/test-node-vm.js",
33
- "test-node-koa": "node ./test/test-node-koa.js",
34
- "test-node-fgc": "node ./test/test-node-fgc.js",
35
- "test-node": "node ./test/test.js --node",
36
- "test-istanbul": "node ./test/test-istanbul.js",
37
- "test-v8": "node ./test/test-v8.js",
38
- "test-puppeteer": "node ./test/test-puppeteer.js",
39
- "test-anonymous": "node ./test/test-anonymous.js",
40
- "test-css": "node ./test/test-css.js",
41
- "test-minify": "node ./test/test-minify.js",
42
- "test-esbuild": "node ./test/test-esbuild.js",
43
- "test-rollup": "node ./test/test-rollup.js",
44
- "test-sections": "node ./test/test-sections.js",
45
- "test-swc": "node ./test/test-swc.js",
46
- "test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
47
- "test-browser": "node ./test/test.js --browser",
48
- "test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
49
- "test-tsx": "npx mcr tsx ./test/specs/tsx.test.ts -c test/mcr.config.tsx.js",
50
- "test-demo": "node ./test/test-demo.js",
51
- "test-merge": "node ./test/test-merge.js",
52
- "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
53
- "test-client": "node ./test/test-client.js",
54
- "test-all": "node ./test/test.js",
55
- "test-pr": "node --inspect=9230 ./test/test-pr.js",
56
- "test": "npm run test-unit && npx mcr npm run test-all -c test/mcr.config.mcr.js && node ./scripts/docs.js",
57
- "test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
58
- "dev": "npx sf d app",
59
- "open": "node ./scripts/open.js",
60
- "eol": "git rm -rf --cached . && git reset --hard HEAD",
61
- "patch": "npm version patch && npm run build && npm run test && npm publish",
62
- "beta": "npm version prerelease --preid=beta && npm run build && npm run test && npm publish --tag beta"
63
- },
64
- "workspaces": [
65
- "test"
66
- ],
67
- "files": [
68
- "lib",
69
- "README.zh-Hans.md"
70
- ],
71
- "license": "MIT",
72
- "repository": {
73
- "type": "git",
74
- "url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
75
- },
76
- "dependencies": {
77
- "@bcoe/v8-coverage": "^0.2.3",
78
- "@jridgewell/sourcemap-codec": "^1.5.0",
79
- "acorn": "^8.12.1",
80
- "acorn-loose": "^8.4.0",
81
- "acorn-walk": "^8.3.4",
82
- "commander": "^12.1.0",
83
- "console-grid": "^2.2.2",
84
- "eight-colors": "^1.3.0",
85
- "foreground-child": "^3.3.0",
86
- "istanbul-lib-coverage": "^3.2.2",
87
- "istanbul-lib-report": "^3.0.1",
88
- "istanbul-reports": "^3.1.7",
89
- "lz-utils": "^2.1.0",
90
- "monocart-locator": "^1.0.2"
91
- },
92
- "devDependencies": {
93
- "async-tick": "^1.0.0",
94
- "convert-source-map": "^2.0.0",
95
- "diff-sequences": "^29.6.3",
96
- "esbuild": "^0.23.1",
97
- "eslint": "~9.10.0",
98
- "eslint-config-plus": "^2.0.2",
99
- "eslint-plugin-html": "^8.1.1",
100
- "eslint-plugin-vue": "^9.28.0",
101
- "find-up": "^7.0.0",
102
- "minimatch": "^9.0.5",
103
- "monocart-code-viewer": "^1.1.4",
104
- "monocart-formatter": "^3.0.0",
105
- "postcss": "^8.4.47",
106
- "starfall-cli": "^2.0.20",
107
- "stylelint": "^16.9.0",
108
- "stylelint-config-plus": "^1.1.3",
109
- "supports-color": "^9.4.0",
110
- "tsx": "^4.19.1",
111
- "turbogrid": "^3.2.0",
112
- "vine-ui": "^3.1.16",
113
- "ws": "^8.18.0"
114
- }
115
- }
1
+ {
2
+ "name": "monocart-coverage-reports",
3
+ "version": "2.11.0",
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
+ },
15
+ "./register": {
16
+ "import": "./lib/register/register.mjs",
17
+ "require": "./lib/register/register.js"
18
+ },
19
+ "./converter": "./lib/converter/converter.js",
20
+ "./util": "./lib/utils/util.js",
21
+ "./package.json": "./package.json"
22
+ },
23
+ "types": "./lib/index.d.ts",
24
+ "scripts": {
25
+ "build-test": "node ./test/build/build-test.js",
26
+ "build": "npx sf lint && npx sf b -p && npm run build-test",
27
+ "test-unit": "mocha --parallel test/unit/*.test.js",
28
+ "test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
29
+ "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
30
+ "test-node-ins": "node ./test/test-node-ins.js",
31
+ "test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
32
+ "test-node-vm": "node ./test/test-node-vm.js",
33
+ "test-node-koa": "node ./test/test-node-koa.js",
34
+ "test-node-fgc": "node ./test/test-node-fgc.js",
35
+ "test-node": "node ./test/test.js --node",
36
+ "test-istanbul": "node ./test/test-istanbul.js",
37
+ "test-v8": "node ./test/test-v8.js",
38
+ "test-puppeteer": "node ./test/test-puppeteer.js",
39
+ "test-anonymous": "node ./test/test-anonymous.js",
40
+ "test-css": "node ./test/test-css.js",
41
+ "test-minify": "node ./test/test-minify.js",
42
+ "test-esbuild": "node ./test/test-esbuild.js",
43
+ "test-rollup": "node ./test/test-rollup.js",
44
+ "test-sections": "node ./test/test-sections.js",
45
+ "test-swc": "node ./test/test-swc.js",
46
+ "test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
47
+ "test-browser": "node ./test/test.js --browser",
48
+ "test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
49
+ "test-tsx": "npx mcr tsx ./test/specs/tsx.test.ts -c test/mcr.config.tsx.js",
50
+ "test-demo": "node ./test/test-demo.js",
51
+ "test-merge": "node ./test/test-merge.js",
52
+ "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
53
+ "test-merge-v8": "node ./test/test-merge-v8.js",
54
+ "test-client": "node ./test/test-client.js",
55
+ "test-all": "node ./test/test.js",
56
+ "test-pr": "node --inspect=9230 ./test/test-pr.js",
57
+ "test": "npm run test-unit && npx mcr npm run test-all -c test/mcr.config.mcr.js && node ./scripts/docs.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 version patch && npm run build && npm run test && npm publish",
63
+ "beta": "npm version prerelease --preid=beta && npm run build && npm run test && npm publish --tag beta"
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
+ "acorn": "^8.12.1",
79
+ "acorn-loose": "^8.4.0",
80
+ "acorn-walk": "^8.3.4",
81
+ "commander": "^12.1.0",
82
+ "console-grid": "^2.2.2",
83
+ "eight-colors": "^1.3.1",
84
+ "foreground-child": "^3.3.0",
85
+ "istanbul-lib-coverage": "^3.2.2",
86
+ "istanbul-lib-report": "^3.0.1",
87
+ "istanbul-reports": "^3.1.7",
88
+ "lz-utils": "^2.1.0",
89
+ "monocart-locator": "^1.0.2"
90
+ },
91
+ "devDependencies": {
92
+ "@bcoe/v8-coverage": "^0.2.3",
93
+ "@jridgewell/sourcemap-codec": "^1.5.0",
94
+ "async-tick": "^1.0.0",
95
+ "convert-source-map": "^2.0.0",
96
+ "diff-sequences": "^29.6.3",
97
+ "esbuild": "^0.24.0",
98
+ "eslint": "~9.11.1",
99
+ "eslint-config-plus": "^2.0.2",
100
+ "eslint-plugin-html": "^8.1.2",
101
+ "eslint-plugin-vue": "^9.28.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
+ "node-stream-zip": "^1.15.0",
107
+ "postcss": "^8.4.47",
108
+ "starfall-cli": "^2.0.20",
109
+ "stylelint": "^16.9.0",
110
+ "stylelint-config-plus": "^1.1.3",
111
+ "supports-color": "^9.4.0",
112
+ "tsx": "^4.19.1",
113
+ "turbogrid": "^3.2.0",
114
+ "vine-ui": "^3.1.16",
115
+ "ws": "^8.18.0",
116
+ "yazl": "^2.5.1"
117
+ }
118
+ }