Skip to content

Commit

Permalink
fix(misc): report should include nx-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Mar 14, 2022
1 parent 4e9375f commit cc142cb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
24 changes: 24 additions & 0 deletions packages/workspace/src/command-line/report.spec.ts
Expand Up @@ -51,6 +51,30 @@ describe('report', () => {
]);
});

it('should exclude misc @angluar packages', () => {
jest.spyOn(devkit, 'readJsonFile').mockImplementation((path) => {
if (path === 'package.json') {
return {
dependencies: {
'@angular/cdk': '1.0.0',
},
devDependencies: {
'plugin-two': '2.0.0',
},
};
} else if (
path.includes(join('node_modules', 'plugin-two', 'package.json'))
) {
return {
schematics: {},
version: '1.0.0',
};
}
});
const plugins = findInstalledCommunityPlugins();
expect(plugins).toEqual([{ package: 'plugin-two', version: '1.0.0' }]);
});

it('should read nx devkit plugins', () => {
jest.spyOn(devkit, 'readJsonFile').mockImplementation((path) => {
if (path === 'package.json') {
Expand Down
14 changes: 11 additions & 3 deletions packages/workspace/src/command-line/report.ts
Expand Up @@ -25,6 +25,7 @@ export const packagesWeCareAbout = [
'@nrwl/next',
'@nrwl/node',
'@nrwl/nx-cloud',
'@nrwl/nx-plugin',
'@nrwl/react',
'@nrwl/react-native',
'@nrwl/schematics',
Expand All @@ -36,11 +37,12 @@ export const packagesWeCareAbout = [
'rxjs',
];

export const packagesWeIgnoreInCommunityReport = new Set([
export const patternsWeIgnoreInCommunityReport: Array<string | RegExp> = [
...packagesWeCareAbout,
'@schematics/angular',
new RegExp('@angular/*'),
'@nestjs/schematics',
]);
];

export const report = {
command: 'report',
Expand Down Expand Up @@ -119,7 +121,13 @@ export function findInstalledCommunityPlugins(): {

return deps.reduce(
(arr: any[], nextDep: string): { project: string; version: string }[] => {
if (packagesWeIgnoreInCommunityReport.has(nextDep)) {
if (
patternsWeIgnoreInCommunityReport.some((pattern) =>
typeof pattern === 'string'
? pattern === nextDep
: pattern.test(nextDep)
)
) {
return arr;
}
try {
Expand Down

0 comments on commit cc142cb

Please sign in to comment.