Skip to content

Commit

Permalink
fix(angular): validate standalone option in the directive generator (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez authored Apr 3, 2023
1 parent 9b60863 commit bf9542a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/generated/packages/angular/generators/directive.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"description": "The HTML selector to use for this directive."
},
"standalone": {
"description": "Whether the generated directive is standalone.",
"description": "Whether the generated directive is standalone. _Note: This is only supported in Angular versions >= 14.1.0_.",
"type": "boolean",
"default": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Tree } from '@nrwl/devkit';
import { getProjects } from '@nrwl/devkit';
import { getProjects, stripIndents } from '@nrwl/devkit';
import { lt } from 'semver';
import { checkPathUnderProjectRoot } from '../../utils/path';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { Schema } from '../schema';

export function validateOptions(tree: Tree, options: Schema): void {
Expand All @@ -10,4 +12,10 @@ export function validateOptions(tree: Tree, options: Schema): void {
}

checkPathUnderProjectRoot(tree, options.project, options.path);

const installedAngularVersionInfo = getInstalledAngularVersionInfo(tree);
if (lt(installedAngularVersionInfo.version, '14.1.0') && options.standalone) {
throw new Error(stripIndents`The "standalone" option is only supported in Angular >= 14.1.0. You are currently using "${installedAngularVersionInfo.version}".
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
}
}
2 changes: 1 addition & 1 deletion packages/angular/src/generators/directive/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"description": "The HTML selector to use for this directive."
},
"standalone": {
"description": "Whether the generated directive is standalone.",
"description": "Whether the generated directive is standalone. _Note: This is only supported in Angular versions >= 14.1.0_.",
"type": "boolean",
"default": false
},
Expand Down

1 comment on commit bf9542a

@vercel
Copy link

@vercel vercel bot commented on bf9542a Apr 3, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app

Please sign in to comment.