mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-07 16:19:38 -04:00
7454329a08
# Description of Changes Adds `tools/templates/` scripts to derive template metadata from manifests and generate READMEs from quickstart docs. Replaces slug-based `builtWith` with manifest-derived data and hardcoded quickstart mappings with discovery from docs. **Manifest-based `builtWith`** (`update-template-jsons.ts`) - Reads `package.json`, `Cargo.toml`, and `.csproj` to populate `builtWith` in `.template.json`. - Scoped npm packages normalize to scope (`@angular/core` → `angular`). Excludes `@types/*`. Adds `nodejs` only for nodejs-ts when `@types/node` is present. - Root manifests processed before subdirs; primary framework first (e.g. `react` before `spacetimedb` in react-ts). Dependencies reordered in package.json where needed. **Dynamic quickstart discovery** (`generate-template-readmes.ts`) - Discovers template → quickstart by parsing `--template X` from files in `docs/docs/00100-intro/00200-quickstarts/`. - Optional `quickstart` override in `.template.json`; must resolve under quickstarts dir. - chat-react-ts has no quickstart; uses manual README. **New:** `tools/templates/` (update-template-jsons.ts, generate-template-readmes.ts, README, package.json, pnpm-lock). **Modified:** all `templates/*/.template.json` (added `builtWith`), new/generated `templates/*/README.md`. # API and ABI breaking changes None. # Expected complexity level and risk **1** – Dev tooling only. No runtime or API changes. Scripts are isolated; failures only affect generated metadata and READMEs. # Testing - [ ] `cd tools/templates && pnpm run generate` completes without errors - [ ] Spot-check `builtWith` and generated READMEs for a few templates
Template Tools
Scripts for maintaining template READMEs and metadata in the SpacetimeDB repo. Output is consumed by spacetimedb.com for the templates page.
Scripts
- generate-readmes – Converts quickstart MDX docs to Markdown and writes
templates/<slug>/README.md. Discovers mappings by parsing--template Xfrom quickstart files. Templates can override with aquickstartfield in.template.json(must point to a file in the quickstarts dir). - update-jsons – Updates
builtWithin eachtemplates/<slug>/.template.jsonfrom package.json, Cargo.toml, and .csproj manifests - generate – Runs both (readmes first, then jsons)
Usage
From this directory:
pnpm install
pnpm run generate
Or individually:
pnpm run generate-readmes
pnpm run update-jsons
When to run
Run after changing quickstart docs (docs/docs/00100-intro/00200-quickstarts/) or adding/renaming templates. Commit the generated READMEs and updated .template.json files.