Skip to content

Add luca update command to upgrade to the latest GitHub release#45

Merged
albertodebortoli merged 1 commit intomainfrom
update-command
Mar 24, 2026
Merged

Add luca update command to upgrade to the latest GitHub release#45
albertodebortoli merged 1 commit intomainfrom
update-command

Conversation

@albertodebortoli
Copy link
Copy Markdown
Member

@albertodebortoli albertodebortoli commented Mar 24, 2026

Summary

  • Adds a new luca update CLI command that fetches the latest release from GitHub and installs it if a newer version is available
  • Extracts a shared performUpdate(from:to:) method so both updateIfNeeded (pin-based) and updateToLatest (explicit update) reuse the same download-extract-install flow
  • Introduces LatestReleaseInfo Decodable model and latestVersionFetchFailed error case; injects DataDownloading into SelfUpdater for testability

Test plan

  • swift build passes (macOS)
  • swift test passes — 225 tests, all green
  • luca update when already on the latest version prints "✅ luca X.Y.Z is already up to date."
  • luca update when a newer release is available downloads and installs the new binary
  • luca update with no network prints a clear error

🤖 Generated with Claude Code

Implements a new `update` CLI command that fetches the latest release
from the GitHub API, compares it against the running version, and
installs the new binary if one is available. Reuses the existing
self-update install infrastructure via a shared `performUpdate(from:to:)`
method, keeping both the pinned-version and explicit-update flows in sync.

Key changes:
- New `UpdateCommand` (LucaCLI) wires up `luca update` via ArgumentParser
- `SelfUpdater.updateToLatest(currentVersion:)` fetches `/releases/latest`,
  normalises `v`-prefixed tags, and delegates to `performUpdate`
- `LatestReleaseInfo` is a minimal Decodable model for the GitHub API response
- `SelfUpdating` protocol gains `updateToLatest(currentVersion:)`
- `SelfUpdater` now accepts an injectable `DataDownloading` dependency
- New `latestVersionFetchFailed(Int)` error case with localised description
- Tests extended: `DataDownloaderMock` gains `.rawData` and `.error` cases;
  seven new `updateToLatest` test scenarios added

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@albertodebortoli albertodebortoli added this to the 0.12.0 milestone Mar 24, 2026
@albertodebortoli albertodebortoli added the feature New feature or enhancement label Mar 24, 2026
@albertodebortoli albertodebortoli merged commit df1ecd8 into main Mar 24, 2026
2 checks passed
@albertodebortoli albertodebortoli deleted the update-command branch March 24, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant