( mode: 'install' | 'reinstall' | 'installFromSource', app: string | undefined, source: BackendInstallSource, result: BackendInstallResult, )
| 267 | |
| 268 | // fallow-ignore-next-line complexity |
| 269 | function 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 | |
| 307 | function readOptionalString(record: Record<string, unknown>, field: string): string | undefined { |
| 308 | const value = record[field]; |
no test coverage detected