microsite-cli
CLI tool for initializing, updating, and validating raycool.dev microsites.
Overview
microsite-cli scaffolds and maintains microsites for the raycool.dev card-stream ecosystem, keeping the evergreen contract intact and enabling optional database syncs.
public/site, manage cards in index.json, sync HTML resources, validate/fix contract issues, and launch the Setup Wizard UI.
Installation
pip install -e .
Quickstart
microsite init /path/to/repo # create public/site, templates, index.json, and a first card
microsite add /path/to/repo --title "Release" # add a new card + details markdown
microsite update /path/to/repo # rescan HTML resources and refresh card paths
microsite validate /path/to/repo # validate the contract and filesystem
microsite fix /path/to/repo # auto-fix common validation issues
microsite sync-db /path/to/repo --db-url ... # push cards to PostgreSQL
microsite ui --host 127.0.0.1 --port 0 # launch the Setup Wizard UI (Ctrl+C to stop)
microsite version # print tool version
--json for structured output.Command Reference
Details for every CLI entry point, in the same order as the README.
microsite init
Ensures public/site exists, writes the bundled index.html/details.md templates, and seeds index.json.
- Creates a first card and details markdown by default; use
--no-first-cardto skip or--first-cardto force when re-running. - Flags:
--slug,--repo-name,--title,--level,--purpose,--summary,--date,--source,--source-type,--source-label,--source-url,--source-ref.
microsite add
Adds a new card to index.json and creates its details markdown using the bundled template.
- Infers slug/repo name from the folder; auto-increments the sequence for matching slug/level/date.
- Flags:
--title(required),--level,--purpose,--summary,--date,--source-type,--source-label,--source-url,--source-ref,--dry-run.
microsite update
Rescans public/site for .html files, sets micro_site_home to index.html, and refreshes paths.resources for every card.
- Warns when
index.htmlis missing, when card details files are absent, or whendetails_mddoes not match the expected filename.
microsite validate
Validates contract fields and filesystem state.
- Checks required fields/types, normalized slugs, allowed levels, ISO dates, and that
index.jsonis a list. - Enforces
micro_site_home == index.htmlwhen present and requires eitherdetails_mdordetails_html. - Verifies details files exist, match
details/<id>.md, and have no YAML frontmatter or<iframe>/<script>tags. - Ensures referenced local resources exist; exits non-zero when errors are found.
microsite fix
Auto-fixes common validation issues without creating new content.
- Ensures
pathsexists, setsmicro_site_hometoindex.html, and removes references to missingdetails_md/details_html. - Relinks standard detail paths if files already exist (e.g.,
details/<id>.md); respects--dry-runto preview.
microsite sync-db
Synchronizes index.json to PostgreSQL with psycopg2; uses --db-url or MICROSITE_DB_URL.
- Upserts a repo record (default
base_url:https://raycool.dev/microsites/<slug>) and all cards, includingpaths,source, andtypewhen set. - Fails fast on missing/invalid
index.jsonor connection info and reports the count of synced cards.
microsite ui
Launches the Setup Wizard UI via a tiny stdlib HTTP server; accepts an optional repo path, --host, --port (use 0 for a free port), and --no-browser.
- Inference (
/infer) requires a repo path and Git URL; returns slug, repo name, branch (viagit symbolic-reffallbackmain), detected HTML resources, and site structure signals. - Snapshot (
/snapshot) lists cards, details markdown, and HTML resources, highlighting missingindex.json, missing details, orphan details, non-HTML resources, and missing resource files. - Generate (
/generate) runsinit+updatewith provided title/summary/purpose/level, uses Git metadata forsource, creates placeholder HTML resources when requested, and surfaces update warnings. - Auto-opens the browser unless
--no-browseris set.
microsite version
Prints the CLI version.
Evergreen Contract
- Required fields:
id,slug,title,summary,date,repo,level,purpose, andpaths. - Card IDs follow
<slug>-<level>-<yyyy-mm-dd>-<seq>(three-digit sequence); details markdown is expected atdetails/<id>.md. paths.micro_site_homemust beindex.htmlwhen it exists; other HTML underpublic/sitebelong inpaths.resources.- Details markdown must avoid duplicated metadata/frontmatter and unsafe HTML tags (
iframe,script); referenced local resources must exist.
Project Layout
microsite-cli/
microsite/
cli.py
core/
add.py
fix.py
init.py
sync.py
update.py
validate.py
utils.py
schema.py
templates/
index.html
details.md
ui_assets/
ui_server.py
VERSION
tests/
pyproject.toml
requirements.txt