@plugjs/cov8 0.6.116 → 0.7.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/dist/analysis.d.ts +1 -0
- package/dist/analysis.d.ts.map +1 -0
- package/dist/analysis.js +264 -0
- package/dist/analysis.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +197 -0
- package/dist/cli.js.map +1 -0
- package/dist/coverage.d.ts +1 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/coverage.js +130 -0
- package/dist/coverage.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/report.d.ts +2 -1
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +288 -0
- package/dist/report.js.map +1 -0
- package/package.json +14 -24
- package/src/analysis.ts +3 -3
- package/src/{cli.mts → cli.ts} +20 -8
- package/src/coverage.ts +4 -4
- package/src/index.ts +2 -2
- package/src/report.ts +1 -1
- package/dist/analysis.cjs +0 -241
- package/dist/analysis.cjs.map +0 -6
- package/dist/analysis.mjs +0 -214
- package/dist/analysis.mjs.map +0 -6
- package/dist/cli.d.mts +0 -2
- package/dist/cli.mjs +0 -168
- package/dist/cli.mjs.map +0 -6
- package/dist/coverage.cjs +0 -150
- package/dist/coverage.cjs.map +0 -6
- package/dist/coverage.mjs +0 -125
- package/dist/coverage.mjs.map +0 -6
- package/dist/index.cjs +0 -22
- package/dist/index.cjs.map +0 -6
- package/dist/index.mjs +0 -5
- package/dist/index.mjs.map +0 -6
- package/dist/report.cjs +0 -236
- package/dist/report.cjs.map +0 -6
- package/dist/report.mjs +0 -221
- package/dist/report.mjs.map +0 -6
package/dist/coverage.cjs
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// coverage.ts
|
|
21
|
-
var coverage_exports = {};
|
|
22
|
-
__export(coverage_exports, {
|
|
23
|
-
Coverage: () => Coverage
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(coverage_exports);
|
|
26
|
-
var import_node_path = require("node:path");
|
|
27
|
-
var import_cov8_html = require("@plugjs/cov8-html");
|
|
28
|
-
var import_asserts = require("@plugjs/plug/asserts");
|
|
29
|
-
var import_files = require("@plugjs/plug/files");
|
|
30
|
-
var import_logging = require("@plugjs/plug/logging");
|
|
31
|
-
var import_paths = require("@plugjs/plug/paths");
|
|
32
|
-
var import_utils = require("@plugjs/plug/utils");
|
|
33
|
-
var import_analysis = require("./analysis.cjs");
|
|
34
|
-
var import_report = require("./report.cjs");
|
|
35
|
-
var Coverage = class {
|
|
36
|
-
constructor(_coverageDir, _options = {}) {
|
|
37
|
-
this._coverageDir = _coverageDir;
|
|
38
|
-
this._options = _options;
|
|
39
|
-
}
|
|
40
|
-
_coverageDir;
|
|
41
|
-
_options;
|
|
42
|
-
async pipe(files, context) {
|
|
43
|
-
const coverageDir = context.resolve(this._coverageDir);
|
|
44
|
-
const coverageFiles = [];
|
|
45
|
-
for await (const file of (0, import_utils.walk)(coverageDir, ["coverage-*.json"])) {
|
|
46
|
-
coverageFiles.push((0, import_paths.resolveAbsolutePath)(coverageDir, file));
|
|
47
|
-
}
|
|
48
|
-
(0, import_asserts.assert)(coverageFiles.length > 0, `No coverage files found in ${(0, import_logging.$p)(coverageDir)}`);
|
|
49
|
-
const sourceFiles = [...files.absolutePaths()];
|
|
50
|
-
const ms1 = Date.now();
|
|
51
|
-
const analyser = await (0, import_analysis.createAnalyser)(
|
|
52
|
-
sourceFiles,
|
|
53
|
-
coverageFiles,
|
|
54
|
-
this._options.sourceMapBias || "least_upper_bound",
|
|
55
|
-
context.log
|
|
56
|
-
);
|
|
57
|
-
context.log.info("Parsed", coverageFiles.length, "coverage files", (0, import_logging.$ms)(Date.now() - ms1));
|
|
58
|
-
const ms2 = Date.now();
|
|
59
|
-
const report = await (0, import_report.coverageReport)(analyser, sourceFiles, context.log);
|
|
60
|
-
context.log.info("Analysed", sourceFiles.length, "source files", (0, import_logging.$ms)(Date.now() - ms2));
|
|
61
|
-
analyser.destroy();
|
|
62
|
-
const {
|
|
63
|
-
minimumCoverage = 50,
|
|
64
|
-
minimumFileCoverage = minimumCoverage,
|
|
65
|
-
optimalCoverage = Math.round((100 + minimumCoverage) / 2),
|
|
66
|
-
optimalFileCoverage = Math.round((100 + minimumFileCoverage) / 2)
|
|
67
|
-
} = this._options;
|
|
68
|
-
let max = 0;
|
|
69
|
-
for (const file in report) {
|
|
70
|
-
if (file.length > max) max = file.length;
|
|
71
|
-
}
|
|
72
|
-
let maxLength = 0;
|
|
73
|
-
for (const file in report.results) {
|
|
74
|
-
if (file.length > maxLength) maxLength = file.length;
|
|
75
|
-
}
|
|
76
|
-
let fileErrors = 0;
|
|
77
|
-
let fileWarnings = 0;
|
|
78
|
-
const _report = context.log.report("Coverage report");
|
|
79
|
-
for (const [_file, result] of Object.entries(report.results)) {
|
|
80
|
-
const { coverage } = result.nodeCoverage;
|
|
81
|
-
const file = _file;
|
|
82
|
-
if (coverage == null) {
|
|
83
|
-
_report.annotate(import_logging.NOTICE, file, "n/a");
|
|
84
|
-
} else if (coverage < minimumFileCoverage) {
|
|
85
|
-
_report.annotate(import_logging.ERROR, file, `${coverage} %`);
|
|
86
|
-
fileErrors++;
|
|
87
|
-
} else if (coverage < optimalFileCoverage) {
|
|
88
|
-
_report.annotate(import_logging.WARN, file, `${coverage} %`);
|
|
89
|
-
fileWarnings++;
|
|
90
|
-
} else {
|
|
91
|
-
_report.annotate(import_logging.NOTICE, file, `${coverage} %`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (report.nodes.coverage == null) {
|
|
95
|
-
const message = "No coverage data collected";
|
|
96
|
-
_report.add({ level: import_logging.WARN, message });
|
|
97
|
-
} else if (report.nodes.coverage < minimumCoverage) {
|
|
98
|
-
const message = `${(0, import_logging.$red)(`${report.nodes.coverage}%`)} does not meet minimum coverage ${(0, import_logging.$gry)(`(${minimumCoverage}%)`)}`;
|
|
99
|
-
_report.add({ level: import_logging.ERROR, message });
|
|
100
|
-
} else if (report.nodes.coverage < optimalCoverage) {
|
|
101
|
-
const message = `${(0, import_logging.$ylw)(`${report.nodes.coverage}%`)} does not meet optimal coverage ${(0, import_logging.$gry)(`(${optimalCoverage}%)`)}`;
|
|
102
|
-
_report.add({ level: import_logging.WARN, message });
|
|
103
|
-
}
|
|
104
|
-
if (fileErrors) {
|
|
105
|
-
const f = (0, import_logging.$plur)(fileErrors, "file does", "files do");
|
|
106
|
-
const message = `${f} not meet minimum file coverage ${(0, import_logging.$gry)(`(${minimumFileCoverage}%)`)}`;
|
|
107
|
-
_report.add({ level: import_logging.ERROR, message });
|
|
108
|
-
}
|
|
109
|
-
if (fileWarnings) {
|
|
110
|
-
const f = (0, import_logging.$plur)(fileWarnings, "file does", "files do");
|
|
111
|
-
const message = `${f} not meet optimal file coverage ${(0, import_logging.$gry)(`(${optimalFileCoverage}%)`)}`;
|
|
112
|
-
_report.add({ level: import_logging.WARN, message });
|
|
113
|
-
}
|
|
114
|
-
if (this._options.reportDir == null) return _report.done(false);
|
|
115
|
-
const reportDir = context.resolve(this._options.reportDir);
|
|
116
|
-
const builder = import_files.Files.builder(reportDir);
|
|
117
|
-
const date = (/* @__PURE__ */ new Date()).toISOString();
|
|
118
|
-
const thresholds = {
|
|
119
|
-
minimumCoverage,
|
|
120
|
-
minimumFileCoverage,
|
|
121
|
-
optimalCoverage,
|
|
122
|
-
optimalFileCoverage
|
|
123
|
-
};
|
|
124
|
-
await builder.write("report.json", JSON.stringify({ ...report, thresholds, date }));
|
|
125
|
-
await builder.write("index.html", import_cov8_html.html);
|
|
126
|
-
const results = {};
|
|
127
|
-
for (const [rel, abs] of files.pathMappings()) {
|
|
128
|
-
results[rel] = report.results[abs];
|
|
129
|
-
}
|
|
130
|
-
const tree = {};
|
|
131
|
-
for (const relative of Object.keys(results)) {
|
|
132
|
-
const directories = relative.split(import_node_path.sep);
|
|
133
|
-
const file = directories.pop();
|
|
134
|
-
let node = tree;
|
|
135
|
-
for (const dir of directories) {
|
|
136
|
-
node = node[dir] = node[dir] || {};
|
|
137
|
-
}
|
|
138
|
-
node[file] = relative;
|
|
139
|
-
}
|
|
140
|
-
const jsonp = JSON.stringify({ ...report, results, thresholds, tree, date });
|
|
141
|
-
await builder.write("report.js", `${import_cov8_html.initFunction}(${jsonp});`);
|
|
142
|
-
_report.done(false);
|
|
143
|
-
return builder.build();
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
-
0 && (module.exports = {
|
|
148
|
-
Coverage
|
|
149
|
-
});
|
|
150
|
-
//# sourceMappingURL=coverage.cjs.map
|
package/dist/coverage.cjs.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/coverage.ts"],
|
|
4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AAG,KAAK,CAAC;AAAA,MACnC;AAEA,WAAK,IAAI,IAAI;AAAA,IACf;AAEA,UAAM,QAAQ,KAAK,UAAU,EAAE,GAAG,QAAQ,SAAS,YAAY,MAAM,KAAK,CAAC;AAC3E,UAAM,QAAQ,MAAM,aAAa,GAAG,6BAAY,IAAI,KAAK,IAAI;AAG7D,YAAQ,KAAK,KAAK;AAGlB,WAAO,QAAQ,MAAM;AAAA,EACvB;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/coverage.mjs
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
// coverage.ts
|
|
2
|
-
import { sep } from "node:path";
|
|
3
|
-
import { html, initFunction } from "@plugjs/cov8-html";
|
|
4
|
-
import { assert } from "@plugjs/plug/asserts";
|
|
5
|
-
import { Files } from "@plugjs/plug/files";
|
|
6
|
-
import { $gry, $ms, $p, $plur, $red, $ylw, ERROR, NOTICE, WARN } from "@plugjs/plug/logging";
|
|
7
|
-
import { resolveAbsolutePath } from "@plugjs/plug/paths";
|
|
8
|
-
import { walk } from "@plugjs/plug/utils";
|
|
9
|
-
import { createAnalyser } from "./analysis.mjs";
|
|
10
|
-
import { coverageReport } from "./report.mjs";
|
|
11
|
-
var Coverage = class {
|
|
12
|
-
constructor(_coverageDir, _options = {}) {
|
|
13
|
-
this._coverageDir = _coverageDir;
|
|
14
|
-
this._options = _options;
|
|
15
|
-
}
|
|
16
|
-
_coverageDir;
|
|
17
|
-
_options;
|
|
18
|
-
async pipe(files, context) {
|
|
19
|
-
const coverageDir = context.resolve(this._coverageDir);
|
|
20
|
-
const coverageFiles = [];
|
|
21
|
-
for await (const file of walk(coverageDir, ["coverage-*.json"])) {
|
|
22
|
-
coverageFiles.push(resolveAbsolutePath(coverageDir, file));
|
|
23
|
-
}
|
|
24
|
-
assert(coverageFiles.length > 0, `No coverage files found in ${$p(coverageDir)}`);
|
|
25
|
-
const sourceFiles = [...files.absolutePaths()];
|
|
26
|
-
const ms1 = Date.now();
|
|
27
|
-
const analyser = await createAnalyser(
|
|
28
|
-
sourceFiles,
|
|
29
|
-
coverageFiles,
|
|
30
|
-
this._options.sourceMapBias || "least_upper_bound",
|
|
31
|
-
context.log
|
|
32
|
-
);
|
|
33
|
-
context.log.info("Parsed", coverageFiles.length, "coverage files", $ms(Date.now() - ms1));
|
|
34
|
-
const ms2 = Date.now();
|
|
35
|
-
const report = await coverageReport(analyser, sourceFiles, context.log);
|
|
36
|
-
context.log.info("Analysed", sourceFiles.length, "source files", $ms(Date.now() - ms2));
|
|
37
|
-
analyser.destroy();
|
|
38
|
-
const {
|
|
39
|
-
minimumCoverage = 50,
|
|
40
|
-
minimumFileCoverage = minimumCoverage,
|
|
41
|
-
optimalCoverage = Math.round((100 + minimumCoverage) / 2),
|
|
42
|
-
optimalFileCoverage = Math.round((100 + minimumFileCoverage) / 2)
|
|
43
|
-
} = this._options;
|
|
44
|
-
let max = 0;
|
|
45
|
-
for (const file in report) {
|
|
46
|
-
if (file.length > max) max = file.length;
|
|
47
|
-
}
|
|
48
|
-
let maxLength = 0;
|
|
49
|
-
for (const file in report.results) {
|
|
50
|
-
if (file.length > maxLength) maxLength = file.length;
|
|
51
|
-
}
|
|
52
|
-
let fileErrors = 0;
|
|
53
|
-
let fileWarnings = 0;
|
|
54
|
-
const _report = context.log.report("Coverage report");
|
|
55
|
-
for (const [_file, result] of Object.entries(report.results)) {
|
|
56
|
-
const { coverage } = result.nodeCoverage;
|
|
57
|
-
const file = _file;
|
|
58
|
-
if (coverage == null) {
|
|
59
|
-
_report.annotate(NOTICE, file, "n/a");
|
|
60
|
-
} else if (coverage < minimumFileCoverage) {
|
|
61
|
-
_report.annotate(ERROR, file, `${coverage} %`);
|
|
62
|
-
fileErrors++;
|
|
63
|
-
} else if (coverage < optimalFileCoverage) {
|
|
64
|
-
_report.annotate(WARN, file, `${coverage} %`);
|
|
65
|
-
fileWarnings++;
|
|
66
|
-
} else {
|
|
67
|
-
_report.annotate(NOTICE, file, `${coverage} %`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (report.nodes.coverage == null) {
|
|
71
|
-
const message = "No coverage data collected";
|
|
72
|
-
_report.add({ level: WARN, message });
|
|
73
|
-
} else if (report.nodes.coverage < minimumCoverage) {
|
|
74
|
-
const message = `${$red(`${report.nodes.coverage}%`)} does not meet minimum coverage ${$gry(`(${minimumCoverage}%)`)}`;
|
|
75
|
-
_report.add({ level: ERROR, message });
|
|
76
|
-
} else if (report.nodes.coverage < optimalCoverage) {
|
|
77
|
-
const message = `${$ylw(`${report.nodes.coverage}%`)} does not meet optimal coverage ${$gry(`(${optimalCoverage}%)`)}`;
|
|
78
|
-
_report.add({ level: WARN, message });
|
|
79
|
-
}
|
|
80
|
-
if (fileErrors) {
|
|
81
|
-
const f = $plur(fileErrors, "file does", "files do");
|
|
82
|
-
const message = `${f} not meet minimum file coverage ${$gry(`(${minimumFileCoverage}%)`)}`;
|
|
83
|
-
_report.add({ level: ERROR, message });
|
|
84
|
-
}
|
|
85
|
-
if (fileWarnings) {
|
|
86
|
-
const f = $plur(fileWarnings, "file does", "files do");
|
|
87
|
-
const message = `${f} not meet optimal file coverage ${$gry(`(${optimalFileCoverage}%)`)}`;
|
|
88
|
-
_report.add({ level: WARN, message });
|
|
89
|
-
}
|
|
90
|
-
if (this._options.reportDir == null) return _report.done(false);
|
|
91
|
-
const reportDir = context.resolve(this._options.reportDir);
|
|
92
|
-
const builder = Files.builder(reportDir);
|
|
93
|
-
const date = (/* @__PURE__ */ new Date()).toISOString();
|
|
94
|
-
const thresholds = {
|
|
95
|
-
minimumCoverage,
|
|
96
|
-
minimumFileCoverage,
|
|
97
|
-
optimalCoverage,
|
|
98
|
-
optimalFileCoverage
|
|
99
|
-
};
|
|
100
|
-
await builder.write("report.json", JSON.stringify({ ...report, thresholds, date }));
|
|
101
|
-
await builder.write("index.html", html);
|
|
102
|
-
const results = {};
|
|
103
|
-
for (const [rel, abs] of files.pathMappings()) {
|
|
104
|
-
results[rel] = report.results[abs];
|
|
105
|
-
}
|
|
106
|
-
const tree = {};
|
|
107
|
-
for (const relative of Object.keys(results)) {
|
|
108
|
-
const directories = relative.split(sep);
|
|
109
|
-
const file = directories.pop();
|
|
110
|
-
let node = tree;
|
|
111
|
-
for (const dir of directories) {
|
|
112
|
-
node = node[dir] = node[dir] || {};
|
|
113
|
-
}
|
|
114
|
-
node[file] = relative;
|
|
115
|
-
}
|
|
116
|
-
const jsonp = JSON.stringify({ ...report, results, thresholds, tree, date });
|
|
117
|
-
await builder.write("report.js", `${initFunction}(${jsonp});`);
|
|
118
|
-
_report.done(false);
|
|
119
|
-
return builder.build();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
export {
|
|
123
|
-
Coverage
|
|
124
|
-
};
|
|
125
|
-
//# sourceMappingURL=coverage.mjs.map
|
package/dist/coverage.mjs.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/coverage.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,WAAW;AAEpB,SAAS,MAAM,oBAAoB;AACnC,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,MAAM,KAAK,IAAI,OAAO,MAAM,MAAM,OAAO,QAAQ,YAAY;AACtE,SAAS,2BAA2B;AACpC,SAAS,YAAY;AAErB,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAOxB,IAAM,WAAN,MAAkD;AAAA,EAEvD,YACqB,cACA,WAA2C,CAAC,GAC/D;AAFmB;AACA;AAAA,EAClB;AAAA,EAFkB;AAAA,EACA;AAAA,EAGrB,MAAM,KAAK,OAAc,SAA8C;AACrE,UAAM,cAAc,QAAQ,QAAQ,KAAK,YAAY;AACrD,UAAM,gBAAgC,CAAC;AACvC,qBAAiB,QAAQ,KAAK,aAAa,CAAE,iBAAkB,CAAC,GAAG;AACjE,oBAAc,KAAK,oBAAoB,aAAa,IAAI,CAAC;AAAA,IAC3D;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KAAK,SAAS,SAAS;AACzD,UAAM,UAAU,MAAM,QAAQ,SAAS;AAGvC,UAAM,QAAO,oBAAI,KAAK,GAAE,YAAY;AACpC,UAAM,aAAa;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAGA,UAAM,QAAQ,MAAM,eAAe,KAAK,UAAU,EAAE,GAAG,QAAQ,YAAY,KAAK,CAAC,CAAC;AAGlF,UAAM,QAAQ,MAAM,cAAc,IAAI;AAGtC,UAAM,UAA0C,CAAC;AACjD,eAAW,CAAE,KAAK,GAAI,KAAK,MAAM,aAAa,GAAG;AAC/C,cAAQ,GAAG,IAAI,OAAO,QAAQ,GAAG;AAAA,IACnC;AAEA,UAAM,OAA4B,CAAC;AACnC,eAAW,YAAY,OAAO,KAAK,OAAO,GAAG;AAC3C,YAAM,cAAc,SAAS,MAAM,GAAG;AACtC,YAAM,OAAO,YAAY,IAAI;AAE7B,UAAI,OAAO;AACX,iBAAW,OAAO,aAAa;AAC7B,eAAO,KAAK,GAAG,IAAI,KAAK,GAAG,KAAK,CAAC;AAAA,MACnC;AAEA,WAAK,IAAI,IAAI;AAAA,IACf;AAEA,UAAM,QAAQ,KAAK,UAAU,EAAE,GAAG,QAAQ,SAAS,YAAY,MAAM,KAAK,CAAC;AAC3E,UAAM,QAAQ,MAAM,aAAa,GAAG,YAAY,IAAI,KAAK,IAAI;AAG7D,YAAQ,KAAK,KAAK;AAGlB,WAAO,QAAQ,MAAM;AAAA,EACvB;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/index.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// index.ts
|
|
17
|
-
var index_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(index_exports);
|
|
19
|
-
var import_pipe = require("@plugjs/plug/pipe");
|
|
20
|
-
var import_coverage = require("./coverage.cjs");
|
|
21
|
-
(0, import_pipe.install)("coverage", import_coverage.Coverage);
|
|
22
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
package/dist/index.mjs
DELETED
package/dist/index.mjs.map
DELETED
package/dist/report.cjs
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// report.ts
|
|
21
|
-
var report_exports = {};
|
|
22
|
-
__export(report_exports, {
|
|
23
|
-
COVERAGE_IGNORED: () => COVERAGE_IGNORED,
|
|
24
|
-
COVERAGE_SKIPPED: () => COVERAGE_SKIPPED,
|
|
25
|
-
coverageReport: () => coverageReport
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(report_exports);
|
|
28
|
-
var import_node_url = require("node:url");
|
|
29
|
-
var import_parser = require("@babel/parser");
|
|
30
|
-
var import_types = require("@babel/types");
|
|
31
|
-
var import_fs = require("@plugjs/plug/fs");
|
|
32
|
-
var import_logging = require("@plugjs/plug/logging");
|
|
33
|
-
var COVERAGE_SKIPPED = -2;
|
|
34
|
-
var COVERAGE_IGNORED = -1;
|
|
35
|
-
var ignoreRegexp = /^\s+(coverage|istanbul)\s+ignore\s+(test|if|else|try|catch|finally|next|prev|file)(\s|$)/g;
|
|
36
|
-
async function coverageReport(analyser, sourceFiles, log) {
|
|
37
|
-
const results = {};
|
|
38
|
-
const nodes = {
|
|
39
|
-
coveredNodes: 0,
|
|
40
|
-
missingNodes: 0,
|
|
41
|
-
ignoredNodes: 0,
|
|
42
|
-
totalNodes: 0,
|
|
43
|
-
coverage: 0
|
|
44
|
-
};
|
|
45
|
-
for (const file of sourceFiles) {
|
|
46
|
-
const url = (0, import_node_url.pathToFileURL)(file).toString();
|
|
47
|
-
const code = await (0, import_fs.readFile)(file, "utf-8");
|
|
48
|
-
let tree;
|
|
49
|
-
try {
|
|
50
|
-
tree = (0, import_parser.parse)(code, {
|
|
51
|
-
allowImportExportEverywhere: true,
|
|
52
|
-
allowAwaitOutsideFunction: true,
|
|
53
|
-
allowReturnOutsideFunction: true,
|
|
54
|
-
allowSuperOutsideMethod: true,
|
|
55
|
-
allowUndeclaredExports: true,
|
|
56
|
-
attachComment: true,
|
|
57
|
-
errorRecovery: false,
|
|
58
|
-
sourceType: "unambiguous",
|
|
59
|
-
sourceFilename: file,
|
|
60
|
-
startLine: 1,
|
|
61
|
-
startColumn: 0,
|
|
62
|
-
plugins: ["typescript", "decorators"],
|
|
63
|
-
strictMode: false,
|
|
64
|
-
ranges: false,
|
|
65
|
-
tokens: false,
|
|
66
|
-
createParenthesizedExpressions: true
|
|
67
|
-
});
|
|
68
|
-
} catch (error) {
|
|
69
|
-
log.fail(`Error parsing ${(0, import_logging.$p)(file)}`, error);
|
|
70
|
-
}
|
|
71
|
-
const codeCoverage = new Array(code.length).fill(0);
|
|
72
|
-
const nodeCoverage = {
|
|
73
|
-
coveredNodes: 0,
|
|
74
|
-
missingNodes: 0,
|
|
75
|
-
ignoredNodes: 0,
|
|
76
|
-
totalNodes: 0,
|
|
77
|
-
coverage: 0
|
|
78
|
-
};
|
|
79
|
-
const setCodeCoverage = (node, coverage, recursive) => {
|
|
80
|
-
if (!node) return;
|
|
81
|
-
if (Array.isArray(node)) {
|
|
82
|
-
for (const n of node) setCodeCoverage(n, coverage, recursive);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (node.start != null && node.end != null) {
|
|
86
|
-
for (let i = node.start; i < node.end; i++) {
|
|
87
|
-
codeCoverage[i] = coverage;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (coverage == COVERAGE_IGNORED) {
|
|
91
|
-
nodeCoverage.ignoredNodes++;
|
|
92
|
-
} else if (coverage === 0) {
|
|
93
|
-
nodeCoverage.missingNodes++;
|
|
94
|
-
} else if (coverage > 0) {
|
|
95
|
-
nodeCoverage.coveredNodes++;
|
|
96
|
-
}
|
|
97
|
-
if (!recursive) return;
|
|
98
|
-
const keys = import_types.VISITOR_KEYS[node.type] || /* coverage ignore next */
|
|
99
|
-
[];
|
|
100
|
-
for (const key of keys) {
|
|
101
|
-
const value = node[key];
|
|
102
|
-
if (Array.isArray(value)) {
|
|
103
|
-
for (const child of value) {
|
|
104
|
-
setCodeCoverage(child, coverage, true);
|
|
105
|
-
}
|
|
106
|
-
} else if (value) {
|
|
107
|
-
setCodeCoverage(value, coverage, true);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const visitChildren = (node, depth) => {
|
|
112
|
-
const keys = import_types.VISITOR_KEYS[node.type] || /* coverage ignore next */
|
|
113
|
-
[];
|
|
114
|
-
for (const key of keys) {
|
|
115
|
-
const children = node[key];
|
|
116
|
-
if (Array.isArray(children)) {
|
|
117
|
-
for (const child of children) {
|
|
118
|
-
if (child) visitNode(child, depth + 1);
|
|
119
|
-
}
|
|
120
|
-
} else if (children) {
|
|
121
|
-
visitNode(children, depth + 1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const maybeIgnoreNode = (condition, node, depth) => {
|
|
126
|
-
if (condition) {
|
|
127
|
-
setCodeCoverage(node, COVERAGE_IGNORED, true);
|
|
128
|
-
} else if (node) {
|
|
129
|
-
visitNode(node, depth);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const visitNode = (node, depth) => {
|
|
133
|
-
log.trace("-".padStart(depth * 2 + 1, " "), node.type, `${node.loc?.start.line}:${node.loc?.start.column}`);
|
|
134
|
-
if ((0, import_types.isFile)(node)) return visitChildren(node, depth);
|
|
135
|
-
if ((0, import_types.isProgram)(node)) return visitChildren(node, depth);
|
|
136
|
-
const ignores = [];
|
|
137
|
-
for (const comment of node.leadingComments || []) {
|
|
138
|
-
for (const match of comment.value.matchAll(ignoreRegexp)) {
|
|
139
|
-
if (match[2] !== "prev") ignores.push(match[2]);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
for (const comment of node.trailingComments || []) {
|
|
143
|
-
for (const match of comment.value.matchAll(ignoreRegexp)) {
|
|
144
|
-
if (match[2] === "prev") ignores.push(match[2]);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (ignores.includes("next")) return setCodeCoverage(node, COVERAGE_IGNORED, true);
|
|
148
|
-
if (ignores.includes("prev")) return setCodeCoverage(node, COVERAGE_IGNORED, true);
|
|
149
|
-
if ((0, import_types.isTypeScript)(node)) {
|
|
150
|
-
if ((0, import_types.isTSDeclareMethod)(node)) return setCodeCoverage(node, COVERAGE_SKIPPED, true);
|
|
151
|
-
if ((0, import_types.isTSTypeReference)(node)) return setCodeCoverage(node, COVERAGE_SKIPPED, true);
|
|
152
|
-
if ((0, import_types.isDeclaration)(node)) return setCodeCoverage(node, COVERAGE_SKIPPED, true);
|
|
153
|
-
setCodeCoverage(node, COVERAGE_SKIPPED, false);
|
|
154
|
-
return visitChildren(node, depth);
|
|
155
|
-
}
|
|
156
|
-
if ((0, import_types.isExportDeclaration)(node) && node.exportKind === "type") {
|
|
157
|
-
return setCodeCoverage(node, COVERAGE_SKIPPED, true);
|
|
158
|
-
}
|
|
159
|
-
if ((0, import_types.isImportDeclaration)(node) && node.importKind === "type") {
|
|
160
|
-
return setCodeCoverage(node, COVERAGE_SKIPPED, true);
|
|
161
|
-
}
|
|
162
|
-
let coverage = 0;
|
|
163
|
-
if (node.loc) {
|
|
164
|
-
const { line, column } = node.loc.start;
|
|
165
|
-
const c = analyser.coverage(url, line, column);
|
|
166
|
-
if (c == null) {
|
|
167
|
-
log.warn(`No coverage for ${node.type} at ${(0, import_logging.$p)(file)}:${line}:${column}`);
|
|
168
|
-
} else {
|
|
169
|
-
coverage = c;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
setCodeCoverage(node, coverage, false);
|
|
173
|
-
if ((0, import_types.isIfStatement)(node)) {
|
|
174
|
-
maybeIgnoreNode(ignores.includes("test"), node.test, depth + 1);
|
|
175
|
-
maybeIgnoreNode(ignores.includes("if"), node.consequent, depth + 1);
|
|
176
|
-
maybeIgnoreNode(ignores.includes("else"), node.alternate, depth + 1);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if ((0, import_types.isTryStatement)(node)) {
|
|
180
|
-
maybeIgnoreNode(ignores.includes("try"), node.block, depth + 1);
|
|
181
|
-
maybeIgnoreNode(ignores.includes("catch"), node.handler, depth + 1);
|
|
182
|
-
maybeIgnoreNode(ignores.includes("finally"), node.finalizer, depth + 1);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
visitChildren(node, depth);
|
|
186
|
-
};
|
|
187
|
-
codeCoverage.fill(COVERAGE_SKIPPED);
|
|
188
|
-
setCodeCoverage(tree.program.directives, 0, true);
|
|
189
|
-
setCodeCoverage(tree.program.body, 0, true);
|
|
190
|
-
nodeCoverage.coveredNodes = 0;
|
|
191
|
-
nodeCoverage.missingNodes = 0;
|
|
192
|
-
nodeCoverage.ignoredNodes = 0;
|
|
193
|
-
let ignoreFileCoverage = false;
|
|
194
|
-
for (const comment of tree.program.body[0]?.leadingComments || []) {
|
|
195
|
-
for (const match of comment.value.matchAll(ignoreRegexp)) {
|
|
196
|
-
if (match[2] === "file") {
|
|
197
|
-
ignoreFileCoverage = true;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (ignoreFileCoverage) break;
|
|
202
|
-
}
|
|
203
|
-
if (ignoreFileCoverage) {
|
|
204
|
-
setCodeCoverage(tree.program, COVERAGE_IGNORED, true);
|
|
205
|
-
} else {
|
|
206
|
-
visitChildren(tree.program, -1);
|
|
207
|
-
}
|
|
208
|
-
setCodeCoverage(tree.comments, COVERAGE_SKIPPED, false);
|
|
209
|
-
updateNodeCoverageResult(nodeCoverage);
|
|
210
|
-
nodes.coveredNodes += nodeCoverage.coveredNodes;
|
|
211
|
-
nodes.missingNodes += nodeCoverage.missingNodes;
|
|
212
|
-
nodes.ignoredNodes += nodeCoverage.ignoredNodes;
|
|
213
|
-
nodes.totalNodes += nodeCoverage.totalNodes;
|
|
214
|
-
results[file] = { code, codeCoverage, nodeCoverage };
|
|
215
|
-
}
|
|
216
|
-
updateNodeCoverageResult(nodes);
|
|
217
|
-
return { results, nodes };
|
|
218
|
-
}
|
|
219
|
-
function updateNodeCoverageResult(result) {
|
|
220
|
-
const { coveredNodes, missingNodes, ignoredNodes } = result;
|
|
221
|
-
const totalNodes = result.totalNodes = coveredNodes + missingNodes + ignoredNodes;
|
|
222
|
-
if (totalNodes === 0) {
|
|
223
|
-
result.coverage = null;
|
|
224
|
-
} else if (totalNodes === ignoredNodes) {
|
|
225
|
-
result.coverage = null;
|
|
226
|
-
} else {
|
|
227
|
-
result.coverage = Math.floor(100 * coveredNodes / (totalNodes - ignoredNodes));
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
-
0 && (module.exports = {
|
|
232
|
-
COVERAGE_IGNORED,
|
|
233
|
-
COVERAGE_SKIPPED,
|
|
234
|
-
coverageReport
|
|
235
|
-
});
|
|
236
|
-
//# sourceMappingURL=report.cjs.map
|
package/dist/report.cjs.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/report.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAE9B,oBAAsB;AACtB,mBAYO;AACP,gBAAyB;AACzB,qBAAmB;AAgBZ,IAAM,mBAAmB;AAMzB,IAAM,mBAAmB;AAuDhC,IAAM,eAAe;AAUrB,eAAsB,eAClB,UACA,aACA,KACuB;AAEzB,QAAM,UAA2B,CAAC;AAClC,QAAM,QAA4B;AAAA,IAChC,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAQA,aAAW,QAAQ,aAAa;AAE9B,UAAM,UAAM,+BAAc,IAAI,EAAE,SAAS;AACzC,UAAM,OAAO,UAAM,oBAAS,MAAM,OAAO;AAEzC,QAAI;AACJ,QAAI;AACF,iBAAO,qBAAM,MAAM;AAAA,QACjB,6BAA6B;AAAA,QAC7B,2BAA2B;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