@code-pushup/utils 0.8.7 → 0.8.8
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 +22 -17
- package/package.json +1 -1
- package/src/index.d.ts +2 -2
- package/src/lib/formatting.d.ts +1 -0
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { MATERIAL_ICONS } from "@code-pushup/portal-client";
|
|
|
15
15
|
var MAX_SLUG_LENGTH = 128;
|
|
16
16
|
var MAX_TITLE_LENGTH = 256;
|
|
17
17
|
var MAX_DESCRIPTION_LENGTH = 65536;
|
|
18
|
+
var MAX_ISSUE_MESSAGE_LENGTH = 1024;
|
|
18
19
|
|
|
19
20
|
// packages/models/src/lib/implementation/utils.ts
|
|
20
21
|
var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -195,7 +196,7 @@ var issueSeveritySchema = z3.enum(["info", "warning", "error"], {
|
|
|
195
196
|
});
|
|
196
197
|
var issueSchema = z3.object(
|
|
197
198
|
{
|
|
198
|
-
message: z3.string({ description: "Descriptive error message" }).max(
|
|
199
|
+
message: z3.string({ description: "Descriptive error message" }).max(MAX_ISSUE_MESSAGE_LENGTH),
|
|
199
200
|
severity: issueSeveritySchema,
|
|
200
201
|
source: sourceFileLocationSchema.optional()
|
|
201
202
|
},
|
|
@@ -588,6 +589,9 @@ function truncateTitle(text) {
|
|
|
588
589
|
function truncateDescription(text) {
|
|
589
590
|
return truncateText(text, MAX_DESCRIPTION_LENGTH);
|
|
590
591
|
}
|
|
592
|
+
function truncateIssueMessage(text) {
|
|
593
|
+
return truncateText(text, MAX_ISSUE_MESSAGE_LENGTH);
|
|
594
|
+
}
|
|
591
595
|
|
|
592
596
|
// packages/utils/src/lib/guards.ts
|
|
593
597
|
function isPromiseFulfilledResult(result) {
|
|
@@ -984,6 +988,22 @@ async function getLatestCommit() {
|
|
|
984
988
|
return log?.latest;
|
|
985
989
|
}
|
|
986
990
|
|
|
991
|
+
// packages/utils/src/lib/group-by-status.ts
|
|
992
|
+
function groupByStatus(results) {
|
|
993
|
+
return results.reduce(
|
|
994
|
+
(acc, result) => {
|
|
995
|
+
if (result.status === "fulfilled") {
|
|
996
|
+
return { ...acc, fulfilled: [...acc.fulfilled, result] };
|
|
997
|
+
}
|
|
998
|
+
if (result.status === "rejected") {
|
|
999
|
+
return { ...acc, rejected: [...acc.rejected, result] };
|
|
1000
|
+
}
|
|
1001
|
+
return acc;
|
|
1002
|
+
},
|
|
1003
|
+
{ fulfilled: [], rejected: [] }
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
987
1007
|
// packages/utils/src/lib/md/details.ts
|
|
988
1008
|
function details(title, content, cfg = { open: false }) {
|
|
989
1009
|
return `<details${cfg.open ? " open" : ""}>
|
|
@@ -1553,22 +1573,6 @@ var verboseUtils = (verbose) => ({
|
|
|
1553
1573
|
log: getLogVerbose(verbose),
|
|
1554
1574
|
exec: getExecVerbose(verbose)
|
|
1555
1575
|
});
|
|
1556
|
-
|
|
1557
|
-
// packages/utils/src/lib/group-by-status.ts
|
|
1558
|
-
function groupByStatus(results) {
|
|
1559
|
-
return results.reduce(
|
|
1560
|
-
(acc, result) => {
|
|
1561
|
-
if (result.status === "fulfilled") {
|
|
1562
|
-
return { ...acc, fulfilled: [...acc.fulfilled, result] };
|
|
1563
|
-
}
|
|
1564
|
-
if (result.status === "rejected") {
|
|
1565
|
-
return { ...acc, rejected: [...acc.rejected, result] };
|
|
1566
|
-
}
|
|
1567
|
-
return acc;
|
|
1568
|
-
},
|
|
1569
|
-
{ fulfilled: [], rejected: [] }
|
|
1570
|
-
);
|
|
1571
|
-
}
|
|
1572
1576
|
export {
|
|
1573
1577
|
CODE_PUSHUP_DOMAIN,
|
|
1574
1578
|
FOOTER_PREFIX,
|
|
@@ -1612,6 +1616,7 @@ export {
|
|
|
1612
1616
|
toArray,
|
|
1613
1617
|
toUnixPath,
|
|
1614
1618
|
truncateDescription,
|
|
1619
|
+
truncateIssueMessage,
|
|
1615
1620
|
truncateText,
|
|
1616
1621
|
truncateTitle,
|
|
1617
1622
|
verboseUtils
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { ProcessConfig, ProcessError, ProcessObserver, ProcessResult, executeProcess, } from './lib/execute-process';
|
|
2
2
|
export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, } from './lib/file-system';
|
|
3
|
-
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateText, truncateTitle, } from './lib/formatting';
|
|
3
|
+
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateIssueMessage, truncateText, truncateTitle, } from './lib/formatting';
|
|
4
4
|
export { getLatestCommit, git } from './lib/git';
|
|
5
|
+
export { groupByStatus } from './lib/group-by-status';
|
|
5
6
|
export { isPromiseFulfilledResult, isPromiseRejectedResult, } from './lib/guards';
|
|
6
7
|
export { logMultipleResults } from './lib/log-results';
|
|
7
8
|
export { NEW_LINE } from './lib/md';
|
|
@@ -12,4 +13,3 @@ export { reportToStdout } from './lib/report-to-stdout';
|
|
|
12
13
|
export { ScoredReport, scoreReport } from './lib/scoring';
|
|
13
14
|
export { CliArgsObject, countOccurrences, distinct, factorOf, objectToCliArgs, objectToEntries, objectToKeys, toArray, toUnixPath, } from './lib/transform';
|
|
14
15
|
export { verboseUtils } from './lib/verbose-utils';
|
|
15
|
-
export { groupByStatus } from './lib/group-by-status';
|
package/src/lib/formatting.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare function formatDuration(duration: number): string;
|
|
|
6
6
|
export declare function truncateText(text: string, maxChars: number): string;
|
|
7
7
|
export declare function truncateTitle(text: string): string;
|
|
8
8
|
export declare function truncateDescription(text: string): string;
|
|
9
|
+
export declare function truncateIssueMessage(text: string): string;
|