/** * Runnable house-pattern generators (WP-43). `npm run gen ` or the `gen:*` scripts. * These emit the boilerplate the skills used to describe by hand; each generated unit ships * with its co-located spec so the "domain/pure logic must have a spec" rule holds by default. * * Generators here are the pure-TS patterns (no Angular-template escaping): value objects and * form/wizard state machines. The UI-component and bff-endpoint patterns stay skill-driven — * they span the template `{{ }}` syntax / the C# backend + `gen:api` regen, where a generator * adds little over the recipe. * * Positional args skip the prompts, e.g. `npx plop value-object registratie KvkNummer`. */ export default function (plop) { const CONTEXT_PROMPT = { type: 'input', name: 'context', message: 'Context (shared | auth | registratie | herregistratie | brief | beheer):', }; const remindEnXlf = () => '⚠ The generated $localize id needs an English in src/locale/messages.en.xlf before `npm run ci` (the localize gate fails otherwise).'; plop.setGenerator('value-object', { description: 'Branded value object + parser + spec ("parse, don\'t validate")', prompts: [ CONTEXT_PROMPT, { type: 'input', name: 'name', message: 'Name (PascalCase, e.g. KvkNummer):' }, ], actions: [ { type: 'add', path: 'src/app/{{context}}/domain/value-objects/{{kebabCase name}}.ts', templateFile: 'plop-templates/value-object.hbs', }, { type: 'add', path: 'src/app/{{context}}/domain/value-objects/{{kebabCase name}}.spec.ts', templateFile: 'plop-templates/value-object.spec.hbs', }, remindEnXlf, ], }); plop.setGenerator('form-machine', { description: 'Elm-style form/wizard state machine (Model/Msg/pure reduce) + spec', prompts: [ CONTEXT_PROMPT, { type: 'input', name: 'name', message: 'Machine name (PascalCase, e.g. Adreswijziging):' }, ], actions: [ { type: 'add', path: 'src/app/{{context}}/domain/{{kebabCase name}}.machine.ts', templateFile: 'plop-templates/form-machine.hbs', }, { type: 'add', path: 'src/app/{{context}}/domain/{{kebabCase name}}.machine.spec.ts', templateFile: 'plop-templates/form-machine.spec.hbs', }, remindEnXlf, ], }); }