- gen-seed.mts: deterministischer Generator aus catalog.ts (Single Source); emittiert BEIDE Artefakte: generated.json (Klammer-Notation, Display) + backend.json (frozen ef/cchm/ch, für Pam EF-Migrationen). Kein magisches Artefakt mehr. - package.json: npm run gen:catalog (npx tsx gen-seed.mts) - catalog-drift.test.ts: Drift-Guard — liest generated.json von Disk via import.meta.url + readFileSync, vergleicht mit live CATALOG; Fail-Meldung zeigt 'npm run gen:catalog'. 5 Test-Files, 93 Tests grün. - colorVarietySeed.backend.json: 66 Zeilen frozen symbols (ef/cchm/ch), kein sofortiger Backend-Eingriff (AR-5 Guardrail; Pam konsumiert bei nächster Reseed-Migration). - README.md: Katalog-Generator-Doku (wann laufen, was erzeugt wird). Gate: build ✓ eslint ✓ vitest 93/93 ✓
25 lines
1010 B
TypeScript
25 lines
1010 B
TypeScript
/**
|
|
* AR-5 Drift-Guard: colorVarietySeed.generated.json muss mit dem Live-Output
|
|
* aus catalog.ts übereinstimmen.
|
|
*
|
|
* Schlägt dieser Test fehl, wurde catalog.ts verändert ohne danach
|
|
* `npm run gen:catalog` auszuführen. Fix: `npm run gen:catalog` laufen lassen
|
|
* und die geänderten JSON-Dateien committen.
|
|
*/
|
|
import { readFileSync } from 'fs'
|
|
import { fileURLToPath } from 'url'
|
|
import { dirname, join } from 'path'
|
|
import { describe, it, expect } from 'vitest'
|
|
import { CATALOG } from '../catalog'
|
|
|
|
const __dir = dirname(fileURLToPath(import.meta.url))
|
|
|
|
describe('AR-5 Catalog drift-guard', () => {
|
|
it('colorVarietySeed.generated.json stimmt mit catalog.ts überein (sonst: npm run gen:catalog)', () => {
|
|
const jsonPath = join(__dir, '..', 'colorVarietySeed.generated.json')
|
|
const committed = JSON.parse(readFileSync(jsonPath, 'utf-8'))
|
|
// CATALOG is readonly — deep equality against the plain parsed array is sufficient.
|
|
expect(committed).toEqual(Array.from(CATALOG))
|
|
})
|
|
})
|