Files
loki/scripts/generate-fleet-sites.ts
CatoandClaude Fable 5.1 95c40a9cd8 refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now
share one name. 638 files, ~3,000 mentions: UI copy, config, env keys
(FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs,
articles, the deploy workflow other repos reuse, and nine file names.

- Three article slugs carried the old name and had been shared; permanent
  redirects keep those links alive (next.config.ts).
- test-no-retired-name.sh now also forbids the old product name across the
  whole repo, so the rename cannot creep back through templates and examples.
- ASSISTANT_STACK collapses the product and the assistant into one entry,
  because they are now the same name.

Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki`
database and role, loki.orangecat.ch (old host 308s to it; /api, /widget,
/embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases.
The Resend sending domain stays fleetcrown.orangecat.ch until the new domain
is verified in DNS.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:13:10 -07:00

73 lines
2.9 KiB
TypeScript

// Derive src/config/fleet-sites.ts from apps.conf.
//
// The footer is a client component and cannot read the register at render, and
// Atlas needs a static, crawlable anchor per site on the homepage. So the list
// is a generated file: derived from the hosting SSOT, checked in, and gated by
// scripts/test/fleet-sites-derived.ts, which fails the moment it drifts.
//
// Listed: rows whose status is live or validating and whose kind is a product
// or client work. Demos, prospects, infra and libraries are not "the fleet".
//
// Run: npx tsx scripts/generate-fleet-sites.ts (writes the file)
// npx tsx scripts/generate-fleet-sites.ts --stdout (prints it)
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { readAppsConf, hostedUrl, type HostedApp } from "@/lib/register/apps-conf";
import { canonicalSlug } from "@/lib/register/build";
import { FLEET_SITE_COPY } from "@/config/fleet-site-copy";
const LISTED_STATUS = new Set(["live", "validating"]);
const LISTED_KIND = new Set(["product", "client-app", "client-site"]);
export function listedSites(apps: HostedApp[]) {
return apps
.filter((a) => LISTED_STATUS.has(a.status) && LISTED_KIND.has(a.kind) && hostedUrl(a))
.map((a) => {
const slug = canonicalSlug(a.name);
const copy = FLEET_SITE_COPY[slug];
return { slug, name: copy?.name ?? a.name, url: hostedUrl(a)!, blurb: copy?.blurb ?? "" };
})
.sort((x, y) => x.name.localeCompare(y.name));
}
export function renderFleetSites(apps: HostedApp[]): string {
const sites = listedSites(apps).filter((s) => s.url !== "https://loki.orangecat.ch");
const body = sites
.map(
(s) =>
` {\n name: ${JSON.stringify(s.name)},\n url: ${JSON.stringify(s.url)},\n blurb: ${JSON.stringify(s.blurb)},\n },`,
)
.join("\n");
return `/**
* GENERATED by scripts/generate-fleet-sites.ts from scripts/hetzner/apps.conf.
* Do not edit: scripts/test/fleet-sites-derived.ts fails when this drifts.
* Copy lives in src/config/fleet-site-copy.ts; the LIST lives in apps.conf.
*
* Why derived: the hand-kept version named a host that had been renamed and
* missed twelve live ones. A list nobody regenerates is a list that lies.
*/
export type FleetSite = {
/** The site's own name, as it titles itself. */
name: string;
url: string;
/** One line, condensed from the site's own meta description. */
blurb: string;
};
/** Ordered by name. Loki itself is absent on purpose. */
export const FLEET_SITES: readonly FleetSite[] = [
${body}
];
`;
}
if (process.argv[1]?.endsWith("generate-fleet-sites.ts")) {
const out = renderFleetSites(readAppsConf());
if (process.argv.includes("--stdout")) process.stdout.write(out);
else {
const target = join(process.cwd(), "src/config/fleet-sites.ts");
writeFileSync(target, out);
console.log(`wrote ${target} (${(out.match(/url:/g) || []).length} sites)`);
}
}