(params: {
req: DaemonRequest;
command: 'install' | 'reinstall';
sessionName: string;
sessionStore: SessionStore;
deployOps: AppDeployOps;
})
| 123 | }; |
| 124 | |
| 125 | export async function handleAppDeployCommand(params: { |
| 126 | req: DaemonRequest; |
| 127 | command: 'install' | 'reinstall'; |
| 128 | sessionName: string; |
| 129 | sessionStore: SessionStore; |
| 130 | deployOps: AppDeployOps; |
| 131 | }): Promise<DaemonResponse> { |
| 132 | const { req, command, sessionName, sessionStore, deployOps } = params; |
| 133 | const session = sessionStore.get(sessionName); |
| 134 | const flags = req.flags ?? {}; |
| 135 | const guard = requireSessionOrExplicitSelector(command, session, flags); |
| 136 | if (guard) return guard; |
| 137 | const deployTarget = resolveDeployTarget(command, req.positionals ?? []); |
| 138 | if (!deployTarget.ok) return deployTarget.response; |
| 139 | const { app, appPathInput } = deployTarget; |
| 140 | const uploadedArtifactId = req.meta?.uploadedArtifactId; |
| 141 | |
| 142 | try { |
| 143 | const appPath = uploadedArtifactId |
| 144 | ? prepareUploadedArtifact(uploadedArtifactId, req.meta?.tenantId) |
| 145 | : SessionStore.expandHome(appPathInput); |
| 146 | if (!fs.existsSync(appPath)) { |
| 147 | return errorResponse('INVALID_ARGS', `App binary not found: ${appPath}`); |
| 148 | } |
| 149 | const device = await resolveCommandDevice({ |
| 150 | session, |
| 151 | flags, |
| 152 | ensureReady: false, |
| 153 | }); |
| 154 | const unsupported = requireCommandSupported(command, device); |
| 155 | if (unsupported) return unsupported; |
| 156 | |
| 157 | const result = isIosFamily(device) |
| 158 | ? buildIosDeployResult(app, appPath, await deployOps.ios(device, app, appPath)) |
| 159 | : buildAndroidDeployResult(app, appPath, await deployOps.android(device, app, appPath)); |
| 160 | |
| 161 | const data = withSuccessText(result, buildDeployMessage(result)); |
| 162 | recordSessionAction(sessionStore, session, req, command, data); |
| 163 | return { ok: true, data }; |
| 164 | } finally { |
| 165 | if (uploadedArtifactId) { |
| 166 | cleanupUploadedArtifact(uploadedArtifactId); |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | function buildDeployMessage(result: DeployCommandResult): string { |
| 172 | return `Installed: ${result.appName ?? resolveDeployResultTarget(result)}`; |
no test coverage detected