Files
eve-alpha/setup.ps1
Aodhan Collins 8d6a681baa Phase 2 complete.
2025-10-06 21:08:25 +01:00

440 lines
13 KiB
PowerShell

# EVE Development Environment Setup Script for Windows
# Run this script in PowerShell with: .\setup.ps1
# Requires PowerShell 5.1 or higher
# Function to print colored output
function Write-ColorOutput($ForegroundColor) {
$fc = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $ForegroundColor
if ($args) {
Write-Output $args
}
$host.UI.RawUI.ForegroundColor = $fc
}
function Log-Info($message) {
Write-ColorOutput Cyan "[INFO] $message"
}
function Log-Success($message) {
Write-ColorOutput Green "[SUCCESS] $message"
}
function Log-Warning($message) {
Write-ColorOutput Yellow "[WARNING] $message"
}
function Log-Error($message) {
Write-ColorOutput Red "[ERROR] $message"
}
# Print header
function Print-Header {
Write-Host ""
Write-Host "╔════════════════════════════════════════════════════════╗"
Write-Host "║ EVE Development Environment Setup ║"
Write-Host "║ Personal Desktop AI Assistant ║"
Write-Host "╚════════════════════════════════════════════════════════╝"
Write-Host ""
}
# Check if running as administrator
function Test-Administrator {
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal $user
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# Check if command exists
function Test-CommandExists($command) {
$null = Get-Command $command -ErrorAction SilentlyContinue
return $?
}
# Check Node.js installation
function Test-NodeJs {
Log-Info "Checking Node.js installation..."
if (Test-CommandExists "node") {
$version = node -v
$versionNumber = $version -replace 'v', ''
$majorVersion = ($versionNumber -split '\.')[0]
if ([int]$majorVersion -ge 18) {
Log-Success "Node.js $version installed ✓"
return $true
} else {
Log-Warning "Node.js $version is installed but v18+ is required"
return $false
}
} else {
Log-Warning "Node.js is not installed"
return $false
}
}
# Check Rust installation
function Test-Rust {
Log-Info "Checking Rust installation..."
if ((Test-CommandExists "rustc") -and (Test-CommandExists "cargo")) {
$version = rustc --version
Log-Success "$version installed ✓"
return $true
} else {
Log-Warning "Rust is not installed"
return $false
}
}
# Check package manager
function Test-PackageManager {
Log-Info "Checking package manager..."
if (Test-CommandExists "npm") {
$version = npm -v
Log-Success "npm $version installed ✓"
$script:PackageManager = "npm"
return $true
} elseif (Test-CommandExists "pnpm") {
$version = pnpm -v
Log-Success "pnpm $version installed ✓"
$script:PackageManager = "pnpm"
return $true
} else {
Log-Error "Neither npm nor pnpm is installed"
return $false
}
}
# Check WebView2
function Test-WebView2 {
Log-Info "Checking WebView2 Runtime..."
$webView2Path = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
if (Test-Path $webView2Path) {
Log-Success "WebView2 Runtime installed ✓"
return $true
} else {
Log-Warning "WebView2 Runtime not detected"
return $false
}
}
# Check Visual Studio Build Tools
function Test-VSBuildTools {
Log-Info "Checking Visual Studio Build Tools..."
$vsPaths = @(
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools",
"C:\Program Files\Microsoft Visual Studio\2022\Community",
"C:\Program Files\Microsoft Visual Studio\2022\Professional",
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
)
foreach ($path in $vsPaths) {
if (Test-Path $path) {
Log-Success "Visual Studio Build Tools found ✓"
return $true
}
}
Log-Warning "Visual Studio Build Tools not detected"
return $false
}
# Install Node.js
function Install-NodeJs {
Log-Info "Installing Node.js..."
Log-Info "Please download and install Node.js from: https://nodejs.org/"
Log-Info "Recommended: Download the LTS version (v18 or higher)"
$response = Read-Host "Open Node.js download page in browser? (Y/n)"
if ($response -ne 'n' -and $response -ne 'N') {
Start-Process "https://nodejs.org/en/download/"
}
Log-Info "After installing Node.js, please restart this script"
exit 0
}
# Install Rust
function Install-Rust {
Log-Info "Installing Rust..."
$rustupUrl = "https://win.rustup.rs/x86_64"
$rustupPath = "$env:TEMP\rustup-init.exe"
try {
Log-Info "Downloading rustup installer..."
Invoke-WebRequest -Uri $rustupUrl -OutFile $rustupPath
Log-Info "Running rustup installer..."
Start-Process -FilePath $rustupPath -Wait
Log-Success "Rust installation initiated!"
Log-Info "Please restart your terminal after the installation completes"
} catch {
Log-Error "Failed to download Rust installer: $_"
Log-Info "Please install manually from: https://rustup.rs/"
}
}
# Install WebView2
function Install-WebView2 {
Log-Info "WebView2 Runtime is required for Tauri applications"
Log-Info "Download from: https://developer.microsoft.com/en-us/microsoft-edge/webview2/"
$response = Read-Host "Open WebView2 download page in browser? (Y/n)"
if ($response -ne 'n' -and $response -ne 'N') {
Start-Process "https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section"
}
}
# Install Visual Studio Build Tools
function Install-VSBuildTools {
Log-Info "Visual Studio Build Tools are required for Rust compilation"
Log-Info "Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/"
$response = Read-Host "Open Visual Studio Build Tools download page in browser? (Y/n)"
if ($response -ne 'n' -and $response -ne 'N') {
Start-Process "https://visualstudio.microsoft.com/visual-cpp-build-tools/"
}
Log-Info ""
Log-Info "During installation, select:"
Log-Info " - Desktop development with C++"
Log-Info " - Windows 10/11 SDK"
}
# Setup environment file
function Setup-EnvFile {
Log-Info "Setting up environment file..."
if (Test-Path ".env") {
Log-Warning ".env file already exists"
$response = Read-Host "Do you want to overwrite it? (y/N)"
if ($response -ne 'y' -and $response -ne 'Y') {
Log-Info "Keeping existing .env file"
return
}
}
Copy-Item ".env.example" ".env"
Log-Success "Created .env file from .env.example"
Write-Host ""
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"
Write-Host ""
}
# Install npm dependencies
function Install-NpmDependencies {
Log-Info "Installing npm dependencies..."
if (Test-Path "node_modules") {
Log-Info "node_modules directory exists"
$response = Read-Host "Do you want to reinstall dependencies? (y/N)"
if ($response -eq 'y' -or $response -eq 'Y') {
Remove-Item -Recurse -Force "node_modules"
if (Test-Path "package-lock.json") {
Remove-Item "package-lock.json"
}
Log-Info "Cleaned node_modules"
} else {
Log-Info "Skipping npm install"
return
}
}
& $script:PackageManager install
if ($LASTEXITCODE -eq 0) {
Log-Success "npm dependencies installed ✓"
} else {
Log-Error "Failed to install npm dependencies"
}
}
# Verify installation
function Test-Installation {
Log-Info "Verifying installation..."
Write-Host ""
$allGood = $true
# Check Node.js
if (Test-CommandExists "node") {
$version = node -v
Log-Success "✓ Node.js: $version"
} else {
Log-Error "✗ Node.js: Not found"
$allGood = $false
}
# Check Rust
if (Test-CommandExists "rustc") {
$version = (rustc --version) -split ' ' | Select-Object -First 2
Log-Success "✓ Rust: $($version -join ' ')"
} else {
Log-Error "✗ Rust: Not found"
$allGood = $false
}
# Check Cargo
if (Test-CommandExists "cargo") {
$version = (cargo --version) -split ' ' | Select-Object -First 2
Log-Success "✓ Cargo: $($version -join ' ')"
} else {
Log-Error "✗ Cargo: Not found"
$allGood = $false
}
# Check npm
if (Test-CommandExists "npm") {
$version = npm -v
Log-Success "✓ npm: v$version"
} else {
Log-Error "✗ npm: Not found"
$allGood = $false
}
# Check node_modules
if (Test-Path "node_modules") {
Log-Success "✓ Node dependencies installed"
} else {
Log-Error "✗ Node dependencies: Not installed"
$allGood = $false
}
# Check .env file
if (Test-Path ".env") {
Log-Success "✓ Environment file exists"
} else {
Log-Warning "⚠ Environment file not found (.env)"
}
# Check WebView2
if (Test-WebView2) {
Log-Success "✓ WebView2 Runtime installed"
} else {
Log-Warning "⚠ WebView2 Runtime: Not detected"
}
Write-Host ""
if ($allGood) {
Log-Success "All checks passed! ✓"
return $true
} else {
Log-Error "Some checks failed. Please review the errors above."
return $false
}
}
# Print next steps
function Print-NextSteps {
Write-Host ""
Write-Host "╔════════════════════════════════════════════════════════╗"
Write-Host "║ Setup Complete! ║"
Write-Host "╚════════════════════════════════════════════════════════╝"
Write-Host ""
Log-Info "Next steps:"
Write-Host ""
Write-Host " 1. Edit .env and add your API keys:"
Write-ColorOutput Cyan " notepad .env"
Write-Host ""
Write-Host " 2. Start the development server:"
Write-ColorOutput Green " npm run tauri:dev"
Write-Host ""
Write-Host " 3. Build for production:"
Write-ColorOutput Green " npm run tauri:build"
Write-Host ""
Log-Info "Additional commands:"
Write-ColorOutput Cyan " - Frontend only: npm run dev"
Write-ColorOutput Cyan " - Lint code: npm run lint"
Write-ColorOutput Cyan " - Format code: npm run format"
Write-Host ""
Log-Info "Documentation: .\docs\README.md"
Log-Info "Troubleshooting: .\docs\setup\SETUP_COMPLETE.md"
Write-Host ""
}
# Main setup function
function Main {
Print-Header
Log-Info "Detected: Windows"
Write-Host ""
# Check existing installations
$needNode = -not (Test-NodeJs)
$needRust = -not (Test-Rust)
$needWebView2 = -not (Test-WebView2)
$needVSBuildTools = -not (Test-VSBuildTools)
Test-PackageManager | Out-Null
Write-Host ""
# Install missing components
if ($needNode) {
$response = Read-Host "Install Node.js? (y/N)"
if ($response -eq 'y' -or $response -eq 'Y') {
Install-NodeJs
} else {
Log-Warning "Skipping Node.js installation"
}
}
if ($needRust) {
$response = Read-Host "Install Rust? (y/N)"
if ($response -eq 'y' -or $response -eq 'Y') {
Install-Rust
} else {
Log-Warning "Skipping Rust installation"
}
}
if ($needWebView2) {
$response = Read-Host "Install WebView2 Runtime? (y/N)"
if ($response -eq 'y' -or $response -eq 'Y') {
Install-WebView2
}
}
if ($needVSBuildTools) {
$response = Read-Host "Install Visual Studio Build Tools? (y/N)"
if ($response -eq 'y' -or $response -eq 'Y') {
Install-VSBuildTools
}
}
Write-Host ""
# Setup environment file
Setup-EnvFile
# Install npm dependencies
$response = Read-Host "Install npm dependencies? (Y/n)"
if ($response -ne 'n' -and $response -ne 'N') {
Install-NpmDependencies
}
Write-Host ""
# Verify installation
Test-Installation
# Print next steps
Print-NextSteps
}
# Run main function
Main