2026-03-29 00:19:56 +00:00
|
|
|
# Frontend asset management
|
|
|
|
|
#
|
2026-07-10 01:44:59 +01:00
|
|
|
# Constellation layout: canonical assets live at ../assets/ (parent repo).
|
|
|
|
|
# code/assets/ is a materialized copy populated by `just sync-assets`.
|
2026-03-29 00:19:56 +00:00
|
|
|
# Vendored JS libs live in assets/vendor/ and are served by the daemon
|
|
|
|
|
# at /assets/vendor/<file>. Pin versions explicitly; bump manually.
|
|
|
|
|
#
|
|
|
|
|
# Pattern guide: reflection/templates/vendor-frontend-assets-prompt.md
|
|
|
|
|
|
|
|
|
|
CYTOSCAPE_NAVIGATOR_VERSION := "2.0.1"
|
2026-03-29 08:32:50 +01:00
|
|
|
HTMX_VERSION := "2.0.7"
|
2026-03-29 00:19:56 +00:00
|
|
|
|
2026-07-10 01:44:59 +01:00
|
|
|
# Sync assets from the constellation parent (../assets/) into code/assets/.
|
|
|
|
|
# Copies CSS build source, vendor JS, and logos needed by this repo.
|
|
|
|
|
# Skips files unchanged by content hash. Writes assets/.sync-manifest.json
|
|
|
|
|
# with source path and per-file digests (precursor to ore sync assets mode).
|
|
|
|
|
[doc("Sync 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 at ($src)" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Returns true when dst is missing or its sha256 differs from 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 = []
|
|
|
|
|
|
|
|
|
|
# CSS build source — node_modules excluded (pnpm install regenerates it)
|
|
|
|
|
for f in ["package.json", "uno.config.js", "tailwind.config.js"] {
|
|
|
|
|
let s = ($src | path join "css" $f)
|
|
|
|
|
if ($s | path exists) {
|
|
|
|
|
$results = ($results | append (sync-file $s ($dst | path join "css" $f) $"css/($f)"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Vendor JS
|
|
|
|
|
let vendor_src = ($src | path join "vendor")
|
|
|
|
|
if ($vendor_src | path exists) {
|
|
|
|
|
mkdir ($dst | path join "vendor")
|
|
|
|
|
for f in (ls $vendor_src | where type == file | get name) {
|
|
|
|
|
let name = ($f | path basename)
|
|
|
|
|
$results = ($results | append (sync-file $f ($dst | path join "vendor" $name) $"vendor/($name)"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Logos referenced by README.md and docs
|
|
|
|
|
for f in ["ontoref-logo.svg", "ontoref.svg", "ontoref_text.svg", "ontoref_v.svg"] {
|
|
|
|
|
let s = ($src | path join $f)
|
|
|
|
|
if ($s | path exists) {
|
|
|
|
|
$results = ($results | append (sync-file $s ($dst | path join $f) $f))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Aggregate digest: sha256 of sorted "file:sha256\n" pairs (same algorithm as ore sync assets)
|
|
|
|
|
let file_hashes = ($results | each { |r| $"($r.file):($r.sha256)" } | sort | str join "\n")
|
|
|
|
|
let aggregate = $"sha256:($file_hashes | 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)"
|
|
|
|
|
|
2026-03-29 00:19:56 +00:00
|
|
|
# Export this daemon's API catalog to api-catalog.json.
|
|
|
|
|
# Run after any #[onto_api] annotation is added or changed.
|
|
|
|
|
# The file is read by the ontoref UI when this project is registered as a
|
|
|
|
|
# non-primary slug — consumer projects that run as separate binaries use this
|
|
|
|
|
# to expose their API surface in the ontoref UI.
|
2026-03-29 08:32:50 +01:00
|
|
|
[doc("Export #[onto_api] routes to artifacts/api-catalog-ontoref-daemon.ncl")]
|
2026-03-29 00:19:56 +00:00
|
|
|
export-api-catalog:
|
2026-03-29 08:32:50 +01:00
|
|
|
mkdir -p artifacts
|
|
|
|
|
cargo run -p ontoref-daemon --no-default-features -- --dump-api-catalog > artifacts/api-catalog-ontoref-daemon.ncl
|
|
|
|
|
@echo "exported routes to artifacts/api-catalog-ontoref-daemon.ncl"
|
2026-03-29 00:19:56 +00:00
|
|
|
|
|
|
|
|
# Download/update all vendored frontend JS dependencies
|
|
|
|
|
[doc("Vendor all frontend JS dependencies")]
|
2026-03-29 08:32:50 +01:00
|
|
|
vendor-js: vendor-cytoscape-navigator vendor-htmx
|
2026-03-29 00:19:56 +00:00
|
|
|
|
|
|
|
|
# cytoscape-navigator — minimap extension for Cytoscape.js
|
|
|
|
|
[doc("Vendor cytoscape-navigator (minimap)")]
|
|
|
|
|
vendor-cytoscape-navigator:
|
|
|
|
|
mkdir -p assets/vendor
|
|
|
|
|
curl -fsSL \
|
|
|
|
|
"https://cdn.jsdelivr.net/npm/cytoscape-navigator@{{CYTOSCAPE_NAVIGATOR_VERSION}}/cytoscape-navigator.js" \
|
|
|
|
|
-o assets/vendor/cytoscape-navigator.js
|
|
|
|
|
@echo "vendored cytoscape-navigator@{{CYTOSCAPE_NAVIGATOR_VERSION}}"
|
2026-03-29 08:32:50 +01:00
|
|
|
|
|
|
|
|
# htmx — HTML-first hypermedia library (goes to public/vendor — served via /public/)
|
|
|
|
|
[doc("Vendor htmx")]
|
|
|
|
|
vendor-htmx:
|
|
|
|
|
mkdir -p crates/ontoref-daemon/public/vendor
|
|
|
|
|
curl -fsSL \
|
|
|
|
|
"https://cdn.jsdelivr.net/npm/htmx.org@{{HTMX_VERSION}}/dist/htmx.min.js" \
|
|
|
|
|
-o crates/ontoref-daemon/public/vendor/htmx.min.js
|
|
|
|
|
@echo "vendored htmx@{{HTMX_VERSION}}"
|