feat: china-first openclaw install (npmmirror fallback to npmjs)

This commit is contained in:
2026-03-09 22:18:52 +08:00
parent ff9383f597
commit 4dcf1d6b3c
4 changed files with 57 additions and 9 deletions

View File

@@ -186,12 +186,27 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
# ─────────────────────────────────────────────
# Step 3: Install / Update OpenClaw
# China-first path: npmmirror → npmjs (if needed)
# ─────────────────────────────────────────────
Write-Info "Installing / updating OpenClaw..."
npm install -g openclaw@latest 2>&1 | Write-Host
if ($LASTEXITCODE -ne 0) {
Write-Err "OpenClaw installation failed. Please run manually: npm install -g openclaw@latest"
function Install-OpenClawByRegistry($registry) {
Write-Info "Trying npm install via $registry ..."
npm install -g openclaw@latest --registry=$registry 2>&1 | Write-Host
return ($LASTEXITCODE -eq 0)
}
$installedOpenClaw = $false
if (Install-OpenClawByRegistry "https://registry.npmmirror.com") {
Write-Ok "OpenClaw installed / updated via npmmirror."
$installedOpenClaw = $true
} elseif (Install-OpenClawByRegistry "https://registry.npmjs.org") {
Write-Ok "OpenClaw installed / updated via npm registry."
$installedOpenClaw = $true
}
if (-not $installedOpenClaw) {
Write-Err "OpenClaw installation failed: both npmmirror and npm registry are unavailable."
}
# Refresh PATH