#!/usr/bin/env bash # # diffweb installer — macOS and Linux. # curl -fsSL https://diffweb.pages.dev/install | bash # curl -fsSL https://diffweb.pages.dev/install | bash -s -- --uninstall # set -euo pipefail # Release tarball from `npm run build:version`. Update this once it is hosted. URL="${DIFFWEB_URL:-https://raw.githubusercontent.com/acharyarupak391/diffweb/main/bin/diffweb.tar.gz}" DIR="${DIFFWEB_HOME:-$HOME/.local/share/diffweb}" BIN="${DIFFWEB_BIN:-$HOME/.local/bin}" MIN_NODE=16 green=$'\033[32m'; red=$'\033[31m'; yellow=$'\033[33m'; dim=$'\033[2m'; reset=$'\033[0m' ok() { printf ' %sāœ“%s %s\n' "$green" "$reset" "$*"; } step() { printf ' %s→%s %s\n' "$dim" "$reset" "$*"; } die() { printf '\n %serror%s %s\n\n' "$red" "$reset" "$*" >&2; exit 1; } if [ "${1:-}" = "--uninstall" ]; then rm -f "$BIN/diffweb" rm -rf "$DIR" ok "diffweb removed" exit 0 fi command -v node >/dev/null 2>&1 || die "Node.js $MIN_NODE+ is required. Install it from https://nodejs.org" major="$(node -v | sed 's/^v//; s/\..*//')" [ "$major" -ge "$MIN_NODE" ] 2>/dev/null || die "Node.js $MIN_NODE+ is required, found $(node -v)" printf '\n %sdiffweb%s installer\n\n' "$dim" "$reset" step "downloading $URL" mkdir -p "$DIR" if command -v curl >/dev/null 2>&1; then curl -fsSL "$URL" | tar -xz -C "$DIR" --strip-components=1 || die "download failed" elif command -v wget >/dev/null 2>&1; then wget -qO- "$URL" | tar -xz -C "$DIR" --strip-components=1 || die "download failed" else die "neither curl nor wget is available" fi [ -f "$DIR/server.js" ] || die "the archive is missing server.js" step "installing launcher" mkdir -p "$BIN" cat > "$BIN/diffweb" <