( options: UpgradeOptions, deps?: Partial<UpgradeDependencies>, )
| 464 | // --- Main command logic --- |
| 465 | |
| 466 | export async function runUpgradeCommand( |
| 467 | options: UpgradeOptions, |
| 468 | deps?: Partial<UpgradeDependencies>, |
| 469 | ): Promise<number> { |
| 470 | const d = resolveDependencies(deps); |
| 471 | const isTTY = d.isInteractive(); |
| 472 | |
| 473 | if (isTTY) { |
| 474 | clack.intro('XcodeBuildMCP Upgrade'); |
| 475 | } |
| 476 | |
| 477 | const installMethod = d.detectInstallMethod(); |
| 478 | |
| 479 | let latestRelease: LatestRelease; |
| 480 | try { |
| 481 | if (isTTY) { |
| 482 | const s = clack.spinner(); |
| 483 | s.start('Checking for updates...'); |
| 484 | try { |
| 485 | latestRelease = await d.fetchLatestRelease(); |
| 486 | s.stop('Update check complete.'); |
| 487 | } catch (error) { |
| 488 | s.stop('Update check failed.'); |
| 489 | throw error; |
| 490 | } |
| 491 | } else { |
| 492 | latestRelease = await d.fetchLatestRelease(); |
| 493 | } |
| 494 | } catch (error) { |
| 495 | const reason = error instanceof Error ? error.message : String(error); |
| 496 | |
| 497 | if (isTTY) { |
| 498 | clack.log.error(reason); |
| 499 | clack.log.info(`Current version: ${d.currentVersion}`); |
| 500 | clack.log.info(`Install method: ${installMethod.kind}`); |
| 501 | if (isAutoUpgradeMethod(installMethod)) { |
| 502 | clack.log.info(`Manual upgrade: ${installMethod.manualCommand}`); |
| 503 | } |
| 504 | clack.outro(''); |
| 505 | } else { |
| 506 | writeError(reason); |
| 507 | writeLine(`Current version: ${d.currentVersion}`); |
| 508 | writeLine(`Install method: ${installMethod.kind}`); |
| 509 | if (isAutoUpgradeMethod(installMethod)) { |
| 510 | writeLine(`Manual upgrade: ${installMethod.manualCommand}`); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | return 1; |
| 515 | } |
| 516 | |
| 517 | const parsedCurrent = parseVersion(d.currentVersion); |
| 518 | const parsedLatest = parseVersion(latestRelease.version); |
| 519 | |
| 520 | if (!parsedCurrent || !parsedLatest) { |
| 521 | const msg = `Cannot compare versions: current=${d.currentVersion}, latest=${latestRelease.version}`; |
| 522 | if (isTTY) { |
| 523 | clack.log.error(msg); |
no test coverage detected