import { readFile, writeFile } from "fs/promises"; import { integrationDefs } from "../packages/definitions/src/integration"; const FILE = "docs/README.md"; const MAX_COLUMNS_PER_ROW = 7; async function updateIntegrationList() { // Read current README content const content = await readFile(FILE, "utf8"); // Define markers const startMarker = ""; const endMarker = ""; // Find the section to replace const startIndex = content.indexOf(startMarker); const endIndex = content.indexOf(endMarker); if (startIndex === -1 || endIndex === -1) { throw new Error("Could not find markers in README.md"); } // Generate the new integration list const integrations = Object.values(integrationDefs) .filter((def) => def.name !== "Mock") .sort((a, b) => a.name.localeCompare(b.name)); const tableRows: string[] = []; let currentRow: string[] = []; integrations.forEach((integration) => { currentRow.push(` ${integration.name}

${integration.name.replaceAll(" ", "
")}

`); if (currentRow.length === MAX_COLUMNS_PER_ROW) { tableRows.push(`${currentRow.join("\n")}`); currentRow = []; } }); // Add remaining items if any if (currentRow.length > 0) { tableRows.push(`${currentRow.join("\n")}`); } // Create the new content const newSection = `${startMarker}
${tableRows.join("\n")}
${endMarker}`; // Replace the old section with the new one const newContent = content.slice(0, startIndex) + newSection + content.slice(endIndex + endMarker.length); // Write the updated content back to the file await writeFile(FILE, newContent, "utf8"); } updateIntegrationList().catch(console.error);