#!/bin/bash

# Setup script for Vitesse Dependency Scripts
# Makes all scripts executable and verifies requirements

echo "🚀 Setting up Vitesse Dependency Scripts..."
echo ""

# Make scripts executable
echo "📝 Making scripts executable..."
chmod +x *.js *.sh
echo "✅ Scripts are now executable"
echo ""

# Check Node.js
echo "🔍 Checking requirements..."
if command -v node &> /dev/null; then
    NODE_VERSION=$(node --version)
    echo "✅ Node.js: $NODE_VERSION"
else
    echo "❌ Node.js not found. Please install Node.js >= 14.18"
    echo "   Visit: https://nodejs.org/"
    exit 1
fi

# Check pnpm
if command -v pnpm &> /dev/null; then
    PNPM_VERSION=$(pnpm --version)
    echo "✅ pnpm: v$PNPM_VERSION"
else
    echo "⚠️  pnpm not found"
    echo "   Installing pnpm..."
    npm install -g pnpm
    if [ $? -eq 0 ]; then
        echo "✅ pnpm installed successfully"
    else
        echo "❌ Failed to install pnpm. Please run: npm install -g pnpm"
        exit 1
    fi
fi

# Check git
if command -v git &> /dev/null; then
    GIT_VERSION=$(git --version)
    echo "✅ Git: $GIT_VERSION"
else
    echo "⚠️  Git not found (optional)"
fi

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✨ Setup complete!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "📚 Quick Start:"
echo ""
echo "   # Create a new project instantly"
echo "   pnpm create my-awesome-app"
echo ""
echo "   # Or use node directly"
echo "   node create-project-instant.js my-awesome-app"
echo ""
echo "   # Link globally to use from anywhere (optional)"
echo "   pnpm link --global"
echo "   vitesse-create my-app"
echo ""
echo "📖 For more info, see README.md"
echo ""

