#!/bin/bash

# Shipdeck Installer
# https://shipdeck.ai

set -e

# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
RESET='\033[0m'

echo -e "${BLUE}"
echo "   _____ __    _           __          __  "
echo "  / ___// /_  (_)___  ____/ /__  _____/ /__"
echo "  \__ \/ __ \/ / __ \/ __  / _ \/ ___/ //_/"
echo " ___/ / / / / / /_/ / /_/ /  __/ /__/ ,<   "
echo "/____/_/ /_/_/ .___/\__,_/\___/\___/_/|_|  "
echo "            /_/                             "
echo "         ⚓ Command Your Ship ⚓            "
echo -e "${RESET}"
echo ""

echo -e "${GREEN}Installing Shipdeck...${RESET}"
echo ""

# Check if npm is installed
if ! command -v npm &> /dev/null; then
    echo -e "${RED}Error: npm is not installed${RESET}"
    echo "Please install Node.js and npm first: https://nodejs.org"
    exit 1
fi

# Install globally via npm
echo -e "${BLUE}Installing via npm...${RESET}"
npm install -g shipdeck

echo ""
echo -e "${GREEN}✅ Shipdeck installed successfully!${RESET}"
echo ""
echo -e "${YELLOW}Quick Start:${RESET}"
echo "  ai-fix         - Fix any error in 30 seconds"
echo "  git-commit-ai  - Generate perfect commit messages"
echo "  shipdeck help  - See all commands"
echo ""
echo -e "${BLUE}Join the community:${RESET}"
echo "  Discord: https://shipdeck.ai/discord"
echo "  Twitter: https://twitter.com/shipdeckai"
echo ""
echo -e "${GREEN}All hands on deck! Ship at full speed! ⚓${RESET}"