44 */
55
66import { createLogger } from '../assets/utils/logger.js'
7- import type { UserConfig , HooksInterface , ResolvedConfig } from '../types.js'
7+ import type { UserConfig , HooksInterface , ResolvedConfig , LaunchOutput } from '../types.js'
88import { resolveConfig , resolveHooks } from '../index.js'
99
1010const logger = createLogger ( 'launch-flow' )
@@ -31,7 +31,7 @@ export interface LaunchStrategy {
3131 /**
3232 * Launch the application
3333 */
34- launch ( context : LaunchContext ) : Promise < void >
34+ launch ( context : LaunchContext ) : Promise < LaunchOutput >
3535
3636 /**
3737 * Cleanup on shutdown
@@ -48,7 +48,6 @@ export interface LaunchContext {
4848 target : string
4949 root : string
5050 outDir : string
51- dev : boolean
5251 port ?: number
5352 host ?: string
5453}
@@ -89,12 +88,11 @@ export class LaunchFlow {
8988 config : UserConfig = { } ,
9089 options : {
9190 hooks ?: HooksInterface
92- dev ?: boolean
9391 port ?: number
9492 host ?: string
9593 } = { }
96- ) : Promise < void > {
97- const { hooks : optHooks , dev = true , port, host } = options
94+ ) : Promise < LaunchOutput > {
95+ const { hooks : optHooks , port, host } = options
9896
9997 // Resolve hooks
10098 const hooks = ( config . hooks = await resolveHooks ( config . hooks , optHooks ) )
@@ -104,10 +102,10 @@ export class LaunchFlow {
104102 const resolvedConfig = await resolveConfig ( config , { build : false } )
105103 const { root, target } = resolvedConfig
106104
107- this . logger . info ( 'Starting launch' , { target, dev , port, host } )
105+ this . logger . info ( 'Starting launch' , { target, port, host } )
108106
109107 // Emit launch start event
110- this . logger . debug ( 'Emitting launch:start' , { config : resolvedConfig . name , target, dev } )
108+ this . logger . debug ( 'Emitting launch:start' , { config : resolvedConfig . name , target } )
111109 hooks . emit ( { type : 'launch:start' , config : resolvedConfig } )
112110
113111 // Get the appropriate launch strategy
@@ -125,15 +123,14 @@ export class LaunchFlow {
125123 target,
126124 root,
127125 outDir : '' , // Will be set by strategy
128- dev,
129126 port,
130127 host,
131128 }
132129
133130 // Execute launch flow
134- await this . executeLaunchFlow ( context , strategy )
135-
131+ const result = await this . executeLaunchFlow ( context , strategy )
136132 this . logger . info ( 'Launch completed successfully' )
133+ return result
137134 } catch ( error ) {
138135 this . logger . debug ( 'Emitting launch:error' , { error : ( error as Error ) . message } )
139136 hooks . emit ( {
@@ -152,17 +149,16 @@ export class LaunchFlow {
152149 private async executeLaunchFlow (
153150 context : LaunchContext ,
154151 strategy : LaunchStrategy
155- ) : Promise < void > {
152+ ) : Promise < LaunchOutput > {
156153 try {
157154 // Step 1: Prepare launch environment
158155 await strategy . prepare ( context )
159156
160157 // Step 2: Launch the application
161- await strategy . launch ( context )
162-
163- // Emit launch complete event
158+ const result = await strategy . launch ( context )
164159 this . logger . debug ( 'Emitting launch:complete' , { target : context . target } )
165160 context . hooks . emit ( { type : 'launch:complete' } )
161+ return result
166162 } catch ( error ) {
167163 // Cleanup on error
168164 await strategy . cleanup ( context ) . catch ( ( cleanupError ) => {
@@ -185,7 +181,7 @@ export abstract class BaseLaunchStrategy implements LaunchStrategy {
185181
186182 abstract prepare ( context : LaunchContext ) : Promise < void >
187183
188- abstract launch ( context : LaunchContext ) : Promise < void >
184+ abstract launch ( context : LaunchContext ) : Promise < LaunchOutput >
189185
190186 async cleanup ( context : LaunchContext ) : Promise < void > {
191187 // Default: no cleanup
0 commit comments