#!/bin/bash # One-shot installer for project-selector # Run after backup restore: curl -fsSL https://git.upfrontops.cloud/UpfrontOps/project-selector/raw/branch/main/install.sh | bash # Or locally: /opt/infra/project-selector/install.sh set -e INSTALL_DIR="/opt/infra/project-selector" REPO_URL="https://git.upfrontops.cloud/UpfrontOps/project-selector.git" BASHRC="$HOME/.bashrc" SOURCE_LINE="source $INSTALL_DIR/cw.sh" echo "=== Project Selector Installer ===" echo "" # Check dependencies echo "Checking dependencies..." if ! command -v fzf &>/dev/null; then echo "Installing fzf..." if command -v apt-get &>/dev/null; then sudo apt-get update && sudo apt-get install -y fzf elif command -v brew &>/dev/null; then brew install fzf else echo "Error: Cannot install fzf. Please install manually." >&2 exit 1 fi fi echo " fzf: OK" if ! command -v git &>/dev/null; then echo "Error: git is required but not installed" >&2 exit 1 fi echo " git: OK" # Check for Node.js (required for npm claude) if ! command -v node &>/dev/null; then echo "Installing Node.js..." if command -v apt-get &>/dev/null; then curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs elif command -v brew &>/dev/null; then brew install node else echo "Error: Cannot install Node.js. Please install manually." >&2 exit 1 fi fi echo " node: OK ($(node --version))" # Install Claude Code via npm (NOT native installer) if ! command -v claude &>/dev/null; then echo "Installing Claude Code via npm..." sudo npm install -g @anthropic-ai/claude-code fi echo " claude: OK (npm)" # Clone or update repo echo "" if [ -d "$INSTALL_DIR/.git" ]; then echo "Updating existing installation..." cd "$INSTALL_DIR" git fetch origin git reset --hard origin/main 2>/dev/null || git reset --hard origin/master else echo "Cloning project-selector..." mkdir -p "$(dirname "$INSTALL_DIR")" git clone "$REPO_URL" "$INSTALL_DIR" fi # Add to bashrc if not already present echo "" if grep -qF "$SOURCE_LINE" "$BASHRC" 2>/dev/null; then echo "Already in $BASHRC" else echo "Adding to $BASHRC..." echo "" >> "$BASHRC" echo "# Project Selector for Claude Code" >> "$BASHRC" echo "$SOURCE_LINE" >> "$BASHRC" fi echo "" echo "=== Installation Complete ===" echo "" echo "Run 'source ~/.bashrc' or start a new terminal, then use 'cw' to start." echo ""