create-prisma 0.7.2 → 0.8.0-pr.56.216.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 +35 -159
- package/dist/cli.mjs +9 -3
- package/dist/create-BeMLn0T7.mjs +1409 -0
- package/dist/index.d.mts +43 -62
- package/dist/index.mjs +35 -2
- package/package.json +24 -19
- package/templates/create/_shared/.gitattributes.hbs +11 -0
- package/templates/create/_shared/README.md.hbs +39 -0
- package/templates/create/_shared/module.ts.hbs +28 -0
- package/templates/create/_shared/pnpm-workspace.yaml.hbs +16 -0
- package/templates/create/_shared/prisma-composer.config.ts.hbs +11 -0
- package/templates/create/_shared/prisma.config.ts.hbs +17 -0
- package/templates/create/_shared/service.ts.hbs +42 -0
- package/templates/create/_shared/src/prisma/composer.ts.hbs +8 -0
- package/templates/create/_shared/src/prisma/db.ts.hbs +51 -0
- package/templates/create/_shared/src/prisma/seed.ts.hbs +36 -0
- package/templates/create/_shared/src/prisma/users.ts.hbs +35 -0
- package/templates/create/astro/{astro.config.mjs.hbs → astro.config.mjs} +1 -2
- package/templates/create/astro/package.json.hbs +5 -5
- package/templates/create/astro/src/pages/api/users.ts.hbs +6 -23
- package/templates/create/astro/src/pages/index.astro.hbs +19 -56
- package/templates/create/astro/tsconfig.json +3 -0
- package/templates/create/elysia/package.json.hbs +6 -7
- package/templates/create/elysia/src/index.ts.hbs +18 -27
- package/templates/create/elysia/tsconfig.json +3 -1
- package/templates/create/hono/package.json.hbs +6 -7
- package/templates/create/hono/src/index.ts.hbs +11 -15
- package/templates/create/hono/tsconfig.json +3 -1
- package/templates/create/minimal/.yarnrc.yml.hbs +3 -0
- package/templates/create/minimal/package.json.hbs +15 -0
- package/templates/create/minimal/src/index.ts.hbs +19 -0
- package/templates/create/{turborepo/apps/api → minimal}/tsconfig.json +2 -2
- package/templates/create/nest/package.json.hbs +7 -7
- package/templates/create/nest/src/app.module.ts.hbs +9 -10
- package/templates/create/nest/src/main.ts.hbs +3 -10
- package/templates/create/nest/src/prisma.service.ts.hbs +6 -5
- package/templates/create/nest/src/users.controller.ts.hbs +3 -5
- package/templates/create/nest/src/users.service.ts.hbs +4 -11
- package/templates/create/nest/tsconfig.json +3 -2
- package/templates/create/next/eslint.config.mjs +8 -1
- package/templates/create/next/package.json.hbs +10 -10
- package/templates/create/next/src/app/page.tsx.hbs +17 -56
- package/templates/create/next/tsconfig.json +1 -0
- package/templates/create/nuxt/app/pages/index.vue.hbs +12 -45
- package/templates/create/nuxt/package.json.hbs +8 -7
- package/templates/create/nuxt/server/api/users.get.ts.hbs +3 -15
- package/templates/create/nuxt/tsconfig.json +3 -0
- package/templates/create/svelte/package.json.hbs +9 -11
- package/templates/create/svelte/src/routes/+page.server.ts.hbs +4 -16
- package/templates/create/svelte/src/routes/+page.svelte.hbs +14 -164
- package/templates/create/svelte/svelte.config.js +1 -4
- package/templates/create/svelte/tsconfig.json +2 -1
- package/templates/create/svelte/vite.config.ts +3 -0
- package/templates/create/tanstack-start/package.json.hbs +14 -14
- package/templates/create/tanstack-start/src/routes/__root.tsx.hbs +2 -3
- package/templates/create/tanstack-start/src/routes/index.tsx.hbs +27 -78
- package/templates/create/tanstack-start/tsconfig.json +4 -2
- package/templates/create/tanstack-start/vite.config.ts +2 -4
- package/dist/src-B3hRLZ0U.mjs +0 -2527
- package/templates/create/astro/README.md.hbs +0 -47
- package/templates/create/astro/deno.json.hbs +0 -5
- package/templates/create/astro/prisma/schema.prisma.hbs +0 -21
- package/templates/create/astro/prisma/seed.ts.hbs +0 -38
- package/templates/create/astro/prisma.compute.ts.hbs +0 -10
- package/templates/create/astro/prisma.config.ts.hbs +0 -15
- package/templates/create/astro/src/lib/prisma.ts.hbs +0 -55
- package/templates/create/elysia/README.md.hbs +0 -43
- package/templates/create/elysia/deno.json.hbs +0 -5
- package/templates/create/elysia/prisma/schema.prisma.hbs +0 -25
- package/templates/create/elysia/prisma/seed.ts.hbs +0 -38
- package/templates/create/elysia/prisma.compute.ts.hbs +0 -11
- package/templates/create/elysia/prisma.config.ts.hbs +0 -15
- package/templates/create/elysia/src/lib/prisma.ts.hbs +0 -56
- package/templates/create/hono/README.md.hbs +0 -43
- package/templates/create/hono/deno.json.hbs +0 -5
- package/templates/create/hono/prisma/schema.prisma.hbs +0 -25
- package/templates/create/hono/prisma/seed.ts.hbs +0 -38
- package/templates/create/hono/prisma.compute.ts.hbs +0 -10
- package/templates/create/hono/prisma.config.ts.hbs +0 -15
- package/templates/create/hono/src/lib/prisma.ts.hbs +0 -56
- package/templates/create/nest/README.md.hbs +0 -43
- package/templates/create/nest/deno.json.hbs +0 -5
- package/templates/create/nest/prisma/schema.prisma.hbs +0 -25
- package/templates/create/nest/prisma/seed.ts.hbs +0 -40
- package/templates/create/nest/prisma.compute.ts.hbs +0 -10
- package/templates/create/nest/prisma.config.ts.hbs +0 -15
- package/templates/create/nest/src/lib/prisma.ts.hbs +0 -58
- package/templates/create/next/README.md.hbs +0 -42
- package/templates/create/next/deno.json.hbs +0 -12
- package/templates/create/next/prisma/schema.prisma.hbs +0 -21
- package/templates/create/next/prisma/seed.ts.hbs +0 -38
- package/templates/create/next/prisma.compute.ts.hbs +0 -9
- package/templates/create/next/prisma.config.ts.hbs +0 -15
- package/templates/create/next/src/lib/prisma.ts.hbs +0 -56
- package/templates/create/nuxt/README.md.hbs +0 -44
- package/templates/create/nuxt/deno.json.hbs +0 -5
- package/templates/create/nuxt/prisma/schema.prisma.hbs +0 -21
- package/templates/create/nuxt/prisma/seed.ts.hbs +0 -38
- package/templates/create/nuxt/prisma.compute.ts.hbs +0 -9
- package/templates/create/nuxt/prisma.config.ts.hbs +0 -15
- package/templates/create/nuxt/server/utils/prisma.ts.hbs +0 -56
- package/templates/create/svelte/README.md.hbs +0 -45
- package/templates/create/svelte/deno.json.hbs +0 -5
- package/templates/create/svelte/prisma/schema.prisma.hbs +0 -21
- package/templates/create/svelte/prisma/seed.ts.hbs +0 -38
- package/templates/create/svelte/prisma.config.ts.hbs +0 -15
- package/templates/create/svelte/src/lib/server/prisma.ts.hbs +0 -53
- package/templates/create/tanstack-start/README.md.hbs +0 -43
- package/templates/create/tanstack-start/deno.json.hbs +0 -13
- package/templates/create/tanstack-start/prisma/schema.prisma.hbs +0 -21
- package/templates/create/tanstack-start/prisma/seed.ts.hbs +0 -38
- package/templates/create/tanstack-start/prisma.compute.ts.hbs +0 -9
- package/templates/create/tanstack-start/prisma.config.ts.hbs +0 -15
- package/templates/create/tanstack-start/src/lib/prisma.server.ts.hbs +0 -56
- package/templates/create/turborepo/README.md.hbs +0 -42
- package/templates/create/turborepo/apps/api/package.json.hbs +0 -26
- package/templates/create/turborepo/apps/api/src/index.ts.hbs +0 -55
- package/templates/create/turborepo/deno.json.hbs +0 -5
- package/templates/create/turborepo/package.json.hbs +0 -30
- package/templates/create/turborepo/packages/db/package.json.hbs +0 -22
- package/templates/create/turborepo/packages/db/prisma/schema.prisma.hbs +0 -21
- package/templates/create/turborepo/packages/db/prisma/seed.ts.hbs +0 -38
- package/templates/create/turborepo/packages/db/prisma.config.ts.hbs +0 -15
- package/templates/create/turborepo/packages/db/src/client.ts.hbs +0 -63
- package/templates/create/turborepo/packages/db/src/index.ts +0 -2
- package/templates/create/turborepo/packages/db/tsconfig.json +0 -15
- package/templates/create/turborepo/pnpm-workspace.yaml +0 -3
- package/templates/create/turborepo/prisma.compute.ts.hbs +0 -14
- package/templates/create/turborepo/turbo.json +0 -28
- /package/templates/create/{turborepo → elysia}/.yarnrc.yml.hbs +0 -0
- /package/templates/create/next/{next.config.ts.hbs → next.config.ts} +0 -0
|
@@ -1,63 +1,44 @@
|
|
|
1
1
|
import { createFileRoute } from "@tanstack/react-router";
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
-
{{#if (eq schemaPreset "basic")}}
|
|
4
|
-
import { prisma } from "../lib/prisma.server";
|
|
5
|
-
{{/if}}
|
|
6
3
|
|
|
7
|
-
{
|
|
8
|
-
function isBootstrapQueryError(error: unknown): error is { code?: string } {
|
|
9
|
-
return (
|
|
10
|
-
typeof error === "object" &&
|
|
11
|
-
error !== null &&
|
|
12
|
-
"code" in error &&
|
|
13
|
-
(error as { code?: string }).code === "P2021"
|
|
14
|
-
);
|
|
15
|
-
}
|
|
4
|
+
import { listUsers as listStarterUsers } from "../prisma/users";
|
|
16
5
|
|
|
17
6
|
const listUsers = createServerFn({ method: "GET" }).handler(async () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
createdAt:
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (isBootstrapQueryError(error)) {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
7
|
+
return listStarterUsers(10)
|
|
8
|
+
.then((rows) =>
|
|
9
|
+
rows.map((user) => ({
|
|
10
|
+
...user,
|
|
11
|
+
createdAt: user.createdAt?.toISOString() ?? null,
|
|
12
|
+
}))
|
|
13
|
+
)
|
|
14
|
+
.catch(() => undefined);
|
|
32
15
|
});
|
|
33
|
-
{{/if}}
|
|
34
16
|
|
|
35
17
|
export const Route = createFileRoute("/")({
|
|
36
|
-
|
|
18
|
+
|
|
37
19
|
loader: async () => listUsers(),
|
|
38
|
-
|
|
20
|
+
|
|
39
21
|
component: Home,
|
|
40
22
|
});
|
|
41
23
|
|
|
42
24
|
function Home() {
|
|
43
|
-
|
|
25
|
+
|
|
44
26
|
const formatter = new Intl.DateTimeFormat("en", {
|
|
45
27
|
dateStyle: "medium",
|
|
46
28
|
timeStyle: "short",
|
|
47
29
|
timeZone: "UTC",
|
|
48
30
|
});
|
|
49
31
|
const users = Route.useLoaderData();
|
|
50
|
-
{{/if}}
|
|
51
32
|
|
|
52
33
|
return (
|
|
53
34
|
<main className="shell">
|
|
54
35
|
<div className="hero">
|
|
55
|
-
<p className="eyebrow">TanStack Start + Prisma
|
|
56
|
-
|
|
36
|
+
<p className="eyebrow">TanStack Start + Prisma 8</p>
|
|
37
|
+
|
|
57
38
|
<h1>Users from your database, loaded through a server function.</h1>
|
|
58
39
|
<p className="lede">
|
|
59
|
-
This route uses TanStack Start's server function API and the Prisma
|
|
60
|
-
<code>src/
|
|
40
|
+
This route uses TanStack Start's server function API and the Prisma 8 helper in{" "}
|
|
41
|
+
<code>src/prisma/users.ts</code>.
|
|
61
42
|
</p>
|
|
62
43
|
</div>
|
|
63
44
|
|
|
@@ -69,63 +50,31 @@ function Home() {
|
|
|
69
50
|
|
|
70
51
|
{!users ? (
|
|
71
52
|
<p className="empty">
|
|
72
|
-
Could not query users yet. Run <code>
|
|
53
|
+
Could not query users yet. Run <code>contract:emit</code> and apply your schema,
|
|
73
54
|
then refresh.
|
|
74
55
|
</p>
|
|
75
56
|
) : users.length === 0 ? (
|
|
76
|
-
<p className="empty">No users
|
|
57
|
+
<p className="empty">No users found.</p>
|
|
77
58
|
) : (
|
|
78
59
|
<ul className="users">
|
|
79
60
|
{users.map((user) => (
|
|
80
61
|
<li key={user.id}>
|
|
81
62
|
<div>
|
|
82
63
|
<strong>{user.name ?? "Unnamed user"}</strong>
|
|
83
|
-
<p>{user.email}</p>
|
|
64
|
+
<p>{user.username ? `@${user.username}` : user.email}</p>
|
|
84
65
|
</div>
|
|
85
|
-
|
|
86
|
-
{
|
|
87
|
-
|
|
66
|
+
{user.createdAt ? (
|
|
67
|
+
<time dateTime={user.createdAt}>
|
|
68
|
+
{formatter.format(new Date(user.createdAt))}
|
|
69
|
+
</time>
|
|
70
|
+
) : (
|
|
71
|
+
<span className="empty">No timestamp</span>
|
|
72
|
+
)}
|
|
88
73
|
</li>
|
|
89
74
|
))}
|
|
90
75
|
</ul>
|
|
91
76
|
)}
|
|
92
77
|
</section>
|
|
93
|
-
{{else}}
|
|
94
|
-
<h1>Your TanStack Start app is ready.</h1>
|
|
95
|
-
<p className="lede">
|
|
96
|
-
Edit <code>prisma/schema.prisma</code>, run <code>db:migrate</code>, then query your
|
|
97
|
-
database from server functions or route loaders.
|
|
98
|
-
</p>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
<section className="panel">
|
|
102
|
-
<div className="panelHeader">
|
|
103
|
-
<h2>What's included</h2>
|
|
104
|
-
<span>Starter kit</span>
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
<ul className="users">
|
|
108
|
-
<li>
|
|
109
|
-
<div>
|
|
110
|
-
<strong>File-based routing</strong>
|
|
111
|
-
<p>Add new routes in <code>src/routes</code>.</p>
|
|
112
|
-
</div>
|
|
113
|
-
</li>
|
|
114
|
-
<li>
|
|
115
|
-
<div>
|
|
116
|
-
<strong>Prisma client</strong>
|
|
117
|
-
<p>Use the shared instance from <code>src/lib/prisma.server.ts</code>.</p>
|
|
118
|
-
</div>
|
|
119
|
-
</li>
|
|
120
|
-
<li>
|
|
121
|
-
<div>
|
|
122
|
-
<strong>Seed script</strong>
|
|
123
|
-
<p>Run <code>db:seed</code> after your first migration.</p>
|
|
124
|
-
</div>
|
|
125
|
-
</li>
|
|
126
|
-
</ul>
|
|
127
|
-
</section>
|
|
128
|
-
{{/if}}
|
|
129
78
|
|
|
130
79
|
<section className="panel">
|
|
131
80
|
<div className="panelHeader">
|
|
@@ -133,7 +82,7 @@ function Home() {
|
|
|
133
82
|
</div>
|
|
134
83
|
|
|
135
84
|
<ul className="steps">
|
|
136
|
-
<li>Run <code>
|
|
85
|
+
<li>Run <code>contract:emit</code> after contract changes.</li>
|
|
137
86
|
<li>Use TanStack Start server functions for server-only logic.</li>
|
|
138
87
|
<li>Preview production output with <code>preview</code>.</li>
|
|
139
88
|
</ul>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"jsx": "react-jsx",
|
|
5
5
|
"module": "ESNext",
|
|
6
6
|
"moduleResolution": "Bundler",
|
|
7
|
+
"resolveJsonModule": true,
|
|
7
8
|
"allowImportingTsExtensions": true,
|
|
8
9
|
"strict": true,
|
|
9
10
|
"noEmit": true,
|
|
@@ -11,11 +12,12 @@
|
|
|
11
12
|
"noUnusedLocals": true,
|
|
12
13
|
"noUnusedParameters": true,
|
|
13
14
|
"noFallthroughCasesInSwitch": true,
|
|
15
|
+
"baseUrl": ".",
|
|
14
16
|
"paths": {
|
|
15
17
|
"@/*": ["./src/*"]
|
|
16
18
|
},
|
|
17
19
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
18
|
-
"types": ["vite/client"]
|
|
20
|
+
"types": ["vite/client", "node"]
|
|
19
21
|
},
|
|
20
|
-
"include": ["src/**/*.ts", "src/**/*.tsx", "
|
|
22
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "vite.config.ts"]
|
|
21
23
|
}
|
|
@@ -2,15 +2,13 @@ import { defineConfig } from "vite";
|
|
|
2
2
|
import viteReact from "@vitejs/plugin-react";
|
|
3
3
|
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
4
4
|
import { nitro } from "nitro/vite";
|
|
5
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
5
6
|
|
|
6
7
|
export default defineConfig({
|
|
7
|
-
resolve: {
|
|
8
|
-
tsconfigPaths: true,
|
|
9
|
-
},
|
|
10
8
|
plugins: [
|
|
9
|
+
tsconfigPaths({ projects: ["./tsconfig.json"] }),
|
|
11
10
|
tanstackStart(),
|
|
12
11
|
nitro(),
|
|
13
|
-
// react's vite plugin must come after start's vite plugin
|
|
14
12
|
viteReact(),
|
|
15
13
|
],
|
|
16
14
|
});
|