# InfiniteCLI installer for Windows (PowerShell 5.1+ or pwsh). # # irm https://nexus-applications.com/cli/install.ps1 | iex # # Downloads the release tarball, checks its SHA-256, and installs it with # `npm install -g`. Needs Node.js 20+ and npm. Environment overrides: # INFINITECLI_VERSION install another published version (no checksum pin) # INFINITECLI_BASE_URL download from another location # This file is a template: scripts/release.mjs fills in the __PLACEHOLDERS__. # It runs inside a script block and throws instead of calling exit, so piping # it to iex never closes the caller's shell or leaks variables into it. & { $ErrorActionPreference = 'Stop' $BuiltVersion = '0.1.1' $BuiltSha256 = '134a18f7b91a8315d1e15b6c9a57fc87d3cb1d6270e04d9119945dbb76bdefe4' $Version = if ($env:INFINITECLI_VERSION) { $env:INFINITECLI_VERSION } else { $BuiltVersion } $BaseUrl = if ($env:INFINITECLI_BASE_URL) { $env:INFINITECLI_BASE_URL } else { 'https://nexus-applications.com/cli' } if (-not (Get-Command node -ErrorAction SilentlyContinue)) { throw 'infinitecli: Node.js 20 or newer is required: https://nodejs.org' } if (-not (Get-Command npm -ErrorAction SilentlyContinue)) { throw 'infinitecli: npm is required (it ships with Node.js).' } $major = [int](& node -p "process.versions.node.split('.')[0]") if ($major -lt 20) { throw "infinitecli: Node.js 20 or newer is required; found $(& node -v)." } $tmp = Join-Path ([IO.Path]::GetTempPath()) ("infinitecli-" + [guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp | Out-Null try { $file = Join-Path $tmp "infinitecli-$Version.tgz" $url = "$BaseUrl/infinitecli-$Version.tgz" Write-Host "infinitecli: downloading $url" # Windows PowerShell 5.1 may default to TLS 1.0; make sure 1.2 is allowed. [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $file if ($Version -eq $BuiltVersion) { $actual = (Get-FileHash -Algorithm SHA256 -Path $file).Hash.ToLowerInvariant() if ($actual -ne $BuiltSha256) { throw "infinitecli: checksum mismatch (expected $BuiltSha256, got $actual). Not installing." } Write-Host 'infinitecli: checksum ok' } else { Write-Host "infinitecli: version $Version was requested; this installer can only pin $BuiltVersion, so the checksum is not checked" } & npm install -g $file if ($LASTEXITCODE -ne 0) { throw "infinitecli: npm install -g failed (exit $LASTEXITCODE)." } } finally { Remove-Item -Recurse -Force -Path $tmp -ErrorAction SilentlyContinue } Write-Host "infinitecli: installed $Version. Run: infinitecli (check setup with: infinitecli doctor)" if (-not (Get-Command infinitecli -ErrorAction SilentlyContinue)) { Write-Host "infinitecli: note: open a new terminal if infinitecli is not found; npm's global bin is $(& npm prefix -g)" } }