#!/usr/bin/env bash # ATHELGARD — one-line install. # # curl -fsSL https://www.bountywarz.com/install.sh | bash # # We ship a program, not a terminal. This runs inside the shell you already have # (Git Bash on Windows, Terminal on macOS, anything on Linux) and puts `athelgard` # on your PATH. Re-running it updates in place instead of cloning a second copy. # # Needs git and node 20+ (22 recommended). Override with ATHELGARD_REPO / ATHELGARD_DIR / # ATHELGARD_BRANCH. set -euo pipefail REPO="${ATHELGARD_REPO:-https://github.com/NyxSpecter4/bountywarz.git}" DIR="${ATHELGARD_DIR:-$HOME/bountywarz}" BRANCH="${ATHELGARD_BRANCH:-main}" say() { printf ' %s\n' "$*"; } die() { printf '\n install failed: %s\n\n' "$*" >&2; exit 1; } printf '\n ATHELGARD — installing into %s\n\n' "$DIR" command -v git >/dev/null 2>&1 || die "git is not installed. Install Git (which also gives you Git Bash on Windows), then re-run." command -v node >/dev/null 2>&1 || die "node is not installed. Install Node 22 from https://nodejs.org, then re-run." # package.json pins engines to 22.x because that is what the Vercel runtime uses, but the CLI # itself runs fine on anything from 20 up. Refuse only what genuinely will not work, and let npm's # EBADENGINE warning on 23+ pass without pretending it is an error. NODE_MAJOR="$(node -p "parseInt(process.versions.node)")" if [ "$NODE_MAJOR" -lt 20 ]; then die "node $(node -v) is too old — Athelgard needs 20 or newer (22 recommended)." fi if [ "$NODE_MAJOR" -ne 22 ]; then say "note: you're on node $(node -v); the repo targets 22.x, so npm will warn about EBADENGINE. Harmless." fi if [ -d "$DIR/.git" ]; then say "found an existing copy — updating it rather than cloning a second one" git -C "$DIR" fetch origin --quiet # Never clobber uncommitted work: if the tree is dirty, install against whatever # they have rather than moving their branch out from under them. `npm install` rewrites # package-lock.json on its own, so counting that as "their work" would freeze every # re-run at the version they first installed. if [ -n "$(git -C "$DIR" status --porcelain -- ':(exclude)package-lock.json')" ]; then say "you have uncommitted changes — leaving your branch alone" else git -C "$DIR" checkout "$BRANCH" --quiet git -C "$DIR" pull --ff-only --quiet fi else say "cloning $REPO" git clone --quiet "$REPO" "$DIR" git -C "$DIR" checkout "$BRANCH" --quiet fi cd "$DIR" say "installing dependencies (this takes a minute)" npm install --silent --no-audit --no-fund say "putting 'athelgard' on your PATH" if ! npm link --silent >/dev/null 2>&1; then say "npm link needed elevated permissions — falling back to a local install" npm install -g . --silent >/dev/null 2>&1 || die "could not put athelgard on your PATH. Run it directly instead: node $DIR/bin/athelgard-cli hunt" fi printf '\n' node bin/athelgard-cli hunt 2>/dev/null | head -24 || true # npm can link the command successfully into a global bin that is not on PATH — which surfaces # to a player as the same "athelgard: command not found" they ran the installer to fix. Say so, # with the line that fixes it, rather than claiming success. if command -v athelgard >/dev/null 2>&1; then printf '\n Installed. Start here:\n\n athelgard\n\n She will introduce herself, take your callsign and open your first range.\n' else NPM_BIN="$(npm prefix -g 2>/dev/null)/bin" printf '\n Installed, but %s is not on your PATH, so the bare command will not resolve yet.\n' "$NPM_BIN" printf ' Add it once:\n\n echo '"'"'export PATH="%s:$PATH"'"'"' >> ~/.bashrc && source ~/.bashrc\n' "$NPM_BIN" printf '\n Or skip PATH entirely and run it directly:\n\n node %s/bin/athelgard-cli\n' "$DIR" fi printf '\n The whole system is explained at https://www.bountywarz.com/terminal\n\n'