monocart-coverage-reports 2.7.0 → 2.7.2
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 +7 -6
- package/lib/cli.js +73 -87
- package/lib/converter/collect-source-maps.js +35 -18
- package/lib/converter/converter.js +2 -2
- package/lib/generate.js +130 -1
- package/lib/index.d.ts +7 -1
- package/lib/index.js +11 -1
- package/lib/packages/monocart-coverage-v8.js +1 -1
- package/lib/register/hooks.js +40 -0
- package/lib/register/hooks.mjs +3 -0
- package/lib/register/register.js +4 -0
- package/lib/register/register.mjs +3 -0
- package/lib/utils/source-path.js +37 -17
- package/lib/v8/v8.js +1 -1
- package/package.json +91 -83
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const Util = require('../utils/util.js');
|
|
4
|
+
const { convertSourceMap } = require('../packages/monocart-coverage-vendor.js');
|
|
5
|
+
|
|
6
|
+
async function load(url, context, nextLoad) {
|
|
7
|
+
|
|
8
|
+
const loaded = await nextLoad(url, context);
|
|
9
|
+
const { source, format } = loaded;
|
|
10
|
+
const dir = process.env.NODE_V8_COVERAGE;
|
|
11
|
+
|
|
12
|
+
if (dir && typeof source === 'string' && (format === 'module' || format === 'commonjs')) {
|
|
13
|
+
|
|
14
|
+
if (convertSourceMap.mapFileCommentRegex.test(source)) {
|
|
15
|
+
|
|
16
|
+
if (!fs.existsSync(dir)) {
|
|
17
|
+
fs.mkdirSync(dir, {
|
|
18
|
+
recursive: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const id = Util.calculateSha1(url + source);
|
|
23
|
+
const filePath = path.resolve(dir, `source-${id}.json`);
|
|
24
|
+
if (!fs.existsSync(filePath)) {
|
|
25
|
+
fs.writeFileSync(filePath, JSON.stringify({
|
|
26
|
+
url,
|
|
27
|
+
source
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return loaded;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
load
|
|
40
|
+
};
|
package/lib/utils/source-path.js
CHANGED
|
@@ -119,7 +119,7 @@ const initIstanbulSourcePath = (coverageData, fileSources, sourcePathHandler) =>
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// new source path, second is source url
|
|
122
|
-
const newSourcePath = sourcePathHandler(sourcePath,
|
|
122
|
+
const newSourcePath = sourcePathHandler(sourcePath, item);
|
|
123
123
|
if (typeof newSourcePath === 'string' && newSourcePath) {
|
|
124
124
|
sourcePath = newSourcePath;
|
|
125
125
|
}
|
|
@@ -141,31 +141,51 @@ const initIstanbulSourcePath = (coverageData, fileSources, sourcePathHandler) =>
|
|
|
141
141
|
|
|
142
142
|
// ========================================================================================================
|
|
143
143
|
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
const resolveSourceUrl = (sourceName, sourceRoot) => {
|
|
145
|
+
|
|
146
|
+
// could be absolute path
|
|
147
|
+
// c:\\workspace\test\\selenium.spec.js
|
|
148
|
+
// a.js false
|
|
149
|
+
// c://a.js true
|
|
150
|
+
// ws://a.js false
|
|
151
|
+
|
|
152
|
+
if (path.isAbsolute(sourceName)) {
|
|
153
|
+
return pathToFileURL(sourceName).toString();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// webpack://coverage-v8/./test/mock/src/branch/branch.js
|
|
157
|
+
// webpack://monocart-v8/../starfall-cli/node_modules/css-loader/dist/runtime/api.js
|
|
158
|
+
|
|
159
|
+
// as url
|
|
160
|
+
const urlObj = Util.resolveUrl(sourceName);
|
|
161
|
+
if (urlObj) {
|
|
162
|
+
return urlObj.toString();
|
|
147
163
|
}
|
|
148
|
-
|
|
164
|
+
|
|
165
|
+
// as relative path, join sourceRoot
|
|
166
|
+
if (sourceRoot && !sourceName.startsWith(sourceRoot)) {
|
|
167
|
+
sourceName = path.join(sourceRoot, sourceName);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
sourceName = path.normalize(sourceName);
|
|
171
|
+
const sourceUrl = pathToFileURL(sourceName).toString();
|
|
172
|
+
|
|
173
|
+
return sourceUrl;
|
|
149
174
|
};
|
|
150
175
|
|
|
151
|
-
const initSourceMapSourcePath = (sourceMap, fileUrls, sourcePathHandler) => {
|
|
152
|
-
// reset sourceRoot
|
|
153
|
-
const sourceRoot = sourceMap.sourceRoot || '';
|
|
154
|
-
sourceMap.sourceRoot = '';
|
|
176
|
+
const initSourceMapSourcePath = (sourceMap, fileUrls, distFile, sourcePathHandler) => {
|
|
155
177
|
|
|
156
178
|
sourceMap.sources = sourceMap.sources.map((sourceName, i) => {
|
|
157
179
|
|
|
158
|
-
|
|
159
|
-
// c:\\workspace\test\\selenium.spec.js
|
|
160
|
-
// console.log(sourceName);
|
|
161
|
-
sourceName = Util.formatPath(sourceName);
|
|
162
|
-
// console.log(sourceName);
|
|
163
|
-
|
|
164
|
-
const sourceUrl = mergeSourceRoot(sourceRoot, sourceName);
|
|
180
|
+
const sourceUrl = resolveSourceUrl(sourceName, sourceMap.sourceRoot);
|
|
165
181
|
|
|
166
182
|
let sourcePath = getSourcePath(sourceUrl, i + 1);
|
|
167
183
|
if (sourcePathHandler) {
|
|
168
|
-
|
|
184
|
+
// sourcePath could be a filename only, may using distFile to get full path
|
|
185
|
+
const newSourcePath = sourcePathHandler(sourcePath, {
|
|
186
|
+
url: sourceUrl,
|
|
187
|
+
distFile
|
|
188
|
+
});
|
|
169
189
|
if (typeof newSourcePath === 'string' && newSourcePath) {
|
|
170
190
|
sourcePath = newSourcePath;
|
|
171
191
|
}
|
package/lib/v8/v8.js
CHANGED
|
@@ -144,7 +144,7 @@ const initV8ListAndSourcemap = async (v8list, options) => {
|
|
|
144
144
|
// resolve source path
|
|
145
145
|
let sourcePath = getSourcePath(data.url, i + 1, data.type);
|
|
146
146
|
if (sourcePathHandler) {
|
|
147
|
-
const newSourcePath = sourcePathHandler(sourcePath, data
|
|
147
|
+
const newSourcePath = sourcePathHandler(sourcePath, data);
|
|
148
148
|
if (typeof newSourcePath === 'string' && newSourcePath) {
|
|
149
149
|
sourcePath = newSourcePath;
|
|
150
150
|
}
|
package/package.json
CHANGED
|
@@ -1,83 +1,91 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "monocart-coverage-reports",
|
|
3
|
-
"version": "2.7.
|
|
4
|
-
"description": "
|
|
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
|
-
"./
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"test
|
|
29
|
-
"
|
|
30
|
-
"test-node
|
|
31
|
-
"test-
|
|
32
|
-
"test-
|
|
33
|
-
"test-
|
|
34
|
-
"test-
|
|
35
|
-
"test-
|
|
36
|
-
"test-
|
|
37
|
-
"test-
|
|
38
|
-
"test-
|
|
39
|
-
"test-
|
|
40
|
-
"test-
|
|
41
|
-
"test-
|
|
42
|
-
"test": "
|
|
43
|
-
"test
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"test"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "monocart-coverage-reports",
|
|
3
|
+
"version": "2.7.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-docs": "node ./scripts/build-docs.js",
|
|
28
|
+
"build-test": "node ./scripts/build-test.js",
|
|
29
|
+
"build": "sf lint && sf b -p && npm run build-test",
|
|
30
|
+
"test-node": "npm run test-node-env && npm run test-node-api && npm run test-node-ins && npm run test-node-cdp && npm run test-node-koa && npm run test-node-vm",
|
|
31
|
+
"test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
|
|
32
|
+
"test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
|
|
33
|
+
"test-node-fgc": "node ./test/test-node-fgc.js",
|
|
34
|
+
"test-node-ins": "node ./test/test-node-ins.js",
|
|
35
|
+
"test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
|
|
36
|
+
"test-node-koa": "node ./test/test-node-koa.js",
|
|
37
|
+
"test-node-vm": "node ./test/test-node-vm.js",
|
|
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-browser": "node ./test/test-browser.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
|
|
42
|
+
"test-anonymous": "node ./test/test-anonymous.js",
|
|
43
|
+
"test-css": "node ./test/test-css.js",
|
|
44
|
+
"test-client": "node ./test/test-client.js",
|
|
45
|
+
"test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
|
|
46
|
+
"test-merge": "node ./test/test-merge.js",
|
|
47
|
+
"test-merge-istanbul": "node ./test/test-merge-istanbul.js",
|
|
48
|
+
"test-all": "npm run test-browser && npm run test-node && npm run test-cli && npm run test-merge && npm run build-docs",
|
|
49
|
+
"test": "npx mcr npm run test-all -c test/mcr.config.mcr.js",
|
|
50
|
+
"test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
|
|
51
|
+
"dev": "sf d v8",
|
|
52
|
+
"open": "node ./scripts/open.js",
|
|
53
|
+
"patch": "npm run build && npm run test && sf publish patch -r"
|
|
54
|
+
},
|
|
55
|
+
"workspaces": [
|
|
56
|
+
"packages/*",
|
|
57
|
+
"test"
|
|
58
|
+
],
|
|
59
|
+
"files": [
|
|
60
|
+
"lib"
|
|
61
|
+
],
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"console-grid": "^2.2.2",
|
|
69
|
+
"eight-colors": "^1.3.0",
|
|
70
|
+
"istanbul-lib-coverage": "^3.2.2",
|
|
71
|
+
"istanbul-lib-report": "^3.0.1",
|
|
72
|
+
"istanbul-reports": "^3.1.7",
|
|
73
|
+
"lz-utils": "^2.0.2",
|
|
74
|
+
"monocart-code-viewer": "^1.1.2",
|
|
75
|
+
"monocart-formatter": "^2.3.2",
|
|
76
|
+
"turbogrid": "^3.0.13"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"commander": "^12.0.0",
|
|
80
|
+
"eslint": "^8.57.0",
|
|
81
|
+
"eslint-config-plus": "^1.0.6",
|
|
82
|
+
"eslint-plugin-html": "^8.0.0",
|
|
83
|
+
"eslint-plugin-vue": "^9.23.0",
|
|
84
|
+
"minimatch": "^9.0.3",
|
|
85
|
+
"stylelint": "^16.2.1",
|
|
86
|
+
"stylelint-config-plus": "^1.1.0",
|
|
87
|
+
"supports-color": "^9.4.0",
|
|
88
|
+
"tsx": "^4.7.1",
|
|
89
|
+
"ws": "^8.16.0"
|
|
90
|
+
}
|
|
91
|
+
}
|