Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/cdk/schematics/ng-add/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,12 +15,16 @@ export const cdkVersion = loadPackageVersionGracefully('@angular/cdk');
/**
* Schematic factory entry-point for the `ng-add` schematic. The ng-add schematic will be
* automatically executed if developers run `ng add @angular/cdk`.
*
* By default, the CLI already installs the package that has been specified with `ng add`.
* We just store the version in the `package.json` in case the package manager didn't. Also
* this ensures that there will be no error that says that the CDK does not support `ng add`.
*/
export default function(): Rule {
return (host: Tree) => {
// By default, the CLI already installs the package that has been installed through `ng add`.
// We just store the version in the `package.json` in case the package manager didn't.
addPackageToPackageJson(host, '@angular/cdk', `^${cdkVersion}`);
// In order to align the CDK version with the other Angular dependencies, we use tilde
// instead of caret. This is default for Angular dependencies in new CLI projects.
addPackageToPackageJson(host, '@angular/cdk', `~${cdkVersion}`);
};
}

Expand Down
6 changes: 4 additions & 2 deletions src/lib/schematics/ng-add/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,8 +26,10 @@ export default function(options: Schema): Rule {
// have the same version tag if possible.
const ngCoreVersionTag = getPackageVersionFromPackageJson(host, '@angular/core');

addPackageToPackageJson(host, '@angular/cdk', `^${materialVersion}`);
addPackageToPackageJson(host, '@angular/material', `^${materialVersion}`);
// In order to align the Material and CDK version with the other Angular dependencies,
// we use tilde instead of caret. This is default for Angular dependencies in new CLI projects.
addPackageToPackageJson(host, '@angular/cdk', `~${materialVersion}`);
addPackageToPackageJson(host, '@angular/material', `~${materialVersion}`);
addPackageToPackageJson(host, '@angular/animations',
ngCoreVersionTag || requiredAngularVersionRange);

Expand Down