@code-pushup/cli 0.8.24 → 0.9.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/index.js
CHANGED
|
@@ -469,7 +469,8 @@ var uploadConfigSchema = z10.object({
|
|
|
469
469
|
description: "API key with write access to portal (use `process.env` for security)"
|
|
470
470
|
}),
|
|
471
471
|
organization: slugSchema("Organization slug from Code PushUp portal"),
|
|
472
|
-
project: slugSchema("Project slug from Code PushUp portal")
|
|
472
|
+
project: slugSchema("Project slug from Code PushUp portal"),
|
|
473
|
+
timeout: z10.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
|
|
473
474
|
});
|
|
474
475
|
|
|
475
476
|
// packages/models/src/lib/core-config.ts
|
|
@@ -573,15 +574,15 @@ function slugify(text) {
|
|
|
573
574
|
return text.trim().toLowerCase().replace(/\s+|\//g, "-").replace(/[^a-z\d-]/g, "");
|
|
574
575
|
}
|
|
575
576
|
function formatBytes(bytes, decimals = 2) {
|
|
576
|
-
|
|
577
|
-
if (
|
|
577
|
+
const positiveBytes = Math.max(bytes, 0);
|
|
578
|
+
if (positiveBytes === 0) {
|
|
578
579
|
return "0 B";
|
|
579
580
|
}
|
|
580
581
|
const k = 1024;
|
|
581
582
|
const dm = decimals < 0 ? 0 : decimals;
|
|
582
583
|
const sizes = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
583
|
-
const i = Math.floor(Math.log(
|
|
584
|
-
return `${Number.parseFloat((
|
|
584
|
+
const i = Math.floor(Math.log(positiveBytes) / Math.log(k));
|
|
585
|
+
return `${Number.parseFloat((positiveBytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
585
586
|
}
|
|
586
587
|
function formatDuration(duration) {
|
|
587
588
|
if (duration < 1e3) {
|
|
@@ -766,8 +767,7 @@ function getSeverityIcon(severity) {
|
|
|
766
767
|
return "\u2139\uFE0F";
|
|
767
768
|
}
|
|
768
769
|
function calcDuration(start, stop) {
|
|
769
|
-
stop
|
|
770
|
-
return Math.floor(stop - start);
|
|
770
|
+
return Math.floor((stop ?? performance.now()) - start);
|
|
771
771
|
}
|
|
772
772
|
function countCategoryAudits(refs, plugins) {
|
|
773
773
|
const groupLookup = plugins.reduce(
|
|
@@ -793,15 +793,15 @@ function countCategoryAudits(refs, plugins) {
|
|
|
793
793
|
}, 0);
|
|
794
794
|
}
|
|
795
795
|
function getAuditByRef({ slug, weight, plugin }, plugins) {
|
|
796
|
-
const auditPlugin = plugins.find((
|
|
796
|
+
const auditPlugin = plugins.find((p) => p.slug === plugin);
|
|
797
797
|
if (!auditPlugin) {
|
|
798
798
|
throwIsNotPresentError(`Plugin ${plugin}`, "report");
|
|
799
799
|
}
|
|
800
|
-
const audit = auditPlugin
|
|
800
|
+
const audit = auditPlugin.audits.find(
|
|
801
801
|
({ slug: auditSlug }) => auditSlug === slug
|
|
802
802
|
);
|
|
803
803
|
if (!audit) {
|
|
804
|
-
throwIsNotPresentError(`Audit ${slug}`, auditPlugin
|
|
804
|
+
throwIsNotPresentError(`Audit ${slug}`, auditPlugin.slug);
|
|
805
805
|
}
|
|
806
806
|
return {
|
|
807
807
|
...audit,
|
|
@@ -814,24 +814,21 @@ function getGroupWithAudits(refSlug, refPlugin, plugins) {
|
|
|
814
814
|
if (!plugin) {
|
|
815
815
|
throwIsNotPresentError(`Plugin ${refPlugin}`, "report");
|
|
816
816
|
}
|
|
817
|
-
const groupWithAudits = plugin
|
|
817
|
+
const groupWithAudits = plugin.groups?.find(({ slug }) => slug === refSlug);
|
|
818
818
|
if (!groupWithAudits) {
|
|
819
|
-
throwIsNotPresentError(`Group ${refSlug}`, plugin
|
|
819
|
+
throwIsNotPresentError(`Group ${refSlug}`, plugin.slug);
|
|
820
820
|
}
|
|
821
821
|
const groupAudits = groupWithAudits.refs.reduce(
|
|
822
822
|
(acc, ref) => {
|
|
823
823
|
const audit = getAuditByRef(
|
|
824
|
-
{ ...ref, plugin: refPlugin },
|
|
824
|
+
{ ...ref, plugin: refPlugin, type: "audit" },
|
|
825
825
|
plugins
|
|
826
826
|
);
|
|
827
|
-
|
|
828
|
-
return [...acc, audit];
|
|
829
|
-
}
|
|
830
|
-
return [...acc];
|
|
827
|
+
return [...acc, audit];
|
|
831
828
|
},
|
|
832
829
|
[]
|
|
833
830
|
);
|
|
834
|
-
const audits = groupAudits.sort(compareCategoryAudits);
|
|
831
|
+
const audits = [...groupAudits].sort(compareCategoryAudits);
|
|
835
832
|
return {
|
|
836
833
|
...groupWithAudits,
|
|
837
834
|
audits
|
|
@@ -874,7 +871,8 @@ async function loadReport(options2) {
|
|
|
874
871
|
const content = await readJsonFile(filePath);
|
|
875
872
|
return reportSchema.parse(content);
|
|
876
873
|
}
|
|
877
|
-
|
|
874
|
+
const text = await readTextFile(filePath);
|
|
875
|
+
return text;
|
|
878
876
|
}
|
|
879
877
|
function throwIsNotPresentError(itemName, presentPlace) {
|
|
880
878
|
throw new Error(`${itemName} is not present in ${presentPlace}`);
|
|
@@ -929,11 +927,11 @@ function executeProcess(cfg) {
|
|
|
929
927
|
let stdout = "";
|
|
930
928
|
let stderr = "";
|
|
931
929
|
process2.stdout.on("data", (data) => {
|
|
932
|
-
stdout += data
|
|
933
|
-
onStdout?.(data);
|
|
930
|
+
stdout += String(data);
|
|
931
|
+
onStdout?.(String(data));
|
|
934
932
|
});
|
|
935
933
|
process2.stderr.on("data", (data) => {
|
|
936
|
-
stderr += data
|
|
934
|
+
stderr += String(data);
|
|
937
935
|
});
|
|
938
936
|
process2.on("error", (err) => {
|
|
939
937
|
stderr += err.toString();
|
|
@@ -953,28 +951,20 @@ function executeProcess(cfg) {
|
|
|
953
951
|
}
|
|
954
952
|
|
|
955
953
|
// packages/utils/src/lib/git.ts
|
|
956
|
-
import simpleGit from "simple-git";
|
|
954
|
+
import { simpleGit } from "simple-git";
|
|
957
955
|
var git = simpleGit();
|
|
958
956
|
async function getLatestCommit() {
|
|
959
957
|
const log = await git.log({
|
|
960
958
|
maxCount: 1,
|
|
961
959
|
format: { hash: "%H", message: "%s", author: "%an", date: "%ad" }
|
|
962
960
|
});
|
|
963
|
-
return log
|
|
961
|
+
return log.latest;
|
|
964
962
|
}
|
|
965
963
|
|
|
966
964
|
// packages/utils/src/lib/group-by-status.ts
|
|
967
965
|
function groupByStatus(results) {
|
|
968
966
|
return results.reduce(
|
|
969
|
-
(acc, result) => {
|
|
970
|
-
if (result.status === "fulfilled") {
|
|
971
|
-
return { ...acc, fulfilled: [...acc.fulfilled, result] };
|
|
972
|
-
}
|
|
973
|
-
if (result.status === "rejected") {
|
|
974
|
-
return { ...acc, rejected: [...acc.rejected, result] };
|
|
975
|
-
}
|
|
976
|
-
return acc;
|
|
977
|
-
},
|
|
967
|
+
(acc, result) => result.status === "fulfilled" ? { ...acc, fulfilled: [...acc.fulfilled, result] } : { ...acc, rejected: [...acc.rejected, result] },
|
|
978
968
|
{ fulfilled: [], rejected: [] }
|
|
979
969
|
);
|
|
980
970
|
}
|
|
@@ -1089,10 +1079,10 @@ function tableMd(data, align) {
|
|
|
1089
1079
|
if (data.length === 0) {
|
|
1090
1080
|
throw new Error("Data can't be empty");
|
|
1091
1081
|
}
|
|
1092
|
-
align
|
|
1082
|
+
const alignmentSetting = align ?? data[0]?.map(() => "c");
|
|
1093
1083
|
const tableContent = data.map((arr) => `|${arr.join("|")}|`);
|
|
1094
|
-
const
|
|
1095
|
-
return tableContent
|
|
1084
|
+
const alignmentRow = `|${alignmentSetting?.map((s) => alignString.get(s)).join("|")}|`;
|
|
1085
|
+
return tableContent[0] + NEW_LINE + alignmentRow + NEW_LINE + tableContent.slice(1).join(NEW_LINE);
|
|
1096
1086
|
}
|
|
1097
1087
|
function tableHtml(data) {
|
|
1098
1088
|
if (data.length === 0) {
|
|
@@ -1145,15 +1135,15 @@ function reportToCategoriesSection(report) {
|
|
|
1145
1135
|
category.score
|
|
1146
1136
|
)} Score: ${style(formatReportScore(category.score))}`;
|
|
1147
1137
|
const categoryDocs = getDocsAndDescription(category);
|
|
1148
|
-
const categoryMDItems = category.refs.reduce((
|
|
1138
|
+
const categoryMDItems = category.refs.reduce((refAcc, ref) => {
|
|
1149
1139
|
if (ref.type === "group") {
|
|
1150
1140
|
const group = getGroupWithAudits(ref.slug, ref.plugin, plugins);
|
|
1151
1141
|
const mdGroupItem = groupItemToCategorySection(group, plugins);
|
|
1152
|
-
return
|
|
1142
|
+
return refAcc + mdGroupItem + NEW_LINE;
|
|
1153
1143
|
} else {
|
|
1154
1144
|
const audit = getAuditByRef(ref, plugins);
|
|
1155
1145
|
const mdAuditItem = auditItemToCategorySection(audit, plugins);
|
|
1156
|
-
return
|
|
1146
|
+
return refAcc + mdAuditItem + NEW_LINE;
|
|
1157
1147
|
}
|
|
1158
1148
|
}, "");
|
|
1159
1149
|
return acc + NEW_LINE + categoryTitle + NEW_LINE + NEW_LINE + categoryDocs + categoryScore + NEW_LINE + categoryMDItems;
|
|
@@ -1164,7 +1154,7 @@ function auditItemToCategorySection(audit, plugins) {
|
|
|
1164
1154
|
const pluginTitle = getPluginNameFromSlug(audit.plugin, plugins);
|
|
1165
1155
|
const auditTitle = link(
|
|
1166
1156
|
`#${slugify(audit.title)}-${slugify(pluginTitle)}`,
|
|
1167
|
-
audit
|
|
1157
|
+
audit.title
|
|
1168
1158
|
);
|
|
1169
1159
|
return li(
|
|
1170
1160
|
`${getSquaredScoreMarker(
|
|
@@ -1181,69 +1171,57 @@ function groupItemToCategorySection(group, plugins) {
|
|
|
1181
1171
|
const groupAudits = group.audits.reduce((acc, audit) => {
|
|
1182
1172
|
const auditTitle = link(
|
|
1183
1173
|
`#${slugify(audit.title)}-${slugify(pluginTitle)}`,
|
|
1184
|
-
audit
|
|
1174
|
+
audit.title
|
|
1185
1175
|
);
|
|
1186
|
-
acc
|
|
1176
|
+
return `${acc} ${li(
|
|
1187
1177
|
`${getSquaredScoreMarker(audit.score)} ${auditTitle} - ${getAuditResult(
|
|
1188
1178
|
audit
|
|
1189
1179
|
)}`
|
|
1190
|
-
)}`;
|
|
1191
|
-
acc += NEW_LINE;
|
|
1192
|
-
return acc;
|
|
1180
|
+
)}${NEW_LINE}`;
|
|
1193
1181
|
}, "");
|
|
1194
1182
|
return groupTitle + NEW_LINE + groupAudits;
|
|
1195
1183
|
}
|
|
1196
1184
|
function reportToAuditsSection(report) {
|
|
1197
|
-
const auditsSection = report.plugins.reduce((
|
|
1198
|
-
const auditsData = plugin.audits.reduce((
|
|
1185
|
+
const auditsSection = report.plugins.reduce((pluginAcc, plugin) => {
|
|
1186
|
+
const auditsData = plugin.audits.reduce((auditAcc, audit) => {
|
|
1199
1187
|
const auditTitle = `${audit.title} (${getPluginNameFromSlug(
|
|
1200
1188
|
audit.plugin,
|
|
1201
1189
|
report.plugins
|
|
1202
1190
|
)})`;
|
|
1203
|
-
|
|
1204
|
-
audit.score
|
|
1205
|
-
)} ${getAuditResult(audit, true)} (score: ${formatReportScore(
|
|
1206
|
-
audit.score
|
|
1207
|
-
)})`;
|
|
1208
|
-
const docsItem = getDocsAndDescription(audit);
|
|
1209
|
-
acc2 += h3(auditTitle);
|
|
1210
|
-
acc2 += NEW_LINE;
|
|
1211
|
-
acc2 += NEW_LINE;
|
|
1212
|
-
if (!audit.details?.issues?.length) {
|
|
1213
|
-
acc2 += detailsTitle;
|
|
1214
|
-
acc2 += NEW_LINE;
|
|
1215
|
-
acc2 += NEW_LINE;
|
|
1216
|
-
acc2 += docsItem;
|
|
1217
|
-
return acc2;
|
|
1218
|
-
}
|
|
1219
|
-
const detailsTableData = [
|
|
1220
|
-
detailsTableHeaders,
|
|
1221
|
-
...audit.details.issues.map((issue) => {
|
|
1222
|
-
const severity = `${getSeverityIcon(issue.severity)} <i>${issue.severity}</i>`;
|
|
1223
|
-
const message = issue.message;
|
|
1224
|
-
if (!issue.source) {
|
|
1225
|
-
return [severity, message, "", ""];
|
|
1226
|
-
}
|
|
1227
|
-
const file = `<code>${issue.source?.file}</code>`;
|
|
1228
|
-
if (!issue.source.position) {
|
|
1229
|
-
return [severity, message, file, ""];
|
|
1230
|
-
}
|
|
1231
|
-
const { startLine, endLine } = issue.source.position;
|
|
1232
|
-
const line = `${startLine || ""}${endLine && startLine !== endLine ? `-${endLine}` : ""}`;
|
|
1233
|
-
return [severity, message, file, line];
|
|
1234
|
-
})
|
|
1235
|
-
];
|
|
1236
|
-
const detailsTable = `<h4>Issues</h4>${tableHtml(detailsTableData)}`;
|
|
1237
|
-
acc2 += details(detailsTitle, detailsTable);
|
|
1238
|
-
acc2 += NEW_LINE;
|
|
1239
|
-
acc2 += NEW_LINE;
|
|
1240
|
-
acc2 += docsItem;
|
|
1241
|
-
return acc2;
|
|
1191
|
+
return auditAcc + h3(auditTitle) + NEW_LINE + NEW_LINE + reportToDetailsSection(audit) + NEW_LINE + NEW_LINE + getDocsAndDescription(audit);
|
|
1242
1192
|
}, "");
|
|
1243
|
-
return
|
|
1193
|
+
return pluginAcc + auditsData;
|
|
1244
1194
|
}, "");
|
|
1245
1195
|
return h2("\u{1F6E1}\uFE0F Audits") + NEW_LINE + NEW_LINE + auditsSection;
|
|
1246
1196
|
}
|
|
1197
|
+
function reportToDetailsSection(audit) {
|
|
1198
|
+
const detailsTitle = `${getSquaredScoreMarker(audit.score)} ${getAuditResult(
|
|
1199
|
+
audit,
|
|
1200
|
+
true
|
|
1201
|
+
)} (score: ${formatReportScore(audit.score)})`;
|
|
1202
|
+
if (!audit.details?.issues.length) {
|
|
1203
|
+
return detailsTitle;
|
|
1204
|
+
}
|
|
1205
|
+
const detailsTableData = [
|
|
1206
|
+
detailsTableHeaders,
|
|
1207
|
+
...audit.details.issues.map((issue) => {
|
|
1208
|
+
const severity = `${getSeverityIcon(issue.severity)} <i>${issue.severity}</i>`;
|
|
1209
|
+
const message = issue.message;
|
|
1210
|
+
if (!issue.source) {
|
|
1211
|
+
return [severity, message, "", ""];
|
|
1212
|
+
}
|
|
1213
|
+
const file = `<code>${issue.source.file}</code>`;
|
|
1214
|
+
if (!issue.source.position) {
|
|
1215
|
+
return [severity, message, file, ""];
|
|
1216
|
+
}
|
|
1217
|
+
const { startLine, endLine } = issue.source.position;
|
|
1218
|
+
const line = `${startLine || ""}${endLine && startLine !== endLine ? `-${endLine}` : ""}`;
|
|
1219
|
+
return [severity, message, file, line];
|
|
1220
|
+
})
|
|
1221
|
+
];
|
|
1222
|
+
const detailsTable = `<h4>Issues</h4>${tableHtml(detailsTableData)}`;
|
|
1223
|
+
return details(detailsTitle, detailsTable);
|
|
1224
|
+
}
|
|
1247
1225
|
function reportToAboutSection(report, commitData) {
|
|
1248
1226
|
const date = (/* @__PURE__ */ new Date()).toString();
|
|
1249
1227
|
const { duration, version: version2, plugins, categories } = report;
|
|
@@ -1261,11 +1239,11 @@ function reportToAboutSection(report, commitData) {
|
|
|
1261
1239
|
];
|
|
1262
1240
|
const pluginMetaTable = [
|
|
1263
1241
|
pluginMetaTableHeaders,
|
|
1264
|
-
...plugins.map((
|
|
1265
|
-
title,
|
|
1266
|
-
audits.length.toString(),
|
|
1267
|
-
style(
|
|
1268
|
-
formatDuration(
|
|
1242
|
+
...plugins.map((plugin) => [
|
|
1243
|
+
plugin.title,
|
|
1244
|
+
plugin.audits.length.toString(),
|
|
1245
|
+
style(plugin.version || "", ["c"]),
|
|
1246
|
+
formatDuration(plugin.duration)
|
|
1269
1247
|
])
|
|
1270
1248
|
];
|
|
1271
1249
|
return (
|
|
@@ -1300,7 +1278,7 @@ function getAuditResult(audit, isHtml = false) {
|
|
|
1300
1278
|
// packages/utils/src/lib/reports/generate-stdout-summary.ts
|
|
1301
1279
|
import cliui from "@isaacs/cliui";
|
|
1302
1280
|
import chalk3 from "chalk";
|
|
1303
|
-
import
|
|
1281
|
+
import CliTable3 from "cli-table3";
|
|
1304
1282
|
function addLine(line = "") {
|
|
1305
1283
|
return line + NEW_LINE;
|
|
1306
1284
|
}
|
|
@@ -1316,20 +1294,20 @@ function reportToDetailSection(report) {
|
|
|
1316
1294
|
return plugins.reduce((acc, plugin) => {
|
|
1317
1295
|
const { title, audits } = plugin;
|
|
1318
1296
|
const ui = cliui({ width: TERMINAL_WIDTH });
|
|
1319
|
-
audits.forEach((
|
|
1297
|
+
audits.forEach((audit) => {
|
|
1320
1298
|
ui.div(
|
|
1321
1299
|
{
|
|
1322
|
-
text: withColor({ score, text: "\u25CF" }),
|
|
1300
|
+
text: withColor({ score: audit.score, text: "\u25CF" }),
|
|
1323
1301
|
width: 2,
|
|
1324
1302
|
padding: [0, 1, 0, 0]
|
|
1325
1303
|
},
|
|
1326
1304
|
{
|
|
1327
|
-
text:
|
|
1305
|
+
text: audit.title,
|
|
1328
1306
|
// eslint-disable-next-line no-magic-numbers
|
|
1329
1307
|
padding: [0, 3, 0, 0]
|
|
1330
1308
|
},
|
|
1331
1309
|
{
|
|
1332
|
-
text: chalk3.cyanBright(displayValue || `${value}`),
|
|
1310
|
+
text: chalk3.cyanBright(audit.displayValue || `${audit.value}`),
|
|
1333
1311
|
width: 10,
|
|
1334
1312
|
padding: [0, 0, 0, 0]
|
|
1335
1313
|
}
|
|
@@ -1342,7 +1320,7 @@ function reportToOverviewSection2({
|
|
|
1342
1320
|
categories,
|
|
1343
1321
|
plugins
|
|
1344
1322
|
}) {
|
|
1345
|
-
const table = new
|
|
1323
|
+
const table = new CliTable3({
|
|
1346
1324
|
head: reportRawOverviewTableHeaders,
|
|
1347
1325
|
colAligns: ["left", "right", "right"],
|
|
1348
1326
|
style: {
|
|
@@ -1375,16 +1353,7 @@ function toArray(val) {
|
|
|
1375
1353
|
return Array.isArray(val) ? val : [val];
|
|
1376
1354
|
}
|
|
1377
1355
|
function deepClone(obj) {
|
|
1378
|
-
|
|
1379
|
-
return obj;
|
|
1380
|
-
}
|
|
1381
|
-
const cloned = Array.isArray(obj) ? [] : {};
|
|
1382
|
-
for (const key in obj) {
|
|
1383
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1384
|
-
cloned[key] = deepClone(obj[key]);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
return cloned;
|
|
1356
|
+
return obj == null || typeof obj !== "object" ? obj : structuredClone(obj);
|
|
1388
1357
|
}
|
|
1389
1358
|
|
|
1390
1359
|
// packages/utils/src/lib/reports/scoring.ts
|
|
@@ -1407,15 +1376,12 @@ function calculateScore(refs, scoreFn) {
|
|
|
1407
1376
|
return numerator / denominator;
|
|
1408
1377
|
}
|
|
1409
1378
|
function scoreReport(report) {
|
|
1410
|
-
const scoredReport = deepClone(report);
|
|
1411
1379
|
const allScoredAuditsAndGroups = /* @__PURE__ */ new Map();
|
|
1412
|
-
|
|
1413
|
-
const { slug, audits } = plugin;
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
audit.plugin = slug;
|
|
1418
|
-
allScoredAuditsAndGroups.set(key, audit);
|
|
1380
|
+
const scoredPlugins = report.plugins.map((plugin) => {
|
|
1381
|
+
const { slug, audits, groups } = plugin;
|
|
1382
|
+
const updatedAudits = audits.map((audit) => ({ ...audit, plugin: slug }));
|
|
1383
|
+
updatedAudits.forEach((audit) => {
|
|
1384
|
+
allScoredAuditsAndGroups.set(`${slug}-${audit.slug}-audit`, audit);
|
|
1419
1385
|
});
|
|
1420
1386
|
function groupScoreFn(ref) {
|
|
1421
1387
|
const score = allScoredAuditsAndGroups.get(
|
|
@@ -1428,13 +1394,15 @@ function scoreReport(report) {
|
|
|
1428
1394
|
}
|
|
1429
1395
|
return score;
|
|
1430
1396
|
}
|
|
1431
|
-
groups
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1397
|
+
const scoredGroups = groups?.map((group) => ({
|
|
1398
|
+
...group,
|
|
1399
|
+
score: calculateScore(group.refs, groupScoreFn),
|
|
1400
|
+
plugin: slug
|
|
1401
|
+
})) ?? [];
|
|
1402
|
+
scoredGroups.forEach((group) => {
|
|
1403
|
+
allScoredAuditsAndGroups.set(`${slug}-${group.slug}-group`, group);
|
|
1436
1404
|
});
|
|
1437
|
-
plugin
|
|
1405
|
+
return { ...plugin, audits: updatedAudits, groups: scoredGroups };
|
|
1438
1406
|
});
|
|
1439
1407
|
function catScoreFn(ref) {
|
|
1440
1408
|
const key = `${ref.plugin}-${ref.slug}-${ref.type}`;
|
|
@@ -1446,13 +1414,15 @@ function scoreReport(report) {
|
|
|
1446
1414
|
}
|
|
1447
1415
|
return item.score;
|
|
1448
1416
|
}
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1417
|
+
const scoredCategories = report.categories.map((category) => ({
|
|
1418
|
+
...category,
|
|
1419
|
+
score: calculateScore(category.refs, catScoreFn)
|
|
1420
|
+
}));
|
|
1421
|
+
return {
|
|
1422
|
+
...deepClone(report),
|
|
1423
|
+
plugins: scoredPlugins,
|
|
1424
|
+
categories: scoredCategories
|
|
1425
|
+
};
|
|
1456
1426
|
}
|
|
1457
1427
|
|
|
1458
1428
|
// packages/utils/src/lib/reports/sorting.ts
|
|
@@ -1475,7 +1445,7 @@ function sortReport(report) {
|
|
|
1475
1445
|
);
|
|
1476
1446
|
const sortedAuditsAndGroups = [
|
|
1477
1447
|
...groups,
|
|
1478
|
-
...audits.sort(compareCategoryAudits)
|
|
1448
|
+
...[...audits].sort(compareCategoryAudits)
|
|
1479
1449
|
];
|
|
1480
1450
|
const sortedRefs = [...category.refs].sort((a, b) => {
|
|
1481
1451
|
const aIndex = sortedAuditsAndGroups.findIndex(
|
|
@@ -1488,7 +1458,14 @@ function sortReport(report) {
|
|
|
1488
1458
|
});
|
|
1489
1459
|
return { ...category, refs: sortedRefs };
|
|
1490
1460
|
});
|
|
1491
|
-
|
|
1461
|
+
return {
|
|
1462
|
+
...report,
|
|
1463
|
+
categories: sortedCategories,
|
|
1464
|
+
plugins: sortPlugins(plugins)
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
function sortPlugins(plugins) {
|
|
1468
|
+
return plugins.map((plugin) => ({
|
|
1492
1469
|
...plugin,
|
|
1493
1470
|
audits: [...plugin.audits].sort(compareAudits).map(
|
|
1494
1471
|
(audit) => audit.details?.issues ? {
|
|
@@ -1500,11 +1477,6 @@ function sortReport(report) {
|
|
|
1500
1477
|
} : audit
|
|
1501
1478
|
)
|
|
1502
1479
|
}));
|
|
1503
|
-
return {
|
|
1504
|
-
...report,
|
|
1505
|
-
categories: sortedCategories,
|
|
1506
|
-
plugins: sortedPlugins
|
|
1507
|
-
};
|
|
1508
1480
|
}
|
|
1509
1481
|
|
|
1510
1482
|
// packages/utils/src/lib/verbose-utils.ts
|
|
@@ -1704,7 +1676,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1704
1676
|
|
|
1705
1677
|
// packages/core/package.json
|
|
1706
1678
|
var name = "@code-pushup/core";
|
|
1707
|
-
var version = "0.
|
|
1679
|
+
var version = "0.9.0";
|
|
1708
1680
|
|
|
1709
1681
|
// packages/core/src/lib/implementation/collect.ts
|
|
1710
1682
|
async function collect(options2) {
|
|
@@ -1825,7 +1797,7 @@ async function upload(options2, uploadFn = uploadToPortal) {
|
|
|
1825
1797
|
if (!options2.upload) {
|
|
1826
1798
|
throw new Error("upload config must be set");
|
|
1827
1799
|
}
|
|
1828
|
-
const { apiKey, server, organization, project } = options2.upload;
|
|
1800
|
+
const { apiKey, server, organization, project, timeout } = options2.upload;
|
|
1829
1801
|
const report = await loadReport({
|
|
1830
1802
|
...persist,
|
|
1831
1803
|
format: "json"
|
|
@@ -1840,7 +1812,7 @@ async function upload(options2, uploadFn = uploadToPortal) {
|
|
|
1840
1812
|
commit: commitData.hash,
|
|
1841
1813
|
...jsonReportToGql(report)
|
|
1842
1814
|
};
|
|
1843
|
-
return uploadFn({ apiKey, server, data });
|
|
1815
|
+
return uploadFn({ apiKey, server, data, timeout });
|
|
1844
1816
|
}
|
|
1845
1817
|
|
|
1846
1818
|
// packages/core/src/lib/collect-and-persist.ts
|
package/package.json
CHANGED