#!/bin/bash set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${BLUE}" echo "╔═══════════════════════════════════════╗" echo "║ SHT CLI Installer/Updater ║" echo "║ Seven Hills Technology ║" echo "╚═══════════════════════════════════════╝" echo -e "${NC}" echo "" # Check if Node.js is installed if ! command -v node &> /dev/null; then echo -e "${RED}Error: Node.js is not installed${NC}" echo "Please install Node.js from: https://nodejs.org/" exit 1 fi NODE_VERSION=$(node --version) echo -e "${GREEN}✓ Node.js detected: ${NODE_VERSION}${NC}" # Check if npm is installed if ! command -v npm &> /dev/null; then echo -e "${RED}Error: npm is not installed${NC}" echo "Please install npm" exit 1 fi NPM_VERSION=$(npm --version) echo -e "${GREEN}✓ npm detected: ${NPM_VERSION}${NC}" # Check if git is installed if ! command -v git &> /dev/null; then echo -e "${RED}Error: git is not installed${NC}" echo "Please install git from: https://git-scm.com/" exit 1 fi GIT_VERSION=$(git --version) echo -e "${GREEN}✓ Git detected: ${GIT_VERSION}${NC}" echo "" # Set installation directory INSTALL_DIR="${HOME}/.sht-cli" # Clone or update repository if [ -d "$INSTALL_DIR" ]; then echo -e "${YELLOW}Updating existing installation...${NC}" cd "$INSTALL_DIR" git pull origin main else echo -e "${YELLOW}Cloning repository...${NC}" git clone https://github.com/seven-hills-technology/sht-cli.git "$INSTALL_DIR" cd "$INSTALL_DIR" fi # Install dependencies echo -e "${YELLOW}Installing dependencies...${NC}" npm install # Build echo -e "${YELLOW}Building CLI...${NC}" npm run build # Link globally echo -e "${YELLOW}Linking CLI globally...${NC}" npm link echo "" echo -e "${GREEN}╔═══════════════════════════════════════╗${NC}" echo -e "${GREEN}║ Installation Complete! ✓ ║${NC}" echo -e "${GREEN}╚═══════════════════════════════════════╝${NC}" echo "" # Check installation if command -v sht &> /dev/null; then VERSION=$(sht --version) echo -e "${GREEN}✓ SHT CLI installed successfully${NC}" echo -e "${BLUE}Version: ${VERSION}${NC}" echo -e "${BLUE}Installation path: ${INSTALL_DIR}${NC}" echo "" echo -e "${YELLOW}Get started with:${NC}" echo -e " ${BLUE}sht init${NC} - Create a new project" echo -e " ${BLUE}sht update${NC} - Update to latest version" echo -e " ${BLUE}sht --help${NC} - Show help" echo -e " ${BLUE}sht --version${NC} - Show version" echo "" else echo -e "${RED}✗ Installation failed${NC}" echo "Please try again or report an issue at:" echo "https://github.com/seven-hills-technology/sht-cli/issues" exit 1 fi