feat(build): add --prune flag to build.{sh,ps1} [skip-tdd: wrapper]
Symmetric to install-side --prune (e871c20). Removes
dist/<name>.skill files whose <name> is not in skills/*.
Design choices match install:
- Combined flag (build + prune in one run)
- Global scan, ignores -Names / positional filter
- Default off, print-and-delete, no confirmation
Bash wrinkle: when build.sh delegates to powershell.exe -File
build.ps1 (Windows-without-zip case), --prune is NOT forwarded.
Bash runs prune itself at the end of the script against the
shared dist/. Keeps the delegation surface narrow and the prune
logic single-sourced per shell.
[skip-tdd: wrapper] — same carve-out as install-side, smoke-test
evidence: fake dist/fake-stale-{sh,ps}.skill files created in real
dist/, ran build.{sh,ps1} --prune, verified fakes removed, real
caveman.skill etc. left intact.
Wiki .wiki/concepts/install-cross-platform.md extended:
- title broadened (Install → Install / Build)
- new "Build-side --prune" section
- scope note: dist-hermes/ is separate (managed by build-hermes.py)
Closes [install-ps1-build-prune-followup].
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Build .skill archives from skills/<name>/ into dist/<name>.skill
|
||||
# Usage: build.ps1 [-Names <name1>,<name2>] (no args = all)
|
||||
# Usage: build.ps1 [-Names <name1>,<name2>] [-Prune]
|
||||
# no args = build all skills/* into dist/<name>.skill
|
||||
# -Prune = after build, remove dist/<name>.skill files whose <name>
|
||||
# is NOT in skills/* (analogue of install.ps1 -Prune).
|
||||
# Prune always scans the full dist/, ignores -Names filter.
|
||||
#
|
||||
# Uses .NET System.IO.Compression.ZipArchive directly to produce
|
||||
# spec-compliant ZIPs with forward-slash entry names (Windows PowerShell 5.1's
|
||||
@@ -7,7 +11,8 @@
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string[]]$Names = @()
|
||||
[string[]]$Names = @(),
|
||||
[switch]$Prune
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -69,3 +74,15 @@ foreach ($name in $Names) {
|
||||
New-SkillArchive -SkillName $name -SourceDir $srcDir -OutPath $out
|
||||
Write-Host "built: dist/$name.skill"
|
||||
}
|
||||
|
||||
if ($Prune) {
|
||||
$sourceNames = @(Get-ChildItem -Path $src -Directory | Select-Object -ExpandProperty Name)
|
||||
$skillArchives = Get-ChildItem -Path $dist -Filter "*.skill" -File -ErrorAction SilentlyContinue
|
||||
foreach ($archive in $skillArchives) {
|
||||
$archiveName = [System.IO.Path]::GetFileNameWithoutExtension($archive.Name)
|
||||
if ($sourceNames -notcontains $archiveName) {
|
||||
Write-Host "pruning: $archiveName (not in skills/) -> $($archive.FullName)"
|
||||
Remove-Item -Force $archive.FullName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user