ontoref/.ontoref/gen-registry.nu
Jesús Pérez c5be37dcd5
Some checks failed
Nickel Type Check / Nickel Type Checking (push) Has been cancelled
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
chore: fix errors in registry projects and skip if project setting fails
2026-03-13 01:19:53 +00:00

36 lines
1.3 KiB
Plaintext

#!/usr/bin/env nu
# .ontoref/gen-registry.nu
# Reads registry.ncl, validates project paths, and writes registry.toml.
# registry.ncl is the source of truth; registry.toml is derived — do not edit it by hand.
def main [] {
let script_dir = ($env.CURRENT_FILE | path dirname)
let ncl_file = $"($script_dir)/registry.ncl"
let toml_file = $"($script_dir)/registry.toml"
let result = (do { ^nickel export --format json $ncl_file } | complete)
if $result.exit_code != 0 {
error make { msg: $"nickel export failed:\n($result.stderr)" }
}
let registry = ($result.stdout | from json)
let valid_projects = ($registry.projects | each { |p|
if ($p.root | path exists) {
$p
} else {
print $" (ansi yellow)WARN(ansi reset) project '($p.slug)': root not found at ($p.root) — skipping"
null
}
} | compact)
let skipped = ($registry.projects | length) - ($valid_projects | length)
if $skipped > 0 {
print $" (ansi yellow)($skipped) project(s) skipped due to missing paths(ansi reset)"
}
{ projects: $valid_projects } | to toml | save -f $toml_file
print $" (ansi green)OK(ansi reset) ($valid_projects | length) project\(s\) written to ($toml_file)"
}