diff --git a/package-lock.json b/package-lock.json index fbea386..8a91f98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,10 +11,11 @@ "dependencies": { "@nuxt/devtools-kit": "^1.3.3", "@nuxt/kit": "^3.11.2", - "@prisma/client": "^5.22.0", + "@prisma/client": "^6.1.0", "chalk": "^5.3.0", "defu": "^6.1.4", "execa": "^8.0.1", + "nypm": "^0.4.1", "pathe": "^1.1.2", "prompts": "^2.4.2" }, @@ -37,7 +38,7 @@ "inquirer": "^9.3.7", "nuxt": "^3.11.2", "prettier": "3.2.5", - "prisma": "^5.22.0", + "prisma": "^6.1.0", "semantic-release": "^24.2.0", "vitest": "^1.2.2" } @@ -2447,6 +2448,77 @@ "node": ">=14.18.0" } }, + "node_modules/@nuxt/devtools/node_modules/nypm": { + "version": "0.3.12", + "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.3.12.tgz", + "integrity": "sha512-D3pzNDWIvgA+7IORhD/IuWzEk4uXv6GsgOxiid4UU3h9oq5IqV1KtPDi63n4sZJ/xcWlr88c0QM2RgN5VbOhFA==", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.2.3", + "execa": "^8.0.1", + "pathe": "^1.1.2", + "pkg-types": "^1.2.0", + "ufo": "^1.5.4" + }, + "bin": { + "nypm": "dist/cli.mjs" + }, + "engines": { + "node": "^14.16.0 || >=16.10.0" + } + }, + "node_modules/@nuxt/devtools/node_modules/nypm/node_modules/execa": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/@nuxt/devtools/node_modules/nypm/node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@nuxt/devtools/node_modules/nypm/node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/@nuxt/devtools/node_modules/nypm/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@nuxt/devtools/node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -3489,12 +3561,12 @@ "integrity": "sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==" }, "node_modules/@prisma/client": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.22.0.tgz", - "integrity": "sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.1.0.tgz", + "integrity": "sha512-AbQYc5+EJKm1Ydfq3KxwcGiy7wIbm4/QbjCKWWoNROtvy7d6a3gmAGkKjK0iUCzh+rHV8xDhD5Cge8ke/kiy5Q==", "hasInstallScript": true, "engines": { - "node": ">=16.13" + "node": ">=18.18" }, "peerDependencies": { "prisma": "*" @@ -3506,48 +3578,48 @@ } }, "node_modules/@prisma/debug": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.22.0.tgz", - "integrity": "sha512-AUt44v3YJeggO2ZU5BkXI7M4hu9BF2zzH2iF2V5pyXT/lRTyWiElZ7It+bRH1EshoMRxHgpYg4VB6rCM+mG5jQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.1.0.tgz", + "integrity": "sha512-0himsvcM4DGBTtvXkd2Tggv6sl2JyUYLzEGXXleFY+7Kp6rZeSS3hiTW9mwtUlXrwYbJP6pwlVNB7jYElrjWUg==", "devOptional": true }, "node_modules/@prisma/engines": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.22.0.tgz", - "integrity": "sha512-UNjfslWhAt06kVL3CjkuYpHAWSO6L4kDCVPegV6itt7nD1kSJavd3vhgAEhjglLJJKEdJ7oIqDJ+yHk6qO8gPA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.1.0.tgz", + "integrity": "sha512-GnYJbCiep3Vyr1P/415ReYrgJUjP79fBNc1wCo7NP6Eia0CzL2Ot9vK7Infczv3oK7JLrCcawOSAxFxNFsAERQ==", "devOptional": true, "hasInstallScript": true, "dependencies": { - "@prisma/debug": "5.22.0", - "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", - "@prisma/fetch-engine": "5.22.0", - "@prisma/get-platform": "5.22.0" + "@prisma/debug": "6.1.0", + "@prisma/engines-version": "6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959", + "@prisma/fetch-engine": "6.1.0", + "@prisma/get-platform": "6.1.0" } }, "node_modules/@prisma/engines-version": { - "version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2.tgz", - "integrity": "sha512-2PTmxFR2yHW/eB3uqWtcgRcgAbG1rwG9ZriSvQw+nnb7c4uCr3RAcGMb6/zfE88SKlC1Nj2ziUvc96Z379mHgQ==", + "version": "6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959.tgz", + "integrity": "sha512-PdJqmYM2Fd8K0weOOtQThWylwjsDlTig+8Pcg47/jszMuLL9iLIaygC3cjWJLda69siRW4STlCTMSgOjZzvKPQ==", "devOptional": true }, "node_modules/@prisma/fetch-engine": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.22.0.tgz", - "integrity": "sha512-bkrD/Mc2fSvkQBV5EpoFcZ87AvOgDxbG99488a5cexp5Ccny+UM6MAe/UFkUC0wLYD9+9befNOqGiIJhhq+HbA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.1.0.tgz", + "integrity": "sha512-asdFi7TvPlEZ8CzSZ/+Du5wZ27q6OJbRSXh+S8ISZguu+S9KtS/gP7NeXceZyb1Jv1SM1S5YfiCv+STDsG6rrg==", "devOptional": true, "dependencies": { - "@prisma/debug": "5.22.0", - "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", - "@prisma/get-platform": "5.22.0" + "@prisma/debug": "6.1.0", + "@prisma/engines-version": "6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959", + "@prisma/get-platform": "6.1.0" } }, "node_modules/@prisma/get-platform": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.22.0.tgz", - "integrity": "sha512-pHhpQdr1UPFpt+zFfnPazhulaZYCUqeIcPpJViYoq9R+D/yw4fjE+CtnsnKzPYm0ddUbeXUzjGVGIRVgPDCk4Q==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.1.0.tgz", + "integrity": "sha512-ia8bNjboBoHkmKGGaWtqtlgQOhCi7+f85aOkPJKgNwWvYrT6l78KgojLekE8zMhVk0R9lWcifV0Pf8l3/15V0Q==", "devOptional": true, "dependencies": { - "@prisma/debug": "5.22.0" + "@prisma/debug": "6.1.0" } }, "node_modules/@rollup/plugin-alias": { @@ -7661,9 +7733,9 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, "node_modules/confbox": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.7.tgz", - "integrity": "sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", + "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==" }, "node_modules/config-chain": { "version": "1.1.13", @@ -10022,6 +10094,25 @@ "giget": "dist/cli.mjs" } }, + "node_modules/giget/node_modules/nypm": { + "version": "0.3.12", + "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.3.12.tgz", + "integrity": "sha512-D3pzNDWIvgA+7IORhD/IuWzEk4uXv6GsgOxiid4UU3h9oq5IqV1KtPDi63n4sZJ/xcWlr88c0QM2RgN5VbOhFA==", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.2.3", + "execa": "^8.0.1", + "pathe": "^1.1.2", + "pkg-types": "^1.2.0", + "ufo": "^1.5.4" + }, + "bin": { + "nypm": "dist/cli.mjs" + }, + "engines": { + "node": "^14.16.0 || >=16.10.0" + } + }, "node_modules/git-config-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/git-config-path/-/git-config-path-2.0.0.tgz", @@ -12774,14 +12865,25 @@ } }, "node_modules/mlly": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.0.tgz", - "integrity": "sha512-U9SDaXGEREBYQgfejV97coK0UL1r+qnF2SyO9A3qcI8MzKnsIFKHNVEkrDyNncQTKQQumsasmeq84eNMdBfsNQ==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.3.tgz", + "integrity": "sha512-xUsx5n/mN0uQf4V548PKQ+YShA4/IW0KI1dZhrNrPCLG+xizETbHTkOa1f8/xut9JRPp8kQuMnz0oqwkTiLo/A==", "dependencies": { - "acorn": "^8.11.3", + "acorn": "^8.14.0", "pathe": "^1.1.2", - "pkg-types": "^1.1.0", - "ufo": "^1.5.3" + "pkg-types": "^1.2.1", + "ufo": "^1.5.4" + } + }, + "node_modules/mlly/node_modules/acorn": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" } }, "node_modules/mri": { @@ -16589,16 +16691,36 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/nypm": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.3.8.tgz", - "integrity": "sha512-IGWlC6So2xv6V4cIDmoV0SwwWx7zLG086gyqkyumteH2fIgCAM4nDVFB2iDRszDvmdSVW9xb1N+2KjQ6C7d4og==", + "node_modules/nuxt/node_modules/nypm": { + "version": "0.3.12", + "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.3.12.tgz", + "integrity": "sha512-D3pzNDWIvgA+7IORhD/IuWzEk4uXv6GsgOxiid4UU3h9oq5IqV1KtPDi63n4sZJ/xcWlr88c0QM2RgN5VbOhFA==", "dependencies": { "citty": "^0.1.6", "consola": "^3.2.3", "execa": "^8.0.1", "pathe": "^1.1.2", - "ufo": "^1.4.0" + "pkg-types": "^1.2.0", + "ufo": "^1.5.4" + }, + "bin": { + "nypm": "dist/cli.mjs" + }, + "engines": { + "node": "^14.16.0 || >=16.10.0" + } + }, + "node_modules/nypm": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.4.1.tgz", + "integrity": "sha512-1b9mihliBh8UCcKtcGRu//G50iHpjxIQVUqkdhPT/SDVE7KdJKoHXLS0heuYTQCx95dFqiyUbXZB9r8ikn+93g==", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.2.3", + "pathe": "^1.1.2", + "pkg-types": "^1.2.1", + "tinyexec": "^0.3.1", + "ufo": "^1.5.4" }, "bin": { "nypm": "dist/cli.mjs" @@ -17318,12 +17440,12 @@ } }, "node_modules/pkg-types": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.1.1.tgz", - "integrity": "sha512-ko14TjmDuQJ14zsotODv7dBlwxKhUKQEhuhmbqo1uCi9BB0Z2alo/wAXg6q1dTR5TyuqYyWhjtfe/Tsh+X28jQ==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.2.1.tgz", + "integrity": "sha512-sQoqa8alT3nHjGuTjuKgOnvjo4cljkufdtLMnO2LBP/wRwuDlo1tkaEdMxCRhyGRPacv/ztlZgDPm2b7FAmEvw==", "dependencies": { - "confbox": "^0.1.7", - "mlly": "^1.7.0", + "confbox": "^0.1.8", + "mlly": "^1.7.2", "pathe": "^1.1.2" } }, @@ -17836,19 +17958,19 @@ } }, "node_modules/prisma": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.22.0.tgz", - "integrity": "sha512-vtpjW3XuYCSnMsNVBjLMNkTj6OZbudcPPTPYHqX0CJfpcdWciI1dM8uHETwmDxxiqEwCIE6WvXucWUetJgfu/A==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.1.0.tgz", + "integrity": "sha512-aFI3Yi+ApUxkwCJJwyQSwpyzUX7YX3ihzuHNHOyv4GJg3X5tQsmRaJEnZ+ZyfHpMtnyahhmXVfbTZ+lS8ZtfKw==", "devOptional": true, "hasInstallScript": true, "dependencies": { - "@prisma/engines": "5.22.0" + "@prisma/engines": "6.1.0" }, "bin": { "prisma": "build/index.js" }, "engines": { - "node": ">=16.13" + "node": ">=18.18" }, "optionalDependencies": { "fsevents": "2.3.3" @@ -20326,8 +20448,7 @@ "node_modules/tinyexec": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.1.tgz", - "integrity": "sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==", - "dev": true + "integrity": "sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==" }, "node_modules/tinypool": { "version": "0.8.4", @@ -20512,9 +20633,9 @@ } }, "node_modules/ufo": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.5.3.tgz", - "integrity": "sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==" + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.5.4.tgz", + "integrity": "sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==" }, "node_modules/uglify-js": { "version": "3.19.3", diff --git a/package.json b/package.json index 831c120..b872c5b 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,11 @@ "dependencies": { "@nuxt/devtools-kit": "^1.3.3", "@nuxt/kit": "^3.11.2", - "@prisma/client": "^5.22.0", + "@prisma/client": "^6.1.0", "chalk": "^5.3.0", "defu": "^6.1.4", "execa": "^8.0.1", + "nypm": "^0.4.1", "pathe": "^1.1.2", "prompts": "^2.4.2" }, @@ -65,7 +66,7 @@ "inquirer": "^9.3.7", "nuxt": "^3.11.2", "prettier": "3.2.5", - "prisma": "^5.22.0", + "prisma": "^6.1.0", "semantic-release": "^24.2.0", "vitest": "^1.2.2" }, diff --git a/src/module.ts b/src/module.ts index dcf5595..2107097 100644 --- a/src/module.ts +++ b/src/module.ts @@ -25,7 +25,6 @@ import { } from "./package-utils/setup-helpers"; import { log, PREDEFINED_LOG_MESSAGES } from "./package-utils/log-helpers"; import type { Prisma } from "@prisma/client"; -import type { PackageManager } from "./package-utils/detect-pm"; import { executeRequiredPrompts } from "./package-utils/prompts"; // Module configuration interface @@ -39,7 +38,6 @@ interface ModuleOptions extends Prisma.PrismaClientOptions { installStudio: boolean; autoSetupPrisma: boolean; skipPrompts: boolean; - packageManager?: PackageManager; prismaRoot?: string; prismaSchemaPath?: string; } @@ -70,7 +68,6 @@ export default defineNuxtModule({ installStudio: true, autoSetupPrisma: false, skipPrompts: false, - packageManager: undefined, prismaRoot: undefined, prismaSchemaPath: undefined, }, @@ -145,7 +142,7 @@ export default defineNuxtModule({ if (options.installCLI) { const prismaInstalled = await isPrismaCLIInstalled(PROJECT_PATH); if (!prismaInstalled) { - await installPrismaCLI(PROJECT_PATH, options.packageManager); + await installPrismaCLI(PROJECT_PATH); await generatePrismaClient( PROJECT_PATH, PRISMA_SCHEMA_CMD, @@ -245,11 +242,7 @@ export default defineNuxtModule({ await writeClientInLib(LAYER_PATH); if (options.generateClient) { - await installPrismaClient( - PROJECT_PATH, - options.installClient, - options.packageManager, - ); + await installPrismaClient(PROJECT_PATH, options.installClient); await generatePrismaClient( PROJECT_PATH, PRISMA_SCHEMA_CMD, diff --git a/src/package-utils/detect-pm.ts b/src/package-utils/detect-pm.ts deleted file mode 100644 index 9116afc..0000000 --- a/src/package-utils/detect-pm.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { existsSync } from "fs"; -import { logWarning } from "./log-helpers"; - -export type PackageManager = "npm" | "yarn" | "pnpm" | "bun"; - -function detectPackageManager( - projectRoot: string, - packageManager?: PackageManager, -): PackageManager { - // If a package manager was explicitly defined, use that one. - if (packageManager) return packageManager; - - // Check for package-lock.json - if ( - existsSync("package-lock.json") || - existsSync(`${projectRoot}/package-lock.json`) - ) { - return "npm"; - } - - // Check for yarn.lock - if (existsSync("yarn.lock") || existsSync(`${projectRoot}/yarn.lock`)) { - return "yarn"; - } - - // Check for pnpm-lock.yaml - if ( - existsSync("pnpm-lock.yaml") || - existsSync(`${projectRoot}/pnpm-lock.yaml`) - ) { - return "pnpm"; - } - - // bun.lockb - if (existsSync("bun.lockb") || existsSync(`${projectRoot}/bun.lockb`)) { - return "bun"; - } - - // Default to npm if none of the above are found - logWarning("Could not find any package manager files. Defaulting to npm."); - return "npm"; -} - -export const installingPrismaCLIWithPM = ( - projectRoot: string, - packageManager?: PackageManager, -) => { - const pm = detectPackageManager(projectRoot, packageManager); - - switch (pm) { - case "npm": { - return { - pm, - command: ["install", "prisma", "--save-dev"], - }; - } - case "pnpm": { - return { - pm, - command: ["add", "-D", "prisma"], - }; - } - case "yarn": { - return { - pm, - command: ["add", "-D", "prisma"], - }; - } - case "bun": { - return { - pm, - command: ["add", "prisma", "--dev"], - }; - } - default: { - return { - pm: "npm", - command: ["install", "prisma", "--save-dev"], - }; - } - } -}; - -export const installingPrismaClientWithPM = ( - projectRoot: string, - packageManager?: PackageManager, -) => { - const pm = detectPackageManager(projectRoot, packageManager); - - switch (pm) { - case "npm": { - return { - pm, - command: ["install", "@prisma/client", "--save-dev"], - }; - } - case "pnpm": { - return { - pm, - command: ["add", "-D", "@prisma/client"], - }; - } - case "yarn": { - return { - pm, - command: ["add", "-D", "@prisma/client"], - }; - } - case "bun": { - return { - pm, - command: ["add", "@prisma/client", "--dev"], - }; - } - default: { - return { - pm: "npm", - command: ["install", "@prisma/client", "--save-dev"], - }; - } - } -}; diff --git a/src/package-utils/setup-helpers.ts b/src/package-utils/setup-helpers.ts index 8ec8330..b71ec91 100644 --- a/src/package-utils/setup-helpers.ts +++ b/src/package-utils/setup-helpers.ts @@ -1,9 +1,4 @@ import { execa } from "execa"; -import { - installingPrismaClientWithPM, - installingPrismaCLIWithPM, - type PackageManager, -} from "./detect-pm"; import { log, logError, @@ -12,6 +7,7 @@ import { } from "./log-helpers"; import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"; import { join } from "pathe"; +import { addDependency, addDevDependency } from "nypm"; export type DatabaseProviderType = | "sqlite" @@ -42,16 +38,12 @@ export async function isPrismaCLIInstalled( } } -export async function installPrismaCLI( - directory: string, - packageManager?: PackageManager, -) { +export async function installPrismaCLI(directory: string) { try { - const installCmd = installingPrismaCLIWithPM(directory, packageManager); - - await execa(installCmd.pm, installCmd.command, { + await addDevDependency("prisma", { cwd: directory, }); + logSuccess(PREDEFINED_LOG_MESSAGES.installPrismaCLI.yes); } catch (err) { logError(PREDEFINED_LOG_MESSAGES.installPrismaCLI.no); @@ -226,18 +218,12 @@ export async function formatSchema(directory: string, schemaPath: string[]) { export async function installPrismaClient( directory: string, installPrismaClient: boolean = true, - packageManager?: PackageManager, ) { log(PREDEFINED_LOG_MESSAGES.generatePrismaClient.action); if (installPrismaClient) { try { - const installCmd = installingPrismaClientWithPM( - directory, - packageManager, - ); - - await execa(installCmd.pm, installCmd.command, { + await addDependency("@prisma/client", { cwd: directory, }); } catch (error) {