diff --git a/packages/workspace/src/command-line/report.spec.ts b/packages/workspace/src/command-line/report.spec.ts index 399311ce3e1f6..f7db9e3bf17d6 100644 --- a/packages/workspace/src/command-line/report.spec.ts +++ b/packages/workspace/src/command-line/report.spec.ts @@ -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') { diff --git a/packages/workspace/src/command-line/report.ts b/packages/workspace/src/command-line/report.ts index f01794b18be57..dd7eb20bea395 100644 --- a/packages/workspace/src/command-line/report.ts +++ b/packages/workspace/src/command-line/report.ts @@ -24,6 +24,7 @@ export const packagesWeCareAbout = [ '@nrwl/next', '@nrwl/node', '@nrwl/nx-cloud', + '@nrwl/nx-plugin', '@nrwl/react', '@nrwl/react-native', '@nrwl/schematics', @@ -34,11 +35,12 @@ export const packagesWeCareAbout = [ 'rxjs', ]; -export const packagesWeIgnoreInCommunityReport = new Set([ +export const patternsWeIgnoreInCommunityReport: Array = [ ...packagesWeCareAbout, '@schematics/angular', + new RegExp('@angular/*'), '@nestjs/schematics', -]); +]; export const report = { command: 'report', @@ -117,7 +119,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 { diff --git a/scripts/check-imports.js b/scripts/check-imports.js index e5c1964054eea..2e5c95ee517f9 100644 --- a/scripts/check-imports.js +++ b/scripts/check-imports.js @@ -30,6 +30,7 @@ function check() { 'packages/create-nx-plugin/bin/create-nx-plugin.ts', 'packages/workspace/src/command-line/affected.ts', 'packages/workspace/src/command-line/report.ts', + 'packages/workspace/src/command-line/report.spec.ts', 'packages/workspace/src/core/file-utils.ts', 'packages/workspace/src/generators/preset/preset.ts', 'packages/workspace/src/generators/init/init.ts',