# Installs CLIDE on Windows. # # irm https://downloads.clide.tools/install.ps1 | iex # # What it does: reads latest/latest.json, downloads the Windows installer, checks its SHA-256, # and runs it. CLIDE installs for this user only; no administrator rights are needed. # # Why a script: CLIDE is free during the beta and not signed by Microsoft. A file a browser # downloads is marked as from the internet, and SmartScreen then warns before it runs. A file # PowerShell downloads is not marked, so the installer runs without the warning. $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $downloads = if ($env:CLIDE_DOWNLOADS) { $env:CLIDE_DOWNLOADS } else { 'https://downloads.clide.tools' } $platform = 'win-x64' # Windows on ARM runs the x64 build. function Fail($message) { Write-Host "CLIDE install: $message" -ForegroundColor Red exit 1 } try { $latest = Invoke-RestMethod -Uri "$downloads/latest/latest.json?$([DateTimeOffset]::UtcNow.ToUnixTimeSeconds())" -UseBasicParsing } catch { Fail "could not reach $downloads" } $build = $latest.installers.$platform if (-not $build) { Fail "no CLIDE build for Windows yet" } # Each installer says which release it is from: platforms are published one at a time. $version = if ($build.version) { $build.version } else { $latest.version } # The terms: CLIDE asks people to agree to them when it first opens. Write-Host "CLIDE is beta software, provided as is, with no warranty. You use it at your own risk." Write-Host "By installing or using it, you agree to its Terms of Use (https://clide.tools/terms.html)" Write-Host "and Privacy Policy (https://clide.tools/privacy.html)." Write-Host "" $work = Join-Path ([IO.Path]::GetTempPath()) ("clide-" + [Guid]::NewGuid()) New-Item -ItemType Directory -Path $work | Out-Null try { $zip = Join-Path $work $build.file Write-Host "Downloading CLIDE $version..." Invoke-WebRequest -Uri "$downloads/latest/$($build.file)" -OutFile $zip -UseBasicParsing $got = (Get-FileHash -Algorithm SHA256 -Path $zip).Hash.ToLower() if ($got -ne $build.sha256) { Fail "the download's checksum does not match ($got, expected $($build.sha256)). Nothing was installed." } Expand-Archive -Path $zip -DestinationPath $work -Force $setup = Get-ChildItem -Path $work -Recurse -Filter '*Setup*.exe' | Select-Object -First 1 if (-not $setup) { Fail "no installer in the download" } Get-Process -Name 'CLIDE', 'launcher' -ErrorAction SilentlyContinue | Where-Object { $_.Path -like '*tools.clide*' } | ForEach-Object { Write-Host 'Closing CLIDE to replace it...'; $_.CloseMainWindow() | Out-Null; Start-Sleep -Seconds 2 } Write-Host "Installing CLIDE $version..." Start-Process -FilePath $setup.FullName -WorkingDirectory $setup.DirectoryName -Wait Write-Host "Installed CLIDE $version. Find it in the Start menu." } finally { Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue }