From 125fe9e6e22051b923f4742ca21490b3d566597a Mon Sep 17 00:00:00 2001 From: DecDuck Date: Thu, 8 May 2025 16:17:23 +1000 Subject: [PATCH] fix: remove jank prisma script, and move to generated prisma client --- .gitignore | 5 +- Dockerfile | 2 +- build/fix-prisma.js | 55 ------------ components/Auth/Simple.vue | 2 +- components/CreateCollectionModal.vue | 2 +- components/DeleteCollectionModal.vue | 2 +- components/GameCarousel.vue | 2 +- components/NotificationItem.vue | 2 +- .../UserHeader/NotificationWidgetPanel.vue | 2 +- composables/collection.ts | 2 +- composables/news.ts | 2 +- composables/notifications.ts | 2 +- composables/user.ts | 2 +- package.json | 8 +- pages/admin/library/[id]/index.vue | 2 +- pages/admin/users/auth/index.vue | 2 +- pages/admin/users/auth/simple/index.vue | 2 +- pages/auth/signin.vue | 6 +- pages/library/game/[id]/index.vue | 2 +- pages/library/index.vue | 2 +- pages/news/index.vue | 2 +- pages/store/[id]/index.vue | 2 +- prisma/schema.prisma | 2 + server/api/v1/admin/auth/index.get.ts | 2 +- server/api/v1/auth/signin/simple.post.ts | 2 +- server/api/v1/auth/signup/simple.post.ts | 2 +- server/api/v1/client/game/versions.get.ts | 3 +- .../[gameid]/[slotindex]/index.delete.ts | 2 +- .../saves/[gameid]/[slotindex]/index.get.ts | 2 +- .../saves/[gameid]/[slotindex]/push.post.ts | 2 +- .../api/v1/client/saves/[gameid]/index.get.ts | 2 +- .../v1/client/saves/[gameid]/index.post.ts | 2 +- server/api/v1/client/saves/index.get.ts | 2 +- server/api/v1/client/saves/settings.get.ts | 2 +- server/api/v1/client/user/webtoken.post.ts | 2 +- server/api/v1/user/token/[id]/index.delete.ts | 2 +- server/api/v1/user/token/index.get.ts | 2 +- server/api/v1/user/token/index.post.ts | 2 +- server/internal/acls/index.ts | 2 +- server/internal/clients/capabilities.ts | 2 +- server/internal/clients/event-handler.ts | 2 +- server/internal/clients/handler.ts | 2 +- .../config/application-configuration.ts | 2 +- server/internal/db/database.ts | 2 +- server/internal/downloads/manifest.ts | 2 +- server/internal/library/index.ts | 2 +- server/internal/metadata/giantbomb.ts | 4 +- server/internal/metadata/igdb.ts | 4 +- server/internal/metadata/index.ts | 4 +- server/internal/metadata/manual.ts | 2 +- server/internal/metadata/pcgamingwiki.ts | 4 +- server/internal/metadata/types.d.ts | 2 +- server/internal/notifications/index.ts | 2 +- server/internal/oidc/index.ts | 2 +- server/internal/session/cache.ts | 35 ++++++++ server/internal/session/index.ts | 5 +- server/internal/utils/parseplatform.ts | 2 +- server/plugins/04.auth-init.ts | 2 +- tsconfig.json | 5 +- yarn.lock | 89 +++++++++---------- 60 files changed, 153 insertions(+), 168 deletions(-) delete mode 100644 build/fix-prisma.js create mode 100644 server/internal/session/cache.ts diff --git a/.gitignore b/.gitignore index 915b82c..705c5c9 100644 --- a/.gitignore +++ b/.gitignore @@ -30,4 +30,7 @@ logs # deploy template deploy-template/* -!deploy-template/compose.yml \ No newline at end of file +!deploy-template/compose.yml + +# generated prisma client +/prisma/client \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index affddb0..cef3e9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,6 @@ COPY --from=build-system /build/build ./startup # OpenSSL as a dependency for Drop (TODO: seperate build environment) RUN apt-get update -y && apt-get install -y openssl -RUN yarn global add prisma@6.6.0 +RUN yarn global add prisma@6.7.0 CMD ["/app/startup/launch.sh"] \ No newline at end of file diff --git a/build/fix-prisma.js b/build/fix-prisma.js deleted file mode 100644 index 0622352..0000000 --- a/build/fix-prisma.js +++ /dev/null @@ -1,55 +0,0 @@ -// thanks https://github.com/prisma/prisma/issues/26565#issuecomment-2777915354 - -import fs from "fs/promises"; -import path from "path"; -import { fileURLToPath } from "url"; - -async function replaceInFiles(dir) { - const files = await fs.readdir(dir, { withFileTypes: true }); - - for (const file of files) { - const fullPath = path.join(dir, file.name); - // Skip directories - if (!file.isDirectory()) { - if ( - file.name.endsWith(".js") || - file.name.endsWith(".ts") || - file.name.endsWith(".mjs") - ) { - let content = await fs.readFile(fullPath, "utf8"); - if (content.includes(".prisma")) { - const isWindows = content.includes("\r\n"); - const lineEnding = isWindows ? "\r\n" : "\n"; - - content = content - .split(/\r?\n/) - .map((line) => line.replace(/\.prisma/g, "_prisma")) - .join(lineEnding); - - await fs.writeFile(fullPath, content, "utf8"); - console.log(`Modified: ${fullPath}`); - } - } - } - } -} - -async function main() { - const __filename = fileURLToPath(import.meta.url); - const __dirname = path.dirname(__filename); - - const oldPath = path.join(__dirname, "../node_modules/.prisma"); - const newPath = path.join(__dirname, "../node_modules/_prisma"); - try { - await fs.rename(oldPath, newPath); - console.log("Directory renamed from .prisma to _prisma"); - // eslint-disable-next-line no-unused-vars - } catch (err) { - console.log("Directory .prisma does not exist or has already been renamed"); - } - - await replaceInFiles(path.join(__dirname, "../node_modules/@prisma/client")); - console.log("Done! --- prisma!!!, replaced .prisma with _prisma"); -} - -main().catch((err) => console.error(err)); diff --git a/components/Auth/Simple.vue b/components/Auth/Simple.vue index c248f2f..a38fe8d 100644 --- a/components/Auth/Simple.vue +++ b/components/Auth/Simple.vue @@ -82,7 +82,7 @@ diff --git a/composables/collection.ts b/composables/collection.ts index 120b0c2..64b5ad2 100644 --- a/composables/collection.ts +++ b/composables/collection.ts @@ -1,4 +1,4 @@ -import type { Collection, CollectionEntry, Game } from "@prisma/client"; +import type { Collection, CollectionEntry, Game } from "~/prisma/client"; import type { SerializeObject } from "nitropack"; type FullCollection = Collection & { diff --git a/composables/news.ts b/composables/news.ts index bd277a7..cec5e4a 100644 --- a/composables/news.ts +++ b/composables/news.ts @@ -1,4 +1,4 @@ -import type { Article } from "@prisma/client"; +import type { Article } from "~/prisma/client"; import type { SerializeObject } from "nitropack"; export const useNews = () => diff --git a/composables/notifications.ts b/composables/notifications.ts index 304a7cd..44d2832 100644 --- a/composables/notifications.ts +++ b/composables/notifications.ts @@ -1,4 +1,4 @@ -import type { Notification } from "@prisma/client"; +import type { Notification } from "~/prisma/client"; const ws = new WebSocketHandler("/api/v1/notifications/ws"); diff --git a/composables/user.ts b/composables/user.ts index b2a2719..ae604da 100644 --- a/composables/user.ts +++ b/composables/user.ts @@ -1,4 +1,4 @@ -import type { User } from "@prisma/client"; +import type { User } from "~/prisma/client"; // undefined = haven't check // null = check, no user diff --git a/package.json b/package.json index ea7fe5b..41d0592 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dev": "nuxt dev", "generate": "nuxt generate", "preview": "nuxt preview", - "postinstall": "prisma generate && nuxt prepare && node build/fix-prisma.js", + "postinstall": "prisma generate && nuxt prepare", "typecheck": "nuxt typecheck", "lint": "yarn lint:eslint && yarn lint:prettier", "lint:eslint": "eslint .", @@ -21,7 +21,7 @@ "@heroicons/vue": "^2.1.5", "@nuxt/fonts": "^0.11.0", "@nuxt/image": "^1.10.0", - "@prisma/client": "^6.6.0", + "@prisma/client": "^6.7.0", "@tailwindcss/vite": "^4.0.6", "argon2": "^0.41.1", "arktype": "^2.1.10", @@ -35,7 +35,7 @@ "micromark": "^4.0.1", "nuxt": "^3.16.2", "nuxt-security": "2.2.0", - "prisma": "^6.6.0", + "prisma": "^6.7.0", "sharp": "^0.33.5", "stream-mime-type": "^2.0.0", "turndown": "^7.2.0", @@ -75,4 +75,4 @@ "prisma": { "schema": "./prisma" } -} \ No newline at end of file +} diff --git a/pages/admin/library/[id]/index.vue b/pages/admin/library/[id]/index.vue index 104c679..e00c9ac 100644 --- a/pages/admin/library/[id]/index.vue +++ b/pages/admin/library/[id]/index.vue @@ -519,7 +519,7 @@