create-prisma 0.4.2-next.37.92.1 → 0.4.2-next.37.93.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -9
- package/dist/cli.mjs +1 -1
- package/dist/{create-B0eFGNQ2.mjs → create-DGDCo1EV.mjs} +17 -11
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/templates/create/minimal/.yarnrc.yml.hbs +3 -0
- package/templates/create/minimal/README.md.hbs +38 -0
- package/templates/create/minimal/deno.json.hbs +5 -0
- package/templates/create/minimal/package.json.hbs +13 -0
- package/templates/create/minimal/src/index.ts.hbs +42 -0
- package/templates/create/minimal/src/lib/prisma.ts.hbs +71 -0
- package/templates/create/minimal/tsconfig.json +14 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Scaffold a new app with Prisma Next already wired up.
|
|
|
10
10
|
- adds Prisma Next dependencies for PostgreSQL or MongoDB
|
|
11
11
|
- runs `prisma-next init --no-install` to scaffold `prisma/contract.*`, `prisma-next.config.ts`, `prisma/db.ts`, `prisma-next.md`, `.env.example`, and the Prisma Next agent skill
|
|
12
12
|
- writes a template-specific Prisma Next runtime helper
|
|
13
|
-
- adds `contract:emit`, `db:init`, `db:update`, `db:verify`, `db:seed`, `migration:plan`, `
|
|
13
|
+
- adds `contract:emit`, `db:init`, `db:update`, `db:verify`, `db:seed`, `migration:plan`, `migrate`, `migration:status`, and `migration:show` scripts
|
|
14
14
|
- adds `db:up` / `db:down` and `docker-compose.yml` for default MongoDB projects
|
|
15
15
|
- creates or updates `.env` with `DATABASE_URL`
|
|
16
16
|
- can install dependencies and run `prisma-next contract emit`
|
|
@@ -57,6 +57,12 @@ Create a project interactively:
|
|
|
57
57
|
create-prisma
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
Create a Minimal project non-interactively:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
create-prisma --name my-script --template minimal --provider postgres
|
|
64
|
+
```
|
|
65
|
+
|
|
60
66
|
Create a Hono app non-interactively:
|
|
61
67
|
|
|
62
68
|
```bash
|
|
@@ -89,14 +95,15 @@ create-prisma --name my-app --template nest --provider postgres --prisma-postgre
|
|
|
89
95
|
|
|
90
96
|
## Supported Templates
|
|
91
97
|
|
|
92
|
-
- `
|
|
93
|
-
- `
|
|
94
|
-
- `
|
|
95
|
-
- `
|
|
96
|
-
- `
|
|
97
|
-
- `
|
|
98
|
-
- `
|
|
99
|
-
- `
|
|
98
|
+
- `minimal` - script-first Prisma Next starter with no web framework
|
|
99
|
+
- `hono` - lightweight TypeScript API server
|
|
100
|
+
- `elysia` - Bun-friendly TypeScript API server
|
|
101
|
+
- `nest` - structured Node API with controllers and services
|
|
102
|
+
- `next` - full-stack React app with App Router
|
|
103
|
+
- `svelte` - full-stack Svelte 5 app with Vite
|
|
104
|
+
- `astro` - content-oriented web app with server routes
|
|
105
|
+
- `nuxt` - full-stack Vue app with Nitro server routes
|
|
106
|
+
- `tanstack-start` - React app with file routes and server functions
|
|
100
107
|
|
|
101
108
|
## Supported Databases
|
|
102
109
|
|
package/dist/cli.mjs
CHANGED
|
@@ -49,7 +49,7 @@ async function getAnonymousId() {
|
|
|
49
49
|
}
|
|
50
50
|
function getCommonProperties() {
|
|
51
51
|
return {
|
|
52
|
-
"cli-version": "0.4.2-next.37.
|
|
52
|
+
"cli-version": "0.4.2-next.37.93.1",
|
|
53
53
|
"node-version": process.version,
|
|
54
54
|
platform: process.platform,
|
|
55
55
|
arch: process.arch
|
|
@@ -176,7 +176,7 @@ function getCreateTemplateDependencies(template, packageManager) {
|
|
|
176
176
|
dependencies: [],
|
|
177
177
|
devDependencies: ["@prisma-next/vite-plugin-contract-emit"]
|
|
178
178
|
});
|
|
179
|
-
if (template === "hono" || template === "elysia" || template === "nest") {
|
|
179
|
+
if (template === "minimal" || template === "hono" || template === "elysia" || template === "nest") {
|
|
180
180
|
const runtimeDevDependencies = usesNodeStyleRuntime(packageManager) ? ["tsx"] : [];
|
|
181
181
|
if (template === "elysia" && packageManager !== "deno") targets.push({
|
|
182
182
|
packageJsonPath: "package.json",
|
|
@@ -209,6 +209,7 @@ const packageManagers = [
|
|
|
209
209
|
];
|
|
210
210
|
const authoringStyles = ["psl", "typescript"];
|
|
211
211
|
const createTemplates = [
|
|
212
|
+
"minimal",
|
|
212
213
|
"hono",
|
|
213
214
|
"elysia",
|
|
214
215
|
"nest",
|
|
@@ -1507,7 +1508,7 @@ function getCreatePrismaIntro() {
|
|
|
1507
1508
|
//#endregion
|
|
1508
1509
|
//#region src/commands/create.ts
|
|
1509
1510
|
const DEFAULT_PROJECT_NAME = "my-app";
|
|
1510
|
-
const DEFAULT_TEMPLATE = "
|
|
1511
|
+
const DEFAULT_TEMPLATE = "minimal";
|
|
1511
1512
|
function toPackageName(projectName) {
|
|
1512
1513
|
return projectName.toLowerCase().replace(/[^a-z0-9._-]/g, "-").replace(/^-+/, "").replace(/-+$/, "") || "app";
|
|
1513
1514
|
}
|
|
@@ -1538,45 +1539,50 @@ async function promptForCreateTemplate() {
|
|
|
1538
1539
|
message: "Select template",
|
|
1539
1540
|
initialValue: DEFAULT_TEMPLATE,
|
|
1540
1541
|
options: [
|
|
1542
|
+
{
|
|
1543
|
+
value: "minimal",
|
|
1544
|
+
label: "Minimal",
|
|
1545
|
+
hint: "Script-first Prisma Next starter with no web framework"
|
|
1546
|
+
},
|
|
1541
1547
|
{
|
|
1542
1548
|
value: "hono",
|
|
1543
1549
|
label: "Hono",
|
|
1544
|
-
hint: "
|
|
1550
|
+
hint: "Lightweight TypeScript API server"
|
|
1545
1551
|
},
|
|
1546
1552
|
{
|
|
1547
1553
|
value: "elysia",
|
|
1548
1554
|
label: "Elysia",
|
|
1549
|
-
hint: "TypeScript API
|
|
1555
|
+
hint: "Bun-friendly TypeScript API server"
|
|
1550
1556
|
},
|
|
1551
1557
|
{
|
|
1552
1558
|
value: "nest",
|
|
1553
1559
|
label: "NestJS",
|
|
1554
|
-
hint: "
|
|
1560
|
+
hint: "Structured Node API with controllers and services"
|
|
1555
1561
|
},
|
|
1556
1562
|
{
|
|
1557
1563
|
value: "next",
|
|
1558
1564
|
label: "Next.js",
|
|
1559
|
-
hint: "
|
|
1565
|
+
hint: "Full-stack React app with App Router"
|
|
1560
1566
|
},
|
|
1561
1567
|
{
|
|
1562
1568
|
value: "svelte",
|
|
1563
1569
|
label: "SvelteKit",
|
|
1564
|
-
hint: "
|
|
1570
|
+
hint: "Full-stack Svelte 5 app with Vite"
|
|
1565
1571
|
},
|
|
1566
1572
|
{
|
|
1567
1573
|
value: "astro",
|
|
1568
1574
|
label: "Astro",
|
|
1569
|
-
hint: "
|
|
1575
|
+
hint: "Content-oriented web app with server routes"
|
|
1570
1576
|
},
|
|
1571
1577
|
{
|
|
1572
1578
|
value: "nuxt",
|
|
1573
1579
|
label: "Nuxt",
|
|
1574
|
-
hint: "
|
|
1580
|
+
hint: "Full-stack Vue app with Nitro server routes"
|
|
1575
1581
|
},
|
|
1576
1582
|
{
|
|
1577
1583
|
value: "tanstack-start",
|
|
1578
1584
|
label: "TanStack Start",
|
|
1579
|
-
hint: "
|
|
1585
|
+
hint: "React app with file routes and server functions"
|
|
1580
1586
|
}
|
|
1581
1587
|
]
|
|
1582
1588
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -195,6 +195,7 @@ declare const AuthoringStyleSchema: z.ZodEnum<{
|
|
|
195
195
|
typescript: "typescript";
|
|
196
196
|
}>;
|
|
197
197
|
declare const CreateTemplateSchema: z.ZodEnum<{
|
|
198
|
+
minimal: "minimal";
|
|
198
199
|
hono: "hono";
|
|
199
200
|
elysia: "elysia";
|
|
200
201
|
nest: "nest";
|
|
@@ -231,6 +232,7 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
231
232
|
emit: z.ZodOptional<z.ZodBoolean>;
|
|
232
233
|
name: z.ZodOptional<z.ZodString>;
|
|
233
234
|
template: z.ZodOptional<z.ZodEnum<{
|
|
235
|
+
minimal: "minimal";
|
|
234
236
|
hono: "hono";
|
|
235
237
|
elysia: "elysia";
|
|
236
238
|
nest: "nest";
|
|
@@ -272,6 +274,7 @@ declare const router: {
|
|
|
272
274
|
emit: zod.ZodOptional<zod.ZodBoolean>;
|
|
273
275
|
name: zod.ZodOptional<zod.ZodString>;
|
|
274
276
|
template: zod.ZodOptional<zod.ZodEnum<{
|
|
277
|
+
minimal: "minimal";
|
|
275
278
|
hono: "hono";
|
|
276
279
|
elysia: "elysia";
|
|
277
280
|
nest: "nest";
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-DGDCo1EV.mjs";
|
|
3
3
|
import { os } from "@orpc/server";
|
|
4
4
|
import { createCli } from "trpc-cli";
|
|
5
5
|
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
const CLI_VERSION = "0.4.2-next.37.
|
|
7
|
+
const CLI_VERSION = "0.4.2-next.37.93.1";
|
|
8
8
|
const router = os.router({ create: os.meta({
|
|
9
9
|
description: "Create a new project with Prisma setup",
|
|
10
10
|
default: true,
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
Generated by `create-prisma` with the Minimal template.
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
- `{{runScriptCommand packageManager "dev"}}` - run the Prisma Next sample script
|
|
8
|
+
|
|
9
|
+
## Prisma Next
|
|
10
|
+
|
|
11
|
+
Prisma Next setup is scaffolded in:
|
|
12
|
+
|
|
13
|
+
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
14
|
+
- `prisma-next.config.ts`
|
|
15
|
+
- `prisma/db.ts`
|
|
16
|
+
- `src/lib/prisma.ts`
|
|
17
|
+
|
|
18
|
+
Database helper scripts are added to `package.json`:
|
|
19
|
+
|
|
20
|
+
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
21
|
+
{{#if (eq provider "mongo")}}
|
|
22
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
23
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB replica set
|
|
24
|
+
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
25
|
+
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
26
|
+
{{else}}
|
|
27
|
+
- `{{runScriptCommand packageManager "db:init"}}` - initialize database state manually
|
|
28
|
+
- `{{runScriptCommand packageManager "db:update"}}` - update database state manually
|
|
29
|
+
- `{{runScriptCommand packageManager "migration:plan"}}` - create a migration plan
|
|
30
|
+
- `{{runScriptCommand packageManager "migrate"}}` - apply a planned migration
|
|
31
|
+
{{/if}}
|
|
32
|
+
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
33
|
+
|
|
34
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Agent-specific project guidance starts in `.agents/skills/prisma-next/SKILL.md`.
|
|
35
|
+
|
|
36
|
+
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
37
|
+
|
|
38
|
+
Run the migration and seed scripts first, then `{{runScriptCommand packageManager "dev"}}` runs a small write/read round trip from `src/index.ts`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
{{#if (packageManagerManifestValue packageManager)}}
|
|
5
|
+
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
6
|
+
{{/if}}
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "{{runtimeScript packageManager "start" "src/index.ts" ""}}"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {},
|
|
12
|
+
"devDependencies": {}
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { db, listUsers } from "./lib/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
2
|
+
|
|
3
|
+
const sampleUser = {
|
|
4
|
+
email: "first.user@prisma.io",
|
|
5
|
+
name: "First User",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
{{#if (eq provider "mongo")}}
|
|
10
|
+
const existingUser = await db.orm.users.where({ email: sampleUser.email }).first();
|
|
11
|
+
if (!existingUser) {
|
|
12
|
+
await db.orm.users.createCount([sampleUser]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const user = await db.orm.users.where({ email: sampleUser.email }).first();
|
|
16
|
+
{{else}}
|
|
17
|
+
const existingUser = await db.orm.User.where({ email: sampleUser.email }).first();
|
|
18
|
+
if (!existingUser) {
|
|
19
|
+
await db.orm.User.createCount([sampleUser]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const user = await db.orm.User.where({ email: sampleUser.email }).first();
|
|
23
|
+
{{/if}}
|
|
24
|
+
const users = await listUsers();
|
|
25
|
+
|
|
26
|
+
console.log(`Prisma Next is ready. Found ${users.length} user${users.length === 1 ? "" : "s"}.`);
|
|
27
|
+
console.log(user);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
await main();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("Prisma Next query failed.");
|
|
34
|
+
console.error("Emit the contract, set DATABASE_URL, then apply migrations before running this script.");
|
|
35
|
+
throw error;
|
|
36
|
+
} finally {
|
|
37
|
+
{{#if (eq provider "mongo")}}
|
|
38
|
+
await db.close();
|
|
39
|
+
{{else}}
|
|
40
|
+
await db.runtime().close();
|
|
41
|
+
{{/if}}
|
|
42
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
{{#if (eq provider "mongo")}}
|
|
3
|
+
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
+
{{else}}
|
|
5
|
+
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
+
{{/if}}
|
|
7
|
+
|
|
8
|
+
{{#if (eq provider "mongo")}}
|
|
9
|
+
import type { DefaultModelRow } from "@prisma-next/mongo-orm";
|
|
10
|
+
{{else}}
|
|
11
|
+
import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
|
|
12
|
+
{{/if}}
|
|
13
|
+
|
|
14
|
+
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
+
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
+
|
|
17
|
+
{{#if (eq provider "mongo")}}
|
|
18
|
+
export const db = mongo<Contract>({
|
|
19
|
+
contractJson,
|
|
20
|
+
url: process.env["DATABASE_URL"],
|
|
21
|
+
});
|
|
22
|
+
{{else}}
|
|
23
|
+
export const db = postgres<Contract>({
|
|
24
|
+
contractJson,
|
|
25
|
+
url: process.env["DATABASE_URL"],
|
|
26
|
+
});
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
+
|
|
31
|
+
{{#if (eq provider "mongo")}}
|
|
32
|
+
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
|
|
33
|
+
return {
|
|
34
|
+
id: String(user._id),
|
|
35
|
+
email: user.email,
|
|
36
|
+
name: user.name ?? null,
|
|
37
|
+
createdAt: null as Date | null,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
{{else}}
|
|
41
|
+
function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
|
|
42
|
+
return {
|
|
43
|
+
id: String(user.id),
|
|
44
|
+
email: user.email,
|
|
45
|
+
name: user.name ?? null,
|
|
46
|
+
createdAt: user.createdAt,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
{{/if}}
|
|
50
|
+
|
|
51
|
+
export async function listUsers(limit = 10) {
|
|
52
|
+
|
|
53
|
+
{{#if (eq provider "mongo")}}
|
|
54
|
+
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
55
|
+
|
|
56
|
+
for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
|
|
57
|
+
users.push(toStarterUser(user));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return users;
|
|
61
|
+
{{else}}
|
|
62
|
+
const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
|
|
63
|
+
|
|
64
|
+
return users.map(toStarterUser);
|
|
65
|
+
{{/if}}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
70
|
+
|
|
71
|
+
export default db;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"resolveJsonModule": true,
|
|
7
|
+
"verbatimModuleSyntax": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts", "prisma/**/*.ts"]
|
|
14
|
+
}
|