Restructures into apps/ssp + apps/behandelportal (two Angular projects) plus libs/shared + libs/beheer (cross-app libraries), replacing WP-61's separate sibling repo. That split had already produced real drift: a hand-vendored copy of the backend's OpenAPI doc, a shared/ui+layout tree forked and silently diverging (7 files), and beheer + the styles.scss token bridge duplicated byte-for-byte across both repos. - git mv the SSP's src/app/* into apps/ssp/; fold shared/, beheer/, environments/, the Storybook docs/*.mdx, and styles.scss into libs/shared + libs/beheer (all confirmed identical between the two repos before merging). auth stays deliberately duplicated per ADR-0002 (actor-specific, expected to diverge) - amended there. - One generated API client (libs/shared), no more vendored swagger.json. - .dependency-cruiser split into a base factory + one config per app, and Storybook into .storybook-ssp/.storybook-behandelportal - both forced by the @auth/* alias resolving to different directories per app. - SiteHeaderComponent/ShellComponent gained HEADER_NAV_ITEMS/ HEADER_ADMIN_LINKS/DEBUG_PANEL injection tokens so each app supplies its own nav/admin-links/dev-panel instead of one being hardcoded. - CLAUDE.md, ARCHITECTURE.md, dependencies.md, and ADR-0002 updated; WP-67 backlog entry documents the full decision trail. npm run ci green (lint, dep:check x2, 360 tests across ssp/ behandelportal/shared/beheer, both localized builds, backend tests, snippet + api-client drift); both dev servers, both Storybook instances, and docker compose verified working. The old sibling repo (/home/eho/repos/behandelportal) is left untouched, not deleted. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
151 lines
6.0 KiB
JavaScript
151 lines
6.0 KiB
JavaScript
/**
|
|
* Runnable house-pattern generators (WP-43). `npm run gen <name>` 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. `context` (WP-44) mechanises the `new-context` skill's manual
|
|
* multi-file edit: folders + tsconfig alias + boundary entry + lazy route.
|
|
*
|
|
* Positional args skip the prompts, e.g. `npx plop value-object registratie KvkNummer`.
|
|
*/
|
|
export default function (plop) {
|
|
// WP-67: shared/beheer moved to libs/ (cross-app libraries); every other context is
|
|
// ssp-only today (behandelportal has its own auth/behandeling, not covered by this
|
|
// ssp-assuming heuristic — run these generators by hand for a behandelportal context).
|
|
const LIBS = ['shared', 'beheer'];
|
|
plop.setHelper('ctxRoot', (context) =>
|
|
LIBS.includes(context) ? `libs/${context}/src` : `apps/ssp/src/app/${context}`,
|
|
);
|
|
|
|
const CONTEXT_PROMPT = {
|
|
type: 'input',
|
|
name: 'context',
|
|
message: 'Context (shared | beheer | auth | registratie | herregistratie | brief):',
|
|
};
|
|
const remindEnXlf = () =>
|
|
'⚠ The generated $localize id needs an English <target> in apps/ssp/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: '{{ctxRoot context}}/domain/value-objects/{{kebabCase name}}.ts',
|
|
templateFile: 'plop-templates/value-object.hbs',
|
|
},
|
|
{
|
|
type: 'add',
|
|
path: '{{ctxRoot 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: '{{ctxRoot context}}/domain/{{kebabCase name}}.machine.ts',
|
|
templateFile: 'plop-templates/form-machine.hbs',
|
|
},
|
|
{
|
|
type: 'add',
|
|
path: '{{ctxRoot context}}/domain/{{kebabCase name}}.machine.spec.ts',
|
|
templateFile: 'plop-templates/form-machine.spec.hbs',
|
|
},
|
|
remindEnXlf,
|
|
],
|
|
});
|
|
|
|
plop.setGenerator('context', {
|
|
description:
|
|
'Scaffold a bounded context: folders + tsconfig alias + boundary entry + lazy route',
|
|
prompts: [
|
|
{
|
|
type: 'input',
|
|
name: 'name',
|
|
message: 'Context name (lowercase, single Dutch ubiquitous term, e.g. vergunning):',
|
|
},
|
|
],
|
|
actions: [
|
|
// WP-67: this generator only scaffolds an ssp context — behandelportal's contexts
|
|
// (auth, behandeling) predate it and aren't covered by this heuristic.
|
|
{
|
|
type: 'add',
|
|
path: 'apps/ssp/src/app/{{kebabCase name}}/ui/{{kebabCase name}}.page.ts',
|
|
templateFile: 'plop-templates/context.page.hbs',
|
|
},
|
|
{
|
|
type: 'add',
|
|
path: 'apps/ssp/src/app/{{kebabCase name}}/domain/.gitkeep',
|
|
templateFile: 'plop-templates/gitkeep.hbs',
|
|
},
|
|
{
|
|
type: 'add',
|
|
path: 'apps/ssp/src/app/{{kebabCase name}}/application/.gitkeep',
|
|
templateFile: 'plop-templates/gitkeep.hbs',
|
|
},
|
|
{
|
|
type: 'add',
|
|
path: 'apps/ssp/src/app/{{kebabCase name}}/infrastructure/.gitkeep',
|
|
templateFile: 'plop-templates/gitkeep.hbs',
|
|
},
|
|
{
|
|
type: 'add',
|
|
path: 'apps/ssp/src/app/{{kebabCase name}}/contracts/.gitkeep',
|
|
templateFile: 'plop-templates/gitkeep.hbs',
|
|
},
|
|
{
|
|
// tsconfig path alias — inserted right after the `"paths": {` line so it's stable
|
|
// across repeated runs regardless of what's already been added.
|
|
type: 'modify',
|
|
path: 'apps/ssp/tsconfig.json',
|
|
pattern: /"paths": \{\n/,
|
|
template: '"paths": {\n "@{{kebabCase name}}/*": ["src/app/{{kebabCase name}}/*"],\n',
|
|
},
|
|
{
|
|
// Boundary entry (WP-38's single source of truth) — inserted right after the
|
|
// ssp dep-cruiser config's CONTEXT_ALLOWED object literal opens, which never moves.
|
|
// (Previously anchored on the `showcase: null,` line, but create-frontend.mjs strips
|
|
// that entry before running this generator, so the modify silently no-op'd and the
|
|
// new context got no fence at all — dep:check stayed green with the boundary rule
|
|
// simply missing.)
|
|
type: 'modify',
|
|
path: '.dependency-cruiser.ssp.js',
|
|
pattern: /\.dependency-cruiser\.base\.js'\)\(\n {2}\{\n/,
|
|
template: ".dependency-cruiser.base.js')(\n {\n {{kebabCase name}}: [],\n",
|
|
},
|
|
{
|
|
// Lazy route — inserted right before the catch-all, which never moves.
|
|
type: 'modify',
|
|
path: 'apps/ssp/src/app/app.routes.ts',
|
|
pattern: " { path: '**', redirectTo: 'login' },",
|
|
template: ` {
|
|
path: '{{kebabCase name}}',
|
|
canActivate: [authGuard],
|
|
loadComponent: () =>
|
|
import('@{{kebabCase name}}/ui/{{kebabCase name}}.page').then(
|
|
(m) => m.{{pascalCase name}}Page,
|
|
),
|
|
},
|
|
{ path: '**', redirectTo: 'login' },`,
|
|
},
|
|
() =>
|
|
'Next: npm run dep:check && npm run lint && npm run build to verify, then build the first feature with the new-feature skill.',
|
|
],
|
|
});
|
|
}
|