feat: china-first openclaw install (npmmirror fallback to npmjs)
This commit is contained in:
@@ -53,6 +53,7 @@ iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branc
|
|||||||
- 默认跳过搜索提供商配置(`--skip-search`)
|
- 默认跳过搜索提供商配置(`--skip-search`)
|
||||||
- 默认跳过渠道配置(`--skip-channels`)
|
- 默认跳过渠道配置(`--skip-channels`)
|
||||||
- 默认跳过 Skills 配置(`--skip-skills`)
|
- 默认跳过 Skills 配置(`--skip-skills`)
|
||||||
|
- OpenClaw 安装优先走 `npmmirror`,失败后回退 `npmjs`(更适合国内网络)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -89,14 +89,31 @@ fi
|
|||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 2: 安装 / 更新 OpenClaw
|
# 步骤 2: 安装 / 更新 OpenClaw
|
||||||
|
# 国内网络优先:npmmirror → npmjs(必要时)
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
info "正在安装 / 更新 OpenClaw..."
|
info "正在安装 / 更新 OpenClaw..."
|
||||||
|
|
||||||
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard
|
install_openclaw_with_registry() {
|
||||||
success "OpenClaw 安装 / 更新完成。"
|
local registry="$1"
|
||||||
|
info "尝试通过 npm 安装 OpenClaw($registry)..."
|
||||||
|
npm install -g openclaw@latest --registry="$registry"
|
||||||
|
}
|
||||||
|
|
||||||
|
if install_openclaw_with_registry "https://registry.npmmirror.com"; then
|
||||||
|
success "已通过 npmmirror 安装 / 更新 OpenClaw。"
|
||||||
|
elif install_openclaw_with_registry "https://registry.npmjs.org"; then
|
||||||
|
success "已通过 npm 官方源安装 / 更新 OpenClaw。"
|
||||||
|
else
|
||||||
|
error "OpenClaw 安装失败:npmmirror 与 npm 官方源均不可用。"
|
||||||
|
fi
|
||||||
|
|
||||||
# 确保 openclaw 在 PATH 中
|
# 确保 openclaw 在 PATH 中
|
||||||
|
NPM_PREFIX=$(npm config get prefix 2>/dev/null || true)
|
||||||
|
if [[ -n "$NPM_PREFIX" ]]; then
|
||||||
|
export PATH="$NPM_PREFIX/bin:$HOME/.openclaw/bin:$PATH"
|
||||||
|
else
|
||||||
export PATH="$HOME/.openclaw/bin:$PATH"
|
export PATH="$HOME/.openclaw/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! command -v openclaw &>/dev/null; then
|
if ! command -v openclaw &>/dev/null; then
|
||||||
error "OpenClaw 安装失败 — 在 PATH 中找不到 'openclaw'。请尝试重启终端后再次运行此脚本。"
|
error "OpenClaw 安装失败 — 在 PATH 中找不到 'openclaw'。请尝试重启终端后再次运行此脚本。"
|
||||||
|
|||||||
@@ -186,12 +186,27 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
|
|||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# Step 3: Install / Update OpenClaw
|
# Step 3: Install / Update OpenClaw
|
||||||
|
# China-first path: npmmirror → npmjs (if needed)
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
Write-Info "Installing / updating OpenClaw..."
|
Write-Info "Installing / updating OpenClaw..."
|
||||||
|
|
||||||
npm install -g openclaw@latest 2>&1 | Write-Host
|
function Install-OpenClawByRegistry($registry) {
|
||||||
if ($LASTEXITCODE -ne 0) {
|
Write-Info "Trying npm install via $registry ..."
|
||||||
Write-Err "OpenClaw installation failed. Please run manually: npm install -g openclaw@latest"
|
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
|
# Refresh PATH
|
||||||
|
|||||||
@@ -187,12 +187,27 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
|
|||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 3: 安装 / 更新 OpenClaw
|
# 步骤 3: 安装 / 更新 OpenClaw
|
||||||
|
# 国内网络优先:npmmirror → npmjs(必要时)
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
Write-Info "正在安装 / 更新 OpenClaw..."
|
Write-Info "正在安装 / 更新 OpenClaw..."
|
||||||
|
|
||||||
npm install -g openclaw@latest 2>&1 | Write-Host
|
function Install-OpenClawByRegistry($registry) {
|
||||||
if ($LASTEXITCODE -ne 0) {
|
Write-Info "尝试通过 npm 安装 OpenClaw($registry)..."
|
||||||
Write-Err "OpenClaw 安装失败。请手动运行:npm install -g openclaw@latest"
|
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 "已通过 npmmirror 安装 / 更新 OpenClaw。"
|
||||||
|
$installedOpenClaw = $true
|
||||||
|
} elseif (Install-OpenClawByRegistry "https://registry.npmjs.org") {
|
||||||
|
Write-Ok "已通过 npm 官方源安装 / 更新 OpenClaw。"
|
||||||
|
$installedOpenClaw = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $installedOpenClaw) {
|
||||||
|
Write-Err "OpenClaw 安装失败:npmmirror 与 npm 官方源均不可用。"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 刷新 PATH
|
# 刷新 PATH
|
||||||
|
|||||||
Reference in New Issue
Block a user