monocart-coverage-reports 2.12.7 → 2.12.9
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/source-path.js +20 -39
- package/package.json +133 -133
package/lib/utils/source-path.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const path = require('path');
|
|
2
3
|
const { fileURLToPath, pathToFileURL } = require('url');
|
|
3
4
|
const Util = require('./util.js');
|
|
@@ -28,37 +29,6 @@ const resolveAnonymousUrl = (url, index, type) => {
|
|
|
28
29
|
return list.join('');
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
const filterPath = (str) => {
|
|
32
|
-
// double \\ to /
|
|
33
|
-
|
|
34
|
-
// src/images/icons/ sync \.svg$
|
|
35
|
-
// src/images/icons/sync-.svg$
|
|
36
|
-
|
|
37
|
-
str = str.replace(/\\\\/g, '/');
|
|
38
|
-
|
|
39
|
-
// decodeURI("%20") to space
|
|
40
|
-
str = decodeURI(str);
|
|
41
|
-
// remove / of start, end or double, ./ ../
|
|
42
|
-
const ls = str.split('/').filter((item) => {
|
|
43
|
-
if (!item || item === '.' || item === '..') {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return ls.join('/');
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const betterFileURLToPath = (url) => {
|
|
53
|
-
try {
|
|
54
|
-
url = fileURLToPath(url);
|
|
55
|
-
} catch (e) {
|
|
56
|
-
url = decodeURIComponent(url);
|
|
57
|
-
url = fileURLToPath(url);
|
|
58
|
-
}
|
|
59
|
-
return url;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
32
|
const normalizePathDir = (sourcePath) => {
|
|
63
33
|
|
|
64
34
|
// decodeURI("%20") to space
|
|
@@ -81,6 +51,16 @@ const normalizePathDir = (sourcePath) => {
|
|
|
81
51
|
}).join('/');
|
|
82
52
|
};
|
|
83
53
|
|
|
54
|
+
const betterFileURLToPath = (url) => {
|
|
55
|
+
try {
|
|
56
|
+
url = fileURLToPath(url);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
url = decodeURIComponent(url);
|
|
59
|
+
url = fileURLToPath(url);
|
|
60
|
+
}
|
|
61
|
+
return url;
|
|
62
|
+
};
|
|
63
|
+
|
|
84
64
|
const normalizeSourcePath = (sourceUrl, baseDir) => {
|
|
85
65
|
|
|
86
66
|
// includes anonymous and everything
|
|
@@ -88,7 +68,7 @@ const normalizeSourcePath = (sourceUrl, baseDir) => {
|
|
|
88
68
|
// file url
|
|
89
69
|
if (sourceUrl.startsWith('file:')) {
|
|
90
70
|
const relPath = Util.relativePath(betterFileURLToPath(sourceUrl), baseDir);
|
|
91
|
-
return
|
|
71
|
+
return normalizePathDir(relPath);
|
|
92
72
|
}
|
|
93
73
|
|
|
94
74
|
// absolute path
|
|
@@ -106,7 +86,7 @@ const normalizeSourcePath = (sourceUrl, baseDir) => {
|
|
|
106
86
|
|
|
107
87
|
if (path.isAbsolute(sourceUrl)) {
|
|
108
88
|
const relPath = Util.relativePath(sourceUrl, baseDir);
|
|
109
|
-
return
|
|
89
|
+
return normalizePathDir(relPath);
|
|
110
90
|
}
|
|
111
91
|
|
|
112
92
|
// ws://a.js
|
|
@@ -131,15 +111,13 @@ const normalizeSourcePath = (sourceUrl, baseDir) => {
|
|
|
131
111
|
p += `-${urlObj.search}`;
|
|
132
112
|
}
|
|
133
113
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return filterPath(p);
|
|
114
|
+
return normalizePathDir(p);
|
|
137
115
|
}
|
|
138
116
|
|
|
139
117
|
// relative path
|
|
140
118
|
const fileUrl = pathToFileURL(sourceUrl).toString();
|
|
141
119
|
const relPath = Util.relativePath(betterFileURLToPath(fileUrl), baseDir);
|
|
142
|
-
return
|
|
120
|
+
return normalizePathDir(relPath);
|
|
143
121
|
};
|
|
144
122
|
|
|
145
123
|
const getSourceType = (sourcePath) => {
|
|
@@ -184,6 +162,7 @@ const initIstanbulSourcePath = (coverageData, fileSources, options) => {
|
|
|
184
162
|
const sourcePathReplacer = getSourcePathReplacer(options);
|
|
185
163
|
|
|
186
164
|
const newCoverage = {};
|
|
165
|
+
// eslint-disable-next-line complexity
|
|
187
166
|
Object.keys(coverageData).forEach((sourcePath) => {
|
|
188
167
|
// previous coverage and source
|
|
189
168
|
const item = coverageData[sourcePath];
|
|
@@ -198,6 +177,10 @@ const initIstanbulSourcePath = (coverageData, fileSources, options) => {
|
|
|
198
177
|
}
|
|
199
178
|
}
|
|
200
179
|
|
|
180
|
+
if (!fs.existsSync(sourcePath)) {
|
|
181
|
+
sourcePath = normalizePathDir(sourcePath);
|
|
182
|
+
}
|
|
183
|
+
|
|
201
184
|
// new source path, second is source url
|
|
202
185
|
if (sourcePathReplacer) {
|
|
203
186
|
const newSourcePath = sourcePathReplacer(sourcePath, item);
|
|
@@ -206,8 +189,6 @@ const initIstanbulSourcePath = (coverageData, fileSources, options) => {
|
|
|
206
189
|
}
|
|
207
190
|
}
|
|
208
191
|
|
|
209
|
-
// console.log(item);
|
|
210
|
-
|
|
211
192
|
// update source path
|
|
212
193
|
if (item.data) {
|
|
213
194
|
item.data.path = sourcePath;
|
package/package.json
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "monocart-coverage-reports",
|
|
3
|
-
"version": "2.12.
|
|
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-css": "node ./test/test-css.js",
|
|
40
|
-
"test-minify": "node ./test/test-minify.js",
|
|
41
|
-
"test-esbuild": "node ./test/test-esbuild.js",
|
|
42
|
-
"test-rollup": "node ./test/test-rollup.js",
|
|
43
|
-
"test-sections": "node ./test/test-sections.js",
|
|
44
|
-
"test-swc": "node ./test/test-swc.js",
|
|
45
|
-
"test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
|
|
46
|
-
"test-browser": "node ./test/test.js --browser",
|
|
47
|
-
"test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
|
|
48
|
-
"test-demo": "node ./test/test-demo.js",
|
|
49
|
-
"test-merge": "node ./test/test-merge.js",
|
|
50
|
-
"test-merge-istanbul": "node ./test/test-merge-istanbul.js",
|
|
51
|
-
"test-merge-v8": "node ./test/test-merge-v8.js",
|
|
52
|
-
"test-merge-cli": "npx mcr merge -r console-details,v8 --inputDir .temp/code-coverage/raw --outputDir .temp/merge-cli",
|
|
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 run build && npm run test && npx sf publish patch -r",
|
|
62
|
-
"beta": "npm version prerelease --preid=beta && npm run build && npm run test && npm publish --tag beta"
|
|
63
|
-
},
|
|
64
|
-
"files": [
|
|
65
|
-
"lib",
|
|
66
|
-
"README.zh-Hans.md"
|
|
67
|
-
],
|
|
68
|
-
"license": "MIT",
|
|
69
|
-
"repository": {
|
|
70
|
-
"type": "git",
|
|
71
|
-
"url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
|
|
72
|
-
},
|
|
73
|
-
"dependencies": {
|
|
74
|
-
"acorn": "^8.15.0",
|
|
75
|
-
"acorn-loose": "^8.5.2",
|
|
76
|
-
"acorn-walk": "^8.3.4",
|
|
77
|
-
"commander": "^14.0.0",
|
|
78
|
-
"console-grid": "^2.2.3",
|
|
79
|
-
"eight-colors": "^1.3.1",
|
|
80
|
-
"foreground-child": "^3.3.1",
|
|
81
|
-
"istanbul-lib-coverage": "^3.2.2",
|
|
82
|
-
"istanbul-lib-report": "^3.0.1",
|
|
83
|
-
"istanbul-reports": "^3.2.0",
|
|
84
|
-
"lz-utils": "^2.1.0",
|
|
85
|
-
"monocart-locator": "^1.0.2"
|
|
86
|
-
},
|
|
87
|
-
"devDependencies": {
|
|
88
|
-
"@actions/core": "^1.11.1",
|
|
89
|
-
"@actions/github": "^6.0.1",
|
|
90
|
-
"@jridgewell/sourcemap-codec": "^1.5.5",
|
|
91
|
-
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
|
92
|
-
"@rollup/plugin-commonjs": "^28.0.6",
|
|
93
|
-
"@rollup/plugin-typescript": "^12.1.4",
|
|
94
|
-
"async-tick": "^1.0.0",
|
|
95
|
-
"babel-loader": "^10.0.0",
|
|
96
|
-
"babel-plugin-istanbul": "^7.0.1",
|
|
97
|
-
"convert-source-map": "^2.0.0",
|
|
98
|
-
"cross-env": "^10.0.0",
|
|
99
|
-
"diff-sequences": "^29.6.3",
|
|
100
|
-
"esbuild": "^0.25.9",
|
|
101
|
-
"eslint": "~9.35.0",
|
|
102
|
-
"eslint-config-plus": "^2.0.3",
|
|
103
|
-
"eslint-plugin-html": "^8.1.3",
|
|
104
|
-
"eslint-plugin-vue": "^10.4.0",
|
|
105
|
-
"find-up": "^7.0.0",
|
|
106
|
-
"foreground-child": "^3.3.1",
|
|
107
|
-
"koa": "^3.0.1",
|
|
108
|
-
"koa-static-resolver": "^1.0.6",
|
|
109
|
-
"minimatch": "^9.0.5",
|
|
110
|
-
"mocha": "^11.7.2",
|
|
111
|
-
"monocart-code-viewer": "^1.1.5",
|
|
112
|
-
"monocart-formatter": "^3.0.1",
|
|
113
|
-
"node-stream-zip": "^1.15.0",
|
|
114
|
-
"open": "^10.2.0",
|
|
115
|
-
"playwright": "^1.55.0",
|
|
116
|
-
"postcss": "^8.5.6",
|
|
117
|
-
"puppeteer": "^24.19.0",
|
|
118
|
-
"rollup": "^4.50.1",
|
|
119
|
-
"starfall-cli": "^2.0.22",
|
|
120
|
-
"stylelint": "^16.24.0",
|
|
121
|
-
"stylelint-config-plus": "^1.1.4",
|
|
122
|
-
"supports-color": "^10.2.2",
|
|
123
|
-
"swc-loader": "^0.2.6",
|
|
124
|
-
"ts-loader": "^9.5.4",
|
|
125
|
-
"tsx": "^4.20.5",
|
|
126
|
-
"turbogrid": "^3.2.1",
|
|
127
|
-
"typescript": "^5.9.2",
|
|
128
|
-
"vine-ui": "^3.1.18",
|
|
129
|
-
"webpack": "^5.101.3",
|
|
130
|
-
"ws": "^8.18.3",
|
|
131
|
-
"yazl": "^3.3.1"
|
|
132
|
-
}
|
|
133
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "monocart-coverage-reports",
|
|
3
|
+
"version": "2.12.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-css": "node ./test/test-css.js",
|
|
40
|
+
"test-minify": "node ./test/test-minify.js",
|
|
41
|
+
"test-esbuild": "node ./test/test-esbuild.js",
|
|
42
|
+
"test-rollup": "node ./test/test-rollup.js",
|
|
43
|
+
"test-sections": "node ./test/test-sections.js",
|
|
44
|
+
"test-swc": "node ./test/test-swc.js",
|
|
45
|
+
"test-v8-and-istanbul": "node ./test/test-v8-and-istanbul.js",
|
|
46
|
+
"test-browser": "node ./test/test.js --browser",
|
|
47
|
+
"test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
|
|
48
|
+
"test-demo": "node ./test/test-demo.js",
|
|
49
|
+
"test-merge": "node ./test/test-merge.js",
|
|
50
|
+
"test-merge-istanbul": "node ./test/test-merge-istanbul.js",
|
|
51
|
+
"test-merge-v8": "node ./test/test-merge-v8.js",
|
|
52
|
+
"test-merge-cli": "npx mcr merge -r console-details,v8 --inputDir .temp/code-coverage/raw --outputDir .temp/merge-cli",
|
|
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 run build && npm run test && npx sf publish patch -r",
|
|
62
|
+
"beta": "npm version prerelease --preid=beta && npm run build && npm run test && npm publish --tag beta"
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"lib",
|
|
66
|
+
"README.zh-Hans.md"
|
|
67
|
+
],
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"repository": {
|
|
70
|
+
"type": "git",
|
|
71
|
+
"url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"acorn": "^8.15.0",
|
|
75
|
+
"acorn-loose": "^8.5.2",
|
|
76
|
+
"acorn-walk": "^8.3.4",
|
|
77
|
+
"commander": "^14.0.0",
|
|
78
|
+
"console-grid": "^2.2.3",
|
|
79
|
+
"eight-colors": "^1.3.1",
|
|
80
|
+
"foreground-child": "^3.3.1",
|
|
81
|
+
"istanbul-lib-coverage": "^3.2.2",
|
|
82
|
+
"istanbul-lib-report": "^3.0.1",
|
|
83
|
+
"istanbul-reports": "^3.2.0",
|
|
84
|
+
"lz-utils": "^2.1.0",
|
|
85
|
+
"monocart-locator": "^1.0.2"
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@actions/core": "^1.11.1",
|
|
89
|
+
"@actions/github": "^6.0.1",
|
|
90
|
+
"@jridgewell/sourcemap-codec": "^1.5.5",
|
|
91
|
+
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
|
92
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
93
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
94
|
+
"async-tick": "^1.0.0",
|
|
95
|
+
"babel-loader": "^10.0.0",
|
|
96
|
+
"babel-plugin-istanbul": "^7.0.1",
|
|
97
|
+
"convert-source-map": "^2.0.0",
|
|
98
|
+
"cross-env": "^10.0.0",
|
|
99
|
+
"diff-sequences": "^29.6.3",
|
|
100
|
+
"esbuild": "^0.25.9",
|
|
101
|
+
"eslint": "~9.35.0",
|
|
102
|
+
"eslint-config-plus": "^2.0.3",
|
|
103
|
+
"eslint-plugin-html": "^8.1.3",
|
|
104
|
+
"eslint-plugin-vue": "^10.4.0",
|
|
105
|
+
"find-up": "^7.0.0",
|
|
106
|
+
"foreground-child": "^3.3.1",
|
|
107
|
+
"koa": "^3.0.1",
|
|
108
|
+
"koa-static-resolver": "^1.0.6",
|
|
109
|
+
"minimatch": "^9.0.5",
|
|
110
|
+
"mocha": "^11.7.2",
|
|
111
|
+
"monocart-code-viewer": "^1.1.5",
|
|
112
|
+
"monocart-formatter": "^3.0.1",
|
|
113
|
+
"node-stream-zip": "^1.15.0",
|
|
114
|
+
"open": "^10.2.0",
|
|
115
|
+
"playwright": "^1.55.0",
|
|
116
|
+
"postcss": "^8.5.6",
|
|
117
|
+
"puppeteer": "^24.19.0",
|
|
118
|
+
"rollup": "^4.50.1",
|
|
119
|
+
"starfall-cli": "^2.0.22",
|
|
120
|
+
"stylelint": "^16.24.0",
|
|
121
|
+
"stylelint-config-plus": "^1.1.4",
|
|
122
|
+
"supports-color": "^10.2.2",
|
|
123
|
+
"swc-loader": "^0.2.6",
|
|
124
|
+
"ts-loader": "^9.5.4",
|
|
125
|
+
"tsx": "^4.20.5",
|
|
126
|
+
"turbogrid": "^3.2.1",
|
|
127
|
+
"typescript": "^5.9.2",
|
|
128
|
+
"vine-ui": "^3.1.18",
|
|
129
|
+
"webpack": "^5.101.3",
|
|
130
|
+
"ws": "^8.18.3",
|
|
131
|
+
"yazl": "^3.3.1"
|
|
132
|
+
}
|
|
133
|
+
}
|