-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
89 lines (77 loc) · 2.86 KB
/
install.ps1
File metadata and controls
89 lines (77 loc) · 2.86 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# clibridge4unity installer for Windows
# Usage: irm https://raw.githubusercontent.com/oddgames/clibridge4unity/main/install.ps1 | iex
# or: .\install.ps1 # install latest
# or: .\install.ps1 -Version 1.0.69 # install specific version
param(
[string]$Version = "",
[string]$InstallDir = "$env:USERPROFILE\.clibridge4unity"
)
$ErrorActionPreference = "Stop"
$repo = "oddgames/clibridge4unity"
Write-Host "clibridge4unity installer" -ForegroundColor Cyan
Write-Host ""
# Determine version
if (-not $Version) {
Write-Host "Fetching latest release..."
try {
$release = Invoke-RestMethod "https://api.github.com/repos/$repo/releases/latest"
$Version = $release.tag_name -replace '^v', ''
} catch {
Write-Host "Error: Could not fetch latest release from GitHub." -ForegroundColor Red
Write-Host " Check your internet connection or specify -Version manually."
exit 1
}
}
$tag = "v$Version"
$asset = "clibridge4unity-win-x64.zip"
$downloadUrl = "https://github.com/$repo/releases/download/$tag/$asset"
Write-Host "Version: $Version"
Write-Host "Install: $InstallDir"
Write-Host ""
# Create install directory
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
# Download
$zipPath = Join-Path $env:TEMP "clibridge4unity-$Version.zip"
Write-Host "Downloading $asset..."
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing
} catch {
Write-Host "Error: Download failed." -ForegroundColor Red
Write-Host " URL: $downloadUrl"
Write-Host " Ensure release '$tag' exists with asset '$asset'."
exit 1
}
# Extract
Write-Host "Extracting..."
Expand-Archive -Path $zipPath -DestinationPath $InstallDir -Force
Remove-Item $zipPath -Force
# Verify
$exePath = Join-Path $InstallDir "clibridge4unity.exe"
if (-not (Test-Path $exePath)) {
Write-Host "Error: clibridge4unity.exe not found after extraction." -ForegroundColor Red
exit 1
}
# Add to PATH if not already there
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$InstallDir*") {
Write-Host "Adding to PATH..."
[Environment]::SetEnvironmentVariable("Path", "$InstallDir;$userPath", "User")
$env:Path = "$InstallDir;$env:Path"
Write-Host " Added $InstallDir to user PATH" -ForegroundColor Green
} else {
Write-Host " Already in PATH" -ForegroundColor Green
}
# Verify installation
Write-Host ""
& $exePath --version
Write-Host ""
Write-Host "Installation complete!" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Cyan
Write-Host " 1. Open a new terminal (for PATH changes)"
Write-Host " 2. cd to your Unity project"
Write-Host " 3. Run: clibridge4unity SETUP"
Write-Host ""
Write-Host "This will install the Unity package and set up CLAUDE.md for your project."