forked from RealZST/HarnessKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
46 lines (36 loc) · 1.52 KB
/
Copy pathinstall.ps1
File metadata and controls
46 lines (36 loc) · 1.52 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
# HarnessKit CLI installer for Windows — downloads the latest `hk` binary
# to ~/.local/bin. Re-run to update to the latest version.
#
# Usage:
# irm https://raw.githubusercontent.com/RealZST/HarnessKit/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
# Ensure TLS 1.2 (required by GitHub, not default on PowerShell 5.1)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Repo = "RealZST/HarnessKit"
$Binary = "hk-windows-x64.exe"
$InstallDir = Join-Path $env:USERPROFILE ".local\bin"
# Get latest release tag
$Headers = @{ "User-Agent" = "HarnessKit-Installer" }
$Release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest" -Headers $Headers
$Tag = $Release.tag_name
if (-not $Tag) {
Write-Error "Failed to fetch latest release"
exit 1
}
$Url = "https://github.com/$Repo/releases/download/$Tag/$Binary"
Write-Host "Installing HarnessKit CLI $Tag..."
# Download
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
$OutPath = Join-Path $InstallDir "hk.exe"
Invoke-WebRequest -Uri $Url -OutFile $OutPath -UseBasicParsing
Write-Host "Installed hk to $OutPath"
# Add to PATH if needed
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$InstallDir;$UserPath", "User")
Write-Host "Added $InstallDir to your PATH."
Write-Host ""
Write-Host "Restart your terminal for PATH changes to take effect."
}
Write-Host ""
Write-Host "Verify with: hk status"