CI / frontend (push) Successful in 3m11s
CI / backend (push) Successful in 2m27s
CI / storybook-a11y (push) Successful in 9m28s
CI / e2e (push) Successful in 4m38s
CI / semgrep (push) Successful in 1m20s
CI / api-client-drift (push) Successful in 2m13s
Runnable `npm run gen:value-object` / `gen:form-machine` (plop) that scaffold the two
pure-TS house patterns with a co-located spec: a branded value object + parseX (mirrors
postcode/bsn), and an Elm-style form/wizard machine (Draft/Valid/Errors + Editing/
Submitting/Submitted/Failed union + initial/pure reduce/assertNever). Prompts take
context + PascalCase name (positional-arg bypass); a post-action reminds to add the
English target for the generated $localize id. Templates in plop-templates/ (prettier-
ignored). Skills (value-object, form-machine) point at the generators. ui-component +
bff-endpoint stay skill-driven (Angular {{}} / backend + gen:api).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
48 lines
2.5 KiB
Markdown
48 lines
2.5 KiB
Markdown
# WP-43 — Runnable leaf generators
|
|
|
|
Status: done (value-object + form-machine; ui-component/bff-endpoint kept as skills)
|
|
Phase: 8 — platform/DX/showcase
|
|
Priority: P3
|
|
|
|
## Outcome
|
|
|
|
Tool = **plop**. `plopfile.mjs` + `plop-templates/` provide two runnable generators for the pure-TS
|
|
patterns: `npm run gen:value-object` (branded type + `parseX` + spec, mirrors postcode/bsn) and
|
|
`npm run gen:form-machine` (Draft/Valid/Errors + Editing/Submitting/Submitted/Failed union +
|
|
`initial`/pure `reduce`/`assertNever` + spec, mirrors change-request.machine). Prompts take
|
|
context + PascalCase name (positional-arg bypass for scripting); each emits a co-located spec so the
|
|
"pure logic must have a spec" rule holds by default; a post-action reminds to add the English
|
|
`<target>` for the generated `$localize` id. Smoke-tested (both generate → lint + dep:check clean),
|
|
then the demo output removed. Skills (`value-object`, `form-machine`) point at the generator.
|
|
`plop-templates/` is prettier-ignored (Handlebars, not TS).
|
|
|
|
**Scoped out (kept as skills):** `gen:ui-component` (Angular template `{{ }}` collides with
|
|
Handlebars) and `gen:bff-endpoint` (spans the C# backend + `gen:api` regen) — a generator adds
|
|
little over the recipe there.
|
|
|
|
## Why
|
|
|
|
The house patterns (value object, form machine, bff endpoint, ui component) are documented only as
|
|
agent-executed prose skills; there's no `npm run gen:*` a developer runs to emit the boilerplate.
|
|
For a template meant to bootstrap real registers, mechanise the highest-churn recipes.
|
|
|
|
## Decisions
|
|
|
|
- **Step 1 — tool fork:** plop (recommended: tiny, readable templates, `npm run gen:*`) vs Angular
|
|
schematics (native `ng generate`, heavier to author). Decide before building.
|
|
- Generators emit house-pattern files **with co-located spec/story**, matching current idioms:
|
|
`gen:value-object`, `gen:form-machine` (page/wizard), `gen:bff-endpoint`, `gen:ui-component`.
|
|
- Templates become the single source; each matching skill gets a one-line "run `npm run gen:x`, then …".
|
|
|
|
## Files
|
|
|
|
- New `plopfile.mjs` (or `schematics/`) + template files; `package.json` `gen:*` scripts.
|
|
- Update the corresponding `.claude/skills/*/SKILL.md` to invoke the generator.
|
|
|
|
## Acceptance criteria
|
|
|
|
- [x] `gen:value-object` + `gen:form-machine` emit files that pass `npm run lint` + `dep:check`
|
|
with no hand-edits beyond the domain specifics (rule/fields) + the en.xlf target.
|
|
- [x] Generated units include their co-located spec.
|
|
- [x] Smoke-tested both; `npm run ci` green.
|