feat(installer): fetch resq-cli binary + per-shell completions (Stage 2)#16
Conversation
Until now, install.sh cloned the target repo and set up the nix shell but never actually installed the resq binary that the whole toolchain is named after. Users had to remember `cargo install resq-cli` or `gh release download` separately. Stage 2 closes that gap. After post_clone_setup, the installer now: - Detects platform (Linux x86_64/aarch64, macOS x86_64/arm64) and maps to the right Rust target triple. - Queries `gh release list` for the latest `resq-cli-v*` tag in resq-software/crates (Windows is skipped; install.ps1 will handle it separately later). - Downloads the matching tar.gz and SHA256SUMS via `gh release download`. - Verifies the checksum with `sha256sum -c` — a failed checksum aborts the install with a warning, not silently. - Drops the verified binary at $RESQ_BIN_DIR/resq (default ~/.local/bin/resq, mode 0755). - Detects the user's $SHELL (bash/zsh/fish) and writes the generated completion script to the conventional user-local path. Other shells get a hint to run `resq completions <shell>` manually. - Warns if ~/.local/bin isn't already on $PATH. Idempotent: if `resq --version` already matches the latest release tag, we skip the download and just refresh completions. Opt out entirely with `SKIP_RESQ_CLI=1`. Also improved post_clone_setup's nix develop step: the previous "a few minutes" message was too vague to be useful. Now we state the expected download size (500 MB–2 GB) and time (2–5 min) up front, and report the actual elapsed seconds when it succeeds. Still no real-time progress — that would need tee-ing the nix log — but expectation-setting is free.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe Changes
Sequence DiagramsequenceDiagram
participant Main as main()
participant InstallCLI as install_resq_cli()
participant GH as GitHub API (gh)
participant SHA as SHA256 Verify
participant Archive as Extract & Locate
participant Completions as install_resq_completions()
participant Shell as Shell Completion Files
Main->>InstallCLI: call install_resq_cli
InstallCLI->>InstallCLI: detect OS/arch triple
InstallCLI->>GH: gh release list (query resq-cli releases)
GH-->>InstallCLI: return latest release tag
InstallCLI->>InstallCLI: check existing resq binary version
alt Binary matches expected version
InstallCLI-->>Main: return (idempotent skip)
else Binary missing or outdated
InstallCLI->>GH: download resq-cli-{tag}-{triple}.tar.gz
InstallCLI->>GH: download SHA256SUMS
GH-->>InstallCLI: provide assets
InstallCLI->>SHA: verify SHA256 of downloaded archive
alt Verification passes
InstallCLI->>Archive: extract tar.gz
Archive-->>InstallCLI: locate resq binary
InstallCLI->>InstallCLI: install to RESQ_BIN_DIR
InstallCLI->>Completions: call install_resq_completions
Completions->>Completions: detect current shell (bash/zsh/fish)
Completions->>Shell: generate and install completions
Shell-->>Completions: return
Completions-->>InstallCLI: return
else Verification fails
InstallCLI-->>Main: warn and exit
end
end
InstallCLI-->>Main: return
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request enhances the install.sh script by adding automated installation of the resq CLI binary and its shell completions. It also improves the Nix environment setup by providing more detailed progress information and timing. Feedback focuses on improving the portability of the checksum verification for macOS and making the binary extraction process more robust against archive structure changes.
Addresses gemini-code-assist review on PR #16. - sha256sum is GNU-only; macOS ships `shasum -a 256` instead. Use sha256sum when available, fall back to shasum. Also drop the `--quiet` flag (GNU-only) — stdout already redirects to /dev/null. - Stop relying on the hardcoded `resq-cli-<tag>-<triple>/resq` staging-dir layout. `find` the extracted binary instead; matches the pattern already used in scripts/install-resq.sh and stays resilient if release.yml ever changes the archive's inner dir name.
|
Resolved both gemini review points:
|
PowerShell parity for install.sh's Stage 2 work (#16). Before this, install.ps1 cloned the repo and set up the nix/WSL environment but never installed the resq binary — Windows users had to remember `gh release download` by hand. Adds two new functions: - Install-ResqCli: maps $IsWindows / $IsMacOS / $IsLinux + $Arch to the right Rust target triple, picks .zip on Windows or .tar.gz on Unix, downloads the archive + SHA256SUMS via `gh release download`, verifies the checksum with Get-FileHash, extracts (Expand-Archive for zip, tar.exe for tar.gz — both native on Win10+ and all Unix hosts), locates the binary via Get-ChildItem -Recurse (matches install.sh's `find` pattern), and installs to $env:RESQ_BIN_DIR (defaults: %LOCALAPPDATA%\Programs\resq\bin on Windows, ~/.local/bin on Unix). Chmod 0755 on Unix, Copy-Item on Windows. Idempotent via `resq --version` match; skippable with $env:SKIP_RESQ_CLI=1. PATH hint if the bin dir isn't on PATH. - Install-ResqCompletions: emits `resq completions powershell` to $(Split-Path $PROFILE -Parent)\Completions\resq.ps1 and tells the user to source it from $PROFILE if they haven't already. Also aligns Initialize-Repo's nix-develop progress messaging with the sh version: set expectations for download size and time upfront, and print actual elapsed seconds when the build succeeds. Wiring: Main now calls Install-ResqCli between Initialize-Repo and Show-RepoInfo, matching install.sh's main().
…#17) * feat(installer): install.ps1 Stage 2 mirror — binary + PS completions PowerShell parity for install.sh's Stage 2 work (#16). Before this, install.ps1 cloned the repo and set up the nix/WSL environment but never installed the resq binary — Windows users had to remember `gh release download` by hand. Adds two new functions: - Install-ResqCli: maps $IsWindows / $IsMacOS / $IsLinux + $Arch to the right Rust target triple, picks .zip on Windows or .tar.gz on Unix, downloads the archive + SHA256SUMS via `gh release download`, verifies the checksum with Get-FileHash, extracts (Expand-Archive for zip, tar.exe for tar.gz — both native on Win10+ and all Unix hosts), locates the binary via Get-ChildItem -Recurse (matches install.sh's `find` pattern), and installs to $env:RESQ_BIN_DIR (defaults: %LOCALAPPDATA%\Programs\resq\bin on Windows, ~/.local/bin on Unix). Chmod 0755 on Unix, Copy-Item on Windows. Idempotent via `resq --version` match; skippable with $env:SKIP_RESQ_CLI=1. PATH hint if the bin dir isn't on PATH. - Install-ResqCompletions: emits `resq completions powershell` to $(Split-Path $PROFILE -Parent)\Completions\resq.ps1 and tells the user to source it from $PROFILE if they haven't already. Also aligns Initialize-Repo's nix-develop progress messaging with the sh version: set expectations for download size and time upfront, and print actual elapsed seconds when the build succeeds. Wiring: Main now calls Install-ResqCli between Initialize-Repo and Show-RepoInfo, matching install.sh's main(). * fix(installer): resolve PR#17 review — Windows arch guard + native exit check Addresses gemini-code-assist review: - Install-ResqCli: the Windows branch assumed x86_64 unconditionally. On 32-bit Windows ($script:Arch = 'x86') we'd have downloaded the x86_64 asset and failed later at checksum-miss / run time. Bail up front with a clear warning when the arch isn't x64. Matches the validation pattern already used for macOS / Linux. - Install-ResqCompletions: `& \$BinPath completions powershell` is native exec, which doesn't throw on non-zero exit (even with ErrorActionPreference=Stop) — so a corrupt or incompatible binary could silently leave an empty completions file on disk. Check \$LASTEXITCODE explicitly and throw; the catch now also deletes the partial file and surfaces the underlying error in the warning.
Summary
Stage 2 of the CLI ergonomics work. After this PR,
sh install.shfinishes the job — you get the `resq` binary on disk and its shell completions wired up, not just a cloned repo.What the installer now does (in order):
$OS / $ARCH→ Rust target triple (Linux x86_64/aarch64, macOS x86_64/arm64).gh release list→ find the latestresq-cli-v*tag inresq-software/crates.gh release downloadthe matching.tar.gz+SHA256SUMS.sha256sum -c— failed checksum aborts with a warning, never silently installs an unverified binary.install -m 0755 → $RESQ_BIN_DIR/resq(default~/.local/bin/resq).$SHELL, generate completions viaresq completions <shell>, write to the conventional user-local path:~/.local/share/bash-completion/completions/resq~/.local/share/zsh/site-functions/_resq(+ zshfpathhint)~/.config/fish/completions/resq.fishresq completions <shell>manually.~/.local/binisn't already in$PATH.Idempotent: if `resq --version` already matches the latest release tag, we skip download and refresh completions. Opt out entirely with
SKIP_RESQ_CLI=1. Custom install prefix viaRESQ_BIN_DIR=/opt/resq/bin.Also improved
post_clone_setup's silent `nix develop` — Stage 1 audit flagged the 2–5 minute freeze with only a vague "a few minutes" banner. Now we state the expected download size (500 MB – 2 GB) and time (2–5 min) up front, and print actual elapsed seconds on success.Test plan
sh -n install.sh,bash -n install.sh,shellcheck install.sh— all cleangh release list --repo resq-software/cratesreturnsresq-cli-v0.2.6and release has all 5 expected assets (4 tar.gz +SHA256SUMS)resq --versionon PATH, tab-completion works in the user's shellSKIP_RESQ_CLI=1 sh install.sh— binary install skipped, rest of the flow unchangedresq X.Y.Z already installedand refreshes completionsNot in this PR (Stage 3 / follow-ups)
install.ps1mirror (separate follow-up — needs Expand-Archive + Invoke-WebRequest + shell-aware completion paths on Windows).gh api /orgs/resq-software/repos— deferred; the 8-entry hardcoded menu is a small surface.resq scan/resq tuigroups) still pending.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores