@code-pushup/utils 0.51.0 → 0.52.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 +44 -27
- package/package.json +5 -2
- package/src/index.d.ts +1 -1
- package/src/lib/file-system.d.ts +1 -0
- package/src/lib/reports/log-stdout-summary.d.ts +2 -1
package/index.js
CHANGED
|
@@ -1275,6 +1275,9 @@ function findLineNumberInText(content, pattern) {
|
|
|
1275
1275
|
function filePathToCliArg(path) {
|
|
1276
1276
|
return `"${path}"`;
|
|
1277
1277
|
}
|
|
1278
|
+
function projectToFilename(project) {
|
|
1279
|
+
return project.replace(/[/\\\s]+/g, "-").replace(/@/g, "");
|
|
1280
|
+
}
|
|
1278
1281
|
|
|
1279
1282
|
// packages/utils/src/lib/filter.ts
|
|
1280
1283
|
function filterItemRefsBy(items, refFilterFn) {
|
|
@@ -2658,11 +2661,11 @@ import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
|
|
|
2658
2661
|
function log(msg = "") {
|
|
2659
2662
|
ui().logger.log(msg);
|
|
2660
2663
|
}
|
|
2661
|
-
function logStdoutSummary(report) {
|
|
2664
|
+
function logStdoutSummary(report, verbose = false) {
|
|
2662
2665
|
const printCategories = report.categories.length > 0;
|
|
2663
2666
|
log(reportToHeaderSection(report));
|
|
2664
2667
|
log();
|
|
2665
|
-
logPlugins(report);
|
|
2668
|
+
logPlugins(report.plugins, verbose);
|
|
2666
2669
|
if (printCategories) {
|
|
2667
2670
|
logCategories(report);
|
|
2668
2671
|
}
|
|
@@ -2673,36 +2676,49 @@ function reportToHeaderSection(report) {
|
|
|
2673
2676
|
const { packageName, version } = report;
|
|
2674
2677
|
return `${bold4(REPORT_HEADLINE_TEXT)} - ${packageName}@${version}`;
|
|
2675
2678
|
}
|
|
2676
|
-
function logPlugins(
|
|
2677
|
-
const { plugins } = report;
|
|
2679
|
+
function logPlugins(plugins, verbose) {
|
|
2678
2680
|
plugins.forEach((plugin) => {
|
|
2679
2681
|
const { title, audits } = plugin;
|
|
2682
|
+
const filteredAudits = verbose ? audits : audits.filter(({ score }) => score !== 1);
|
|
2683
|
+
const diff = audits.length - filteredAudits.length;
|
|
2684
|
+
logAudits(title, filteredAudits);
|
|
2685
|
+
if (diff > 0) {
|
|
2686
|
+
const notice = filteredAudits.length === 0 ? `... All ${diff} audits have perfect scores ...` : `... ${diff} audits with perfect scores omitted for brevity ...`;
|
|
2687
|
+
logRow(1, notice);
|
|
2688
|
+
}
|
|
2680
2689
|
log();
|
|
2681
|
-
log(bold4.magentaBright(`${title} audits`));
|
|
2682
|
-
log();
|
|
2683
|
-
audits.forEach((audit) => {
|
|
2684
|
-
ui().row([
|
|
2685
|
-
{
|
|
2686
|
-
text: applyScoreColor({ score: audit.score, text: "\u25CF" }),
|
|
2687
|
-
width: 2,
|
|
2688
|
-
padding: [0, 1, 0, 0]
|
|
2689
|
-
},
|
|
2690
|
-
{
|
|
2691
|
-
text: audit.title,
|
|
2692
|
-
// eslint-disable-next-line no-magic-numbers
|
|
2693
|
-
padding: [0, 3, 0, 0]
|
|
2694
|
-
},
|
|
2695
|
-
{
|
|
2696
|
-
text: cyanBright(audit.displayValue || `${audit.value}`),
|
|
2697
|
-
// eslint-disable-next-line no-magic-numbers
|
|
2698
|
-
width: 20,
|
|
2699
|
-
padding: [0, 0, 0, 0]
|
|
2700
|
-
}
|
|
2701
|
-
]);
|
|
2702
|
-
});
|
|
2703
|
-
log();
|
|
2704
2690
|
});
|
|
2705
2691
|
}
|
|
2692
|
+
function logAudits(pluginTitle, audits) {
|
|
2693
|
+
log();
|
|
2694
|
+
log(bold4.magentaBright(`${pluginTitle} audits`));
|
|
2695
|
+
log();
|
|
2696
|
+
audits.forEach(({ score, title, displayValue, value }) => {
|
|
2697
|
+
logRow(score, title, displayValue || `${value}`);
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
function logRow(score, title, value) {
|
|
2701
|
+
ui().row([
|
|
2702
|
+
{
|
|
2703
|
+
text: applyScoreColor({ score, text: "\u25CF" }),
|
|
2704
|
+
width: 2,
|
|
2705
|
+
padding: [0, 1, 0, 0]
|
|
2706
|
+
},
|
|
2707
|
+
{
|
|
2708
|
+
text: title,
|
|
2709
|
+
// eslint-disable-next-line no-magic-numbers
|
|
2710
|
+
padding: [0, 3, 0, 0]
|
|
2711
|
+
},
|
|
2712
|
+
...value ? [
|
|
2713
|
+
{
|
|
2714
|
+
text: cyanBright(value),
|
|
2715
|
+
// eslint-disable-next-line no-magic-numbers
|
|
2716
|
+
width: 20,
|
|
2717
|
+
padding: [0, 0, 0, 0]
|
|
2718
|
+
}
|
|
2719
|
+
] : []
|
|
2720
|
+
]);
|
|
2721
|
+
}
|
|
2706
2722
|
function logCategories({ categories, plugins }) {
|
|
2707
2723
|
const hAlign = (idx) => idx === 0 ? "left" : "right";
|
|
2708
2724
|
const rows = categories.map(({ title, score, refs, isBinary }) => [
|
|
@@ -2911,6 +2927,7 @@ export {
|
|
|
2911
2927
|
pluginWorkDir,
|
|
2912
2928
|
pluralize,
|
|
2913
2929
|
pluralizeToken,
|
|
2930
|
+
projectToFilename,
|
|
2914
2931
|
readJsonFile,
|
|
2915
2932
|
readTextFile,
|
|
2916
2933
|
removeDirectoryIfExists,
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@code-pushup/models": "0.
|
|
6
|
+
"@code-pushup/models": "0.52.0",
|
|
7
7
|
"@isaacs/cliui": "^8.0.2",
|
|
8
8
|
"@poppinss/cliui": "^6.4.0",
|
|
9
9
|
"ansis": "^3.3.0",
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
25
25
|
"directory": "packages/utils"
|
|
26
26
|
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
27
30
|
"type": "module",
|
|
28
31
|
"main": "./index.js",
|
|
29
32
|
"types": "./src/index.d.ts"
|
package/src/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { exists } from '@code-pushup/models';
|
|
|
2
2
|
export { comparePairs, matchArrayItemsByKey, type Diff } from './lib/diff';
|
|
3
3
|
export { stringifyError } from './lib/errors';
|
|
4
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
|
+
export { crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, filePathToCliArg, findLineNumberInText, importModule, logMultipleFileResults, pluginWorkDir, projectToFilename, readJsonFile, readTextFile, removeDirectoryIfExists, type CrawlFileSystemOptions, type FileResult, type MultipleFileResults, } from './lib/file-system';
|
|
6
6
|
export { filterItemRefsBy } from './lib/filter';
|
|
7
7
|
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateIssueMessage, truncateText, truncateTitle, } from './lib/formatting';
|
|
8
8
|
export { formatGitPath, getGitRoot, guardAgainstLocalChanges, safeCheckout, toGitPath, } from './lib/git/git';
|
package/src/lib/file-system.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export type CrawlFileSystemOptions<T> = {
|
|
|
18
18
|
export declare function crawlFileSystem<T = string>(options: CrawlFileSystemOptions<T>): Promise<T[]>;
|
|
19
19
|
export declare function findLineNumberInText(content: string, pattern: string): number | null;
|
|
20
20
|
export declare function filePathToCliArg(path: string): string;
|
|
21
|
+
export declare function projectToFilename(project: string): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ScoredReport } from './types';
|
|
2
|
-
export declare function logStdoutSummary(report: ScoredReport): void;
|
|
2
|
+
export declare function logStdoutSummary(report: ScoredReport, verbose?: boolean): void;
|
|
3
|
+
export declare function logPlugins(plugins: ScoredReport['plugins'], verbose: boolean): void;
|
|
3
4
|
export declare function logCategories({ categories, plugins }: ScoredReport): void;
|
|
4
5
|
export declare function binaryIconPrefix(score: number, isBinary: boolean | undefined): string;
|