forked from 1broseidon/cymbal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
51 lines (40 loc) · 1.74 KB
/
install.ps1
File metadata and controls
51 lines (40 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
45
46
47
48
49
50
51
#!/usr/bin/env pwsh
# Install cymbal on Windows.
# Usage: irm https://raw.githubusercontent.com/1broseidon/cymbal/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
$repo = "1broseidon/cymbal"
$installDir = "$env:LOCALAPPDATA\cymbal"
# Get latest release tag
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases/latest"
$tag = $release.tag_name
$version = $tag -replace '^v', ''
Write-Host "Installing cymbal $version ..." -ForegroundColor Cyan
# Download and extract
$asset = "cymbal_${tag}_windows_x86_64.zip"
$url = "https://github.com/$repo/releases/download/$tag/$asset"
$tmp = Join-Path $env:TEMP $asset
Invoke-WebRequest -Uri $url -OutFile $tmp
if (Test-Path $installDir) { Remove-Item -Recurse -Force $installDir }
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
Expand-Archive -Path $tmp -DestinationPath $installDir -Force
Remove-Item $tmp
# Verify binary exists
$bin = Join-Path $installDir "cymbal.exe"
if (-not (Test-Path $bin)) {
Write-Error "Failed to install: cymbal.exe not found in archive"
exit 1
}
# Record install metadata for update guidance.
$installMeta = Join-Path $installDir "install.json"
$meta = @{
install_type = "powershell"
} | ConvertTo-Json
Set-Content -Path $installMeta -Value $meta -Encoding UTF8
# Add to user PATH if not already present
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
[Environment]::SetEnvironmentVariable("Path", "$installDir;$userPath", "User")
Write-Host "Added $installDir to user PATH." -ForegroundColor Yellow
Write-Host "Restart your terminal for PATH changes to take effect." -ForegroundColor Yellow
}
Write-Host "cymbal $version installed to $installDir" -ForegroundColor Green