seedproject-web/scripts/configure.mjs
Carlos Arias 0acc80f8e4 docs: add root AGENTS.md + CLAUDE.md for fresh-clone agents; fix agentUser leftover
- AGENTS.md / CLAUDE.md: tell any agent (Claude Code, astroagent, Codex) what the
  base is and the exact fresh-clone setup flow (new-site.sh / configure.mjs / build)
- configure.mjs: stamp astroagent ai.agentUser as <slug>-agent (was stale 'comiida-agent')

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SYHWLHihq3v9nxNwoPCKSn
2026-07-04 23:33:50 +00:00

60 lines
2.2 KiB
JavaScript
Executable file

#!/usr/bin/env node
/**
* configure.mjs — stamp site.config.json (the single source of identity) into
* every engine config. Run after editing site.config.json:
*
* node scripts/configure.mjs
*
* Writes:
* - app/src/config/site.json (Astro theme reads this)
* - content-pipeline/config.json (site identity + author + timezone)
* - astroagent.config.json (name + url)
*/
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const read = (p) => JSON.parse(readFileSync(resolve(root, p), "utf8"));
const write = (p, obj) => {
const full = resolve(root, p);
mkdirSync(dirname(full), { recursive: true });
writeFileSync(full, JSON.stringify(obj, null, 2) + "\n");
console.log(" wrote", p);
};
const slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
const site = read("site.config.json");
console.log(`Configuring site: ${site.name} <${site.url}>`);
// 1) Astro theme
write("app/src/config/site.json", {
name: site.name,
url: site.url,
description: site.description,
tagline: site.tagline,
language: site.language,
author: site.author,
social: site.social,
});
// 2) content-pipeline
if (existsSync(resolve(root, "content-pipeline/config.json"))) {
const cp = read("content-pipeline/config.json");
cp.site = { ...cp.site, url: site.url, name: site.name, topic: site.topic, audience: site.audience, language: site.language };
cp.author = { ...(cp.author || {}), slug: site.author.slug, name: site.author.name };
if (cp.editorial) cp.editorial.timezone = site.timezone;
if (cp.image && cp.image.credit) cp.image.credit.author = site.name;
write("content-pipeline/config.json", cp);
}
// 3) astroagent
if (existsSync(resolve(root, "astroagent.config.json"))) {
const aa = read("astroagent.config.json");
aa.name = slug(site.name);
aa.url = site.url;
if (aa.ai) aa.ai.agentUser = `${slug(site.name)}-agent`;
write("astroagent.config.json", aa);
}
console.log("Done. Rebuild the site: (cd app && npm run build)");