#!/bin/sh # Install Cuvette on macOS or Linux. # curl -fsSL https://cuvette.ai/install.sh | sh # Settings: # CUVETTE_FROM=npm|source force one install method (default: npm if the package is published) # CUVETTE_SRC= the folder for the source install (default: ~/.local/share/cuvette/src) # CUVETTE_REF= the branch or tag for the source install (default: main) set -eu REPO=https://github.com/elparko/cuvette PKG=@elparko/cuvette say() { printf '%s\n' "$*"; } warn() { printf 'Warning: %s\n' "$*" >&2; } fail() { printf 'Error: %s\n' "$*" >&2; exit 1; } has() { command -v "$1" >/dev/null 2>&1; } from_npm() { say "Install $PKG from npm." npm install -g "$PKG" || fail "npm could not install $PKG. If the error is EACCES, set an npm prefix that you own: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally" } from_source() { has git || fail "git is not installed. Install git, then run this script again." src=${CUVETTE_SRC:-$HOME/.local/share/cuvette/src} ref=${CUVETTE_REF:-main} if [ -d "$src/.git" ]; then say "Update the source in $src." git -C "$src" fetch --depth 1 origin "$ref" git -C "$src" checkout -q FETCH_HEAD else say "Get the source from $REPO into $src." mkdir -p "$(dirname "$src")" git clone -q --depth 1 --branch "$ref" "$REPO" "$src" fi (cd "$src" && npm ci --omit=dev --no-audit --no-fund && npm link --no-audit --no-fund) || fail "npm could not install Cuvette from $src. If the error is EACCES, set an npm prefix that you own: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally" } main() { case "$(uname -s)" in Darwin | Linux) ;; *) fail "This script is for macOS and Linux. On Windows, install Node.js 22 and run: npm i -g $PKG" ;; esac has node || fail "Node.js is not installed. Cuvette needs Node.js 22 or later. Get it from https://nodejs.org" has npm || fail "npm is not installed. npm comes with Node.js. Get Node.js from https://nodejs.org" major=$(node -p 'process.versions.node.split(".")[0]') [ "$major" -ge 22 ] || fail "Node.js $(node -v) is too old. Cuvette needs Node.js 22 or later." say "Node.js $(node -v)" if has python3; then say "$(python3 --version 2>&1)" else warn "Python 3 is not installed. Most adapters need it. 'cuvette doctor' tells what to install." fi how=${CUVETTE_FROM:-} if [ -z "$how" ]; then if npm view "$PKG" version >/dev/null 2>&1; then how=npm; else how=source; fi fi case "$how" in npm) from_npm ;; source) from_source ;; *) fail "CUVETTE_FROM must be npm or source, not '$how'." ;; esac if ! has cuvette; then warn "The cuvette command is not on your PATH. Add $(npm prefix -g)/bin to PATH, then open a new terminal." exit 0 fi say "" say "Cuvette is installed. Check your computer:" cuvette doctor || true say "" say "To start a session, open a terminal in your data folder and run: cuvette" } main "$@"