42 lines
1.9 KiB
PowerShell
42 lines
1.9 KiB
PowerShell
# Build release zips for XShop (PowerShell 5.1)
|
|
param(
|
|
[string]$Version = "1.0.0"
|
|
)
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$outDir = Join-Path $root "release"
|
|
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
|
|
|
function New-ThemeZip {
|
|
param([string]$Src, [string]$Dest)
|
|
if (Test-Path $Dest) { Remove-Item -LiteralPath $Dest -Force }
|
|
Add-Type -AssemblyName System.IO.Compression
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
$tmp = Join-Path $env:TEMP ("xshop-build-" + [Guid]::NewGuid())
|
|
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
|
|
Copy-Item -Recurse -Force -Path $Src -Destination (Join-Path $tmp "xshop")
|
|
# Strip dev artifacts if present
|
|
@("node_modules",".git",".cache") | ForEach-Object {
|
|
$p = Join-Path $tmp ("xshop\" + $_)
|
|
if (Test-Path $p) { Remove-Item -Recurse -Force -LiteralPath $p }
|
|
}
|
|
# Include top-level folder `xshop` inside zip (WP expects folder wrapper)
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($tmp, $Dest, [System.IO.Compression.CompressionLevel]::Optimal, $false)
|
|
Remove-Item -Recurse -Force -LiteralPath $tmp
|
|
Write-Host "Built $Dest"
|
|
}
|
|
function New-PluginZip {
|
|
param([string]$Src, [string]$Dest)
|
|
if (Test-Path $Dest) { Remove-Item -LiteralPath $Dest -Force }
|
|
$tmp = Join-Path $env:TEMP ("xshop-core-build-" + [Guid]::NewGuid())
|
|
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
|
|
Copy-Item -Recurse -Force -Path $Src -Destination (Join-Path $tmp "xshop-core")
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($tmp, $Dest, [System.IO.Compression.CompressionLevel]::Optimal, $false)
|
|
Remove-Item -Recurse -Force -LiteralPath $tmp
|
|
Write-Host "Built $Dest"
|
|
}
|
|
|
|
New-ThemeZip -Src (Join-Path $root "xshop-theme") -Dest (Join-Path $outDir "xshop.zip")
|
|
New-PluginZip -Src (Join-Path $root "xshop-core") -Dest (Join-Path $outDir "xshop-core.zip")
|
|
Write-Host "Done. Version $Version"
|