feat: merge install/uninstall into one interactive entrypoint
This commit is contained in:
10
README.md
10
README.md
@@ -25,7 +25,12 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 快速安装
|
## 统一入口(安装 / 卸载)
|
||||||
|
|
||||||
|
> 运行脚本后会先弹出菜单,让用户选择:
|
||||||
|
> 1) 安装 / 更新
|
||||||
|
> 2) 卸载
|
||||||
|
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
@@ -106,7 +111,8 @@ iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branc
|
|||||||
|
|
||||||
## 卸载
|
## 卸载
|
||||||
|
|
||||||
> 已对齐当前安装方式:Windows 卸载脚本会按“原生 Windows 安装”路径执行卸载。
|
> 推荐直接运行上面的“统一入口”脚本,然后选择 **2) 卸载**。
|
||||||
|
> 下面保留独立卸载命令,方便自动化或批量操作。
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,24 @@ header() {
|
|||||||
|
|
||||||
header
|
header
|
||||||
|
|
||||||
|
echo -e "${BOLD}请选择操作:${NC}"
|
||||||
|
echo " 1) 安装 / 更新 OpenClaw"
|
||||||
|
echo " 2) 卸载 OpenClaw"
|
||||||
|
read -r -p "请输入选项 [1/2](默认 1): " ACTION
|
||||||
|
ACTION=${ACTION:-1}
|
||||||
|
|
||||||
|
if [[ "$ACTION" == "2" ]]; then
|
||||||
|
info "你选择了:卸载 OpenClaw"
|
||||||
|
if command -v openclaw &>/dev/null; then
|
||||||
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
else
|
||||||
|
warn "在 PATH 中未找到 openclaw,尝试使用 npx 卸载..."
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
|
fi
|
||||||
|
success "OpenClaw 已卸载。"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 1: 检查 / 安装 Node 22+
|
# 步骤 1: 检查 / 安装 Node 22+
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
|
|||||||
@@ -20,6 +20,48 @@ try {
|
|||||||
|
|
||||||
Write-Header
|
Write-Header
|
||||||
|
|
||||||
|
Write-Host "Choose an action:" -ForegroundColor White
|
||||||
|
Write-Host " 1) Install / Update OpenClaw" -ForegroundColor Gray
|
||||||
|
Write-Host " 2) Uninstall OpenClaw" -ForegroundColor Gray
|
||||||
|
$action = Read-Host "Enter [1/2] (default: 1)"
|
||||||
|
if ([string]::IsNullOrWhiteSpace($action)) { $action = "1" }
|
||||||
|
|
||||||
|
if ($action -eq "2") {
|
||||||
|
Write-Info "You chose: uninstall OpenClaw"
|
||||||
|
|
||||||
|
$uninstalled = $false
|
||||||
|
|
||||||
|
if (Get-Command openclaw -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
} catch {
|
||||||
|
Write-Warn "openclaw uninstall failed, trying npx..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $uninstalled -and (Get-Command npx -ErrorAction SilentlyContinue)) {
|
||||||
|
try {
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
} catch {
|
||||||
|
Write-Warn "npx uninstall failed."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
||||||
|
try { npm uninstall -g openclaw 2>$null | Out-Null } catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($uninstalled) {
|
||||||
|
Write-Ok "OpenClaw uninstalled."
|
||||||
|
} else {
|
||||||
|
Write-Err "Failed to uninstall OpenClaw. Please ensure Node.js/npm is available and retry."
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# Step 1: Check / Install Node.js 22+
|
# Step 1: Check / Install Node.js 22+
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
|
|||||||
@@ -20,6 +20,48 @@ try {
|
|||||||
|
|
||||||
Write-Header
|
Write-Header
|
||||||
|
|
||||||
|
Write-Host "请选择操作:" -ForegroundColor White
|
||||||
|
Write-Host " 1) 安装 / 更新 OpenClaw" -ForegroundColor Gray
|
||||||
|
Write-Host " 2) 卸载 OpenClaw" -ForegroundColor Gray
|
||||||
|
$action = Read-Host "请输入选项 [1/2](默认 1)"
|
||||||
|
if ([string]::IsNullOrWhiteSpace($action)) { $action = "1" }
|
||||||
|
|
||||||
|
if ($action -eq "2") {
|
||||||
|
Write-Info "你选择了:卸载 OpenClaw"
|
||||||
|
|
||||||
|
$uninstalled = $false
|
||||||
|
|
||||||
|
if (Get-Command openclaw -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
} catch {
|
||||||
|
Write-Warn "openclaw 卸载失败,尝试 npx 方式..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $uninstalled -and (Get-Command npx -ErrorAction SilentlyContinue)) {
|
||||||
|
try {
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
} catch {
|
||||||
|
Write-Warn "npx 卸载失败。"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
||||||
|
try { npm uninstall -g openclaw 2>$null | Out-Null } catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($uninstalled) {
|
||||||
|
Write-Ok "OpenClaw 已卸载。"
|
||||||
|
} else {
|
||||||
|
Write-Err "未能完成 OpenClaw 卸载。请确认 Node.js/npm 可用后重试。"
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 1: 检查 / 安装 Node.js 22+
|
# 步骤 1: 检查 / 安装 Node.js 22+
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user