Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(driver-adapters-wasm): test custom path for Remix projects #5234

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/scripts/convert-to-custom-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ import fs from 'node:fs/promises'
import { glob } from 'glob'

const projectPath = process.argv[2]
const isD1CfPagesNuxt = process.cwd().includes('d1-cfpages-nuxt')

// Evaluates to `true` when the project requires explicit `"db": "link:prisma/client"` in package.json to
// support Prisma Client's custom output.
const customOutputNeedsLinking = [
'd1-cfpages-nuxt',
'neon-cf-remix',
'neon-cfpages-remix',
].some(sustring => process.cwd().includes(sustring))

// See https://github.com/prisma/ecosystem-tests/pull/5040#issuecomment-2152970656
// Add the db link to the package.json
if (isD1CfPagesNuxt) {
if (customOutputNeedsLinking) {
const packageJson = JSON.parse(await fs.readFile(path.join(projectPath, 'package.json'), 'utf8'))
packageJson.dependencies['db'] = 'link:prisma/client'
fs.writeFile(path.join(projectPath, 'package.json'), JSON.stringify(packageJson, null, 2), 'utf8')
Expand All @@ -29,7 +36,7 @@ for await (const file of sourceFiles) {
if (!relImport.startsWith('.')) {
relImport = `./${relImport}`
}
if (isD1CfPagesNuxt) {
if (customOutputNeedsLinking) {
// Replace '@prisma/client' with 'db'
await replaceInFile(file, /@prisma\/client/g, 'db')
} else {
Expand Down
1 change: 0 additions & 1 deletion driver-adapters-wasm/neon-cf-remix/.ignore-custom-output

This file was deleted.

1 change: 1 addition & 0 deletions driver-adapters-wasm/neon-cf-remix/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public-hoist-pattern[]=@prisma/*
5 changes: 4 additions & 1 deletion driver-adapters-wasm/neon-cf-remix/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

set -eu

pnpm install
# Since we modify the package.json to add `"db": "link:prisma/client`
# `--no-frozen-lockfile` is required to avoid the error:
# `ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json`
pnpm install --no-frozen-lockfile

pnpm prisma generate

Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions driver-adapters-wasm/neon-cfpages-remix/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public-hoist-pattern[]=@prisma/*
5 changes: 4 additions & 1 deletion driver-adapters-wasm/neon-cfpages-remix/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

set -eu

pnpm install
# Since we modify the package.json to add `"db": "link:prisma/client`
# `--no-frozen-lockfile` is required to avoid the error:
# `ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json`
pnpm install --no-frozen-lockfile

pnpm prisma generate
pnpm build
Expand Down
Loading