@code-pushup/utils 0.48.0 → 0.50.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.
Files changed (37) hide show
  1. package/index.js +1187 -1237
  2. package/package.json +10 -35
  3. package/src/index.d.ts +13 -11
  4. package/src/lib/errors.d.ts +1 -0
  5. package/src/lib/execute-process.d.ts +5 -3
  6. package/src/lib/git/git.commits-and-tags.d.ts +2 -2
  7. package/src/lib/git/git.d.ts +1 -1
  8. package/src/lib/merge-configs.d.ts +1 -1
  9. package/src/lib/progress.d.ts +1 -1
  10. package/src/lib/reports/constants.d.ts +2 -27
  11. package/src/lib/reports/flatten-plugins.d.ts +1 -1
  12. package/src/lib/reports/formatting.d.ts +5 -5
  13. package/src/lib/reports/generate-md-report-categoy-section.d.ts +8 -6
  14. package/src/lib/reports/generate-md-report.d.ts +10 -9
  15. package/src/lib/reports/generate-md-reports-diff-utils.d.ts +29 -0
  16. package/src/lib/reports/generate-md-reports-diff.d.ts +4 -1
  17. package/src/lib/reports/load-report.d.ts +6 -0
  18. package/src/lib/reports/log-stdout-summary.d.ts +3 -1
  19. package/src/lib/reports/scoring.d.ts +2 -2
  20. package/src/lib/reports/sorting.d.ts +5 -1
  21. package/src/lib/reports/types.d.ts +1 -1
  22. package/src/lib/reports/utils.d.ts +19 -13
  23. package/src/lib/text-formats/constants.d.ts +8 -0
  24. package/src/lib/text-formats/html/table.d.ts +1 -1
  25. package/src/lib/text-formats/index.d.ts +9 -40
  26. package/src/lib/text-formats/table.d.ts +1 -1
  27. package/src/lib/transform.d.ts +0 -1
  28. package/src/lib/types.d.ts +9 -0
  29. package/src/lib/text-formats/md/font-style.d.ts +0 -4
  30. package/src/lib/text-formats/md/headline.d.ts +0 -14
  31. package/src/lib/text-formats/md/image.d.ts +0 -1
  32. package/src/lib/text-formats/md/link.d.ts +0 -1
  33. package/src/lib/text-formats/md/list.d.ts +0 -7
  34. package/src/lib/text-formats/md/paragraphs.d.ts +0 -1
  35. package/src/lib/text-formats/md/section.d.ts +0 -2
  36. package/src/lib/text-formats/md/table.d.ts +0 -9
  37. package/src/lib/text-formats/types.d.ts +0 -1
package/package.json CHANGED
@@ -1,19 +1,21 @@
1
1
  {
2
2
  "name": "@code-pushup/utils",
3
- "version": "0.48.0",
3
+ "version": "0.50.0",
4
+ "description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
4
5
  "dependencies": {
5
- "@code-pushup/models": "0.48.0",
6
+ "@code-pushup/models": "0.50.0",
7
+ "@isaacs/cliui": "^8.0.2",
8
+ "@poppinss/cliui": "^6.4.0",
9
+ "ansis": "^3.3.0",
10
+ "build-md": "^0.4.2",
6
11
  "bundle-require": "^4.0.1",
7
12
  "esbuild": "^0.19.2",
8
- "chalk": "^5.3.0",
9
- "@isaacs/cliui": "^8.0.2",
10
- "simple-git": "^3.20.0",
11
13
  "multi-progress-bars": "^5.0.3",
12
- "@poppinss/cliui": "^6.4.0",
13
- "semver": "^7.6.0"
14
+ "semver": "^7.6.0",
15
+ "simple-git": "^3.20.0"
14
16
  },
15
17
  "license": "MIT",
16
- "homepage": "https://github.com/code-pushup/cli#readme",
18
+ "homepage": "https://github.com/code-pushup/cli/tree/main/packages/utils#readme",
17
19
  "bugs": {
18
20
  "url": "https://github.com/code-pushup/cli/issues"
19
21
  },
@@ -22,33 +24,6 @@
22
24
  "url": "git+https://github.com/code-pushup/cli.git",
23
25
  "directory": "packages/utils"
24
26
  },
25
- "contributors": [
26
- {
27
- "name": "Igor Katsuba",
28
- "email": "igor@katsuba.dev",
29
- "url": "https://katsuba.dev"
30
- },
31
- {
32
- "name": "Kateřina Pilátová",
33
- "email": "katerina.pilatova@flowup.cz",
34
- "url": "https://github.com/Tlacenka"
35
- },
36
- {
37
- "name": "Matěj Chalk",
38
- "email": "matej.chalk@flowup.cz",
39
- "url": "https://github.com/matejchalk"
40
- },
41
- {
42
- "name": "Michael Hladky",
43
- "email": "michael.hladky@push-based.io",
44
- "url": "https://push-based.io"
45
- },
46
- {
47
- "name": "Michael Seredenko",
48
- "email": "misha.seredenko@push-based.io",
49
- "url": "https://github.com/MishaSeredenkoPushBased"
50
- }
51
- ],
52
27
  "type": "module",
53
28
  "main": "./index.js",
54
29
  "types": "./src/index.d.ts"
package/src/index.d.ts CHANGED
@@ -1,28 +1,30 @@
1
1
  export { exists } from '@code-pushup/models';
2
- export { Diff, comparePairs, matchArrayItemsByKey } from './lib/diff';
3
- export { ProcessConfig, ProcessError, ProcessObserver, ProcessResult, executeProcess, } from './lib/execute-process';
4
- export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, filePathToCliArg, findLineNumberInText, importModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, removeDirectoryIfExists, } from './lib/file-system';
2
+ export { type Diff, comparePairs, matchArrayItemsByKey } from './lib/diff';
3
+ export { stringifyError } from './lib/errors';
4
+ export { type ProcessConfig, ProcessError, type ProcessObserver, type ProcessResult, executeProcess, } from './lib/execute-process';
5
+ export { type CrawlFileSystemOptions, type FileResult, type MultipleFileResults, crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, filePathToCliArg, findLineNumberInText, importModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, removeDirectoryIfExists, } from './lib/file-system';
5
6
  export { filterItemRefsBy } from './lib/filter';
6
7
  export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateIssueMessage, truncateText, truncateTitle, } from './lib/formatting';
7
8
  export { formatGitPath, getGitRoot, guardAgainstLocalChanges, safeCheckout, toGitPath, } from './lib/git/git';
8
- export { LogResult, getCurrentBranchOrTag, getHashFromTag, getHashes, getLatestCommit, getSemverTags, } from './lib/git/git.commits-and-tags';
9
+ export { type LogResult, getCurrentBranchOrTag, getHashFromTag, getHashes, getLatestCommit, getSemverTags, } from './lib/git/git.commits-and-tags';
9
10
  export { groupByStatus } from './lib/group-by-status';
10
11
  export { isPromiseFulfilledResult, isPromiseRejectedResult, } from './lib/guards';
11
12
  export { logMultipleResults } from './lib/log-results';
12
- export { CliUi, Column, link, ui } from './lib/logging';
13
+ export { type CliUi, type Column, link, ui } from './lib/logging';
13
14
  export { mergeConfigs } from './lib/merge-configs';
14
- export { ProgressBar, getProgressBar } from './lib/progress';
15
+ export { type ProgressBar, getProgressBar } from './lib/progress';
15
16
  export { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX, README_LINK, TERMINAL_WIDTH, } from './lib/reports/constants';
16
17
  export { listAuditsFromAllPlugins, listGroupsFromAllPlugins, } from './lib/reports/flatten-plugins';
17
18
  export { generateMdReport } from './lib/reports/generate-md-report';
18
- export { generateMdReportsDiff } from './lib/reports/generate-md-reports-diff';
19
+ export { generateMdReportsDiff, generateMdReportsDiffForMonorepo, } from './lib/reports/generate-md-reports-diff';
20
+ export { loadReport } from './lib/reports/load-report';
19
21
  export { logStdoutSummary } from './lib/reports/log-stdout-summary';
20
22
  export { scoreReport } from './lib/reports/scoring';
21
23
  export { sortReport } from './lib/reports/sorting';
22
- export { ScoredCategoryConfig, ScoredGroup, ScoredReport, } from './lib/reports/types';
23
- export { calcDuration, compareIssueSeverity, loadReport, } from './lib/reports/utils';
24
+ export type { ScoredCategoryConfig, ScoredGroup, ScoredReport, } from './lib/reports/types';
25
+ export { calcDuration, compareIssueSeverity, formatReportScore, } from './lib/reports/utils';
24
26
  export { isSemver, normalizeSemver, sortSemvers } from './lib/semver';
25
27
  export * from './lib/text-formats';
26
- export { CliArgsObject, apostrophize, capitalize, countOccurrences, distinct, factorOf, fromJsonLines, objectFromEntries, objectToCliArgs, objectToEntries, objectToKeys, toArray, toJsonLines, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, } from './lib/transform';
27
- export { ExcludeNullFromPropertyTypes } from './lib/types';
28
+ export { type CliArgsObject, capitalize, countOccurrences, distinct, factorOf, fromJsonLines, objectFromEntries, objectToCliArgs, objectToEntries, objectToKeys, toArray, toJsonLines, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, } from './lib/transform';
29
+ export type { ExcludeNullFromPropertyTypes, ExtractArray, ExtractArrays, ItemOrArray, Prettify, WithRequired, } from './lib/types';
28
30
  export { verboseUtils } from './lib/verbose-utils';
@@ -0,0 +1 @@
1
+ export declare function stringifyError(error: unknown): string;
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ import { type ChildProcess, type SpawnOptionsWithStdioTuple, type StdioPipe } from 'node:child_process';
1
3
  /**
2
4
  * Represents the process result.
3
5
  * @category Types
@@ -66,10 +68,9 @@ export declare class ProcessError extends Error {
66
68
  * args: ['--version']
67
69
  *
68
70
  */
69
- export type ProcessConfig = {
71
+ export type ProcessConfig = Omit<SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>, 'stdio'> & {
70
72
  command: string;
71
73
  args?: string[];
72
- cwd?: string;
73
74
  observer?: ProcessObserver;
74
75
  ignoreExitCode?: boolean;
75
76
  };
@@ -87,7 +88,8 @@ export type ProcessConfig = {
87
88
  * }
88
89
  */
89
90
  export type ProcessObserver = {
90
- onStdout?: (stdout: string) => void;
91
+ onStdout?: (stdout: string, sourceProcess?: ChildProcess) => void;
92
+ onStderr?: (stderr: string, sourceProcess?: ChildProcess) => void;
91
93
  onError?: (error: ProcessError) => void;
92
94
  onComplete?: () => void;
93
95
  };
@@ -1,5 +1,5 @@
1
- import { LogOptions as SimpleGitLogOptions } from 'simple-git';
2
- import { Commit } from '@code-pushup/models';
1
+ import { type LogOptions as SimpleGitLogOptions } from 'simple-git';
2
+ import { type Commit } from '@code-pushup/models';
3
3
  export declare function getLatestCommit(git?: import("simple-git").SimpleGit): Promise<Commit | null>;
4
4
  export declare function getCurrentBranchOrTag(git?: import("simple-git").SimpleGit): Promise<string>;
5
5
  export type LogResult = {
@@ -1,4 +1,4 @@
1
- import { StatusResult } from 'simple-git';
1
+ import { type StatusResult } from 'simple-git';
2
2
  export declare function getGitRoot(git?: import("simple-git").SimpleGit): Promise<string>;
3
3
  export declare function formatGitPath(path: string, gitRoot: string): string;
4
4
  export declare function toGitPath(path: string, git?: import("simple-git").SimpleGit): Promise<string>;
@@ -1,2 +1,2 @@
1
- import { CoreConfig } from '@code-pushup/models';
1
+ import type { CoreConfig } from '@code-pushup/models';
2
2
  export declare function mergeConfigs(config: CoreConfig, ...configs: Partial<CoreConfig>[]): Partial<CoreConfig>;
@@ -1,4 +1,4 @@
1
- import { CtorOptions, MultiProgressBars } from 'multi-progress-bars';
1
+ import { type CtorOptions, MultiProgressBars } from 'multi-progress-bars';
2
2
  type BarStyles = 'active' | 'done' | 'idle';
3
3
  type StatusStyles = Record<BarStyles, (s: string) => string>;
4
4
  export declare const barStyles: StatusStyles;
@@ -3,33 +3,8 @@ export declare const SCORE_COLOR_RANGE: {
3
3
  GREEN_MIN: number;
4
4
  YELLOW_MIN: number;
5
5
  };
6
- export declare const CATEGORIES_TITLE = "\uD83C\uDFF7 Categories";
7
6
  export declare const FOOTER_PREFIX = "Made with \u2764 by";
8
7
  export declare const CODE_PUSHUP_DOMAIN = "code-pushup.dev";
9
8
  export declare const README_LINK = "https://github.com/code-pushup/cli#readme";
10
- export declare const reportHeadlineText = "Code PushUp Report";
11
- export declare const reportOverviewTableHeaders: [{
12
- readonly key: "category";
13
- readonly label: "🏷 Category";
14
- readonly align: "left";
15
- }, {
16
- readonly key: "score";
17
- readonly label: "⭐ Score";
18
- }, {
19
- readonly key: "audits";
20
- readonly label: "🛡 Audits";
21
- }];
22
- export declare const reportRawOverviewTableHeaders: string[];
23
- export declare const issuesTableHeadings: [{
24
- readonly key: "severity";
25
- readonly label: "Severity";
26
- }, {
27
- readonly key: "message";
28
- readonly label: "Message";
29
- }, {
30
- readonly key: "file";
31
- readonly label: "Source file";
32
- }, {
33
- readonly key: "line";
34
- readonly label: "Line(s)";
35
- }];
9
+ export declare const REPORT_HEADLINE_TEXT = "Code PushUp Report";
10
+ export declare const REPORT_RAW_OVERVIEW_TABLE_HEADERS: string[];
@@ -1,4 +1,4 @@
1
- import { Report } from '@code-pushup/models';
1
+ import type { Report } from '@code-pushup/models';
2
2
  export declare function listGroupsFromAllPlugins<T extends Report>(report: T): {
3
3
  plugin: T['plugins'][number];
4
4
  group: NonNullable<T['plugins'][number]['groups']>[number];
@@ -1,6 +1,6 @@
1
- import { AuditReport, Table } from '@code-pushup/models';
2
- import { Hierarchy } from '../text-formats';
1
+ import { type HeadingLevel, type InlineText, MarkdownDocument } from 'build-md';
2
+ import type { AuditReport, Table } from '@code-pushup/models';
3
3
  export declare function tableSection(tableData: Table, options?: {
4
- level?: Hierarchy | 0;
5
- }): string;
6
- export declare function metaDescription({ docsUrl, description, }: Pick<AuditReport, 'docsUrl' | 'description'>): string;
4
+ level?: HeadingLevel;
5
+ }): MarkdownDocument | null;
6
+ export declare function metaDescription(audit: Pick<AuditReport, 'docsUrl' | 'description'>): InlineText;
@@ -1,6 +1,8 @@
1
- import { AuditReport } from '@code-pushup/models';
2
- import { ScoredGroup, ScoredReport } from './types';
3
- export declare function categoriesOverviewSection(report: Pick<ScoredReport, 'categories' | 'plugins'>): string;
4
- export declare function categoriesDetailsSection(report: Pick<ScoredReport, 'categories' | 'plugins'>): string;
5
- export declare function categoryRef({ title, score, value, displayValue }: AuditReport, pluginTitle: string): string;
6
- export declare function categoryGroupItem({ score, title }: ScoredGroup, groupAudits: AuditReport[], pluginTitle: string): string;
1
+ import { type InlineText, MarkdownDocument } from 'build-md';
2
+ import type { AuditReport } from '@code-pushup/models';
3
+ import type { ScoredGroup, ScoredReport } from './types';
4
+ export declare function categoriesOverviewSection(report: Pick<ScoredReport, 'categories' | 'plugins'>): MarkdownDocument;
5
+ export declare function categoriesDetailsSection(report: Pick<ScoredReport, 'categories' | 'plugins'>): MarkdownDocument;
6
+ export declare function categoryRef({ title, score, value, displayValue }: AuditReport, pluginTitle: string): InlineText;
7
+ export declare function categoryGroupItem({ score, title }: ScoredGroup, groupAudits: AuditReport[], pluginTitle: string): InlineText;
8
+ export declare function binaryIconSuffix(score: number, isBinary: boolean | undefined): string;
@@ -1,10 +1,11 @@
1
- import { AuditReport, Issue, Report, Table } from '@code-pushup/models';
2
- import { ScoredReport } from './types';
3
- export declare function auditDetailsAuditValue({ score, value, displayValue, }: AuditReport): string;
1
+ import { type InlineText, MarkdownDocument } from 'build-md';
2
+ import type { AuditReport, Issue, Report } from '@code-pushup/models';
3
+ import type { ScoredReport } from './types';
4
+ export declare function auditDetailsAuditValue({ score, value, displayValue, }: AuditReport): InlineText;
4
5
  export declare function generateMdReport(report: ScoredReport): string;
5
- export declare function auditDetailsIssues(issues?: Issue[]): string;
6
- export declare function auditDetails(audit: AuditReport): string;
7
- export declare function auditsSection({ plugins, }: Pick<ScoredReport, 'plugins'>): string;
8
- export declare function aboutSection(report: Omit<ScoredReport, 'packageName'>): string;
9
- export declare function reportPluginMeta({ plugins }: Pick<Report, 'plugins'>): Table;
10
- export declare function reportMetaData({ commit, version, duration, plugins, categories, }: Pick<ScoredReport, 'date' | 'duration' | 'version' | 'commit' | 'plugins' | 'categories'>): Table;
6
+ export declare function auditDetailsIssues(issues?: Issue[]): MarkdownDocument | null;
7
+ export declare function auditDetails(audit: AuditReport): MarkdownDocument;
8
+ export declare function auditsSection({ plugins, }: Pick<ScoredReport, 'plugins'>): MarkdownDocument;
9
+ export declare function aboutSection(report: Omit<ScoredReport, 'packageName'>): MarkdownDocument;
10
+ export declare function pluginMetaTable({ plugins, }: Pick<Report, 'plugins'>): Parameters<MarkdownDocument['table']>;
11
+ export declare function reportMetaTable({ commit, version, duration, plugins, categories, }: Pick<ScoredReport, 'date' | 'duration' | 'version' | 'commit' | 'plugins' | 'categories'>): Parameters<MarkdownDocument['table']>;
@@ -0,0 +1,29 @@
1
+ import { type InlineText, MarkdownDocument } from 'build-md';
2
+ import type { ReportsDiff } from '@code-pushup/models';
3
+ import type { DiffOutcome } from './types';
4
+ export declare function summarizeUnchanged(token: string, { changed, unchanged }: {
5
+ changed: unknown[];
6
+ unchanged: unknown[];
7
+ }): string;
8
+ export declare function summarizeDiffOutcomes(outcomes: DiffOutcome[], token: string): string;
9
+ export declare function createGroupsOrAuditsDetails<T extends 'group' | 'audit'>(token: T, { changed, unchanged }: ReportsDiff[`${T}s`], ...[columns, rows]: Parameters<MarkdownDocument['table']>): MarkdownDocument;
10
+ export declare function formatTitle({ title, docsUrl, }: {
11
+ title: string;
12
+ docsUrl?: string;
13
+ }): InlineText;
14
+ export declare function formatPortalLink(portalUrl: string | undefined): InlineText | undefined;
15
+ type Change = {
16
+ scores: {
17
+ diff: number;
18
+ };
19
+ values?: {
20
+ diff: number;
21
+ };
22
+ };
23
+ export declare function sortChanges<T extends Change>(changes: T[]): T[];
24
+ export declare function getDiffChanges(diff: ReportsDiff): Change[];
25
+ export declare function changesToDiffOutcomes(changes: Change[]): DiffOutcome[];
26
+ export declare function mergeDiffOutcomes(outcomes: DiffOutcome[]): DiffOutcome;
27
+ export declare function formatReportOutcome(outcome: DiffOutcome, commits?: ReportsDiff['commits']): InlineText;
28
+ export declare function compareDiffsBy<T extends 'categories' | 'groups' | 'audits'>(type: T, a: ReportsDiff, b: ReportsDiff): number;
29
+ export {};
@@ -1,2 +1,5 @@
1
- import { ReportsDiff } from '@code-pushup/models';
1
+ import type { ReportsDiff } from '@code-pushup/models';
2
+ import type { WithRequired } from '../types';
2
3
  export declare function generateMdReportsDiff(diff: ReportsDiff): string;
4
+ export type LabeledDiff = WithRequired<ReportsDiff, 'label'>;
5
+ export declare function generateMdReportsDiffForMonorepo(diffs: LabeledDiff[]): string;
@@ -0,0 +1,6 @@
1
+ import { type Format, type PersistConfig, type Report } from '@code-pushup/models';
2
+ type LoadedReportFormat<T extends Format> = T extends 'json' ? Report : string;
3
+ export declare function loadReport<T extends Format>(options: Required<Omit<PersistConfig, 'format'>> & {
4
+ format: T;
5
+ }): Promise<LoadedReportFormat<T>>;
6
+ export {};
@@ -1,2 +1,4 @@
1
- import { ScoredReport } from './types';
1
+ import type { ScoredReport } from './types';
2
2
  export declare function logStdoutSummary(report: ScoredReport): void;
3
+ export declare function logCategories({ categories, plugins }: ScoredReport): void;
4
+ export declare function binaryIconPrefix(score: number, isBinary: boolean | undefined): string;
@@ -1,5 +1,5 @@
1
- import { Report } from '@code-pushup/models';
2
- import { ScoredReport } from './types';
1
+ import type { Report } from '@code-pushup/models';
2
+ import type { ScoredReport } from './types';
3
3
  export declare class GroupRefInvalidError extends Error {
4
4
  constructor(auditSlug: string, pluginSlug: string);
5
5
  }
@@ -1,2 +1,6 @@
1
- import { ScoredReport } from './types';
1
+ import type { CategoryRef, Group } from '@code-pushup/models';
2
+ import type { ScoredReport, SortableAuditReport, SortableGroup } from './types';
3
+ export declare function getSortableAuditByRef({ slug, weight, plugin }: CategoryRef, plugins: ScoredReport['plugins']): SortableAuditReport;
4
+ export declare function getSortedGroupAudits(group: Group, plugin: string, plugins: ScoredReport['plugins']): SortableAuditReport[];
5
+ export declare function getSortableGroupByRef({ plugin, slug, weight }: CategoryRef, plugins: ScoredReport['plugins']): SortableGroup;
2
6
  export declare function sortReport(report: ScoredReport): ScoredReport;
@@ -1,4 +1,4 @@
1
- import { AuditReport, CategoryConfig, Group, PluginReport, Report } from '@code-pushup/models';
1
+ import type { AuditReport, CategoryConfig, Group, PluginReport, Report } from '@code-pushup/models';
2
2
  export type ScoredCategoryConfig = CategoryConfig & {
3
3
  score: number;
4
4
  };
@@ -1,32 +1,38 @@
1
- import { AuditReport, CategoryRef, IssueSeverity as CliIssueSeverity, Format, Group, Issue, PersistConfig, Report } from '@code-pushup/models';
2
- import { ScoredReport, SortableAuditReport, SortableGroup } from './types';
1
+ import { type Ansis } from 'ansis';
2
+ import { type InlineText } from 'build-md';
3
+ import type { AuditDiff, AuditReport, CategoryRef, IssueSeverity as CliIssueSeverity, Issue } from '@code-pushup/models';
4
+ import type { ScoredReport, SortableAuditReport, SortableGroup } from './types';
3
5
  export declare function formatReportScore(score: number): string;
4
6
  export declare function formatScoreWithColor(score: number, options?: {
5
7
  skipBold?: boolean;
6
- }): string;
8
+ }): InlineText;
7
9
  export type MarkerShape = 'circle' | 'square';
8
10
  export type ScoreColors = 'red' | 'yellow' | 'green';
9
11
  export declare const MARKERS: Record<MarkerShape, Record<ScoreColors, string>>;
10
12
  export declare function scoreMarker(score: number, markerType?: MarkerShape): string;
11
13
  export declare function getDiffMarker(diff: number): string;
12
- export declare function colorByScoreDiff(text: string, diff: number): string;
13
- export declare function shieldsBadge(text: string, color: string): string;
14
+ export declare function colorByScoreDiff(text: string, diff: number): InlineText;
15
+ export declare function shieldsBadge(text: string, color: string): InlineText;
14
16
  export declare function formatDiffNumber(diff: number): string;
15
17
  export declare function severityMarker(severity: 'info' | 'warning' | 'error'): string;
18
+ export declare function formatScoreChange(diff: number): InlineText;
19
+ export declare function formatValueChange({ values, scores, }: Pick<AuditDiff, 'values' | 'scores'>): InlineText;
16
20
  export declare function calcDuration(start: number, stop?: number): number;
17
21
  export declare function countWeightedRefs(refs: CategoryRef[]): number;
18
22
  export declare function countCategoryAudits(refs: CategoryRef[], plugins: ScoredReport['plugins']): number;
19
- export declare function getSortableAuditByRef({ slug, weight, plugin }: CategoryRef, plugins: ScoredReport['plugins']): SortableAuditReport;
20
- export declare function getSortableGroupByRef({ plugin, slug, weight }: CategoryRef, plugins: ScoredReport['plugins']): SortableGroup;
21
- export declare function getSortedGroupAudits(group: Group, plugin: string, plugins: ScoredReport['plugins']): SortableAuditReport[];
22
23
  export declare function compareCategoryAuditsAndGroups(a: SortableAuditReport | SortableGroup, b: SortableAuditReport | SortableGroup): number;
23
24
  export declare function compareAudits(a: AuditReport, b: AuditReport): number;
24
25
  export declare function compareIssueSeverity(severity1: CliIssueSeverity, severity2: CliIssueSeverity): number;
25
- type LoadedReportFormat<T extends Format> = T extends 'json' ? Report : string;
26
- export declare function loadReport<T extends Format>(options: Required<Omit<PersistConfig, 'format'>> & {
27
- format: T;
28
- }): Promise<LoadedReportFormat<T>>;
29
26
  export declare function throwIsNotPresentError(itemName: string, presentPlace: string): never;
30
27
  export declare function getPluginNameFromSlug(slug: string, plugins: ScoredReport['plugins']): string;
31
28
  export declare function compareIssues(a: Issue, b: Issue): number;
32
- export {};
29
+ export declare function applyScoreColor({ score, text }: {
30
+ score: number;
31
+ text?: string;
32
+ }, style?: Ansis): string;
33
+ export declare function targetScoreIcon(score: number, targetScore?: number, options?: {
34
+ passIcon?: string;
35
+ failIcon?: string;
36
+ prefix?: string;
37
+ postfix?: string;
38
+ }): string;
@@ -1,3 +1,11 @@
1
1
  export declare const NEW_LINE = "\n";
2
2
  export declare const TAB = " ";
3
3
  export declare const SPACE = " ";
4
+ export declare const HIERARCHY: {
5
+ readonly level_1: 1;
6
+ readonly level_2: 2;
7
+ readonly level_3: 3;
8
+ readonly level_4: 4;
9
+ readonly level_5: 5;
10
+ readonly level_6: 6;
11
+ };
@@ -1,2 +1,2 @@
1
- import { Table } from '@code-pushup/models';
1
+ import type { Table } from '@code-pushup/models';
2
2
  export declare function table(tableData: Table): string;
@@ -1,44 +1,13 @@
1
1
  import { details } from './html/details';
2
- import { bold as boldHtml, code as codeHtml, italic as italicHtml } from './html/font-style';
3
- import { link as linkHtml } from './html/link';
4
- import { table as tableHtml } from './html/table';
5
- import { bold as boldMd, code as codeMd, italic as italicMd, strikeThrough as strikeThroughMd } from './md/font-style';
6
- import { h, h1, h2, h3, h4, h5, h6, headline } from './md/headline';
7
- import { image } from './md/image';
8
- import { link as linkMd } from './md/link';
9
- import { indentation, li } from './md/list';
10
- import { paragraphs } from './md/paragraphs';
11
- import { lines, section } from './md/section';
12
- import { table as tableMd } from './md/table';
13
- export { NEW_LINE, SPACE, TAB } from './constants';
14
- export { Hierarchy } from './types';
15
- export declare const md: {
16
- bold: typeof boldMd;
17
- italic: typeof italicMd;
18
- strikeThrough: typeof strikeThroughMd;
19
- code: typeof codeMd;
20
- link: typeof linkMd;
21
- image: typeof image;
22
- headline: typeof headline;
23
- h: typeof h;
24
- h1: typeof h1;
25
- h2: typeof h2;
26
- h3: typeof h3;
27
- h4: typeof h4;
28
- h5: typeof h5;
29
- h6: typeof h6;
30
- indentation: typeof indentation;
31
- lines: typeof lines;
32
- li: typeof li;
33
- section: typeof section;
34
- paragraphs: typeof paragraphs;
35
- table: typeof tableMd;
36
- };
2
+ import { bold, code, italic } from './html/font-style';
3
+ import { link } from './html/link';
4
+ import { table } from './html/table';
5
+ export { NEW_LINE, SPACE, TAB, HIERARCHY } from './constants';
37
6
  export declare const html: {
38
- bold: typeof boldHtml;
39
- italic: typeof italicHtml;
40
- code: typeof codeHtml;
41
- link: typeof linkHtml;
7
+ bold: typeof bold;
8
+ italic: typeof italic;
9
+ code: typeof code;
10
+ link: typeof link;
42
11
  details: typeof details;
43
- table: typeof tableHtml;
12
+ table: typeof table;
44
13
  };
@@ -1,4 +1,4 @@
1
- import { Table, TableAlignment, TableColumnObject, TableColumnPrimitive } from '@code-pushup/models';
1
+ import type { Table, TableAlignment, TableColumnObject, TableColumnPrimitive } from '@code-pushup/models';
2
2
  export declare function rowToStringArray({ rows, columns }: Table): string[][];
3
3
  export declare function columnsToStringArray({ rows, columns, }: Pick<Table, 'columns' | 'rows'>): string[];
4
4
  export declare function getColumnAlignmentForKeyAndIndex(targetKey: string, targetIdx: number, columns?: TableColumnObject[]): TableAlignment;
@@ -28,7 +28,6 @@ export declare function toUnixNewlines(text: string): string;
28
28
  export declare function fromJsonLines<T = unknown>(jsonLines: string): T;
29
29
  export declare function toJsonLines<T>(json: T[]): string;
30
30
  export declare function capitalize<T extends string>(text: T): Capitalize<T>;
31
- export declare function apostrophize(text: string, upperCase?: boolean): string;
32
31
  export declare function toNumberPrecision(value: number, decimalPlaces: number): number;
33
32
  export declare function toOrdinal(value: number): string;
34
33
  export {};
@@ -1,3 +1,12 @@
1
1
  export type ExcludeNullFromPropertyTypes<T> = {
2
2
  [P in keyof T]: Exclude<T[P], null>;
3
3
  };
4
+ export type ItemOrArray<T> = T | T[];
5
+ export type ExtractArray<T> = T extends Array<unknown> ? T : never;
6
+ export type ExtractArrays<T extends Record<string, unknown>> = {
7
+ [K in keyof T]: ExtractArray<T[K]>;
8
+ };
9
+ export type WithRequired<T, K extends keyof T> = Prettify<Omit<T, K> & Required<Pick<T, K>>>;
10
+ export type Prettify<T> = {
11
+ [K in keyof T]: T[K];
12
+ };
@@ -1,4 +0,0 @@
1
- export declare function bold(text: string): string;
2
- export declare function italic(text: string): string;
3
- export declare function strikeThrough(text: string): string;
4
- export declare function code(text: string): string;
@@ -1,14 +0,0 @@
1
- import { Hierarchy } from '../types';
2
- /**
3
- * \# {text} // hierarchy set to 1
4
- *
5
- * \## {text} // hierarchy set to 2
6
- */
7
- export declare function headline(text: string, hierarchy?: Hierarchy): string;
8
- export declare function h(text: string, hierarchy?: Hierarchy): string;
9
- export declare function h1(text: string): string;
10
- export declare function h2(text: string): string;
11
- export declare function h3(text: string): string;
12
- export declare function h4(text: string): string;
13
- export declare function h5(text: string): string;
14
- export declare function h6(text: string): string;
@@ -1 +0,0 @@
1
- export declare function image(src: string, alt: string): string;
@@ -1 +0,0 @@
1
- export declare function link(href: string, text?: string): string;
@@ -1,7 +0,0 @@
1
- export type Order = 'unordered' | 'checkbox';
2
- /**
3
- * - {text}
4
- */
5
- export declare function li(text: string, order?: Order): string;
6
- export type Indentations = 1 | 2 | 3;
7
- export declare function indentation(text: string, level?: Indentations): string;
@@ -1 +0,0 @@
1
- export declare function paragraphs(...sections: (string | undefined | boolean)[]): string;
@@ -1,2 +0,0 @@
1
- export declare function section(...contents: (string | undefined | boolean)[]): string;
2
- export declare function lines(...contents: (string | undefined | boolean | number)[]): string;
@@ -1,9 +0,0 @@
1
- import { Table } from '@code-pushup/models';
2
- /**
3
- * | Table Header 1 | Table Header 2 |
4
- * | :-------------- | -------------: |
5
- * | String 1 | 1 |
6
- * | String 1 | 2 |
7
- * | String 1 | 3 |
8
- */
9
- export declare function table(data: Table): string;
@@ -1 +0,0 @@
1
- export type Hierarchy = 1 | 2 | 3 | 4 | 5 | 6;