Repository navigation
feat(install): unified install.sh that prefers Homebrew #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/bin/sh | ||
| # install.sh — one installer for Linux and macOS. | ||
| # | ||
| # If Homebrew is on the machine, install (or upgrade) through the tap so the | ||
| # binary is managed by brew and `hotdata manage upgrade` follows suit. | ||
| # Otherwise fall back to the cargo-dist shell installer, which drops a | ||
| # prebuilt binary into ~/.hotdata/cli. | ||
| # | ||
| # Usage: | ||
| # curl --proto '=https' --tlsv1.2 -LsSf https://github.com/hotdata-dev/hotdata-cli/releases/latest/download/install.sh | sh | ||
| # | ||
| # After the binary lands, the agent skill is installed too (`hotdata manage | ||
| # skills install`): it goes to ~/.agents/skills and is linked into ~/.claude | ||
| # when that directory exists, so Claude Code picks it up with no extra step. | ||
| # | ||
| # Environment: | ||
| # HOTDATA_NO_BREW=1 skip Homebrew even when it is installed | ||
| # HOTDATA_NO_SKILLS=1 install the binary only, skip the agent skill | ||
|
|
||
| set -eu | ||
|
|
||
| FORMULA="hotdata-dev/tap/cli" | ||
| REPO="https://github.com/hotdata-dev/hotdata-cli" | ||
| DIST_INSTALLER="$REPO/releases/latest/download/hotdata-cli-installer.sh" | ||
|
|
||
| find_brew() { | ||
| if command -v brew >/dev/null 2>&1; then | ||
| command -v brew | ||
| return 0 | ||
| fi | ||
| for candidate in /opt/homebrew/bin/brew /usr/local/bin/brew /home/linuxbrew/.linuxbrew/bin/brew; do | ||
| if [ -x "$candidate" ]; then | ||
| echo "$candidate" | ||
| return 0 | ||
| fi | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| # Best-effort: a skill failure must not fail the install. | ||
| install_skills() { | ||
| bin="$1" | ||
| [ "${HOTDATA_NO_SKILLS:-}" = "1" ] && return 0 | ||
| if [ ! -x "$bin" ]; then | ||
| echo "warning: $bin not found; run 'hotdata manage skills install' to add the agent skill" >&2 | ||
| return 0 | ||
| fi | ||
| echo "Installing the hotdata agent skill" >&2 | ||
| "$bin" manage skills install --no-input \ | ||
| || echo "warning: skill install failed; run 'hotdata manage skills install' later" >&2 | ||
| } | ||
|
|
||
| BREW="" | ||
| if [ "${HOTDATA_NO_BREW:-}" != "1" ]; then | ||
| BREW="$(find_brew || true)" | ||
| fi | ||
|
|
||
| if [ -n "$BREW" ]; then | ||
| echo "Homebrew found at $BREW; installing $FORMULA" >&2 | ||
| if "$BREW" list --formula "$FORMULA" >/dev/null 2>&1; then | ||
| "$BREW" upgrade "$FORMULA" | ||
| else | ||
| "$BREW" install "$FORMULA" | ||
| fi | ||
| HOTDATA_BIN="$("$BREW" --prefix)/bin/hotdata" | ||
| echo "Installed $HOTDATA_BIN" >&2 | ||
| install_skills "$HOTDATA_BIN" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Homebrew not found; installing a prebuilt binary to ~/.hotdata/cli" >&2 | ||
| # Download fully before running: plain sh has no pipefail, so a failed | ||
| # download piped into sh would otherwise "succeed" with nothing installed. | ||
| TMP="$(mktemp)" | ||
| trap 'rm -f "$TMP"' EXIT | ||
| if command -v curl >/dev/null 2>&1; then | ||
| curl --proto '=https' --tlsv1.2 -LsSf "$DIST_INSTALLER" -o "$TMP" | ||
| elif command -v wget >/dev/null 2>&1; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Download the dist installer fully before running it, so a failed download fails the script (not blocking). POSIX Fix: capture the script first, for example |
||
| wget -qO "$TMP" "$DIST_INSTALLER" | ||
| else | ||
| echo "error: need curl or wget to download the installer" >&2 | ||
| exit 1 | ||
| fi | ||
| sh "$TMP" | ||
| install_skills "$HOME/.hotdata/cli/hotdata" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Check the fully-qualified formula instead of the short name
cli(not blocking).The short name
climatches any installed formula namedclifrom any tap. A user with a differentcliformula takes theupgradebranch.brew upgrade hotdata-dev/tap/clithen fails with "not installed", andset -eaborts the script.