# Utah IDE installer for Windows (PowerShell 5.1 or newer). # irm https://aithatsee.com/utah/ide/install.ps1 | iex # Installs into your user profile only. The download is checked against a pinned SHA-256. $ErrorActionPreference = 'Stop' $Version = '0.1.1' $Url = 'https://aithatsee.com/utah/ide/utah-ide-0.1.1.tgz' $Sha256 = 'df260e62c9496f23496338ae36bb186ee855e7b33930cf53eb71dc3117b5f266' $InstallRoot = if ($env:UTAH_IDE_INSTALL_DIR) { $env:UTAH_IDE_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'UtahIDE' } $BinDir = if ($env:UTAH_IDE_BIN_DIR) { $env:UTAH_IDE_BIN_DIR } else { Join-Path $InstallRoot 'bin' } function Fail($Message) { Write-Error "Utah IDE install failed: $Message"; exit 1 } $node = Get-Command node -ErrorAction SilentlyContinue if (-not $node) { Fail 'Node.js 22.13 or newer is required and was not found. Install it from https://nodejs.org and run this again.' } # Compared here, not in an inline node script: Windows PowerShell 5.1 strips double quotes from # arguments passed to programs, which silently breaks any JavaScript that contains them. $NodeVersion = (& node --version).Trim().TrimStart('v') $Parts = $NodeVersion.Split('.') $NodeOk = ([int]$Parts[0] -gt 22) -or (([int]$Parts[0] -eq 22) -and ([int]$Parts[1] -ge 13)) if (-not $NodeOk) { Fail "Node.js 22.13 or newer is required; found v$NodeVersion." } if (-not (Get-Command tar -ErrorAction SilentlyContinue)) { Fail 'tar is required (it ships with Windows 10 1803 and newer).' } $Temp = Join-Path ([IO.Path]::GetTempPath()) ("utah-ide-" + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $Temp | Out-Null try { $Archive = Join-Path $Temp 'package.tgz' Write-Host "Downloading Utah IDE $Version..." [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -Uri $Url -OutFile $Archive -UseBasicParsing $Got = (Get-FileHash -Algorithm SHA256 -Path $Archive).Hash.ToLowerInvariant() if ($Got -ne $Sha256) { Fail "checksum mismatch (expected $Sha256, got $Got). Nothing was installed." } $Target = Join-Path $InstallRoot $Version $Stage = Join-Path $InstallRoot (".staging-" + $PID) if (Test-Path $Stage) { Remove-Item -Recurse -Force $Stage } New-Item -ItemType Directory -Force -Path $Stage, $BinDir | Out-Null & tar -xzf $Archive -C $Stage --strip-components 1 if ($LASTEXITCODE -ne 0) { Fail 'could not unpack the download.' } if (-not (Test-Path (Join-Path $Stage 'bin\utah-ide.mjs'))) { Fail 'the download is not an Utah IDE package.' } if (Test-Path $Target) { Remove-Item -Recurse -Force $Target } Move-Item $Stage $Target $Launcher = Join-Path $BinDir 'utah-ide.cmd' Set-Content -Path $Launcher -Encoding ASCII -Value "@echo off`r`nnode `"$Target\bin\utah-ide.mjs`" %*" $Installed = & $Launcher --version if ($Installed -ne $Version) { Fail "the installed copy did not start (got '$Installed')." } Get-ChildItem -Directory $InstallRoot | Where-Object { $_.FullName -ne $Target -and $_.FullName -ne $BinDir } | Remove-Item -Recurse -Force $UserPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (($UserPath -split ';') -notcontains $BinDir) { [Environment]::SetEnvironmentVariable('Path', ($UserPath.TrimEnd(';') + ';' + $BinDir), 'User') Write-Host "Added $BinDir to your PATH. Open a new terminal to use it." } Write-Host "Utah IDE $Version is installed: $Launcher" Write-Host '' Write-Host 'Next:' Write-Host ' utah-ide login sign in' Write-Host ' utah-ide doctor check this machine' Write-Host ' utah-ide start in the current project' if (-not (Get-Command git -ErrorAction SilentlyContinue)) { Write-Host '' Write-Host 'Git for Windows was not found. Utah IDE runs commands in its bash; without it, commands written for bash fail.' Write-Host 'Install it from https://git-scm.com/download/win, then run: utah-ide doctor' } } finally { Remove-Item -Recurse -Force $Temp -ErrorAction SilentlyContinue }