@code-pushup/core 0.53.1 → 0.55.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
|
@@ -29,7 +29,7 @@ function exists(value) {
|
|
|
29
29
|
return value != null;
|
|
30
30
|
}
|
|
31
31
|
function getMissingRefsForCategories(categories, plugins) {
|
|
32
|
-
if (categories.length === 0) {
|
|
32
|
+
if (!categories || categories.length === 0) {
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
const auditRefsFromCategory = categories.flatMap(
|
|
@@ -106,7 +106,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
|
106
106
|
message: `The filename has to be valid`
|
|
107
107
|
}).min(1, { message: "file name is invalid" });
|
|
108
108
|
var positiveIntSchema = z.number().int().positive();
|
|
109
|
-
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
110
109
|
var nonnegativeNumberSchema = z.number().nonnegative();
|
|
111
110
|
function packageVersionSchema(options) {
|
|
112
111
|
const { versionDescription = "NPM version of the package", required } = options ?? {};
|
|
@@ -529,12 +528,9 @@ var unrefinedCoreConfigSchema = z14.object({
|
|
|
529
528
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
530
529
|
function refineCoreConfig(schema) {
|
|
531
530
|
return schema.refine(
|
|
532
|
-
(
|
|
533
|
-
(
|
|
534
|
-
message: missingRefsForCategoriesErrorMsg(
|
|
535
|
-
coreCfg.categories ?? [],
|
|
536
|
-
coreCfg.plugins
|
|
537
|
-
)
|
|
531
|
+
({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
|
|
532
|
+
({ categories, plugins }) => ({
|
|
533
|
+
message: missingRefsForCategoriesErrorMsg(categories, plugins)
|
|
538
534
|
})
|
|
539
535
|
);
|
|
540
536
|
}
|
|
@@ -590,19 +586,16 @@ var reportSchema = packageVersionSchema({
|
|
|
590
586
|
).merge(
|
|
591
587
|
z15.object(
|
|
592
588
|
{
|
|
593
|
-
categories: z15.array(categoryConfigSchema),
|
|
594
589
|
plugins: z15.array(pluginReportSchema).min(1),
|
|
590
|
+
categories: z15.array(categoryConfigSchema).optional(),
|
|
595
591
|
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
596
592
|
},
|
|
597
593
|
{ description: "Collect output data" }
|
|
598
594
|
)
|
|
599
595
|
).refine(
|
|
600
|
-
(
|
|
601
|
-
(
|
|
602
|
-
message: missingRefsForCategoriesErrorMsg(
|
|
603
|
-
report.categories,
|
|
604
|
-
report.plugins
|
|
605
|
-
)
|
|
596
|
+
({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
|
|
597
|
+
({ categories, plugins }) => ({
|
|
598
|
+
message: missingRefsForCategoriesErrorMsg(categories, plugins)
|
|
606
599
|
})
|
|
607
600
|
);
|
|
608
601
|
|
|
@@ -654,7 +647,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
654
647
|
z16.object({
|
|
655
648
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
656
649
|
z16.object({
|
|
657
|
-
diff: z16.number().
|
|
650
|
+
diff: z16.number().describe("Value change (`values.after - values.before`)")
|
|
658
651
|
})
|
|
659
652
|
).describe("Audit `value` comparison"),
|
|
660
653
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -1000,6 +993,7 @@ function executeProcess(cfg) {
|
|
|
1000
993
|
return new Promise((resolve, reject) => {
|
|
1001
994
|
const spawnedProcess = spawn(command, args ?? [], {
|
|
1002
995
|
shell: true,
|
|
996
|
+
windowsHide: true,
|
|
1003
997
|
...options
|
|
1004
998
|
});
|
|
1005
999
|
let stdout = "";
|
|
@@ -1667,7 +1661,7 @@ function getSortableGroupByRef({ plugin, slug, weight }, plugins) {
|
|
|
1667
1661
|
}
|
|
1668
1662
|
function sortReport(report) {
|
|
1669
1663
|
const { categories, plugins } = report;
|
|
1670
|
-
const sortedCategories = categories
|
|
1664
|
+
const sortedCategories = categories?.map((category) => {
|
|
1671
1665
|
const { audits, groups } = category.refs.reduce(
|
|
1672
1666
|
(acc, ref) => ({
|
|
1673
1667
|
...acc,
|
|
@@ -1807,14 +1801,15 @@ function auditDetailsAuditValue({
|
|
|
1807
1801
|
String(displayValue ?? value)
|
|
1808
1802
|
)} (score: ${formatReportScore(score)})`;
|
|
1809
1803
|
}
|
|
1804
|
+
function hasCategories(report) {
|
|
1805
|
+
return !!report.categories && report.categories.length > 0;
|
|
1806
|
+
}
|
|
1810
1807
|
function generateMdReport(report, options) {
|
|
1811
|
-
return new MarkdownDocument3().heading(HIERARCHY.level_1, REPORT_HEADLINE_TEXT).$
|
|
1812
|
-
report
|
|
1813
|
-
(
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
)
|
|
1817
|
-
).$concat(auditsSection(report, options), aboutSection(report)).rule().paragraph(md4`${FOOTER_PREFIX} ${md4.link(README_LINK, "Code PushUp")}`).toString();
|
|
1808
|
+
return new MarkdownDocument3().heading(HIERARCHY.level_1, REPORT_HEADLINE_TEXT).$concat(
|
|
1809
|
+
...hasCategories(report) ? [categoriesOverviewSection(report), categoriesDetailsSection(report)] : [],
|
|
1810
|
+
auditsSection(report, options),
|
|
1811
|
+
aboutSection(report)
|
|
1812
|
+
).rule().paragraph(md4`${FOOTER_PREFIX} ${md4.link(README_LINK, "Code PushUp")}`).toString();
|
|
1818
1813
|
}
|
|
1819
1814
|
function auditDetailsIssues(issues = [], options) {
|
|
1820
1815
|
if (issues.length === 0) {
|
|
@@ -1916,7 +1911,7 @@ function reportMetaTable({
|
|
|
1916
1911
|
md4.code(version2),
|
|
1917
1912
|
formatDuration(duration),
|
|
1918
1913
|
plugins.length.toString(),
|
|
1919
|
-
categories
|
|
1914
|
+
(categories?.length ?? 0).toString(),
|
|
1920
1915
|
plugins.reduce((acc, { audits }) => acc + audits.length, 0).toString()
|
|
1921
1916
|
]
|
|
1922
1917
|
]
|
|
@@ -2248,24 +2243,26 @@ function log(msg = "") {
|
|
|
2248
2243
|
ui().logger.log(msg);
|
|
2249
2244
|
}
|
|
2250
2245
|
function logStdoutSummary(report, verbose = false) {
|
|
2251
|
-
const
|
|
2252
|
-
log(reportToHeaderSection(
|
|
2246
|
+
const { plugins, categories, packageName, version: version2 } = report;
|
|
2247
|
+
log(reportToHeaderSection({ packageName, version: version2 }));
|
|
2253
2248
|
log();
|
|
2254
|
-
logPlugins(
|
|
2255
|
-
if (
|
|
2256
|
-
logCategories(
|
|
2249
|
+
logPlugins(plugins, verbose);
|
|
2250
|
+
if (categories && categories.length > 0) {
|
|
2251
|
+
logCategories({ plugins, categories });
|
|
2257
2252
|
}
|
|
2258
2253
|
log(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
|
|
2259
2254
|
log();
|
|
2260
2255
|
}
|
|
2261
|
-
function reportToHeaderSection(
|
|
2262
|
-
|
|
2256
|
+
function reportToHeaderSection({
|
|
2257
|
+
packageName,
|
|
2258
|
+
version: version2
|
|
2259
|
+
}) {
|
|
2263
2260
|
return `${bold4(REPORT_HEADLINE_TEXT)} - ${packageName}@${version2}`;
|
|
2264
2261
|
}
|
|
2265
2262
|
function logPlugins(plugins, verbose) {
|
|
2266
2263
|
plugins.forEach((plugin) => {
|
|
2267
2264
|
const { title, audits } = plugin;
|
|
2268
|
-
const filteredAudits = verbose ? audits : audits.filter(({ score }) => score !== 1);
|
|
2265
|
+
const filteredAudits = verbose || audits.length === 1 ? audits : audits.filter(({ score }) => score !== 1);
|
|
2269
2266
|
const diff = audits.length - filteredAudits.length;
|
|
2270
2267
|
logAudits(title, filteredAudits);
|
|
2271
2268
|
if (diff > 0) {
|
|
@@ -2305,7 +2302,10 @@ function logRow(score, title, value) {
|
|
|
2305
2302
|
] : []
|
|
2306
2303
|
]);
|
|
2307
2304
|
}
|
|
2308
|
-
function logCategories({
|
|
2305
|
+
function logCategories({
|
|
2306
|
+
plugins,
|
|
2307
|
+
categories
|
|
2308
|
+
}) {
|
|
2309
2309
|
const hAlign = (idx) => idx === 0 ? "left" : "right";
|
|
2310
2310
|
const rows = categories.map(({ title, score, refs, isBinary }) => [
|
|
2311
2311
|
title,
|
|
@@ -2387,7 +2387,7 @@ function scoreReport(report) {
|
|
|
2387
2387
|
}
|
|
2388
2388
|
return item.score;
|
|
2389
2389
|
}
|
|
2390
|
-
const scoredCategories = report.categories
|
|
2390
|
+
const scoredCategories = report.categories?.map((category) => ({
|
|
2391
2391
|
...category,
|
|
2392
2392
|
score: calculateScore(category.refs, catScoreFn)
|
|
2393
2393
|
}));
|
|
@@ -2450,7 +2450,7 @@ var verboseUtils = (verbose = false) => ({
|
|
|
2450
2450
|
|
|
2451
2451
|
// packages/core/package.json
|
|
2452
2452
|
var name = "@code-pushup/core";
|
|
2453
|
-
var version = "0.
|
|
2453
|
+
var version = "0.55.0";
|
|
2454
2454
|
|
|
2455
2455
|
// packages/core/src/lib/implementation/execute-plugin.ts
|
|
2456
2456
|
import { bold as bold5 } from "ansis";
|
|
@@ -2714,8 +2714,8 @@ import { join as join5 } from "node:path";
|
|
|
2714
2714
|
// packages/core/src/lib/implementation/compare-scorables.ts
|
|
2715
2715
|
function compareCategories(reports) {
|
|
2716
2716
|
const { pairs, added, removed } = matchArrayItemsByKey({
|
|
2717
|
-
before: reports.before.categories,
|
|
2718
|
-
after: reports.after.categories,
|
|
2717
|
+
before: reports.before.categories ?? [],
|
|
2718
|
+
after: reports.after.categories ?? [],
|
|
2719
2719
|
key: "slug"
|
|
2720
2720
|
});
|
|
2721
2721
|
const { changed, unchanged } = comparePairs(
|
|
@@ -2956,7 +2956,7 @@ function reportToGQL(report) {
|
|
|
2956
2956
|
commandStartDate: report.date,
|
|
2957
2957
|
commandDuration: report.duration,
|
|
2958
2958
|
plugins: report.plugins.map(pluginToGQL),
|
|
2959
|
-
categories: report.categories.map(categoryToGQL)
|
|
2959
|
+
categories: (report.categories ?? []).map(categoryToGQL)
|
|
2960
2960
|
};
|
|
2961
2961
|
}
|
|
2962
2962
|
function pluginToGQL(plugin) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core business logic for the used by the Code PushUp CLI",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/core#readme",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"main": "./index.js",
|
|
42
42
|
"types": "./src/index.d.ts",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@code-pushup/models": "0.
|
|
45
|
-
"@code-pushup/utils": "0.
|
|
44
|
+
"@code-pushup/models": "0.55.0",
|
|
45
|
+
"@code-pushup/utils": "0.55.0",
|
|
46
46
|
"ansis": "^3.3.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CoreConfig, type PersistConfig } from '@code-pushup/models';
|
|
2
2
|
import type { GlobalOptions } from './types';
|
|
3
|
-
export type CollectAndPersistReportsOptions =
|
|
3
|
+
export type CollectAndPersistReportsOptions = Pick<CoreConfig, 'plugins' | 'categories'> & {
|
|
4
4
|
persist: Required<PersistConfig>;
|
|
5
5
|
} & Partial<GlobalOptions>;
|
|
6
6
|
export declare function collectAndPersistReports(options: CollectAndPersistReportsOptions): Promise<void>;
|
package/src/lib/history.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type HistoryOnlyOptions = {
|
|
|
5
5
|
skipUploads?: boolean;
|
|
6
6
|
forceCleanStatus?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export type HistoryOptions =
|
|
8
|
+
export type HistoryOptions = Pick<CoreConfig, 'plugins' | 'categories'> & {
|
|
9
9
|
persist: Required<PersistConfig>;
|
|
10
10
|
upload?: Required<UploadConfig>;
|
|
11
11
|
} & HistoryOnlyOptions & Partial<GlobalOptions>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CoreConfig, Report } from '@code-pushup/models';
|
|
2
2
|
import type { GlobalOptions } from '../types';
|
|
3
|
-
export type CollectOptions =
|
|
3
|
+
export type CollectOptions = Pick<CoreConfig, 'plugins' | 'categories'> & Partial<GlobalOptions>;
|
|
4
4
|
/**
|
|
5
5
|
* Run audits, collect plugin output and aggregate it into a JSON object
|
|
6
6
|
* @param options
|