|
| 1 | +#Requires -Version 5.0 |
| 2 | + |
| 3 | +# Yappus Terminal Windows Installer |
| 4 | +# This script installs Yappus Terminal on Windows systems |
| 5 | + |
| 6 | +Write-Host "Yappus Terminal Windows Installer" -ForegroundColor Cyan |
| 7 | +Write-Host "=================================" -ForegroundColor Cyan |
| 8 | + |
| 9 | +# admin check |
| 10 | +$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) |
| 11 | + |
| 12 | +$appDir = "$env:USERPROFILE\Yappus-Term" |
| 13 | +$configDir = "$env:APPDATA\yappus\yappus-term\config" |
| 14 | + |
| 15 | +# rust installation |
| 16 | +function Test-RustInstalled { |
| 17 | + try { |
| 18 | + $rustVersion = (rustc --version) |
| 19 | + $cargoVersion = (cargo --version) |
| 20 | + return $true |
| 21 | + } |
| 22 | + catch { |
| 23 | + return $false |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +# rust install |
| 28 | +if (-not (Test-RustInstalled)) { |
| 29 | + Write-Host "Rust is not installed. Installing Rust..." -ForegroundColor Yellow |
| 30 | + |
| 31 | + try { |
| 32 | + # Download rustup-init |
| 33 | + $rustupInitPath = "$env:TEMP\rustup-init.exe" |
| 34 | + Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile $rustupInitPath |
| 35 | + |
| 36 | + # Run rustup-init |
| 37 | + & $rustupInitPath -y --default-toolchain stable |
| 38 | + |
| 39 | + # Update PATH for current session |
| 40 | + $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine") |
| 41 | + |
| 42 | + Write-Host "Rust installed successfully!" -ForegroundColor Green |
| 43 | + } |
| 44 | + catch { |
| 45 | + Write-Host "Failed to install Rust. Please install it manually from https://rustup.rs/" -ForegroundColor Red |
| 46 | + exit 1 |
| 47 | + } |
| 48 | +} |
| 49 | +else { |
| 50 | + Write-Host "Rust is already installed." -ForegroundColor Green |
| 51 | +} |
| 52 | + |
| 53 | +Write-Host "Setting up directories..." -ForegroundColor Cyan |
| 54 | +New-Item -ItemType Directory -Path $appDir -Force | Out-Null |
| 55 | +New-Item -ItemType Directory -Path $configDir -Force | Out-Null |
| 56 | + |
| 57 | +Write-Host "Cloning Yappus Terminal repository..." -ForegroundColor Cyan |
| 58 | +Set-Location $appDir |
| 59 | +try { |
| 60 | + if (Test-Path "$appDir\.git") { |
| 61 | + git pull |
| 62 | + } |
| 63 | + else { |
| 64 | + git clone https://github.com/MostlyKIGuess/Yappus-Term.git . |
| 65 | + } |
| 66 | +} |
| 67 | +catch { |
| 68 | + Write-Host "Failed to clone repository. Make sure Git is installed." -ForegroundColor Red |
| 69 | + Write-Host "You can install Git from https://git-scm.com/download/win" -ForegroundColor Red |
| 70 | + exit 1 |
| 71 | +} |
| 72 | + |
| 73 | +Write-Host "Building Yappus Terminal..." -ForegroundColor Cyan |
| 74 | +try { |
| 75 | + cargo build --release |
| 76 | +} |
| 77 | +catch { |
| 78 | + Write-Host "Failed to build Yappus Terminal. Please check the error messages above." -ForegroundColor Red |
| 79 | + exit 1 |
| 80 | +} |
| 81 | + |
| 82 | +$targetPath = "$appDir\target\release\yappus.exe" |
| 83 | +$addToPath = $false |
| 84 | + |
| 85 | +if ($isAdmin) { |
| 86 | + $addToPath = (Read-Host "Do you want to add Yappus to your system PATH? (y/N)").ToLower() -eq 'y' |
| 87 | + |
| 88 | + if ($addToPath) { |
| 89 | + $pathEnv = [System.Environment]::GetEnvironmentVariable("Path", "Machine") |
| 90 | + if ($pathEnv -notlike "*$appDir\target\release*") { |
| 91 | + [System.Environment]::SetEnvironmentVariable("Path", "$pathEnv;$appDir\target\release", "Machine") |
| 92 | + Write-Host "Added Yappus to system PATH." -ForegroundColor Green |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | +elseif ((Read-Host "Do you want to add Yappus to your user PATH? (y/N)").ToLower() -eq 'y') { |
| 97 | + $pathEnv = [System.Environment]::GetEnvironmentVariable("Path", "User") |
| 98 | + if ($pathEnv -notlike "*$appDir\target\release*") { |
| 99 | + [System.Environment]::SetEnvironmentVariable("Path", "$pathEnv;$appDir\target\release", "User") |
| 100 | + Write-Host "Added Yappus to user PATH." -ForegroundColor Green |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +$createShortcut = (Read-Host "Do you want to create a desktop shortcut? (y/N)").ToLower() -eq 'y' |
| 105 | +if ($createShortcut) { |
| 106 | + $desktopPath = [System.Environment]::GetFolderPath('Desktop') |
| 107 | + $shortcutPath = Join-Path -Path $desktopPath -ChildPath "Yappus Terminal.lnk" |
| 108 | + |
| 109 | + $WScriptShell = New-Object -ComObject WScript.Shell |
| 110 | + $shortcut = $WScriptShell.CreateShortcut($shortcutPath) |
| 111 | + $shortcut.TargetPath = $targetPath |
| 112 | + $shortcut.WorkingDirectory = Split-Path -Parent $targetPath |
| 113 | + $shortcut.Description = "Yappus Terminal AI Assistant" |
| 114 | + $shortcut.Save() |
| 115 | + |
| 116 | + Write-Host "Desktop shortcut created." -ForegroundColor Green |
| 117 | +} |
| 118 | + |
| 119 | +Write-Host "`nYappus Terminal has been successfully installed!" -ForegroundColor Green |
| 120 | +Write-Host "`nTo run Yappus Terminal:" -ForegroundColor Cyan |
| 121 | +Write-Host " - From any terminal: yappus" -ForegroundColor White |
| 122 | +Write-Host " - Or run directly: $targetPath" -ForegroundColor White |
| 123 | +Write-Host "`nOn first run, you will be prompted to enter your Google Gemini API key." -ForegroundColor Yellow |
| 124 | +Write-Host "You can get your API key from: https://aistudio.google.com/app/apikey" -ForegroundColor Yellow |
| 125 | + |
| 126 | +if ((Read-Host "`nDo you want to run Yappus Terminal now? (y/N)").ToLower() -eq 'y') { |
| 127 | + Set-Location $env:USERPROFILE |
| 128 | + & $targetPath |
| 129 | +} |
0 commit comments