import path from "path"; export function generateMarkdownLog({ fromVersion, toVersion, deprecatedItems, autoFixes }) { const required: string[] = []; const optional: string[] = []; const fileMap: Record> = {}; let ignoredCacheMatches = 0; deprecatedItems.forEach(item => { const isOptional = item.trim().startsWith("ℹ"); if (isOptional) optional.push(item); else required.push(item); // Extract file reference const match = item.match(/→ (.*)$/); if (match) { const file = match[1].trim(); if (file.includes(".angular/cache")) { ignoredCacheMatches++; return; } const cleaned = path.normalize(file); if (!fileMap[cleaned]) fileMap[cleaned] = new Set(); fileMap[cleaned].add(item.split("→")[0].trim()); } }); const affectedFiles = Object.keys(fileMap); const autofixesList = autoFixes ?? []; return `# Migration ${fromVersion} → ${toVersion} --- ## 🚨 Required Changes (may break project if ignored) ${required.length ? required.map(r => `- ${r}`).join("\n") : "✓ None — no blockers"} --- ## ⚙️ Autofixes Applied Automatically ${autofixesList.length ? autofixesList.map(a => `- ${a}`).join("\n") : "No autofixes applied"} --- ## 🔍 Optional Improvements (not required but recommended) ${optional.length ? optional.map(o => `- ${o}`).join("\n") : "✓ No suggestions — this project is aligned with modern Angular"} --- ## 📌 Files Needing Manual Attention ${affectedFiles.length ? affectedFiles.map(f => `- ${f}`).join("\n") : "✓ None"} ${ignoredCacheMatches > 0 ? `\n> 🔹 ${ignoredCacheMatches} internal/cache files matched but were ignored intentionally — they do not require developer action.\n` : ""} --- ## 📊 Migration Summary | Category | Count | |----------|-------| | Required changes | ${required.length} | | Optional suggestions | ${optional.length} | | Autofixes applied | ${autofixesList.length} | | Files needing attention | ${affectedFiles.length} | | Cache matches ignored | ${ignoredCacheMatches} | --- 📄 Generated by **MigratorX — Quantum Migration Core** `; }