1
0

feat: Implement a user-approved shell command execution tool and a Windows installer script.

This commit is contained in:
2026-03-04 11:04:01 +01:00
parent b05e905dc4
commit 2b122a28c9
4 changed files with 57 additions and 2 deletions

39
installer.ps1 Normal file
View File

@@ -0,0 +1,39 @@
$ErrorActionPreference = "Stop"
Write-Host "Publishing project..."
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -o ./publish
Write-Host "Finding binary..."
$binary = Get-ChildItem -Path ./publish -Filter "anchor.exe" -File | Select-Object -First 1
if (-not $binary) {
Write-Host "Error: Could not find anchor.exe in ./publish" -ForegroundColor Red
exit 1
}
Write-Host "Found binary: $($binary.FullName)"
# Define the installation directory in the user's profile
$installDir = Join-Path $env:USERPROFILE ".anchor\bin"
if (-not (Test-Path $installDir)) {
Write-Host "Creating installation directory: $installDir"
New-Item -ItemType Directory -Path $installDir | Out-Null
}
Write-Host "Copying to $installDir..."
Copy-Item -Path $binary.FullName -Destination $installDir -Force
# Check if the installation directory is in the User PATH
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($userPath -split ';' -notcontains $installDir) {
Write-Host "Adding $installDir to User PATH..."
$newPath = if ($userPath) { "$userPath;$installDir" } else { $installDir }
[Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
Write-Host "PATH updated. You may need to restart your terminal for changes to take effect." -ForegroundColor Yellow
}
else {
Write-Host "$installDir is already in the PATH."
}
Write-Host "Installation complete!" -ForegroundColor Green