@@ -20,14 +20,9 @@ import {
2020 strings ,
2121 url ,
2222} from '@angular-devkit/schematics' ;
23- import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks' ;
2423import { 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' ;
3126import { JSONFile } from '../utility/json-file' ;
3227import { latestVersions } from '../utility/latest-versions' ;
3328import { isStandaloneApp } from '../utility/ng-ast-utils' ;
@@ -136,23 +131,25 @@ function updateTsConfigFile(tsConfigPath: string): Rule {
136131 } ;
137132}
138133
139- function addDependencies ( ) : Rule {
134+ function addDependencies ( skipInstall : boolean | undefined ) : Rule {
140135 return ( host : Tree ) => {
141136 const coreDep = getPackageJsonDependency ( host , '@angular/core' ) ;
142137 if ( coreDep === null ) {
143138 throw new SchematicsException ( 'Could not find version.' ) ;
144139 }
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+ ] ) ;
156153 } ;
157154}
158155
@@ -178,9 +175,6 @@ export default function (options: ServerOptions): Rule {
178175 return ;
179176 }
180177
181- if ( ! options . skipInstall ) {
182- context . addTask ( new NodePackageInstallTask ( ) ) ;
183- }
184178 const clientBuildOptions = clientBuildTarget . options as Record < string , string > ;
185179 const browserEntryPoint = await getMainFilePath ( host , options . project ) ;
186180 const isStandalone = isStandaloneApp ( host , browserEntryPoint ) ;
@@ -220,7 +214,7 @@ export default function (options: ServerOptions): Rule {
220214 ) ,
221215 updateConfigFileBrowserBuilder ( options , tsConfigDirectory ) ,
222216 ] ) ,
223- addDependencies ( ) ,
217+ addDependencies ( options . skipInstall ) ,
224218 addRootProvider (
225219 options . project ,
226220 ( { code, external } ) =>
0 commit comments