monocart-coverage-reports 2.13.2 → 3.0.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 +267 -114
- package/README.zh-Hans.md +268 -115
- package/lib/assets.js +6 -6
- package/lib/cli.js +191 -95
- package/lib/client/cdp-client.js +74 -43
- package/lib/client/coverage-client.js +24 -8
- package/lib/client/ws-session.js +115 -37
- package/lib/converter/ast-visitor.js +5 -7
- package/lib/converter/ast.js +6 -6
- package/lib/converter/collect-source-maps.js +9 -9
- package/lib/converter/converter.js +41 -115
- package/lib/converter/fake-source-coverage.js +64 -0
- package/lib/converter/find-original-range.js +3 -3
- package/lib/converter/flatten-source-maps.js +2 -4
- package/lib/converter/ignore.js +2 -4
- package/lib/converter/info-branch.js +5 -3
- package/lib/converter/info-function.js +5 -3
- package/lib/converter/info-statement.js +5 -3
- package/lib/converter/range-index.js +78 -0
- package/lib/converter/source-range-merge.js +103 -0
- package/lib/converter/untested.js +27 -55
- package/lib/default/options.js +13 -1
- package/lib/generate.js +44 -26
- package/lib/index.d.ts +52 -4
- package/lib/index.js +35 -41
- package/lib/istanbul/istanbul-summary.js +2 -2
- package/lib/istanbul/istanbul.js +35 -13
- package/lib/packages/chunks/chunk-RVOSNMVU.js +2 -0
- package/lib/packages/monocart-coverage-assets.js +4 -3
- package/lib/packages/monocart-coverage-converter.js +27 -0
- package/lib/packages/monocart-coverage-vendor.js +2 -41
- package/lib/packages/monocart-coverage-vendor.js.LICENSE +3 -221
- package/lib/platform/concurrency.js +47 -43
- package/lib/platform/share.js +1 -1
- package/lib/register/hooks.js +19 -13
- package/lib/register/register.js +5 -3
- package/lib/reports/codacy.js +3 -5
- package/lib/reports/codecov.js +3 -5
- package/lib/reports/console-details.js +5 -5
- package/lib/reports/console-summary.js +4 -4
- package/lib/reports/custom.js +8 -24
- package/lib/reports/markdown-details.js +4 -6
- package/lib/reports/markdown-summary.js +4 -6
- package/lib/reports/raw.js +10 -12
- package/lib/reports/v8-json.js +3 -5
- package/lib/reports/v8.js +3 -5
- package/lib/utils/dedupe.js +1 -1
- package/lib/utils/gc.js +30 -14
- package/lib/utils/markdown.js +2 -2
- package/lib/utils/merge/merge.js +2 -4
- package/lib/utils/merge/range-tree.js +1 -1
- package/lib/utils/request.js +85 -73
- package/lib/utils/snapshot.js +4 -4
- package/lib/utils/source-path.js +5 -5
- package/lib/utils/util.js +61 -41
- package/lib/v8/v8-summary.js +2 -4
- package/lib/v8/v8.js +11 -11
- package/migrate-to-3.md +175 -0
- package/package.json +153 -149
- package/skills/monocart-coverage-reports/SKILL.md +106 -0
- package/skills/monocart-coverage-reports/references/cli.md +108 -0
- package/skills/monocart-coverage-reports/references/collection.md +152 -0
- package/skills/monocart-coverage-reports/references/filtering-and-sourcemaps.md +170 -0
- package/skills/monocart-coverage-reports/references/reports-and-ci.md +219 -0
- package/skills/monocart-coverage-reports/references/repository-map.md +55 -0
- package/lib/index.mjs +0 -9
- package/lib/register/hooks.mjs +0 -3
- package/lib/register/register.mjs +0 -3
package/lib/reports/raw.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const getMergedData = (type, dataList, options) => {
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Util } from '../utils/util.js';
|
|
4
|
+
import { mergeV8DataList } from '../v8/v8.js';
|
|
5
|
+
|
|
6
|
+
const getMergedData = async (type, dataList, options) => {
|
|
9
7
|
if (type === 'istanbul') {
|
|
8
|
+
const { mergeIstanbulDataList } = await import('../istanbul/istanbul.js');
|
|
10
9
|
return mergeIstanbulDataList(dataList, options);
|
|
11
10
|
}
|
|
12
11
|
return mergeV8DataList(dataList, options);
|
|
@@ -43,7 +42,8 @@ const mergeReport = async (rawDir, options) => {
|
|
|
43
42
|
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
const zipReport = (rawDir, rawParent) => {
|
|
45
|
+
const zipReport = async (rawDir, rawParent) => {
|
|
46
|
+
const { ZipFile } = await import('yazl');
|
|
47
47
|
const zipName = path.basename(rawDir);
|
|
48
48
|
const zipPath = path.resolve(rawParent, `${zipName}.zip`);
|
|
49
49
|
|
|
@@ -110,6 +110,4 @@ const rawReport = async (reportData, reportOptions, options) => {
|
|
|
110
110
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
rawReport
|
|
115
|
-
};
|
|
113
|
+
export { rawReport };
|
package/lib/reports/v8-json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { Util } from '../utils/util.js';
|
|
3
3
|
|
|
4
4
|
const v8JsonReport = async (reportData, reportOptions, options) => {
|
|
5
5
|
const v8JsonOptions = {
|
|
@@ -17,6 +17,4 @@ const v8JsonReport = async (reportData, reportOptions, options) => {
|
|
|
17
17
|
return reportPath;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
v8JsonReport
|
|
22
|
-
};
|
|
20
|
+
export { v8JsonReport };
|
package/lib/reports/v8.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const Assets = require('../assets.js');
|
|
1
|
+
import path from 'node:path';
|
|
3
2
|
|
|
4
3
|
const v8Report = async (reportData, reportOptions, options) => {
|
|
5
4
|
|
|
@@ -41,11 +40,10 @@ const v8Report = async (reportData, reportOptions, options) => {
|
|
|
41
40
|
};
|
|
42
41
|
|
|
43
42
|
// compress json data for html
|
|
43
|
+
const { Assets } = await import('../assets.js');
|
|
44
44
|
const htmlPath = await Assets.saveHtmlReport(htmlOptions);
|
|
45
45
|
|
|
46
46
|
return htmlPath;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
v8Report
|
|
51
|
-
};
|
|
49
|
+
export { v8Report };
|
package/lib/utils/dedupe.js
CHANGED
package/lib/utils/gc.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
|
+
let collect;
|
|
1
2
|
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const createGC = () => {
|
|
4
|
+
const v8 = process.getBuiltinModule('v8');
|
|
5
|
+
const vm = process.getBuiltinModule('vm');
|
|
6
|
+
// The host may have replaced global.gc while leaving the flag enabled.
|
|
7
|
+
const existing = vm.runInNewContext('typeof gc === "function" ? gc : null');
|
|
8
|
+
if (existing) {
|
|
9
|
+
return existing;
|
|
10
|
+
}
|
|
11
|
+
v8.setFlagsFromString('--expose_gc');
|
|
12
|
+
try {
|
|
13
|
+
return vm.runInNewContext('gc');
|
|
14
|
+
} finally {
|
|
15
|
+
v8.setFlagsFromString('--no-expose_gc');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
5
18
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
// Importing MCR must not change V8 flags or install globals in the host process.
|
|
20
|
+
const gc = () => {
|
|
21
|
+
if (typeof globalThis.gc === 'function') {
|
|
22
|
+
return globalThis.gc();
|
|
23
|
+
}
|
|
24
|
+
if (!collect) {
|
|
25
|
+
if (typeof Bun !== 'undefined' && process.versions.bun) {
|
|
26
|
+
collect = () => Bun.gc(true);
|
|
27
|
+
} else {
|
|
28
|
+
collect = createGC();
|
|
29
|
+
}
|
|
15
30
|
}
|
|
16
|
-
|
|
31
|
+
return collect();
|
|
32
|
+
};
|
|
17
33
|
|
|
18
|
-
|
|
34
|
+
export { gc };
|
package/lib/utils/markdown.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import os from 'node:os';
|
|
2
2
|
|
|
3
3
|
const renderLine = (ls, padding) => {
|
|
4
4
|
const spacing = ''.padEnd(padding, ' ');
|
|
@@ -129,4 +129,4 @@ const markdownGrid = (data) => {
|
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
export { markdownGrid };
|
package/lib/utils/merge/merge.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* https://github.com/demurgos/v8-coverage
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { RangeTree } from './range-tree.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -430,6 +430,4 @@ function mergeV8Coverage(scriptCovs) {
|
|
|
430
430
|
return merged;
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
-
|
|
434
|
-
mergeV8Coverage
|
|
435
|
-
};
|
|
433
|
+
export { mergeV8Coverage };
|
package/lib/utils/request.js
CHANGED
|
@@ -1,86 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import https from 'node:https';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let rawData = '';
|
|
29
|
-
res.on('data', (chunk) => {
|
|
30
|
-
rawData += chunk;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
res.on('end', () => {
|
|
34
|
-
|
|
35
|
-
let dataErr;
|
|
36
|
-
let data = rawData;
|
|
37
|
-
|
|
38
|
-
// parse json
|
|
39
|
-
const contentType = res.headers['content-type'];
|
|
40
|
-
if ((/^application\/json/).test(contentType)) {
|
|
41
|
-
try {
|
|
42
|
-
data = JSON.parse(rawData);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
dataErr = e;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
res.data = data;
|
|
49
|
-
resolve([dataErr, res]);
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
}).on('error', (httpErr) => {
|
|
54
|
-
|
|
55
|
-
resolve([httpErr]);
|
|
4
|
+
const readResponse = async (res) => {
|
|
5
|
+
if (res.statusCode !== 200) {
|
|
6
|
+
res.destroy();
|
|
7
|
+
return [new Error(`Request Failed. Status Code: ${res.statusCode}`)];
|
|
8
|
+
}
|
|
9
|
+
res.setEncoding('utf8');
|
|
10
|
+
let rawData = '';
|
|
11
|
+
// Async iteration rejects on response errors and premature connection close.
|
|
12
|
+
for await (const chunk of res) {
|
|
13
|
+
rawData += chunk;
|
|
14
|
+
}
|
|
15
|
+
let dataErr;
|
|
16
|
+
let data = rawData;
|
|
17
|
+
if ((/^application\/json/).test(res.headers['content-type'])) {
|
|
18
|
+
try {
|
|
19
|
+
data = JSON.parse(rawData);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
dataErr = error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
res.data = data;
|
|
25
|
+
return [dataErr, res];
|
|
26
|
+
};
|
|
56
27
|
|
|
28
|
+
// Keep the existing [error, IncomingMessage] API and Node HTTP options.
|
|
29
|
+
// timeout is a total deadline (headers and body); 0 explicitly disables it.
|
|
30
|
+
const requestHTTP = (url, options) => new Promise((resolve) => {
|
|
31
|
+
const { timeout = 30000, ... requestOptions } = options;
|
|
32
|
+
const HTTP = url.startsWith('https:') ? https : http;
|
|
33
|
+
let req;
|
|
34
|
+
let timer;
|
|
35
|
+
let settled = false;
|
|
36
|
+
const finish = (result) => {
|
|
37
|
+
if (settled) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
settled = true;
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
resolve(result);
|
|
43
|
+
};
|
|
44
|
+
const fail = (error) => {
|
|
45
|
+
finish([error]);
|
|
46
|
+
req?.destroy();
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
req = HTTP.get(url, requestOptions, (res) => {
|
|
50
|
+
readResponse(res).then(finish, fail);
|
|
57
51
|
});
|
|
52
|
+
req.once('error', fail);
|
|
53
|
+
if (timeout > 0) {
|
|
54
|
+
timer = setTimeout(() => {
|
|
55
|
+
const error = new Error(`Request timed out after ${timeout}ms: ${url}`);
|
|
56
|
+
error.code = 'ETIMEDOUT';
|
|
57
|
+
fail(error);
|
|
58
|
+
}, timeout);
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
fail(error);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
const resolveRequestURL = (url, options) => {
|
|
66
|
+
const urlObj = new URL(url);
|
|
67
|
+
if (!['http:', 'https:'].includes(urlObj.protocol)) {
|
|
68
|
+
throw new TypeError(`Unsupported request protocol: ${urlObj.protocol}`);
|
|
69
|
+
}
|
|
70
|
+
const { timeout = 30000 } = options;
|
|
71
|
+
if (!Number.isFinite(timeout) || timeout < 0) {
|
|
72
|
+
throw new RangeError('Request timeout must be a non-negative finite number');
|
|
73
|
+
}
|
|
74
|
+
return urlObj;
|
|
60
75
|
};
|
|
61
76
|
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
const shouldRetryIPv4 = (err, urlObj, options) => err?.code === 'ECONNREFUSED'
|
|
78
|
+
&& urlObj.hostname === 'localhost' && !options.signal?.aborted;
|
|
79
|
+
|
|
80
|
+
const request = async (url, options = {}) => {
|
|
64
81
|
let urlObj;
|
|
65
82
|
try {
|
|
66
|
-
urlObj =
|
|
67
|
-
} catch (
|
|
68
|
-
|
|
69
|
-
urlErr = err;
|
|
83
|
+
urlObj = resolveRequestURL(url, options);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return [error];
|
|
70
86
|
}
|
|
71
87
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// replace localhost to 127.0.0.1
|
|
79
|
-
// ECONNREFUSED on NodeJS 18 https://github.com/node-fetch/node-fetch/issues/1624
|
|
80
|
-
if (urlObj.hostname === 'localhost') {
|
|
81
|
-
urlObj.hostname = '127.0.0.1';
|
|
82
|
-
return request(urlObj.toString(), options);
|
|
83
|
-
}
|
|
88
|
+
const [err, res] = await requestHTTP(urlObj.toString(), options);
|
|
89
|
+
// IPv4-only servers can reject localhost's IPv6 address on modern Node too.
|
|
90
|
+
// Do not repeat timeouts, aborts, HTTP failures or JSON parsing errors.
|
|
91
|
+
if (shouldRetryIPv4(err, urlObj, options)) {
|
|
92
|
+
urlObj.hostname = '127.0.0.1';
|
|
93
|
+
return requestHTTP(urlObj.toString(), options);
|
|
84
94
|
}
|
|
85
95
|
return [err, res];
|
|
86
96
|
};
|
|
97
|
+
|
|
98
|
+
export { request };
|
package/lib/utils/snapshot.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import CG from 'console-grid';
|
|
2
|
+
import EC from 'eight-colors';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { Util } from './util.js';
|
|
5
5
|
|
|
6
6
|
const mergeSingleSubGroups = (item) => {
|
|
7
7
|
|
|
@@ -341,7 +341,7 @@ const diffSnapshot = (oldData, newData, diffOptions) => {
|
|
|
341
341
|
};
|
|
342
342
|
};
|
|
343
343
|
|
|
344
|
-
|
|
344
|
+
export {
|
|
345
345
|
getGroupedRows,
|
|
346
346
|
getSnapshot,
|
|
347
347
|
diffSnapshot
|
package/lib/utils/source-path.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
+
import { Util } from './util.js';
|
|
5
5
|
|
|
6
6
|
const resolveSourceRootUrl = (sourceName, sourceRoot) => {
|
|
7
7
|
// prepend sourceRoot
|
|
@@ -241,7 +241,7 @@ const initSourceMapSourcesPath = (fileUrls, sourceMap, distFile, options) => {
|
|
|
241
241
|
|
|
242
242
|
};
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
export {
|
|
245
245
|
resolveAnonymousUrl,
|
|
246
246
|
normalizeSourcePath,
|
|
247
247
|
getSourceType,
|
package/lib/utils/util.js
CHANGED
|
@@ -1,23 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
findUpSync, supportsColor, minimatch
|
|
20
|
-
}
|
|
1
|
+
import packageMetadata from '../../package.json' with { type: 'json' };
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { writeFile, readFile } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import crypto from 'node:crypto';
|
|
7
|
+
|
|
8
|
+
import EC from 'eight-colors';
|
|
9
|
+
import CG from 'console-grid';
|
|
10
|
+
import * as acornWalk from 'acorn-walk';
|
|
11
|
+
|
|
12
|
+
import { Util as Share } from '../platform/share.js';
|
|
13
|
+
import { request } from './request.js';
|
|
14
|
+
import { markdownGrid } from './markdown.js';
|
|
15
|
+
import { mergeV8Coverage } from './merge/merge.js';
|
|
16
|
+
import { gc } from './gc.js';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
findUpSync, supportsColor, minimatch, Minimatch
|
|
20
|
+
} from '../packages/monocart-coverage-vendor.js';
|
|
21
|
+
|
|
22
|
+
const version = packageMetadata.version;
|
|
23
|
+
|
|
24
|
+
// Compile lazily: substring matches need no glob, and invalid patterns should
|
|
25
|
+
// only fail when the old matcher would actually have evaluated them.
|
|
26
|
+
const createPatternMatcher = (pattern) => {
|
|
27
|
+
let matcher;
|
|
28
|
+
const match = (value) => {
|
|
29
|
+
matcher ||= new Minimatch(pattern);
|
|
30
|
+
return matcher.match(value);
|
|
31
|
+
};
|
|
32
|
+
return (value) => Util.betterMinimatch(value, pattern, match);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getMemoryAfterGC = () => {
|
|
36
|
+
const memory = Util.getMemory();
|
|
37
|
+
if (Util.gcThreshold && Util.gcThreshold < memory) {
|
|
38
|
+
Util.forceGC();
|
|
39
|
+
return Util.getMemory();
|
|
40
|
+
}
|
|
41
|
+
return memory;
|
|
42
|
+
};
|
|
21
43
|
|
|
22
44
|
// https://github.com/chalk/supports-color
|
|
23
45
|
// disabled color if Terminal stdout does not support color
|
|
@@ -185,7 +207,7 @@ const Util = {
|
|
|
185
207
|
};
|
|
186
208
|
},
|
|
187
209
|
|
|
188
|
-
betterMinimatch: (str, pattern) => {
|
|
210
|
+
betterMinimatch: (str, pattern, match = (value) => minimatch(value, pattern)) => {
|
|
189
211
|
str = `${str}`;
|
|
190
212
|
pattern = `${pattern}`;
|
|
191
213
|
|
|
@@ -199,7 +221,7 @@ const Util = {
|
|
|
199
221
|
}
|
|
200
222
|
|
|
201
223
|
// with minimatch
|
|
202
|
-
if (
|
|
224
|
+
if (match(str)) {
|
|
203
225
|
return true;
|
|
204
226
|
}
|
|
205
227
|
|
|
@@ -210,7 +232,7 @@ const Util = {
|
|
|
210
232
|
return true;
|
|
211
233
|
}
|
|
212
234
|
|
|
213
|
-
if (
|
|
235
|
+
if (match(str)) {
|
|
214
236
|
return true;
|
|
215
237
|
}
|
|
216
238
|
|
|
@@ -229,19 +251,18 @@ const Util = {
|
|
|
229
251
|
if (obj) {
|
|
230
252
|
input = obj;
|
|
231
253
|
} else {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
};
|
|
254
|
+
const match = createPatternMatcher(input);
|
|
255
|
+
return (item) => match(fieldAccessor(item));
|
|
235
256
|
}
|
|
236
257
|
}
|
|
237
258
|
|
|
238
259
|
// for patterns
|
|
239
260
|
if (input && typeof input === 'object') {
|
|
240
|
-
const patterns = Object.keys(input);
|
|
261
|
+
const patterns = Object.keys(input).map((pattern) => [pattern, createPatternMatcher(pattern)]);
|
|
241
262
|
return (item) => {
|
|
242
263
|
const value = fieldAccessor(item);
|
|
243
|
-
for (const pattern of patterns) {
|
|
244
|
-
if (
|
|
264
|
+
for (const [pattern, match] of patterns) {
|
|
265
|
+
if (match(value)) {
|
|
245
266
|
return input[pattern];
|
|
246
267
|
}
|
|
247
268
|
}
|
|
@@ -426,11 +447,12 @@ const Util = {
|
|
|
426
447
|
}
|
|
427
448
|
};
|
|
428
449
|
|
|
429
|
-
const list = fs.readdirSync(dir
|
|
430
|
-
|
|
450
|
+
const list = fs.readdirSync(dir, {
|
|
451
|
+
withFileTypes: true
|
|
452
|
+
});
|
|
453
|
+
for (const info of list) {
|
|
454
|
+
const { name } = info;
|
|
431
455
|
const abs = path.resolve(dir, name);
|
|
432
|
-
|
|
433
|
-
const info = fs.lstatSync(abs);
|
|
434
456
|
if (info.isSymbolicLink()) {
|
|
435
457
|
continue;
|
|
436
458
|
}
|
|
@@ -879,20 +901,18 @@ const Util = {
|
|
|
879
901
|
// time is debug level, fix the log info, for checking snapshot
|
|
880
902
|
logTime: (message, time_start) => {
|
|
881
903
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
Util.forceGC();
|
|
904
|
+
const logEnabled = Util.loggingLevel >= Util.loggingLevels.debug || Boolean(process.env.MCR_LOG_TIME);
|
|
905
|
+
if (!logEnabled && !Util.gcThreshold) {
|
|
906
|
+
return;
|
|
886
907
|
}
|
|
887
|
-
|
|
888
|
-
if (
|
|
908
|
+
const memory = getMemoryAfterGC();
|
|
909
|
+
if (!logEnabled) {
|
|
889
910
|
return;
|
|
890
911
|
}
|
|
891
912
|
const duration = Date.now() - time_start;
|
|
892
913
|
const durationH = Util.TF(duration);
|
|
893
914
|
const ls = [`[MCR] ${message}`];
|
|
894
915
|
|
|
895
|
-
memory = Util.getMemory();
|
|
896
916
|
ls.push(` (memory: ${memory}MB)`);
|
|
897
917
|
|
|
898
918
|
// time
|
|
@@ -911,4 +931,4 @@ const Util = {
|
|
|
911
931
|
|
|
912
932
|
};
|
|
913
933
|
|
|
914
|
-
|
|
934
|
+
export { Util };
|
package/lib/v8/v8-summary.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Util } from '../utils/util.js';
|
|
2
2
|
|
|
3
3
|
// both css and js
|
|
4
4
|
const getV8SummaryBytes = (item) => {
|
|
@@ -133,6 +133,4 @@ const getV8Summary = (v8list, watermarks) => {
|
|
|
133
133
|
return summary;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
getV8Summary
|
|
138
|
-
};
|
|
136
|
+
export { getV8Summary };
|
package/lib/v8/v8.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import EC from 'eight-colors';
|
|
2
|
+
import { Util } from '../utils/util.js';
|
|
3
|
+
import { getV8Summary } from './v8-summary.js';
|
|
4
|
+
import { dedupeFlatRanges } from '../utils/dedupe.js';
|
|
5
|
+
import {
|
|
6
6
|
resolveAnonymousUrl, normalizeSourcePath, getSourcePathReplacer
|
|
7
|
-
}
|
|
8
|
-
|
|
7
|
+
} from '../utils/source-path.js';
|
|
8
|
+
import { collectSourceMaps } from '../converter/collect-source-maps.js';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import { v8Report } from '../reports/v8.js';
|
|
11
|
+
import { v8JsonReport } from '../reports/v8-json.js';
|
|
12
|
+
import { customReport } from '../reports/custom.js';
|
|
13
13
|
|
|
14
14
|
const getWrapperSource = (offset, source) => {
|
|
15
15
|
// NO \n because it break line number in mappings
|
|
@@ -334,7 +334,7 @@ const saveV8Report = async (v8list, options, istanbulReportPath) => {
|
|
|
334
334
|
return coverageResults;
|
|
335
335
|
};
|
|
336
336
|
|
|
337
|
-
|
|
337
|
+
export {
|
|
338
338
|
initV8ListAndSourcemap,
|
|
339
339
|
mergeV8DataList,
|
|
340
340
|
mergeV8Coverage,
|