Spaces:
Sleeping
Sleeping
| # --- Ever Brain Web Installer for Windows --- | |
| # This script downloads and installs Ever Brain globally. | |
| $ErrorActionPreference = "Stop" | |
| Write-Host "--- Ever Brain Installation Started ---" -ForegroundColor Cyan | |
| # 1. Configuration | |
| $BaseUrl = "https://projectsorg-ever-brain.hf.space" # In production, this would be your domain | |
| $InstallDir = Join-Path $env:LOCALAPPDATA "EverBrain" | |
| $BinDir = Join-Path $InstallDir "bin" | |
| $ExeName = "ever-brain.exe" | |
| $DownloadUrl = "$BaseUrl/download" | |
| # 2. Create Install Directory | |
| Write-Host "> Creating installation directory at $BinDir..." -ForegroundColor Gray | |
| if (-not (Test-Path $BinDir)) { | |
| New-Item -ItemType Directory -Path $BinDir -Force | Out-Null | |
| } | |
| # 3. Download Executable | |
| Write-Host "> Downloading Ever Brain CLI..." -ForegroundColor Gray | |
| Invoke-WebRequest -Uri $DownloadUrl -OutFile (Join-Path $BinDir $ExeName) -UseBasicParsing | |
| # 4. Add to PATH | |
| Write-Host "> Updating PATH environment variable..." -ForegroundColor Gray | |
| $UserPath = [Environment]::GetEnvironmentVariable("Path", "User") | |
| if ($UserPath -notlike "*$BinDir*") { | |
| $NewPath = "$UserPath;$BinDir" | |
| [Environment]::SetEnvironmentVariable("Path", $NewPath, "User") | |
| $env:Path = "$env:Path;$BinDir" | |
| Write-Host "++ Added $BinDir to User PATH." -ForegroundColor Green | |
| } else { | |
| Write-Host ">> $BinDir is already in PATH." -ForegroundColor DarkGray | |
| } | |
| # 5. Register in 'Add or Remove Programs' | |
| Write-Host "> Registering with Windows for uninstallation..." -ForegroundColor Gray | |
| $UninstallKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\EverBrain" | |
| if (-not (Test-Path $UninstallKey)) { | |
| New-Item -Path $UninstallKey -Force | Out-Null | |
| } | |
| $UninstallCommand = "powershell.exe -Command `"[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User').Replace('$BinDir', '').Replace(';;', ';'), 'User'); Remove-Item -Path '$InstallDir' -Recurse -Force; Remove-Item -Path '$UninstallKey' -Force`"" | |
| Set-ItemProperty -Path $UninstallKey -Name "DisplayName" -Value "Ever Brain" | |
| Set-ItemProperty -Path $UninstallKey -Name "UninstallString" -Value $UninstallCommand | |
| Set-ItemProperty -Path $UninstallKey -Name "DisplayVersion" -Value "0.1.0" | |
| Set-ItemProperty -Path $UninstallKey -Name "Publisher" -Value "Ever Brain" | |
| Set-ItemProperty -Path $UninstallKey -Name "InstallLocation" -Value "$InstallDir" | |
| Set-ItemProperty -Path $UninstallKey -Name "NoModify" -Value 1 | |
| Set-ItemProperty -Path $UninstallKey -Name "NoRepair" -Value 1 | |
| Write-Host "`nSUCCESS! Ever Brain is now installed." -ForegroundColor Green | |
| Write-Host "Please restart your terminal and run: ever-brain status" -ForegroundColor White | |
| Write-Host "----------------------------------------" -ForegroundColor Cyan | |