-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
36 lines (36 loc) · 2.18 KB
/
Copy pathinstall.ps1
File metadata and controls
36 lines (36 loc) · 2.18 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
$ErrorActionPreference = "Stop"
$repo = if ($env:RAVEL_REPO) { $env:RAVEL_REPO } else { "12vault/ravel" }
$version = if ($env:RAVEL_VERSION) { $env:RAVEL_VERSION } else { "latest" }
$installDir = if ($env:RAVEL_INSTALL_DIR) { $env:RAVEL_INSTALL_DIR } else { Join-Path $HOME ".local\bin" }
$arch = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString()) {
"X64" { "amd64" }
"Arm64" { "arm64" }
default { throw "ravel: unsupported architecture" }
}
$base = if ($version -eq "latest") { "https://github.com/$repo/releases/latest/download" } else { "https://github.com/$repo/releases/download/$version" }
$asset = "ravel_windows_$arch.zip"
$tmp = Join-Path ([IO.Path]::GetTempPath()) ("ravel-" + [guid]::NewGuid())
New-Item -ItemType Directory -Path $tmp | Out-Null
try {
Invoke-WebRequest "$base/$asset" -OutFile (Join-Path $tmp $asset)
Invoke-WebRequest "$base/checksums.txt" -OutFile (Join-Path $tmp "checksums.txt")
$expected = ((Get-Content (Join-Path $tmp "checksums.txt")) | Where-Object { $_ -match " $([regex]::Escape($asset))$" }) -split " " | Select-Object -First 1
$actual = (Get-FileHash (Join-Path $tmp $asset) -Algorithm SHA256).Hash.ToLowerInvariant()
if (-not $expected -or $actual -ne $expected.ToLowerInvariant()) { throw "ravel: checksum verification failed" }
Expand-Archive (Join-Path $tmp $asset) -DestinationPath $tmp
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Copy-Item (Join-Path $tmp "ravel.exe") (Join-Path $installDir "ravel.exe") -Force
Write-Output "Installed ravel to $installDir\ravel.exe"
# The new binary refreshes only Ravel-owned skills and project instructions
# that were already installed. Fresh installations remain opt-in.
& (Join-Path $installDir "ravel.exe") version | Out-Null
$pathEntries = $env:Path -split [IO.Path]::PathSeparator
if ($pathEntries -notcontains $installDir) {
Write-Warning "$installDir is not on PATH."
Write-Output "Run this now:"
Write-Output (' $env:Path = "{0};$env:Path"' -f $installDir)
Write-Output 'Then add the same line to your PowerShell profile and open a new terminal.'
}
} finally {
Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
}