Files
bradleyshep 7454329a08 Template README + template.json generation tool (#4570)
# 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
2026-03-20 13:01:58 +00:00
..

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 X from quickstart files. Templates can override with a quickstart field in .template.json (must point to a file in the quickstarts dir).
  • update-jsons Updates builtWith in each templates/<slug>/.template.json from 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.