MCPcopy
hub / github.com/callstack/agent-device / handleAppDeployCommand

Function handleAppDeployCommand

src/daemon/handlers/session-deploy.ts:125–169  ·  view source on GitHub ↗
(params: {
  req: DaemonRequest;
  command: 'install' | 'reinstall';
  sessionName: string;
  sessionStore: SessionStore;
  deployOps: AppDeployOps;
})

Source from the content-addressed store, hash-verified

123};
124
125export 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
171function buildDeployMessage(result: DeployCommandResult): string {
172 return `Installed: ${result.appName ?? resolveDeployResultTarget(result)}`;

Callers 1

handleSessionCommandsFunction · 0.90

Calls 15

prepareUploadedArtifactFunction · 0.90
errorResponseFunction · 0.90
resolveCommandDeviceFunction · 0.90
requireCommandSupportedFunction · 0.90
isIosFamilyFunction · 0.90
withSuccessTextFunction · 0.90
recordSessionActionFunction · 0.90
cleanupUploadedArtifactFunction · 0.90
resolveDeployTargetFunction · 0.85
buildIosDeployResultFunction · 0.85
buildAndroidDeployResultFunction · 0.85

Tested by

no test coverage detected