Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d6b80b3

Browse files
leosvelperezFrozenPandaz
authored andcommittedApr 11, 2023
fix(angular): validate standalone option in the directive generator (#16051)
(cherry picked from commit bf9542a)
1 parent c4b602a commit d6b80b3

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
 

‎docs/generated/packages/angular/generators/directive.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"description": "The HTML selector to use for this directive."
5555
},
5656
"standalone": {
57-
"description": "Whether the generated directive is standalone.",
57+
"description": "Whether the generated directive is standalone. _Note: This is only supported in Angular versions >= 14.1.0_.",
5858
"type": "boolean",
5959
"default": false
6060
},

‎packages/angular/src/generators/directive/lib/validate-options.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { Tree } from '@nrwl/devkit';
2-
import { getProjects } from '@nrwl/devkit';
2+
import { getProjects, stripIndents } from '@nrwl/devkit';
3+
import { lt } from 'semver';
34
import { checkPathUnderProjectRoot } from '../../utils/path';
5+
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
46
import type { Schema } from '../schema';
57

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

1214
checkPathUnderProjectRoot(tree, options.project, options.path);
15+
16+
const installedAngularVersionInfo = getInstalledAngularVersionInfo(tree);
17+
if (lt(installedAngularVersionInfo.version, '14.1.0') && options.standalone) {
18+
throw new Error(stripIndents`The "standalone" option is only supported in Angular >= 14.1.0. You are currently using "${installedAngularVersionInfo.version}".
19+
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
20+
}
1321
}

‎packages/angular/src/generators/directive/schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"description": "The HTML selector to use for this directive."
6464
},
6565
"standalone": {
66-
"description": "Whether the generated directive is standalone.",
66+
"description": "Whether the generated directive is standalone. _Note: This is only supported in Angular versions >= 14.1.0_.",
6767
"type": "boolean",
6868
"default": false
6969
},

0 commit comments

Comments
 (0)
Please sign in to comment.