MCPcopy Index your code
hub / github.com/callstack/agent-device / formatInstallResult

Function formatInstallResult

src/commands/management/runtime/admin.ts:269–305  ·  view source on GitHub ↗
(
  mode: 'install' | 'reinstall' | 'installFromSource',
  app: string | undefined,
  source: BackendInstallSource,
  result: BackendInstallResult,
)

Source from the content-addressed store, hash-verified

267
268// fallow-ignore-next-line complexity
269function formatInstallResult(
270 mode: 'install' | 'reinstall' | 'installFromSource',
271 app: string | undefined,
272 source: BackendInstallSource,
273 result: BackendInstallResult,
274): AdminInstallCommandResult {
275 const backendResult = toBackendResult(result);
276 const kind =
277 mode === 'reinstall'
278 ? 'appReinstalled'
279 : mode === 'installFromSource'
280 ? 'appInstalledFromSource'
281 : 'appInstalled';
282 const appName = readOptionalString(result, 'appName');
283 const appId = readOptionalString(result, 'appId');
284 const bundleId = readOptionalString(result, 'bundleId');
285 const packageName = readOptionalString(result, 'packageName');
286 const launchTarget = readOptionalString(result, 'launchTarget');
287 const installablePath = readOptionalString(result, 'installablePath');
288 const archivePath = readOptionalString(result, 'archivePath');
289 return {
290 kind,
291 ...(app ? { app } : {}),
292 source,
293 ...(appId ? { appId } : {}),
294 ...(appName ? { appName } : {}),
295 ...(bundleId ? { bundleId } : {}),
296 ...(packageName ? { packageName } : {}),
297 ...(launchTarget ? { launchTarget } : {}),
298 ...(installablePath ? { installablePath } : {}),
299 ...(archivePath ? { archivePath } : {}),
300 ...(backendResult ? { backendResult } : {}),
301 ...successText(
302 `${mode === 'reinstall' ? 'Reinstalled' : 'Installed'}: ${appName ?? launchTarget ?? app ?? formatSource(source)}`,
303 ),
304 };
305}
306
307function readOptionalString(record: Record<string, unknown>, field: string): string | undefined {
308 const value = record[field];

Callers 1

runInstallCommandFunction · 0.85

Calls 4

toBackendResultFunction · 0.90
successTextFunction · 0.90
formatSourceFunction · 0.85
readOptionalStringFunction · 0.70

Tested by

no test coverage detected