#!/bin/sh set -eu NEONDIFF_VERSION="${NEONDIFF_VERSION:-latest}" DRY_RUN=0 PREFIX="${NPM_PREFIX:-}" usage() { cat <<'USAGE' Install NeonDiff from npm. Usage: sh install.sh [--dry-run] [--prefix /path/to/prefix] Environment: NEONDIFF_VERSION Version or dist-tag to install, defaults to latest. NPM_PREFIX Optional npm global prefix. Requires Node.js 26 or newer and npm. USAGE } while [ "$#" -gt 0 ]; do case "$1" in --dry-run) DRY_RUN=1 shift ;; --prefix) if [ "$#" -lt 2 ]; then echo "error: --prefix requires a path" >&2 exit 2 fi PREFIX="$2" shift 2 ;; --help|-h) usage exit 0 ;; *) echo "error: unknown argument: $1" >&2 usage >&2 exit 2 ;; esac done if ! command -v node >/dev/null 2>&1; then echo "error: Node.js 26 or newer is required before installing NeonDiff" >&2 exit 1 fi if ! command -v npm >/dev/null 2>&1; then echo "error: npm is required before installing NeonDiff" >&2 exit 1 fi NODE_MAJOR="$(node -p 'process.versions.node.split(".")[0]')" if [ "$NODE_MAJOR" -lt 26 ]; then echo "error: Node.js 26 or newer is required; found $(node -v)" >&2 exit 1 fi set -- npm install -g "neondiff@${NEONDIFF_VERSION}" if [ -n "$PREFIX" ]; then set -- "$@" --prefix "$PREFIX" fi echo "NeonDiff installer" echo "version: ${NEONDIFF_VERSION}" if [ -n "$PREFIX" ]; then echo "prefix: ${PREFIX}" fi printf 'command:' for part in "$@"; do printf ' %s' "$part" done printf '\n' echo "activation: API-backed activation is required for every repository" if [ "$DRY_RUN" -eq 1 ]; then echo "dry-run: no changes made" exit 0 fi "$@" echo "installed: initialize config, activate from an approved secret store, then verify status" echo " neondiff init --config config.local.json" echo "macOS Keychain example: the first command prompts without putting the key in shell history" echo " security add-generic-password -a \$USER -s neondiff-license -U -w" echo " security find-generic-password -s neondiff-license -w | neondiff license activate --config config.local.json --license-key-stdin true --json" echo "Linux, Windows, and other platforms: save the key with your approved secret manager UI, then pipe that manager's retrieval command to the same activation command." echo " neondiff license status --config config.local.json --json"