feat(frontend): automatically trigger prisma generate on schema.prisma write

This commit is contained in:
2026-06-03 15:48:25 -07:00
parent 59e5b4d4a9
commit 6f16401849

View File

@@ -4974,6 +4974,20 @@ async function toolFsWrite(principal: Principal, params: Record<string, any>) {
const { createHash } = require("crypto"); const { createHash } = require("crypto");
const bytes = Buffer.byteLength(content, "utf8"); const bytes = Buffer.byteLength(content, "utf8");
const sha256 = createHash("sha256").update(content, "utf8").digest("hex"); const sha256 = createHash("sha256").update(content, "utf8").digest("hex");
// If we are writing to schema.prisma, automatically generate Prisma Client
if (path.endsWith("schema.prisma")) {
const prismaDir = path.replace(/\/prisma\/schema\.prisma$/, "");
console.log(
`[Prisma Hook] Automatically generating prisma client in ${prismaDir}...`,
);
runFsCmd(
principal,
project,
`cd ${shq(prismaDir)} && npx prisma generate`,
).catch(() => {});
}
return NextResponse.json({ return NextResponse.json({
result: { ok: true, path, bytes, sha256 }, result: { ok: true, path, bytes, sha256 },
}); });