Add a one-line install script - #103
Conversation
curl -fsSL https://raw.githubusercontent.com/jonhadfield/sn-cli/main/install.sh | sh The README previously offered a multi-line case statement for picking the right archive, which is awkward to paste and easy to get wrong. install.sh resolves the latest tag from the release redirect rather than the API, which is rate limited for unauthenticated callers, picks the archive matching uname, verifies it against the published checksums before unpacking, and installs to /usr/local/bin. BIN_DIR and VERSION override the destination and the release. sudo is used only for the final install step, and only when the destination is not already writable, rather than running the whole script as root. On darwin it clears the quarantine flag, since these binaries are unsigned. Verified: install, piped from stdin as curl would, pinned VERSION, non-existent version, missing checksums, and a corrupted archive. Each failure exits non-zero and installs nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKSZwABnkoJTMcpUhFife3
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ +0.00% coverage variation (-1.00%) |
| Diff coverage | ✅ ∅ diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (b1da3fb) 9319 755 8.10% Head commit (991a002) 9319 (+0) 755 (+0) 8.10% (+0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#103) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
🟡 Changes recommended
The installer has confirmed portability/behavior bugs (BSD mktemp usage and incorrect sudo escalation for user-creatable BIN_DIR paths) that can break installs or create root-owned directories in user homes.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a single-file POSIX sh installer to streamline installing sn-cli from GitHub Releases, and updates the README to document the one-liner install path alongside the existing Homebrew/manual options.
Changes:
- Document a
curl | shone-liner install flow inREADME.md, includingBIN_DIRandVERSIONoverrides. - Add
install.shthat selects the correct release archive, verifies SHA-256 checksums, unpackssn, clears macOS quarantine, and installs toBIN_DIR.
File summaries
| File | Description |
|---|---|
| README.md | Adds one-line installer instructions and environment-variable overrides. |
| install.sh | Introduces a platform-aware, checksum-verifying installer script for sn-cli. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| base="https://github.com/$REPO/releases/download/$version" | ||
|
|
||
| tmp="$(mktemp -d)" |
| sudo="" | ||
| if [ ! -d "$BIN_DIR" ] || [ ! -w "$BIN_DIR" ]; then | ||
| if [ "$(id -u)" -ne 0 ]; then | ||
| command -v sudo >/dev/null 2>&1 || fail "$BIN_DIR is not writable and sudo is not available" | ||
| sudo="sudo" | ||
| fi | ||
| fi | ||
|
|
||
| $sudo mkdir -p "$BIN_DIR" | ||
| $sudo install -m 755 "$tmp/sn" "$BIN_DIR/sn" || fail "failed to install into $BIN_DIR" |
Codacy's markdownlint flags the curl commands as over 80 columns. Being a single pasteable line is the point of them, and the raw.githubusercontent URL cannot be shortened, so wrapping would break the feature rather than improve the file. Scoped to that block rather than disabling MD013 for the README, though note 20 lines here already exceed the limit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKSZwABnkoJTMcpUhFife3
curl -fsSL https://raw.githubusercontent.com/jonhadfield/sn-cli/main/install.sh | shThe README previously offered a multi-line
casestatement for picking the right archive, which is awkward to paste and easy to get wrong.What the script does
uname -s/uname -m, including the single universal darwin build and the Linux, FreeBSD and OpenBSD archives/usr/local/bin, overridable withBIN_DIR;VERSIONpins a releaseOn sudo
sudois used only for the final install step, and only when the destination is not already writable — rather than piping the whole script intosudo sh. So the download, checksum verification and unpacking all run as you, and root is used for oneinstallcommand.If you would rather not pipe to a shell at all,
install.shis in the repository to read first, and the homebrew and manual-download routes are unchanged.Verified
Each of these was actually run, not assumed:
0.5.1-b1da3fbcurl | shdoesVERSION=0.5.0🤖 Generated with Claude Code
https://claude.ai/code/session_01YKSZwABnkoJTMcpUhFife3