442 lines
12 KiB
Bash
Executable File
442 lines
12 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# EVE Development Environment Setup Script
|
|
# This script automates the setup process for the EVE desktop assistant
|
|
|
|
set -e # Exit on error
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Logging functions
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
log_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Print header
|
|
print_header() {
|
|
echo ""
|
|
echo "╔════════════════════════════════════════════════════════╗"
|
|
echo "║ EVE Development Environment Setup ║"
|
|
echo "║ Personal Desktop AI Assistant ║"
|
|
echo "╚════════════════════════════════════════════════════════╝"
|
|
echo ""
|
|
}
|
|
|
|
# Detect OS
|
|
detect_os() {
|
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
if [ -f /etc/debian_version ]; then
|
|
OS="debian"
|
|
log_info "Detected: Debian/Ubuntu Linux"
|
|
elif [ -f /etc/fedora-release ]; then
|
|
OS="fedora"
|
|
log_info "Detected: Fedora/RHEL Linux"
|
|
elif [ -f /etc/arch-release ]; then
|
|
OS="arch"
|
|
log_info "Detected: Arch Linux"
|
|
else
|
|
OS="linux"
|
|
log_info "Detected: Linux (generic)"
|
|
fi
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
OS="macos"
|
|
log_info "Detected: macOS"
|
|
else
|
|
OS="unknown"
|
|
log_warning "Unknown OS: $OSTYPE"
|
|
fi
|
|
}
|
|
|
|
# Check if command exists
|
|
command_exists() {
|
|
command -v "$1" >/dev/null 2>&1
|
|
}
|
|
|
|
# Check Node.js installation
|
|
check_node() {
|
|
log_info "Checking Node.js installation..."
|
|
|
|
if command_exists node; then
|
|
NODE_VERSION=$(node -v | cut -d'v' -f2)
|
|
MAJOR_VERSION=$(echo $NODE_VERSION | cut -d'.' -f1)
|
|
|
|
if [ "$MAJOR_VERSION" -ge 18 ]; then
|
|
log_success "Node.js $NODE_VERSION installed ✓"
|
|
return 0
|
|
else
|
|
log_warning "Node.js $NODE_VERSION is installed but v18+ is required"
|
|
return 1
|
|
fi
|
|
else
|
|
log_warning "Node.js is not installed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Check Rust installation
|
|
check_rust() {
|
|
log_info "Checking Rust installation..."
|
|
|
|
if command_exists rustc && command_exists cargo; then
|
|
RUST_VERSION=$(rustc --version | cut -d' ' -f2)
|
|
log_success "Rust $RUST_VERSION installed ✓"
|
|
return 0
|
|
else
|
|
log_warning "Rust is not installed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Check npm/pnpm
|
|
check_package_manager() {
|
|
log_info "Checking package manager..."
|
|
|
|
if command_exists npm; then
|
|
NPM_VERSION=$(npm -v)
|
|
log_success "npm $NPM_VERSION installed ✓"
|
|
PACKAGE_MANAGER="npm"
|
|
return 0
|
|
elif command_exists pnpm; then
|
|
PNPM_VERSION=$(pnpm -v)
|
|
log_success "pnpm $PNPM_VERSION installed ✓"
|
|
PACKAGE_MANAGER="pnpm"
|
|
return 0
|
|
else
|
|
log_error "Neither npm nor pnpm is installed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Install Node.js
|
|
install_node() {
|
|
log_info "Installing Node.js..."
|
|
|
|
if [[ "$OS" == "macos" ]]; then
|
|
if command_exists brew; then
|
|
brew install node
|
|
else
|
|
log_error "Homebrew not found. Please install from https://brew.sh/"
|
|
log_info "Or install Node.js manually from https://nodejs.org/"
|
|
exit 1
|
|
fi
|
|
else
|
|
log_info "Please install Node.js manually from https://nodejs.org/"
|
|
log_info "Recommended: Use nvm (Node Version Manager) https://github.com/nvm-sh/nvm"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Install Rust
|
|
install_rust() {
|
|
log_info "Installing Rust..."
|
|
|
|
if command_exists curl; then
|
|
log_info "Running rustup installer..."
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
|
|
# Source cargo environment
|
|
source "$HOME/.cargo/env"
|
|
|
|
log_success "Rust installed successfully!"
|
|
else
|
|
log_error "curl is not installed. Please install curl first."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Install system dependencies for Linux
|
|
install_linux_dependencies() {
|
|
log_info "Installing system dependencies for Tauri..."
|
|
|
|
case "$OS" in
|
|
debian)
|
|
log_info "Installing dependencies via apt..."
|
|
sudo apt update
|
|
sudo apt install -y \
|
|
libwebkit2gtk-4.0-dev \
|
|
build-essential \
|
|
curl \
|
|
wget \
|
|
file \
|
|
libssl-dev \
|
|
libgtk-3-dev \
|
|
libayatana-appindicator3-dev \
|
|
librsvg2-dev
|
|
;;
|
|
fedora)
|
|
log_info "Installing dependencies via dnf..."
|
|
sudo dnf install -y \
|
|
webkit2gtk4.0-devel \
|
|
openssl-devel \
|
|
curl \
|
|
wget \
|
|
file \
|
|
libappindicator-gtk3-devel \
|
|
librsvg2-devel
|
|
;;
|
|
arch)
|
|
log_info "Installing dependencies via pacman..."
|
|
sudo pacman -S --needed --noconfirm \
|
|
webkit2gtk \
|
|
base-devel \
|
|
curl \
|
|
wget \
|
|
file \
|
|
openssl \
|
|
gtk3 \
|
|
libappindicator-gtk3 \
|
|
librsvg
|
|
;;
|
|
*)
|
|
log_warning "Automatic dependency installation not supported for your Linux distribution"
|
|
log_info "Please refer to README.md for manual installation instructions"
|
|
return 1
|
|
;;
|
|
esac
|
|
|
|
log_success "System dependencies installed ✓"
|
|
}
|
|
|
|
# Install system dependencies for macOS
|
|
install_macos_dependencies() {
|
|
log_info "Checking Xcode Command Line Tools..."
|
|
|
|
if xcode-select -p &> /dev/null; then
|
|
log_success "Xcode Command Line Tools already installed ✓"
|
|
else
|
|
log_info "Installing Xcode Command Line Tools..."
|
|
xcode-select --install
|
|
log_info "Please complete the Xcode installation and run this script again"
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
# Setup environment file
|
|
setup_env_file() {
|
|
log_info "Setting up environment file..."
|
|
|
|
if [ -f ".env" ]; then
|
|
log_warning ".env file already exists"
|
|
read -p "Do you want to overwrite it? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
log_info "Keeping existing .env file"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
cp .env.example .env
|
|
log_success "Created .env file from .env.example"
|
|
|
|
echo ""
|
|
log_info "Please edit .env and add your API keys:"
|
|
log_info " - OpenRouter API key: https://openrouter.ai/keys"
|
|
log_info " - ElevenLabs API key (optional): https://elevenlabs.io"
|
|
echo ""
|
|
}
|
|
|
|
# Install npm dependencies
|
|
install_npm_dependencies() {
|
|
log_info "Installing npm dependencies..."
|
|
|
|
if [ -d "node_modules" ]; then
|
|
log_info "node_modules directory exists"
|
|
read -p "Do you want to reinstall dependencies? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
rm -rf node_modules package-lock.json
|
|
log_info "Cleaned node_modules"
|
|
else
|
|
log_info "Skipping npm install"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
$PACKAGE_MANAGER install
|
|
log_success "npm dependencies installed ✓"
|
|
}
|
|
|
|
# Verify installation
|
|
verify_installation() {
|
|
log_info "Verifying installation..."
|
|
echo ""
|
|
|
|
local all_good=true
|
|
|
|
# Check Node.js
|
|
if command_exists node; then
|
|
log_success "✓ Node.js: $(node -v)"
|
|
else
|
|
log_error "✗ Node.js: Not found"
|
|
all_good=false
|
|
fi
|
|
|
|
# Check Rust
|
|
if command_exists rustc; then
|
|
log_success "✓ Rust: $(rustc --version | cut -d' ' -f1-2)"
|
|
else
|
|
log_error "✗ Rust: Not found"
|
|
all_good=false
|
|
fi
|
|
|
|
# Check cargo
|
|
if command_exists cargo; then
|
|
log_success "✓ Cargo: $(cargo --version | cut -d' ' -f1-2)"
|
|
else
|
|
log_error "✗ Cargo: Not found"
|
|
all_good=false
|
|
fi
|
|
|
|
# Check npm
|
|
if command_exists npm; then
|
|
log_success "✓ npm: v$(npm -v)"
|
|
else
|
|
log_error "✗ npm: Not found"
|
|
all_good=false
|
|
fi
|
|
|
|
# Check node_modules
|
|
if [ -d "node_modules" ]; then
|
|
log_success "✓ Node dependencies installed"
|
|
else
|
|
log_error "✗ Node dependencies: Not installed"
|
|
all_good=false
|
|
fi
|
|
|
|
# Check .env file
|
|
if [ -f ".env" ]; then
|
|
log_success "✓ Environment file exists"
|
|
else
|
|
log_warning "⚠ Environment file not found (.env)"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
if [ "$all_good" = true ]; then
|
|
log_success "All checks passed! ✓"
|
|
return 0
|
|
else
|
|
log_error "Some checks failed. Please review the errors above."
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Print next steps
|
|
print_next_steps() {
|
|
echo ""
|
|
echo "╔════════════════════════════════════════════════════════╗"
|
|
echo "║ Setup Complete! ║"
|
|
echo "╚════════════════════════════════════════════════════════╝"
|
|
echo ""
|
|
log_info "Next steps:"
|
|
echo ""
|
|
echo " 1. Edit .env and add your API keys:"
|
|
echo " ${BLUE}nano .env${NC} or ${BLUE}vim .env${NC}"
|
|
echo ""
|
|
echo " 2. Start the development server:"
|
|
echo " ${GREEN}npm run tauri:dev${NC}"
|
|
echo ""
|
|
echo " 3. Build for production:"
|
|
echo " ${GREEN}npm run tauri:build${NC}"
|
|
echo ""
|
|
log_info "Additional commands:"
|
|
echo " - Frontend only: ${BLUE}npm run dev${NC}"
|
|
echo " - Lint code: ${BLUE}npm run lint${NC}"
|
|
echo " - Format code: ${BLUE}npm run format${NC}"
|
|
echo ""
|
|
log_info "Documentation: ./docs/README.md"
|
|
log_info "Troubleshooting: ./docs/setup/SETUP_COMPLETE.md"
|
|
echo ""
|
|
}
|
|
|
|
# Main setup function
|
|
main() {
|
|
print_header
|
|
|
|
# Detect OS
|
|
detect_os
|
|
echo ""
|
|
|
|
# Check existing installations
|
|
local need_node=false
|
|
local need_rust=false
|
|
|
|
check_node || need_node=true
|
|
check_rust || need_rust=true
|
|
check_package_manager
|
|
|
|
echo ""
|
|
|
|
# Install missing components
|
|
if [ "$need_node" = true ]; then
|
|
read -p "Install Node.js? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
install_node
|
|
else
|
|
log_warning "Skipping Node.js installation"
|
|
fi
|
|
fi
|
|
|
|
if [ "$need_rust" = true ]; then
|
|
read -p "Install Rust? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
install_rust
|
|
else
|
|
log_warning "Skipping Rust installation"
|
|
fi
|
|
fi
|
|
|
|
# Install system dependencies
|
|
if [[ "$OS" == "debian" ]] || [[ "$OS" == "fedora" ]] || [[ "$OS" == "arch" ]]; then
|
|
read -p "Install system dependencies for Tauri? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
install_linux_dependencies
|
|
fi
|
|
elif [[ "$OS" == "macos" ]]; then
|
|
install_macos_dependencies
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Setup environment file
|
|
setup_env_file
|
|
|
|
# Install npm dependencies
|
|
read -p "Install npm dependencies? (Y/n): " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Nn]$ ]]; then
|
|
install_npm_dependencies
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Verify installation
|
|
verify_installation
|
|
|
|
# Print next steps
|
|
print_next_steps
|
|
}
|
|
|
|
# Run main function
|
|
main "$@"
|