create-lx2-app 0.11.5-beta.f8c5ccc → 0.12.1-beta.4f7512c
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/dist/index.js +28 -26
- package/package.json +3 -1
- package/template/packages/src/app/api/trpc/[trpc]/route.ts +34 -0
- package/template/packages/src/app/layout/with-trpc.tsx +37 -0
- package/template/packages/src/app/page/with-authjs-prisma.tsx +4 -0
- package/template/packages/src/app/page/with-better-auth-prisma.tsx +4 -0
- package/template/packages/src/app/page/with-prisma.tsx +4 -0
- package/template/packages/src/app/page/with-trpc.tsx +115 -0
- package/template/packages/src/components/greeting.tsx +21 -0
- package/template/packages/src/env/with-better-auth-db.js +2 -2
- package/template/packages/src/env/with-better-auth.js +2 -2
- package/template/packages/src/env/with-trpc-authjs-db.js +55 -0
- package/template/packages/src/env/with-trpc-authjs.js +53 -0
- package/template/packages/src/env/with-trpc-better-auth-db.js +52 -0
- package/template/packages/src/env/with-trpc-better-auth.js +50 -0
- package/template/packages/src/env/with-trpc-db.js +46 -0
- package/template/packages/src/env/with-trpc.js +44 -0
- package/template/packages/src/lib/api/client.tsx +85 -0
- package/template/packages/src/lib/api/query-client.ts +22 -0
- package/template/packages/src/lib/api/server.ts +31 -0
- package/template/packages/src/lib/auth/better-auth-client.ts +1 -1
- package/template/packages/src/lib/utils.ts +7 -0
- package/template/packages/src/server/api/init/base.ts +103 -0
- package/template/packages/src/server/api/init/with-authjs-db.ts +132 -0
- package/template/packages/src/server/api/init/with-authjs.ts +130 -0
- package/template/packages/src/server/api/init/with-betterauth-db.ts +134 -0
- package/template/packages/src/server/api/init/with-betterauth.ts +132 -0
- package/template/packages/src/server/api/init/with-db.ts +106 -0
- package/template/packages/src/server/api/root.ts +23 -0
- package/template/packages/src/server/api/routers/post/base.ts +46 -0
- package/template/packages/src/server/api/routers/post/with-auth-drizzle.ts +44 -0
- package/template/packages/src/server/api/routers/post/with-auth-prisma.ts +47 -0
- package/template/packages/src/server/api/routers/post/with-auth.ts +43 -0
- package/template/packages/src/server/api/routers/post/with-drizzle.ts +36 -0
- package/template/packages/src/server/api/routers/post/with-prisma.ts +37 -0
- package/template/packages/src/server/auth/better-auth-with-drizzle.ts +1 -1
- package/template/packages/src/server/auth/better-auth-with-prisma.ts +1 -1
- package/template/packages/src/server/auth/better-auth.ts +1 -0
- package/template/packages/src/server/auth/config/authjs-with-drizzle.ts +1 -1
- package/template/packages/src/server/auth/config/authjs-with-prisma.ts +1 -1
- package/template/packages/src/server/auth/config/authjs.ts +1 -1
- package/template/packages/src/server/db/schema-drizzle/with-authjs-mysql.ts +1 -1
- package/template/packages/src/server/db/schema-drizzle/with-authjs-postgresql.ts +1 -1
- package/template/packages/src/server/db/schema-drizzle/with-authjs-sqlite.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import ft from"path";import{execa as Vt}from"execa";import ut from"fs-extra";import ke from"path";import{fileURLToPath as gt}from"url";var ht=gt(import.meta.url),yt=ke.dirname(ht),d=ke.join(yt,"../"),xe=` ___ ___ ___ _ _____ ___ _ ___ _ ___ ___
|
|
3
3
|
/ __| _ \\ __| /_\\_ _| __| | | __ __|_ ) /_\\ | _ \\ _ \\
|
|
4
4
|
| (__| / _| / _ \\| | | _| | |__\\ \\ / / / / _ \\| _/ _/
|
|
5
5
|
\\___|_|_\\___/_/ \\_\\_| |___| |____/_\\_\\/___| /_/ \\_\\_| |_|
|
|
6
|
-
`,
|
|
6
|
+
`,L="my-lx2-app",oe="create-lx2-app",R=[{packages:["payload"],message:"Our Payload CMS integration does not yet support other packages."},{packages:["trpc","payload"]}];import{confirm as Q,input as Ne,select as U}from"@inquirer/prompts";import{Command as Ct}from"commander";var v=()=>{let e=process.env.npm_config_user_agent;return e?e.startsWith("yarn")?"yarn":e.startsWith("pnpm")?"pnpm":e.startsWith("bun")?"bun":"npm":"npm"};import I from"path";import re from"fs-extra";var Pe={"next-auth":"^5.0.0-beta.25","@auth/prisma-adapter":"^2.11.1","@auth/drizzle-adapter":"^1.11.1","better-auth":"^1.4.6","better-sqlite3":"^12.5.0","@types/better-sqlite3":"^7.6.13",prisma:"^7.1.0","@prisma/client":"^7.1.0","@prisma/client-runtime-utils":"^7.2.0","@prisma/adapter-better-sqlite3":"^7.2.0","@prisma/adapter-libsql":"^7.2.0","@prisma/adapter-mariadb":"^7.2.0","@prisma/adapter-pg":"^7.2.0","drizzle-orm":"^0.45.0","drizzle-kit":"^0.31.8","@libsql/client":"^0.15.15",mysql2:"^3.15.3",postgres:"^3.4.7","@trpc/server":"^11.7.2","@trpc/client":"^11.7.2","@trpc/react-query":"^11.7.2","@tanstack/react-query":"^5.90.10","server-only":"^0.0.1",superjson:"^2.2.5","@t3-oss/env-nextjs":"^0.13.8",zod:"^4.1.13",prettier:"^3.7.4","prettier-plugin-tailwindcss":"^0.7.2","@ianvs/prettier-plugin-sort-imports":"^4.7.0",eslint:"^9.39.1","eslint-config-next":"^16.0.8","@eslint/eslintrc":"^3.3.3","@biomejs/biome":"^2.3.8",typescript:"^5.9.3","@types/node":"^24.10.2","@types/react":"^19.2.7","@types/react-dom":"^19.2.3",payload:"^3.67.0","@payloadcms/next":"^3.67.0","@payloadcms/payload-cloud":"^3.67.0","@payloadcms/richtext-lexical":"^3.67.0","@payloadcms/db-vercel-postgres":"^3.67.0","@payloadcms/db-sqlite":"^3.67.0",graphql:"^16.12.0",sharp:"^0.34.5"};import Se from"path";import _e from"fs-extra";import bt from"sort-package-json";var u=e=>{let{dependencies:t,devMode:n,projectDir:s}=e,i=_e.readJsonSync(Se.join(s,"package.json"));t.forEach(o=>{let r=Pe[o];n&&i.devDependencies?i.devDependencies[o]=r:i.dependencies&&(i.dependencies[o]=r)});let a=bt(i);_e.writeJsonSync(Se.join(s,"package.json"),a,{spaces:2})};var je=({projectDir:e,packages:t})=>{let n=t?.prisma.inUse,s=t?.drizzle.inUse,i=["next-auth"];n&&i.push("@auth/prisma-adapter"),s&&i.push("@auth/drizzle-adapter"),u({projectDir:e,dependencies:i,devMode:!1});let a=I.join(d,"template/packages"),o="src/app/api/auth/[...nextauth]/route.ts",r=I.join(a,o),l=I.join(e,o),f=I.join(a,"src/server/auth/config",n?"authjs-with-prisma.ts":s?"authjs-with-drizzle.ts":"authjs.ts"),g=I.join(e,"src/server/auth/config.ts"),p=I.join(a,"src/server/auth/authjs.ts"),m=I.join(e,"src/server/auth/index.ts");re.copySync(r,l),re.copySync(f,g),re.copySync(p,m)};import _ from"path";import F from"fs-extra";import vt from"path";import Ae from"fs-extra";import{sortPackageJson as wt}from"sort-package-json";function w(e){let{scripts:t,projectDir:n}=e,s=vt.join(n,"package.json"),i=Ae.readJSONSync(s);i.scripts={...i.scripts,...t};let a=wt(i);Ae.writeJSONSync(s,a,{spaces:2})}var Ie=({projectDir:e,packages:t,databaseProvider:n})=>{let s=t?.prisma.inUse,i=t?.drizzle.inUse,a=s||i,o=["better-auth"],r=[];a||o.push("better-sqlite3"),a||r.push("@types/better-sqlite3"),u({projectDir:e,dependencies:o,devMode:!1}),u({projectDir:e,dependencies:r,devMode:!0});let l=_.join(d,"template/packages"),f=_.join(l,"src/app/api/auth/[...betterauth]/route.ts"),g=_.join(e,"src/app/api/auth/[...all]/route.ts"),p=_.join(l,"src/server/auth",s?"better-auth-with-prisma.ts":i?"better-auth-with-drizzle.ts":"better-auth.ts"),m=F.readFileSync(p,"utf-8");(s||i)&&n!=="sqlite"&&(m=m.replace('provider: "sqlite",',`provider: "${{mysql:"mysql",postgresql:i?"pg":"postgresql"}[n]}",`));let b=_.join(e,"src/server/auth/index.ts");F.mkdirSync(_.dirname(b),{recursive:!0}),F.writeFileSync(b,m);let x=_.join(l,"src/lib/auth/better-auth-client.ts"),D=_.join(e,"src/lib/auth/client.ts");w({projectDir:e,scripts:{"auth:generate":"npx @better-auth/cli@latest generate --config ./src/server/auth/index.ts --yes",...!s&&!i&&{"auth:migrate":"npx @better-auth/cli@latest migrate --config ./src/server/auth/index.ts --yes"}}}),F.copySync(f,g),F.copySync(x,D)};import le from"path";import kt from"fs-extra";var Ce=({projectDir:e})=>{u({projectDir:e,dependencies:["@biomejs/biome"],devMode:!0});let t=le.join(d,"template/packages"),n=le.join(t,"config/biome.jsonc"),s=le.join(e,"biome.jsonc");kt.copyFileSync(n,s),w({projectDir:e,scripts:{"lint:unsafe":"biome check --write --unsafe .","lint:write":"biome check --write .",lint:"biome check .",format:"biome format --write ."}})};import j from"path";import C from"fs-extra";var ze=({projectDir:e,packages:t,scopedAppName:n,databaseProvider:s})=>{let i=t?.authjs.inUse,a=t?.betterAuth.inUse;u({projectDir:e,dependencies:["drizzle-kit"],devMode:!0}),u({projectDir:e,dependencies:["drizzle-orm",{sqlite:"@libsql/client",mysql:"mysql2",postgresql:"postgres"}[s]],devMode:!1});let o=j.join(d,"template/packages"),r=j.join(o,"config/drizzle",{sqlite:"with-sqlite",mysql:"with-mysql",postgresql:"with-postgresql"}[s]+".ts"),l=j.join(e,"drizzle.config.ts"),f=j.join(o,"src/server/db/schema-drizzle",i?`with-authjs-${s}.ts`:a?`with-better-auth-${s}.ts`:`base-${s}.ts`),g=j.join(e,"src/server/db/schema.ts"),p=C.readFileSync(f,"utf-8");p=p.replace("project1_${name}",`${n}_\${name}`);let m=C.readFileSync(r,"utf-8");m=m.replace("project1_*",`${n}_*`);let b=j.join(o,`src/server/db/index-drizzle/with-${s}.ts`),x=j.join(e,"src/server/db/index.ts");w({projectDir:e,scripts:{"db:generate":"drizzle-kit generate","db:migrate":"drizzle-kit migrate","db:push":"drizzle-kit push","db:studio":"drizzle-kit studio"}}),C.copySync(r,l),C.mkdirSync(j.dirname(g),{recursive:!0}),C.writeFileSync(g,p),C.writeFileSync(l,m),C.copySync(b,x)};import V from"path";import ce from"fs-extra";var De=({projectDir:e,scopedAppName:t,packages:n,databaseProvider:s})=>{let i=n?.envVariables.inUse,a=n?.authjs.inUse,o=n?.betterAuth.inUse,r=n?.trpc.inUse,l=n?.prisma.inUse,f=n?.drizzle.inUse,g=n?.payload.inUse,p=[];i&&(p.push("@t3-oss/env-nextjs"),p.push("zod")),u({projectDir:e,dependencies:p,devMode:!1});let m=l||f,b=xt(!!a,!!o,!!r,!!l,!!f,!!g,t,s),D=[{condition:m&&r&&o,file:"with-trpc-better-auth-db.js"},{condition:m&&r&&a,file:"with-trpc-authjs-db.js"},{condition:m&&r,file:"with-trpc-db.js"},{condition:m&&a,file:"with-authjs-db.js"},{condition:m&&o,file:"with-better-auth-db.js"},{condition:r&&a,file:"with-trpc-authjs.js"},{condition:r&&o,file:"with-trpc-better-auth.js"},{condition:g,file:"with-payload.js"},{condition:m,file:"with-db.js"},{condition:r,file:"with-trpc.js"},{condition:a,file:"with-authjs.js"},{condition:o,file:"with-better-auth.js"}].find(q=>q.condition)?.file||"";if(D!==""){let q=V.join(d,"template/packages/src/env",D),J=V.join(e,"src/env.ts");ce.copyFileSync(q,J)}let ee=V.join(e,".env"),te=V.join(e,".env.example"),ie=Pt+b,E=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("base64"),se=b.replace('AUTH_SECRET=""',`AUTH_SECRET="${E}" # Generated by create-lx2-app`).replace('BETTER_AUTH_SECRET=""',`BETTER_AUTH_SECRET="${E}" # Generated by create-lx2-app`).replace('PAYLOAD_SECRET=""',`PAYLOAD_SECRET="${E}" # Generated by create-lx2-app`);ce.writeFileSync(ee,se,"utf-8"),ce.writeFileSync(te,ie,"utf-8")};function xt(e,t,n,s,i,a,o,r){let l=`
|
|
7
7
|
# When adding additional environment variables, the schema in "/src/env.ts"
|
|
8
8
|
# should be updated accordingly.
|
|
9
9
|
`.trim().concat(`
|
|
10
|
-
`);return
|
|
10
|
+
`);return s&&(l+=`
|
|
11
11
|
# Prisma
|
|
12
12
|
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
|
|
13
|
-
`),i&&(
|
|
13
|
+
`),i&&(l+=`
|
|
14
14
|
# Drizzle ORM
|
|
15
15
|
# https://orm.drizzle.team/docs/connect-overview
|
|
16
|
-
`),(
|
|
17
|
-
`),
|
|
16
|
+
`),(s||i)&&(r==="mysql"?l+=`DATABASE_URL="mysql://root:password@localhost:3306/${o}"`:r==="postgresql"?l+=`DATABASE_URL="postgresql://postgres:password@localhost:5432/${o}"`:r==="sqlite"&&(l+='DATABASE_URL="file:./db.sqlite"'),l+=`
|
|
17
|
+
`),a&&(l+=`
|
|
18
18
|
# Payload CMS
|
|
19
19
|
# https://payloadcms.com/docs/database/overview
|
|
20
|
-
`,
|
|
21
|
-
`,
|
|
22
|
-
`),e&&(
|
|
20
|
+
`,l+=`PAYLOAD_SECRET=""
|
|
21
|
+
`,r==="postgresql"?l+=`DATABASE_URL="postgresql://postgres:password@localhost:5432/${o}"`:r==="sqlite"&&(l+='DATABASE_URL="file:./db.sqlite"'),l+=`
|
|
22
|
+
`),e&&(l+=`
|
|
23
23
|
# Next Auth
|
|
24
24
|
# You can generate a new secret on the command line with:
|
|
25
25
|
# npx auth secret
|
|
@@ -29,21 +29,23 @@ AUTH_SECRET=""
|
|
|
29
29
|
# Next Auth Discord Provider
|
|
30
30
|
DISCORD_CLIENT_ID=""
|
|
31
31
|
DISCORD_CLIENT_SECRET=""
|
|
32
|
-
`),
|
|
32
|
+
`),t&&(l+=`
|
|
33
33
|
# Better Auth
|
|
34
34
|
# You can generate a new secret by going to the Better Auth docs:
|
|
35
35
|
# https://www.better-auth.com/docs/installation#set-environment-variables
|
|
36
36
|
BETTER_AUTH_SECRET=""
|
|
37
|
-
|
|
37
|
+
NEXT_PUBLIC_URL="http://localhost:3000" # Base URL of your app
|
|
38
38
|
|
|
39
39
|
# Better Auth Discord Provider
|
|
40
40
|
DISCORD_CLIENT_ID=""
|
|
41
41
|
DISCORD_CLIENT_SECRET=""
|
|
42
|
-
`),!e&&!a
|
|
42
|
+
`),!e&&!s&&!a&&(l+=`
|
|
43
43
|
# Example:
|
|
44
44
|
# SERVERVAR="foo"
|
|
45
45
|
# NEXT_PUBLIC_CLIENTVAR="bar"
|
|
46
|
-
`),
|
|
46
|
+
`),n&&(l+=`
|
|
47
|
+
NEXT_PUBLIC_URL="http://localhost:3000"
|
|
48
|
+
`),l}var Pt=`
|
|
47
49
|
# Since the ".env" file is gitignored, you can use the ".env.example" file to
|
|
48
50
|
# build a new ".env" file when you clone the repo. Keep this file up-to-date
|
|
49
51
|
# when you add new variables to \`.env\`.
|
|
@@ -53,19 +55,19 @@ DISCORD_CLIENT_SECRET=""
|
|
|
53
55
|
# ".env" and populate it with your secrets.
|
|
54
56
|
`.trim().concat(`
|
|
55
57
|
|
|
56
|
-
`);import
|
|
58
|
+
`);import H from"path";import Re from"fs-extra";var Te=({projectDir:e,packages:t})=>{let n=t?.["eslint/prettier"].inUse,s=[];n&&(s.push("eslint"),s.push("eslint-config-next"),s.push("@eslint/eslintrc"),s.push("prettier"),s.push("prettier-plugin-tailwindcss"),s.push("@ianvs/prettier-plugin-sort-imports")),u({projectDir:e,dependencies:s,devMode:!0});let i=H.join(d,"template/packages/config","eslint.config.mjs"),a=H.join(d,"template/packages/config","prettier.config.mjs"),o=H.join(e,"eslint.config.mjs"),r=H.join(e,"prettier.config.mjs");w({projectDir:e,scripts:{"lint:write":"eslint --fix",lint:"eslint",format:"prettier --write ."}}),Re.copyFileSync(i,o),Re.copyFileSync(a,r)};import k from"path";import T from"fs-extra";var Oe=({projectDir:e,packages:t,databaseProvider:n})=>{let s=[],i=[];if(t?.payload.inUse)switch(s.push("payload"),s.push("@payloadcms/next"),s.push("@payloadcms/payload-cloud"),s.push("@payloadcms/richtext-lexical"),s.push("graphql"),n){case"sqlite":i.push("@payloadcms/db-sqlite");break;case"postgresql":i.push("@payloadcms/db-vercel-postgres");break}u({projectDir:e,dependencies:s,devMode:!1}),u({projectDir:e,dependencies:i,devMode:!1});let a=k.join(d,"template/packages"),o=k.join(a,"config/payload",`${n==="postgresql"?"with-postgres":"with-sqlite"}.ts`),r=k.join(e,"payload.config.ts");T.copyFileSync(o,r);let l=k.join(a,"src/payload/collections"),f=k.join(e,"src/collections");T.mkdirSync(f,{recursive:!0}),T.copyFileSync(k.join(l,"Media.ts"),k.join(f,"Media.ts")),T.copyFileSync(k.join(l,"Users.ts"),k.join(f,"Users.ts"));let g=k.join(a,"src/app/(payload)"),p=k.join(e,"src/app/(payload)");T.mkdirSync(p,{recursive:!0}),T.copySync(g,p),w({projectDir:e,scripts:{payload:"payload","generate:importmap":"payload generate:importmap","generate:types":"payload generate:types"}})};import P from"path";import A from"fs-extra";var Ue=({projectDir:e,packages:t,databaseProvider:n,pkgManager:s})=>{let i=t?.authjs.inUse,a=t?.betterAuth.inUse;u({projectDir:e,dependencies:["prisma"],devMode:!0});let o={sqlite:s==="bun"?"@prisma/adapter-libsql":"@prisma/adapter-better-sqlite3",mysql:"@prisma/adapter-mariadb",postgresql:"@prisma/adapter-pg"}[n];u({projectDir:e,dependencies:["@prisma/client",o],devMode:!1}),n==="sqlite"&&s!=="bun"&&u({projectDir:e,dependencies:["@types/better-sqlite3"],devMode:!0}),s==="pnpm"&&u({projectDir:e,dependencies:["@prisma/client-runtime-utils"],devMode:!1});let r=P.join(d,"template/packages"),l=P.join(r,"config/prisma.config.ts"),f=P.join(e,"prisma.config.ts");A.writeFileSync(f,A.readFileSync(l,"utf-8"));let g=P.join(r,"prisma/schema",`${i?"with-authjs":a?"with-better-auth":"base"}.prisma`),p=A.readFileSync(g,"utf-8");n!=="sqlite"&&(p=p.replace('provider = "sqlite"',`provider = "${{mysql:"mysql",postgresql:"postgresql"}[n]}"`),["mysql"].includes(n)&&(p=p.replace("// @db.Text","@db.Text")));let m=P.join(e,"prisma/schema.prisma");A.mkdirSync(P.dirname(m),{recursive:!0}),A.writeFileSync(m,p);let b=P.join(r,`src/server/db/prisma/with-${n}${s==="bun"?"-bun":""}.ts`),x=P.join(e,"src/server/db/index.ts");A.mkdirSync(P.dirname(x),{recursive:!0}),A.writeFileSync(x,A.readFileSync(b,"utf-8")),w({projectDir:e,scripts:{postinstall:"prisma generate","db:push":"prisma db push","db:studio":"prisma studio","db:generate":"prisma migrate dev","db:migrate":"prisma migrate deploy"}})};import h from"path";import St from"fs-extra";var Ee=({projectDir:e,packages:t})=>{let n=t?.authjs.inUse,s=t?.betterAuth.inUse,i=t?.prisma.inUse,a=t?.drizzle.inUse,o=i||a;u({projectDir:e,dependencies:["@trpc/server","@trpc/client","@trpc/react-query","@tanstack/react-query","server-only","superjson"],devMode:!1});let r=h.join(d,"template/packages"),l="src/app/api/trpc/[trpc]/route.ts",f=h.join(r,l),g=h.join(e,l),p=n&&o?"with-authjs-db.ts":n?"with-authjs.ts":s&&o?"with-betterauth-db.ts":s?"with-betterauth.ts":o?"with-db.ts":"base.ts",m=h.join(r,"src/server/api/init",p),b=h.join(e,"src/server/api/init.ts"),x=h.join(r,"src/server/api/root.ts"),D=h.join(e,"src/server/api/root.ts");function ee({usingAuthjs:M,usingBetterAuth:$,usingPrisma:ve,usingDrizzle:we}){return(M||$)&&ve?"with-auth-prisma.ts":(M||$)&&we?"with-auth-drizzle.ts":M||$?"with-auth.ts":ve?"with-prisma.ts":we?"with-drizzle.ts":"base.ts"}let te=ee({usingAuthjs:n,usingBetterAuth:s,usingPrisma:i,usingDrizzle:a}),ie=h.join(r,"src/server/api/routers/post",te),E=h.join(e,"src/server/api/routers/post.ts"),se=h.join(r,"src/lib/utils.ts"),q=h.join(e,"src/lib/utils.ts"),J=[[f,g],[m,b],[x,D],[ie,E],[se,q]],ne=h.join(r,"src/lib/api"),ae=h.join(e,"src/lib/api");J.push([h.join(ne,"client.tsx"),h.join(ae,"client.tsx")],[h.join(ne,"query-client.ts"),h.join(ae,"query-client.ts")],[h.join(ne,"server.ts"),h.join(ae,"server.ts")],[h.join(r,"src/components/greeting.tsx"),h.join(e,"src/components/greeting.tsx")]),J.forEach(([M,$])=>{St.copySync(M,$)})};import qe from"path";import _t from"fs-extra";var Me=({projectDir:e,packages:t})=>{let n=t?.typescript.inUse,s=t?.payload.inUse,i=[];n&&(i.push("typescript"),i.push("@types/node"),i.push("@types/react"),i.push("@types/react-dom")),u({projectDir:e,dependencies:i,devMode:!0});let a=qe.join(d,"template/packages/config/tsconfig",`${s?"with-payload":"base"}.json`),o=qe.join(e,"tsconfig.json");_t.copyFileSync(a,o)};var $e=["nextjs","payload"],pe=["none","authjs","betterAuth"],de=["none","prisma","drizzle"],K=["sqlite","mysql","postgresql"];var Le=e=>({authjs:{inUse:e.includes("authjs"),installer:je},betterAuth:{inUse:e.includes("betterAuth"),installer:Ie},trpc:{inUse:e.includes("trpc"),installer:Ee},prisma:{inUse:e.includes("prisma"),installer:Ue},drizzle:{inUse:e.includes("drizzle"),installer:ze},envVariables:{inUse:!0,installer:De},"eslint/prettier":{inUse:e.includes("eslint/prettier"),installer:Te},biome:{inUse:e.includes("biome"),installer:Ce},typescript:{inUse:!0,installer:Me},payload:{inUse:e.includes("payload"),installer:Oe}});import jt from"path";import At from"fs-extra";function O(){let e=jt.join(d,"package.json");return At.readJSONSync(e).version??"1.0.0"}var B=class extends Error{constructor(t){super(t)}};import Y from"chalk";var c={error(...e){console.log(Y.red(...e))},warn(...e){console.log(Y.yellow(...e))},info(...e){console.log(Y.cyan(...e))},success(...e){console.log(Y.green(...e))}};var X=e=>(e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e);var It=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;function Fe(e){let t=X(e),n=t.split("/"),s=n.findIndex(a=>a.startsWith("@")),i=n[n.length-1];return n.findIndex(a=>a.startsWith("@"))!==-1&&(i=n.slice(s).join("/")),t=="."||It.test(i??"")?!0:"App name must consist of only lowercase alphanumeric characters, '-', and '_'"}var Be=e=>e.startsWith(".")||e.startsWith("/")?"Import alias can't start with '.' or '/'":!0;var y={appName:L,packages:[],flags:{git:!1,install:!1,default:!1,CI:!1,trpc:!1,authentication:"none",orm:"none",linter:"eslint/prettier",importAlias:"@/",dbProvider:"sqlite",backend:"nextjs"},databaseProvider:"sqlite"};async function Ge(){let e=y,t=new Ct().name(oe).description("CLI for scaffolding new web apps with the Lx2 stack").version(O(),"-v, --version","Output the current version of Create Lx2 App").argument("[dir]","The name of the application, as well as the name of the directory to create").option("--git","Boolean flag to explicitly tell the CLI to initialize a new git repo in the project",!1).option("--install","Boolean flag to explicitly tell the CLI to run the package manager's install command",!1).option("-y, --default","Bypass the CLI and use all default options to bootstrap a new lx2-app",!1).option("--CI","Boolean value if we're running in CI",!1).option("--backend [framework]",`Choose a backend framework to use. Possible values: ${$e.join(", ")}`,y.flags.backend).option("--trpc [boolean]","Boolean flag to explicitly tell the CLI to set up tRPC in the project",s=>!!s&&s!=="false").option("--authProvider [provider]",`Choose an authentication provider to use. Possible values: ${pe.join(", ")}`,y.flags.authentication).option("--databaseORM [orm]",`Choose a database ORM to use. Possible values: ${de.join(", ")}`,y.flags.orm).option("--linter [linter]",`Choose what linter and formatter to use. Possible values: ${y.flags.linter}`,y.flags.linter).option("-i, --import-alias [alias]","Explicitly tell the CLI to use a custom import alias",y.flags.importAlias).option("--dbProvider [provider]",`Choose a database provider to use. Possible values: ${K.join(", ")}`,y.flags.dbProvider).parse(process.argv);process.env.npm_config_user_agent?.startsWith("yarn/3")&&c.warn(` WARNING: It looks like you are using Yarn 3. This is currently not supported,
|
|
57
59
|
and likely to result in a crash. Please run create-lx2-app with another
|
|
58
60
|
package manager such as pnpm, npm, or Yarn Classic.
|
|
59
|
-
See: https://github.com/t3-oss/create-t3-app/issues/57`);let
|
|
61
|
+
See: https://github.com/t3-oss/create-t3-app/issues/57`);let n=t.args[0];if(n&&(e.appName=n),e.flags=t.opts(),e.flags.CI){switch(e.packages=[],e.flags.backend==="payload"&&e.packages.push("payload"),e.flags.trpc&&e.packages.push("trpc"),e.flags.authentication){case"authjs":e.packages.push("authjs");break;case"betterAuth":e.packages.push("betterAuth");break;default:break}switch(e.flags.orm){case"prisma":e.packages.push("prisma");break;case"drizzle":e.packages.push("drizzle");break;default:break}switch(e.flags.linter){case"eslint/prettier":e.packages.push("eslint/prettier");break;case"biome":e.packages.push("biome");break;default:break}return e.packages.includes("authjs")&&e.packages.includes("betterAuth")&&(c.warn(`Incompatible authentication providers provided. Use either ${pe.join(", or ")}. Exiting.`),process.exit(0)),e.packages.includes("prisma")&&e.packages.includes("drizzle")&&(c.warn(`Incompatible database ORMs provided. Use either ${de.join(", or ")}. Exiting.`),process.exit(0)),K.includes(e.flags.dbProvider)===!1&&(c.warn(`Incompatible database provided. Use either ${K.join(", or ")}. Exiting.`),process.exit(0)),e.flags.backend==="payload"&&e.flags.dbProvider==="mysql"&&(c.warn("Payload CMS does not support MySQL. Exiting."),process.exit(0)),e.packages.includes("eslint/prettier")&&e.packages.includes("biome")&&(c.warn(`Incompatible linters provided. Use either ${y.flags.linter}. Exiting.`),process.exit(0)),e.databaseProvider=e.packages.includes("prisma")||e.packages.includes("drizzle")?e.flags.dbProvider:"sqlite",e}if(e.flags.default)return e;try{if(process.env.TERM_PROGRAM?.toLowerCase().includes("mintty"))throw c.warn(` WARNING: It looks like you are using MinTTY, which is non-interactive. This is most likely because you are
|
|
60
62
|
using Git Bash. If that's that case, please use Git Bash from another terminal, such as Windows Terminal. Alternatively, you
|
|
61
|
-
can provide the arguments from the CLI directly: https://create.lx2.dev/docs/getting-started#experimental-ci-flags to skip the prompts.`),new
|
|
62
|
-
Using: ${
|
|
63
|
-
`);let
|
|
64
|
-
`).start();if(
|
|
65
|
-
`);else{
|
|
66
|
-
`),
|
|
67
|
-
`)}import
|
|
68
|
-
`).start(),
|
|
69
|
-
`)}catch{
|
|
70
|
-
`)}}import
|
|
71
|
-
`))};var
|
|
63
|
+
can provide the arguments from the CLI directly: https://create.lx2.dev/docs/getting-started#experimental-ci-flags to skip the prompts.`),new B("Non-interactive environment");let s=v(),i={};n||(i.name=await Ne({message:"What will your project be called?",default:L,validate:f=>Fe(f)})),i.backend=await U({message:"What backend framework would you like to use?",choices:[{value:"nextjs",name:"Next.js"},{value:"payload",name:"Payload CMS"}],default:y.flags.backend}),i.backend==="payload"&&(i.databaseProvider=await U({message:"What database provider would you like to use?",choices:[{value:"sqlite",name:"SQLite"},{value:"postgresql",name:"PostgreSQL"}],default:y.flags.dbProvider})),i.backend==="nextjs"&&(i.trpc=await Q({message:"Would you like to use tRPC?",default:!y.flags.trpc}),i.authentication=await U({message:"What authentication provider would you like to use?",choices:[{value:"none",name:"None"},{value:"authjs",name:"Auth.js"},{value:"betterAuth",name:"Better Auth"}],default:y.flags.authentication}),i.orm=await U({message:"What database ORM would you like to use?",choices:[{value:"none",name:"None"},{value:"prisma",name:"Prisma"},{value:"drizzle",name:"Drizzle"}],default:y.flags.orm}),i.orm!=="none"&&(i.databaseProvider=await U({message:"What database provider would you like to use?",choices:[{value:"sqlite",name:"SQLite"},{value:"mysql",name:"MySQL"},{value:"postgresql",name:"PostgreSQL"}],default:y.flags.dbProvider}))),i.linter=await U({message:"What linter and formatter would you like to use?",choices:[{value:"eslint/prettier",name:"ESLint/Prettier"},{value:"biome",name:"Biome"}],default:y.flags.linter}),e.flags.git||(i.git=await Q({message:"Should we initialize a Git repository and stage the changes?",default:!y.flags.git})),e.flags.install||(i.install=await Q({message:`Should we run '${s}`+(s==="yarn"?"'?":" install' for you?"),default:!y.flags.install})),i.importAlias=await Ne({message:"What import alias would you like to use?",default:y.flags.importAlias,validate:Be});let a=[];switch(i.backend==="payload"&&a.push("payload"),i.trpc&&a.push("trpc"),i.authentication){case"authjs":a.push("authjs");break;case"betterAuth":a.push("betterAuth");break;default:break}switch(i.orm){case"prisma":a.push("prisma");break;case"drizzle":a.push("drizzle");break;default:break}switch(i.linter){case"eslint/prettier":a.push("eslint/prettier");break;case"biome":a.push("biome");break;default:break}let o=[...e.packages||[],...a||[]],r=Array.from(new Set(o));if(r.includes("trpc")){let f=R.find(g=>g.packages.includes("trpc"));f&&r.filter(p=>f.packages.includes(p)&&p!=="trpc").length>0&&(c.warn("As of right now, Create Lx2 App only supports TRPC with certain combinations of packages. Exiting."),process.exit(0))}return{appName:i.name??e.appName,packages:a,flags:{...e.flags,git:i.git??e.flags.git,install:i.install??e.flags.install,importAlias:i.importAlias??e.flags.importAlias},databaseProvider:i.databaseProvider??"sqlite"}}catch(s){if(s instanceof B)c.warn(`${oe} needs an interactive terminal to run.`),await Q({message:"Continue scaffolding with default options?",default:!0})||(c.info("Exiting..."),process.exit(0)),c.info(`Scaffolding default lx2 app in ./${e.appName}`);else throw s}return e}import Ot from"path";import We from"chalk";import zt from"ora";function Je(e){let{packages:t}=e;c.info("Adding boilerplate...");for(let[n,s]of Object.entries(t))if(s.inUse){let i=zt(`Boilerplating ${n}...`).start();s.installer(e),i.succeed(We.green(`${We.green.bold(n)}`))}c.info("")}import me from"path";import{confirm as Dt,select as Rt}from"@inquirer/prompts";import z from"chalk";import N from"fs-extra";import Tt from"ora";async function Ve({projectName:e,projectDir:t,pkgManager:n,install:s}){let i=me.join(d,"template/base");s?c.info(""):c.info(`
|
|
64
|
+
Using: ${z.cyan.bold(n)}
|
|
65
|
+
`);let a=Tt(`Scaffolding in: ${t}...
|
|
66
|
+
`).start();if(N.existsSync(t))if(N.readdirSync(t).length===0)e!=="."&&a.info(`${z.cyan.bold(e)} exists but is empty, continuing...
|
|
67
|
+
`);else{a.stopAndPersist();let r=await Rt({message:`${z.redBright.bold("Warning:")} ${z.cyan.bold(e)} already exists and isn't empty. How would you like to proceed?`,choices:[{value:"abort",name:"Abort installation (recommended)"},{value:"clear",name:"Clear the directory and continue installation"},{value:"overwrite",name:"Continue installation and overwrite conflicting files"}],default:"abort"});r==="abort"&&(a.fail("Aborting installation..."),process.exit(1)),await Dt({message:`Are you sure you want to ${r==="clear"?"clear the directory":"overwrite conflicting files"}`,default:!1})||(a.fail("Aborting installation..."),process.exit(1)),r==="clear"&&(a.info(`Emptying ${z.cyan.bold(e)} and creating lx2 app...
|
|
68
|
+
`),N.emptyDirSync(t))}a.start(),N.copySync(i,t),N.renameSync(me.join(t,"_gitignore"),me.join(t,".gitignore"));let o=e==="."?"App":z.cyan.bold(e);a.succeed(`${o} ${z.green.bold("scaffolded successfully!")}
|
|
69
|
+
`)}import S from"path";import fe from"fs-extra";function He({packages:e,projectDir:t}){let n=S.join(d,"template/packages/src/app/layout"),s=e.payload.inUse,i=e.trpc.inUse,a="base.tsx";i&&(a="with-trpc.tsx");let o=S.join(n,a),r=S.join(t,`src/app/${s?"(frontend)":""}/layout.tsx`);fe.copySync(o,r)}function Ke({packages:e,projectDir:t}){let n=S.join(d,"template/packages/src/app/page"),s=e.payload.inUse,i=e.authjs.inUse,a=e.betterAuth.inUse,o=e.trpc.inUse,r=e.prisma.inUse,l=e.drizzle.inUse,g=[{condition:o&&l&&a,file:"with-trpc.tsx"},{condition:o&&l&&i,file:"with-trpc.tsx"},{condition:o&&l,file:"with-trpc.tsx"},{condition:o&&r&&a,file:"with-trpc.tsx"},{condition:o&&r&&i,file:"with-trpc.tsx"},{condition:o&&r,file:"with-trpc.tsx"},{condition:s,file:"with-payload.tsx"},{condition:l&&a,file:"with-better-auth-drizzle.tsx"},{condition:l&&i,file:"with-authjs-drizzle.tsx"},{condition:l,file:"with-drizzle.tsx"},{condition:r&&a,file:"with-better-auth-prisma.tsx"},{condition:r&&i,file:"with-authjs-prisma.tsx"},{condition:r,file:"with-prisma.tsx"},{condition:o&&a,file:"with-trpc.tsx"},{condition:o&&i,file:"with-trpc.tsx"},{condition:o,file:"with-trpc.tsx"},{condition:a,file:"with-better-auth.tsx"},{condition:i,file:"with-authjs.tsx"},{condition:!0,file:"base.tsx"}].find(b=>b.condition)?.file||"base.tsx",p=S.join(n,g),m=S.join(t,`src/app/${s?"(frontend)":""}/page.tsx`);fe.copySync(p,m)}function Ye({projectDir:e}){let t=S.join(d,"template/packages/src/styles"),s=S.join(t,"base.css"),i=S.join(e,"src/styles/globals.css");fe.copySync(s,i)}async function Xe({projectName:e,scopedAppName:t,packages:n,install:s,databaseProvider:i}){let a=v(),o=Ot.resolve(process.cwd(),e);return await Ve({projectName:e,projectDir:o,pkgManager:a,scopedAppName:t,install:s,databaseProvider:i}),Je({projectName:e,scopedAppName:t,projectDir:o,pkgManager:a,packages:n,install:s,databaseProvider:i}),He({packages:n,projectDir:o}),Ke({packages:n,projectDir:o}),Ye({packages:n,projectDir:o}),o}import{execSync as ge}from"child_process";import ue from"path";import{confirm as Qe}from"@inquirer/prompts";import G from"chalk";import{execa as W}from"execa";import Ze from"fs-extra";import Ut from"ora";function Et(e){try{return ge("git --version",{cwd:e}),!0}catch{return!1}}function he(e){return Ze.existsSync(ue.join(e,".git"))}async function ye(e){try{return await W("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}}function qt(){let t=ge("git --version").toString().trim().split(" ")[2],n=t?.split(".")[0],s=t?.split(".")[1];return{major:Number(n),minor:Number(s)}}function Mt(){return ge("git config --global init.defaultBranch || echo main").toString().trim()}async function et(e){if(c.info("Initializing Git..."),!Et(e)){c.warn("Git is not installed. Skipping Git initialization.");return}let t=Ut(`Creating a new git repo...
|
|
70
|
+
`).start(),n=he(e),s=await ye(e),i=ue.parse(e).name;if(s&&n){if(t.stop(),!await Qe({message:`${G.redBright.bold("Warning:")} Git is already initialized in "${i}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`,default:!1})){t.info("Skipping Git initialization.");return}Ze.removeSync(ue.join(e,".git"))}else if(s&&!n&&(t.stop(),!await Qe({message:`${G.redBright.bold("Warning:")} "${i}" is already in a git worktree. Would you still like to initialize a new git repository in this directory?`,default:!1}))){t.info("Skipping Git initialization.");return}try{let a=Mt(),{major:o,minor:r}=qt();o<2||o==2&&r<28?(await W("git",["init"],{cwd:e}),await W("git",["symbolic-ref","HEAD",`refs/heads/${a}`],{cwd:e})):await W("git",["init",`--initial-branch=${a}`],{cwd:e}),await W("git",["add","."],{cwd:e}),t.succeed(`${G.green("Successfully initialized and staged")} ${G.green.bold("git")}
|
|
71
|
+
`)}catch{t.fail(`${G.bold.red("Failed:")} could not initialize git. Update git to the latest version!
|
|
72
|
+
`)}}import $t from"chalk";import{execa as tt}from"execa";import it from"ora";var be=async(e,t,n)=>{let{onDataHandle:s,args:i=["install"],stdout:a="pipe"}=n,o=it(`Running ${t} install...`).start(),r=tt(t,i,{cwd:e,stdout:a});return await new Promise((l,f)=>{s&&r.stdout?.on("data",s(o)),r.on("error",g=>f(g)),r.on("close",()=>l())}),o},Lt=async(e,t)=>{switch(e){case"npm":return await tt(e,["install"],{cwd:t,stderr:"inherit"}),null;case"pnpm":return be(t,e,{onDataHandle:n=>s=>{let i=s.toString();i.includes("Progress")&&(n.text=i.includes("|")?i.split(" | ")[1]??"":i)}});case"yarn":return be(t,e,{onDataHandle:n=>s=>{n.text=s.toString()}});case"bun":return be(t,e,{stdout:"ignore"})}},st=async({projectDir:e})=>{c.info("Installing dependencies...");let t=v();(await Lt(t,e)??it()).succeed($t.green(`Successfully installed dependencies!
|
|
73
|
+
`))};var nt=async({projectName:e=L,packages:t,install:n,projectDir:s,databaseProvider:i})=>{let a=v();c.info("Next steps:"),e!=="."&&c.info(` cd ${e}`),n===!1&&(a==="yarn"?c.info(` ${a}`):c.info(` ${a} install`)),["postgresql","mysql"].includes(i)&&c.info(" Add your database connection string to .env"),t?.authjs.inUse&&c.info(" Fill in your .env with necessary values. See https://create.lx2.dev/docs/first-steps for more info."),t?.betterAuth.inUse&&c.info(" Fill in your .env with necessary values. See https://create.lx2.dev/docs/first-steps for more info."),t?.prisma.inUse&&c.info(` Run "${a} db:push" to create you database tables.`),["npm"].includes(a)?c.info(` ${a} run dev`):c.info(` ${a} dev`),!await ye(s)&&!he(s)&&c.info(" git init"),c.info(' git commit -m "initial commit"')};import Z from"fs";import Ft from"path";function at(e,t,n){Z.readdirSync(e).forEach(i=>{let a=Ft.join(e,i);if(Z.statSync(a).isDirectory())at(a,t,n);else{let r=Z.readFileSync(a,"utf8").replace(new RegExp(t,"g"),n);Z.writeFileSync(a,r,"utf8")}})}function ot(e,t){let n=t.replace(/\*/g,"").replace(/[^\/]$/,"$&/");at(e,"@/",n)}import rt from"path";function lt(e){let n=X(e).split("/"),s=n[n.length-1];if(s==="."){let o=rt.resolve(process.cwd());s=rt.basename(o)}let i=n.findIndex(o=>o.startsWith("@"));n.findIndex(o=>o.startsWith("@"))!==-1&&(s=n.slice(i).join("/"));let a=n.filter(o=>!o.startsWith("@")).join("/");return[s,a]}function ct(){c.warn(" Compatibility Warnings:");for(let e of R){let t=e.packages,n="";e.message?n=` - ${e.message}`:t.length===2?n=` - Using ${t[0]} with ${t[1]} is not supported yet.`:t.length>2&&(n=` - Using ${t[0]} with ${t.slice(1,-1).join(", ")}, or ${t.slice(-1)} is not supported yet.`),c.warn(n)}console.log("")}import Bt from"gradient-string";var Nt={primary:"#bf95f9",accent:"#6071a4",secondary:"#ff7ac5"};function pt(){let e=Bt(Object.values(Nt)),t=v();(t==="yarn"||t==="pnpm")&&console.log(""),console.log(e.multiline(xe))}import{execSync as Gt}from"child_process";import Wt from"https";function dt(e){let t=O();t.includes("beta")?(c.warn(" You are using a beta version of create-lx2-app."),c.warn(" Please report any bugs you encounter.")):t!==e&&(c.warn(" You are using an outdated version of create-lx2-app."),c.warn(" Your version:",t+".","Latest version in the npm registry:",e),c.warn(" Please run the CLI with @latest to get the latest updates.")),console.log("")}function Jt(){return new Promise((e,t)=>{Wt.get("https://registry.npmjs.org/-/package/create-lx2-app/dist-tags",n=>{if(n.statusCode===200){let s="";n.on("data",i=>s+=i),n.on("end",()=>{e(JSON.parse(s).latest)})}else t()}).on("error",()=>{t()})})}var mt=()=>Jt().catch(()=>{try{return Gt("npm view create-lx2-app version").toString().trim()}catch{return null}});async function Ht(){let e=await mt(),t=v();pt(),e&&dt(e),R.length>0&&ct();let{appName:n,packages:s,flags:{git:i,install:a,importAlias:o},databaseProvider:r}=await Ge(),l=Le(s),[f,g]=lt(n),p=await Xe({projectName:g,scopedAppName:f,packages:l,install:a,databaseProvider:r}),m=ut.readJsonSync(ft.join(p,"package.json"));if(m.name=f,m.clx2aMetadata={initVersion:O()},t!=="bun"){let{stdout:b}=await Vt(t,["-v"],{cwd:p});m.packageManager=`${t}@${b.trim()}`}ut.writeJSONSync(ft.join(p,"package.json"),m,{spaces:2}),o!=="@/"&&ot(p,o),a&&await st({projectDir:p}),i&&await et(p),await nt({projectDir:p,projectName:g,packages:l,install:a,databaseProvider:r}),process.exit(0)}Ht().catch(e=>{c.error("Aborting installation..."),e instanceof Error?c.error(e.message):(c.error("An unknown error occurred. Please open an issue on GitHub with the below:"),console.error(e)),process.exit(1)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-lx2-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1-beta.4f7512c",
|
|
4
4
|
"description": "The Most Opinionated Way to Build Next.js Apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@prisma/adapter-mariadb": "^7.2.0",
|
|
71
71
|
"@prisma/adapter-pg": "^7.2.0",
|
|
72
72
|
"@prisma/client": "^7.2.0",
|
|
73
|
+
"@prisma/client-runtime-utils": "^7.2.0",
|
|
73
74
|
"@t3-oss/env-nextjs": "^0.13.10",
|
|
74
75
|
"@types/better-sqlite3": "^7.6.13",
|
|
75
76
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -93,6 +94,7 @@
|
|
|
93
94
|
"prisma": "^7.2.0",
|
|
94
95
|
"react": "^19.2.3",
|
|
95
96
|
"react-dom": "^19.2.3",
|
|
97
|
+
"server-only": "^0.0.1",
|
|
96
98
|
"sharp": "^0.34.5",
|
|
97
99
|
"tailwindcss": "^4.1.18",
|
|
98
100
|
"tsup": "^8.5.1",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"
|
|
2
|
+
import { type NextRequest } from "next/server"
|
|
3
|
+
|
|
4
|
+
import { env } from "@/env"
|
|
5
|
+
import { createTRPCContext } from "@/server/api/init"
|
|
6
|
+
import { appRouter } from "@/server/api/root"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
|
|
10
|
+
* handling a HTTP request (e.g. when you make requests from Client Components).
|
|
11
|
+
*/
|
|
12
|
+
async function createContext(req: NextRequest) {
|
|
13
|
+
return createTRPCContext({
|
|
14
|
+
headers: req.headers,
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const handler = (req: NextRequest) =>
|
|
19
|
+
fetchRequestHandler({
|
|
20
|
+
endpoint: "/api/trpc",
|
|
21
|
+
req,
|
|
22
|
+
router: appRouter,
|
|
23
|
+
createContext: () => createContext(req),
|
|
24
|
+
onError:
|
|
25
|
+
env.NODE_ENV === "development"
|
|
26
|
+
? ({ path, error }) => {
|
|
27
|
+
console.error(
|
|
28
|
+
`[tRPC] Error on ${path ?? "<no-path>"}: ${error.message}`
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
: undefined,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export { handler as GET, handler as POST }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
import { Geist, Geist_Mono } from "next/font/google"
|
|
3
|
+
|
|
4
|
+
import { TRPCReactProvider } from "@/lib/api/client"
|
|
5
|
+
|
|
6
|
+
import "@/styles/globals.css"
|
|
7
|
+
|
|
8
|
+
const geistSans = Geist({
|
|
9
|
+
variable: "--font-geist-sans",
|
|
10
|
+
subsets: ["latin"],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const geistMono = Geist_Mono({
|
|
14
|
+
variable: "--font-geist-mono",
|
|
15
|
+
subsets: ["latin"],
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export const metadata: Metadata = {
|
|
19
|
+
title: "Create Lx2 App",
|
|
20
|
+
description: "Generated by create lx2 app",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function RootLayout({
|
|
24
|
+
children,
|
|
25
|
+
}: Readonly<{
|
|
26
|
+
children: React.ReactNode
|
|
27
|
+
}>) {
|
|
28
|
+
return (
|
|
29
|
+
<html lang="en">
|
|
30
|
+
<body
|
|
31
|
+
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
|
32
|
+
>
|
|
33
|
+
<TRPCReactProvider>{children}</TRPCReactProvider>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -4,6 +4,10 @@ import { revalidatePath } from "next/cache"
|
|
|
4
4
|
import { auth, signIn, signOut } from "@/server/auth"
|
|
5
5
|
import { db } from "@/server/db"
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Force dynamic rendering for pnpm + prisma
|
|
9
|
+
* @see https://github.com/prisma/prisma/issues/28581
|
|
10
|
+
*/
|
|
7
11
|
export const dynamic = "force-dynamic"
|
|
8
12
|
|
|
9
13
|
export default async function HomePage() {
|
|
@@ -6,6 +6,10 @@ import { redirect } from "next/navigation"
|
|
|
6
6
|
import { auth } from "@/server/auth"
|
|
7
7
|
import { db } from "@/server/db"
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Force dynamic rendering for pnpm + prisma
|
|
11
|
+
* @see https://github.com/prisma/prisma/issues/28581
|
|
12
|
+
*/
|
|
9
13
|
export const dynamic = "force-dynamic"
|
|
10
14
|
|
|
11
15
|
export default async function HomePage() {
|
|
@@ -3,6 +3,10 @@ import { revalidatePath } from "next/cache"
|
|
|
3
3
|
|
|
4
4
|
import { db } from "@/server/db"
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Force dynamic rendering for pnpm + prisma
|
|
8
|
+
* @see https://github.com/prisma/prisma/issues/28581
|
|
9
|
+
*/
|
|
6
10
|
export const dynamic = "force-dynamic"
|
|
7
11
|
|
|
8
12
|
export default async function HomePage() {
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { fileURLToPath } from "url"
|
|
2
|
+
|
|
3
|
+
import { Greeting } from "@/components/greeting"
|
|
4
|
+
import { api, HydrateClient } from "@/lib/api/server"
|
|
5
|
+
|
|
6
|
+
export const dynamic = "force-dynamic"
|
|
7
|
+
|
|
8
|
+
export default async function HomePage() {
|
|
9
|
+
const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}`
|
|
10
|
+
|
|
11
|
+
void api.post.greeting({ text: "from tRPC!" })
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<HydrateClient>
|
|
15
|
+
<main className="mx-auto flex h-screen max-w-5xl flex-col items-center justify-between overflow-hidden p-6 sm:p-[45px]">
|
|
16
|
+
<div className="flex grow flex-col items-center justify-center">
|
|
17
|
+
{/* Logo */}
|
|
18
|
+
<picture className="relative">
|
|
19
|
+
<div className="absolute inset-0 animate-pulse bg-linear-to-r from-[oklch(0.7468_0.1455_302.21)] via-[oklch(0.7345_0.0464_270.71)] to-[oklch(0.7563_0.1807_347.17)] opacity-20 blur-lg dark:via-[oklch(0.5567_0.0816_269.53)]" />
|
|
20
|
+
|
|
21
|
+
<source srcSet="https://github.com/SlickYeet/create-lx2-app/blob/f1209465d59e03e284702d9f492f1bc1cfa49c32/docs/v2/public/android-chrome-192x192.png?raw=true" />
|
|
22
|
+
<img
|
|
23
|
+
src="https://github.com/SlickYeet/create-lx2-app/blob/f1209465d59e03e284702d9f492f1bc1cfa49c32/docs/v2/public/android-chrome-192x192.png?raw=true"
|
|
24
|
+
alt="Logo"
|
|
25
|
+
width={65}
|
|
26
|
+
height={65}
|
|
27
|
+
className="block h-auto max-w-full"
|
|
28
|
+
/>
|
|
29
|
+
</picture>
|
|
30
|
+
|
|
31
|
+
{/* Title & Description */}
|
|
32
|
+
<h1 className="mt-6 text-5xl font-bold tracking-tight text-balance md:text-6xl lg:text-7xl">
|
|
33
|
+
Create{" "}
|
|
34
|
+
<span className="text-[oklch(0.7468_0.1455_302.21)]">Lx2</span> App
|
|
35
|
+
</h1>
|
|
36
|
+
<p className="text-center text-lg text-neutral-700 md:text-xl lg:mt-6 dark:text-neutral-300">
|
|
37
|
+
The Most Opinionated Way to Build Next.js Apps
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
{/* Links */}
|
|
41
|
+
<div className="mt-12 flex items-center gap-3">
|
|
42
|
+
<a
|
|
43
|
+
href="https://create.lx2.dev/docs"
|
|
44
|
+
target="_blank"
|
|
45
|
+
rel="noopener noreferrer"
|
|
46
|
+
className="flex items-center rounded-md border border-white/25 px-2 py-1 outline-none hover:opacity-80 focus:opacity-80 active:opacity-70"
|
|
47
|
+
>
|
|
48
|
+
Docs
|
|
49
|
+
<svg
|
|
50
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
51
|
+
viewBox="0 0 24 24"
|
|
52
|
+
strokeLinecap="round"
|
|
53
|
+
strokeLinejoin="round"
|
|
54
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
55
|
+
>
|
|
56
|
+
<path d="M7 7h10v10" />
|
|
57
|
+
<path d="M7 17 17 7" />
|
|
58
|
+
</svg>
|
|
59
|
+
</a>
|
|
60
|
+
<a
|
|
61
|
+
href="https://link.lx2.dev/discord"
|
|
62
|
+
target="_blank"
|
|
63
|
+
rel="noopener noreferrer"
|
|
64
|
+
className="flex items-center rounded-md border border-white/25 px-2 py-1 outline-none hover:opacity-80 focus:opacity-80 active:opacity-70"
|
|
65
|
+
>
|
|
66
|
+
Discord
|
|
67
|
+
<svg
|
|
68
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
69
|
+
viewBox="0 0 24 24"
|
|
70
|
+
strokeLinecap="round"
|
|
71
|
+
strokeLinejoin="round"
|
|
72
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
73
|
+
>
|
|
74
|
+
<path d="M7 7h10v10" />
|
|
75
|
+
<path d="M7 17 17 7" />
|
|
76
|
+
</svg>
|
|
77
|
+
</a>
|
|
78
|
+
<a
|
|
79
|
+
href="https://github.com/SlickYeet/create-lx2-app"
|
|
80
|
+
target="_blank"
|
|
81
|
+
rel="noopener noreferrer"
|
|
82
|
+
className="flex items-center rounded-md border border-white/25 px-2 py-1 outline-none hover:opacity-80 focus:opacity-80 active:opacity-70"
|
|
83
|
+
>
|
|
84
|
+
GitHub
|
|
85
|
+
<svg
|
|
86
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
87
|
+
viewBox="0 0 24 24"
|
|
88
|
+
strokeLinecap="round"
|
|
89
|
+
strokeLinejoin="round"
|
|
90
|
+
className="mb-1.5 size-4 fill-none stroke-current stroke-2"
|
|
91
|
+
>
|
|
92
|
+
<path d="M7 7h10v10" />
|
|
93
|
+
<path d="M7 17 17 7" />
|
|
94
|
+
</svg>
|
|
95
|
+
</a>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
{/* tRPC Greeting */}
|
|
99
|
+
<Greeting />
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{/* Footer */}
|
|
103
|
+
<div className="flex flex-col items-center gap-1 text-sm text-neutral-600 lg:flex-row lg:gap-2 dark:text-neutral-400">
|
|
104
|
+
<p className="m-0">Get started by editing </p>
|
|
105
|
+
<a
|
|
106
|
+
href={fileURL}
|
|
107
|
+
className="rounded-md bg-neutral-200 px-2 py-1 dark:bg-neutral-800"
|
|
108
|
+
>
|
|
109
|
+
<code>src/app/page.tsx</code>
|
|
110
|
+
</a>
|
|
111
|
+
</div>
|
|
112
|
+
</main>
|
|
113
|
+
</HydrateClient>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { api } from "@/lib/api/client"
|
|
4
|
+
|
|
5
|
+
export function Greeting() {
|
|
6
|
+
const [greeting] = api.post.greeting.useSuspenseQuery({
|
|
7
|
+
text: "from tRPC!",
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div className="mt-12 flex flex-col items-center gap-3">
|
|
12
|
+
<div className="mb-4">
|
|
13
|
+
<h2 className="mb-4 text-center">
|
|
14
|
+
<span className="text-2xl text-neutral-700 dark:text-neutral-300">
|
|
15
|
+
{greeting}
|
|
16
|
+
</span>
|
|
17
|
+
</h2>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -23,7 +23,7 @@ export const env = createEnv({
|
|
|
23
23
|
*/
|
|
24
24
|
client: {
|
|
25
25
|
// NEXT_PUBLIC_CLIENTVAR: z.string(),
|
|
26
|
-
|
|
26
|
+
NEXT_PUBLIC_URL: z.url(),
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -34,7 +34,7 @@ export const env = createEnv({
|
|
|
34
34
|
NODE_ENV: process.env.NODE_ENV,
|
|
35
35
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
36
36
|
BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
|
|
37
|
-
|
|
37
|
+
NEXT_PUBLIC_URL: process.env.NEXT_PUBLIC_URL,
|
|
38
38
|
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
|
|
39
39
|
DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
|
|
40
40
|
},
|
|
@@ -20,7 +20,7 @@ export const env = createEnv({
|
|
|
20
20
|
*/
|
|
21
21
|
client: {
|
|
22
22
|
// NEXT_PUBLIC_CLIENTVAR: z.string(),
|
|
23
|
-
|
|
23
|
+
NEXT_PUBLIC_URL: z.url(),
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -31,7 +31,7 @@ export const env = createEnv({
|
|
|
31
31
|
NODE_ENV: process.env.NODE_ENV,
|
|
32
32
|
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
|
|
33
33
|
BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
|
|
34
|
-
|
|
34
|
+
NEXT_PUBLIC_URL: process.env.NEXT_PUBLIC_URL,
|
|
35
35
|
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
|
|
36
36
|
DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
|
|
37
37
|
},
|