#!/usr/bin/env pwsh # A simple Powershell script to download and install the Gel CLI. # # Copyright 2021-present Gel Data Inc. and the Gel authors. # Licensed under the Apache License, Version 2.0 (the "License"); &{ # Bail immediately on any error. $ErrorActionPreference = 'Stop' # Prevent the pointless progress overlay produced by iwr. $ProgressPreference = 'SilentlyContinue' # Ensure proper transport security. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 function Get-OSArch { switch ($env:PROCESSOR_ARCHITECTURE) { "AMD64" { "x86_64" } "ARM64" { "aarch64" } default { throw "Detected processor architecture ($env:PROCESSOR_ARCHITECTURE) is not currently supported by Gel CLI" } } } $BaseUrl = "https://packages.geldata.com/dist" $DistArch = Get-OSArch If ($Channel -eq $null) { $DistSuf = "" } Else { $DistSuf = ".$Channel" } $DownloadUrl = "$BaseUrl/${DistArch}-pc-windows-msvc${DistSuf}/gel-cli.exe" Write-Output "Downloading installer..." $TempRoot = [System.IO.Path]::GetTempPath() $TempStem = [System.IO.Path]::GetRandomFileName() $TempDir = Join-Path $TempRoot $TempStem $CliExe = Join-Path $TempDir "gel-init.exe" New-Item $TempDir -ItemType Directory | Out-Null Invoke-WebRequest $DownloadUrl -OutFile $CliExe -UseBasicParsing Start-Process $CliExe -ArgumentList "--no-wait-for-exit-prompt" -NoNewWindow -Wait # Make PATH modifications actual in current session. $User = [EnvironmentVariableTarget]::User $Path = [Environment]::GetEnvironmentVariable('Path', $User) $Env:Path += ";$Path" }