#!/bin/sh # InfiniteCLI installer for macOS and Linux. # # curl -fsSL https://nexus-applications.com/cli/install.sh | sh # # Downloads the release tarball, checks its SHA-256, and installs it with # `npm install -g`. Needs Node.js 20+ and npm. Environment overrides: # INFINITECLI_VERSION install another published version (no checksum pin) # INFINITECLI_BASE_URL download from another location # This file is a template: scripts/release.mjs fills in the __PLACEHOLDERS__. set -eu BUILT_VERSION="0.1.1" BUILT_SHA256="134a18f7b91a8315d1e15b6c9a57fc87d3cb1d6270e04d9119945dbb76bdefe4" VERSION="${INFINITECLI_VERSION:-$BUILT_VERSION}" BASE_URL="${INFINITECLI_BASE_URL:-https://nexus-applications.com/cli}" say() { printf '%s\n' "infinitecli: $*"; } fail() { printf '%s\n' "infinitecli: $*" >&2; exit 1; } command -v node >/dev/null 2>&1 || fail "Node.js 20 or newer is required: https://nodejs.org" command -v npm >/dev/null 2>&1 || fail "npm is required (it ships with Node.js)." major=$(node -p 'process.versions.node.split(".")[0]') [ "$major" -ge 20 ] || fail "Node.js 20 or newer is required; found $(node -v)." tmp=$(mktemp -d 2>/dev/null || mktemp -d -t infinitecli) trap 'rm -rf "$tmp"' EXIT INT TERM file="$tmp/infinitecli-$VERSION.tgz" url="$BASE_URL/infinitecli-$VERSION.tgz" say "downloading $url" if command -v curl >/dev/null 2>&1; then curl -fsSL "$url" -o "$file" || fail "download failed: $url" elif command -v wget >/dev/null 2>&1; then wget -q -O "$file" "$url" || fail "download failed: $url" else fail "curl or wget is required to download." fi if [ "$VERSION" = "$BUILT_VERSION" ]; then actual=$(node -e "process.stdout.write(require('crypto').createHash('sha256').update(require('fs').readFileSync(process.argv[1])).digest('hex'))" "$file") [ "$actual" = "$BUILT_SHA256" ] || fail "checksum mismatch (expected $BUILT_SHA256, got $actual). Not installing." say "checksum ok" else say "version $VERSION was requested; this installer can only pin $BUILT_VERSION, so the checksum is not checked" fi if ! npm install -g "$file"; then fail "npm install -g failed. If it was a permissions error, point npm at a user directory and retry: npm config set prefix \"\$HOME/.local\" (and make sure \$HOME/.local/bin is on PATH)" fi say "installed $VERSION. Run: infinitecli (check setup with: infinitecli doctor)" command -v infinitecli >/dev/null 2>&1 || say "note: infinitecli is not on PATH yet; npm's global bin is $(npm prefix -g)/bin"