feat: china-first openclaw install (npmmirror fallback to npmjs)
This commit is contained in:
@@ -89,14 +89,31 @@ fi
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 2: 安装 / 更新 OpenClaw
|
||||
# 国内网络优先:npmmirror → npmjs(必要时)
|
||||
# ─────────────────────────────────────────────
|
||||
info "正在安装 / 更新 OpenClaw..."
|
||||
|
||||
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard
|
||||
success "OpenClaw 安装 / 更新完成。"
|
||||
install_openclaw_with_registry() {
|
||||
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 中
|
||||
export PATH="$HOME/.openclaw/bin:$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"
|
||||
fi
|
||||
|
||||
if ! command -v openclaw &>/dev/null; then
|
||||
error "OpenClaw 安装失败 — 在 PATH 中找不到 'openclaw'。请尝试重启终端后再次运行此脚本。"
|
||||
|
||||
Reference in New Issue
Block a user