feat: use db for rag

This commit is contained in:
2025-08-07 14:14:46 -07:00
parent 4971695d2a
commit 24d37dcd16
11 changed files with 145 additions and 50 deletions
+13 -12
View File
@@ -15,6 +15,7 @@ import path from "node:path";
import matter from "gray-matter";
import { promisify } from "node:util";
import { exec } from "node:child_process";
import { PrismaClient } from "@prisma/client";
const execAsync = promisify(exec);
@@ -68,18 +69,18 @@ const results = await Promise.all(
const flat = results.flat();
const string = `/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
const db = new PrismaClient();
export const documentationData = ${JSON.stringify({ documents: flat }, null, 2)};
`;
await fs.writeFile(
path.resolve(process.cwd(), "src", "data", "docs.ts"),
string
);
await db.documentation.deleteMany({});
await db.documentation.createMany({
data: flat.map((doc) => ({
pageId: doc.id,
title: doc.title,
content: doc.content,
file: doc.file,
pageTitle: doc.metadata.title ?? doc.title,
url: doc.url,
})),
});
await fs.rm(docsDirectory, { recursive: true, force: true });