Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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