Skip to content

Commit

Permalink
fix: cf pages (#4575)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Piotrowski <[email protected]>
Co-authored-by: Peter Bacon Darwin <[email protected]>
  • Loading branch information
3 people authored Feb 19, 2024
1 parent 735fd16 commit f6806a8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/scripts/test-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ if [ -n "${FORCE_PRISMA_CLIENT_CUSTOM_OUTPUT+x}" ]; then
echo ""
echo "FORCE_PRISMA_CLIENT_CUSTOM_OUTPUT=$FORCE_PRISMA_CLIENT_CUSTOM_OUTPUT, executing commands to turn the project into a custom output project"
echo ""
find . -name "*.js" ! -path "*/node_modules/*" ! -name "*test*" -print0 | xargs -0 -r sed -i "s/@prisma\/client/db/g"
find . -name "*.mjs" ! -path "*/node_modules/*" ! -name "*test*" -print0 | xargs -0 -r sed -i "s/@prisma\/client/db/g"
find . -name '*.prisma' ! -path '*/node_modules/*' -print0 | xargs -0 -r sed -i 's/provider\s*=\s*"prisma-client-js"/&\noutput = "client"/g'
find . -name "package.json" ! -path "*/node_modules/*" -print0 | xargs -0 -r sed -i 's/"dependencies": {/&\n"db": "link:.\/prisma\/client",/g'
find . -type f -name "*.js" ! -path "*/node_modules/*" ! -name "*test*" -print0 | xargs -0 -r sed -i "s/@prisma\/client/db/g"
find . -type f -name "*.mjs" ! -path "*/node_modules/*" ! -name "*test*" -print0 | xargs -0 -r sed -i "s/@prisma\/client/db/g"
find . -type f -name '*.prisma' ! -path '*/node_modules/*' -print0 | xargs -0 -r sed -i 's/provider\s*=\s*"prisma-client-js"/&\noutput = "client"/g'
find . -type f -name "package.json" ! -path "*/node_modules/*" -print0 | xargs -0 -r sed -i 's/"dependencies": {/&\n"db": "link:.\/prisma\/client",/g'
bash ../../scripts/update-locks.sh

# this adds some level of safety to ensure that js files were at least modified as one would expect
Expand Down
3 changes: 2 additions & 1 deletion driver-adapters-wasm/pg-cfpages-basic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
deployment-logs.txt
.env
.wrangler
.dev.vars
.dev.vars
_worker.js
3 changes: 1 addition & 2 deletions driver-adapters-wasm/pg-cfpages-basic/finally.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env bash

echo "Temporary disabled, see https://github.com/cloudflare/workers-sdk/pull/2541"
# cat deployment-logs.txt
cat deployment-logs.txt
2 changes: 1 addition & 1 deletion driver-adapters-wasm/pg-cfpages-basic/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
export PRISMA_TELEMETRY_INFORMATION='ecosystem-tests driver-adapters-wasm pg-cfpages-basic build'
export PRISMA_CLIENT_ENGINE_TYPE='wasm' # because setup otherwise makes it library/binary

echo "export const DATABASE_URL = '$DATABASE_URL'" > ./functions/dbUrl.js
echo "export const DATABASE_URL = '$DATABASE_URL'" > ./fns/dbUrl.js
13 changes: 11 additions & 2 deletions driver-adapters-wasm/pg-cfpages-basic/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@ pnpm install

pnpm prisma generate

# pnpm wrangler pages deploy . --project-name pg-cfpages-basic --node-compat | tee deployment-logs.txt
# sleep 15
# First build the functions using the `--node-compat` flag into the `_worker.js` directory
# (Note that the functions are in the non-standard `fns` directory so that they are not confused with the output `_worker.js` directory.)
# Make sure build folder does not exist
rm -rf build
# Build pages function to build/_worker.js
pnpm wrangler pages functions build fns --node-compat --outdir build/_worker.js
# Copy index.html to build folder
cp index.html build/index.html
# Now deploy the _worker.js alongside the index.html asset to Pages
pnpm wrangler pages deploy ./build --project-name pg-cfpages-basic -- | tee deployment-logs.txt
sleep 15
8 changes: 3 additions & 5 deletions driver-adapters-wasm/pg-cfpages-basic/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

set -eu

echo "Temporary disabled, because wrangler does not support "--node-compat" flag for pages commands yet. See https://github.com/cloudflare/workers-sdk/pull/2541"
export DEPLOYMENT_URL=$(cat deployment-logs.txt | grep -Eo "(https.*)\.pages\.dev$" --color=never)
echo $DEPLOYMENT_URL

# export DEPLOYMENT_URL=$(cat deployment-logs.txt | grep -Eo "(https.*)\.pages\.dev$" --color=never)
# echo $DEPLOYMENT_URL

# pnpm test
pnpm test

0 comments on commit f6806a8

Please sign in to comment.