From 28f18fdd512a8bb6c4ee3251665e1c529d3a74ae Mon Sep 17 00:00:00 2001 From: Connor van Spronssen Date: Wed, 3 Jul 2024 20:23:17 +0200 Subject: [PATCH 1/4] fix: Resolve an issue where Prisma generation would fail on alternative package managers #15 --- src/package-utils/setup-helpers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/package-utils/setup-helpers.ts b/src/package-utils/setup-helpers.ts index a6fad30..ac07285 100644 --- a/src/package-utils/setup-helpers.ts +++ b/src/package-utils/setup-helpers.ts @@ -1,4 +1,5 @@ import { execa } from "execa"; +import { installingPrismaCLIWithPM } from "./detect-pm"; import { log, logError, @@ -175,7 +176,9 @@ export async function generateClient( if (installPrismaClient) { try { - await execa("npm", ["install", "@prisma/client", "--save-dev"], { + const installCmd = installingPrismaCLIWithPM(); + + await execa(installCmd.pm, installCmd.command, { cwd: directory, }); } catch (error) { From 5a43583a9a5bf680c5f5c6026151626e000b94c0 Mon Sep 17 00:00:00 2001 From: Connor van Spronssen Date: Sat, 6 Jul 2024 14:34:00 +0200 Subject: [PATCH 2/4] fix: Make sure to actually install the Prisma client and not the Prisma CLI #17 --- src/package-utils/setup-helpers.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/package-utils/setup-helpers.ts b/src/package-utils/setup-helpers.ts index ac07285..e92efa8 100644 --- a/src/package-utils/setup-helpers.ts +++ b/src/package-utils/setup-helpers.ts @@ -1,5 +1,8 @@ import { execa } from "execa"; -import { installingPrismaCLIWithPM } from "./detect-pm"; +import { + installingPrismaClientWithPM, + installingPrismaCLIWithPM, +} from "./detect-pm"; import { log, logError, @@ -37,9 +40,10 @@ export async function isPrismaCLIInstalled( } export async function installPrismaCLI(directory: string) { - try { - await execa("npm", ["install", "prisma", "--save-dev"], { + const installCmd = installingPrismaCLIWithPM(); + + await execa(installCmd.pm, installCmd.command, { cwd: directory, }); logSuccess(PREDEFINED_LOG_MESSAGES.installPrismaCLI.yes); @@ -173,10 +177,9 @@ export async function generateClient( ) { log(PREDEFINED_LOG_MESSAGES.generatePrismaClient.action); - if (installPrismaClient) { try { - const installCmd = installingPrismaCLIWithPM(); + const installCmd = installingPrismaClientWithPM(); await execa(installCmd.pm, installCmd.command, { cwd: directory, From 47eb61d9a2c8a786b7ca03b50c7ffadd8b3f79b5 Mon Sep 17 00:00:00 2001 From: Connor van Spronssen Date: Fri, 26 Jul 2024 19:15:01 +0200 Subject: [PATCH 3/4] fix: Hoist Prisma dependencies in the playground #15 --- playground/.npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 playground/.npmrc diff --git a/playground/.npmrc b/playground/.npmrc new file mode 100644 index 0000000..124a673 --- /dev/null +++ b/playground/.npmrc @@ -0,0 +1 @@ +hoist-pattern[]=*prisma* From 03d319ca5b815b0db641df4b8c1cb0d67db27a3a Mon Sep 17 00:00:00 2001 From: Connor van Spronssen Date: Sat, 27 Jul 2024 15:20:45 +0200 Subject: [PATCH 4/4] fix: Resolve an issue where a hydation error would occur #15 --- playground/.npmrc | 1 - playground/components/PostList.server.vue | 6 ++++-- src/package-utils/setup-helpers.ts | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 playground/.npmrc diff --git a/playground/.npmrc b/playground/.npmrc deleted file mode 100644 index 124a673..0000000 --- a/playground/.npmrc +++ /dev/null @@ -1 +0,0 @@ -hoist-pattern[]=*prisma* diff --git a/playground/components/PostList.server.vue b/playground/components/PostList.server.vue index f019b0b..c638fcc 100644 --- a/playground/components/PostList.server.vue +++ b/playground/components/PostList.server.vue @@ -4,6 +4,8 @@ const post = await prisma.post.findFirst(); diff --git a/src/package-utils/setup-helpers.ts b/src/package-utils/setup-helpers.ts index e92efa8..e11f293 100644 --- a/src/package-utils/setup-helpers.ts +++ b/src/package-utils/setup-helpers.ts @@ -29,7 +29,7 @@ export async function isPrismaCLIInstalled( directory: string, ): Promise { try { - await execa("prisma", ["version"], { cwd: directory }); + await execa("npx", ["prisma", "version"], { cwd: directory }); logSuccess(PREDEFINED_LOG_MESSAGES.isPrismaCLIinstalled.yes); return true; } catch (error) { @@ -72,7 +72,7 @@ export async function initPrisma({ provider = "sqlite", datasourceUrl, }: PrismaInitOptions) { - const command = ["prisma", "init", "--datasource-provider"]; + const command = ["npx", "prisma", "init", "--datasource-provider"]; command.push(provider);