Files
claude-skills/scripts/package-all.ps1
T

51 lines
1.8 KiB
PowerShell

# Builds ZIP for every skill, .mcpb when extension/ exists, and Cursor plugin ZIPs.
# Usage: scripts\package-all.ps1
. (Join-Path $PSScriptRoot 'lib.ps1')
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
& (Join-Path $PSScriptRoot 'package.ps1')
if ($LASTEXITCODE -ne 0) { exit 1 }
foreach ($n in (Get-SkillNames)) {
$ext = Join-Path (Join-Path $SkillsDir $n) 'extension\manifest.json'
if (Test-Path $ext) {
& (Join-Path $PSScriptRoot 'package-mcpb.ps1') -Name $n
if ($LASTEXITCODE -ne 0) { exit 1 }
}
}
& (Join-Path $PSScriptRoot 'build-cursor.ps1')
if ($LASTEXITCODE -ne 0) { exit 1 }
foreach ($n in (Get-SkillNames)) {
$pluginDir = Join-Path $DistDir "cursor\plugins\$n"
if (-not (Test-Path $pluginDir)) { continue }
$ver = Get-SkillVersion (Join-Path $SkillsDir $n)
$out = Join-Path $DistDir "$n-cursor-v$ver.zip"
if (Test-Path $out) { Remove-Item $out -Force }
$src = (Get-Item $pluginDir).FullName
$files = @(Get-ChildItem -Path $src -Recurse -File -Force | ForEach-Object { $_.FullName })
[Array]::Sort($files, [StringComparer]::Ordinal)
$zip = [IO.Compression.ZipFile]::Open($out, [IO.Compression.ZipArchiveMode]::Create)
try {
[void]$zip.CreateEntry("$n/")
foreach ($f in $files) {
$rel = $f.Substring($src.Length).TrimStart('\', '/') -replace '\\', '/'
[void][IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, $f, "$n/$rel")
}
}
finally { $zip.Dispose() }
Write-Host ''
Write-Host "dist/$n-cursor-v$ver.zip"
$read = [IO.Compression.ZipFile]::OpenRead($out)
try {
foreach ($e in $read.Entries) { Write-Host ('{0,9} {1}' -f $e.Length, $e.FullName) }
}
finally { $read.Dispose() }
}