@@ -37,16 +37,16 @@ jobs:
3737
3838 - name : Check what GoReleaser created
3939 run : |
40- echo "📁 Checking dist directory contents..."
40+ Write-Host "📁 Checking dist directory contents..."
4141 if (Test-Path 'dist') {
4242 Write-Host "✅ dist folder exists!"
4343 Get-ChildItem -Path 'dist' -Recurse | Select-Object FullName, Length
4444 } else {
4545 Write-Host "❌ dist folder not found!"
4646 }
4747
48- echo ""
49- echo "🔍 Looking for scoop manifest..."
48+ Write-Host ""
49+ Write-Host "🔍 Looking for scoop manifest..."
5050 if (Test-Path 'dist/scoop/zed-cli-win-unofficial.json') {
5151 Write-Host "✅ Scoop manifest found!"
5252 Write-Host "📦 Original manifest contents:"
@@ -64,52 +64,69 @@ jobs:
6464
6565 - name : Fix Scoop Manifest (Test - Log Only)
6666 run : |
67- echo "🔧 Testing scoop manifest fix..."
67+ Write-Host "🔧 Testing scoop manifest fix..."
6868
6969 if (Test-Path 'dist/scoop/zed-cli-win-unofficial.json') {
70- Write-Host "✅ Found scoop manifest, reading contents..."
71- $manifest = Get-Content 'dist/scoop/zed-cli-win-unofficial.json' | ConvertFrom-Json
72-
73- Write-Host "📋 Current bin array:"
74- $manifest.architecture."64bit".bin | ForEach-Object { Write-Host " - $_" }
75-
76- # Add zed.bat to bin array
77- $manifest.architecture."64bit".bin += "zed-cli-win-unofficial/zed.bat"
78-
79- Write-Host ""
80- Write-Host "📋 Updated bin array would be:"
81- $manifest.architecture."64bit".bin | ForEach-Object { Write-Host " - $_" }
82-
83- # Convert to JSON for preview
84- $jsonContent = $manifest | ConvertTo-Json -Depth 10
85-
86- Write-Host ""
87- Write-Host "📄 Complete updated manifest would be:"
88- Write-Host $jsonContent
89-
70+ Write-Host "✅ Found scoop manifest, reading contents..."
71+
72+ # Read the original content as text to preserve formatting
73+ $content = Get-Content 'dist/scoop/zed-cli-win-unofficial.json' -Raw
74+
75+ Write-Host "📄 Original manifest:"
76+ Write-Host $content
77+
78+ # Parse JSON to check current bin array (for logging only)
79+ $manifest = $content | ConvertFrom-Json
80+ Write-Host ""
81+ Write-Host "📋 Current bin array:"
82+ $manifest.architecture."64bit".bin | ForEach-Object { Write-Host " - $_" }
83+
84+ # Use regex to find and modify the bin array while preserving formatting
85+ # This looks for the bin array pattern and adds zed.bat if not already present
86+ if ($content -notmatch '"zed-cli-win-unofficial/zed\.bat"') {
87+ Write-Host ""
88+ Write-Host "🔧 Adding zed.bat to bin array..."
89+
90+ # Find the bin array and add the new entry
91+ # Pattern matches: "bin": ["existing-entry"] or "bin": ["entry1", "entry2"]
92+ $pattern = '("bin":\s*\[\s*"[^"]+")(\s*\])'
93+ $replacement = '$1, "zed-cli-win-unofficial/zed.bat"$2'
94+
95+ $updatedContent = $content -replace $pattern, $replacement
96+
97+ Write-Host "📄 Updated manifest:"
98+ Write-Host $updatedContent
99+
100+ # Create bucket directory for testing
101+ if (-not (Test-Path 'bucket')) {
102+ New-Item -ItemType Directory -Path 'bucket'
90103 Write-Host ""
91- Write-Host "✅ Scoop manifest fix test successful!"
92-
93- # Create bucket directory for testing
94- if (-not (Test-Path 'bucket')) {
95- New-Item -ItemType Directory -Path 'bucket'
96- Write-Host "📁 Created bucket directory (for testing)"
97- }
98-
99- # Save the fixed manifest (just for logging, not committing)
100- $jsonContent | Set-Content 'bucket/zed-cli-win-unofficial.json'
101- Write-Host "💾 Saved fixed manifest to bucket/ (for testing)"
102-
103- } else {
104- Write-Host "❌ Scoop manifest not found"
105- exit 1
104+ Write-Host "📁 Created bucket directory (for testing)"
105+ }
106+
107+ # Save the updated manifest with preserved formatting
108+ $updatedContent | Set-Content 'bucket/zed-cli-win-unofficial.json' -NoNewline
109+ Write-Host ""
110+ Write-Host "💾 Saved updated manifest to bucket/ (for testing)"
111+ Write-Host "✅ Scoop manifest fix test successful!"
112+
113+ }
114+ else {
115+ Write-Host ""
116+ Write-Host "✅ zed.bat already exists in bin array"
117+ }
118+
119+ }
120+ else {
121+ Write-Host "❌ Scoop manifest not found"
122+ exit 1
106123 }
107124 shell : powershell
108125
109126 - name : Show what would be committed
110127 run : |
111- echo "📊 Summary of what would be committed to repository:"
112- echo ""
128+ Write-Host "📊 Summary of what would be committed to repository:"
129+ Write-Host ""
113130
114131 if (Test-Path 'bucket/zed-cli-win-unofficial.json') {
115132 Write-Host "✅ bucket/zed-cli-win-unofficial.json"
@@ -121,7 +138,7 @@ jobs:
121138 Write-Host "❌ No manifest file to commit"
122139 }
123140
124- echo ""
141+ Write-Host ""
125142 Write-Host "🚀 In a real release, this would:"
126143 Write-Host " 1. Create/update bucket/zed-cli-win-unofficial.json"
127144 Write-Host " 2. Commit with message: 'Scoop update for zed-cli-win-unofficial version ${{ github.ref_name }}'"
0 commit comments