@code-pushup/utils 0.47.0 → 0.49.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/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@code-pushup/utils",
3
- "version": "0.47.0",
3
+ "version": "0.49.0",
4
4
  "dependencies": {
5
- "@code-pushup/models": "0.47.0",
5
+ "@code-pushup/models": "0.49.0",
6
+ "@isaacs/cliui": "^8.0.2",
7
+ "@poppinss/cliui": "^6.4.0",
8
+ "ansis": "^3.3.0",
9
+ "build-md": "^0.4.1",
6
10
  "bundle-require": "^4.0.1",
7
11
  "esbuild": "^0.19.2",
8
- "chalk": "^5.3.0",
9
- "@isaacs/cliui": "^8.0.2",
10
- "simple-git": "^3.20.0",
11
12
  "multi-progress-bars": "^5.0.3",
12
- "@poppinss/cliui": "^6.4.0",
13
- "semver": "^7.6.0"
13
+ "semver": "^7.6.0",
14
+ "simple-git": "^3.20.0"
14
15
  },
15
16
  "license": "MIT",
16
17
  "homepage": "https://github.com/code-pushup/cli#readme",
package/src/index.d.ts CHANGED
@@ -10,18 +10,20 @@ export { groupByStatus } from './lib/group-by-status';
10
10
  export { isPromiseFulfilledResult, isPromiseRejectedResult, } from './lib/guards';
11
11
  export { logMultipleResults } from './lib/log-results';
12
12
  export { CliUi, Column, link, ui } from './lib/logging';
13
+ export { mergeConfigs } from './lib/merge-configs';
13
14
  export { ProgressBar, getProgressBar } from './lib/progress';
14
15
  export { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX, README_LINK, TERMINAL_WIDTH, } from './lib/reports/constants';
15
16
  export { listAuditsFromAllPlugins, listGroupsFromAllPlugins, } from './lib/reports/flatten-plugins';
16
17
  export { generateMdReport } from './lib/reports/generate-md-report';
17
18
  export { generateMdReportsDiff } from './lib/reports/generate-md-reports-diff';
19
+ export { loadReport } from './lib/reports/load-report';
18
20
  export { logStdoutSummary } from './lib/reports/log-stdout-summary';
19
21
  export { scoreReport } from './lib/reports/scoring';
20
22
  export { sortReport } from './lib/reports/sorting';
21
23
  export { ScoredCategoryConfig, ScoredGroup, ScoredReport, } from './lib/reports/types';
22
- export { calcDuration, compareIssueSeverity, loadReport, } from './lib/reports/utils';
24
+ export { calcDuration, compareIssueSeverity } from './lib/reports/utils';
23
25
  export { isSemver, normalizeSemver, sortSemvers } from './lib/semver';
24
26
  export * from './lib/text-formats';
25
- export { CliArgsObject, apostrophize, capitalize, countOccurrences, distinct, factorOf, fromJsonLines, objectFromEntries, objectToCliArgs, objectToEntries, objectToKeys, toArray, toJsonLines, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, } from './lib/transform';
27
+ export { CliArgsObject, capitalize, countOccurrences, distinct, factorOf, fromJsonLines, objectFromEntries, objectToCliArgs, objectToEntries, objectToKeys, toArray, toJsonLines, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, } from './lib/transform';
26
28
  export { ExcludeNullFromPropertyTypes } from './lib/types';
27
29
  export { verboseUtils } from './lib/verbose-utils';
@@ -0,0 +1,2 @@
1
+ import { CoreConfig } from '@code-pushup/models';
2
+ export declare function mergeConfigs(config: CoreConfig, ...configs: Partial<CoreConfig>[]): Partial<CoreConfig>;
@@ -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,6 +1,6 @@
1
+ import { HeadingLevel, InlineText, MarkdownDocument } from 'build-md';
1
2
  import { AuditReport, Table } from '@code-pushup/models';
2
- import { Hierarchy } from '../text-formats';
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 { InlineText, MarkdownDocument } from 'build-md';
1
2
  import { AuditReport } from '@code-pushup/models';
2
3
  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;
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';
1
+ import { InlineText, MarkdownDocument } from 'build-md';
2
+ import { AuditReport, Issue, Report } from '@code-pushup/models';
2
3
  import { ScoredReport } from './types';
3
- export declare function auditDetailsAuditValue({ score, value, displayValue, }: AuditReport): string;
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']>;
@@ -1,2 +1,2 @@
1
1
  import { ReportsDiff } from '@code-pushup/models';
2
- export declare function generateMdReportsDiff(diff: ReportsDiff): string;
2
+ export declare function generateMdReportsDiff(diff: ReportsDiff, portalUrl?: string): string;
@@ -0,0 +1,6 @@
1
+ import { Format, PersistConfig, 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
1
  import { 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,2 +1,6 @@
1
- import { ScoredReport } from './types';
1
+ import { CategoryRef, Group } from '@code-pushup/models';
2
+ import { 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,32 +1,38 @@
1
- import { AuditReport, CategoryRef, IssueSeverity as CliIssueSeverity, Format, Group, Issue, PersistConfig, Report } from '@code-pushup/models';
1
+ import { Ansis } from 'ansis';
2
+ import { InlineText } from 'build-md';
3
+ import { AuditDiff, AuditReport, CategoryRef, IssueSeverity as CliIssueSeverity, Issue } from '@code-pushup/models';
2
4
  import { 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,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
  };
@@ -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,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;