@code-pushup/utils 0.14.4 → 0.16.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 +54 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -2
- package/src/lib/filter-by-slug.d.ts +6 -0
- package/src/lib/git.d.ts +3 -0
- package/src/lib/logging.d.ts +1 -0
- package/src/lib/reports/utils.d.ts +6 -1
package/index.js
CHANGED
|
@@ -960,6 +960,13 @@ function compareIssues(a, b) {
|
|
|
960
960
|
}
|
|
961
961
|
return 0;
|
|
962
962
|
}
|
|
963
|
+
function portalCommitLink(config, commit) {
|
|
964
|
+
const { organization, project, baseUrl } = config;
|
|
965
|
+
return `${baseUrl}/portal/${organization}/${project}/commit/${commit}`;
|
|
966
|
+
}
|
|
967
|
+
function portalCommitDashboardLink(config, commit) {
|
|
968
|
+
return `${portalCommitLink(config, commit)}/dashboard`;
|
|
969
|
+
}
|
|
963
970
|
|
|
964
971
|
// packages/utils/src/lib/execute-process.ts
|
|
965
972
|
var ProcessError = class extends Error {
|
|
@@ -1016,6 +1023,19 @@ async function getLatestCommit() {
|
|
|
1016
1023
|
});
|
|
1017
1024
|
return log.latest;
|
|
1018
1025
|
}
|
|
1026
|
+
function validateCommitData(commitData, options = {}) {
|
|
1027
|
+
const { throwError = false } = options;
|
|
1028
|
+
if (!commitData) {
|
|
1029
|
+
const msg = "no commit data available";
|
|
1030
|
+
if (throwError) {
|
|
1031
|
+
throw new Error(msg);
|
|
1032
|
+
} else {
|
|
1033
|
+
console.warn(msg);
|
|
1034
|
+
return false;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1019
1039
|
|
|
1020
1040
|
// packages/utils/src/lib/group-by-status.ts
|
|
1021
1041
|
function groupByStatus(results) {
|
|
@@ -1661,6 +1681,35 @@ var verboseUtils = (verbose = false) => ({
|
|
|
1661
1681
|
log: getLogVerbose(verbose),
|
|
1662
1682
|
exec: getExecVerbose(verbose)
|
|
1663
1683
|
});
|
|
1684
|
+
|
|
1685
|
+
// packages/utils/src/lib/logging.ts
|
|
1686
|
+
import chalk4 from "chalk";
|
|
1687
|
+
function link2(text) {
|
|
1688
|
+
return chalk4.underline(chalk4.blueBright(text));
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
// packages/utils/src/lib/filter-by-slug.ts
|
|
1692
|
+
function filterGroupsByAuditSlug(groups, auditSlugs) {
|
|
1693
|
+
const slugs = toArray(auditSlugs);
|
|
1694
|
+
if (slugs.length === 0) {
|
|
1695
|
+
return groups;
|
|
1696
|
+
}
|
|
1697
|
+
return groups.map((group) => ({
|
|
1698
|
+
...group,
|
|
1699
|
+
refs: filterSlug(group.refs, slugs)
|
|
1700
|
+
})).filter((group) => group.refs.length);
|
|
1701
|
+
}
|
|
1702
|
+
function filterAuditsBySlug(list, auditSlugs) {
|
|
1703
|
+
const slugs = toArray(auditSlugs);
|
|
1704
|
+
if (slugs.length === 0) {
|
|
1705
|
+
return list;
|
|
1706
|
+
}
|
|
1707
|
+
return filterSlug(list, slugs);
|
|
1708
|
+
}
|
|
1709
|
+
function filterSlug(refs, slugOrSlugs) {
|
|
1710
|
+
const slugs = toArray(slugOrSlugs);
|
|
1711
|
+
return refs.filter(({ slug }) => slugs.includes(slug));
|
|
1712
|
+
}
|
|
1664
1713
|
export {
|
|
1665
1714
|
CODE_PUSHUP_DOMAIN,
|
|
1666
1715
|
FOOTER_PREFIX,
|
|
@@ -1679,6 +1728,8 @@ export {
|
|
|
1679
1728
|
exists,
|
|
1680
1729
|
factorOf,
|
|
1681
1730
|
fileExists,
|
|
1731
|
+
filterAuditsBySlug,
|
|
1732
|
+
filterGroupsByAuditSlug,
|
|
1682
1733
|
findLineNumberInText,
|
|
1683
1734
|
formatBytes,
|
|
1684
1735
|
formatDuration,
|
|
@@ -1691,6 +1742,7 @@ export {
|
|
|
1691
1742
|
importEsmModule,
|
|
1692
1743
|
isPromiseFulfilledResult,
|
|
1693
1744
|
isPromiseRejectedResult,
|
|
1745
|
+
link2 as link,
|
|
1694
1746
|
loadReport,
|
|
1695
1747
|
logMultipleFileResults,
|
|
1696
1748
|
logMultipleResults,
|
|
@@ -1700,6 +1752,7 @@ export {
|
|
|
1700
1752
|
pluginWorkDir,
|
|
1701
1753
|
pluralize,
|
|
1702
1754
|
pluralizeToken,
|
|
1755
|
+
portalCommitDashboardLink,
|
|
1703
1756
|
readJsonFile,
|
|
1704
1757
|
readTextFile,
|
|
1705
1758
|
scoreReport,
|
|
@@ -1714,5 +1767,6 @@ export {
|
|
|
1714
1767
|
truncateIssueMessage,
|
|
1715
1768
|
truncateText,
|
|
1716
1769
|
truncateTitle,
|
|
1770
|
+
validateCommitData,
|
|
1717
1771
|
verboseUtils
|
|
1718
1772
|
};
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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, } from './lib/file-system';
|
|
4
4
|
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateIssueMessage, truncateText, truncateTitle, } from './lib/formatting';
|
|
5
|
-
export { getLatestCommit, git } from './lib/git';
|
|
5
|
+
export { getLatestCommit, git, validateCommitData } from './lib/git';
|
|
6
6
|
export { groupByStatus } from './lib/group-by-status';
|
|
7
7
|
export { isPromiseFulfilledResult, isPromiseRejectedResult, } from './lib/guards';
|
|
8
8
|
export { logMultipleResults } from './lib/log-results';
|
|
@@ -12,6 +12,8 @@ export { generateMdReport } from './lib/reports/generate-md-report';
|
|
|
12
12
|
export { generateStdoutSummary } from './lib/reports/generate-stdout-summary';
|
|
13
13
|
export { ScoredReport, scoreReport } from './lib/reports/scoring';
|
|
14
14
|
export { sortReport } from './lib/reports/sorting';
|
|
15
|
-
export { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX, README_LINK, calcDuration, compareIssueSeverity, loadReport, } from './lib/reports/utils';
|
|
15
|
+
export { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX, README_LINK, calcDuration, compareIssueSeverity, loadReport, portalCommitDashboardLink, } from './lib/reports/utils';
|
|
16
16
|
export { CliArgsObject, capitalize, countOccurrences, distinct, factorOf, objectToCliArgs, objectToEntries, objectToKeys, toArray, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, } from './lib/transform';
|
|
17
17
|
export { verboseUtils } from './lib/verbose-utils';
|
|
18
|
+
export { link } from './lib/logging';
|
|
19
|
+
export { filterAuditsBySlug, filterGroupsByAuditSlug, } from './lib/filter-by-slug';
|
|
@@ -0,0 +1,6 @@
|
|
|
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[];
|
package/src/lib/git.d.ts
CHANGED
|
@@ -11,3 +11,6 @@ export declare function getLatestCommit(): Promise<({
|
|
|
11
11
|
author: string;
|
|
12
12
|
date: string;
|
|
13
13
|
} & import("simple-git").ListLogLine) | null>;
|
|
14
|
+
export declare function validateCommitData(commitData?: unknown, options?: {
|
|
15
|
+
throwError?: boolean;
|
|
16
|
+
}): commitData is CommitData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function link(text: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CategoryRef, IssueSeverity as CliIssueSeverity, Format, Issue, PersistConfig, Report } from '@code-pushup/models';
|
|
1
|
+
import { CategoryRef, IssueSeverity as CliIssueSeverity, Format, Issue, PersistConfig, Report, UploadConfig } from '@code-pushup/models';
|
|
2
2
|
import { EnrichedAuditReport, EnrichedScoredGroupWithAudits, ScoredReport, WeighedAuditReport } from './scoring';
|
|
3
3
|
export declare const FOOTER_PREFIX = "Made with \u2764 by";
|
|
4
4
|
export declare const CODE_PUSHUP_DOMAIN = "code-pushup.dev";
|
|
@@ -28,4 +28,9 @@ export declare function loadReport<T extends Format>(options: Required<Pick<Pers
|
|
|
28
28
|
export declare function throwIsNotPresentError(itemName: string, presentPlace: string): never;
|
|
29
29
|
export declare function getPluginNameFromSlug(slug: string, plugins: ScoredReport['plugins']): string;
|
|
30
30
|
export declare function compareIssues(a: Issue, b: Issue): number;
|
|
31
|
+
export type CommitLinkOptions = Pick<UploadConfig, 'project' | 'organization'> & {
|
|
32
|
+
baseUrl: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function portalCommitLink(config: CommitLinkOptions, commit: string): string;
|
|
35
|
+
export declare function portalCommitDashboardLink(config: CommitLinkOptions, commit: string): string;
|
|
31
36
|
export {};
|