fix(angular): validate standalone option in the directive generator (#16051)
This commit is contained in:
parent
9b60863b7b
commit
bf9542a150
@ -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
|
||||
},
|
||||
|
||||
@ -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.`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user