#Requires -Version 5.1 <# .SYNOPSIS One-line installer for InstaDocs on Windows. .DESCRIPTION Downloads the latest InstaDocs Windows installer (Tauri/NSIS .exe) from https://get.appz.dev/instadocs and runs it. Honors: $env:IMAGEQC_VERSION -- pin to a specific tag (e.g. "0.9.1"); leave unset to install whatever the R2 'latest' pointer resolves to. $env:IMAGEQC_SILENT -- if "1", run the installer with /S (no UI, per-user install, no elevation needed). Default: shows the NSIS installer wizard. .EXAMPLE iex (irm https://get.appz.dev/instadocs/install.ps1) .EXAMPLE $env:IMAGEQC_VERSION = "0.9.1" iex (irm https://get.appz.dev/instadocs/install.ps1) .EXAMPLE $env:IMAGEQC_SILENT = "1" iex (irm https://get.appz.dev/instadocs/install.ps1) #> $ErrorActionPreference = "Stop" $BaseUrl = "https://get.appz.dev/instadocs" function Main { if ($PSVersionTable.PSVersion.Major -ge 6 -and -not $IsWindows) { Write-Error "InstaDocs is Windows-only. This script targets Windows." exit 1 } $Version = $env:IMAGEQC_VERSION if ($Version) { $Version = $Version -replace "^v","" } else { Write-Host "Fetching latest version from $BaseUrl/latest ..." try { $Version = (Invoke-RestMethod -Uri "$BaseUrl/latest" -UseBasicParsing).Trim() } catch { Write-Error "Failed to fetch latest version: $_" exit 1 } } $InstallerName = "instadocs-setup.exe" $Url = "$BaseUrl/v$Version/$InstallerName" $ShaUrl = "$Url.sha256" $TmpDir = Join-Path $env:TEMP "image-qc-install-$Version" $TmpFile = Join-Path $TmpDir $InstallerName $TmpSha = "$TmpFile.sha256" New-Item -ItemType Directory -Path $TmpDir -Force | Out-Null Write-Host "" Write-Host "Downloading InstaDocs v$Version ..." Write-Host " $Url" try { Invoke-WebRequest -Uri $Url -OutFile $TmpFile -UseBasicParsing } catch { Write-Error "Download failed: $Url`nCheck that v$Version exists." exit 1 } if (-not (Test-Path $TmpFile) -or (Get-Item $TmpFile).Length -lt 1MB) { Remove-Item -Path $TmpFile -ErrorAction SilentlyContinue Write-Error "Downloaded file looks empty/truncated." exit 1 } # SHA256 verification (best-effort -- skip silently if .sha256 missing) try { Invoke-WebRequest -Uri $ShaUrl -OutFile $TmpSha -UseBasicParsing $expected = (Get-Content $TmpSha -Raw).Trim().Split()[0] $actual = (Get-FileHash -Algorithm SHA256 $TmpFile).Hash.ToLower() if ($expected -ne $actual) { Write-Error "SHA256 mismatch.`n expected: $expected`n actual: $actual" exit 1 } Write-Host "SHA256 verified." } catch { Write-Host "(SHA256 check skipped -- $ShaUrl not reachable)" } Write-Host "" Write-Host "Running installer ..." # NSIS (Tauri's bundler), not Inno Setup -- /S is the silent flag, and # the install is per-user (no UAC elevation, unlike the legacy Inno # Setup installer's /VERYSILENT /SUPPRESSMSGBOXES /NORESTART). $silent = $env:IMAGEQC_SILENT -eq "1" if ($silent) { $proc = Start-Process -FilePath $TmpFile -ArgumentList @("/S") -Wait -PassThru } else { $proc = Start-Process -FilePath $TmpFile -Wait -PassThru } if ($proc.ExitCode -ne 0) { Write-Error "Installer exited with code $($proc.ExitCode)." exit $proc.ExitCode } Write-Host "" Write-Host "InstaDocs v$Version installed." Write-Host "Launch from Start Menu: 'InstaDocs'" } Main