@code-pushup/utils 0.8.7 → 0.8.9

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
@@ -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(512),
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/utils",
3
- "version": "0.8.7",
3
+ "version": "0.8.9",
4
4
  "dependencies": {
5
5
  "@code-pushup/models": "*",
6
6
  "bundle-require": "^4.0.1",
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';
@@ -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;