fix(sync): normalize section separators in regenerate()
CI — Test & Build / 🧪 Run Tests & Generate Reports (push) Waiting to run
CI — Test & Build / 🏗️ Build Docker Image (push) Blocked by required conditions

A previous run could merge the '---' separator with the next section
header (---##  Befejezett), breaking section detection. Prefix/suffix
are now trimmed and rejoined with fixed separators. Regression test
added; also create Plane issues for local-only completed work
(MITHOME-28 Custom CMS, MITHOME-29 Webmail) to avoid ID collisions.
This commit is contained in:
Do Siki
2026-08-17 13:29:25 +02:00
parent 35bf43798d
commit 52f4f524c5
3 changed files with 35 additions and 9 deletions
+6 -3
View File
@@ -8,12 +8,13 @@ Next.js 15 alapú weboldal a mozdIT Bt. számára, Docker Compose-szal deployolv
**Lokális másolat**: Ez a fájl csak referencia, a Plane az authoritative source **Lokális másolat**: Ez a fájl csak referencia, a Plane az authoritative source
--- ---
## ✅ Befejezett ## ✅ Befejezett
| Plane | Feladat | Státusz | | Plane | Feladat | Státusz |
|-------|---------|---------| |-------|---------|---------|
| MITHOME-1 | Repo & Next.js bootstrap — dev szerver | ✅ | | MITHOME-1 | Repo & Next.js bootstrap — dev szerver | ✅ |
| MITHOME-2 | Kezdőlap (Hero + USP + Webmail CTA) | ✅ | | MITHOME-2 | Kezdlap (Hero + USP + Webmail CTA) | ✅ |
| MITHOME-3 | Rólunk oldal | ✅ | | MITHOME-3 | Rólunk oldal | ✅ |
| MITHOME-4 | Szolgáltatások oldal | ✅ | | MITHOME-4 | Szolgáltatások oldal | ✅ |
| MITHOME-5 | Kapcsolat űrlap + API route | ✅ | | MITHOME-5 | Kapcsolat űrlap + API route | ✅ |
@@ -24,8 +25,8 @@ Next.js 15 alapú weboldal a mozdIT Bt. számára, Docker Compose-szal deployolv
| MITHOME-10 | Unit teszt infrastruktúra (Jest + React Testing Library) | ✅ | | MITHOME-10 | Unit teszt infrastruktúra (Jest + React Testing Library) | ✅ |
| MITHOME-11 | Contact API — rate limiting, spam detection, validáció | ✅ | | MITHOME-11 | Contact API — rate limiting, spam detection, validáció | ✅ |
| MITHOME-12 | Docker stack — Next.js + MongoDB + Loki + Grafana | ✅ | | MITHOME-12 | Docker stack — Next.js + MongoDB + Loki + Grafana | ✅ |
| MITHOME-27 | Custom CMS (content-editor.js) UI fejlesztés, Basic Auth & Publikálás gomb | ✅ | | MITHOME-28 | Custom CMS (content-editor.js) UI fejlesztés, Basic Auth & Publikálás gomb | ✅ |
| MITHOME-28 | Webmail link (mail.mozdit.hu) és Logo finomhangolás | ✅ | | MITHOME-29 | Webmail link (mail.mozdit.hu) és Logo finomhangolás | ✅ |
--- ---
@@ -61,6 +62,7 @@ Next.js 15 alapú weboldal a mozdIT Bt. számára, Docker Compose-szal deployolv
| MITHOME-24 | Performance optimalizálás | 📋 | | MITHOME-24 | Performance optimalizálás | 📋 |
| MITHOME-25 | Reszponzív design finomítása | 📋 | | MITHOME-25 | Reszponzív design finomítása | 📋 |
| MITHOME-26 | Analytics integráció (Plausible / GA4) | 📋 | | MITHOME-26 | Analytics integráció (Plausible / GA4) | 📋 |
| MITHOME-27 | Production környezet beállítása (mozdit.hu — Iron szerver) | 📋 |
--- ---
@@ -103,6 +105,7 @@ docker-compose -f docker-compose.dev.yml down
--- ---
## Frissítési Napló ## Frissítési Napló
- **2026-08-17**: Plane sync (`plane-sync.js`). Új MITHOME-27 (Production környezet) Backlog-ba; Custom CMS és Webmail bevéve a Plane-be (28/29, Done). `regenerate()` hiba javítva (szekció-elválasztó).
- **2026-08-17**: Plane sync futtatása (`plane-sync.js`). MITHOME-15, MITHOME-18 visszaminősítve Backlog-ba (Plane szerint), MITHOME-27/28 megtartva. - **2026-08-17**: Plane sync futtatása (`plane-sync.js`). MITHOME-15, MITHOME-18 visszaminősítve Backlog-ba (Plane szerint), MITHOME-27/28 megtartva.
- **2026-04-26**: Átállás Linear → Plane (MITHOME projekt). TODO.md teljes újraírva, 26 issue szinkronizálva. - **2026-04-26**: Átállás Linear → Plane (MITHOME projekt). TODO.md teljes újraírva, 26 issue szinkronizálva.
- **2025-01-23**: ZEE-29 (Tailwind + layout) és JSON content management befejezése (Linear) - **2025-01-23**: ZEE-29 (Tailwind + layout) és JSON content management befejezése (Linear)
+22
View File
@@ -162,3 +162,25 @@ test('buildTable sorts rows by sequence number', () => {
assert.equal(lines[2], '| MITHOME-1 | A | ✅ |'); assert.equal(lines[2], '| MITHOME-1 | A | ✅ |');
assert.equal(lines[3], '| MITHOME-15 | B | ✅ |'); assert.equal(lines[3], '| MITHOME-15 | B | ✅ |');
}); });
// Regression: a previous run dropping the blank line after `---` must not merge
// the separator with the section header (`---## ✅ Befejezett`).
test('regenerate always separates `---` from section headers', () => {
const planeIssues = [
{ sequence_id: 1, name: 'Kezdőlap', state: { group: 'completed' } },
{ sequence_id: 13, name: 'CI pipeline', state: { group: 'unstarted' } },
{ sequence_id: 17, name: 'Winston logger + Loki integráció', state: { group: 'started' } },
{ sequence_id: 19, name: 'Accessibility', state: { group: 'backlog' } }
];
const { rows } = parseTodoFile(SAMPLE_TODO);
const buildData = buildDiscrepancies(planeIssues, rows, 'MITHOME');
const decisions = { moveToPlane: new Set(), keepOrphan: new Set(), addNew: new Set() };
const final = buildFinalSections(buildData, decisions);
const corrupted = SAMPLE_TODO.replace('---\n\n## ✅ Befejezett', '---## ✅ Befejezett');
const output = regenerate(corrupted, final);
assert.ok(output.includes('---\n\n## ✅ Befejezett'), 'header must be separated from ---');
assert.ok(!output.includes('---##'), 'no merged separator+header');
assert.ok(output.includes('## ✅ Befejezett'));
});
+7 -6
View File
@@ -64,7 +64,9 @@ function buildTable(sec, rows) {
return [header, separator, ...body].join('\n'); return [header, separator, ...body].join('\n');
} }
// WHY: only the section region is regenerated, prefix/suffix (overview, commands) are preserved // WHY: only the section region is regenerated, prefix/suffix (overview, commands) are preserved.
// Prefix/suffix are trimmed and rejoined with normalized separators so that a previous run
// that dropped the blank line after `---` cannot corrupt the section headers (`---## ✅`).
function regenerate(content, finalSections) { function regenerate(content, finalSections) {
const lines = content.split('\n'); const lines = content.split('\n');
const firstIdx = lines.findIndex(l => SECTIONS[0].header.test(l)); const firstIdx = lines.findIndex(l => SECTIONS[0].header.test(l));
@@ -79,8 +81,8 @@ function regenerate(content, finalSections) {
} }
} }
const prefix = lines.slice(0, firstIdx).join('\n'); const prefix = lines.slice(0, firstIdx).join('\n').trimEnd();
const suffix = lines.slice(endIdx + 1).join('\n'); const suffix = lines.slice(endIdx + 1).join('\n').trimStart();
const headerOf = key => { const headerOf = key => {
const sec = SECTIONS.find(s => s.key === key); const sec = SECTIONS.find(s => s.key === key);
@@ -92,9 +94,8 @@ function regenerate(content, finalSections) {
const rows = finalSections[sec.key] || []; const rows = finalSections[sec.key] || [];
return `## ${headerOf(sec.key)}\n\n${buildTable(sec, rows)}`; return `## ${headerOf(sec.key)}\n\n${buildTable(sec, rows)}`;
}); });
const middle = blocks.join('\n\n---\n\n') + '\n\n---\n'; const middle = blocks.join('\n\n---\n\n');
const result = `${prefix}\n\n${middle}\n\n---\n\n${suffix}`;
const result = `${prefix}${middle}${suffix}`;
return result.endsWith('\n') ? result : `${result}\n`; return result.endsWith('\n') ? result : `${result}\n`;
} }