/** * Inter-CLI integration — scaffold-doc (client mode) → aggregate-component-registry. * * The client wiring contract only holds if the registry scaffold-doc emits is * exactly what the aggregator consumes: componentRegistry.generated.ts must * import './docs-Registry' (routing via the package's docs.* seam) and * moduleResources.generated.ts must register the '' namespace from the * locale JSON scaffold-doc wrote (i18n via addClientResources). */ import { describe, it, expect, beforeEach, afterEach } from 'vitest' import fs from 'node:fs' import os from 'node:os' import path from 'node:path' import { generate as scaffoldDoc } from '../generate.js' import { generate as aggregate } from '../../../../development/frontend/routes/cli/aggregate-component-registry/generate.js' import { makeClientProject, clientSpec } from './fixtures.js' let root: string let web: string beforeEach(async () => { root = fs.mkdtempSync(path.join(os.tmpdir(), 'sdoc-agg-')) web = makeClientProject(root) const res = await scaffoldDoc(clientSpec(root)) expect(res.errors).toEqual([]) }) afterEach(() => { fs.rmSync(root, { recursive: true, force: true }) }) describe('scaffold-doc → aggregate-component-registry', () => { it('the aggregator picks up the doc registry and registers the kebab i18n namespace', () => { const res = aggregate({ projectPath: web, exclude: [] }) expect(res.errors).toEqual([]) expect(res.unresolved).toEqual([]) expect(res.collisions).toEqual([]) const componentRegistry = res.files.find((f) => f.path.endsWith('componentRegistry.generated.ts')) expect(componentRegistry?.content).toContain(`import './docs-gaf-affairesRegistry';`) expect(componentRegistry?.content).toContain(`import './moduleResources.generated';`) const moduleResources = res.files.find((f) => f.path.endsWith('moduleResources.generated.ts')) expect(moduleResources?.content).toContain(`'docs-gaf-affaires':`) for (const locale of ['fr', 'en', 'de', 'it']) { expect(moduleResources?.content).toContain(`addClientResources('${locale}',`) } }) it('a scoped --modules run (ba-develop) still aggregates the doc registry', () => { const res = aggregate({ projectPath: web, modules: ['crm'], exclude: [] }) expect(res.warnings.join('\n')).toContain('docs-gaf-affairesRegistry.ts') expect(res.warnings.join('\n')).toContain('always aggregated') const componentRegistry = res.files.find((f) => f.path.endsWith('componentRegistry.generated.ts')) expect(componentRegistry?.content).toContain(`import './docs-gaf-affairesRegistry';`) }) })