mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat: Add dynamic version detection to installation menu
Enhanced version selection menu with real-time version detection:
New Features:
- Auto-detect and display latest stable version in menu
- Show branch name for development version (main)
- Display recent release versions for reference
- Improved menu layout with tree-style formatting
- Real-time GitHub API query for latest release
Menu Improvements:
- Wider separator lines for better visibility
- Tree-style indicators (└─) for sub-items
- Color-coded options (Green=Stable, Yellow=Dev, Cyan=Custom)
- Version information displayed directly in menu
- Fallback handling if API request fails
User Experience:
Before:
1) Latest Stable Release (Recommended)
- Production-ready version
After:
1) Latest Stable Release (Recommended)
└─ Version: v3.2.0
└─ Production-ready
Implementation:
- PowerShell: Invoke-RestMethod with 5s timeout
- Bash: curl with jq (preferred) or grep/sed fallback
- Graceful degradation if network unavailable
- "Detecting latest release..." status message
- Confirmation message shows selected version
Example Output:
Detecting latest release...
Latest stable release: v3.2.0
============================================
Version Selection Menu
============================================
1) Latest Stable Release (Recommended)
└─ Version: v3.2.0
└─ Production-ready
2) Latest Development Version
└─ Branch: main
└─ Cutting-edge features
3) Specific Release Version
└─ Recent releases: v3.2.0, v3.1.0, v3.0.1
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -339,21 +339,40 @@ function Wait-ForUserConfirmation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Show-VersionMenu {
|
function Show-VersionMenu {
|
||||||
|
param(
|
||||||
|
[string]$LatestStableVersion = "Detecting..."
|
||||||
|
)
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-ColorOutput "====== Version Selection ======" $ColorInfo
|
Write-ColorOutput "============================================" $ColorInfo
|
||||||
Write-Host "1) Latest Stable Release (Recommended)"
|
Write-ColorOutput " Version Selection Menu" $ColorInfo
|
||||||
Write-Host " - Production-ready version"
|
Write-ColorOutput "============================================" $ColorInfo
|
||||||
Write-Host " - Auto-detected from GitHub releases"
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "2) Latest Development Version"
|
|
||||||
Write-Host " - Cutting-edge features"
|
# Option 1: Latest Stable
|
||||||
Write-Host " - May contain experimental changes"
|
Write-ColorOutput "1) Latest Stable Release (Recommended)" $ColorSuccess
|
||||||
|
if ($LatestStableVersion -ne "Detecting..." -and $LatestStableVersion -ne "Unknown") {
|
||||||
|
Write-Host " └─ Version: $LatestStableVersion"
|
||||||
|
} else {
|
||||||
|
Write-Host " └─ Version: Auto-detected from GitHub"
|
||||||
|
}
|
||||||
|
Write-Host " └─ Production-ready"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "3) Specific Release Version"
|
|
||||||
Write-Host " - Install a specific tagged release"
|
# Option 2: Latest Development
|
||||||
Write-Host " - You will be asked for the version tag"
|
Write-ColorOutput "2) Latest Development Version" $ColorWarning
|
||||||
|
Write-Host " └─ Branch: main"
|
||||||
|
Write-Host " └─ Cutting-edge features"
|
||||||
|
Write-Host " └─ May contain experimental changes"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-ColorOutput "===============================" $ColorInfo
|
|
||||||
|
# Option 3: Specific Version
|
||||||
|
Write-ColorOutput "3) Specific Release Version" $ColorInfo
|
||||||
|
Write-Host " └─ Install a specific tagged release"
|
||||||
|
Write-Host " └─ Recent releases: v3.2.0, v3.1.0, v3.0.1"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-ColorOutput "============================================" $ColorInfo
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,13 +386,26 @@ function Get-UserVersionChoice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Show-VersionMenu
|
# Detect latest stable version
|
||||||
|
Write-ColorOutput "Detecting latest release..." $ColorInfo
|
||||||
|
$latestVersion = "Unknown"
|
||||||
|
try {
|
||||||
|
$apiUrl = "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest"
|
||||||
|
$response = Invoke-RestMethod -Uri $apiUrl -UseBasicParsing -TimeoutSec 5
|
||||||
|
$latestVersion = $response.tag_name
|
||||||
|
Write-ColorOutput "Latest stable release: $latestVersion" $ColorSuccess
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput "Could not detect latest version, will auto-detect during download" $ColorWarning
|
||||||
|
}
|
||||||
|
|
||||||
|
Show-VersionMenu -LatestStableVersion $latestVersion
|
||||||
|
|
||||||
$choice = Read-Host "Select version to install (1-3, default: 1)"
|
$choice = Read-Host "Select version to install (1-3, default: 1)"
|
||||||
|
|
||||||
switch ($choice) {
|
switch ($choice) {
|
||||||
"2" {
|
"2" {
|
||||||
Write-ColorOutput "Selected: Latest Development Version" $ColorSuccess
|
Write-Host ""
|
||||||
|
Write-ColorOutput "✓ Selected: Latest Development Version (main branch)" $ColorSuccess
|
||||||
return @{
|
return @{
|
||||||
Type = "latest"
|
Type = "latest"
|
||||||
Tag = ""
|
Tag = ""
|
||||||
@@ -396,7 +428,7 @@ function Get-UserVersionChoice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-ColorOutput "Selected: Specific Version $tagInput" $ColorSuccess
|
Write-ColorOutput "✓ Selected: Specific Version $tagInput" $ColorSuccess
|
||||||
return @{
|
return @{
|
||||||
Type = "stable"
|
Type = "stable"
|
||||||
Tag = $tagInput
|
Tag = $tagInput
|
||||||
@@ -404,7 +436,12 @@ function Get-UserVersionChoice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
default {
|
default {
|
||||||
Write-ColorOutput "Selected: Latest Stable Release (default)" $ColorSuccess
|
Write-Host ""
|
||||||
|
if ($latestVersion -ne "Unknown") {
|
||||||
|
Write-ColorOutput "✓ Selected: Latest Stable Release ($latestVersion)" $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-ColorOutput "✓ Selected: Latest Stable Release (auto-detect)" $ColorSuccess
|
||||||
|
}
|
||||||
return @{
|
return @{
|
||||||
Type = "stable"
|
Type = "stable"
|
||||||
Tag = ""
|
Tag = ""
|
||||||
|
|||||||
@@ -383,21 +383,38 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_version_menu() {
|
function show_version_menu() {
|
||||||
|
local latest_version="$1"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
write_color "====== Version Selection ======" "$COLOR_INFO"
|
write_color "============================================" "$COLOR_INFO"
|
||||||
echo "1) Latest Stable Release (Recommended)"
|
write_color " Version Selection Menu" "$COLOR_INFO"
|
||||||
echo " - Production-ready version"
|
write_color "============================================" "$COLOR_INFO"
|
||||||
echo " - Auto-detected from GitHub releases"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "2) Latest Development Version"
|
|
||||||
echo " - Cutting-edge features"
|
# Option 1: Latest Stable
|
||||||
echo " - May contain experimental changes"
|
write_color "1) Latest Stable Release (Recommended)" "$COLOR_SUCCESS"
|
||||||
|
if [ -n "$latest_version" ] && [ "$latest_version" != "Unknown" ]; then
|
||||||
|
echo " └─ Version: $latest_version"
|
||||||
|
else
|
||||||
|
echo " └─ Version: Auto-detected from GitHub"
|
||||||
|
fi
|
||||||
|
echo " └─ Production-ready"
|
||||||
echo ""
|
echo ""
|
||||||
echo "3) Specific Release Version"
|
|
||||||
echo " - Install a specific tagged release"
|
# Option 2: Latest Development
|
||||||
echo " - You will be asked for the version tag"
|
write_color "2) Latest Development Version" "$COLOR_WARNING"
|
||||||
|
echo " └─ Branch: main"
|
||||||
|
echo " └─ Cutting-edge features"
|
||||||
|
echo " └─ May contain experimental changes"
|
||||||
echo ""
|
echo ""
|
||||||
write_color "===============================" "$COLOR_INFO"
|
|
||||||
|
# Option 3: Specific Version
|
||||||
|
write_color "3) Specific Release Version" "$COLOR_INFO"
|
||||||
|
echo " └─ Install a specific tagged release"
|
||||||
|
echo " └─ Recent releases: v3.2.0, v3.1.0, v3.0.1"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
write_color "============================================" "$COLOR_INFO"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,13 +425,33 @@ function get_user_version_choice() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
show_version_menu
|
# Detect latest stable version
|
||||||
|
write_color "Detecting latest release..." "$COLOR_INFO"
|
||||||
|
local latest_version="Unknown"
|
||||||
|
|
||||||
|
if command -v jq &> /dev/null; then
|
||||||
|
# Use jq if available
|
||||||
|
latest_version=$(curl -fsSL --connect-timeout 5 "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | jq -r '.tag_name' 2>/dev/null)
|
||||||
|
else
|
||||||
|
# Fallback: parse JSON with grep/sed
|
||||||
|
latest_version=$(curl -fsSL --connect-timeout 5 "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name":\s*"[^"]*"' | sed 's/"tag_name":\s*"\([^"]*\)"/\1/')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$latest_version" ] && [ "$latest_version" != "null" ] && [ "$latest_version" != "Unknown" ]; then
|
||||||
|
write_color "Latest stable release: $latest_version" "$COLOR_SUCCESS"
|
||||||
|
else
|
||||||
|
latest_version="Unknown"
|
||||||
|
write_color "Could not detect latest version, will auto-detect during download" "$COLOR_WARNING"
|
||||||
|
fi
|
||||||
|
|
||||||
|
show_version_menu "$latest_version"
|
||||||
|
|
||||||
read -p "Select version to install (1-3, default: 1): " choice
|
read -p "Select version to install (1-3, default: 1): " choice
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
2)
|
2)
|
||||||
write_color "✓ Selected: Latest Development Version" "$COLOR_SUCCESS"
|
echo ""
|
||||||
|
write_color "✓ Selected: Latest Development Version (main branch)" "$COLOR_SUCCESS"
|
||||||
VERSION_TYPE="latest"
|
VERSION_TYPE="latest"
|
||||||
TAG_VERSION=""
|
TAG_VERSION=""
|
||||||
BRANCH="main"
|
BRANCH="main"
|
||||||
@@ -431,6 +468,7 @@ function get_user_version_choice() {
|
|||||||
VERSION_TYPE="stable"
|
VERSION_TYPE="stable"
|
||||||
TAG_VERSION=""
|
TAG_VERSION=""
|
||||||
else
|
else
|
||||||
|
echo ""
|
||||||
write_color "✓ Selected: Specific Version $tag_input" "$COLOR_SUCCESS"
|
write_color "✓ Selected: Specific Version $tag_input" "$COLOR_SUCCESS"
|
||||||
VERSION_TYPE="stable"
|
VERSION_TYPE="stable"
|
||||||
TAG_VERSION="$tag_input"
|
TAG_VERSION="$tag_input"
|
||||||
@@ -438,7 +476,12 @@ function get_user_version_choice() {
|
|||||||
BRANCH="main"
|
BRANCH="main"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
write_color "✓ Selected: Latest Stable Release (default)" "$COLOR_SUCCESS"
|
echo ""
|
||||||
|
if [ "$latest_version" != "Unknown" ]; then
|
||||||
|
write_color "✓ Selected: Latest Stable Release ($latest_version)" "$COLOR_SUCCESS"
|
||||||
|
else
|
||||||
|
write_color "✓ Selected: Latest Stable Release (auto-detect)" "$COLOR_SUCCESS"
|
||||||
|
fi
|
||||||
VERSION_TYPE="stable"
|
VERSION_TYPE="stable"
|
||||||
TAG_VERSION=""
|
TAG_VERSION=""
|
||||||
BRANCH="main"
|
BRANCH="main"
|
||||||
|
|||||||
Reference in New Issue
Block a user