@code-pushup/cli 0.8.11 → 0.8.12
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
|
@@ -14,7 +14,7 @@ import { join as join2 } from "node:path";
|
|
|
14
14
|
// packages/utils/src/lib/execute-process.ts
|
|
15
15
|
import { spawn } from "node:child_process";
|
|
16
16
|
|
|
17
|
-
// packages/utils/src/lib/
|
|
17
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
18
18
|
import { join } from "node:path";
|
|
19
19
|
|
|
20
20
|
// packages/models/src/lib/audit.ts
|
|
@@ -575,12 +575,6 @@ var reportSchema = packageVersionSchema({
|
|
|
575
575
|
})
|
|
576
576
|
);
|
|
577
577
|
|
|
578
|
-
// packages/utils/src/lib/constants.ts
|
|
579
|
-
var SCORE_COLOR_RANGE = {
|
|
580
|
-
GREEN_MIN: 0.9,
|
|
581
|
-
YELLOW_MIN: 0.5
|
|
582
|
-
};
|
|
583
|
-
|
|
584
578
|
// packages/utils/src/lib/file-system.ts
|
|
585
579
|
import { bundleRequire } from "bundle-require";
|
|
586
580
|
import chalk from "chalk";
|
|
@@ -706,7 +700,14 @@ async function importEsmModule(options2) {
|
|
|
706
700
|
return mod.default;
|
|
707
701
|
}
|
|
708
702
|
|
|
709
|
-
// packages/utils/src/lib/
|
|
703
|
+
// packages/utils/src/lib/reports/constants.ts
|
|
704
|
+
var NEW_LINE = "\n";
|
|
705
|
+
var SCORE_COLOR_RANGE = {
|
|
706
|
+
GREEN_MIN: 0.9,
|
|
707
|
+
YELLOW_MIN: 0.5
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
710
711
|
var FOOTER_PREFIX = "Made with \u2764 by";
|
|
711
712
|
var CODE_PUSHUP_DOMAIN = "code-pushup.dev";
|
|
712
713
|
var README_LINK = "https://github.com/flowup/quality-metrics-cli#readme";
|
|
@@ -989,83 +990,6 @@ function groupByStatus(results) {
|
|
|
989
990
|
);
|
|
990
991
|
}
|
|
991
992
|
|
|
992
|
-
// packages/utils/src/lib/md/details.ts
|
|
993
|
-
function details(title, content, cfg = { open: false }) {
|
|
994
|
-
return `<details${cfg.open ? " open" : ""}>
|
|
995
|
-
<summary>${title}</summary>
|
|
996
|
-
${content}
|
|
997
|
-
</details>
|
|
998
|
-
`;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
// packages/utils/src/lib/md/headline.ts
|
|
1002
|
-
function headline(text, hierarchy = 1) {
|
|
1003
|
-
return `${new Array(hierarchy).fill("#").join("")} ${text}`;
|
|
1004
|
-
}
|
|
1005
|
-
function h2(text) {
|
|
1006
|
-
return headline(text, 2);
|
|
1007
|
-
}
|
|
1008
|
-
function h3(text) {
|
|
1009
|
-
return headline(text, 3);
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// packages/utils/src/lib/md/constants.ts
|
|
1013
|
-
var NEW_LINE = "\n";
|
|
1014
|
-
|
|
1015
|
-
// packages/utils/src/lib/md/table.ts
|
|
1016
|
-
var alignString = /* @__PURE__ */ new Map([
|
|
1017
|
-
["l", ":--"],
|
|
1018
|
-
["c", ":--:"],
|
|
1019
|
-
["r", "--:"]
|
|
1020
|
-
]);
|
|
1021
|
-
function tableMd(data, align) {
|
|
1022
|
-
if (data.length === 0) {
|
|
1023
|
-
throw new Error("Data can't be empty");
|
|
1024
|
-
}
|
|
1025
|
-
align = align || data[0]?.map(() => "c");
|
|
1026
|
-
const _data = data.map((arr) => "|" + arr.join("|") + "|");
|
|
1027
|
-
const secondRow = "|" + align?.map((s) => alignString.get(s)).join("|") + "|";
|
|
1028
|
-
return _data.shift() + NEW_LINE + secondRow + NEW_LINE + _data.join(NEW_LINE);
|
|
1029
|
-
}
|
|
1030
|
-
function tableHtml(data) {
|
|
1031
|
-
if (data.length === 0) {
|
|
1032
|
-
throw new Error("Data can't be empty");
|
|
1033
|
-
}
|
|
1034
|
-
const _data = data.map((arr, index) => {
|
|
1035
|
-
if (index === 0) {
|
|
1036
|
-
return "<tr>" + arr.map((s) => `<th>${s}</th>`).join("") + "</tr>";
|
|
1037
|
-
}
|
|
1038
|
-
return "<tr>" + arr.map((s) => `<td>${s}</td>`).join("") + "</tr>";
|
|
1039
|
-
});
|
|
1040
|
-
return "<table>" + _data.join("") + "</table>";
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
// packages/utils/src/lib/md/font-style.ts
|
|
1044
|
-
var stylesMap = {
|
|
1045
|
-
i: "_",
|
|
1046
|
-
// italic
|
|
1047
|
-
b: "**",
|
|
1048
|
-
// bold
|
|
1049
|
-
s: "~",
|
|
1050
|
-
// strike through
|
|
1051
|
-
c: "`"
|
|
1052
|
-
// code
|
|
1053
|
-
};
|
|
1054
|
-
function style(text, styles = ["b"]) {
|
|
1055
|
-
return styles.reduce((t, s) => `${stylesMap[s]}${t}${stylesMap[s]}`, text);
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
// packages/utils/src/lib/md/link.ts
|
|
1059
|
-
function link(href, text) {
|
|
1060
|
-
return `[${text || href}](${href})`;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
// packages/utils/src/lib/md/list.ts
|
|
1064
|
-
function li(text, order = "unordered") {
|
|
1065
|
-
const style2 = order === "unordered" ? "-" : "- [ ]";
|
|
1066
|
-
return `${style2} ${text}`;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
993
|
// packages/utils/src/lib/progress.ts
|
|
1070
994
|
import chalk2 from "chalk";
|
|
1071
995
|
import { MultiProgressBars } from "multi-progress-bars";
|
|
@@ -1120,8 +1044,82 @@ function getProgressBar(taskName) {
|
|
|
1120
1044
|
};
|
|
1121
1045
|
}
|
|
1122
1046
|
|
|
1123
|
-
// packages/utils/src/lib/
|
|
1124
|
-
function
|
|
1047
|
+
// packages/utils/src/lib/reports/md/details.ts
|
|
1048
|
+
function details(title, content, cfg = { open: false }) {
|
|
1049
|
+
return `<details${cfg.open ? " open" : ""}>
|
|
1050
|
+
<summary>${title}</summary>
|
|
1051
|
+
${content}
|
|
1052
|
+
</details>
|
|
1053
|
+
`;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
// packages/utils/src/lib/reports/md/font-style.ts
|
|
1057
|
+
var stylesMap = {
|
|
1058
|
+
i: "_",
|
|
1059
|
+
// italic
|
|
1060
|
+
b: "**",
|
|
1061
|
+
// bold
|
|
1062
|
+
s: "~",
|
|
1063
|
+
// strike through
|
|
1064
|
+
c: "`"
|
|
1065
|
+
// code
|
|
1066
|
+
};
|
|
1067
|
+
function style(text, styles = ["b"]) {
|
|
1068
|
+
return styles.reduce((t, s) => `${stylesMap[s]}${t}${stylesMap[s]}`, text);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// packages/utils/src/lib/reports/md/headline.ts
|
|
1072
|
+
function headline(text, hierarchy = 1) {
|
|
1073
|
+
return `${new Array(hierarchy).fill("#").join("")} ${text}`;
|
|
1074
|
+
}
|
|
1075
|
+
function h2(text) {
|
|
1076
|
+
return headline(text, 2);
|
|
1077
|
+
}
|
|
1078
|
+
function h3(text) {
|
|
1079
|
+
return headline(text, 3);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// packages/utils/src/lib/reports/md/link.ts
|
|
1083
|
+
function link(href, text) {
|
|
1084
|
+
return `[${text || href}](${href})`;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// packages/utils/src/lib/reports/md/list.ts
|
|
1088
|
+
function li(text, order = "unordered") {
|
|
1089
|
+
const style2 = order === "unordered" ? "-" : "- [ ]";
|
|
1090
|
+
return `${style2} ${text}`;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// packages/utils/src/lib/reports/md/table.ts
|
|
1094
|
+
var alignString = /* @__PURE__ */ new Map([
|
|
1095
|
+
["l", ":--"],
|
|
1096
|
+
["c", ":--:"],
|
|
1097
|
+
["r", "--:"]
|
|
1098
|
+
]);
|
|
1099
|
+
function tableMd(data, align) {
|
|
1100
|
+
if (data.length === 0) {
|
|
1101
|
+
throw new Error("Data can't be empty");
|
|
1102
|
+
}
|
|
1103
|
+
align = align || data[0]?.map(() => "c");
|
|
1104
|
+
const _data = data.map((arr) => "|" + arr.join("|") + "|");
|
|
1105
|
+
const secondRow = "|" + align?.map((s) => alignString.get(s)).join("|") + "|";
|
|
1106
|
+
return _data.shift() + NEW_LINE + secondRow + NEW_LINE + _data.join(NEW_LINE);
|
|
1107
|
+
}
|
|
1108
|
+
function tableHtml(data) {
|
|
1109
|
+
if (data.length === 0) {
|
|
1110
|
+
throw new Error("Data can't be empty");
|
|
1111
|
+
}
|
|
1112
|
+
const _data = data.map((arr, index) => {
|
|
1113
|
+
if (index === 0) {
|
|
1114
|
+
return "<tr>" + arr.map((s) => `<th>${s}</th>`).join("") + "</tr>";
|
|
1115
|
+
}
|
|
1116
|
+
return "<tr>" + arr.map((s) => `<td>${s}</td>`).join("") + "</tr>";
|
|
1117
|
+
});
|
|
1118
|
+
return "<table>" + _data.join("") + "</table>";
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// packages/utils/src/lib/reports/generate-md-report.ts
|
|
1122
|
+
function generateMdReport(report, commitData) {
|
|
1125
1123
|
let md = reportToHeaderSection() + NEW_LINE;
|
|
1126
1124
|
md += reportToOverviewSection(report) + NEW_LINE + NEW_LINE;
|
|
1127
1125
|
md += reportToCategoriesSection(report) + NEW_LINE + NEW_LINE;
|
|
@@ -1302,14 +1300,14 @@ function getAuditResult(audit, isHtml = false) {
|
|
|
1302
1300
|
return isHtml ? `<b>${displayValue || value}</b>` : style(String(displayValue || value));
|
|
1303
1301
|
}
|
|
1304
1302
|
|
|
1305
|
-
// packages/utils/src/lib/
|
|
1303
|
+
// packages/utils/src/lib/reports/generate-stdout-summary.ts
|
|
1306
1304
|
import cliui from "@isaacs/cliui";
|
|
1307
1305
|
import chalk3 from "chalk";
|
|
1308
1306
|
import Table from "cli-table3";
|
|
1309
1307
|
function addLine(line = "") {
|
|
1310
1308
|
return line + NEW_LINE;
|
|
1311
1309
|
}
|
|
1312
|
-
function
|
|
1310
|
+
function generateStdoutSummary(report) {
|
|
1313
1311
|
let output = "";
|
|
1314
1312
|
output += addLine(reportToHeaderSection2(report));
|
|
1315
1313
|
output += addLine();
|
|
@@ -1405,7 +1403,7 @@ function deepClone(obj) {
|
|
|
1405
1403
|
return cloned;
|
|
1406
1404
|
}
|
|
1407
1405
|
|
|
1408
|
-
// packages/utils/src/lib/scoring.ts
|
|
1406
|
+
// packages/utils/src/lib/reports/scoring.ts
|
|
1409
1407
|
function calculateScore(refs, scoreFn) {
|
|
1410
1408
|
const { numerator, denominator } = refs.reduce(
|
|
1411
1409
|
(acc, ref) => {
|
|
@@ -1473,27 +1471,7 @@ function scoreReport(report) {
|
|
|
1473
1471
|
return scoredReport;
|
|
1474
1472
|
}
|
|
1475
1473
|
|
|
1476
|
-
// packages/utils/src/lib/
|
|
1477
|
-
function getLogVerbose(verbose) {
|
|
1478
|
-
return (...args) => {
|
|
1479
|
-
if (verbose) {
|
|
1480
|
-
console.info(...args);
|
|
1481
|
-
}
|
|
1482
|
-
};
|
|
1483
|
-
}
|
|
1484
|
-
function getExecVerbose(verbose) {
|
|
1485
|
-
return (fn) => {
|
|
1486
|
-
if (verbose) {
|
|
1487
|
-
fn();
|
|
1488
|
-
}
|
|
1489
|
-
};
|
|
1490
|
-
}
|
|
1491
|
-
var verboseUtils = (verbose) => ({
|
|
1492
|
-
log: getLogVerbose(verbose),
|
|
1493
|
-
exec: getExecVerbose(verbose)
|
|
1494
|
-
});
|
|
1495
|
-
|
|
1496
|
-
// packages/utils/src/lib/sort-report.ts
|
|
1474
|
+
// packages/utils/src/lib/reports/sorting.ts
|
|
1497
1475
|
function sortReport(report) {
|
|
1498
1476
|
const { categories, plugins } = report;
|
|
1499
1477
|
const sortedCategories = categories.map((category) => {
|
|
@@ -1543,6 +1521,26 @@ function sortReport(report) {
|
|
|
1543
1521
|
};
|
|
1544
1522
|
}
|
|
1545
1523
|
|
|
1524
|
+
// packages/utils/src/lib/verbose-utils.ts
|
|
1525
|
+
function getLogVerbose(verbose) {
|
|
1526
|
+
return (...args) => {
|
|
1527
|
+
if (verbose) {
|
|
1528
|
+
console.info(...args);
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
function getExecVerbose(verbose) {
|
|
1533
|
+
return (fn) => {
|
|
1534
|
+
if (verbose) {
|
|
1535
|
+
fn();
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
var verboseUtils = (verbose) => ({
|
|
1540
|
+
log: getLogVerbose(verbose),
|
|
1541
|
+
exec: getExecVerbose(verbose)
|
|
1542
|
+
});
|
|
1543
|
+
|
|
1546
1544
|
// packages/core/src/lib/implementation/persist.ts
|
|
1547
1545
|
var PersistDirError = class extends Error {
|
|
1548
1546
|
constructor(outputDir) {
|
|
@@ -1557,7 +1555,7 @@ var PersistError = class extends Error {
|
|
|
1557
1555
|
async function persistReport(report, options2) {
|
|
1558
1556
|
const { outputDir, filename, format } = options2;
|
|
1559
1557
|
const sortedScoredReport = sortReport(scoreReport(report));
|
|
1560
|
-
console.info(
|
|
1558
|
+
console.info(generateStdoutSummary(sortedScoredReport));
|
|
1561
1559
|
const results = [];
|
|
1562
1560
|
if (format.includes("json")) {
|
|
1563
1561
|
results.push({
|
|
@@ -1570,7 +1568,7 @@ async function persistReport(report, options2) {
|
|
|
1570
1568
|
validateCommitData(commitData);
|
|
1571
1569
|
results.push({
|
|
1572
1570
|
format: "md",
|
|
1573
|
-
content:
|
|
1571
|
+
content: generateMdReport(sortedScoredReport, commitData)
|
|
1574
1572
|
});
|
|
1575
1573
|
}
|
|
1576
1574
|
if (!existsSync(outputDir)) {
|
|
@@ -1715,7 +1713,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1715
1713
|
|
|
1716
1714
|
// packages/core/package.json
|
|
1717
1715
|
var name = "@code-pushup/core";
|
|
1718
|
-
var version = "0.8.
|
|
1716
|
+
var version = "0.8.12";
|
|
1719
1717
|
|
|
1720
1718
|
// packages/core/src/lib/implementation/collect.ts
|
|
1721
1719
|
async function collect(options2) {
|