refactor: Claude Code 安装方式从官方原生脚本改为 npm install
Some checks failed
Deploy to Cloudflare Pages / deploy (push) Failing after 11s
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:
80
setup.ps1
80
setup.ps1
@@ -216,64 +216,38 @@ function Install-Tool {
|
||||
[hashtable]$Tool
|
||||
)
|
||||
|
||||
if ($Tool.Command -eq "claude") {
|
||||
# Claude Code: 使用官方原生安装脚本
|
||||
Write-Info "使用官方安装脚本安装 $($Tool.Name)..."
|
||||
Write-Host " 执行: irm https://claude.ai/install.ps1 | iex" -ForegroundColor Gray
|
||||
# 所有工具统一使用 npm 安装 (需要 Node.js)
|
||||
if (-not (Ensure-NodeEnvironment)) {
|
||||
return $false
|
||||
}
|
||||
|
||||
try {
|
||||
Invoke-Expression "& { $(Invoke-RestMethod https://claude.ai/install.ps1) }"
|
||||
Refresh-Path
|
||||
Write-Info "使用 npm 安装 $($Tool.Name)..."
|
||||
$installCmd = "npm install -g $($Tool.Package)"
|
||||
Write-Host " 执行: $installCmd" -ForegroundColor Gray
|
||||
|
||||
if (Test-Command $Tool.Command) {
|
||||
Write-Success "$($Tool.Name) 安装成功!"
|
||||
return $true
|
||||
}
|
||||
else {
|
||||
Write-Warning "$($Tool.Name) 可能已安装,但需要重新打开终端才能生效"
|
||||
$continue = Read-Host "是否继续进行配置? (Y/n)"
|
||||
return ($continue -ne "n" -and $continue -ne "N")
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "安装失败: $($_.Exception.Message)"
|
||||
try {
|
||||
Invoke-Expression $installCmd
|
||||
$exitCode = $LASTEXITCODE
|
||||
Refresh-Path
|
||||
|
||||
if ($exitCode -ne 0) {
|
||||
Write-Error "安装命令返回错误码: $exitCode"
|
||||
return $false
|
||||
}
|
||||
|
||||
if (Test-Command $Tool.Command) {
|
||||
Write-Success "$($Tool.Name) 安装成功!"
|
||||
return $true
|
||||
}
|
||||
else {
|
||||
Write-Warning "$($Tool.Name) 可能已安装,但需要重新打开终端才能生效"
|
||||
$continue = Read-Host "是否继续进行配置? (Y/n)"
|
||||
return ($continue -ne "n" -and $continue -ne "N")
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Gemini CLI / Codex: 使用 npm 安装 (需要 Node.js)
|
||||
if (-not (Ensure-NodeEnvironment)) {
|
||||
return $false
|
||||
}
|
||||
|
||||
Write-Info "使用 npm 安装 $($Tool.Name)..."
|
||||
$installCmd = "npm install -g $($Tool.Package)"
|
||||
Write-Host " 执行: $installCmd" -ForegroundColor Gray
|
||||
|
||||
try {
|
||||
Invoke-Expression $installCmd
|
||||
$exitCode = $LASTEXITCODE
|
||||
Refresh-Path
|
||||
|
||||
if ($exitCode -ne 0) {
|
||||
Write-Error "安装命令返回错误码: $exitCode"
|
||||
return $false
|
||||
}
|
||||
|
||||
if (Test-Command $Tool.Command) {
|
||||
Write-Success "$($Tool.Name) 安装成功!"
|
||||
return $true
|
||||
}
|
||||
else {
|
||||
Write-Warning "$($Tool.Name) 可能已安装,但需要重新打开终端才能生效"
|
||||
$continue = Read-Host "是否继续进行配置? (Y/n)"
|
||||
return ($continue -ne "n" -and $continue -ne "N")
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "安装失败: $($_.Exception.Message)"
|
||||
return $false
|
||||
}
|
||||
catch {
|
||||
Write-Error "安装失败: $($_.Exception.Message)"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user