16 lines
1.2 KiB
JavaScript
16 lines
1.2 KiB
JavaScript
// One-time fixture authoring helper; normal example builds read the checked-in fixtures.
|
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
const document = await readFile(new URL('../../docs/org-chart/data-contract.md', import.meta.url), 'utf8');
|
|
const snippets = [...document.matchAll(/```json\r?\n([\s\S]*?)\r?\n```/g)].map(match => JSON.parse(match[1]));
|
|
const initial = snippets.find(value => Array.isArray(value.organizations));
|
|
if (!initial) throw new Error('No documented fictitious dataset');
|
|
initial.schemaVersion = '0.1-draft';
|
|
initial.presentation.description = '가상 데이터 · 원본 집계와 업무상 총원은 구분됩니다.';
|
|
const changed = structuredClone(initial);
|
|
changed.metadata.dataVersion = 'mock-2';
|
|
changed.organizations[1].name = '가상 전략기획팀';
|
|
changed.employees.find(person => person.id === 'emp-c').organizationId = 'team-b';
|
|
changed.employees.push({ id: 'emp-e', organizationId: 'team-b', affiliationId: 'aff-a', name: '가상직원 마', position: '책임', jobTitle: null, profileImage: null, workStatus: 'active' });
|
|
for (const [file, value] of [['data-v1.json', initial], ['data-v2.json', changed]])
|
|
await writeFile(new URL(file, import.meta.url), JSON.stringify(value, null, 2) + '\n');
|