@code-pushup/utils 0.49.0 → 0.51.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 +450 -265
- package/package.json +5 -31
- package/src/index.d.ts +13 -12
- package/src/lib/errors.d.ts +1 -0
- package/src/lib/execute-process.d.ts +5 -3
- package/src/lib/git/git.commits-and-tags.d.ts +2 -2
- package/src/lib/git/git.d.ts +1 -1
- package/src/lib/merge-configs.d.ts +1 -1
- package/src/lib/progress.d.ts +1 -1
- package/src/lib/reports/constants.d.ts +1 -0
- package/src/lib/reports/flatten-plugins.d.ts +1 -1
- package/src/lib/reports/formatting.d.ts +15 -2
- package/src/lib/reports/generate-md-report-categoy-section.d.ts +3 -3
- package/src/lib/reports/generate-md-report.d.ts +7 -7
- package/src/lib/reports/generate-md-reports-diff-utils.d.ts +29 -0
- package/src/lib/reports/generate-md-reports-diff.d.ts +5 -2
- package/src/lib/reports/ide-environment.d.ts +3 -0
- package/src/lib/reports/load-report.d.ts +1 -1
- package/src/lib/reports/log-stdout-summary.d.ts +1 -1
- package/src/lib/reports/scoring.d.ts +2 -2
- package/src/lib/reports/sorting.d.ts +2 -2
- package/src/lib/reports/types.d.ts +3 -1
- package/src/lib/reports/utils.d.ts +5 -4
- package/src/lib/text-formats/html/table.d.ts +1 -1
- package/src/lib/text-formats/table.d.ts +1 -1
- package/src/lib/types.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
|
+
"description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
|
|
4
5
|
"dependencies": {
|
|
5
|
-
"@code-pushup/models": "0.
|
|
6
|
+
"@code-pushup/models": "0.51.0",
|
|
6
7
|
"@isaacs/cliui": "^8.0.2",
|
|
7
8
|
"@poppinss/cliui": "^6.4.0",
|
|
8
9
|
"ansis": "^3.3.0",
|
|
9
|
-
"build-md": "^0.4.
|
|
10
|
+
"build-md": "^0.4.2",
|
|
10
11
|
"bundle-require": "^4.0.1",
|
|
11
12
|
"esbuild": "^0.19.2",
|
|
12
13
|
"multi-progress-bars": "^5.0.3",
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
"simple-git": "^3.20.0"
|
|
15
16
|
},
|
|
16
17
|
"license": "MIT",
|
|
17
|
-
"homepage": "https://github.com/code-pushup/cli#readme",
|
|
18
|
+
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/utils#readme",
|
|
18
19
|
"bugs": {
|
|
19
20
|
"url": "https://github.com/code-pushup/cli/issues"
|
|
20
21
|
},
|
|
@@ -23,33 +24,6 @@
|
|
|
23
24
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
24
25
|
"directory": "packages/utils"
|
|
25
26
|
},
|
|
26
|
-
"contributors": [
|
|
27
|
-
{
|
|
28
|
-
"name": "Igor Katsuba",
|
|
29
|
-
"email": "igor@katsuba.dev",
|
|
30
|
-
"url": "https://katsuba.dev"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "Kateřina Pilátová",
|
|
34
|
-
"email": "katerina.pilatova@flowup.cz",
|
|
35
|
-
"url": "https://github.com/Tlacenka"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"name": "Matěj Chalk",
|
|
39
|
-
"email": "matej.chalk@flowup.cz",
|
|
40
|
-
"url": "https://github.com/matejchalk"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"name": "Michael Hladky",
|
|
44
|
-
"email": "michael.hladky@push-based.io",
|
|
45
|
-
"url": "https://push-based.io"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"name": "Michael Seredenko",
|
|
49
|
-
"email": "misha.seredenko@push-based.io",
|
|
50
|
-
"url": "https://github.com/MishaSeredenkoPushBased"
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
27
|
"type": "module",
|
|
54
28
|
"main": "./index.js",
|
|
55
29
|
"types": "./src/index.d.ts"
|
package/src/index.d.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
export { exists } from '@code-pushup/models';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
2
|
+
export { comparePairs, matchArrayItemsByKey, type Diff } from './lib/diff';
|
|
3
|
+
export { stringifyError } from './lib/errors';
|
|
4
|
+
export { ProcessError, executeProcess, type ProcessConfig, type ProcessObserver, type ProcessResult, } from './lib/execute-process';
|
|
5
|
+
export { crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, filePathToCliArg, findLineNumberInText, importModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, removeDirectoryIfExists, type CrawlFileSystemOptions, type FileResult, type MultipleFileResults, } 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 {
|
|
9
|
+
export { getCurrentBranchOrTag, getHashFromTag, getHashes, getLatestCommit, getSemverTags, type LogResult, } 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 {
|
|
13
|
+
export { link, ui, type CliUi, type Column } from './lib/logging';
|
|
13
14
|
export { mergeConfigs } from './lib/merge-configs';
|
|
14
|
-
export {
|
|
15
|
-
export { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX, README_LINK, TERMINAL_WIDTH, } from './lib/reports/constants';
|
|
15
|
+
export { getProgressBar, type ProgressBar } from './lib/progress';
|
|
16
|
+
export { CODE_PUSHUP_DOMAIN, CODE_PUSHUP_UNICODE_LOGO, 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';
|
|
19
20
|
export { loadReport } from './lib/reports/load-report';
|
|
20
21
|
export { logStdoutSummary } from './lib/reports/log-stdout-summary';
|
|
21
22
|
export { scoreReport } from './lib/reports/scoring';
|
|
22
23
|
export { sortReport } from './lib/reports/sorting';
|
|
23
|
-
export { ScoredCategoryConfig, ScoredGroup, ScoredReport, } from './lib/reports/types';
|
|
24
|
-
export { calcDuration, compareIssueSeverity } from './lib/reports/utils';
|
|
24
|
+
export type { ScoredCategoryConfig, ScoredGroup, ScoredReport, } from './lib/reports/types';
|
|
25
|
+
export { calcDuration, compareIssueSeverity, formatReportScore, } from './lib/reports/utils';
|
|
25
26
|
export { isSemver, normalizeSemver, sortSemvers } from './lib/semver';
|
|
26
27
|
export * from './lib/text-formats';
|
|
27
|
-
export {
|
|
28
|
-
export { ExcludeNullFromPropertyTypes } from './lib/types';
|
|
28
|
+
export { capitalize, countOccurrences, distinct, factorOf, fromJsonLines, objectFromEntries, objectToCliArgs, objectToEntries, objectToKeys, toArray, toJsonLines, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, type CliArgsObject, } from './lib/transform';
|
|
29
|
+
export type { ExcludeNullFromPropertyTypes, ExtractArray, ExtractArrays, ItemOrArray, Prettify, WithRequired, } from './lib/types';
|
|
29
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 = {
|
package/src/lib/git/git.d.ts
CHANGED
|
@@ -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>;
|
package/src/lib/progress.d.ts
CHANGED
|
@@ -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;
|
|
@@ -7,4 +7,5 @@ export declare const FOOTER_PREFIX = "Made with \u2764 by";
|
|
|
7
7
|
export declare const CODE_PUSHUP_DOMAIN = "code-pushup.dev";
|
|
8
8
|
export declare const README_LINK = "https://github.com/code-pushup/cli#readme";
|
|
9
9
|
export declare const REPORT_HEADLINE_TEXT = "Code PushUp Report";
|
|
10
|
+
export declare const CODE_PUSHUP_UNICODE_LOGO = "<\u2713>";
|
|
10
11
|
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,19 @@
|
|
|
1
|
-
import { HeadingLevel, InlineText, MarkdownDocument } from 'build-md';
|
|
2
|
-
import { AuditReport, Table } from '@code-pushup/models';
|
|
1
|
+
import { type HeadingLevel, type InlineText, MarkdownDocument } from 'build-md';
|
|
2
|
+
import type { AuditReport, SourceFileLocation, Table } from '@code-pushup/models';
|
|
3
|
+
import type { MdReportOptions } from './types';
|
|
3
4
|
export declare function tableSection(tableData: Table, options?: {
|
|
4
5
|
level?: HeadingLevel;
|
|
5
6
|
}): MarkdownDocument | null;
|
|
6
7
|
export declare function metaDescription(audit: Pick<AuditReport, 'docsUrl' | 'description'>): InlineText;
|
|
8
|
+
/**
|
|
9
|
+
* Link to local source for IDE
|
|
10
|
+
* @param source
|
|
11
|
+
* @param reportLocation
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* linkToLocalSourceInIde({ file: 'src/index.ts' }, { outputDir: '.code-pushup' }) // [`src/index.ts`](../src/index.ts)
|
|
15
|
+
*/
|
|
16
|
+
export declare function linkToLocalSourceForIde(source: SourceFileLocation, options?: Pick<MdReportOptions, 'outputDir'>): InlineText;
|
|
17
|
+
export declare function formatSourceLine(position: SourceFileLocation['position']): string;
|
|
18
|
+
export declare function formatGitHubLink(file: string, position: SourceFileLocation['position']): string;
|
|
19
|
+
export declare function formatFileLink(file: string, position: SourceFileLocation['position'], outputDir: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InlineText, MarkdownDocument } from 'build-md';
|
|
2
|
-
import { AuditReport } from '@code-pushup/models';
|
|
3
|
-
import { ScoredGroup, ScoredReport } from './types';
|
|
1
|
+
import { type InlineText, MarkdownDocument } from 'build-md';
|
|
2
|
+
import type { AuditReport } from '@code-pushup/models';
|
|
3
|
+
import type { ScoredGroup, ScoredReport } from './types';
|
|
4
4
|
export declare function categoriesOverviewSection(report: Pick<ScoredReport, 'categories' | 'plugins'>): MarkdownDocument;
|
|
5
5
|
export declare function categoriesDetailsSection(report: Pick<ScoredReport, 'categories' | 'plugins'>): MarkdownDocument;
|
|
6
6
|
export declare function categoryRef({ title, score, value, displayValue }: AuditReport, pluginTitle: string): InlineText;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { InlineText, MarkdownDocument } from 'build-md';
|
|
2
|
-
import { AuditReport, Issue, Report } from '@code-pushup/models';
|
|
3
|
-
import { ScoredReport } from './types';
|
|
1
|
+
import { type InlineText, MarkdownDocument } from 'build-md';
|
|
2
|
+
import type { AuditReport, Issue, Report } from '@code-pushup/models';
|
|
3
|
+
import type { MdReportOptions, ScoredReport } from './types';
|
|
4
4
|
export declare function auditDetailsAuditValue({ score, value, displayValue, }: AuditReport): InlineText;
|
|
5
|
-
export declare function generateMdReport(report: ScoredReport): string;
|
|
6
|
-
export declare function auditDetailsIssues(issues?: Issue[]): MarkdownDocument | null;
|
|
7
|
-
export declare function auditDetails(audit: AuditReport): MarkdownDocument;
|
|
8
|
-
export declare function auditsSection({ plugins
|
|
5
|
+
export declare function generateMdReport(report: ScoredReport, options?: MdReportOptions): string;
|
|
6
|
+
export declare function auditDetailsIssues(issues?: Issue[], options?: MdReportOptions): MarkdownDocument | null;
|
|
7
|
+
export declare function auditDetails(audit: AuditReport, options?: MdReportOptions): MarkdownDocument;
|
|
8
|
+
export declare function auditsSection({ plugins }: Pick<ScoredReport, 'plugins'>, options?: MdReportOptions): MarkdownDocument;
|
|
9
9
|
export declare function aboutSection(report: Omit<ScoredReport, 'packageName'>): MarkdownDocument;
|
|
10
10
|
export declare function pluginMetaTable({ plugins, }: Pick<Report, 'plugins'>): Parameters<MarkdownDocument['table']>;
|
|
11
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';
|
|
2
|
-
|
|
1
|
+
import type { ReportsDiff } from '@code-pushup/models';
|
|
2
|
+
import type { WithRequired } from '../types';
|
|
3
|
+
export declare function generateMdReportsDiff(diff: ReportsDiff): string;
|
|
4
|
+
export type LabeledDiff = WithRequired<ReportsDiff, 'label'>;
|
|
5
|
+
export declare function generateMdReportsDiffForMonorepo(diffs: LabeledDiff[]): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Format, PersistConfig, Report } from '@code-pushup/models';
|
|
1
|
+
import { type Format, type PersistConfig, type Report } from '@code-pushup/models';
|
|
2
2
|
type LoadedReportFormat<T extends Format> = T extends 'json' ? Report : string;
|
|
3
3
|
export declare function loadReport<T extends Format>(options: Required<Omit<PersistConfig, 'format'>> & {
|
|
4
4
|
format: T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScoredReport } from './types';
|
|
1
|
+
import type { ScoredReport } from './types';
|
|
2
2
|
export declare function logStdoutSummary(report: ScoredReport): void;
|
|
3
3
|
export declare function logCategories({ categories, plugins }: ScoredReport): void;
|
|
4
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,5 +1,5 @@
|
|
|
1
|
-
import { CategoryRef, Group } from '@code-pushup/models';
|
|
2
|
-
import { ScoredReport, SortableAuditReport, SortableGroup } from './types';
|
|
1
|
+
import type { CategoryRef, Group } from '@code-pushup/models';
|
|
2
|
+
import type { ScoredReport, SortableAuditReport, SortableGroup } from './types';
|
|
3
3
|
export declare function getSortableAuditByRef({ slug, weight, plugin }: CategoryRef, plugins: ScoredReport['plugins']): SortableAuditReport;
|
|
4
4
|
export declare function getSortedGroupAudits(group: Group, plugin: string, plugins: ScoredReport['plugins']): SortableAuditReport[];
|
|
5
5
|
export declare function getSortableGroupByRef({ plugin, slug, weight }: CategoryRef, plugins: ScoredReport['plugins']): SortableGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuditReport, CategoryConfig, Group, PluginReport, Report } from '@code-pushup/models';
|
|
1
|
+
import type { AuditReport, CategoryConfig, Group, PersistConfig, PluginReport, Report } from '@code-pushup/models';
|
|
2
2
|
export type ScoredCategoryConfig = CategoryConfig & {
|
|
3
3
|
score: number;
|
|
4
4
|
};
|
|
@@ -20,3 +20,5 @@ export type SortableAuditReport = AuditReport & {
|
|
|
20
20
|
plugin: string;
|
|
21
21
|
};
|
|
22
22
|
export type DiffOutcome = 'positive' | 'negative' | 'mixed' | 'unchanged';
|
|
23
|
+
export type MdReportOptions = Pick<PersistConfig, 'outputDir'>;
|
|
24
|
+
export type IdeEnvironment = 'vscode' | 'github' | 'other';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Ansis } from 'ansis';
|
|
2
|
-
import { InlineText } from 'build-md';
|
|
3
|
-
import { AuditDiff, AuditReport, CategoryRef, IssueSeverity as CliIssueSeverity, Issue } from '@code-pushup/models';
|
|
4
|
-
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';
|
|
5
5
|
export declare function formatReportScore(score: number): string;
|
|
6
6
|
export declare function formatScoreWithColor(score: number, options?: {
|
|
7
7
|
skipBold?: boolean;
|
|
@@ -15,6 +15,7 @@ export declare function colorByScoreDiff(text: string, diff: number): InlineText
|
|
|
15
15
|
export declare function shieldsBadge(text: string, color: string): InlineText;
|
|
16
16
|
export declare function formatDiffNumber(diff: number): string;
|
|
17
17
|
export declare function severityMarker(severity: 'info' | 'warning' | 'error'): string;
|
|
18
|
+
export declare function roundValue(value: number): number;
|
|
18
19
|
export declare function formatScoreChange(diff: number): InlineText;
|
|
19
20
|
export declare function formatValueChange({ values, scores, }: Pick<AuditDiff, 'values' | 'scores'>): InlineText;
|
|
20
21
|
export declare function calcDuration(start: number, stop?: number): number;
|
|
@@ -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,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;
|
package/src/lib/types.d.ts
CHANGED
|
@@ -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
|
+
};
|