Skip to content

Commit e963c36

Browse files
committed
fix(cli): make onlyPlugins filter based on plugin not audit/group slug
1 parent c0038b2 commit e963c36

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

packages/cli/src/lib/implementation/only-plugins.utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import chalk from 'chalk';
2-
import { CategoryConfig, CoreConfig } from '@code-pushup/models';
2+
import type { CategoryConfig, CoreConfig } from '@code-pushup/models';
33

44
export function filterPluginsBySlug(
55
plugins: CoreConfig['plugins'],
@@ -29,14 +29,14 @@ export function filterCategoryByPluginSlug(
2929

3030
return categories.filter(category =>
3131
category.refs.every(ref => {
32-
const isNotSkipped = onlyPlugins.includes(ref.slug);
32+
const isNotSkipped = onlyPlugins.includes(ref.plugin);
3333

3434
if (!isNotSkipped && verbose) {
3535
console.info(
3636
`${chalk.yellow('⚠')} Category "${
3737
category.title
3838
}" is ignored because it references audits from skipped plugin "${
39-
ref.slug
39+
ref.plugin
4040
}"`,
4141
);
4242
}

packages/cli/src/lib/implementation/only-plugins.utils.unit.test.ts

+19-9
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,47 @@ describe('filterCategoryByPluginSlug', () => {
3939
expect(
4040
filterCategoryByPluginSlug(
4141
[
42-
{ refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }] },
43-
{ refs: [{ slug: 'plugin3' }] },
42+
{
43+
refs: [{ plugin: 'plugin1' }, { plugin: 'plugin2' }],
44+
},
45+
{ refs: [{ plugin: 'plugin3' }] },
4446
] as CategoryConfig[],
4547
{},
4648
),
4749
).toEqual([
48-
{ refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }] },
49-
{ refs: [{ slug: 'plugin3' }] },
50+
{
51+
refs: [{ plugin: 'plugin1' }, { plugin: 'plugin2' }],
52+
},
53+
{ refs: [{ plugin: 'plugin3' }] },
5054
]);
5155
});
5256

5357
it('should return categories containing only defined plugins', () => {
5458
expect(
5559
filterCategoryByPluginSlug(
5660
[
57-
{ refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }] },
58-
{ refs: [{ slug: 'plugin3' }] },
61+
{
62+
refs: [{ plugin: 'plugin1' }, { plugin: 'plugin2' }],
63+
},
64+
{ refs: [{ plugin: 'plugin3' }] },
5965
] as CategoryConfig[],
6066
{ onlyPlugins: ['plugin1', 'plugin3'] },
6167
),
62-
).toEqual([{ refs: [{ slug: 'plugin3' }] }]);
68+
).toEqual([{ refs: [{ plugin: 'plugin3' }] }]);
6369
});
6470

6571
it('should print ignored category and its first violating plugin', () => {
6672
filterCategoryByPluginSlug(
6773
[
6874
{
6975
title: 'category1',
70-
refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }, { slug: 'plugin4' }],
76+
refs: [
77+
{ plugin: 'plugin1' },
78+
{ plugin: 'plugin2' },
79+
{ plugin: 'plugin4' },
80+
],
7181
},
72-
{ title: 'category2', refs: [{ slug: 'plugin3' }] },
82+
{ title: 'category2', refs: [{ plugin: 'plugin3' }] },
7383
] as CategoryConfig[],
7484
{
7585
onlyPlugins: ['plugin1', 'plugin3'],

0 commit comments

Comments
 (0)