11import assert from 'node:assert' ;
2- import { setTimeout } from 'node:timers/promises' ;
3- import { ng , waitForAnyProcessOutputToMatch } from '../../utils/process' ;
2+ import {
3+ execAndWaitForOutputToMatch ,
4+ ng ,
5+ waitForAnyProcessOutputToMatch ,
6+ } from '../../utils/process' ;
47import { installWorkspacePackages , uninstallPackage } from '../../utils/packages' ;
5- import { ngServe , useSha } from '../../utils/project' ;
8+ import { useSha } from '../../utils/project' ;
69import { getGlobalVariable } from '../../utils/env' ;
710import { readFile , writeFile } from '../../utils/fs' ;
11+ import { findFreePort } from '../../utils/network' ;
812
913export default async function ( ) {
1014 assert (
@@ -22,20 +26,27 @@ export default async function () {
2226 await useSha ( ) ;
2327 await installWorkspacePackages ( ) ;
2428
25- const port = await ngServe ( ) ;
29+ const port = await findFreePort ( ) ;
30+ await execAndWaitForOutputToMatch (
31+ 'ng' ,
32+ [ 'serve' , '--port' , port . toString ( ) ] ,
33+ / A p p l i c a t i o n b u n d l e g e n e r a t i o n c o m p l e t e / ,
34+ { CI : '0' , NO_COLOR : 'true' } ,
35+ ) ;
2636 await validateResponse ( '/' , / H e l l o , / ) ;
2737
28- const appConfigContentsUpdated = `
29- import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
30- ${ ( await readFile ( 'src/app/app.config.ts' ) ) . replace ( 'provideRouter(routes),' , 'provideAnimationsAsync(), provideRouter(routes),' ) }
31- ` ;
32-
3338 await Promise . all ( [
3439 waitForAnyProcessOutputToMatch (
3540 / n e w d e p e n d e n c i e s o p t i m i z e d : @ a n g u l a r \/ p l a t f o r m - b r o w s e r \/ a n i m a t i o n s \/ a s y n c / ,
3641 6000 ,
3742 ) ,
38- setTimeout ( 200 ) . then ( ( ) => writeFile ( 'src/app/app.config.ts' , appConfigContentsUpdated ) ) ,
43+ writeFile (
44+ 'src/app/app.config.ts' ,
45+ `
46+ import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
47+ ${ ( await readFile ( 'src/app/app.config.ts' ) ) . replace ( 'provideRouter(routes),' , 'provideAnimationsAsync(), provideRouter(routes),' ) }
48+ ` ,
49+ ) ,
3950 ] ) ;
4051
4152 // Verify the app still works.
0 commit comments