#!/bin/bash

# WordLift CLI Installation Script

set -e

echo "🚀 Installing WordLift CLI..."

# Check if Node.js is installed
if ! command -v node &> /dev/null; then
    echo "❌ Node.js is not installed. Please install Node.js first:"
    echo "   https://nodejs.org/"
    exit 1
fi

# Check Node.js version
NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1)
if [ "$NODE_VERSION" -lt 16 ]; then
    echo "❌ Node.js version 16 or higher is required. Current version: $(node -v)"
    exit 1
fi

echo "✅ Node.js $(node -v) found"

# Install Gemini CLI globally
echo "📦 Installing Gemini CLI..."
npm install -g @google/gemini-cli

# Install WordLift CLI dependencies
echo "📦 Installing WordLift CLI dependencies..."
npm install

# Run setup
echo "⚙️  Running WordLift CLI setup..."
npm run configure

echo ""
echo "🎉 WordLift CLI installation complete!"
echo ""
echo "Usage:"
echo "  wordlift-cli --help           # Show help"
echo "  wordlift-cli chat             # Start chat session"
echo "  wordlift-cli generate \"text\"  # Generate content"
echo ""
echo "For more information, check the README.md file."
