generate
Generate language-native typed event wrappers from the spec registry.
Synopsis
event-spec generate [source] [flags]
Flags
| Flag | Default | Description |
|---|---|---|
--lang | "" | Target language: go | typescript. Required when no source is specified. Overrides source config. |
--out | ./generated | Output directory for generated files. Overrides source config. |
Usage
With a source config (recommended)
event-spec generate web-app
Reads sources/web-app.yaml for language, output path, event filters, and version pinning. No flags required.
Ad-hoc flags
# Go
event-spec generate --lang go --out ./generated
# TypeScript
event-spec generate --lang typescript --out ./src/analytics/generated
Without event-spec.yaml
The CLI falls back to ./specs when no workspace config is found:
event-spec generate --lang go --out ./gen
Source config
Source configs allow per-app settings and event filtering:
sources/web-app.yaml
name: web-app
platform: web
language: typescript
events:
- ecommerce/** # all events in the ecommerce namespace
- auth/user_signed_up # single event
output:
path: ./src/analytics/generated
package: "@my-company/analytics"
Events patterns support glob syntax. Unmatched events are excluded from codegen.
Output
generated 8 event(s) to ./src/analytics/generated
Files generated:
- One
index.ts/eventspec.goentry point - One file per event:
<namespace>/<event_name>.<ext>
Generated files are marked // Code generated by event-spec. DO NOT EDIT. — commit them to source control and regenerate when specs change.
CI usage
# Regenerate and fail if the working tree changes (drift detection)
event-spec generate web-app
git diff --exit-code generated/