@code-pushup/cli 0.47.0 → 0.48.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/README.md +2 -1
- package/index.js +76 -19
- package/package.json +4 -4
- package/src/lib/implementation/core-config.middleware.d.ts +2 -1
- package/src/lib/implementation/skip-plugins.middleware.d.ts +2 -0
- package/src/lib/implementation/skip-plugins.model.d.ts +6 -0
- package/src/lib/implementation/skip-plugins.options.d.ts +3 -0
- package/src/lib/implementation/validate-plugin-filter-options.utils.d.ts +8 -0
- package/src/lib/options.d.ts +1 -0
- package/src/lib/implementation/only-plugins.utils.d.ts +0 -8
package/README.md
CHANGED
|
@@ -198,9 +198,10 @@ Each example is fully tested to demonstrate best practices for plugin testing as
|
|
|
198
198
|
| **`--upload.server`** | `string` | n/a | URL to your portal server. |
|
|
199
199
|
| **`--upload.apiKey`** | `string` | n/a | API key for the portal server. |
|
|
200
200
|
| **`--onlyPlugins`** | `string[]` | `[]` | Only run the specified plugins. Applicable to all commands except `upload`. |
|
|
201
|
+
| **`--skipPlugins`** | `string[]` | `[]` | Skip the specified plugins. Applicable to all commands except `upload`. |
|
|
201
202
|
|
|
202
203
|
> [!NOTE]
|
|
203
|
-
> All common options, except `--onlyPlugins`, can be specified in the configuration file as well.
|
|
204
|
+
> All common options, except `--onlyPlugins` and `--skipPlugins`, can be specified in the configuration file as well.
|
|
204
205
|
> CLI arguments take precedence over configuration file options.
|
|
205
206
|
|
|
206
207
|
> [!NOTE]
|
package/index.js
CHANGED
|
@@ -2139,8 +2139,8 @@ function formatDiffCategoriesSection(diff) {
|
|
|
2139
2139
|
}
|
|
2140
2140
|
const columns = [
|
|
2141
2141
|
{ key: "category", label: "\u{1F3F7}\uFE0F Category", align: "left" },
|
|
2142
|
-
{ key: "before", label: "\u2B50 Previous score" },
|
|
2143
|
-
{ key: "after", label:
|
|
2142
|
+
{ key: "before", label: hasChanges ? "\u2B50 Previous score" : "\u2B50 Score" },
|
|
2143
|
+
{ key: "after", label: "\u2B50 Current score" },
|
|
2144
2144
|
{ key: "change", label: "\u{1F504} Score change" }
|
|
2145
2145
|
];
|
|
2146
2146
|
return lines5(
|
|
@@ -2169,7 +2169,7 @@ function formatDiffCategoriesSection(diff) {
|
|
|
2169
2169
|
change: "\u2013"
|
|
2170
2170
|
}))
|
|
2171
2171
|
].map(
|
|
2172
|
-
(row) => hasChanges ? row : { category: row.category,
|
|
2172
|
+
(row) => hasChanges ? row : { category: row.category, before: row.before }
|
|
2173
2173
|
)
|
|
2174
2174
|
}),
|
|
2175
2175
|
added.length > 0 && section5(italicMd("(\\*) New category."))
|
|
@@ -2578,7 +2578,7 @@ var verboseUtils = (verbose = false) => ({
|
|
|
2578
2578
|
|
|
2579
2579
|
// packages/core/package.json
|
|
2580
2580
|
var name = "@code-pushup/core";
|
|
2581
|
-
var version = "0.
|
|
2581
|
+
var version = "0.48.0";
|
|
2582
2582
|
|
|
2583
2583
|
// packages/core/src/lib/implementation/execute-plugin.ts
|
|
2584
2584
|
import chalk5 from "chalk";
|
|
@@ -3469,6 +3469,19 @@ function yargsOnlyPluginsOptionsDefinition() {
|
|
|
3469
3469
|
};
|
|
3470
3470
|
}
|
|
3471
3471
|
|
|
3472
|
+
// packages/cli/src/lib/implementation/skip-plugins.options.ts
|
|
3473
|
+
var skipPluginsOption = {
|
|
3474
|
+
describe: "List of plugins to skip. If not set all plugins are run.",
|
|
3475
|
+
type: "array",
|
|
3476
|
+
default: [],
|
|
3477
|
+
coerce: coerceArray
|
|
3478
|
+
};
|
|
3479
|
+
function yargsSkipPluginsOptionsDefinition() {
|
|
3480
|
+
return {
|
|
3481
|
+
skipPlugins: skipPluginsOption
|
|
3482
|
+
};
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3472
3485
|
// packages/cli/src/lib/history/history.options.ts
|
|
3473
3486
|
function yargsHistoryOptionsDefinition() {
|
|
3474
3487
|
return {
|
|
@@ -3579,7 +3592,8 @@ function yargsHistoryCommandObject() {
|
|
|
3579
3592
|
builder: (yargs2) => {
|
|
3580
3593
|
yargs2.options({
|
|
3581
3594
|
...yargsHistoryOptionsDefinition(),
|
|
3582
|
-
...yargsOnlyPluginsOptionsDefinition()
|
|
3595
|
+
...yargsOnlyPluginsOptionsDefinition(),
|
|
3596
|
+
...yargsSkipPluginsOptionsDefinition()
|
|
3583
3597
|
});
|
|
3584
3598
|
yargs2.group(
|
|
3585
3599
|
Object.keys(yargsHistoryOptionsDefinition()),
|
|
@@ -3674,35 +3688,37 @@ async function coreConfigMiddleware(processArgs) {
|
|
|
3674
3688
|
};
|
|
3675
3689
|
}
|
|
3676
3690
|
|
|
3677
|
-
// packages/cli/src/lib/implementation/
|
|
3691
|
+
// packages/cli/src/lib/implementation/validate-plugin-filter-options.utils.ts
|
|
3678
3692
|
import chalk12 from "chalk";
|
|
3679
|
-
function
|
|
3693
|
+
function validatePluginFilterOption(filterOption, {
|
|
3680
3694
|
plugins,
|
|
3681
3695
|
categories
|
|
3682
3696
|
}, {
|
|
3683
|
-
|
|
3697
|
+
pluginsToFilter = [],
|
|
3684
3698
|
verbose = false
|
|
3685
3699
|
} = {}) {
|
|
3686
|
-
const
|
|
3687
|
-
const missingPlugins =
|
|
3700
|
+
const pluginsToFilterSet = new Set(pluginsToFilter);
|
|
3701
|
+
const missingPlugins = pluginsToFilter.filter(
|
|
3688
3702
|
(plugin) => !plugins.some(({ slug }) => slug === plugin)
|
|
3689
3703
|
);
|
|
3704
|
+
const isSkipOption = filterOption === "skipPlugins";
|
|
3705
|
+
const filterFunction = (plugin) => isSkipOption ? pluginsToFilterSet.has(plugin) : !pluginsToFilterSet.has(plugin);
|
|
3690
3706
|
if (missingPlugins.length > 0 && verbose) {
|
|
3691
3707
|
ui().logger.info(
|
|
3692
3708
|
`${chalk12.yellow(
|
|
3693
3709
|
"\u26A0"
|
|
3694
|
-
)} The
|
|
3710
|
+
)} The --${filterOption} argument references plugins with "${missingPlugins.join(
|
|
3695
3711
|
'", "'
|
|
3696
3712
|
)}" slugs, but no such plugins are present in the configuration. Expected one of the following plugin slugs: "${plugins.map(({ slug }) => slug).join('", "')}".`
|
|
3697
3713
|
);
|
|
3698
3714
|
}
|
|
3699
|
-
if (categories.length > 0) {
|
|
3700
|
-
const
|
|
3715
|
+
if (categories.length > 0 && verbose) {
|
|
3716
|
+
const removedCategorySlugs = filterItemRefsBy(
|
|
3701
3717
|
categories,
|
|
3702
|
-
({ plugin }) =>
|
|
3718
|
+
({ plugin }) => filterFunction(plugin)
|
|
3703
3719
|
).map(({ slug }) => slug);
|
|
3704
3720
|
ui().logger.info(
|
|
3705
|
-
`The
|
|
3721
|
+
`The --${filterOption} argument removed categories with "${removedCategorySlugs.join(
|
|
3706
3722
|
'", "'
|
|
3707
3723
|
)}" slugs.
|
|
3708
3724
|
`
|
|
@@ -3715,9 +3731,10 @@ function onlyPluginsMiddleware(originalProcessArgs) {
|
|
|
3715
3731
|
const { categories = [], onlyPlugins: originalOnlyPlugins } = originalProcessArgs;
|
|
3716
3732
|
if (originalOnlyPlugins && originalOnlyPlugins.length > 0) {
|
|
3717
3733
|
const { verbose, plugins, onlyPlugins = [] } = originalProcessArgs;
|
|
3718
|
-
|
|
3734
|
+
validatePluginFilterOption(
|
|
3735
|
+
"onlyPlugins",
|
|
3719
3736
|
{ plugins, categories },
|
|
3720
|
-
{ onlyPlugins, verbose }
|
|
3737
|
+
{ pluginsToFilter: onlyPlugins, verbose }
|
|
3721
3738
|
);
|
|
3722
3739
|
const validOnlyPlugins = onlyPlugins.filter(
|
|
3723
3740
|
(oP) => plugins.find((p) => p.slug === oP)
|
|
@@ -3739,6 +3756,36 @@ function onlyPluginsMiddleware(originalProcessArgs) {
|
|
|
3739
3756
|
};
|
|
3740
3757
|
}
|
|
3741
3758
|
|
|
3759
|
+
// packages/cli/src/lib/implementation/skip-plugins.middleware.ts
|
|
3760
|
+
function skipPluginsMiddleware(originalProcessArgs) {
|
|
3761
|
+
const { categories = [], skipPlugins: originalSkipPlugins } = originalProcessArgs;
|
|
3762
|
+
if (originalSkipPlugins && originalSkipPlugins.length > 0) {
|
|
3763
|
+
const { verbose, plugins, skipPlugins = [] } = originalProcessArgs;
|
|
3764
|
+
validatePluginFilterOption(
|
|
3765
|
+
"skipPlugins",
|
|
3766
|
+
{ plugins, categories },
|
|
3767
|
+
{ pluginsToFilter: skipPlugins, verbose }
|
|
3768
|
+
);
|
|
3769
|
+
const validSkipPlugins = skipPlugins.filter(
|
|
3770
|
+
(sP) => plugins.find((p) => p.slug === sP)
|
|
3771
|
+
);
|
|
3772
|
+
const skipPluginsSet = new Set(validSkipPlugins);
|
|
3773
|
+
return {
|
|
3774
|
+
...originalProcessArgs,
|
|
3775
|
+
plugins: skipPluginsSet.size > 0 ? plugins.filter(({ slug }) => !skipPluginsSet.has(slug)) : plugins,
|
|
3776
|
+
categories: skipPluginsSet.size > 0 ? filterItemRefsBy(
|
|
3777
|
+
categories,
|
|
3778
|
+
({ plugin }) => !skipPluginsSet.has(plugin)
|
|
3779
|
+
) : categories
|
|
3780
|
+
};
|
|
3781
|
+
}
|
|
3782
|
+
return {
|
|
3783
|
+
...originalProcessArgs,
|
|
3784
|
+
// if undefined fill categories with empty array
|
|
3785
|
+
categories
|
|
3786
|
+
};
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3742
3789
|
// packages/cli/src/lib/middlewares.ts
|
|
3743
3790
|
var middlewares = [
|
|
3744
3791
|
{
|
|
@@ -3748,6 +3795,10 @@ var middlewares = [
|
|
|
3748
3795
|
{
|
|
3749
3796
|
middlewareFunction: onlyPluginsMiddleware,
|
|
3750
3797
|
applyBeforeValidation: false
|
|
3798
|
+
},
|
|
3799
|
+
{
|
|
3800
|
+
middlewareFunction: skipPluginsMiddleware,
|
|
3801
|
+
applyBeforeValidation: false
|
|
3751
3802
|
}
|
|
3752
3803
|
];
|
|
3753
3804
|
|
|
@@ -3823,12 +3874,14 @@ function yargsGlobalOptionsDefinition() {
|
|
|
3823
3874
|
var options = {
|
|
3824
3875
|
...yargsGlobalOptionsDefinition(),
|
|
3825
3876
|
...yargsCoreConfigOptionsDefinition(),
|
|
3826
|
-
...yargsOnlyPluginsOptionsDefinition()
|
|
3877
|
+
...yargsOnlyPluginsOptionsDefinition(),
|
|
3878
|
+
...yargsSkipPluginsOptionsDefinition()
|
|
3827
3879
|
};
|
|
3828
3880
|
var groups = {
|
|
3829
3881
|
"Global Options:": [
|
|
3830
3882
|
...Object.keys(yargsGlobalOptionsDefinition()),
|
|
3831
|
-
...Object.keys(yargsOnlyPluginsOptionsDefinition())
|
|
3883
|
+
...Object.keys(yargsOnlyPluginsOptionsDefinition()),
|
|
3884
|
+
...Object.keys(yargsSkipPluginsOptionsDefinition())
|
|
3832
3885
|
],
|
|
3833
3886
|
"Persist Options:": Object.keys(yargsPersistConfigOptionsDefinition()),
|
|
3834
3887
|
"Upload Options:": Object.keys(yargsUploadConfigOptionsDefinition())
|
|
@@ -3920,6 +3973,10 @@ var cli = (args) => yargsCli(args, {
|
|
|
3920
3973
|
"code-pushup collect --onlyPlugins=coverage",
|
|
3921
3974
|
"Run collect with only coverage plugin, other plugins from config file will be skipped."
|
|
3922
3975
|
],
|
|
3976
|
+
[
|
|
3977
|
+
"code-pushup collect --skipPlugins=coverage",
|
|
3978
|
+
"Run collect skiping the coverage plugin, other plugins from config file will be included."
|
|
3979
|
+
],
|
|
3923
3980
|
[
|
|
3924
3981
|
"code-pushup upload --persist.outputDir=dist --persist.filename=cp-report --upload.apiKey=$CP_API_KEY",
|
|
3925
3982
|
"Upload dist/cp-report.json to portal using API key from environment variable"
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"code-pushup": "index.js"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@code-pushup/models": "0.
|
|
10
|
-
"@code-pushup/core": "0.
|
|
11
|
-
"@code-pushup/utils": "0.
|
|
9
|
+
"@code-pushup/models": "0.48.0",
|
|
10
|
+
"@code-pushup/core": "0.48.0",
|
|
11
|
+
"@code-pushup/utils": "0.48.0",
|
|
12
12
|
"yargs": "^17.7.2",
|
|
13
13
|
"chalk": "^5.3.0",
|
|
14
14
|
"simple-git": "^3.20.0"
|
|
@@ -2,4 +2,5 @@ import { CoreConfig } from '@code-pushup/models';
|
|
|
2
2
|
import { CoreConfigCliOptions } from './core-config.model';
|
|
3
3
|
import { GeneralCliOptions } from './global.model';
|
|
4
4
|
import { OnlyPluginsOptions } from './only-plugins.model';
|
|
5
|
-
|
|
5
|
+
import { SkipPluginsOptions } from './skip-plugins.model';
|
|
6
|
+
export declare function coreConfigMiddleware<T extends GeneralCliOptions & CoreConfigCliOptions & OnlyPluginsOptions & SkipPluginsOptions>(processArgs: T): Promise<GeneralCliOptions & CoreConfig & OnlyPluginsOptions & SkipPluginsOptions>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GlobalOptions } from '@code-pushup/core';
|
|
2
|
+
import { CoreConfig } from '@code-pushup/models';
|
|
3
|
+
export type SkipPluginsCliOptions = {
|
|
4
|
+
skipPlugins?: string[];
|
|
5
|
+
};
|
|
6
|
+
export type SkipPluginsOptions = Partial<GlobalOptions> & Pick<CoreConfig, 'categories' | 'plugins'> & SkipPluginsCliOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CategoryConfig, PluginConfig } from '@code-pushup/models';
|
|
2
|
+
export declare function validatePluginFilterOption(filterOption: 'onlyPlugins' | 'skipPlugins', { plugins, categories, }: {
|
|
3
|
+
plugins: PluginConfig[];
|
|
4
|
+
categories: CategoryConfig[];
|
|
5
|
+
}, { pluginsToFilter, verbose, }?: {
|
|
6
|
+
pluginsToFilter?: string[];
|
|
7
|
+
verbose?: boolean;
|
|
8
|
+
}): void;
|
package/src/lib/options.d.ts
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CategoryConfig, PluginConfig } from '@code-pushup/models';
|
|
2
|
-
export declare function validateOnlyPluginsOption({ plugins, categories, }: {
|
|
3
|
-
plugins: PluginConfig[];
|
|
4
|
-
categories: CategoryConfig[];
|
|
5
|
-
}, { onlyPlugins, verbose, }?: {
|
|
6
|
-
onlyPlugins?: string[];
|
|
7
|
-
verbose?: boolean;
|
|
8
|
-
}): void;
|