Skip to content

Commit

Permalink
fix(misc): report should include nx-plugin (#9312)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Mar 14, 2022
1 parent 6f038e7 commit db93879
Show file tree
Hide file tree
Showing 3 changed files with 36 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 @@ -24,6 +24,7 @@ export const packagesWeCareAbout = [
'@nrwl/next',
'@nrwl/node',
'@nrwl/nx-cloud',
'@nrwl/nx-plugin',
'@nrwl/react',
'@nrwl/react-native',
'@nrwl/schematics',
Expand All @@ -34,11 +35,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 @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions scripts/check-imports.js
Expand Up @@ -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',
Expand Down

0 comments on commit db93879

Please sign in to comment.