@@ -20,14 +20,9 @@ import {
20
20
strings ,
21
21
url ,
22
22
} from '@angular-devkit/schematics' ;
23
- import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks' ;
24
23
import { posix } from 'node:path' ;
25
- import { addRootProvider } from '../utility' ;
26
- import {
27
- NodeDependencyType ,
28
- addPackageJsonDependency ,
29
- getPackageJsonDependency ,
30
- } from '../utility/dependencies' ;
24
+ import { DependencyType , InstallBehavior , addDependency , addRootProvider } from '../utility' ;
25
+ import { getPackageJsonDependency } from '../utility/dependencies' ;
31
26
import { JSONFile } from '../utility/json-file' ;
32
27
import { latestVersions } from '../utility/latest-versions' ;
33
28
import { isStandaloneApp } from '../utility/ng-ast-utils' ;
@@ -136,23 +131,25 @@ function updateTsConfigFile(tsConfigPath: string): Rule {
136
131
} ;
137
132
}
138
133
139
- function addDependencies ( ) : Rule {
134
+ function addDependencies ( skipInstall : boolean | undefined ) : Rule {
140
135
return ( host : Tree ) => {
141
136
const coreDep = getPackageJsonDependency ( host , '@angular/core' ) ;
142
137
if ( coreDep === null ) {
143
138
throw new SchematicsException ( 'Could not find version.' ) ;
144
139
}
145
- const platformServerDep = {
146
- ...coreDep ,
147
- name : '@angular/platform-server' ,
148
- } ;
149
- addPackageJsonDependency ( host , platformServerDep ) ;
150
-
151
- addPackageJsonDependency ( host , {
152
- type : NodeDependencyType . Dev ,
153
- name : '@types/node' ,
154
- version : latestVersions [ '@types/node' ] ,
155
- } ) ;
140
+
141
+ const install = skipInstall ? InstallBehavior . None : InstallBehavior . Auto ;
142
+
143
+ return chain ( [
144
+ addDependency ( '@angular/platform-server' , coreDep . version , {
145
+ type : DependencyType . Default ,
146
+ install,
147
+ } ) ,
148
+ addDependency ( '@types/node' , latestVersions [ '@types/node' ] , {
149
+ type : DependencyType . Dev ,
150
+ install,
151
+ } ) ,
152
+ ] ) ;
156
153
} ;
157
154
}
158
155
@@ -178,9 +175,6 @@ export default function (options: ServerOptions): Rule {
178
175
return ;
179
176
}
180
177
181
- if ( ! options . skipInstall ) {
182
- context . addTask ( new NodePackageInstallTask ( ) ) ;
183
- }
184
178
const clientBuildOptions = clientBuildTarget . options as Record < string , string > ;
185
179
const browserEntryPoint = await getMainFilePath ( host , options . project ) ;
186
180
const isStandalone = isStandaloneApp ( host , browserEntryPoint ) ;
@@ -220,7 +214,7 @@ export default function (options: ServerOptions): Rule {
220
214
) ,
221
215
updateConfigFileBrowserBuilder ( options , tsConfigDirectory ) ,
222
216
] ) ,
223
- addDependencies ( ) ,
217
+ addDependencies ( options . skipInstall ) ,
224
218
addRootProvider (
225
219
options . project ,
226
220
( { code, external } ) =>
0 commit comments