@@ -41,13 +41,16 @@ type Props = {
4141 options : zod . infer < typeof options > ;
4242} ;
4343
44- function isDockerRunning ( ) {
45- try {
46- spawn ( 'docker' , [ 'info' ] ) ;
47- return true ;
48- } catch {
49- return false ;
50- }
44+ function isDockerRunning ( ) : Promise < boolean > {
45+ return new Promise ( resolve => {
46+ const isRunning = spawn ( 'docker' , [ 'info' ] ) ;
47+ isRunning . on ( 'close' , code => {
48+ resolve ( code === 0 ) ;
49+ } ) ;
50+ isRunning . on ( 'error' , ( ) => {
51+ resolve ( false ) ;
52+ } ) ;
53+ } ) ;
5154}
5255
5356export default function Start ( { options} : Props ) {
@@ -64,7 +67,8 @@ export default function Start({options}: Props) {
6467 cwd : CONFIG_DIR ,
6568 } ) ;
6669
67- if ( options ?. docker_check && ! isDockerRunning ( ) ) {
70+ const dockerRunning = await isDockerRunning ( ) ;
71+ if ( ! dockerRunning ) {
6872 setDockerError ( true ) ;
6973 setLoading ( false ) ;
7074 return ;
@@ -75,18 +79,29 @@ export default function Start({options}: Props) {
7579
7680 const folderName = path . basename ( REPO_URL , '.git' ) ;
7781
78- spawn ( 'docker-compose' , [ '-f' , 'docker-compose.dev.yml' , 'up' , '-d' ] , {
79- cwd : path . join ( CONFIG_DIR , folderName ) ,
80- stdio : 'inherit' ,
81- env : {
82- ...process . env ,
83- API_PORT : String ( options ?. port || 3000 ) ,
84- ENABLE_VERBOSE_LOGGING : options ?. verbose || 'false' ,
82+ const dockerCompose = spawn (
83+ 'docker-compose' ,
84+ [ '-f' , 'docker-compose.dev.yml' , 'up' , '-d' ] ,
85+ {
86+ cwd : path . join ( CONFIG_DIR , folderName ) ,
87+ stdio : 'inherit' ,
88+ env : {
89+ ...process . env ,
90+ API_PORT : String ( options ?. port || 3000 ) ,
91+ ENABLE_VERBOSE_LOGGING : options ?. verbose || 'false' ,
92+ } ,
8593 } ,
86- } ) ;
94+ ) ;
8795
88- setStatus ( 'Opening browser...' ) ;
89- await open ( 'http://localhost:5173' ) ;
96+ dockerCompose . on ( 'close' , async code => {
97+ if ( code !== 0 ) {
98+ setDockerError ( true ) ;
99+ setLoading ( false ) ;
100+ return ;
101+ }
102+ setStatus ( 'Opening browser...' ) ;
103+ await open ( 'http://localhost:5173' ) ;
104+ } ) ;
90105 }
91106 start ( ) ;
92107 } , [ ] ) ;
@@ -109,9 +124,19 @@ export default function Start({options}: Props) {
109124 ) ;
110125 }
111126
127+ if ( status === 'Opening browser...' ) {
128+ return (
129+ < Callout variant = "success" title = "Development Environment Started" >
130+ Browser opened at http://localhost:5173
131+ </ Callout >
132+ ) ;
133+ }
134+
112135 return (
113- < Callout variant = "success" title = "Development Environment Started" >
114- Browser opened at http://localhost:5173
136+ < Callout variant = "info" title = "Starting Development Environment" >
137+ < Text >
138+ < Spinner type = "dots" /> { status }
139+ </ Text >
115140 </ Callout >
116141 ) ;
117142}
0 commit comments