Monorepo for Aesthetic.Computer aesthetic.computer
at main 153 lines 4.1 kB view raw
1#!/usr/bin/env bash 2# Quick checker/installer for a native (non-devcontainer) AC environment on macOS. 3# It verifies host tools and repo installs needed to run ac-site (Netlify dev) and Tezos keeps scripts. 4 5set -euo pipefail 6 7REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 8OS_NAME="$(uname -s)" 9INSTALL=false 10INSTALL_NPM=false 11 12for arg in "$@"; do 13 case "$arg" in 14 --install) INSTALL=true ;; 15 --npm) INSTALL_NPM=true ;; 16 --help|-h) 17 echo "Usage: $0 [--install] [--npm]" 18 echo " --install Install missing brew deps (fnm, fish, jq, caddy, stripe-cli) on macOS." 19 echo " --npm Install missing node_modules in root/system/tezos." 20 exit 0 21 ;; 22 esac 23done 24 25if [[ "$OS_NAME" != "Darwin" ]]; then 26 echo "Note: expected macOS; detected $OS_NAME. The script will continue with best-effort checks." 27fi 28 29have() { command -v "$1" >/dev/null 2>&1; } 30 31require_brew() { 32 if ! have brew; then 33 echo "Homebrew not found. Install from https://brew.sh first." 34 return 1 35 fi 36} 37 38install_pkg() { 39 local pkg="$1" 40 if $INSTALL; then 41 echo "Installing $pkg via brew..." 42 brew install "$pkg" 43 else 44 echo "Missing $pkg (run: brew install $pkg)" 45 fi 46} 47 48install_npm() { 49 local dir="$1" 50 if [[ ! -f "$dir/package.json" ]]; then 51 echo "Skipping $dir (no package.json)" 52 return 53 fi 54 echo "Installing npm deps in $dir..." 55 (cd "$dir" && npm install) 56} 57 58echo "Checking host tools..." 59require_brew || true 60 61for pkg in fnm; do 62 if have "$pkg"; then 63 echo "$pkg" 64 else 65 install_pkg "$pkg" 66 fi 67done 68 69# Optional helpers that improve parity with the devcontainer. 70for pkg in fish jq caddy stripe/stripe-cli; do 71 name="${pkg##*/}" 72 if have "$name"; then 73 echo "$name" 74 else 75 if $INSTALL; then 76 install_pkg "$pkg" 77 else 78 echo "(optional) Missing $name (brew install $pkg)" 79 fi 80 fi 81done 82 83echo "Ensuring Node (LTS Jod / v22) via fnm..." 84if have fnm; then 85 if $INSTALL; then 86 fnm install lts/jod >/dev/null 2>&1 || fnm install 22 >/dev/null 2>&1 || true 87 fi 88 # shellcheck disable=SC1090 89 eval "$(fnm env --use-on-cd --shell bash --log-level quiet)" >/dev/null 2>&1 || true 90fi 91 92if have node; then 93 NODE_VER="$(node -v 2>/dev/null || true)" 94 echo "Node detected: $NODE_VER" 95 if [[ "$NODE_VER" < "v22." ]]; then 96 echo "Warning: Node is older than v22. Use: fnm use lts/jod --install-if-missing" 97 fi 98else 99 echo "Node not found. Install via fnm: fnm install lts/jod && fnm use lts/jod" 100fi 101 102echo "Checking repo installs..." 103if [[ ! -d "$REPO_ROOT/node_modules" ]]; then 104 if $INSTALL_NPM; then 105 install_npm "$REPO_ROOT" 106 else 107 echo "Root node_modules missing. Run: cd \"$REPO_ROOT\" && npm install (or rerun with --npm)" 108 fi 109else 110 echo "✓ root node_modules present" 111fi 112 113if [[ ! -d "$REPO_ROOT/system/node_modules" ]]; then 114 if $INSTALL_NPM; then 115 install_npm "$REPO_ROOT/system" 116 else 117 echo "System node_modules missing. Run: cd \"$REPO_ROOT/system\" && npm install (or rerun with --npm)" 118 fi 119else 120 echo "✓ system node_modules present" 121fi 122 123NETLIFY_BIN="$REPO_ROOT/system/node_modules/.bin/netlify" 124if [[ -x "$NETLIFY_BIN" ]]; then 125 echo "✓ netlify CLI (local) found at $NETLIFY_BIN" 126else 127 echo "netlify CLI not found locally. After installing system deps, use: cd \"$REPO_ROOT/system\" && npm install" 128fi 129 130echo "Tezos keeps helpers..." 131if have python3; then 132 echo "✓ python3" 133else 134 echo "Missing python3 (install via: brew install python)" 135fi 136 137if [[ ! -d "$REPO_ROOT/tezos/node_modules" ]]; then 138 if $INSTALL_NPM; then 139 install_npm "$REPO_ROOT/tezos" 140 else 141 echo "Tezos node_modules missing. Run: cd \"$REPO_ROOT/tezos\" && npm install (or rerun with --npm)" 142 fi 143else 144 echo "✓ tezos node_modules present" 145fi 146 147echo 148echo "Next steps:" 149echo "- To install missing tools: rerun with --install (Homebrew is required)." 150echo "- To install missing node_modules: rerun with --npm." 151echo "- Start the site: cd \"$REPO_ROOT/system\" && npm run local-dev" 152echo "- Full stack: cd \"$REPO_ROOT\" && npm run aesthetic" 153echo "- Tezos CLI smoke test: cd \"$REPO_ROOT/tezos\" && node keeps.mjs status"