Private
Public Access
1
0

refactor: Claude Code 安装方式从官方原生脚本改为 npm install
Some checks failed
Deploy to Cloudflare Pages / deploy (push) Failing after 11s

国内用户无法访问 claude.ai/install.sh,统一三个工具的安装路径:
- 移除 setup.sh/ps1 中 Claude Code 的特殊安装分支
- ClaudeCode 独立脚本添加 Node.js/fnm 检测安装函数链
- 三个工具均使用 npm install -g 安装 (需要 Node.js >= 20)
- 更新 CLAUDE.md 和文档中的安装说明
This commit is contained in:
2026-02-28 19:38:00 +08:00
parent f1ab858212
commit 34c950057c
8 changed files with 521 additions and 115 deletions

View File

@@ -365,46 +365,25 @@ install_tool() {
info "安装 $tool_name..."
if [ "$tool_num" = "1" ]; then
# Claude Code: 使用官方原生安装脚本
local install_cmd="curl -fsSL https://claude.ai/install.sh | bash"
echo -e " 执行: ${CYAN}$install_cmd${NC}"
if bash -c 'set -o pipefail; curl -fsSL https://claude.ai/install.sh | bash'; then
export PATH="$HOME/.local/bin:$PATH"
hash -r 2>/dev/null || true
local tool_cmd=$(get_tool_cmd "$tool_num")
if command -v "$tool_cmd" >/dev/null 2>&1; then
success "$tool_name 安装成功!"
return 0
else
warning "$tool_name 可能已安装,但需要重新打开终端才能生效"
return 0
fi
# 所有工具统一使用 npm 安装 (需要 Node.js)
if ! ensure_node_environment; then
return 1
fi
local install_cmd="npm install -g $tool_pkg"
echo -e " 执行: ${CYAN}$install_cmd${NC}"
if eval "$install_cmd"; then
hash -r 2>/dev/null || true
local tool_cmd=$(get_tool_cmd "$tool_num")
if command -v "$tool_cmd" >/dev/null 2>&1; then
success "$tool_name 安装成功!"
return 0
else
error "$tool_name 安装失败 (请检查 https://claude.ai 是否可达)"
return 1
warning "$tool_name 可能已安装,但需要重新打开终端才能生效"
return 0
fi
else
# Gemini CLI / Codex: 使用 npm 安装 (需要 Node.js)
if ! ensure_node_environment; then
return 1
fi
local install_cmd="npm install -g $tool_pkg"
echo -e " 执行: ${CYAN}$install_cmd${NC}"
if eval "$install_cmd"; then
hash -r 2>/dev/null || true
local tool_cmd=$(get_tool_cmd "$tool_num")
if command -v "$tool_cmd" >/dev/null 2>&1; then
success "$tool_name 安装成功!"
return 0
else
warning "$tool_name 可能已安装,但需要重新打开终端才能生效"
return 0
fi
else
error "$tool_name 安装失败"
return 1
fi
error "$tool_name 安装失败"
return 1
fi
}
@@ -559,7 +538,7 @@ main() {
info "API 密钥: ${api_key:0:8}..."
echo ""
# Node.js 环境检查已移至 install_tool 内部 (仅 Gemini CLI / Codex 需要)
# Node.js 环境检查已移至 install_tool 内部 (三个工具均需要)
echo ""
echo -e "${CYAN}========================================${NC}"