Skip to content
Merged
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
4 changes: 3 additions & 1 deletion apps/blog/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export default defineConfig({
command: (cmd: string) => {
const converted = convert(cmd.replace(/^npm init -y$/, "npm init"), "bun");
if (!converted) return undefined;
return converted.replace(/^bun x /, "bunx --bun ");
return converted
.replace(/^bun x (prisma(?:@\S+)? init\b)/gm, "bunx --bun $1")
.replace(/^bun x /gm, "bunx ");
},
name: "bun",
},
Expand Down
40 changes: 20 additions & 20 deletions apps/docs/content/docs/guides/deployment/bun-workspaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ This guide shows you how to use Prisma ORM in a [Bun Workspaces](https://bun.sh/

Before integrating Prisma ORM, you need to set up your project structure. Start by creating a new directory for your project (for example, `my-monorepo`) and initialize a Node.js project:

```bash
```npm
mkdir my-monorepo
cd my-monorepo
bun init -y
npm init
```

Next, add the `workspaces` array to your root `package.json` to define your workspace structure:
Expand All @@ -50,16 +50,16 @@ This section covers creating a standalone database package that uses Prisma ORM.

Navigate to the `packages/database` directory and initialize a new package:

```bash
```npm
cd packages/database
bun init
npm init
```

Install the required Prisma ORM packages and other dependencies:

```bash
bun add -d prisma typescript tsx @types/node @types/pg
bun add @prisma/client @prisma/adapter-pg pg
```npm
npm install prisma typescript tsx @types/node @types/pg --save-dev
npm install @prisma/client @prisma/adapter-pg pg
```

:::info
Expand All @@ -72,8 +72,8 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst

Initialize Prisma ORM with an instance of [Prisma Postgres](/postgres) in the `database` package by running the following command:

```bash
bunx --bun prisma init
```npm
npx prisma init
```

:::info
Expand All @@ -91,7 +91,7 @@ This command:

Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output:

```bash
```npm
npx create-db
```

Expand All @@ -116,8 +116,8 @@ model User { // [!code ++]

If the generated `prisma.config.ts` comments mention installing `dotenv`, install it so environment variables load:

```bash
bun add dotenv
```npm
npm install dotenv
```

Add a `scripts` section to your database `package.json` (Bun init may not add one by default):
Expand All @@ -136,14 +136,14 @@ Add a `scripts` section to your database `package.json` (Bun init may not add on

Use [Prisma Migrate](/orm/prisma-migrate) to migrate your database changes:

```bash
bun run db:migrate
```npm
npm run db:migrate
```

When prompted by the CLI, enter a descriptive name for your migration. After the migration completes, run generate so the Prisma ORM client is created:

```bash
bun run db:generate
```npm
npm run db:generate
```

Create a `client.ts` file to initialize the Prisma ORM client with a driver adapter:
Expand Down Expand Up @@ -291,8 +291,8 @@ Open the `package.json` file of your Next.js app and add the shared `database` p

Run the following command to install the `database` package:

```bash
bun install
```npm
npm install
```

### 3.2. Add database to app
Expand Down Expand Up @@ -330,8 +330,8 @@ cd ../../

Start your development server by executing:

```bash
bun run dev
```npm
npm run dev
```

Open your browser at [`http://localhost:3000`](http://localhost:3000) to see your app in action. You can run `bun run studio` to open [Prisma Studio](/studio) at [`http://localhost:5555`](http://localhost:5555) to view and edit your data.
Expand Down
34 changes: 17 additions & 17 deletions apps/docs/content/docs/guides/frameworks/elysia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Or follow the steps below to set it up manually.

## 1. Set up your project

Create a new Elysia project using the Bun scaffolding command:
Create a new Elysia project:

```bash
bun create elysia elysia-prisma
```npm
npm create elysia@latest elysia-prisma
```

Navigate to the project directory:
Expand All @@ -47,9 +47,9 @@ cd elysia-prisma

Install the required Prisma packages, database adapter, and Prismabox (for generated TypeBox schemas):

```bash
bun add -d prisma bun-types
bun add @prisma/client @prisma/adapter-pg pg prismabox
```npm
npm install prisma bun-types --save-dev
npm install @prisma/client @prisma/adapter-pg pg prismabox
```

:::info
Expand All @@ -60,8 +60,8 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst

Once installed, initialize Prisma in your project:

```bash
bunx --bun prisma init --output ../src/generated/prisma
```npm
npx prisma init --output ../src/generated/prisma
```

:::info
Expand Down Expand Up @@ -125,9 +125,9 @@ This matches the Prisma Elysia example: it generates Prisma Client to `src/gener

Run the following commands to create the database tables and generate the Prisma Client:

```bash
bunx --bun prisma migrate dev --name init
bunx --bun prisma generate
```npm
npx prisma migrate dev --name init
npx prisma generate
```

### 2.4. Seed the database
Expand Down Expand Up @@ -177,14 +177,14 @@ main()

Run the seed script:

```bash
bunx --bun prisma db seed
```npm
npx prisma db seed
```

And open Prisma Studio to inspect your data:

```bash
bunx --bun prisma studio
```npm
npx prisma studio
```

## 3. Integrate Prisma into Elysia
Expand Down Expand Up @@ -406,8 +406,8 @@ Prismabox generates the `TodoPlain`/`TodoPlainInput*` TypeBox schemas so respons

Start your Elysia server:

```bash
bun run dev
```npm
npm run dev
```

You should see `🦊 Elysia is running at localhost:3000` in the console.
Expand Down
28 changes: 14 additions & 14 deletions apps/docs/content/docs/guides/runtimes/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ cd bun-prisma

Then, initialise a new Bun project:

```bash
bun init -y
```npm
npm init
```

This creates a basic Bun project that includes a `package.json` file and an `index.ts` file.
Expand All @@ -42,9 +42,9 @@ This creates a basic Bun project that includes a `package.json` file and an `ind

Install the required Prisma packages and other dependencies:

```bash
bun add -d prisma @types/pg
bun add @prisma/client @prisma/adapter-pg pg
```npm
npm install prisma @types/pg --save-dev
npm install @prisma/client @prisma/adapter-pg pg
```

:::info
Expand All @@ -57,13 +57,13 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst

Initialize Prisma ORM with Prisma Postgres in your project:

```bash
bunx --bun prisma init
```npm
npx prisma init
```

:::note

The `--bun` flag is required to ensure Prisma runs with the Bun runtime. Without it, Prisma falls back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.
When using the Bun tab for `prisma init`, the `--bun` flag ensures Prisma runs with the Bun runtime instead of falling back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.

:::

Expand All @@ -83,7 +83,7 @@ This command creates:

Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output:

```bash
```npm
npx create-db
```

Expand Down Expand Up @@ -118,9 +118,9 @@ model User { // [!code ++]

Generate the Prisma client and apply your schema to the database:

```bash
bunx --bun prisma migrate dev --name init
bunx --bun prisma generate
```npm
npx prisma migrate dev --name init
npx prisma generate
```

This command:
Expand Down Expand Up @@ -221,8 +221,8 @@ Unlike Node.js, Bun automatically loads `.env` files, so the `import 'dotenv/con

Run the seed script to populate your database:

```bash
bunx --bun prisma db seed
```npm
npx prisma db seed
```

## 5. Creating your Bun server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ For Bun, `.env` files are automatically loaded without additional configuration.

:::note

When running Prisma CLI commands with Bun, use the `--bun` flag (e.g., `bunx --bun prisma init`) to ensure Prisma uses the Bun runtime instead of falling back to Node.js.
When running `prisma init` with Bun, use the `--bun` flag (for example, `bunx --bun prisma init`) to ensure Prisma uses the Bun runtime instead of falling back to Node.js.

:::

Expand Down Expand Up @@ -682,13 +682,13 @@ pnpm prisma validate
# → Still finds prisma.config.ts and resolves schema correctly
```

### Behavior with `npx prisma` or `bunx --bun prisma`
### Behavior with `npx prisma` or `bunx prisma`

When running via `npx prisma` or `bunx --bun prisma`, the CLI only detects the config file if the command is run from the **project root** (where `package.json` declares Prisma).
When running via `npx prisma` or `bunx prisma`, the CLI only detects the config file if the command is run from the **project root** (where `package.json` declares Prisma).

:::note

The `--bun` flag is required when using Bun to ensure Prisma runs with the Bun runtime. Without it, Prisma falls back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.
When running `prisma init` with Bun, use `bunx --bun prisma init` to ensure Prisma runs with the Bun runtime.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ For Bun, `.env` files are automatically loaded without additional configuration.

:::note

When running Prisma CLI commands with Bun, use the `--bun` flag (e.g., `bunx --bun prisma init`) to ensure Prisma uses the Bun runtime instead of falling back to Node.js.
When running `prisma init` with Bun, use the `--bun` flag (for example, `bunx --bun prisma init`) to ensure Prisma uses the Bun runtime instead of falling back to Node.js.

:::

Expand Down Expand Up @@ -738,13 +738,13 @@ pnpm prisma validate
# → Still finds prisma.config.ts and resolves schema correctly
```

### Behavior with `npx prisma` or `bunx --bun prisma`
### Behavior with `npx prisma` or `bunx prisma`

When running via `npx prisma` or `bunx --bun prisma`, the CLI only detects the config file if the command is run from the **project root** (where `package.json` declares Prisma).
When running via `npx prisma` or `bunx prisma`, the CLI only detects the config file if the command is run from the **project root** (where `package.json` declares Prisma).

:::note

The `--bun` flag is required when using Bun to ensure Prisma runs with the Bun runtime. Without it, Prisma falls back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.
When running `prisma init` with Bun, use `bunx --bun prisma init` to ensure Prisma runs with the Bun runtime.

:::

Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/orm/v6/tools/prisma-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ pnpm dlx prisma
### Bun

```
bunx --bun prisma
bunx prisma
```

:::note

The `--bun` flag ensures Prisma runs with the Bun runtime. Without it, Prisma falls back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.
When running `prisma init` with Bun, use `bunx --bun prisma init` to ensure Prisma runs with the Bun runtime.

:::

Expand Down
4 changes: 3 additions & 1 deletion apps/docs/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export default defineConfig({
command: (cmd: string) => {
const converted = convertLine(cmd, "bun");
if (!converted) return undefined;
return converted.replace(/^bun x /gm, "bunx --bun ");
return converted
.replace(/^bun x (prisma(?:@\S+)? init\b)/gm, "bunx --bun $1")
.replace(/^bun x /gm, "bunx ");
},
name: "bun",
},
Expand Down
4 changes: 3 additions & 1 deletion apps/eclipse/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default defineConfig({
command: (cmd: string) => {
const converted = convert(cmd.replace(/^npm init -y$/, "npm init"), "bun");
if (!converted) return undefined;
return converted.replace(/^bun x /, "bunx --bun ");
return converted
.replace(/^bun x (prisma(?:@\S+)? init\b)/gm, "bunx --bun $1")
.replace(/^bun x /gm, "bunx ");
},
name: "bun",
},
Expand Down
4 changes: 3 additions & 1 deletion apps/site/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default defineConfig({
command: (cmd: string) => {
const converted = convert(cmd.replace(/^npm init -y$/, "npm init"), "bun");
if (!converted) return undefined;
return converted.replace(/^bun x /, "bunx --bun ");
return converted
.replace(/^bun x (prisma(?:@\S+)? init\b)/gm, "bunx --bun $1")
.replace(/^bun x /gm, "bunx ");
},
name: "bun",
},
Expand Down
Loading