From 0232fe36f45fbfac84c6e88f324849b9a2c1e24f Mon Sep 17 00:00:00 2001 From: istarkov Date: Sun, 5 May 2024 19:56:50 +0300 Subject: [PATCH 1/2] Fix image error --- apps/builder/app/routes/cgi.image.$name.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/builder/app/routes/cgi.image.$name.ts b/apps/builder/app/routes/cgi.image.$name.ts index 1347a6e189cd..d1b48079c0f4 100644 --- a/apps/builder/app/routes/cgi.image.$name.ts +++ b/apps/builder/app/routes/cgi.image.$name.ts @@ -1,4 +1,4 @@ -import { createReadStream } from "node:fs"; +import { createReadStream, existsSync } from "node:fs"; import { join } from "node:path"; import { createReadableStreamFromReadable } from "@remix-run/node"; import type { LoaderFunctionArgs } from "@remix-run/server-runtime"; @@ -52,6 +52,13 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => { } const fileUploadPath = env.FILE_UPLOAD_PATH; const filePath = join(process.cwd(), fileUploadPath, name); + + if (existsSync(filePath) === false) { + throw new Response("Not found", { + status: 404, + }); + } + return new Response( createReadableStreamFromReadable(createReadStream(filePath)) ); From 30b3f9e817611b1cf01dc017bbaa29140d26556a Mon Sep 17 00:00:00 2001 From: istarkov Date: Sun, 5 May 2024 19:57:02 +0300 Subject: [PATCH 2/2] Fix migrations --- .../migrations-cli/prisma-migrations.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/prisma-client/migrations-cli/prisma-migrations.ts b/packages/prisma-client/migrations-cli/prisma-migrations.ts index 6283cecbd84c..763284907ba9 100644 --- a/packages/prisma-client/migrations-cli/prisma-migrations.ts +++ b/packages/prisma-client/migrations-cli/prisma-migrations.ts @@ -250,11 +250,13 @@ export const generateMigrationName = (baseName: string) => { }; export const resetDatabase = async () => { - const { stdout: sqlToDeleteEverything } = - await $`"prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-empty --script`; + const { stdout: sqlToDeleteEverything } = await $({ + cwd: prismaDir, + })`"prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-empty --script`; await $({ input: sqlToDeleteEverything, + cwd: prismaDir, })`prisma db execute --stdin --schema ${schemaFilePath}`; await context.prisma.$executeRaw`DROP TABLE IF EXISTS _prisma_migrations`; @@ -262,14 +264,17 @@ export const resetDatabase = async () => { // https://www.prisma.io/docs/reference/api-reference/command-reference#migrate-diff export const cliDiff = async () => { - const { stdout } = - await $`prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-schema-datamodel ${schemaFilePath} --script`; + const { stdout } = await $({ + cwd: prismaDir, + })`prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-schema-datamodel ${schemaFilePath} --script`; return stdout; }; // https://www.prisma.io/docs/reference/api-reference/command-reference#db-execute export const cliExecute = async (filePath: string) => { - await $`prisma db execute --file ${filePath} --schema ${schemaFilePath}`; + await $({ + cwd: prismaDir, + })`prisma db execute --file ${filePath} --schema ${schemaFilePath}`; }; export const generateMigrationClient = async (migrationName: string) => { @@ -293,5 +298,7 @@ export const generateMigrationClient = async (migrationName: string) => { } // https://www.prisma.io/docs/reference/api-reference/command-reference#generate - await $`prisma generate --schema ${schemaPath}`; + await $({ + cwd: prismaDir, + })`prisma generate --schema ${schemaPath}`; };