monocart-coverage-reports 2.7.9 → 2.8.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/README.md +47 -56
- package/README.zh-Hans.md +1035 -0
- package/lib/cli.js +3 -0
- package/lib/converter/converter.js +12 -4
- package/lib/converter/find-original-range.js +9 -0
- package/lib/default/options.js +3 -0
- package/lib/generate.js +20 -5
- package/lib/index.d.ts +11 -6
- package/lib/index.js +3 -16
- package/lib/packages/monocart-coverage-v8.js +1 -1
- package/lib/packages/monocart-coverage-vendor.js +32 -32
- package/lib/platform/share.js +0 -4
- package/lib/utils/util.js +54 -1
- package/lib/v8/v8.js +12 -4
- package/package.json +101 -100
package/lib/platform/share.js
CHANGED
package/lib/utils/util.js
CHANGED
|
@@ -10,7 +10,9 @@ const Share = require('../platform/share.js');
|
|
|
10
10
|
const request = require('./request.js');
|
|
11
11
|
const { deflateSync } = require('lz-utils');
|
|
12
12
|
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
acornWalk, findUpSync, supportsColor
|
|
15
|
+
} = require('../packages/monocart-coverage-vendor.js');
|
|
14
16
|
|
|
15
17
|
// https://github.com/chalk/supports-color
|
|
16
18
|
// disabled color if Terminal stdout does not support color
|
|
@@ -60,6 +62,27 @@ const Util = {
|
|
|
60
62
|
return str;
|
|
61
63
|
},
|
|
62
64
|
|
|
65
|
+
strToObj: (str) => {
|
|
66
|
+
if (typeof str === 'string') {
|
|
67
|
+
str = str.trim();
|
|
68
|
+
if (str.startsWith('{') && str.endsWith('}')) {
|
|
69
|
+
let fun;
|
|
70
|
+
let err;
|
|
71
|
+
try {
|
|
72
|
+
fun = new Function(`return ${str}`);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
err = e;
|
|
75
|
+
}
|
|
76
|
+
if (!err) {
|
|
77
|
+
const obj = fun();
|
|
78
|
+
if (obj && typeof obj === 'object') {
|
|
79
|
+
return obj;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
63
86
|
calculateSha1: (buffer) => {
|
|
64
87
|
const hash = crypto.createHash('sha1');
|
|
65
88
|
hash.update(buffer);
|
|
@@ -81,9 +104,13 @@ const Util = {
|
|
|
81
104
|
|
|
82
105
|
resolveUrl: (input, base) => {
|
|
83
106
|
let url;
|
|
107
|
+
let err;
|
|
84
108
|
try {
|
|
85
109
|
url = new URL(input, base);
|
|
86
110
|
} catch (e) {
|
|
111
|
+
err = e;
|
|
112
|
+
}
|
|
113
|
+
if (err) {
|
|
87
114
|
// console.error('error url', input);
|
|
88
115
|
return;
|
|
89
116
|
}
|
|
@@ -164,6 +191,31 @@ const Util = {
|
|
|
164
191
|
return path.resolve(__dirname, '../packages', p);
|
|
165
192
|
},
|
|
166
193
|
|
|
194
|
+
findUpConfig: (customConfigFile) => {
|
|
195
|
+
if (customConfigFile) {
|
|
196
|
+
if (fs.existsSync(customConfigFile)) {
|
|
197
|
+
return customConfigFile;
|
|
198
|
+
}
|
|
199
|
+
// custom config not found
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const defaultConfigList = [
|
|
204
|
+
'mcr.config.js',
|
|
205
|
+
'mcr.config.cjs',
|
|
206
|
+
'mcr.config.mjs',
|
|
207
|
+
'mcr.config.json',
|
|
208
|
+
'mcr.config.ts'
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
const configPath = findUpSync(defaultConfigList);
|
|
212
|
+
if (configPath) {
|
|
213
|
+
return configPath;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// default config not found
|
|
217
|
+
},
|
|
218
|
+
|
|
167
219
|
saveHtmlReport: async (options) => {
|
|
168
220
|
|
|
169
221
|
const {
|
|
@@ -472,6 +524,7 @@ const Util = {
|
|
|
472
524
|
info: 20,
|
|
473
525
|
debug: 30
|
|
474
526
|
},
|
|
527
|
+
loggingLevel: 20,
|
|
475
528
|
|
|
476
529
|
isDebug: () => {
|
|
477
530
|
return Util.loggingType === 'debug';
|
package/lib/v8/v8.js
CHANGED
|
@@ -23,7 +23,7 @@ const getWrapperSource = (offset, source) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const getEntryFilter = (options) => {
|
|
26
|
-
|
|
26
|
+
let input = options.entryFilter || options.filter;
|
|
27
27
|
|
|
28
28
|
// for function handler
|
|
29
29
|
if (typeof input === 'function') {
|
|
@@ -32,9 +32,17 @@ const getEntryFilter = (options) => {
|
|
|
32
32
|
|
|
33
33
|
// for single minimatch pattern
|
|
34
34
|
if (input && typeof input === 'string') {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
35
|
+
// string to multiple patterns "{...}"
|
|
36
|
+
// mcr npx mocha --entryFilter {'**/node_modules/**':false,'**/src/*.js':true}
|
|
37
|
+
// mcr npx mocha --entryFilter "{'**/node_modules/**': false, '**/src/*.js': true}"
|
|
38
|
+
const obj = Util.strToObj(input);
|
|
39
|
+
if (obj) {
|
|
40
|
+
input = obj;
|
|
41
|
+
} else {
|
|
42
|
+
return (entry) => {
|
|
43
|
+
return minimatch(entry.url, input);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
// for patterns
|
package/package.json
CHANGED
|
@@ -1,100 +1,101 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "monocart-coverage-reports",
|
|
3
|
-
"version": "2.
|
|
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": "sf lint && 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-swc": "node ./test/test-swc.js",
|
|
47
|
-
"test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
|
|
48
|
-
"test-browser": "node ./test/test.js --browser",
|
|
49
|
-
"test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
|
|
50
|
-
"test-tsx": "npx mcr tsx ./test/specs/tsx.test.ts -c test/mcr.config.tsx.js",
|
|
51
|
-
"test-demo": "node ./test/test-demo.js",
|
|
52
|
-
"test-merge": "node ./test/test-merge.js",
|
|
53
|
-
"test-merge-istanbul": "node ./test/test-merge-istanbul.js",
|
|
54
|
-
"test-client": "node ./test/test-client.js",
|
|
55
|
-
"test-all": "node ./test/test.js && node ./scripts/docs.js",
|
|
56
|
-
"test": "npm run test-unit && npx mcr npm run test-all -c test/mcr.config.mcr.js",
|
|
57
|
-
"test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
|
|
58
|
-
"dev": "sf d v8",
|
|
59
|
-
"open": "node ./scripts/open.js",
|
|
60
|
-
"patch": "npm run build && npm run test && sf publish patch -r"
|
|
61
|
-
},
|
|
62
|
-
"workspaces": [
|
|
63
|
-
"packages/*",
|
|
64
|
-
"test"
|
|
65
|
-
],
|
|
66
|
-
"files": [
|
|
67
|
-
"lib"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"istanbul-lib-
|
|
79
|
-
"istanbul-
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"monocart-
|
|
83
|
-
"monocart-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"eslint
|
|
91
|
-
"eslint-
|
|
92
|
-
"eslint-plugin-
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"stylelint
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "monocart-coverage-reports",
|
|
3
|
+
"version": "2.8.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
|
+
"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": "sf lint && 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-swc": "node ./test/test-swc.js",
|
|
47
|
+
"test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
|
|
48
|
+
"test-browser": "node ./test/test.js --browser",
|
|
49
|
+
"test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
|
|
50
|
+
"test-tsx": "npx mcr tsx ./test/specs/tsx.test.ts -c test/mcr.config.tsx.js",
|
|
51
|
+
"test-demo": "node ./test/test-demo.js",
|
|
52
|
+
"test-merge": "node ./test/test-merge.js",
|
|
53
|
+
"test-merge-istanbul": "node ./test/test-merge-istanbul.js",
|
|
54
|
+
"test-client": "node ./test/test-client.js",
|
|
55
|
+
"test-all": "node ./test/test.js && node ./scripts/docs.js",
|
|
56
|
+
"test": "npm run test-unit && npx mcr npm run test-all -c test/mcr.config.mcr.js",
|
|
57
|
+
"test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
|
|
58
|
+
"dev": "sf d v8",
|
|
59
|
+
"open": "node ./scripts/open.js",
|
|
60
|
+
"patch": "npm run build && npm run test && sf publish patch -r"
|
|
61
|
+
},
|
|
62
|
+
"workspaces": [
|
|
63
|
+
"packages/*",
|
|
64
|
+
"test"
|
|
65
|
+
],
|
|
66
|
+
"files": [
|
|
67
|
+
"lib",
|
|
68
|
+
"README.zh-Hans.md"
|
|
69
|
+
],
|
|
70
|
+
"license": "MIT",
|
|
71
|
+
"repository": {
|
|
72
|
+
"type": "git",
|
|
73
|
+
"url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"console-grid": "^2.2.2",
|
|
77
|
+
"eight-colors": "^1.3.0",
|
|
78
|
+
"istanbul-lib-coverage": "^3.2.2",
|
|
79
|
+
"istanbul-lib-report": "^3.0.1",
|
|
80
|
+
"istanbul-reports": "^3.1.7",
|
|
81
|
+
"lz-utils": "^2.0.2",
|
|
82
|
+
"monocart-code-viewer": "^1.1.3",
|
|
83
|
+
"monocart-formatter": "^3.0.0",
|
|
84
|
+
"monocart-locator": "^1.0.0",
|
|
85
|
+
"turbogrid": "^3.0.13"
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"commander": "^12.0.0",
|
|
89
|
+
"esbuild": "^0.21.1",
|
|
90
|
+
"eslint": "~9.2.0",
|
|
91
|
+
"eslint-config-plus": "^2.0.0",
|
|
92
|
+
"eslint-plugin-html": "^8.1.1",
|
|
93
|
+
"eslint-plugin-vue": "^9.26.0",
|
|
94
|
+
"minimatch": "^9.0.4",
|
|
95
|
+
"stylelint": "^16.5.0",
|
|
96
|
+
"stylelint-config-plus": "^1.1.2",
|
|
97
|
+
"supports-color": "^9.4.0",
|
|
98
|
+
"tsx": "^4.9.3",
|
|
99
|
+
"ws": "^8.17.0"
|
|
100
|
+
}
|
|
101
|
+
}
|