Files
unlimitedcoding/claude/uclaude_update.ps1
delta-cloud-208e 6479aacfd4 feat: full auto-install chain for all platforms
- Wire ensure_claude_code() into cmd_update() — auto npm install if missing
- uclaude_install.sh: auto-install git, python3, curl via apt/dnf/yum/brew
- uclaude_update.bat: prereq checks with winget install suggestions
- uclaude_update.ps1: auto-install via winget (git, python, node)
- install_node(): macOS support via brew, RHEL/Fedora via rpm.nodesource
- Increased npm install timeout to 300s for slow connections
2026-02-21 11:58:33 +00:00

70 lines
2.4 KiB
PowerShell

# UClaude Updater — automatic Claude Code patch updater
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_update.ps1 [--check] [--force] [--settings-only]
$ErrorActionPreference = "Continue"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRoot = Split-Path -Parent $ScriptDir
Set-Location $RepoRoot
# ---- Check prerequisites ----
function Test-Command($cmd) {
return [bool](Get-Command $cmd -ErrorAction SilentlyContinue)
}
function Install-WithWinget($id, $name) {
if (Test-Command "winget") {
Write-Host " Installing $name via winget..." -ForegroundColor Yellow
winget install --id $id --accept-package-agreements --accept-source-agreements -e
# Refresh PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
return $true
}
return $false
}
# Git
if (-not (Test-Command "git")) {
Write-Host " git not found." -ForegroundColor Red
if (-not (Install-WithWinget "Git.Git" "Git")) {
Write-Host " Install manually: https://git-scm.com/download/win" -ForegroundColor Yellow
exit 1
}
}
# Python
$hasPython = (Test-Command "python3") -or (Test-Command "python")
if (-not $hasPython) {
Write-Host " Python not found." -ForegroundColor Red
if (-not (Install-WithWinget "Python.Python.3.12" "Python 3.12")) {
Write-Host " Install manually: https://www.python.org/downloads/" -ForegroundColor Yellow
exit 1
}
}
# Node.js
if (-not (Test-Command "node")) {
Write-Host " Node.js not found." -ForegroundColor Yellow
if (-not (Install-WithWinget "OpenJS.NodeJS" "Node.js")) {
Write-Host " Install manually: https://nodejs.org/" -ForegroundColor Yellow
}
}
# ---- Pull latest artifacts ----
git pull --quiet 2>$null
# ---- Check admin ----
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "Re-running as Administrator..." -ForegroundColor Yellow
Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`" $args" -Verb RunAs
exit
}
# ---- Run updater ----
$pythonCmd = if (Test-Command "python3") { "python3" } else { "python" }
& $pythonCmd claude\uclaude_updater.py @args