@code-pushup/utils 0.12.1 → 0.12.2
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 +13 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -38,6 +38,9 @@ function exists(value) {
|
|
|
38
38
|
return value != null;
|
|
39
39
|
}
|
|
40
40
|
function getMissingRefsForCategories(categories, plugins) {
|
|
41
|
+
if (categories.length === 0) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
41
44
|
const auditRefsFromCategory = categories.flatMap(
|
|
42
45
|
({ refs }) => refs.filter(({ type }) => type === "audit").map(({ plugin, slug }) => `${plugin}/${slug}`)
|
|
43
46
|
);
|
|
@@ -312,7 +315,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
312
315
|
}
|
|
313
316
|
var categoriesSchema = z5.array(categoryConfigSchema, {
|
|
314
317
|
description: "Categorization of individual audits"
|
|
315
|
-
}).
|
|
318
|
+
}).refine(
|
|
316
319
|
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
317
320
|
(categoryCfg) => ({
|
|
318
321
|
message: duplicateSlugCategoriesErrorMsg(categoryCfg)
|
|
@@ -470,15 +473,15 @@ var unrefinedCoreConfigSchema = z11.object({
|
|
|
470
473
|
persist: persistConfigSchema.optional(),
|
|
471
474
|
/** portal configuration for uploading results */
|
|
472
475
|
upload: uploadConfigSchema.optional(),
|
|
473
|
-
categories: categoriesSchema
|
|
476
|
+
categories: categoriesSchema.optional()
|
|
474
477
|
});
|
|
475
478
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
476
479
|
function refineCoreConfig(schema) {
|
|
477
480
|
return schema.refine(
|
|
478
|
-
(coreCfg) => !getMissingRefsForCategories(coreCfg.categories, coreCfg.plugins),
|
|
481
|
+
(coreCfg) => !getMissingRefsForCategories(coreCfg.categories ?? [], coreCfg.plugins),
|
|
479
482
|
(coreCfg) => ({
|
|
480
483
|
message: missingRefsForCategoriesErrorMsg(
|
|
481
|
-
coreCfg.categories,
|
|
484
|
+
coreCfg.categories ?? [],
|
|
482
485
|
coreCfg.plugins
|
|
483
486
|
)
|
|
484
487
|
})
|
|
@@ -1155,12 +1158,13 @@ function tableHtml(data) {
|
|
|
1155
1158
|
|
|
1156
1159
|
// packages/utils/src/lib/reports/generate-md-report.ts
|
|
1157
1160
|
function generateMdReport(report, commitData) {
|
|
1161
|
+
const printCategories = report.categories.length > 0;
|
|
1158
1162
|
return (
|
|
1159
1163
|
// header section
|
|
1160
1164
|
// eslint-disable-next-line prefer-template
|
|
1161
|
-
reportToHeaderSection() + NEW_LINE + // overview section
|
|
1162
|
-
reportToOverviewSection(report) + NEW_LINE + NEW_LINE + // categories section
|
|
1163
|
-
reportToCategoriesSection(report) + NEW_LINE + NEW_LINE + // audits section
|
|
1165
|
+
reportToHeaderSection() + NEW_LINE + // categories overview section
|
|
1166
|
+
(printCategories ? reportToOverviewSection(report) + NEW_LINE + NEW_LINE : "") + // categories section
|
|
1167
|
+
(printCategories ? reportToCategoriesSection(report) + NEW_LINE + NEW_LINE : "") + // audits section
|
|
1164
1168
|
reportToAuditsSection(report) + NEW_LINE + NEW_LINE + // about section
|
|
1165
1169
|
reportToAboutSection(report, commitData) + NEW_LINE + NEW_LINE + // footer section
|
|
1166
1170
|
`${FOOTER_PREFIX} ${link(README_LINK, "Code PushUp")}`
|
|
@@ -1337,7 +1341,8 @@ function addLine(line = "") {
|
|
|
1337
1341
|
return line + NEW_LINE;
|
|
1338
1342
|
}
|
|
1339
1343
|
function generateStdoutSummary(report) {
|
|
1340
|
-
|
|
1344
|
+
const printCategories = report.categories.length > 0;
|
|
1345
|
+
return addLine(reportToHeaderSection2(report)) + addLine() + addLine(reportToDetailSection(report)) + (printCategories ? addLine(reportToOverviewSection2(report)) : "") + addLine(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
|
|
1341
1346
|
}
|
|
1342
1347
|
function reportToHeaderSection2(report) {
|
|
1343
1348
|
const { packageName, version } = report;
|