provisioning-code/justfiles/assets.just

89 lines
4.2 KiB
Text

# Asset sync + API catalog export
# Sync brand assets from the constellation parent (../assets/) into code/assets/.
# Canonical source: ../assets/ → materialized copy: code/assets/ (tracked in git)
[doc("Sync brand assets from constellation parent ../assets/ into code/assets/")]
sync-assets:
#!/usr/bin/env nu
let src = (($env.PWD | path dirname) | path join "assets")
let dst = ($env.PWD | path join "assets")
if not ($src | path exists) {
error make { msg: $"sync-assets: source not found: ($src)" }
}
def needs-copy [s: string, d: string]: nothing -> bool {
if not ($d | path exists) { return true }
(open --raw $s | hash sha256) != (open --raw $d | hash sha256)
}
def sync-file [s: string, d: string, label: string]: nothing -> record {
if (needs-copy $s $d) {
mkdir ($d | path dirname)
cp $s $d
{ file: $label, action: "copied", sha256: (open --raw $d | hash sha256) }
} else {
{ file: $label, action: "unchanged", sha256: (open --raw $d | hash sha256) }
}
}
mut results = []
for f in ["provisioning.svg", "provisioning_img.svg", "provisioning_v.svg"] {
let s = ($src | path join $f)
if ($s | path exists) {
$results = ($results | append (sync-file $s ($dst | path join $f) $f))
}
}
let digest_input = ($results | each { |r| $"($r.file):($r.sha256)" } | sort | str join "\n")
let aggregate = $"sha256:($digest_input | hash sha256)"
let synced_at = (date now | format date "%Y-%m-%dT%H:%M:%SZ")
{
source: ($src | into string),
aggregate_digest: $aggregate,
synced_at: $synced_at,
files: $results,
} | to json | save --force ($dst | path join ".sync-manifest.json")
let copied = ($results | where action == "copied" | length)
let unchanged = ($results | where action == "unchanged" | length)
print $"✓ sync-assets copied=($copied) unchanged=($unchanged) ($dst)"
# API catalog export
#
# Generates per-service api-catalog-*.json from #[onto_api] registered routes.
# Run after any handler annotation is added or changed.
# Commit alongside the annotation changes — they are paired artifacts.
PLATFORM_MANIFEST := "platform/Cargo.toml"
# Export #[onto_api] routes for all platform services
[doc("Export #[onto_api] routes for all platform services to api-catalog-*.json")]
export-api-catalog: export-api-catalog-orchestrator export-api-catalog-control-center export-api-catalog-catalog-registry export-api-catalog-ai-service
@echo "all platform API catalogs exported"
# Export orchestrator routes
[doc("Export orchestrator #[onto_api] routes to api-catalog-orchestrator.json")]
export-api-catalog-orchestrator:
cargo run --manifest-path {{PLATFORM_MANIFEST}} -p orchestrator --no-default-features --features "core,audit,compliance,platform,ssh,workflow,testing,http-api" -- --dump-api-catalog > api-catalog-orchestrator.json
@echo "orchestrator: $(cat api-catalog-orchestrator.json | jq length) routes"
# Export control-center routes
[doc("Export control-center #[onto_api] routes to api-catalog-control-center.json")]
export-api-catalog-control-center:
cargo run --manifest-path {{PLATFORM_MANIFEST}} -p control-center --no-default-features --features "core,kms,audit,mfa,compliance,experimental" -- --dump-api-catalog > api-catalog-control-center.json
@echo "control-center: $(cat api-catalog-control-center.json | jq length) routes"
# Export catalog-registry routes
[doc("Export catalog-registry #[onto_api] routes to api-catalog-catalog-registry.json")]
export-api-catalog-catalog-registry:
cargo run --manifest-path {{PLATFORM_MANIFEST}} -p catalog-registry --no-default-features -- --dump-api-catalog > api-catalog-catalog-registry.json
@echo "catalog-registry: $(cat api-catalog-catalog-registry.json | jq length) routes"
# Export ai-service routes
[doc("Export ai-service #[onto_api] routes to api-catalog-ai-service.json")]
export-api-catalog-ai-service:
cargo run --manifest-path {{PLATFORM_MANIFEST}} -p ai-service --no-default-features -- --dump-api-catalog > api-catalog-ai-service.json
@echo "ai-service: $(cat api-catalog-ai-service.json | jq length) routes"