feat(frontend): automatically trigger prisma generate on schema.prisma write
This commit is contained in:
@@ -4974,6 +4974,20 @@ async function toolFsWrite(principal: Principal, params: Record<string, any>) {
|
||||
const { createHash } = require("crypto");
|
||||
const bytes = Buffer.byteLength(content, "utf8");
|
||||
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({
|
||||
result: { ok: true, path, bytes, sha256 },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user