# push-all.ps1 -- push every crate repo (each crate is its own git repo; the
# root C:\dev\fuke is NOT a repo).
#
# Rule: push before publish -- check-package.ps1 (strict) requires a clean tree,
# and the published content must have a source of truth on cnb.cool.
#
# Usage: powershell -ExecutionPolicy Bypass -File scripts/push-all.ps1
# Exit: 0 = all repos pushed, 1 = at least one repo not pushed (per-line report).
# NOTE: ASCII-only on purpose (PS5.1 decodes BOM-less .ps1 as ANSI).
[CmdletBinding()]
param()
$ErrorActionPreference = 'Continue'
$order = @(
'ek-core', 'ek-event', 'ek-data', 'ek-converter', 'ek-cfg', 'ek-ctp',
'ek-dm', 'ek-oms', 'ek-risk', 'ek-station', 'ek-tq', 'ek-ui'
)
$root = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
$fail = 0
foreach ($c in $order) {
Push-Location (Join-Path $root $c)
$dirty = git status --porcelain
if ($dirty) {
Write-Host (" SKIP {0}: working tree dirty (commit first)" -f $c) -ForegroundColor Yellow
$fail++
Pop-Location
continue
}
$ahead = git rev-list --count '@{u}..HEAD' 2>$null
$log = Join-Path $root ("target\push-" + $c + ".log")
& git push origin main *> $log
$code = $LASTEXITCODE
if ($code -eq 0) {
Write-Host (" OK {0} (pushed {1} commits ahead)" -f $c, $ahead) -ForegroundColor Green
} else {
Write-Host (" FAIL {0} (exit {1}) -> {2}" -f $c, $code, $log) -ForegroundColor Red
$fail++
}
Pop-Location
}
Write-Host ("pushed: " + ($order.Count - $fail) + "/" + $order.Count) -ForegroundColor Cyan
if ($fail -eq 0) { exit 0 } else { exit 1 }