@code-pushup/utils 0.14.3 → 0.15.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 +29 -0
- package/package.json +1 -1
- package/src/index.d.ts +3 -2
- 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,12 @@ 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
|
+
}
|
|
1664
1690
|
export {
|
|
1665
1691
|
CODE_PUSHUP_DOMAIN,
|
|
1666
1692
|
FOOTER_PREFIX,
|
|
@@ -1691,6 +1717,7 @@ export {
|
|
|
1691
1717
|
importEsmModule,
|
|
1692
1718
|
isPromiseFulfilledResult,
|
|
1693
1719
|
isPromiseRejectedResult,
|
|
1720
|
+
link2 as link,
|
|
1694
1721
|
loadReport,
|
|
1695
1722
|
logMultipleFileResults,
|
|
1696
1723
|
logMultipleResults,
|
|
@@ -1700,6 +1727,7 @@ export {
|
|
|
1700
1727
|
pluginWorkDir,
|
|
1701
1728
|
pluralize,
|
|
1702
1729
|
pluralizeToken,
|
|
1730
|
+
portalCommitDashboardLink,
|
|
1703
1731
|
readJsonFile,
|
|
1704
1732
|
readTextFile,
|
|
1705
1733
|
scoreReport,
|
|
@@ -1714,5 +1742,6 @@ export {
|
|
|
1714
1742
|
truncateIssueMessage,
|
|
1715
1743
|
truncateText,
|
|
1716
1744
|
truncateTitle,
|
|
1745
|
+
validateCommitData,
|
|
1717
1746
|
verboseUtils
|
|
1718
1747
|
};
|
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,7 @@ 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';
|
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 {};
|