@code-pushup/core 0.8.11 → 0.8.13
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/index.js +112 -114
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { join as join2 } from "node:path";
|
|
|
6
6
|
// packages/utils/src/lib/execute-process.ts
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
8
|
|
|
9
|
-
// packages/utils/src/lib/
|
|
9
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
10
10
|
import { join } from "node:path";
|
|
11
11
|
|
|
12
12
|
// packages/models/src/lib/audit.ts
|
|
@@ -567,12 +567,6 @@ var reportSchema = packageVersionSchema({
|
|
|
567
567
|
})
|
|
568
568
|
);
|
|
569
569
|
|
|
570
|
-
// packages/utils/src/lib/constants.ts
|
|
571
|
-
var SCORE_COLOR_RANGE = {
|
|
572
|
-
GREEN_MIN: 0.9,
|
|
573
|
-
YELLOW_MIN: 0.5
|
|
574
|
-
};
|
|
575
|
-
|
|
576
570
|
// packages/utils/src/lib/file-system.ts
|
|
577
571
|
import { bundleRequire } from "bundle-require";
|
|
578
572
|
import chalk from "chalk";
|
|
@@ -698,7 +692,14 @@ async function importEsmModule(options) {
|
|
|
698
692
|
return mod.default;
|
|
699
693
|
}
|
|
700
694
|
|
|
701
|
-
// packages/utils/src/lib/
|
|
695
|
+
// packages/utils/src/lib/reports/constants.ts
|
|
696
|
+
var NEW_LINE = "\n";
|
|
697
|
+
var SCORE_COLOR_RANGE = {
|
|
698
|
+
GREEN_MIN: 0.9,
|
|
699
|
+
YELLOW_MIN: 0.5
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
702
703
|
var FOOTER_PREFIX = "Made with \u2764 by";
|
|
703
704
|
var CODE_PUSHUP_DOMAIN = "code-pushup.dev";
|
|
704
705
|
var README_LINK = "https://github.com/flowup/quality-metrics-cli#readme";
|
|
@@ -981,83 +982,6 @@ function groupByStatus(results) {
|
|
|
981
982
|
);
|
|
982
983
|
}
|
|
983
984
|
|
|
984
|
-
// packages/utils/src/lib/md/details.ts
|
|
985
|
-
function details(title, content, cfg = { open: false }) {
|
|
986
|
-
return `<details${cfg.open ? " open" : ""}>
|
|
987
|
-
<summary>${title}</summary>
|
|
988
|
-
${content}
|
|
989
|
-
</details>
|
|
990
|
-
`;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
// packages/utils/src/lib/md/headline.ts
|
|
994
|
-
function headline(text, hierarchy = 1) {
|
|
995
|
-
return `${new Array(hierarchy).fill("#").join("")} ${text}`;
|
|
996
|
-
}
|
|
997
|
-
function h2(text) {
|
|
998
|
-
return headline(text, 2);
|
|
999
|
-
}
|
|
1000
|
-
function h3(text) {
|
|
1001
|
-
return headline(text, 3);
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
// packages/utils/src/lib/md/constants.ts
|
|
1005
|
-
var NEW_LINE = "\n";
|
|
1006
|
-
|
|
1007
|
-
// packages/utils/src/lib/md/table.ts
|
|
1008
|
-
var alignString = /* @__PURE__ */ new Map([
|
|
1009
|
-
["l", ":--"],
|
|
1010
|
-
["c", ":--:"],
|
|
1011
|
-
["r", "--:"]
|
|
1012
|
-
]);
|
|
1013
|
-
function tableMd(data, align) {
|
|
1014
|
-
if (data.length === 0) {
|
|
1015
|
-
throw new Error("Data can't be empty");
|
|
1016
|
-
}
|
|
1017
|
-
align = align || data[0]?.map(() => "c");
|
|
1018
|
-
const _data = data.map((arr) => "|" + arr.join("|") + "|");
|
|
1019
|
-
const secondRow = "|" + align?.map((s) => alignString.get(s)).join("|") + "|";
|
|
1020
|
-
return _data.shift() + NEW_LINE + secondRow + NEW_LINE + _data.join(NEW_LINE);
|
|
1021
|
-
}
|
|
1022
|
-
function tableHtml(data) {
|
|
1023
|
-
if (data.length === 0) {
|
|
1024
|
-
throw new Error("Data can't be empty");
|
|
1025
|
-
}
|
|
1026
|
-
const _data = data.map((arr, index) => {
|
|
1027
|
-
if (index === 0) {
|
|
1028
|
-
return "<tr>" + arr.map((s) => `<th>${s}</th>`).join("") + "</tr>";
|
|
1029
|
-
}
|
|
1030
|
-
return "<tr>" + arr.map((s) => `<td>${s}</td>`).join("") + "</tr>";
|
|
1031
|
-
});
|
|
1032
|
-
return "<table>" + _data.join("") + "</table>";
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
// packages/utils/src/lib/md/font-style.ts
|
|
1036
|
-
var stylesMap = {
|
|
1037
|
-
i: "_",
|
|
1038
|
-
// italic
|
|
1039
|
-
b: "**",
|
|
1040
|
-
// bold
|
|
1041
|
-
s: "~",
|
|
1042
|
-
// strike through
|
|
1043
|
-
c: "`"
|
|
1044
|
-
// code
|
|
1045
|
-
};
|
|
1046
|
-
function style(text, styles = ["b"]) {
|
|
1047
|
-
return styles.reduce((t, s) => `${stylesMap[s]}${t}${stylesMap[s]}`, text);
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
// packages/utils/src/lib/md/link.ts
|
|
1051
|
-
function link(href, text) {
|
|
1052
|
-
return `[${text || href}](${href})`;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
// packages/utils/src/lib/md/list.ts
|
|
1056
|
-
function li(text, order = "unordered") {
|
|
1057
|
-
const style2 = order === "unordered" ? "-" : "- [ ]";
|
|
1058
|
-
return `${style2} ${text}`;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
985
|
// packages/utils/src/lib/progress.ts
|
|
1062
986
|
import chalk2 from "chalk";
|
|
1063
987
|
import { MultiProgressBars } from "multi-progress-bars";
|
|
@@ -1112,8 +1036,82 @@ function getProgressBar(taskName) {
|
|
|
1112
1036
|
};
|
|
1113
1037
|
}
|
|
1114
1038
|
|
|
1115
|
-
// packages/utils/src/lib/
|
|
1116
|
-
function
|
|
1039
|
+
// packages/utils/src/lib/reports/md/details.ts
|
|
1040
|
+
function details(title, content, cfg = { open: false }) {
|
|
1041
|
+
return `<details${cfg.open ? " open" : ""}>
|
|
1042
|
+
<summary>${title}</summary>
|
|
1043
|
+
${content}
|
|
1044
|
+
</details>
|
|
1045
|
+
`;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// packages/utils/src/lib/reports/md/font-style.ts
|
|
1049
|
+
var stylesMap = {
|
|
1050
|
+
i: "_",
|
|
1051
|
+
// italic
|
|
1052
|
+
b: "**",
|
|
1053
|
+
// bold
|
|
1054
|
+
s: "~",
|
|
1055
|
+
// strike through
|
|
1056
|
+
c: "`"
|
|
1057
|
+
// code
|
|
1058
|
+
};
|
|
1059
|
+
function style(text, styles = ["b"]) {
|
|
1060
|
+
return styles.reduce((t, s) => `${stylesMap[s]}${t}${stylesMap[s]}`, text);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// packages/utils/src/lib/reports/md/headline.ts
|
|
1064
|
+
function headline(text, hierarchy = 1) {
|
|
1065
|
+
return `${new Array(hierarchy).fill("#").join("")} ${text}`;
|
|
1066
|
+
}
|
|
1067
|
+
function h2(text) {
|
|
1068
|
+
return headline(text, 2);
|
|
1069
|
+
}
|
|
1070
|
+
function h3(text) {
|
|
1071
|
+
return headline(text, 3);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// packages/utils/src/lib/reports/md/link.ts
|
|
1075
|
+
function link(href, text) {
|
|
1076
|
+
return `[${text || href}](${href})`;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// packages/utils/src/lib/reports/md/list.ts
|
|
1080
|
+
function li(text, order = "unordered") {
|
|
1081
|
+
const style2 = order === "unordered" ? "-" : "- [ ]";
|
|
1082
|
+
return `${style2} ${text}`;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// packages/utils/src/lib/reports/md/table.ts
|
|
1086
|
+
var alignString = /* @__PURE__ */ new Map([
|
|
1087
|
+
["l", ":--"],
|
|
1088
|
+
["c", ":--:"],
|
|
1089
|
+
["r", "--:"]
|
|
1090
|
+
]);
|
|
1091
|
+
function tableMd(data, align) {
|
|
1092
|
+
if (data.length === 0) {
|
|
1093
|
+
throw new Error("Data can't be empty");
|
|
1094
|
+
}
|
|
1095
|
+
align = align || data[0]?.map(() => "c");
|
|
1096
|
+
const _data = data.map((arr) => "|" + arr.join("|") + "|");
|
|
1097
|
+
const secondRow = "|" + align?.map((s) => alignString.get(s)).join("|") + "|";
|
|
1098
|
+
return _data.shift() + NEW_LINE + secondRow + NEW_LINE + _data.join(NEW_LINE);
|
|
1099
|
+
}
|
|
1100
|
+
function tableHtml(data) {
|
|
1101
|
+
if (data.length === 0) {
|
|
1102
|
+
throw new Error("Data can't be empty");
|
|
1103
|
+
}
|
|
1104
|
+
const _data = data.map((arr, index) => {
|
|
1105
|
+
if (index === 0) {
|
|
1106
|
+
return "<tr>" + arr.map((s) => `<th>${s}</th>`).join("") + "</tr>";
|
|
1107
|
+
}
|
|
1108
|
+
return "<tr>" + arr.map((s) => `<td>${s}</td>`).join("") + "</tr>";
|
|
1109
|
+
});
|
|
1110
|
+
return "<table>" + _data.join("") + "</table>";
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// packages/utils/src/lib/reports/generate-md-report.ts
|
|
1114
|
+
function generateMdReport(report, commitData) {
|
|
1117
1115
|
let md = reportToHeaderSection() + NEW_LINE;
|
|
1118
1116
|
md += reportToOverviewSection(report) + NEW_LINE + NEW_LINE;
|
|
1119
1117
|
md += reportToCategoriesSection(report) + NEW_LINE + NEW_LINE;
|
|
@@ -1294,14 +1292,14 @@ function getAuditResult(audit, isHtml = false) {
|
|
|
1294
1292
|
return isHtml ? `<b>${displayValue || value}</b>` : style(String(displayValue || value));
|
|
1295
1293
|
}
|
|
1296
1294
|
|
|
1297
|
-
// packages/utils/src/lib/
|
|
1295
|
+
// packages/utils/src/lib/reports/generate-stdout-summary.ts
|
|
1298
1296
|
import cliui from "@isaacs/cliui";
|
|
1299
1297
|
import chalk3 from "chalk";
|
|
1300
1298
|
import Table from "cli-table3";
|
|
1301
1299
|
function addLine(line = "") {
|
|
1302
1300
|
return line + NEW_LINE;
|
|
1303
1301
|
}
|
|
1304
|
-
function
|
|
1302
|
+
function generateStdoutSummary(report) {
|
|
1305
1303
|
let output = "";
|
|
1306
1304
|
output += addLine(reportToHeaderSection2(report));
|
|
1307
1305
|
output += addLine();
|
|
@@ -1394,7 +1392,7 @@ function deepClone(obj) {
|
|
|
1394
1392
|
return cloned;
|
|
1395
1393
|
}
|
|
1396
1394
|
|
|
1397
|
-
// packages/utils/src/lib/scoring.ts
|
|
1395
|
+
// packages/utils/src/lib/reports/scoring.ts
|
|
1398
1396
|
function calculateScore(refs, scoreFn) {
|
|
1399
1397
|
const { numerator, denominator } = refs.reduce(
|
|
1400
1398
|
(acc, ref) => {
|
|
@@ -1462,27 +1460,7 @@ function scoreReport(report) {
|
|
|
1462
1460
|
return scoredReport;
|
|
1463
1461
|
}
|
|
1464
1462
|
|
|
1465
|
-
// packages/utils/src/lib/
|
|
1466
|
-
function getLogVerbose(verbose) {
|
|
1467
|
-
return (...args) => {
|
|
1468
|
-
if (verbose) {
|
|
1469
|
-
console.info(...args);
|
|
1470
|
-
}
|
|
1471
|
-
};
|
|
1472
|
-
}
|
|
1473
|
-
function getExecVerbose(verbose) {
|
|
1474
|
-
return (fn) => {
|
|
1475
|
-
if (verbose) {
|
|
1476
|
-
fn();
|
|
1477
|
-
}
|
|
1478
|
-
};
|
|
1479
|
-
}
|
|
1480
|
-
var verboseUtils = (verbose) => ({
|
|
1481
|
-
log: getLogVerbose(verbose),
|
|
1482
|
-
exec: getExecVerbose(verbose)
|
|
1483
|
-
});
|
|
1484
|
-
|
|
1485
|
-
// packages/utils/src/lib/sort-report.ts
|
|
1463
|
+
// packages/utils/src/lib/reports/sorting.ts
|
|
1486
1464
|
function sortReport(report) {
|
|
1487
1465
|
const { categories, plugins } = report;
|
|
1488
1466
|
const sortedCategories = categories.map((category) => {
|
|
@@ -1532,6 +1510,26 @@ function sortReport(report) {
|
|
|
1532
1510
|
};
|
|
1533
1511
|
}
|
|
1534
1512
|
|
|
1513
|
+
// packages/utils/src/lib/verbose-utils.ts
|
|
1514
|
+
function getLogVerbose(verbose) {
|
|
1515
|
+
return (...args) => {
|
|
1516
|
+
if (verbose) {
|
|
1517
|
+
console.info(...args);
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
function getExecVerbose(verbose) {
|
|
1522
|
+
return (fn) => {
|
|
1523
|
+
if (verbose) {
|
|
1524
|
+
fn();
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
var verboseUtils = (verbose) => ({
|
|
1529
|
+
log: getLogVerbose(verbose),
|
|
1530
|
+
exec: getExecVerbose(verbose)
|
|
1531
|
+
});
|
|
1532
|
+
|
|
1535
1533
|
// packages/core/src/lib/implementation/persist.ts
|
|
1536
1534
|
var PersistDirError = class extends Error {
|
|
1537
1535
|
constructor(outputDir) {
|
|
@@ -1546,7 +1544,7 @@ var PersistError = class extends Error {
|
|
|
1546
1544
|
async function persistReport(report, options) {
|
|
1547
1545
|
const { outputDir, filename, format } = options;
|
|
1548
1546
|
const sortedScoredReport = sortReport(scoreReport(report));
|
|
1549
|
-
console.info(
|
|
1547
|
+
console.info(generateStdoutSummary(sortedScoredReport));
|
|
1550
1548
|
const results = [];
|
|
1551
1549
|
if (format.includes("json")) {
|
|
1552
1550
|
results.push({
|
|
@@ -1559,7 +1557,7 @@ async function persistReport(report, options) {
|
|
|
1559
1557
|
validateCommitData(commitData);
|
|
1560
1558
|
results.push({
|
|
1561
1559
|
format: "md",
|
|
1562
|
-
content:
|
|
1560
|
+
content: generateMdReport(sortedScoredReport, commitData)
|
|
1563
1561
|
});
|
|
1564
1562
|
}
|
|
1565
1563
|
if (!existsSync(outputDir)) {
|
|
@@ -1704,7 +1702,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1704
1702
|
|
|
1705
1703
|
// packages/core/package.json
|
|
1706
1704
|
var name = "@code-pushup/core";
|
|
1707
|
-
var version = "0.8.
|
|
1705
|
+
var version = "0.8.13";
|
|
1708
1706
|
|
|
1709
1707
|
// packages/core/src/lib/implementation/collect.ts
|
|
1710
1708
|
async function collect(options) {
|