#!/usr/bin/env bash
# Download Prisma engines for node:20-slim (debian-openssl-3.0.x). Run on a machine with internet.
set -euo pipefail
cd "$(dirname "$0")/.."

pnpm install --registry https://registry.npmjs.org
PRISMA_CLI_BINARY_TARGETS=debian-openssl-3.0.x pnpm exec prisma generate

ENGINES="$(find node_modules -path '*/@prisma/engines' -type d | head -1)"
mkdir -p prisma-binaries
cp "$ENGINES/libquery_engine-debian-openssl-3.0.x.so.node" prisma-binaries/
cp "$ENGINES/schema-engine-debian-openssl-3.0.x" prisma-binaries/
chmod +x prisma-binaries/schema-engine-debian-openssl-3.0.x
ls -lh prisma-binaries/
