Skip to content

Commit be8510c

Browse files
fix: Update prepare-binaries script to handle missing components gracefully
1 parent 595657e commit be8510c

File tree

1 file changed

+71
-28
lines changed

1 file changed

+71
-28
lines changed

scripts/prepare-binaries.ps1

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,110 @@
11
# scripts/prepare-binaries.ps1
2-
Write-Host "🔧 Preparing DevStackBox binaries for release..." -ForegroundColor Green
2+
Write-Host "Preparing DevStackBox binaries for release..." -ForegroundColor Green
33

4-
# Ensure src-tauri directory structure for bundling
54
$srcTauriPath = "src-tauri"
5+
$componentsFound = 0
6+
$componentsTotal = 6
67

7-
# Copy all server components to src-tauri for bundling
8-
Write-Host "📦 Copying server components..." -ForegroundColor Blue
8+
Write-Host "Copying server components..." -ForegroundColor Blue
99

1010
# Copy Apache
1111
if (Test-Path "apache") {
12-
Write-Host " Copying Apache binaries..."
12+
Write-Host " Copying Apache binaries..."
1313
if (Test-Path "$srcTauriPath/apache") {
1414
Remove-Item "$srcTauriPath/apache" -Recurse -Force
1515
}
1616
Copy-Item -Path "apache" -Destination "$srcTauriPath/apache" -Recurse -Force
17+
$componentsFound++
18+
} else {
19+
New-Item -ItemType Directory -Force -Path "$srcTauriPath/apache" | Out-Null
20+
New-Item -ItemType File -Force -Path "$srcTauriPath/apache/README.txt" -Value "Placeholder for Apache component" | Out-Null
21+
Write-Host " Created placeholder for Apache" -ForegroundColor Yellow
1722
}
1823

1924
# Copy MySQL
2025
if (Test-Path "mysql") {
21-
Write-Host " ✅ Copying MySQL binaries..."
22-
Copy-Item -Path "mysql" -Destination "$srcTauriPath/mysql" -Recurse -Force
23-
# Exclude runtime data but keep structure
24-
if (Test-Path "$srcTauriPath/mysql/data") {
25-
Remove-Item "$srcTauriPath/mysql/data/*" -Recurse -Force -ErrorAction SilentlyContinue
26+
Write-Host " Copying MySQL binaries..."
27+
if (Test-Path "$srcTauriPath/mysql") {
28+
Remove-Item "$srcTauriPath/mysql" -Recurse -Force
2629
}
30+
Copy-Item -Path "mysql" -Destination "$srcTauriPath/mysql" -Recurse -Force
31+
$componentsFound++
32+
} else {
33+
New-Item -ItemType Directory -Force -Path "$srcTauriPath/mysql" | Out-Null
34+
New-Item -ItemType File -Force -Path "$srcTauriPath/mysql/README.txt" -Value "Placeholder for MySQL component" | Out-Null
35+
Write-Host " Created placeholder for MySQL" -ForegroundColor Yellow
2736
}
2837

2938
# Copy PHP
3039
if (Test-Path "php") {
31-
Write-Host " ✅ Copying PHP binaries..."
32-
Copy-Item -Path "php" -Destination "$srcTauriPath/php" -Recurse -Force
33-
# Exclude sessions but keep structure
34-
if (Test-Path "$srcTauriPath/php/sessions") {
35-
Remove-Item "$srcTauriPath/php/sessions/*" -Force -ErrorAction SilentlyContinue
40+
Write-Host " Copying PHP binaries..."
41+
if (Test-Path "$srcTauriPath/php") {
42+
Remove-Item "$srcTauriPath/php" -Recurse -Force
3643
}
44+
Copy-Item -Path "php" -Destination "$srcTauriPath/php" -Recurse -Force
45+
$componentsFound++
46+
} else {
47+
New-Item -ItemType Directory -Force -Path "$srcTauriPath/php" | Out-Null
48+
New-Item -ItemType File -Force -Path "$srcTauriPath/php/README.txt" -Value "Placeholder for PHP component" | Out-Null
49+
Write-Host " Created placeholder for PHP" -ForegroundColor Yellow
3750
}
3851

3952
# Copy phpMyAdmin
4053
if (Test-Path "phpmyadmin") {
41-
Write-Host " ✅ Copying phpMyAdmin..."
42-
Copy-Item -Path "phpmyadmin" -Destination "$srcTauriPath/phpmyadmin" -Recurse -Force
43-
# Exclude temp files but keep structure
44-
@("tmp", "upload", "save") | ForEach-Object {
45-
$tempPath = "$srcTauriPath/phpmyadmin/$_"
46-
if (Test-Path $tempPath) {
47-
Remove-Item "$tempPath/*" -Force -ErrorAction SilentlyContinue
48-
} else {
49-
New-Item -ItemType Directory -Path $tempPath -Force | Out-Null
50-
}
54+
Write-Host " Copying phpMyAdmin..."
55+
if (Test-Path "$srcTauriPath/phpmyadmin") {
56+
Remove-Item "$srcTauriPath/phpmyadmin" -Recurse -Force
5157
}
58+
Copy-Item -Path "phpmyadmin" -Destination "$srcTauriPath/phpmyadmin" -Recurse -Force
59+
$componentsFound++
60+
} else {
61+
New-Item -ItemType Directory -Force -Path "$srcTauriPath/phpmyadmin" | Out-Null
62+
New-Item -ItemType File -Force -Path "$srcTauriPath/phpmyadmin/README.txt" -Value "Placeholder for phpMyAdmin component" | Out-Null
63+
Write-Host " Created placeholder for phpMyAdmin" -ForegroundColor Yellow
5264
}
5365

5466
# Copy www directory
5567
if (Test-Path "www") {
56-
Write-Host " ✅ Copying www directory..."
68+
Write-Host " Copying www directory..."
69+
if (Test-Path "$srcTauriPath/www") {
70+
Remove-Item "$srcTauriPath/www" -Recurse -Force
71+
}
5772
Copy-Item -Path "www" -Destination "$srcTauriPath/www" -Recurse -Force
73+
$componentsFound++
74+
} else {
75+
New-Item -ItemType Directory -Force -Path "$srcTauriPath/www" | Out-Null
76+
New-Item -ItemType File -Force -Path "$srcTauriPath/www/README.txt" -Value "Placeholder for WWW component" | Out-Null
77+
$indexContent = '<html><head><title>DevStackBox</title></head><body><h1>DevStackBox</h1><p>Ready!</p></body></html>'
78+
New-Item -ItemType File -Force -Path "$srcTauriPath/www/index.html" -Value $indexContent | Out-Null
79+
Write-Host " Created placeholder for WWW" -ForegroundColor Yellow
5880
}
5981

6082
# Copy config files
6183
if (Test-Path "config") {
62-
Write-Host " ✅ Copying configuration files..."
84+
Write-Host " Copying configuration files..."
85+
if (Test-Path "$srcTauriPath/config") {
86+
Remove-Item "$srcTauriPath/config" -Recurse -Force
87+
}
6388
Copy-Item -Path "config" -Destination "$srcTauriPath/config" -Recurse -Force
89+
$componentsFound++
90+
} else {
91+
New-Item -ItemType Directory -Force -Path "$srcTauriPath/config" | Out-Null
92+
New-Item -ItemType File -Force -Path "$srcTauriPath/config/README.txt" -Value "Placeholder for Config component" | Out-Null
93+
Write-Host " Created placeholder for Config" -ForegroundColor Yellow
94+
}
95+
96+
Write-Host ""
97+
Write-Host "Component Summary:" -ForegroundColor Cyan
98+
Write-Host " Total components: $componentsTotal"
99+
Write-Host " Found and copied: $componentsFound" -ForegroundColor Green
100+
Write-Host " Placeholders created: $($componentsTotal - $componentsFound)" -ForegroundColor Yellow
101+
102+
if ($componentsFound -eq 0) {
103+
Write-Host ""
104+
Write-Host "Warning: No server components found in repository!" -ForegroundColor Yellow
105+
Write-Host "Building with placeholder files only." -ForegroundColor Yellow
64106
}
65107

108+
Write-Host ""
66109
Write-Host "All binaries prepared for bundling!" -ForegroundColor Green
67-
Write-Host "Ready to run: npm run tauri build" -ForegroundColor Yellow
110+
Write-Host "Ready to run: npm run tauri build" -ForegroundColor Yellow

0 commit comments

Comments
 (0)