Skip to content

Commit d195a8c

Browse files
committed
fix: modernize and fix Deno tests
- Switch from Deno 1.x to Deno 2.x - Switch from `prisma-client-js` to `prisma-client-ts` generator - Use `deno.json` instead of `package.json`
1 parent 00fc56e commit d195a8c

26 files changed

+563
-902
lines changed

.github/scripts/check-engines-cli.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fi
2020
# TODO Adapt tests so they also work here, or adapt project to fit into the mold
2121
skipped_projects=(
2222
aws-graviton # No local project at all (everything happens on server), so no `prisma` or `node_modules`
23+
deno # A different binary target (OpenSSL 3.x) is used with Deno
2324
firebase-functions # No local project at expected location (but in `functions` subfolder)
2425
pnpm # Current logic does not work with pnpm hoisitng
2526
pnpm-workspaces-custom-output # Current logic does not work with pnpm hoisitng
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
shopt -s inherit_errexit || true
5+
6+
denoJsonPath="$1"
7+
8+
echo "-------------------------"
9+
echo ""
10+
11+
echo "deno: $(deno -v)"
12+
13+
echo "prisma-version.txt: $(cat .github/prisma-version.txt)"
14+
echo "prisma (deno.json): $(jq -r '.imports["prisma"] | sub("^npm:prisma@"; "")' < $denoJsonPath)"
15+
echo "@prisma/client (deno.json): $(jq -r '.imports["@prisma/client"] | sub("^npm:@prisma/client@"; "")' < $denoJsonPath)"
16+
17+
echo ""
18+
echo "-------------------------"

.github/scripts/print-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -eu
44
shopt -s inherit_errexit || true

.github/scripts/test-project.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ set -u
1414

1515
# In platforms/firebase-functions, the file exists in /functions sub-directory, so we can't hardcode the package.json path
1616
pjson_path=$(find "$dir"/"$project" -name "package.json" ! -path "*/node_modules/*" | head -n 1)
17-
bash .github/scripts/print-version.sh "$pjson_path"
17+
if [ -n "$pjson_path" ]; then
18+
bash .github/scripts/print-version.sh "$pjson_path"
19+
fi
20+
21+
deno_json_path="$dir/$project/deno.json"
22+
if [ -f "$deno_json_path" ]; then
23+
bash .github/scripts/print-version-deno.sh "$deno_json_path"
24+
fi
1825

1926
# Install deps for Slack scripts
2027
echo "cd .github/slack/"
@@ -40,8 +47,18 @@ then
4047
else
4148
# Find version of Prisma this project uses (so we can call the CLI explicitly)
4249
default_version="$(cat .github/prisma-version.txt)"
43-
cli_version_dev="$(node -e "console.log(require('./$dir/$project/package.json')?.devDependencies?.prisma ?? '')")"
44-
cli_version_dep="$(node -e "console.log(require('./$dir/$project/package.json')?.dependencies?.prisma ?? '')")"
50+
51+
if [ -n "$pjson_path" ]; then
52+
cli_version_dev="$(node -e "console.log(require('./$pjson_path')?.devDependencies?.prisma ?? '')")"
53+
cli_version_dep="$(node -e "console.log(require('./$pjson_path')?.dependencies?.prisma ?? '')")"
54+
elif [ -f "$deno_json_path" ]; then
55+
cli_version_dev=""
56+
cli_version_dep="$(node -e "console.log(require('./$deno_json_path')?.imports?.prisma?.replace(/^npm:prisma@/, '') ?? '')")"
57+
else
58+
cli_version_dev=""
59+
cli_version_dep=""
60+
fi
61+
4562
version="$(node -e "console.log('$cli_version_dev' || '$cli_version_dep' || '$default_version')")"
4663

4764
schema_path=$(find "$dir"/"$project" -name "schema.prisma" ! -path "*/node_modules/*" | head -n 1)

.github/workflows/check-for-update.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
cache: 'pnpm'
2828
cache-dependency-path: '**/pnpm-lock.yaml'
2929

30+
- uses: denoland/setup-deno@v2
31+
with:
32+
deno-version: v2.x
33+
3034
- name: Install Dependencies
3135
run: pnpm install
3236

.github/workflows/test.yaml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,20 +1202,21 @@ jobs:
12021202
- uses: pnpm/action-setup@v4.0.0
12031203

12041204
- uses: actions/setup-node@v4
1205+
if: ${{ matrix.platform != 'deno' }}
12051206
with:
12061207
node-version: 18
12071208
cache: 'pnpm'
12081209
cache-dependency-path: ${{ github.job }}/${{ matrix.platform }}/pnpm-lock.yaml
12091210

1210-
- name: use deno v1.x
1211-
uses: denoland/setup-deno@v1
1211+
- uses: denoland/setup-deno@v2
12121212
with:
1213-
deno-version: v1.x
1213+
deno-version: v2.x
12141214

12151215
- name: Define Client Engine Type to test
12161216
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV
12171217

12181218
- name: Install Dependencies
1219+
if: ${{ matrix.platform != 'deno' }}
12191220
run: pnpm install
12201221

12211222
# see above why this is not a matrix for each DP variant
@@ -1602,7 +1603,7 @@ jobs:
16021603
runtime:
16031604
- deno
16041605
#- bun
1605-
clientEngine: ['library', 'binary']
1606+
clientEngine: ['library']
16061607
os: [ubuntu-22.04]
16071608
runs-on: ${{ matrix.os }}
16081609
concurrency: ${{ github.job }}-${{ matrix.runtime }}-${{ matrix.clientEngine }}
@@ -1617,20 +1618,14 @@ jobs:
16171618
- uses: actions/setup-node@v4
16181619
with:
16191620
node-version: 18
1620-
cache: 'pnpm'
1621-
cache-dependency-path: ${{ github.job }}/${{ matrix.runtime }}/pnpm-lock.yaml
16221621

1623-
- name: use deno v1.x
1624-
uses: denoland/setup-deno@v1
1622+
- uses: denoland/setup-deno@v2
16251623
with:
1626-
deno-version: v1.44.2
1624+
deno-version: v2.x
16271625

16281626
- name: Define Client Engine Type to test
16291627
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV
16301628

1631-
- name: Install Dependencies
1632-
run: pnpm install
1633-
16341629
- name: test ${{ matrix.runtime }}
16351630
run: bash .github/scripts/test-project.sh ${{ github.job }} ${{ matrix.runtime }}
16361631

accelerate/deno/deno.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"imports": {
3+
"prisma": "npm:prisma@6.6.0-dev.101",
4+
"@prisma/client": "npm:@prisma/client@6.6.0-dev.101",
5+
"@prisma/extension-accelerate": "npm:@prisma/extension-accelerate@1.2.2",
6+
"@std/assert": "jsr:@std/assert@^1.0.12"
7+
},
8+
"nodeModulesDir": "auto",
9+
"tasks": {
10+
"generate": "prisma generate --no-engine"
11+
}
12+
}

accelerate/deno/deno.lock

Lines changed: 211 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accelerate/deno/package.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)