6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { Rule , Tree , SchematicContext , TaskId } from '@angular-devkit/schematics' ;
9
+ import { Rule , SchematicContext , Tree } from '@angular-devkit/schematics' ;
10
10
import { NodePackageInstallTask , RunSchematicTask } from '@angular-devkit/schematics/tasks' ;
11
- import { addPackageToPackageJson , getPackageVersionFromPackageJson } from './package-json ' ;
11
+ import { addPackageToPackageJson , getPackageVersionFromPackageJson } from './package-config ' ;
12
12
import { Schema } from './schema' ;
13
13
import { hammerjsVersion , materialVersion , requiredAngularVersionRange } from './version-names' ;
14
14
@@ -21,32 +21,24 @@ import {hammerjsVersion, materialVersion, requiredAngularVersionRange} from './v
21
21
*/
22
22
export default function ( options : Schema ) : Rule {
23
23
return ( host : Tree , context : SchematicContext ) => {
24
- // Since the Angular Material schematics depend on the schematic utility functions from the
25
- // CDK, we need to install the CDK before loading the schematic files that import from the CDK.
26
- let installTaskId : TaskId ;
27
-
28
- if ( ! options . skipPackageJson ) {
29
- // Version tag of the `@angular/core` dependency that has been loaded from the `package.json`
30
- // of the CLI project. This tag should be preferred because all Angular dependencies should
31
- // have the same version tag if possible.
32
- const ngCoreVersionTag = getPackageVersionFromPackageJson ( host , '@angular/core' ) ;
33
-
34
- addPackageToPackageJson ( host , '@angular/cdk' , `^${ materialVersion } ` ) ;
35
- addPackageToPackageJson ( host , '@angular/material' , `^${ materialVersion } ` ) ;
36
- addPackageToPackageJson ( host , '@angular/animations' ,
37
- ngCoreVersionTag || requiredAngularVersionRange ) ;
24
+ // Version tag of the `@angular/core` dependency that has been loaded from the `package.json`
25
+ // of the CLI project. This tag should be preferred because all Angular dependencies should
26
+ // have the same version tag if possible.
27
+ const ngCoreVersionTag = getPackageVersionFromPackageJson ( host , '@angular/core' ) ;
38
28
39
- if ( options . gestures ) {
40
- addPackageToPackageJson ( host , 'hammerjs' , hammerjsVersion ) ;
41
- }
29
+ addPackageToPackageJson ( host , '@angular/cdk' , `^${ materialVersion } ` ) ;
30
+ addPackageToPackageJson ( host , '@angular/material' , `^${ materialVersion } ` ) ;
31
+ addPackageToPackageJson ( host , '@angular/animations' ,
32
+ ngCoreVersionTag || requiredAngularVersionRange ) ;
42
33
43
- installTaskId = context . addTask ( new NodePackageInstallTask ( ) ) ;
44
- } else {
45
- installTaskId = context . addTask ( new NodePackageInstallTask ( {
46
- packageName : `@angular/cdk@^${ materialVersion } `
47
- } ) ) ;
34
+ if ( options . gestures ) {
35
+ addPackageToPackageJson ( host , 'hammerjs' , hammerjsVersion ) ;
48
36
}
49
37
38
+ // Since the Angular Material schematics depend on the schematic utility functions from the
39
+ // CDK, we need to install the CDK before loading the schematic files that import from the CDK.
40
+ const installTaskId = context . addTask ( new NodePackageInstallTask ( ) ) ;
41
+
50
42
context . addTask ( new RunSchematicTask ( 'ng-add-setup-project' , options ) , [ installTaskId ] ) ;
51
43
} ;
52
44
}
0 commit comments