fix: Fix Unicode display and add detailed version info to menu

Fixed Issues:
- Unicode tree characters causing display corruption
- Replaced Unicode symbols (└─) with ASCII alternatives (|-- and \--)
- Now uses ASCII-safe characters that display correctly in all terminals

Enhanced Version Information:
- Stable Release: Now shows release date
  * Version: v3.2.0
  * Released: 2025-10-02 04:27 UTC

- Development Version: Now shows commit details
  * Branch: main
  * Commit: ed1e1c4 (7-char SHA)
  * Updated: 2025-10-02 08:15 UTC

Technical Improvements:
- Query both releases and commits APIs in parallel
- Parse and format ISO 8601 timestamps
- Display dates in readable format (YYYY-MM-DD HH:MM UTC)
- Show 7-character commit SHA for brevity
- Wider separator lines for better visibility

Menu Display Format:
===================================================
           Version Selection Menu
===================================================

1) Latest Stable Release (Recommended)
   |-- Version: v3.2.0
   |-- Released: 2025-10-02 04:27 UTC
   \-- Production-ready

2) Latest Development Version
   |-- Branch: main
   |-- Commit: ed1e1c4
   |-- Updated: 2025-10-02 08:15 UTC
   |-- Cutting-edge features
   \-- May contain experimental changes

3) Specific Release Version
   |-- Install a specific tagged release
   \-- Recent: v3.2.0, v3.1.0, v3.0.1

===================================================

Implementation Details:
- PowerShell: DateTime.Parse() for timestamp formatting
- Bash: sed/cut pipeline for date parsing (jq optional)
- Graceful degradation if API calls fail
- 5-second timeout for quick response

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-10-02 12:48:09 +08:00
parent ed1e1c4bbf
commit cdea58f32f
3 changed files with 134 additions and 41 deletions

BIN
image.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -340,39 +340,50 @@ function Wait-ForUserConfirmation {
function Show-VersionMenu {
param(
[string]$LatestStableVersion = "Detecting..."
[string]$LatestStableVersion = "Detecting...",
[string]$LatestStableDate = "",
[string]$LatestCommitId = "",
[string]$LatestCommitDate = ""
)
Write-Host ""
Write-ColorOutput "============================================" $ColorInfo
Write-ColorOutput " Version Selection Menu" $ColorInfo
Write-ColorOutput "============================================" $ColorInfo
Write-ColorOutput "====================================================" $ColorInfo
Write-ColorOutput " Version Selection Menu" $ColorInfo
Write-ColorOutput "====================================================" $ColorInfo
Write-Host ""
# Option 1: Latest Stable
Write-ColorOutput "1) Latest Stable Release (Recommended)" $ColorSuccess
if ($LatestStableVersion -ne "Detecting..." -and $LatestStableVersion -ne "Unknown") {
Write-Host " └─ Version: $LatestStableVersion"
Write-Host " |-- Version: $LatestStableVersion"
if ($LatestStableDate) {
Write-Host " |-- Released: $LatestStableDate"
}
Write-Host " \-- Production-ready"
} else {
Write-Host " └─ Version: Auto-detected from GitHub"
Write-Host " |-- Version: Auto-detected from GitHub"
Write-Host " \-- Production-ready"
}
Write-Host " └─ Production-ready"
Write-Host ""
# Option 2: Latest Development
Write-ColorOutput "2) Latest Development Version" $ColorWarning
Write-Host " └─ Branch: main"
Write-Host " └─ Cutting-edge features"
Write-Host " └─ May contain experimental changes"
Write-Host " |-- Branch: main"
if ($LatestCommitId -and $LatestCommitDate) {
Write-Host " |-- Commit: $LatestCommitId"
Write-Host " |-- Updated: $LatestCommitDate"
}
Write-Host " |-- Cutting-edge features"
Write-Host " \-- May contain experimental changes"
Write-Host ""
# 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 " |-- Install a specific tagged release"
Write-Host " \-- Recent: v3.2.0, v3.1.0, v3.0.1"
Write-Host ""
Write-ColorOutput "============================================" $ColorInfo
Write-ColorOutput "====================================================" $ColorInfo
Write-Host ""
}
@@ -386,19 +397,48 @@ function Get-UserVersionChoice {
}
}
# Detect latest stable version
Write-ColorOutput "Detecting latest release..." $ColorInfo
# Detect latest stable version and commit info
Write-ColorOutput "Detecting latest release and commits..." $ColorInfo
$latestVersion = "Unknown"
$latestStableDate = ""
$latestCommitId = ""
$latestCommitDate = ""
try {
# Get latest release info
$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
# Parse and format release date
if ($response.published_at) {
$publishDate = [DateTime]::Parse($response.published_at)
$latestStableDate = $publishDate.ToString("yyyy-MM-dd HH:mm UTC")
}
Write-ColorOutput "Latest stable: $latestVersion ($latestStableDate)" $ColorSuccess
} catch {
Write-ColorOutput "Could not detect latest version, will auto-detect during download" $ColorWarning
Write-ColorOutput "Could not detect latest release" $ColorWarning
}
Show-VersionMenu -LatestStableVersion $latestVersion
try {
# Get latest commit info from main branch
$commitUrl = "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main"
$commitResponse = Invoke-RestMethod -Uri $commitUrl -UseBasicParsing -TimeoutSec 5
$latestCommitId = $commitResponse.sha.Substring(0, 7)
# Parse and format commit date
if ($commitResponse.commit.committer.date) {
$commitDate = [DateTime]::Parse($commitResponse.commit.committer.date)
$latestCommitDate = $commitDate.ToString("yyyy-MM-dd HH:mm UTC")
}
Write-ColorOutput "Latest commit: $latestCommitId ($latestCommitDate)" $ColorSuccess
} catch {
Write-ColorOutput "Could not detect latest commit" $ColorWarning
}
Show-VersionMenu -LatestStableVersion $latestVersion -LatestStableDate $latestStableDate -LatestCommitId $latestCommitId -LatestCommitDate $latestCommitDate
$choice = Read-Host "Select version to install (1-3, default: 1)"

View File

@@ -384,37 +384,48 @@ EOF
function show_version_menu() {
local latest_version="$1"
local latest_date="$2"
local commit_id="$3"
local commit_date="$4"
echo ""
write_color "============================================" "$COLOR_INFO"
write_color " Version Selection Menu" "$COLOR_INFO"
write_color "============================================" "$COLOR_INFO"
write_color "====================================================" "$COLOR_INFO"
write_color " Version Selection Menu" "$COLOR_INFO"
write_color "====================================================" "$COLOR_INFO"
echo ""
# Option 1: Latest Stable
write_color "1) Latest Stable Release (Recommended)" "$COLOR_SUCCESS"
if [ -n "$latest_version" ] && [ "$latest_version" != "Unknown" ]; then
echo " └─ Version: $latest_version"
echo " |-- Version: $latest_version"
if [ -n "$latest_date" ]; then
echo " |-- Released: $latest_date"
fi
echo " \-- Production-ready"
else
echo " └─ Version: Auto-detected from GitHub"
echo " |-- Version: Auto-detected from GitHub"
echo " \-- Production-ready"
fi
echo " └─ Production-ready"
echo ""
# Option 2: Latest Development
write_color "2) Latest Development Version" "$COLOR_WARNING"
echo " └─ Branch: main"
echo " └─ Cutting-edge features"
echo " └─ May contain experimental changes"
echo " |-- Branch: main"
if [ -n "$commit_id" ] && [ -n "$commit_date" ]; then
echo " |-- Commit: $commit_id"
echo " |-- Updated: $commit_date"
fi
echo " |-- Cutting-edge features"
echo " \-- May contain experimental changes"
echo ""
# 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 " |-- Install a specific tagged release"
echo " \-- Recent: v3.2.0, v3.1.0, v3.0.1"
echo ""
write_color "============================================" "$COLOR_INFO"
write_color "====================================================" "$COLOR_INFO"
echo ""
}
@@ -425,26 +436,68 @@ function get_user_version_choice() {
return 0
fi
# Detect latest stable version
write_color "Detecting latest release..." "$COLOR_INFO"
# Detect latest stable version and commit info
write_color "Detecting latest release and commits..." "$COLOR_INFO"
local latest_version="Unknown"
local latest_date=""
local commit_id=""
local commit_date=""
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/')
# Get latest release info
local release_data
release_data=$(curl -fsSL --connect-timeout 5 "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null)
if [ -n "$release_data" ]; then
if command -v jq &> /dev/null; then
latest_version=$(echo "$release_data" | jq -r '.tag_name' 2>/dev/null)
local published_at=$(echo "$release_data" | jq -r '.published_at' 2>/dev/null)
if [ -n "$published_at" ] && [ "$published_at" != "null" ]; then
# Format: 2025-10-02T04:27:21Z -> 2025-10-02 04:27 UTC
latest_date=$(echo "$published_at" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1)
fi
else
latest_version=$(echo "$release_data" | grep -o '"tag_name":\s*"[^"]*"' | sed 's/"tag_name":\s*"\([^"]*\)"/\1/')
local published_at=$(echo "$release_data" | grep -o '"published_at":\s*"[^"]*"' | sed 's/"published_at":\s*"\([^"]*\)"/\1/')
if [ -n "$published_at" ]; then
latest_date=$(echo "$published_at" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1)
fi
fi
fi
if [ -n "$latest_version" ] && [ "$latest_version" != "null" ] && [ "$latest_version" != "Unknown" ]; then
write_color "Latest stable release: $latest_version" "$COLOR_SUCCESS"
write_color "Latest stable: $latest_version ($latest_date)" "$COLOR_SUCCESS"
else
latest_version="Unknown"
write_color "Could not detect latest version, will auto-detect during download" "$COLOR_WARNING"
write_color "Could not detect latest release" "$COLOR_WARNING"
fi
show_version_menu "$latest_version"
# Get latest commit info
local commit_data
commit_data=$(curl -fsSL --connect-timeout 5 "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null)
if [ -n "$commit_data" ]; then
if command -v jq &> /dev/null; then
commit_id=$(echo "$commit_data" | jq -r '.sha' 2>/dev/null | cut -c1-7)
local committer_date=$(echo "$commit_data" | jq -r '.commit.committer.date' 2>/dev/null)
if [ -n "$committer_date" ] && [ "$committer_date" != "null" ]; then
commit_date=$(echo "$committer_date" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1)
fi
else
commit_id=$(echo "$commit_data" | grep -o '"sha":\s*"[^"]*"' | head -1 | sed 's/"sha":\s*"\([^"]*\)"/\1/' | cut -c1-7)
local committer_date=$(echo "$commit_data" | grep -o '"date":\s*"[^"]*"' | head -1 | sed 's/"date":\s*"\([^"]*\)"/\1/')
if [ -n "$committer_date" ]; then
commit_date=$(echo "$committer_date" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1)
fi
fi
fi
if [ -n "$commit_id" ] && [ -n "$commit_date" ]; then
write_color "Latest commit: $commit_id ($commit_date)" "$COLOR_SUCCESS"
else
write_color "Could not detect latest commit" "$COLOR_WARNING"
fi
show_version_menu "$latest_version" "$latest_date" "$commit_id" "$commit_date"
read -p "Select version to install (1-3, default: 1): " choice