-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.ps1
More file actions
82 lines (67 loc) · 2.83 KB
/
Copy pathpackage.ps1
File metadata and controls
82 lines (67 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# package.ps1
# Creates a versioned CurseForge zip in the WoW AddOns folder.
# Triggered automatically by .githooks/post-commit.
# 1. Resolve Repo Root correctly
$RepoRoot = if ($PSScriptRoot) { $PSScriptRoot } else { Get-Location }
$RepoRoot = (Get-Item $RepoRoot).FullName
Write-Host "Repo Root: $RepoRoot" -ForegroundColor Cyan
# 2. Find .toc to get Addon Name
$tocFile = Get-ChildItem -Path $RepoRoot -Filter "*.toc" | Select-Object -First 1
if (-not $tocFile) {
Write-Host "Error: No .toc file found in $RepoRoot" -ForegroundColor Red
exit 1
}
$addonName = $tocFile.BaseName
Write-Host "Addon Name: $addonName" -ForegroundColor Yellow
# 3. Get Git Hash
Push-Location $RepoRoot
$hash = git rev-parse --short HEAD 2>$null
Pop-Location
if ($LASTEXITCODE -ne 0 -or -not $hash) {
Write-Host "Warning: Could not get git hash. ZIP will not be versioned." -ForegroundColor Yellow
$hash = "dev"
} else {
$hash = $hash.Trim()
}
Write-Host "Commit Hash: $hash" -ForegroundColor Yellow
# 4. Resolve WoW AddOns path
$wowPathsFile = Join-Path $RepoRoot "wow_paths.json"
$wowAddonsPath = $null
if (Test-Path $wowPathsFile) {
$config = Get-Content $wowPathsFile -Raw | ConvertFrom-Json
if ($config.wowAddonPath -and (Test-Path $config.wowAddonPath)) {
$wowAddonsPath = $config.wowAddonPath
}
}
if (-not $wowAddonsPath) {
$defaultPath = "C:\Program Files (x86)\World of Warcraft\_anniversary_\Interface\AddOns"
if (Test-Path $defaultPath) {
$wowAddonsPath = $defaultPath
}
}
if (-not $wowAddonsPath) {
Write-Host "Error: WoW AddOns folder not found. Check wow_paths.json." -ForegroundColor Red
exit 1
}
Write-Host "Target AddOns Folder: $wowAddonsPath" -ForegroundColor Cyan
# 5. Cleanup Stale Zips
Write-Host "Cleaning up stale zips..." -ForegroundColor Gray
Get-ChildItem -Path $wowAddonsPath -Filter "$addonName-*.zip" | Remove-Item -Force -ErrorAction SilentlyContinue
# 6. Verify Deployed Folder exists
$addonSource = Join-Path $wowAddonsPath $addonName
if (-not (Test-Path $addonSource)) {
Write-Host "Error: Deployed folder '$addonSource' not found. Run deploy.ps1 first." -ForegroundColor Red
exit 1
}
# 7. Create Zip
$zipPath = Join-Path $wowAddonsPath "$addonName-$hash.zip"
Write-Host "Creating Zip: $zipPath" -ForegroundColor Green
# Stage to Temp to ensure clean structure <AddonName>/<files>
$tempStaging = Join-Path $env:TEMP "eq_pkg_$addonName"
if (Test-Path $tempStaging) { Remove-Item $tempStaging -Recurse -Force }
New-Item -ItemType Directory -Path $tempStaging | Out-Null
$stagingAddon = Join-Path $tempStaging $addonName
Copy-Item -Path $addonSource -Destination $stagingAddon -Recurse -Force
Compress-Archive -Path "$stagingAddon" -DestinationPath $zipPath -CompressionLevel Fastest -Force
Remove-Item $tempStaging -Recurse -Force
Write-Host "✅ Packaging Complete!" -ForegroundColor Green