@code-pushup/cli 0.12.1 → 0.12.3
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/README.md
CHANGED
|
@@ -23,6 +23,8 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
|
|
|
23
23
|
## Getting started
|
|
24
24
|
|
|
25
25
|
1. Install as a dev dependency with your package manager:
|
|
26
|
+
<details>
|
|
27
|
+
<summary>Installation command for <code>npm</code>, <code>yarn</code> and <code>pnpm</code></summary>
|
|
26
28
|
|
|
27
29
|
```sh
|
|
28
30
|
npm install --save-dev @code-pushup/cli
|
|
@@ -36,6 +38,8 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
|
|
|
36
38
|
pnpm add --save-dev @code-pushup/cli
|
|
37
39
|
```
|
|
38
40
|
|
|
41
|
+
</details>
|
|
42
|
+
|
|
39
43
|
2. Create a `code-pushup.config.js` configuration file (`.ts` or `.mjs` extensions are also supported).
|
|
40
44
|
|
|
41
45
|
```js
|
|
@@ -43,9 +47,6 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
|
|
|
43
47
|
plugins: [
|
|
44
48
|
// ...
|
|
45
49
|
],
|
|
46
|
-
categories: [
|
|
47
|
-
// ...
|
|
48
|
-
],
|
|
49
50
|
};
|
|
50
51
|
```
|
|
51
52
|
|
|
@@ -67,7 +68,13 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
|
|
|
67
68
|
};
|
|
68
69
|
```
|
|
69
70
|
|
|
70
|
-
4.
|
|
71
|
+
4. Run the CLI with `npx code-pushup` (see `--help` for list of commands and arguments).
|
|
72
|
+
|
|
73
|
+
5. View report file(s) in output directory (specified by `persist.outputDir` configuration).
|
|
74
|
+
|
|
75
|
+
### Set up categories (optional)
|
|
76
|
+
|
|
77
|
+
1. Define your custom categories.
|
|
71
78
|
|
|
72
79
|
```js
|
|
73
80
|
export default {
|
|
@@ -77,6 +84,7 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
|
|
|
77
84
|
slug: 'performance',
|
|
78
85
|
title: 'Performance',
|
|
79
86
|
refs: [
|
|
87
|
+
// reference to an existing audit or group from plugins
|
|
80
88
|
{
|
|
81
89
|
type: 'audit',
|
|
82
90
|
plugin: 'eslint',
|
|
@@ -91,9 +99,9 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
|
|
|
91
99
|
};
|
|
92
100
|
```
|
|
93
101
|
|
|
94
|
-
|
|
102
|
+
2. Run the CLI with `npx code-pushup`.
|
|
95
103
|
|
|
96
|
-
|
|
104
|
+
3. View report file(s) including category section in output directory.
|
|
97
105
|
|
|
98
106
|
## Portal integration
|
|
99
107
|
|
|
@@ -172,13 +180,15 @@ Each example is fully tested to demonstrate best practices for plugin testing as
|
|
|
172
180
|
> All common options, except `--onlyPlugins`, can be specified in the configuration file as well.
|
|
173
181
|
> CLI arguments take precedence over configuration file options.
|
|
174
182
|
|
|
175
|
-
> [!NOTE]
|
|
183
|
+
> [!NOTE]
|
|
176
184
|
> The `--upload.*` group of options is applicable to all commands except `collect`.
|
|
177
185
|
|
|
178
186
|
### Commands
|
|
179
187
|
|
|
180
188
|
#### `collect` command
|
|
181
189
|
|
|
190
|
+
<img src="./docs/images/cli-run-stdout-example.png" width="400" alt="example of code-pushup terminal output">
|
|
191
|
+
|
|
182
192
|
Usage:
|
|
183
193
|
`code-pushup collect [options]`
|
|
184
194
|
|
package/index.js
CHANGED
|
@@ -40,6 +40,9 @@ function exists(value) {
|
|
|
40
40
|
return value != null;
|
|
41
41
|
}
|
|
42
42
|
function getMissingRefsForCategories(categories, plugins) {
|
|
43
|
+
if (categories.length === 0) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
43
46
|
const auditRefsFromCategory = categories.flatMap(
|
|
44
47
|
({ refs }) => refs.filter(({ type }) => type === "audit").map(({ plugin, slug }) => `${plugin}/${slug}`)
|
|
45
48
|
);
|
|
@@ -314,7 +317,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
314
317
|
}
|
|
315
318
|
var categoriesSchema = z5.array(categoryConfigSchema, {
|
|
316
319
|
description: "Categorization of individual audits"
|
|
317
|
-
}).
|
|
320
|
+
}).refine(
|
|
318
321
|
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
319
322
|
(categoryCfg) => ({
|
|
320
323
|
message: duplicateSlugCategoriesErrorMsg(categoryCfg)
|
|
@@ -472,15 +475,15 @@ var unrefinedCoreConfigSchema = z11.object({
|
|
|
472
475
|
persist: persistConfigSchema.optional(),
|
|
473
476
|
/** portal configuration for uploading results */
|
|
474
477
|
upload: uploadConfigSchema.optional(),
|
|
475
|
-
categories: categoriesSchema
|
|
478
|
+
categories: categoriesSchema.optional()
|
|
476
479
|
});
|
|
477
480
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
478
481
|
function refineCoreConfig(schema) {
|
|
479
482
|
return schema.refine(
|
|
480
|
-
(coreCfg) => !getMissingRefsForCategories(coreCfg.categories, coreCfg.plugins),
|
|
483
|
+
(coreCfg) => !getMissingRefsForCategories(coreCfg.categories ?? [], coreCfg.plugins),
|
|
481
484
|
(coreCfg) => ({
|
|
482
485
|
message: missingRefsForCategoriesErrorMsg(
|
|
483
|
-
coreCfg.categories,
|
|
486
|
+
coreCfg.categories ?? [],
|
|
484
487
|
coreCfg.plugins
|
|
485
488
|
)
|
|
486
489
|
})
|
|
@@ -1114,12 +1117,13 @@ function tableHtml(data) {
|
|
|
1114
1117
|
|
|
1115
1118
|
// packages/utils/src/lib/reports/generate-md-report.ts
|
|
1116
1119
|
function generateMdReport(report, commitData) {
|
|
1120
|
+
const printCategories = report.categories.length > 0;
|
|
1117
1121
|
return (
|
|
1118
1122
|
// header section
|
|
1119
1123
|
// eslint-disable-next-line prefer-template
|
|
1120
|
-
reportToHeaderSection() + NEW_LINE + // overview section
|
|
1121
|
-
reportToOverviewSection(report) + NEW_LINE + NEW_LINE + // categories section
|
|
1122
|
-
reportToCategoriesSection(report) + NEW_LINE + NEW_LINE + // audits section
|
|
1124
|
+
reportToHeaderSection() + NEW_LINE + // categories overview section
|
|
1125
|
+
(printCategories ? reportToOverviewSection(report) + NEW_LINE + NEW_LINE : "") + // categories section
|
|
1126
|
+
(printCategories ? reportToCategoriesSection(report) + NEW_LINE + NEW_LINE : "") + // audits section
|
|
1123
1127
|
reportToAuditsSection(report) + NEW_LINE + NEW_LINE + // about section
|
|
1124
1128
|
reportToAboutSection(report, commitData) + NEW_LINE + NEW_LINE + // footer section
|
|
1125
1129
|
`${FOOTER_PREFIX} ${link(README_LINK, "Code PushUp")}`
|
|
@@ -1296,7 +1300,8 @@ function addLine(line = "") {
|
|
|
1296
1300
|
return line + NEW_LINE;
|
|
1297
1301
|
}
|
|
1298
1302
|
function generateStdoutSummary(report) {
|
|
1299
|
-
|
|
1303
|
+
const printCategories = report.categories.length > 0;
|
|
1304
|
+
return addLine(reportToHeaderSection2(report)) + addLine() + addLine(reportToDetailSection(report)) + (printCategories ? addLine(reportToOverviewSection2(report)) : "") + addLine(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
|
|
1300
1305
|
}
|
|
1301
1306
|
function reportToHeaderSection2(report) {
|
|
1302
1307
|
const { packageName, version: version2 } = report;
|
|
@@ -1528,7 +1533,7 @@ var verboseUtils = (verbose) => ({
|
|
|
1528
1533
|
|
|
1529
1534
|
// packages/core/package.json
|
|
1530
1535
|
var name = "@code-pushup/core";
|
|
1531
|
-
var version = "0.12.
|
|
1536
|
+
var version = "0.12.3";
|
|
1532
1537
|
|
|
1533
1538
|
// packages/core/src/lib/implementation/execute-plugin.ts
|
|
1534
1539
|
import chalk4 from "chalk";
|
|
@@ -1960,6 +1965,13 @@ function yargsAutorunCommandObject() {
|
|
|
1960
1965
|
}
|
|
1961
1966
|
};
|
|
1962
1967
|
await collectAndPersistReports(optionsWithFormat);
|
|
1968
|
+
if (options2.categories.length === 0) {
|
|
1969
|
+
console.info(
|
|
1970
|
+
chalk5.gray(
|
|
1971
|
+
"\u{1F4A1} Configure categories to see the scores in an overview table. See: https://github.com/code-pushup/cli/blob/main/packages/cli/README.md"
|
|
1972
|
+
)
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1963
1975
|
if (options2.upload) {
|
|
1964
1976
|
await upload(options2);
|
|
1965
1977
|
} else {
|
|
@@ -1991,6 +2003,13 @@ function yargsCollectCommandObject() {
|
|
|
1991
2003
|
console.info(chalk6.bold(CLI_NAME));
|
|
1992
2004
|
console.info(chalk6.gray(`Run ${command}...`));
|
|
1993
2005
|
await collectAndPersistReports(options2);
|
|
2006
|
+
if (options2.categories.length === 0) {
|
|
2007
|
+
console.info(
|
|
2008
|
+
chalk6.gray(
|
|
2009
|
+
"\u{1F4A1} Configure categories to see the scores in an overview table. See: https://github.com/code-pushup/cli/blob/main/packages/cli/README.md"
|
|
2010
|
+
)
|
|
2011
|
+
);
|
|
2012
|
+
}
|
|
1994
2013
|
const { upload: upload2 = {} } = args;
|
|
1995
2014
|
if (Object.keys(upload2).length === 0) {
|
|
1996
2015
|
console.info(
|
|
@@ -2077,6 +2096,7 @@ async function coreConfigMiddleware(processArgs) {
|
|
|
2077
2096
|
const {
|
|
2078
2097
|
persist: rcPersist,
|
|
2079
2098
|
upload: rcUpload,
|
|
2099
|
+
categories: rcCategories,
|
|
2080
2100
|
...remainingRcConfig
|
|
2081
2101
|
} = importedRc;
|
|
2082
2102
|
const parsedProcessArgs = {
|
|
@@ -2091,7 +2111,8 @@ async function coreConfigMiddleware(processArgs) {
|
|
|
2091
2111
|
outputDir: cliPersist?.outputDir ?? rcPersist?.outputDir ?? PERSIST_OUTPUT_DIR,
|
|
2092
2112
|
format: cliPersist?.format ?? rcPersist?.format ?? PERSIST_FORMAT,
|
|
2093
2113
|
filename: cliPersist?.filename ?? rcPersist?.filename ?? PERSIST_FILENAME
|
|
2094
|
-
}
|
|
2114
|
+
},
|
|
2115
|
+
categories: rcCategories ?? []
|
|
2095
2116
|
};
|
|
2096
2117
|
return parsedProcessArgs;
|
|
2097
2118
|
}
|
|
@@ -2108,6 +2129,9 @@ function filterCategoryByPluginSlug(categories, {
|
|
|
2108
2129
|
onlyPlugins,
|
|
2109
2130
|
verbose = false
|
|
2110
2131
|
}) {
|
|
2132
|
+
if (categories.length === 0) {
|
|
2133
|
+
return categories;
|
|
2134
|
+
}
|
|
2111
2135
|
if (!onlyPlugins?.length) {
|
|
2112
2136
|
return categories;
|
|
2113
2137
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import { CoreConfig } from '@code-pushup/models';
|
|
2
2
|
import { GeneralCliOptions } from './global.model';
|
|
3
3
|
export declare function coreConfigMiddleware<T extends Partial<GeneralCliOptions & CoreConfig>>(processArgs: T): Promise<{
|
|
4
|
-
categories: {
|
|
5
|
-
slug: string;
|
|
6
|
-
refs: {
|
|
7
|
-
slug: string;
|
|
8
|
-
weight: number;
|
|
9
|
-
type: "audit" | "group";
|
|
10
|
-
plugin: string;
|
|
11
|
-
}[];
|
|
12
|
-
title: string;
|
|
13
|
-
description?: string | undefined;
|
|
14
|
-
docsUrl?: string | undefined;
|
|
15
|
-
isBinary?: boolean | undefined;
|
|
16
|
-
}[];
|
|
17
4
|
plugins: {
|
|
18
5
|
slug: string;
|
|
19
6
|
title: string;
|
|
@@ -222,4 +209,17 @@ export declare function coreConfigMiddleware<T extends Partial<GeneralCliOptions
|
|
|
222
209
|
project: string;
|
|
223
210
|
timeout?: number | undefined;
|
|
224
211
|
} | undefined;
|
|
212
|
+
categories?: {
|
|
213
|
+
slug: string;
|
|
214
|
+
refs: {
|
|
215
|
+
slug: string;
|
|
216
|
+
weight: number;
|
|
217
|
+
type: "audit" | "group";
|
|
218
|
+
plugin: string;
|
|
219
|
+
}[];
|
|
220
|
+
title: string;
|
|
221
|
+
description?: string | undefined;
|
|
222
|
+
docsUrl?: string | undefined;
|
|
223
|
+
isBinary?: boolean | undefined;
|
|
224
|
+
}[] | undefined;
|
|
225
225
|
} & import("./core-config.model").ConfigCliOptions & import("@code-pushup/core").GlobalOptions>;
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { CoreConfig } from '@code-pushup/models';
|
|
2
2
|
import { GeneralCliOptions } from './global.model';
|
|
3
3
|
import { OnlyPluginsOptions } from './only-plugins.model';
|
|
4
|
-
export declare function onlyPluginsMiddleware<T extends Partial<GeneralCliOptions & CoreConfig & OnlyPluginsOptions>>(processArgs: T): {
|
|
5
|
-
categories: {
|
|
6
|
-
slug: string;
|
|
7
|
-
refs: {
|
|
8
|
-
slug: string;
|
|
9
|
-
weight: number;
|
|
10
|
-
type: "audit" | "group";
|
|
11
|
-
plugin: string;
|
|
12
|
-
}[];
|
|
13
|
-
title: string;
|
|
14
|
-
description?: string | undefined;
|
|
15
|
-
docsUrl?: string | undefined;
|
|
16
|
-
isBinary?: boolean | undefined;
|
|
17
|
-
}[];
|
|
4
|
+
export declare function onlyPluginsMiddleware<T extends Partial<GeneralCliOptions & CoreConfig & OnlyPluginsOptions>>(processArgs: T): Required<{
|
|
18
5
|
plugins: {
|
|
19
6
|
slug: string;
|
|
20
7
|
title: string;
|
|
@@ -223,4 +210,17 @@ export declare function onlyPluginsMiddleware<T extends Partial<GeneralCliOption
|
|
|
223
210
|
project: string;
|
|
224
211
|
timeout?: number | undefined;
|
|
225
212
|
} | undefined;
|
|
226
|
-
|
|
213
|
+
categories?: {
|
|
214
|
+
slug: string;
|
|
215
|
+
refs: {
|
|
216
|
+
slug: string;
|
|
217
|
+
weight: number;
|
|
218
|
+
type: "audit" | "group";
|
|
219
|
+
plugin: string;
|
|
220
|
+
}[];
|
|
221
|
+
title: string;
|
|
222
|
+
description?: string | undefined;
|
|
223
|
+
docsUrl?: string | undefined;
|
|
224
|
+
isBinary?: boolean | undefined;
|
|
225
|
+
}[] | undefined;
|
|
226
|
+
}> & import("./core-config.model").ConfigCliOptions & import("@code-pushup/core").GlobalOptions & OnlyPluginsOptions;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CoreConfig } from '@code-pushup/models';
|
|
1
|
+
import { CategoryConfig, CoreConfig } from '@code-pushup/models';
|
|
2
2
|
export declare function filterPluginsBySlug(plugins: CoreConfig['plugins'], { onlyPlugins }: {
|
|
3
3
|
onlyPlugins?: string[];
|
|
4
4
|
}): CoreConfig['plugins'];
|
|
5
|
-
export declare function filterCategoryByPluginSlug(categories:
|
|
5
|
+
export declare function filterCategoryByPluginSlug(categories: CategoryConfig[], { onlyPlugins, verbose, }: {
|
|
6
6
|
onlyPlugins?: string[];
|
|
7
7
|
verbose?: boolean;
|
|
8
|
-
}):
|
|
8
|
+
}): CategoryConfig[];
|
|
9
9
|
export declare function validateOnlyPluginsOption(plugins: CoreConfig['plugins'], { onlyPlugins, verbose, }: {
|
|
10
10
|
onlyPlugins?: string[];
|
|
11
11
|
verbose?: boolean;
|