feat(cli): add installation-aware update command#263
Conversation
Detect Go and WinGet installations, checksum and atomically replace standalone releases, and use a versioned junction layout for safe Windows updates. Closes #262
📝 WalkthroughWalkthroughAdds an installation-aware ChangesInstallation-aware update command
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant UpdateCommand
participant Updater
participant GitHubReleases
participant Filesystem
User->>UpdateCommand: run vizb update
UpdateCommand->>Updater: Run with CLI streams
Updater->>Filesystem: detect installation and executable
Updater->>GitHubReleases: resolve release and download assets
GitHubReleases-->>Updater: checksums.txt and archive
Updater->>Filesystem: verify, extract, and stage binary
Updater->>Filesystem: atomically replace executable
Updater-->>UpdateCommand: status or error
UpdateCommand-->>User: output
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
internal/updater/updater.go (1)
151-154: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStore the updater’s temp paths in
shared.TempFiles.prepareCandidate,replaceExecutable, andrunWindowsInstallerstill create their own workspace/staging/script files withos.MkdirTempandos.CreateTemp; adding those paths to the shared manager would align this flow with the rest of the app’s temp-file cleanup.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/updater/updater.go` around lines 151 - 154, Update prepareCandidate, replaceExecutable, and runWindowsInstaller to register every path created by os.MkdirTemp or os.CreateTemp with the shared shared.TempFiles manager. Preserve the existing cleanup and error-handling behavior while ensuring all updater workspace, staging, and script files are tracked for centralized cleanup.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/cli.yml:
- Around line 31-34: Harden the windows-installer job by adding a
least-privilege permissions block with no write access and configuring its
actions/checkout step to disable persisted credentials. Update only the
windows-installer job and its checkout configuration.
In `@internal/updater/install.ps1`:
- Around line 205-220: Add a one-time TLS 1.2 security protocol assignment near
the top of the PowerShell script, before Get-LatestVersion and the
archive/checksum download logic execute. Ensure all GitHub WebRequest operations
use this pinned protocol rather than the Windows PowerShell 5.1 host default.
---
Nitpick comments:
In `@internal/updater/updater.go`:
- Around line 151-154: Update prepareCandidate, replaceExecutable, and
runWindowsInstaller to register every path created by os.MkdirTemp or
os.CreateTemp with the shared shared.TempFiles manager. Preserve the existing
cleanup and error-handling behavior while ensuring all updater workspace,
staging, and script files are tracked for centralized cleanup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 74a08caa-cb87-45c8-b31d-46a36d46a084
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (19)
.github/workflows/cli.yml.goreleaser.ymlcmd/testing.gocmd/update.gocmd/update_test.godocs/astro.config.mjsdocs/public/install.ps1docs/public/install.ps1docs/src/content/docs/commands/update.mdxdocs/src/content/docs/installation.mdxgo.modinternal/updater/archive.gointernal/updater/download.gointernal/updater/install.ps1internal/updater/installation.gointernal/updater/release.gointernal/updater/updater.gointernal/updater/updater_test.goversion/version.go
Pin the Windows validation job to read-only checkout permissions, enable TLS 1.2 for Windows PowerShell, and register updater workspaces with centralized temporary-path cleanup.
Keep standalone self-update native to Linux and macOS. Windows standalone builds now print the existing PowerShell reinstall command, while WinGet and Go installations remain delegated to their package managers.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/updater/updater_test.go`:
- Around line 395-397: Update the test around extractBinary to create the
archive fixture and extraction workspace through shared.TempFiles instead of
s.T().TempDir(). Preserve the temporary-file manager’s cleanup registration
across all exit paths while keeping the existing missingArchive and extraction
assertions unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 81bd7f45-9f99-4f4c-888c-a7c1b2d5d38e
📒 Files selected for processing (7)
.github/workflows/cli.ymldocs/src/content/docs/commands/update.mdxdocs/src/content/docs/installation.mdxinternal/updater/archive.gointernal/updater/release.gointernal/updater/updater.gointernal/updater/updater_test.go
💤 Files with no reviewable changes (2)
- .github/workflows/cli.yml
- internal/updater/archive.go
🚧 Files skipped from review as they are similar to previous changes (2)
- docs/src/content/docs/installation.mdx
- internal/updater/release.go
| missingPath := filepath.Join(s.T().TempDir(), "release.tar.gz") | ||
| s.Require().NoError(os.WriteFile(missingPath, missingArchive, 0o600)) | ||
| err := extractBinary(missingPath, ".tar.gz", filepath.Join(s.T().TempDir(), "vizb"), "vizb") |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use shared.TempFiles for the archive fixture.
This test bypasses the repository-required temporary-file manager by using s.T().TempDir() directly. Allocate the temporary workspace through shared.TempFiles and preserve its cleanup registration.
As per coding guidelines, **/*.go must manage temporary files through shared.TempFiles and preserve cleanup on all exit paths.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/updater/updater_test.go` around lines 395 - 397, Update the test
around extractBinary to create the archive fixture and extraction workspace
through shared.TempFiles instead of s.T().TempDir(). Preserve the temporary-file
manager’s cleanup registration across all exit paths while keeping the existing
missingArchive and extraction assertions unchanged.
Source: Coding guidelines
Summary
vizb updatecommand that delegates Go and WinGet installations and refuses unidentified buildsstandaloneand document update behavior without adding a local receipt or remote manifestInstallation behavior
vizb updatebehaviorirm https://vizb.goptics.org/install.ps1 | iex; no network request or binary changego install github.com/goptics/vizb@latestwinget upgrade --id goptics.vizb --exactThe existing
install.shandinstall.ps1files remain the initial-install entry points. No installer script is embedded in the Vizb binary.Validation
task format:check— Go and UI formatting passtask test— all Go tests and 503 UI tests passtask lint— Go lint and UI typecheck passtask build:docs— documentation build passestask release:check— GoReleaser configuration is validCloses #262
Summary by CodeRabbit
vizb updatecommand for safely updating standalone installations.