@code-pushup/utils 0.23.1 → 0.25.6
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 +92 -87
- package/package.json +1 -1
- package/src/index.d.ts +5 -4
- package/src/lib/filter.d.ts +5 -0
- package/src/lib/reports/constants.d.ts +9 -0
- package/src/lib/reports/generate-md-report.d.ts +1 -1
- package/src/lib/reports/generate-stdout-summary.d.ts +1 -1
- package/src/lib/reports/scoring.d.ts +2 -24
- package/src/lib/reports/sorting.d.ts +1 -1
- package/src/lib/reports/types.d.ts +21 -0
- package/src/lib/reports/utils.d.ts +7 -15
- package/src/lib/filter-by-slug.d.ts +0 -6
package/index.js
CHANGED
|
@@ -752,8 +752,6 @@ var SCORE_COLOR_RANGE = {
|
|
|
752
752
|
GREEN_MIN: 0.9,
|
|
753
753
|
YELLOW_MIN: 0.5
|
|
754
754
|
};
|
|
755
|
-
|
|
756
|
-
// packages/utils/src/lib/reports/utils.ts
|
|
757
755
|
var FOOTER_PREFIX = "Made with \u2764 by";
|
|
758
756
|
var CODE_PUSHUP_DOMAIN = "code-pushup.dev";
|
|
759
757
|
var README_LINK = "https://github.com/flowup/quality-metrics-cli#readme";
|
|
@@ -784,6 +782,8 @@ var detailsTableHeaders = [
|
|
|
784
782
|
"Source file",
|
|
785
783
|
"Line(s)"
|
|
786
784
|
];
|
|
785
|
+
|
|
786
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
787
787
|
function formatReportScore(score) {
|
|
788
788
|
return Math.round(score * 100).toString();
|
|
789
789
|
}
|
|
@@ -820,7 +820,7 @@ function calcDuration(start, stop) {
|
|
|
820
820
|
function countCategoryAudits(refs, plugins) {
|
|
821
821
|
const groupLookup = plugins.reduce(
|
|
822
822
|
(lookup, plugin) => {
|
|
823
|
-
if (plugin.groups.length === 0) {
|
|
823
|
+
if (plugin.groups == null || plugin.groups.length === 0) {
|
|
824
824
|
return lookup;
|
|
825
825
|
}
|
|
826
826
|
return {
|
|
@@ -840,7 +840,7 @@ function countCategoryAudits(refs, plugins) {
|
|
|
840
840
|
return acc + 1;
|
|
841
841
|
}, 0);
|
|
842
842
|
}
|
|
843
|
-
function
|
|
843
|
+
function getSortableAuditByRef({ slug, weight, plugin }, plugins) {
|
|
844
844
|
const auditPlugin = plugins.find((p) => p.slug === plugin);
|
|
845
845
|
if (!auditPlugin) {
|
|
846
846
|
throwIsNotPresentError(`Plugin ${plugin}`, "report");
|
|
@@ -857,39 +857,51 @@ function getAuditByRef({ slug, weight, plugin }, plugins) {
|
|
|
857
857
|
plugin
|
|
858
858
|
};
|
|
859
859
|
}
|
|
860
|
-
function
|
|
861
|
-
const
|
|
862
|
-
if (!
|
|
863
|
-
throwIsNotPresentError(`Plugin ${
|
|
864
|
-
}
|
|
865
|
-
const groupWithAudits = plugin.groups?.find(({ slug }) => slug === refSlug);
|
|
866
|
-
if (!groupWithAudits) {
|
|
867
|
-
throwIsNotPresentError(`Group ${refSlug}`, plugin.slug);
|
|
860
|
+
function getSortableGroupByRef({ plugin, slug, weight }, plugins) {
|
|
861
|
+
const groupPlugin = plugins.find((p) => p.slug === plugin);
|
|
862
|
+
if (!groupPlugin) {
|
|
863
|
+
throwIsNotPresentError(`Plugin ${plugin}`, "report");
|
|
868
864
|
}
|
|
869
|
-
const
|
|
870
|
-
(
|
|
871
|
-
const audit = getAuditByRef(
|
|
872
|
-
{ ...ref, plugin: refPlugin, type: "audit" },
|
|
873
|
-
plugins
|
|
874
|
-
);
|
|
875
|
-
return [...acc, audit];
|
|
876
|
-
},
|
|
877
|
-
[]
|
|
865
|
+
const group = groupPlugin.groups?.find(
|
|
866
|
+
({ slug: groupSlug }) => groupSlug === slug
|
|
878
867
|
);
|
|
879
|
-
|
|
868
|
+
if (!group) {
|
|
869
|
+
throwIsNotPresentError(`Group ${slug}`, groupPlugin.slug);
|
|
870
|
+
}
|
|
871
|
+
const sortedAudits = getSortedGroupAudits(group, groupPlugin.slug, plugins);
|
|
872
|
+
const sortedAuditRefs = [...group.refs].sort((a, b) => {
|
|
873
|
+
const aIndex = sortedAudits.findIndex((ref) => ref.slug === a.slug);
|
|
874
|
+
const bIndex = sortedAudits.findIndex((ref) => ref.slug === b.slug);
|
|
875
|
+
return aIndex - bIndex;
|
|
876
|
+
});
|
|
880
877
|
return {
|
|
881
|
-
...
|
|
882
|
-
|
|
878
|
+
...group,
|
|
879
|
+
refs: sortedAuditRefs,
|
|
880
|
+
plugin,
|
|
881
|
+
weight
|
|
883
882
|
};
|
|
884
883
|
}
|
|
885
|
-
function
|
|
884
|
+
function getSortedGroupAudits(group, plugin, plugins) {
|
|
885
|
+
return group.refs.map(
|
|
886
|
+
(ref) => getSortableAuditByRef(
|
|
887
|
+
{
|
|
888
|
+
plugin,
|
|
889
|
+
slug: ref.slug,
|
|
890
|
+
weight: ref.weight,
|
|
891
|
+
type: "audit"
|
|
892
|
+
},
|
|
893
|
+
plugins
|
|
894
|
+
)
|
|
895
|
+
).sort(compareCategoryAuditsAndGroups);
|
|
896
|
+
}
|
|
897
|
+
function compareCategoryAuditsAndGroups(a, b) {
|
|
886
898
|
if (a.weight !== b.weight) {
|
|
887
899
|
return b.weight - a.weight;
|
|
888
900
|
}
|
|
889
901
|
if (a.score !== b.score) {
|
|
890
902
|
return a.score - b.score;
|
|
891
903
|
}
|
|
892
|
-
if (a.value !== b.value) {
|
|
904
|
+
if ("value" in a && "value" in b && a.value !== b.value) {
|
|
893
905
|
return b.value - a.value;
|
|
894
906
|
}
|
|
895
907
|
return a.title.localeCompare(b.title);
|
|
@@ -998,6 +1010,18 @@ function executeProcess(cfg) {
|
|
|
998
1010
|
});
|
|
999
1011
|
}
|
|
1000
1012
|
|
|
1013
|
+
// packages/utils/src/lib/filter.ts
|
|
1014
|
+
function filterItemRefsBy(items, refFilterFn) {
|
|
1015
|
+
return items.map((item) => ({
|
|
1016
|
+
...item,
|
|
1017
|
+
refs: item.refs.filter(refFilterFn)
|
|
1018
|
+
})).filter((item) => item.refs.length);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// packages/utils/src/lib/git.ts
|
|
1022
|
+
import { isAbsolute, join as join3, relative } from "node:path";
|
|
1023
|
+
import { simpleGit } from "simple-git";
|
|
1024
|
+
|
|
1001
1025
|
// packages/utils/src/lib/transform.ts
|
|
1002
1026
|
import { platform } from "node:os";
|
|
1003
1027
|
function toArray(val) {
|
|
@@ -1087,32 +1111,7 @@ function toOrdinal(value) {
|
|
|
1087
1111
|
return `${value}th`;
|
|
1088
1112
|
}
|
|
1089
1113
|
|
|
1090
|
-
// packages/utils/src/lib/filter-by-slug.ts
|
|
1091
|
-
function filterGroupsByAuditSlug(groups, auditSlugs) {
|
|
1092
|
-
const slugs = toArray(auditSlugs);
|
|
1093
|
-
if (slugs.length === 0) {
|
|
1094
|
-
return groups;
|
|
1095
|
-
}
|
|
1096
|
-
return groups.map((group) => ({
|
|
1097
|
-
...group,
|
|
1098
|
-
refs: filterSlug(group.refs, slugs)
|
|
1099
|
-
})).filter((group) => group.refs.length);
|
|
1100
|
-
}
|
|
1101
|
-
function filterAuditsBySlug(list, auditSlugs) {
|
|
1102
|
-
const slugs = toArray(auditSlugs);
|
|
1103
|
-
if (slugs.length === 0) {
|
|
1104
|
-
return list;
|
|
1105
|
-
}
|
|
1106
|
-
return filterSlug(list, slugs);
|
|
1107
|
-
}
|
|
1108
|
-
function filterSlug(refs, slugOrSlugs) {
|
|
1109
|
-
const slugs = toArray(slugOrSlugs);
|
|
1110
|
-
return refs.filter(({ slug }) => slugs.includes(slug));
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
1114
|
// packages/utils/src/lib/git.ts
|
|
1114
|
-
import { isAbsolute, join as join3, relative } from "node:path";
|
|
1115
|
-
import { simpleGit } from "simple-git";
|
|
1116
1115
|
async function getLatestCommit(git = simpleGit()) {
|
|
1117
1116
|
const log = await git.log({
|
|
1118
1117
|
maxCount: 1,
|
|
@@ -1135,7 +1134,7 @@ async function toGitPath(path, git = simpleGit()) {
|
|
|
1135
1134
|
function validateCommitData(commitData, options = {}) {
|
|
1136
1135
|
if (!commitData) {
|
|
1137
1136
|
const msg = "no commit data available";
|
|
1138
|
-
if (options
|
|
1137
|
+
if (options.throwError) {
|
|
1139
1138
|
throw new Error(msg);
|
|
1140
1139
|
} else {
|
|
1141
1140
|
console.warn(msg);
|
|
@@ -1329,12 +1328,24 @@ function reportToCategoriesSection(report) {
|
|
|
1329
1328
|
const categoryDocs = getDocsAndDescription(category);
|
|
1330
1329
|
const categoryMDItems = category.refs.reduce((refAcc, ref) => {
|
|
1331
1330
|
if (ref.type === "group") {
|
|
1332
|
-
const group =
|
|
1333
|
-
const
|
|
1331
|
+
const group = getSortableGroupByRef(ref, plugins);
|
|
1332
|
+
const groupAudits = group.refs.map(
|
|
1333
|
+
(groupRef) => getSortableAuditByRef(
|
|
1334
|
+
{ ...groupRef, plugin: group.plugin, type: "audit" },
|
|
1335
|
+
plugins
|
|
1336
|
+
)
|
|
1337
|
+
);
|
|
1338
|
+
const pluginTitle = getPluginNameFromSlug(ref.plugin, plugins);
|
|
1339
|
+
const mdGroupItem = groupItemToCategorySection(
|
|
1340
|
+
group,
|
|
1341
|
+
groupAudits,
|
|
1342
|
+
pluginTitle
|
|
1343
|
+
);
|
|
1334
1344
|
return refAcc + mdGroupItem + NEW_LINE;
|
|
1335
1345
|
} else {
|
|
1336
|
-
const audit =
|
|
1337
|
-
const
|
|
1346
|
+
const audit = getSortableAuditByRef(ref, plugins);
|
|
1347
|
+
const pluginTitle = getPluginNameFromSlug(ref.plugin, plugins);
|
|
1348
|
+
const mdAuditItem = auditItemToCategorySection(audit, pluginTitle);
|
|
1338
1349
|
return refAcc + mdAuditItem + NEW_LINE;
|
|
1339
1350
|
}
|
|
1340
1351
|
}, "");
|
|
@@ -1342,8 +1353,7 @@ function reportToCategoriesSection(report) {
|
|
|
1342
1353
|
}, "");
|
|
1343
1354
|
return h2("\u{1F3F7} Categories") + NEW_LINE + categoryDetails;
|
|
1344
1355
|
}
|
|
1345
|
-
function auditItemToCategorySection(audit,
|
|
1346
|
-
const pluginTitle = getPluginNameFromSlug(audit.plugin, plugins);
|
|
1356
|
+
function auditItemToCategorySection(audit, pluginTitle) {
|
|
1347
1357
|
const auditTitle = link2(
|
|
1348
1358
|
`#${slugify(audit.title)}-${slugify(pluginTitle)}`,
|
|
1349
1359
|
audit.title
|
|
@@ -1354,13 +1364,12 @@ function auditItemToCategorySection(audit, plugins) {
|
|
|
1354
1364
|
)} ${auditTitle} (_${pluginTitle}_) - ${getAuditResult(audit)}`
|
|
1355
1365
|
);
|
|
1356
1366
|
}
|
|
1357
|
-
function groupItemToCategorySection(group,
|
|
1358
|
-
const
|
|
1359
|
-
const groupScore = Number(formatReportScore(group?.score || 0));
|
|
1367
|
+
function groupItemToCategorySection(group, groupAudits, pluginTitle) {
|
|
1368
|
+
const groupScore = Number(formatReportScore(group.score || 0));
|
|
1360
1369
|
const groupTitle = li(
|
|
1361
1370
|
`${getRoundScoreMarker(groupScore)} ${group.title} (_${pluginTitle}_)`
|
|
1362
1371
|
);
|
|
1363
|
-
const
|
|
1372
|
+
const auditTitles = groupAudits.reduce((acc, audit) => {
|
|
1364
1373
|
const auditTitle = link2(
|
|
1365
1374
|
`#${slugify(audit.title)}-${slugify(pluginTitle)}`,
|
|
1366
1375
|
audit.title
|
|
@@ -1371,13 +1380,13 @@ function groupItemToCategorySection(group, plugins) {
|
|
|
1371
1380
|
)}`
|
|
1372
1381
|
)}${NEW_LINE}`;
|
|
1373
1382
|
}, "");
|
|
1374
|
-
return groupTitle + NEW_LINE +
|
|
1383
|
+
return groupTitle + NEW_LINE + auditTitles;
|
|
1375
1384
|
}
|
|
1376
1385
|
function reportToAuditsSection(report) {
|
|
1377
1386
|
const auditsSection = report.plugins.reduce((pluginAcc, plugin) => {
|
|
1378
1387
|
const auditsData = plugin.audits.reduce((auditAcc, audit) => {
|
|
1379
1388
|
const auditTitle = `${audit.title} (${getPluginNameFromSlug(
|
|
1380
|
-
|
|
1389
|
+
plugin.slug,
|
|
1381
1390
|
report.plugins
|
|
1382
1391
|
)})`;
|
|
1383
1392
|
return auditAcc + h3(auditTitle) + NEW_LINE + NEW_LINE + reportToDetailsSection(audit) + NEW_LINE + NEW_LINE + getDocsAndDescription(audit);
|
|
@@ -1554,29 +1563,30 @@ var GroupRefInvalidError = class extends Error {
|
|
|
1554
1563
|
function scoreReport(report) {
|
|
1555
1564
|
const allScoredAuditsAndGroups = /* @__PURE__ */ new Map();
|
|
1556
1565
|
const scoredPlugins = report.plugins.map((plugin) => {
|
|
1557
|
-
const {
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
allScoredAuditsAndGroups.set(`${slug}-${audit.slug}-audit`, audit);
|
|
1566
|
+
const { groups, ...pluginProps } = plugin;
|
|
1567
|
+
plugin.audits.forEach((audit) => {
|
|
1568
|
+
allScoredAuditsAndGroups.set(`${plugin.slug}-${audit.slug}-audit`, audit);
|
|
1561
1569
|
});
|
|
1562
1570
|
function groupScoreFn(ref) {
|
|
1563
1571
|
const score = allScoredAuditsAndGroups.get(
|
|
1564
|
-
`${slug}-${ref.slug}-audit`
|
|
1572
|
+
`${plugin.slug}-${ref.slug}-audit`
|
|
1565
1573
|
)?.score;
|
|
1566
1574
|
if (score == null) {
|
|
1567
|
-
throw new GroupRefInvalidError(ref.slug, slug);
|
|
1575
|
+
throw new GroupRefInvalidError(ref.slug, plugin.slug);
|
|
1568
1576
|
}
|
|
1569
1577
|
return score;
|
|
1570
1578
|
}
|
|
1571
1579
|
const scoredGroups = groups?.map((group) => ({
|
|
1572
1580
|
...group,
|
|
1573
|
-
score: calculateScore(group.refs, groupScoreFn)
|
|
1574
|
-
plugin: slug
|
|
1581
|
+
score: calculateScore(group.refs, groupScoreFn)
|
|
1575
1582
|
})) ?? [];
|
|
1576
1583
|
scoredGroups.forEach((group) => {
|
|
1577
|
-
allScoredAuditsAndGroups.set(`${slug}-${group.slug}-group`, group);
|
|
1584
|
+
allScoredAuditsAndGroups.set(`${plugin.slug}-${group.slug}-group`, group);
|
|
1578
1585
|
});
|
|
1579
|
-
return {
|
|
1586
|
+
return {
|
|
1587
|
+
...pluginProps,
|
|
1588
|
+
...scoredGroups.length > 0 && { groups: scoredGroups }
|
|
1589
|
+
};
|
|
1580
1590
|
});
|
|
1581
1591
|
function catScoreFn(ref) {
|
|
1582
1592
|
const key = `${ref.plugin}-${ref.slug}-${ref.type}`;
|
|
@@ -1637,26 +1647,22 @@ function sortReport(report) {
|
|
|
1637
1647
|
(acc, ref) => ({
|
|
1638
1648
|
...acc,
|
|
1639
1649
|
...ref.type === "group" ? {
|
|
1640
|
-
groups: [
|
|
1641
|
-
...acc.groups,
|
|
1642
|
-
getGroupWithAudits(ref.slug, ref.plugin, plugins)
|
|
1643
|
-
]
|
|
1650
|
+
groups: [...acc.groups, getSortableGroupByRef(ref, plugins)]
|
|
1644
1651
|
} : {
|
|
1645
|
-
audits: [...acc.audits,
|
|
1652
|
+
audits: [...acc.audits, getSortableAuditByRef(ref, plugins)]
|
|
1646
1653
|
}
|
|
1647
1654
|
}),
|
|
1648
1655
|
{ groups: [], audits: [] }
|
|
1649
1656
|
);
|
|
1650
|
-
const sortedAuditsAndGroups = [
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
];
|
|
1657
|
+
const sortedAuditsAndGroups = [...audits, ...groups].sort(
|
|
1658
|
+
compareCategoryAuditsAndGroups
|
|
1659
|
+
);
|
|
1654
1660
|
const sortedRefs = [...category.refs].sort((a, b) => {
|
|
1655
1661
|
const aIndex = sortedAuditsAndGroups.findIndex(
|
|
1656
|
-
(ref) => ref.slug === a.slug
|
|
1662
|
+
(ref) => ref.slug === a.slug && ref.plugin === a.plugin
|
|
1657
1663
|
);
|
|
1658
1664
|
const bIndex = sortedAuditsAndGroups.findIndex(
|
|
1659
|
-
(ref) => ref.slug === b.slug
|
|
1665
|
+
(ref) => ref.slug === b.slug && ref.plugin === b.plugin
|
|
1660
1666
|
);
|
|
1661
1667
|
return aIndex - bIndex;
|
|
1662
1668
|
});
|
|
@@ -1720,8 +1726,7 @@ export {
|
|
|
1720
1726
|
exists,
|
|
1721
1727
|
factorOf,
|
|
1722
1728
|
fileExists,
|
|
1723
|
-
|
|
1724
|
-
filterGroupsByAuditSlug,
|
|
1729
|
+
filterItemRefsBy,
|
|
1725
1730
|
findLineNumberInText,
|
|
1726
1731
|
formatBytes,
|
|
1727
1732
|
formatDuration,
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { exists } from '@code-pushup/models';
|
|
2
2
|
export { ProcessConfig, ProcessError, ProcessObserver, ProcessResult, executeProcess, } from './lib/execute-process';
|
|
3
3
|
export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, removeDirectoryIfExists, } from './lib/file-system';
|
|
4
|
-
export {
|
|
4
|
+
export { filterItemRefsBy } from './lib/filter';
|
|
5
5
|
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateIssueMessage, truncateText, truncateTitle, } from './lib/formatting';
|
|
6
6
|
export { formatGitPath, getGitRoot, getLatestCommit, toGitPath, validateCommitData, } from './lib/git';
|
|
7
7
|
export { groupByStatus } from './lib/group-by-status';
|
|
@@ -9,11 +9,12 @@ export { isPromiseFulfilledResult, isPromiseRejectedResult, } from './lib/guards
|
|
|
9
9
|
export { logMultipleResults } from './lib/log-results';
|
|
10
10
|
export { link } from './lib/logging';
|
|
11
11
|
export { ProgressBar, getProgressBar } from './lib/progress';
|
|
12
|
-
export { TERMINAL_WIDTH } from './lib/reports/constants';
|
|
12
|
+
export { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX, README_LINK, TERMINAL_WIDTH, } from './lib/reports/constants';
|
|
13
13
|
export { generateMdReport } from './lib/reports/generate-md-report';
|
|
14
14
|
export { generateStdoutSummary } from './lib/reports/generate-stdout-summary';
|
|
15
|
-
export {
|
|
15
|
+
export { scoreReport } from './lib/reports/scoring';
|
|
16
16
|
export { sortReport } from './lib/reports/sorting';
|
|
17
|
-
export {
|
|
17
|
+
export { ScoredReport } from './lib/reports/types';
|
|
18
|
+
export { calcDuration, compareIssueSeverity, loadReport, } from './lib/reports/utils';
|
|
18
19
|
export { CliArgsObject, capitalize, countOccurrences, distinct, factorOf, objectToCliArgs, objectToEntries, objectToKeys, toArray, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, } from './lib/transform';
|
|
19
20
|
export { verboseUtils } from './lib/verbose-utils';
|
|
@@ -4,3 +4,12 @@ export declare const SCORE_COLOR_RANGE: {
|
|
|
4
4
|
GREEN_MIN: number;
|
|
5
5
|
YELLOW_MIN: number;
|
|
6
6
|
};
|
|
7
|
+
export declare const FOOTER_PREFIX = "Made with \u2764 by";
|
|
8
|
+
export declare const CODE_PUSHUP_DOMAIN = "code-pushup.dev";
|
|
9
|
+
export declare const README_LINK = "https://github.com/flowup/quality-metrics-cli#readme";
|
|
10
|
+
export declare const reportHeadlineText = "Code PushUp Report";
|
|
11
|
+
export declare const reportOverviewTableHeaders: string[];
|
|
12
|
+
export declare const reportRawOverviewTableHeaders: string[];
|
|
13
|
+
export declare const reportMetaTableHeaders: string[];
|
|
14
|
+
export declare const pluginMetaTableHeaders: string[];
|
|
15
|
+
export declare const detailsTableHeaders: string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ScoredReport } from './
|
|
1
|
+
import { ScoredReport } from './types';
|
|
2
2
|
export declare function generateStdoutSummary(report: ScoredReport): string;
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
plugin: string;
|
|
4
|
-
};
|
|
5
|
-
export type WeighedAuditReport = EnrichedAuditReport & {
|
|
6
|
-
weight: number;
|
|
7
|
-
};
|
|
8
|
-
export type EnrichedScoredGroupWithAudits = EnrichedScoredGroup & {
|
|
9
|
-
audits: AuditReport[];
|
|
10
|
-
};
|
|
11
|
-
export type ScoredCategoryConfig = CategoryConfig & {
|
|
12
|
-
score: number;
|
|
13
|
-
};
|
|
14
|
-
export type EnrichedScoredGroup = Group & {
|
|
15
|
-
plugin: string;
|
|
16
|
-
score: number;
|
|
17
|
-
};
|
|
18
|
-
export type ScoredReport = Omit<Report, 'plugins' | 'categories'> & {
|
|
19
|
-
plugins: (Omit<PluginReport, 'audits' | 'groups'> & {
|
|
20
|
-
audits: EnrichedAuditReport[];
|
|
21
|
-
groups: EnrichedScoredGroup[];
|
|
22
|
-
})[];
|
|
23
|
-
categories: ScoredCategoryConfig[];
|
|
24
|
-
};
|
|
1
|
+
import { Report } from '@code-pushup/models';
|
|
2
|
+
import { ScoredReport } from './types';
|
|
25
3
|
export declare class GroupRefInvalidError extends Error {
|
|
26
4
|
constructor(auditSlug: string, pluginSlug: string);
|
|
27
5
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ScoredReport } from './
|
|
1
|
+
import { ScoredReport } from './types';
|
|
2
2
|
export declare function sortReport(report: ScoredReport): ScoredReport;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AuditReport, CategoryConfig, Group, PluginReport, Report } from '@code-pushup/models';
|
|
2
|
+
export type ScoredCategoryConfig = CategoryConfig & {
|
|
3
|
+
score: number;
|
|
4
|
+
};
|
|
5
|
+
export type ScoredGroup = Group & {
|
|
6
|
+
score: number;
|
|
7
|
+
};
|
|
8
|
+
export type ScoredReport = Omit<Report, 'plugins' | 'categories'> & {
|
|
9
|
+
plugins: (Omit<PluginReport, 'groups'> & {
|
|
10
|
+
groups?: ScoredGroup[];
|
|
11
|
+
})[];
|
|
12
|
+
categories: ScoredCategoryConfig[];
|
|
13
|
+
};
|
|
14
|
+
export type SortableGroup = ScoredGroup & {
|
|
15
|
+
weight: number;
|
|
16
|
+
plugin: string;
|
|
17
|
+
};
|
|
18
|
+
export type SortableAuditReport = AuditReport & {
|
|
19
|
+
weight: number;
|
|
20
|
+
plugin: string;
|
|
21
|
+
};
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { CategoryRef, IssueSeverity as CliIssueSeverity, Format, Issue, PersistConfig, Report } from '@code-pushup/models';
|
|
2
|
-
import {
|
|
3
|
-
export declare const FOOTER_PREFIX = "Made with \u2764 by";
|
|
4
|
-
export declare const CODE_PUSHUP_DOMAIN = "code-pushup.dev";
|
|
5
|
-
export declare const README_LINK = "https://github.com/flowup/quality-metrics-cli#readme";
|
|
6
|
-
export declare const reportHeadlineText = "Code PushUp Report";
|
|
7
|
-
export declare const reportOverviewTableHeaders: string[];
|
|
8
|
-
export declare const reportRawOverviewTableHeaders: string[];
|
|
9
|
-
export declare const reportMetaTableHeaders: string[];
|
|
10
|
-
export declare const pluginMetaTableHeaders: string[];
|
|
11
|
-
export declare const detailsTableHeaders: string[];
|
|
1
|
+
import { AuditReport, CategoryRef, IssueSeverity as CliIssueSeverity, Format, Group, Issue, PersistConfig, Report } from '@code-pushup/models';
|
|
2
|
+
import { ScoredReport, SortableAuditReport, SortableGroup } from './types';
|
|
12
3
|
export declare function formatReportScore(score: number): string;
|
|
13
4
|
export declare function getRoundScoreMarker(score: number): string;
|
|
14
5
|
export declare function getSquaredScoreMarker(score: number): string;
|
|
@@ -16,10 +7,11 @@ export declare function getSeverityIcon(severity: 'info' | 'warning' | 'error'):
|
|
|
16
7
|
export declare function calcDuration(start: number, stop?: number): number;
|
|
17
8
|
export declare function countWeightedRefs(refs: CategoryRef[]): number;
|
|
18
9
|
export declare function countCategoryAudits(refs: CategoryRef[], plugins: ScoredReport['plugins']): number;
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
10
|
+
export declare function getSortableAuditByRef({ slug, weight, plugin }: CategoryRef, plugins: ScoredReport['plugins']): SortableAuditReport;
|
|
11
|
+
export declare function getSortableGroupByRef({ plugin, slug, weight }: CategoryRef, plugins: ScoredReport['plugins']): SortableGroup;
|
|
12
|
+
export declare function getSortedGroupAudits(group: Group, plugin: string, plugins: ScoredReport['plugins']): SortableAuditReport[];
|
|
13
|
+
export declare function compareCategoryAuditsAndGroups(a: SortableAuditReport | SortableGroup, b: SortableAuditReport | SortableGroup): number;
|
|
14
|
+
export declare function compareAudits(a: AuditReport, b: AuditReport): number;
|
|
23
15
|
export declare function compareIssueSeverity(severity1: CliIssueSeverity, severity2: CliIssueSeverity): number;
|
|
24
16
|
type LoadedReportFormat<T extends Format> = T extends 'json' ? Report : string;
|
|
25
17
|
export declare function loadReport<T extends Format>(options: Required<Omit<PersistConfig, 'format'>> & {
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Audit, Group } from '@code-pushup/models';
|
|
2
|
-
export declare function filterGroupsByAuditSlug(groups: Group[], auditSlugs: string | string[]): Group[];
|
|
3
|
-
export declare function filterAuditsBySlug(list: Audit[], auditSlugs: string[] | string): Audit[];
|
|
4
|
-
export declare function filterSlug<T extends {
|
|
5
|
-
slug: string;
|
|
6
|
-
}>(refs: T[], slugOrSlugs: string | string[]): T[];
|