Files
unlimitedcoding/claude/uclaude_update.ps1
delta-cloud-208e bb708e5650 fix: Windows scripts check Node.js version, use winget OpenJS.NodeJS.V24
BAT and PS1 now detect if installed Node is < v24 and suggest/install
the correct v24 package instead of LTS (v22).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 14:04:36 +00:00

81 lines
2.7 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 v24+
$nodeOk = $false
if (Test-Command "node") {
$nodeVer = (node --version) -replace '^v', ''
$nodeMajor = [int]($nodeVer -split '\.')[0]
if ($nodeMajor -ge 24) {
$nodeOk = $true
} else {
Write-Host " Node.js v$nodeVer found, need v24+. Upgrading..." -ForegroundColor Yellow
}
} else {
Write-Host " Node.js not found." -ForegroundColor Yellow
}
if (-not $nodeOk) {
if (-not (Install-WithWinget "OpenJS.NodeJS.V24" "Node.js v24")) {
Write-Host " Install Node.js v24+ 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