import { readFile, writeFile } from "fs/promises";
import {
getIntegrationDocumentationUrl,
integrationDefs,
integrationKinds,
} 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 = integrationKinds
.filter((kind) => kind !== "mock")
.map((kind) => ({
...integrationDefs[kind],
documentationUrl: getIntegrationDocumentationUrl(kind),
}))
.toSorted((a, b) => a.name.localeCompare(b.name));
const tableRows: string[] = [];
let currentRow: string[] = [];
integrations.forEach((integration) => {
const cellBody = `
${integration.name.replaceAll(" ", "
")}