You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.8 KiB
47 lines
1.8 KiB
|
17 hours ago
|
# deploy-bruno-t12.ps1 - ticket 12g: copy staging tree into docs repo (conflict precheck + copy + verify + ledger)
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
$src = 'e:\code\crm-backend-matt\.scratch\a7-parity\t12-bru'
|
||
|
|
$dst = 'E:\code\crm-api-docs'
|
||
|
|
|
||
|
|
$files = Get-ChildItem -LiteralPath $src -Recurse -File -Filter '*.bru'
|
||
|
|
Write-Output ("source files: {0}" -f $files.Count)
|
||
|
|
|
||
|
|
# 1. conflict precheck: any same-name file already in docs repo -> abort (never overwrite silently)
|
||
|
|
$conflicts = @()
|
||
|
|
foreach ($f in $files) {
|
||
|
|
$rel = $f.FullName.Substring($src.Length).TrimStart('\')
|
||
|
|
$target = Join-Path $dst $rel
|
||
|
|
if (Test-Path -LiteralPath $target) { $conflicts += $rel }
|
||
|
|
}
|
||
|
|
if ($conflicts.Count -gt 0) {
|
||
|
|
Write-Output ("ABORT: {0} target files already exist:" -f $conflicts.Count)
|
||
|
|
$conflicts | ForEach-Object { Write-Output (" {0}" -f $_) }
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
|
||
|
|
# 2. copy (create parent dirs as needed)
|
||
|
|
$copied = 0
|
||
|
|
foreach ($f in $files) {
|
||
|
|
$rel = $f.FullName.Substring($src.Length).TrimStart('\')
|
||
|
|
$target = Join-Path $dst $rel
|
||
|
|
$targetDir = Split-Path -Parent $target
|
||
|
|
if (-not (Test-Path -LiteralPath $targetDir)) {
|
||
|
|
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
|
||
|
|
}
|
||
|
|
Copy-Item -LiteralPath $f.FullName -Destination $target -Force
|
||
|
|
$copied++
|
||
|
|
}
|
||
|
|
|
||
|
|
# 3. verify: exists + byte size matches source
|
||
|
|
$errors = @()
|
||
|
|
foreach ($f in $files) {
|
||
|
|
$rel = $f.FullName.Substring($src.Length).TrimStart('\')
|
||
|
|
$target = Join-Path $dst $rel
|
||
|
|
if (-not (Test-Path -LiteralPath $target)) { $errors += ("missing: {0}" -f $rel); continue }
|
||
|
|
if ((Get-Item -LiteralPath $target).Length -ne $f.Length) { $errors += ("size-mismatch: {0}" -f $rel) }
|
||
|
|
}
|
||
|
|
|
||
|
|
Write-Output ("copied={0} errors={1}" -f $copied, $errors.Count)
|
||
|
|
$errors | ForEach-Object { Write-Output ("ERR {0}" -f $_) }
|
||
|
|
if ($errors.Count -gt 0) { exit 1 }
|