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(core): ignore angular.json projects if @nrwl/angular is not insta… #13827

Merged
merged 1 commit into from Dec 14, 2022
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
12 changes: 11 additions & 1 deletion packages/nx/src/config/workspaces.ts
Expand Up @@ -33,7 +33,8 @@ import { joinPathFragments } from '../utils/path';
export function workspaceConfigName(
root: string
): 'angular.json' | 'workspace.json' | null {
if (existsSync(path.join(root, 'angular.json'))) {
// If a workspace doesn't have `@nrwl/angular` it's likely they do not want projects from `angular.json` to be considered by Nx.
if (existsSync(path.join(root, 'angular.json')) && isNrwlAngularInstalled()) {
return 'angular.json';
} else if (existsSync(path.join(root, 'workspace.json'))) {
return 'workspace.json';
Expand Down Expand Up @@ -431,6 +432,15 @@ function assertValidWorkspaceConfiguration(
}
}

function isNrwlAngularInstalled() {
try {
require.resolve('@nrwl/angular');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some debate on whether require.resolve vs reading package.json and checking deps is better for this check.

This could potentially have a false positive if there was @nrwl/angular found in one of the dependency chains of another installed library, but that should be relatively rare. In any case, the behavior exhibited would be the currently existing behavior, so its a low impact.

return true;
} catch {
return false;
}
}

function findFullGeneratorName(
name: string,
generators: {
Expand Down
1 change: 1 addition & 0 deletions scripts/depcheck/missing.ts
Expand Up @@ -124,6 +124,7 @@ const IGNORE_MATCHES_IN_PACKAGE = {
'@angular-devkit/core',
'@angular-devkit/architect',
'@angular/cli',
'@nrwl/angular',
'ts-node', // We *may* fall back on ts-node, but we want to encourage the use of @swc-node instead so we don't explicitly list ts-node as an optional dep
],
web: [
Expand Down