diff --git a/docs/generated/packages/angular/generators/directive.json b/docs/generated/packages/angular/generators/directive.json index 07a4e8b7d95b0..1dd939c7d4898 100644 --- a/docs/generated/packages/angular/generators/directive.json +++ b/docs/generated/packages/angular/generators/directive.json @@ -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 }, diff --git a/packages/angular/src/generators/directive/lib/validate-options.ts b/packages/angular/src/generators/directive/lib/validate-options.ts index a73bcccdc8878..7af9476ea0817 100644 --- a/packages/angular/src/generators/directive/lib/validate-options.ts +++ b/packages/angular/src/generators/directive/lib/validate-options.ts @@ -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 { @@ -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.`); + } } diff --git a/packages/angular/src/generators/directive/schema.json b/packages/angular/src/generators/directive/schema.json index 3b499174bcb34..46ae84d8b7c4b 100644 --- a/packages/angular/src/generators/directive/schema.json +++ b/packages/angular/src/generators/directive/schema.json @@ -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 },