( params: LaunchAppSimParams, executor: CommandExecutor, launcher: SimulatorLauncher = launchSimulatorAppWithLogging, )
| 64 | export type SimulatorLauncher = typeof launchSimulatorAppWithLogging; |
| 65 | |
| 66 | export async function launch_app_simLogic( |
| 67 | params: LaunchAppSimParams, |
| 68 | executor: CommandExecutor, |
| 69 | launcher: SimulatorLauncher = launchSimulatorAppWithLogging, |
| 70 | ): Promise<void> { |
| 71 | const ctx = getHandlerContext(); |
| 72 | const simulatorResult = await determineSimulatorUuid(params, executor); |
| 73 | if (simulatorResult.error || !simulatorResult.uuid) { |
| 74 | const result = buildLaunchFailure( |
| 75 | { bundleId: params.bundleId }, |
| 76 | `Failed to resolve simulator: ${simulatorResult.error ?? 'No simulator UUID returned'}`, |
| 77 | { target: 'simulator' }, |
| 78 | ); |
| 79 | setLaunchResultStructuredOutput(ctx, result); |
| 80 | log('error', `Error during launch app in simulator operation: ${result.error}`); |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | if (simulatorResult.warning) { |
| 85 | log('warn', simulatorResult.warning); |
| 86 | } |
| 87 | |
| 88 | const resolvedParams: ResolvedLaunchAppSimParams = { |
| 89 | ...params, |
| 90 | simulatorId: simulatorResult.uuid, |
| 91 | }; |
| 92 | const executeLaunchAppSim = createLaunchAppSimExecutor(executor, launcher); |
| 93 | const result = await executeLaunchAppSim(resolvedParams); |
| 94 | |
| 95 | setLaunchResultStructuredOutput(ctx, result); |
| 96 | |
| 97 | if (result.didError) { |
| 98 | log( |
| 99 | 'error', |
| 100 | `Error during launch app in simulator operation: ${result.error ?? 'Unknown error'}`, |
| 101 | ); |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | ctx.nextStepParams = { |
| 106 | open_sim: {}, |
| 107 | stop_app_sim: { simulatorId: resolvedParams.simulatorId, bundleId: params.bundleId }, |
| 108 | }; |
| 109 | } |
| 110 | |
| 111 | function buildSuccessArtifacts( |
| 112 | params: ResolvedLaunchAppSimParams, |
no test coverage detected