#!/bin/bash

# =============================================
# FateOS 项目安装脚本
# =============================================

set -e

echo "🚀 开始安装 FateOS 依赖..."
echo ""

# 进入项目目录
cd "$(dirname "$0")/.."

# 检查 Node.js
if ! command -v node &> /dev/null; then
    echo "❌ 未找到 Node.js，请先安装 Node.js 18+"
    exit 1
fi

echo "✓ Node.js 版本: $(node -v)"
echo "✓ npm 版本: $(npm -v)"
echo ""

# 安装依赖
echo "📦 安装 npm 依赖..."
npm install

echo ""
echo "✅ 依赖安装完成！"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "📝 下一步操作："
echo ""
echo "1. 创建环境变量文件:"
echo "   cp env.example.txt .env.local"
echo ""
echo "2. 编辑 .env.local 填写 API Key:"
echo "   - DASHSCOPE_API_KEY (通义千问)"
echo "   - XUNHU_APPID / XUNHU_APPSECRET (虎皮椒支付)"
echo ""
echo "3. 启动开发服务器:"
echo "   npm run dev"
echo ""
echo "4. 访问 http://localhost:3000"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

