Ka-Note/ka-note/scripts/show-bundle.ps1

31 lines
1003 B
PowerShell

param(
[string]$BundlePath
)
if (-not $BundlePath) {
$root = git rev-parse --show-toplevel
$BundlePath = "$root/work/kai-bundle.json"
}
if (-not (Test-Path $BundlePath)) {
Write-Host "NEIN - Bundle nicht gefunden: $BundlePath"
exit 1
}
$b = Get-Content $BundlePath -Raw | ConvertFrom-Json
Write-Host "Lock: $($b.manifest.lockToken)"
Write-Host "Expires: $($b.manifest.expiresAt)"
Write-Host ""
Write-Host "--- CONTEXTS ---"
$b.contexts | Where-Object { -not $_.deletedAt } | Sort-Object sortOrder | ForEach-Object {
$prefix = if ($_.id.Length -ge 8) { $_.id.Substring(0, 8) } else { $_.id }
Write-Host (" [{0}] {1} ({2})" -f $prefix, $_.name, $_.type)
}
Write-Host ""
Write-Host "--- TOPICS (active) ---"
$b.topics | Where-Object { $_.status -eq 'active' -and -not $_.deletedAt } | Sort-Object contextId, sortOrder | ForEach-Object {
$prefix = if ($_.id.Length -ge 8) { $_.id.Substring(0, 8) } else { $_.id }
Write-Host (" [{0}] {1}" -f $prefix, $_.title)
}