2024-04-07 08:50:08 +02:00
|
|
|
#!/bin/bash
|
2023-12-09 00:00:47 +01:00
|
|
|
|
|
|
|
|
# This script is a wrapper for the main server, CLI and Prisma binaries.
|
|
|
|
|
# Commands:
|
|
|
|
|
# - `start`: Starts the server
|
|
|
|
|
# - `cli`: Starts the CLI, sends all arguments to it
|
|
|
|
|
# - `prisma`: Execute a Prisma command, sends
|
|
|
|
|
|
|
|
|
|
# Exit immediately if a command exits with a non-zero status.
|
|
|
|
|
set -e
|
|
|
|
|
|
2024-04-07 10:56:15 +02:00
|
|
|
cd ./dist
|
|
|
|
|
|
2023-12-09 00:00:47 +01:00
|
|
|
# Parse first argument
|
|
|
|
|
case "$1" in
|
|
|
|
|
"start")
|
|
|
|
|
# Start the server
|
2024-04-07 10:56:15 +02:00
|
|
|
exec bun run ./index.js --prod
|
2023-12-09 00:00:47 +01:00
|
|
|
;;
|
|
|
|
|
"cli")
|
|
|
|
|
# Start the CLI
|
|
|
|
|
shift 1
|
2024-04-07 10:56:15 +02:00
|
|
|
exec bun run ./cli.js "$@"
|
2023-12-09 00:00:47 +01:00
|
|
|
;;
|
|
|
|
|
"prisma")
|
|
|
|
|
# Proxy all Prisma commands
|
|
|
|
|
# Use output of dist/prisma.js to get the env variable
|
|
|
|
|
shift 1
|
|
|
|
|
# Set DATABASE_URL env variable to the output of bun run ./dist/prisma.js
|
2024-04-07 10:56:15 +02:00
|
|
|
export DATABASE_URL=$(bun run ./prisma.js)
|
2023-12-09 00:00:47 +01:00
|
|
|
# Execute the Prisma binary
|
|
|
|
|
exec bunx prisma "$@"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
# Run custom commands
|
|
|
|
|
exec "$@"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
```
|