fix(misc): report should include nx-plugin (#9312)

This commit is contained in:
Craigory Coppola 2022-03-14 17:09:27 -04:00 committed by GitHub
parent 6f038e7a4a
commit db938799a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 3 deletions

View File

@ -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', () => { it('should read nx devkit plugins', () => {
jest.spyOn(devkit, 'readJsonFile').mockImplementation((path) => { jest.spyOn(devkit, 'readJsonFile').mockImplementation((path) => {
if (path === 'package.json') { if (path === 'package.json') {

View File

@ -24,6 +24,7 @@ export const packagesWeCareAbout = [
'@nrwl/next', '@nrwl/next',
'@nrwl/node', '@nrwl/node',
'@nrwl/nx-cloud', '@nrwl/nx-cloud',
'@nrwl/nx-plugin',
'@nrwl/react', '@nrwl/react',
'@nrwl/react-native', '@nrwl/react-native',
'@nrwl/schematics', '@nrwl/schematics',
@ -34,11 +35,12 @@ export const packagesWeCareAbout = [
'rxjs', 'rxjs',
]; ];
export const packagesWeIgnoreInCommunityReport = new Set([ export const patternsWeIgnoreInCommunityReport: Array<string | RegExp> = [
...packagesWeCareAbout, ...packagesWeCareAbout,
'@schematics/angular', '@schematics/angular',
new RegExp('@angular/*'),
'@nestjs/schematics', '@nestjs/schematics',
]); ];
export const report = { export const report = {
command: 'report', command: 'report',
@ -117,7 +119,13 @@ export function findInstalledCommunityPlugins(): {
return deps.reduce( return deps.reduce(
(arr: any[], nextDep: string): { project: string; version: string }[] => { (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; return arr;
} }
try { try {

View File

@ -30,6 +30,7 @@ function check() {
'packages/create-nx-plugin/bin/create-nx-plugin.ts', 'packages/create-nx-plugin/bin/create-nx-plugin.ts',
'packages/workspace/src/command-line/affected.ts', 'packages/workspace/src/command-line/affected.ts',
'packages/workspace/src/command-line/report.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/core/file-utils.ts',
'packages/workspace/src/generators/preset/preset.ts', 'packages/workspace/src/generators/preset/preset.ts',
'packages/workspace/src/generators/init/init.ts', 'packages/workspace/src/generators/init/init.ts',