mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
fix: improve environment detection and error handling in remote installers
- Add git availability check with helpful installation hints - Improve version detection with automatic fallback to GitHub API - Add detailed progress feedback during installation - Enhance error messages for better user experience - Fix WSL installation issue reported in #1 Changes: - install-remote.sh: Add git check, improve commit SHA detection - install-remote.ps1: Add git check, improve commit SHA detection Fixes #1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -127,17 +127,36 @@ function Test-Prerequisites {
|
||||
Write-ColorOutput "Current version: $($PSVersionTable.PSVersion)" $ColorError
|
||||
return $false
|
||||
}
|
||||
|
||||
|
||||
# Check for optional but recommended commands
|
||||
$gitAvailable = $false
|
||||
try {
|
||||
$gitVersion = git --version 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-ColorOutput "✓ Git available" $ColorSuccess
|
||||
$gitAvailable = $true
|
||||
}
|
||||
} catch {
|
||||
# Git not found
|
||||
}
|
||||
|
||||
if (-not $gitAvailable) {
|
||||
Write-ColorOutput "WARNING: 'git' not found - version detection may be limited" $ColorWarning
|
||||
Write-ColorOutput "Hint: Install Git for Windows for better version tracking" $ColorInfo
|
||||
Write-ColorOutput " Download from: https://git-scm.com/download/win" $ColorInfo
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# Test internet connectivity
|
||||
try {
|
||||
$null = Invoke-WebRequest -Uri "https://github.com" -Method Head -TimeoutSec 10 -UseBasicParsing
|
||||
Write-ColorOutput "Network connection OK" $ColorSuccess
|
||||
Write-ColorOutput "✓ Network connection OK" $ColorSuccess
|
||||
} catch {
|
||||
Write-ColorOutput "ERROR: Cannot connect to GitHub" $ColorError
|
||||
Write-ColorOutput "Please check your network connection: $($_.Exception.Message)" $ColorError
|
||||
return $false
|
||||
}
|
||||
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
@@ -566,20 +585,52 @@ function Main {
|
||||
|
||||
# Get commit SHA from the downloaded repository first
|
||||
$commitSha = ""
|
||||
Write-ColorOutput "Detecting version information..." $ColorInfo
|
||||
|
||||
# Try to get from git repository if git is available
|
||||
$gitAvailable = $false
|
||||
try {
|
||||
Push-Location $repoDir
|
||||
$commitSha = (git rev-parse --short HEAD 2>$null)
|
||||
if (-not $commitSha) {
|
||||
# Fallback: try to get from GitHub API
|
||||
$null = git --version 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$gitAvailable = $true
|
||||
}
|
||||
} catch {
|
||||
# Git not available
|
||||
}
|
||||
|
||||
if ($gitAvailable) {
|
||||
try {
|
||||
Push-Location $repoDir
|
||||
$commitSha = (git rev-parse --short HEAD 2>$null)
|
||||
Pop-Location
|
||||
|
||||
if ($commitSha) {
|
||||
Write-ColorOutput "✓ Version detected from git: $commitSha" $ColorSuccess
|
||||
}
|
||||
} catch {
|
||||
Pop-Location
|
||||
# Continue to fallback
|
||||
}
|
||||
}
|
||||
|
||||
# Fallback: try to get from GitHub API
|
||||
if (-not $commitSha) {
|
||||
try {
|
||||
Write-ColorOutput "Fetching version from GitHub API..." $ColorInfo
|
||||
$commitUrl = "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/$Branch"
|
||||
$commitResponse = Invoke-RestMethod -Uri $commitUrl -UseBasicParsing -TimeoutSec 5 -ErrorAction SilentlyContinue
|
||||
$commitResponse = Invoke-RestMethod -Uri $commitUrl -UseBasicParsing -TimeoutSec 10 -ErrorAction Stop
|
||||
|
||||
if ($commitResponse.sha) {
|
||||
$commitSha = $commitResponse.sha.Substring(0, 7)
|
||||
Write-ColorOutput "✓ Version detected from API: $commitSha" $ColorSuccess
|
||||
}
|
||||
} catch {
|
||||
Write-ColorOutput "WARNING: Could not detect version, using 'unknown'" $ColorWarning
|
||||
$commitSha = "unknown"
|
||||
}
|
||||
Pop-Location
|
||||
} catch {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
if (-not $commitSha) {
|
||||
$commitSha = "unknown"
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,17 @@ function test_prerequisites() {
|
||||
fi
|
||||
done
|
||||
|
||||
# Check for optional but recommended commands
|
||||
if ! command -v git &> /dev/null; then
|
||||
write_color "WARNING: 'git' not found - version detection may be limited" "$COLOR_WARNING"
|
||||
write_color "Hint: Install git for better version tracking" "$COLOR_INFO"
|
||||
write_color " On Ubuntu/Debian: sudo apt-get install git" "$COLOR_INFO"
|
||||
write_color " On WSL: sudo apt-get update && sudo apt-get install git" "$COLOR_INFO"
|
||||
echo ""
|
||||
else
|
||||
write_color "✓ Git available" "$COLOR_SUCCESS"
|
||||
fi
|
||||
|
||||
# Test internet connectivity
|
||||
if curl -sSf --connect-timeout 10 "https://github.com" &> /dev/null; then
|
||||
write_color "✓ Network connection OK" "$COLOR_SUCCESS"
|
||||
@@ -650,14 +661,39 @@ function main() {
|
||||
|
||||
# Get commit SHA from the downloaded repository first
|
||||
local commit_sha=""
|
||||
write_color "Detecting version information..." "$COLOR_INFO"
|
||||
|
||||
if command -v git &> /dev/null && [ -d "$repo_dir/.git" ]; then
|
||||
commit_sha=$(cd "$repo_dir" && git rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
||||
else
|
||||
# Try to get from git repository
|
||||
commit_sha=$(cd "$repo_dir" && git rev-parse --short HEAD 2>/dev/null || echo "")
|
||||
if [ -n "$commit_sha" ]; then
|
||||
write_color "✓ Version detected from git: $commit_sha" "$COLOR_SUCCESS"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$commit_sha" ]; then
|
||||
# Fallback: try to get from GitHub API
|
||||
write_color "Fetching version from GitHub API..." "$COLOR_INFO"
|
||||
local temp_branch="main"
|
||||
[ "$VERSION_TYPE" = "branch" ] && temp_branch="$BRANCH"
|
||||
commit_sha=$(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/$temp_branch" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7)
|
||||
[ -z "$commit_sha" ] && commit_sha="unknown"
|
||||
|
||||
local commit_data
|
||||
commit_data=$(curl -fsSL --connect-timeout 10 "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/$temp_branch" 2>/dev/null)
|
||||
|
||||
if [ -n "$commit_data" ]; then
|
||||
if command -v jq &> /dev/null; then
|
||||
commit_sha=$(echo "$commit_data" | jq -r '.sha' 2>/dev/null | cut -c1-7)
|
||||
else
|
||||
commit_sha=$(echo "$commit_data" | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$commit_sha" ] && [ "$commit_sha" != "null" ]; then
|
||||
write_color "✓ Version detected from API: $commit_sha" "$COLOR_SUCCESS"
|
||||
else
|
||||
write_color "WARNING: Could not detect version, using 'unknown'" "$COLOR_WARNING"
|
||||
commit_sha="unknown"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Determine version and branch information to pass
|
||||
|
||||
Reference in New Issue
Block a user