create-lx2-app 0.11.5-beta.f8c5ccc → 0.12.1-beta.db923f0
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 +14 -14
- package/package.json +2 -1
- 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/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/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import Qe from"path";import{execa as Rt}from"execa";import Xe from"fs-extra";import{confirm as Q,input as Ie,select as
|
|
2
|
+
import Qe from"path";import{execa as Rt}from"execa";import Xe from"fs-extra";import{confirm as Q,input as Ie,select as T}from"@inquirer/prompts";import{Command as ht}from"commander";import ne from"path";import{fileURLToPath as it}from"url";var at=it(import.meta.url),nt=ne.dirname(at),c=ne.join(nt,"../"),oe=` ___ ___ ___ _ _____ ___ _ ___ _ ___ ___
|
|
3
3
|
/ __| _ \\ __| /_\\_ _| __| | | __ __|_ ) /_\\ | _ \\ _ \\
|
|
4
4
|
| (__| / _| / _ \\| | | _| | |__\\ \\ / / / / _ \\| _/ _/
|
|
5
5
|
\\___|_|_\\___/_/ \\_\\_| |___| |____/_\\_\\/___| /_/ \\_\\_| |_|
|
|
6
|
-
`,O="my-lx2-app",V="create-lx2-app";var b=()=>{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
|
|
6
|
+
`,O="my-lx2-app",V="create-lx2-app";var b=()=>{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 j from"path";import H from"fs-extra";var re={"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","@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 le from"path";import pe from"fs-extra";import ot from"sort-package-json";var m=e=>{let{dependencies:s,devMode:a,projectDir:i}=e,t=pe.readJsonSync(le.join(i,"package.json"));s.forEach(o=>{let r=re[o];a&&t.devDependencies?t.devDependencies[o]=r:t.dependencies&&(t.dependencies[o]=r)});let n=ot(t);pe.writeJsonSync(le.join(i,"package.json"),n,{spaces:2})};var ce=({projectDir:e,packages:s})=>{let a=s?.prisma.inUse,i=s?.drizzle.inUse,t=["next-auth"];a&&t.push("@auth/prisma-adapter"),i&&t.push("@auth/drizzle-adapter"),m({projectDir:e,dependencies:t,devMode:!1});let n=j.join(c,"template/packages"),o="src/app/api/auth/[...nextauth]/route.ts",r=j.join(n,o),p=j.join(e,o),f=j.join(n,"src/server/auth/config",a?"authjs-with-prisma.ts":i?"authjs-with-drizzle.ts":"authjs.ts"),u=j.join(e,"src/server/auth/config.ts"),d=j.join(n,"src/server/auth/authjs.ts"),g=j.join(e,"src/server/auth/index.ts");H.copySync(r,p),H.copySync(f,u),H.copySync(d,g)};import P from"path";import R from"fs-extra";import rt from"path";import de from"fs-extra";import{sortPackageJson as lt}from"sort-package-json";function v(e){let{scripts:s,projectDir:a}=e,i=rt.join(a,"package.json"),t=de.readJSONSync(i);t.scripts={...t.scripts,...s};let n=lt(t);de.writeJSONSync(i,n,{spaces:2})}var me=({projectDir:e,packages:s,databaseProvider:a})=>{let i=s?.prisma.inUse,t=s?.drizzle.inUse,n=i||t,o=["better-auth"],r=[];n||o.push("better-sqlite3"),n||r.push("@types/better-sqlite3"),m({projectDir:e,dependencies:o,devMode:!1}),m({projectDir:e,dependencies:r,devMode:!0});let p=P.join(c,"template/packages"),f=P.join(p,"src/app/api/auth/[...betterauth]/route.ts"),u=P.join(e,"src/app/api/auth/[...all]/route.ts"),d=P.join(p,"src/server/auth",i?"better-auth-with-prisma.ts":t?"better-auth-with-drizzle.ts":"better-auth.ts"),g=R.readFileSync(d,"utf-8");(i||t)&&a!=="sqlite"&&(g=g.replace('provider: "sqlite",',`provider: "${{mysql:"mysql",postgresql:t?"pg":"postgresql"}[a]}",`));let h=P.join(e,"src/server/auth/index.ts");R.mkdirSync(P.dirname(h),{recursive:!0}),R.writeFileSync(h,g);let S=P.join(p,"src/lib/auth/better-auth-client.ts"),W=P.join(e,"src/lib/auth/client.ts");v({projectDir:e,scripts:{"auth:generate":"npx @better-auth/cli@latest generate --config ./src/server/auth/index.ts --yes",...!i&&!t&&{"auth:migrate":"npx @better-auth/cli@latest migrate --config ./src/server/auth/index.ts --yes"}}}),R.copySync(f,u),R.copySync(S,W)};import K from"path";import pt from"fs-extra";var fe=({projectDir:e})=>{m({projectDir:e,dependencies:["@biomejs/biome"],devMode:!0});let s=K.join(c,"template/packages"),a=K.join(s,"config/biome.jsonc"),i=K.join(e,"biome.jsonc");pt.copyFileSync(a,i),v({projectDir:e,scripts:{"lint:unsafe":"biome check --write --unsafe .","lint:write":"biome check --write .",lint:"biome check .",format:"biome format --write ."}})};import _ from"path";import I from"fs-extra";var ue=({projectDir:e,packages:s,scopedAppName:a,databaseProvider:i})=>{let t=s?.authjs.inUse,n=s?.betterAuth.inUse;m({projectDir:e,dependencies:["drizzle-kit"],devMode:!0}),m({projectDir:e,dependencies:["drizzle-orm",{sqlite:"@libsql/client",mysql:"mysql2",postgresql:"postgres"}[i]],devMode:!1});let o=_.join(c,"template/packages"),r=_.join(o,"config/drizzle",{sqlite:"with-sqlite",mysql:"with-mysql",postgresql:"with-postgresql"}[i]+".ts"),p=_.join(e,"drizzle.config.ts"),f=_.join(o,"src/server/db/schema-drizzle",t?`with-authjs-${i}.ts`:n?`with-better-auth-${i}.ts`:`base-${i}.ts`),u=_.join(e,"src/server/db/schema.ts"),d=I.readFileSync(f,"utf-8");d=d.replace("project1_${name}",`${a}_\${name}`);let g=I.readFileSync(r,"utf-8");g=g.replace("project1_*",`${a}_*`);let h=_.join(o,`src/server/db/index-drizzle/with-${i}.ts`),S=_.join(e,"src/server/db/index.ts");v({projectDir:e,scripts:{"db:generate":"drizzle-kit generate","db:migrate":"drizzle-kit migrate","db:push":"drizzle-kit push","db:studio":"drizzle-kit studio"}}),I.copySync(r,p),I.mkdirSync(_.dirname(u),{recursive:!0}),I.writeFileSync(u,d),I.writeFileSync(p,g),I.copySync(h,S)};import $ from"path";import Y from"fs-extra";var ge=({projectDir:e,scopedAppName:s,packages:a,databaseProvider:i})=>{let t=a?.envVariables.inUse,n=a?.authjs.inUse,o=a?.betterAuth.inUse,r=a?.prisma.inUse,p=a?.drizzle.inUse,f=a?.payload.inUse,u=[];t&&(u.push("@t3-oss/env-nextjs"),u.push("zod")),m({projectDir:e,dependencies:u,devMode:!1});let d=r||p||f,g=ct(!!n,!!o,!!r,!!p,!!f,s,i),h="";if(d?n?h="with-authjs-db.js":o?h="with-better-auth-db.js":f?h="with-payload.js":h="with-db.js":n?h="with-authjs.js":o&&(h="with-better-auth.js"),h!==""){let tt=$.join(c,"template/packages/src/env",h),st=$.join(e,"src/env.ts");Y.copyFileSync(tt,st)}let S=$.join(e,".env"),W=$.join(e,".env.example"),Ze=dt+g,J=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("base64"),et=g.replace('AUTH_SECRET=""',`AUTH_SECRET="${J}" # Generated by create-lx2-app`).replace('BETTER_AUTH_SECRET=""',`BETTER_AUTH_SECRET="${J}" # Generated by create-lx2-app`).replace('PAYLOAD_SECRET=""',`PAYLOAD_SECRET="${J}" # Generated by create-lx2-app`);Y.writeFileSync(S,et,"utf-8"),Y.writeFileSync(W,Ze,"utf-8")};function ct(e,s,a,i,t,n,o){let r=`
|
|
7
7
|
# When adding additional environment variables, the schema in "/src/env.ts"
|
|
8
8
|
# should be updated accordingly.
|
|
9
9
|
`.trim().concat(`
|
|
@@ -43,7 +43,7 @@ DISCORD_CLIENT_SECRET=""
|
|
|
43
43
|
# Example:
|
|
44
44
|
# SERVERVAR="foo"
|
|
45
45
|
# NEXT_PUBLIC_CLIENTVAR="bar"
|
|
46
|
-
`),r}var
|
|
46
|
+
`),r}var dt=`
|
|
47
47
|
# Since the ".env" file is gitignored, you can use the ".env.example" file to
|
|
48
48
|
# build a new ".env" file when you clone the repo. Keep this file up-to-date
|
|
49
49
|
# when you add new variables to \`.env\`.
|
|
@@ -53,19 +53,19 @@ DISCORD_CLIENT_SECRET=""
|
|
|
53
53
|
# ".env" and populate it with your secrets.
|
|
54
54
|
`.trim().concat(`
|
|
55
55
|
|
|
56
|
-
`);import F from"path";import he from"fs-extra";var ye=({projectDir:e,packages:s})=>{let a=s?.["eslint/prettier"].inUse,i=[];a&&(i.push("eslint"),i.push("eslint-config-next"),i.push("@eslint/eslintrc"),i.push("prettier"),i.push("prettier-plugin-tailwindcss"),i.push("@ianvs/prettier-plugin-sort-imports")),
|
|
56
|
+
`);import F from"path";import he from"fs-extra";var ye=({projectDir:e,packages:s})=>{let a=s?.["eslint/prettier"].inUse,i=[];a&&(i.push("eslint"),i.push("eslint-config-next"),i.push("@eslint/eslintrc"),i.push("prettier"),i.push("prettier-plugin-tailwindcss"),i.push("@ianvs/prettier-plugin-sort-imports")),m({projectDir:e,dependencies:i,devMode:!0});let t=F.join(c,"template/packages/config","eslint.config.mjs"),n=F.join(c,"template/packages/config","prettier.config.mjs"),o=F.join(e,"eslint.config.mjs"),r=F.join(e,"prettier.config.mjs");v({projectDir:e,scripts:{"lint:write":"eslint --fix",lint:"eslint",format:"prettier --write ."}}),he.copyFileSync(t,o),he.copyFileSync(n,r)};import w from"path";import C from"fs-extra";var be=({projectDir:e,packages:s,databaseProvider:a})=>{let i=[],t=[];if(s?.payload.inUse)switch(i.push("payload"),i.push("@payloadcms/next"),i.push("@payloadcms/payload-cloud"),i.push("@payloadcms/richtext-lexical"),i.push("graphql"),a){case"sqlite":t.push("@payloadcms/db-sqlite");break;case"postgresql":t.push("@payloadcms/db-vercel-postgres");break}m({projectDir:e,dependencies:i,devMode:!1}),m({projectDir:e,dependencies:t,devMode:!1});let n=w.join(c,"template/packages"),o=w.join(n,"config/payload",`${a==="postgresql"?"with-postgres":"with-sqlite"}.ts`),r=w.join(e,"payload.config.ts");C.copyFileSync(o,r);let p=w.join(n,"src/payload/collections"),f=w.join(e,"src/collections");C.mkdirSync(f,{recursive:!0}),C.copyFileSync(w.join(p,"Media.ts"),w.join(f,"Media.ts")),C.copyFileSync(w.join(p,"Users.ts"),w.join(f,"Users.ts"));let u=w.join(n,"src/app/(payload)"),d=w.join(e,"src/app/(payload)");C.mkdirSync(d,{recursive:!0}),C.copySync(u,d),v({projectDir:e,scripts:{payload:"payload","generate:importmap":"payload generate:importmap","generate:types":"payload generate:types"}})};import k from"path";import A from"fs-extra";var ve=({projectDir:e,packages:s,databaseProvider:a,pkgManager:i})=>{let t=s?.authjs.inUse,n=s?.betterAuth.inUse;m({projectDir:e,dependencies:["prisma"],devMode:!0});let o={sqlite:i==="bun"?"@prisma/adapter-libsql":"@prisma/adapter-better-sqlite3",mysql:"@prisma/adapter-mariadb",postgresql:"@prisma/adapter-pg"}[a];m({projectDir:e,dependencies:["@prisma/client",o],devMode:!1}),a==="sqlite"&&i!=="bun"&&m({projectDir:e,dependencies:["@types/better-sqlite3"],devMode:!0}),i==="pnpm"&&m({projectDir:e,dependencies:["@prisma/client-runtime-utils"],devMode:!1});let r=k.join(c,"template/packages"),p=k.join(r,"config/prisma.config.ts"),f=k.join(e,"prisma.config.ts");A.writeFileSync(f,A.readFileSync(p,"utf-8"));let u=k.join(r,"prisma/schema",`${t?"with-authjs":n?"with-better-auth":"base"}.prisma`),d=A.readFileSync(u,"utf-8");a!=="sqlite"&&(d=d.replace('provider = "sqlite"',`provider = "${{mysql:"mysql",postgresql:"postgresql"}[a]}"`),["mysql"].includes(a)&&(d=d.replace("// @db.Text","@db.Text")));let g=k.join(e,"prisma/schema.prisma");A.mkdirSync(k.dirname(g),{recursive:!0}),A.writeFileSync(g,d);let h=k.join(r,`src/server/db/prisma/with-${a}${i==="bun"?"-bun":""}.ts`),S=k.join(e,"src/server/db/index.ts");A.mkdirSync(k.dirname(S),{recursive:!0}),A.writeFileSync(S,A.readFileSync(h,"utf-8")),v({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 we from"path";import mt from"fs-extra";var ke=({projectDir:e,packages:s})=>{let a=s?.typescript.inUse,i=s?.payload.inUse,t=[];a&&(t.push("typescript"),t.push("@types/node"),t.push("@types/react"),t.push("@types/react-dom")),m({projectDir:e,dependencies:t,devMode:!0});let n=we.join(c,"template/packages/config/tsconfig",`${i?"with-payload":"base"}.json`),o=we.join(e,"tsconfig.json");mt.copyFileSync(n,o)};var xe=["nextjs","payload"],Se=["none","authjs","betterAuth"],Pe=["none","prisma","drizzle"],L=["sqlite","mysql","postgresql"];var _e=e=>({authjs:{inUse:e.includes("authjs"),installer:ce},betterAuth:{inUse:e.includes("betterAuth"),installer:me},prisma:{inUse:e.includes("prisma"),installer:ve},drizzle:{inUse:e.includes("drizzle"),installer:ue},envVariables:{inUse:!0,installer:ge},"eslint/prettier":{inUse:e.includes("eslint/prettier"),installer:ye},biome:{inUse:e.includes("biome"),installer:fe},typescript:{inUse:!0,installer:ke},payload:{inUse:e.includes("payload"),installer:be}});import ft from"path";import ut from"fs-extra";function D(){let e=ft.join(c,"package.json");return ut.readJSONSync(e).version??"1.0.0"}var E=class extends Error{constructor(s){super(s)}};import B from"chalk";var l={error(...e){console.log(B.red(...e))},warn(...e){console.log(B.yellow(...e))},info(...e){console.log(B.cyan(...e))},success(...e){console.log(B.green(...e))}};var N=e=>(e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e);var gt=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;function Ae(e){let s=N(e),a=s.split("/"),i=a.findIndex(n=>n.startsWith("@")),t=a[a.length-1];return a.findIndex(n=>n.startsWith("@"))!==-1&&(t=a.slice(i).join("/")),s=="."||gt.test(t??"")?!0:"App name must consist of only lowercase alphanumeric characters, '-', and '_'"}var je=e=>e.startsWith(".")||e.startsWith("/")?"Import alias can't start with '.' or '/'":!0;var y={appName:O,packages:[],flags:{git:!1,install:!1,default:!1,CI:!1,authentication:"none",orm:"none",linter:"eslint/prettier",importAlias:"@/",dbProvider:"sqlite",backend:"nextjs"},databaseProvider:"sqlite"};async function ze(){let e=y,s=new ht().name(V).description("CLI for scaffolding new web apps with the Lx2 stack").version(D(),"-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: ${xe.join(", ")}`,y.flags.backend).option("--authProvider [provider]",`Choose an authentication provider to use. Possible values: ${Se.join(", ")}`,y.flags.authentication).option("--databaseORM [orm]",`Choose a database ORM to use. Possible values: ${Pe.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: ${L.join(", ")}`,y.flags.dbProvider).parse(process.argv);process.env.npm_config_user_agent?.startsWith("yarn/3")&&l.warn(` WARNING: It looks like you are using Yarn 3. This is currently not supported,
|
|
57
57
|
and likely to result in a crash. Please run create-lx2-app with another
|
|
58
58
|
package manager such as pnpm, npm, or Yarn Classic.
|
|
59
59
|
See: https://github.com/t3-oss/create-t3-app/issues/57`);let a=s.args[0];if(a&&(e.appName=a),e.flags=s.opts(),e.flags.CI){switch(e.packages=[],e.flags.backend==="payload"&&e.packages.push("payload"),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 L.includes(e.flags.dbProvider)===!1&&(l.warn(`Incompatible database provided. Use: ${L.join(", ")}. Exiting.`),process.exit(0)),e.flags.backend==="payload"&&e.flags.dbProvider==="mysql"&&(l.warn("Payload CMS does not support MySQL. Exiting."),process.exit(0)),e}if(e.flags.default)return e;try{if(process.env.TERM_PROGRAM?.toLowerCase().includes("mintty"))throw l.warn(` WARNING: It looks like you are using MinTTY, which is non-interactive. This is most likely because you are
|
|
60
60
|
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 E("Non-interactive environment");let i=b(),t={};a||(t.name=await Ie({message:"What will your project be called?",default:O,validate:o=>Ae(o)})),t.backend=await
|
|
62
|
-
Using: ${
|
|
61
|
+
can provide the arguments from the CLI directly: https://create.lx2.dev/docs/getting-started#experimental-ci-flags to skip the prompts.`),new E("Non-interactive environment");let i=b(),t={};a||(t.name=await Ie({message:"What will your project be called?",default:O,validate:o=>Ae(o)})),t.backend=await T({message:"What backend framework would you like to use?",choices:[{value:"nextjs",name:"Next.js"},{value:"payload",name:"Payload CMS"}],default:y.flags.backend}),t.backend==="payload"&&(t.databaseProvider=await T({message:"What database provider would you like to use?",choices:[{value:"sqlite",name:"SQLite"},{value:"postgresql",name:"PostgreSQL"}],default:y.flags.dbProvider})),t.backend==="nextjs"&&(t.authentication=await T({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}),t.orm=await T({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}),t.orm!=="none"&&(t.databaseProvider=await T({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}))),t.linter=await T({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||(t.git=await Q({message:"Should we initialize a Git repository and stage the changes?",default:!y.flags.git})),e.flags.install||(t.install=await Q({message:`Should we run '${i}`+(i==="yarn"?"'?":" install' for you?"),default:!y.flags.install})),t.importAlias=await Ie({message:"What import alias would you like to use?",default:y.flags.importAlias,validate:je});let n=[];switch(t.backend==="payload"&&n.push("payload"),t.authentication){case"authjs":n.push("authjs");break;case"betterAuth":n.push("betterAuth");break;default:break}switch(t.orm){case"prisma":n.push("prisma");break;case"drizzle":n.push("drizzle");break;default:break}switch(t.linter){case"eslint/prettier":n.push("eslint/prettier");break;case"biome":n.push("biome");break;default:break}return{appName:t.name??e.appName,packages:n,flags:{...e.flags,git:t.git??e.flags.git,install:t.install??e.flags.install,importAlias:t.importAlias??e.flags.importAlias},databaseProvider:t.databaseProvider??"sqlite"}}catch(i){if(i instanceof E)l.warn(`${V} needs an interactive terminal to run.`),await Q({message:"Continue scaffolding with default options?",default:!0})||(l.info("Exiting..."),process.exit(0)),l.info(`Scaffolding default lx2 app in ./${e.appName}`);else throw i}return e}import kt from"path";import Ce from"chalk";import yt from"ora";function De(e){let{packages:s}=e;l.info("Adding boilerplate...");for(let[a,i]of Object.entries(s))if(i.inUse){let t=yt(`Boilerplating ${a}...`).start();i.installer(e),t.succeed(Ce.green(`${Ce.green.bold(a)}`))}l.info("")}import X from"path";import{confirm as bt,select as vt}from"@inquirer/prompts";import z from"chalk";import q from"fs-extra";import wt from"ora";async function Te({projectName:e,projectDir:s,pkgManager:a,install:i}){let t=X.join(c,"template/base");i?l.info(""):l.info(`
|
|
62
|
+
Using: ${z.cyan.bold(a)}
|
|
63
63
|
`);let n=wt(`Scaffolding in: ${s}...
|
|
64
|
-
`).start();if(
|
|
65
|
-
`);else{n.stopAndPersist();let r=await vt({message:`${
|
|
66
|
-
`),
|
|
67
|
-
`)}import x from"path";import Z from"fs-extra";function Oe({packages:e,projectDir:s}){let a=x.join(c,"template/packages/src/app/layout"),i=e.payload.inUse,n=x.join(a,"base.tsx"),o=x.join(s,`src/app/${i?"(frontend)":""}/layout.tsx`);Z.copySync(n,o)}function Re({packages:e,projectDir:s}){let a=x.join(c,"template/packages/src/app/page"),i=e.payload.inUse,t=e.authjs.inUse,n=e.betterAuth.inUse,o=e.prisma.inUse,r=e.drizzle.inUse,p="base.tsx";i&&(p="with-payload.tsx"),t&&(p="with-authjs.tsx"),n&&(p="with-better-auth.tsx"),o&&(p="with-prisma.tsx"),t&&o&&(p="with-authjs-prisma.tsx"),n&&o&&(p="with-better-auth-prisma.tsx"),r&&(p="with-drizzle.tsx"),t&&r&&(p="with-authjs-drizzle.tsx"),n&&r&&(p="with-better-auth-drizzle.tsx");let f=x.join(a,p),
|
|
68
|
-
`).start(),a=se(e),i=await ie(e),t=ee.parse(e).name;if(i&&a){if(s.stop(),!await
|
|
69
|
-
`)}catch{s.fail(`${
|
|
70
|
-
`)}}import At from"chalk";import{execa as Fe}from"execa";import Le from"ora";var ae=async(e,s,a)=>{let{onDataHandle:i,args:t=["install"],stdout:n="pipe"}=a,o=Le(`Running ${s} install...`).start(),r=Fe(s,t,{cwd:e,stdout:n});return await new Promise((p,f)=>{i&&r.stdout?.on("data",i(o)),r.on("error",
|
|
71
|
-
`))};var Ne=async({projectName:e=O,packages:s,install:a,projectDir:i,databaseProvider:t})=>{let n=b();l.info("Next steps:"),e!=="."&&l.info(` cd ${e}`),a===!1&&(n==="yarn"?l.info(` ${n}`):l.info(` ${n} install`)),["postgresql","mysql"].includes(t)&&l.info(" Add your database connection string to .env"),s?.authjs.inUse&&l.info(" Fill in your .env with necessary values. See https://create.lx2.dev/docs/first-steps for more info."),s?.betterAuth.inUse&&l.info(" Fill in your .env with necessary values. See https://create.lx2.dev/docs/first-steps for more info."),s?.prisma.inUse&&l.info(` Run "${n} db:push" to create you database tables.`),["npm"].includes(n)?l.info(` ${n} run dev`):l.info(` ${n} dev`),!await ie(i)&&!se(i)&&l.info(" git init"),l.info(' git commit -m "initial commit"')};import G from"fs";import It from"path";function Ge(e,s,a){G.readdirSync(e).forEach(t=>{let n=It.join(e,t);if(G.statSync(n).isDirectory())Ge(n,s,a);else{let r=G.readFileSync(n,"utf8").replace(new RegExp(s,"g"),a);G.writeFileSync(n,r,"utf8")}})}function We(e,s){let a=s.replace(/\*/g,"").replace(/[^\/]$/,"$&/");Ge(e,"@/",a)}import Je from"path";function Ve(e){let a=N(e).split("/"),i=a[a.length-1];if(i==="."){let o=Je.resolve(process.cwd());i=Je.basename(o)}let t=a.findIndex(o=>o.startsWith("@"));a.findIndex(o=>o.startsWith("@"))!==-1&&(i=a.slice(t).join("/"));let n=a.filter(o=>!o.startsWith("@")).join("/");return[i,n]}import zt from"gradient-string";var Ct={primary:"#bf95f9",accent:"#6071a4",secondary:"#ff7ac5"};function He(){let e=zt(Object.values(Ct)),s=b();(s==="yarn"||s==="pnpm")&&console.log(""),console.log(e.multiline(oe))}import{execSync as Dt}from"child_process";import Tt from"https";function Ke(e){let s=
|
|
64
|
+
`).start();if(q.existsSync(s))if(q.readdirSync(s).length===0)e!=="."&&n.info(`${z.cyan.bold(e)} exists but is empty, continuing...
|
|
65
|
+
`);else{n.stopAndPersist();let r=await vt({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"&&(n.fail("Aborting installation..."),process.exit(1)),await bt({message:`Are you sure you want to ${r==="clear"?"clear the directory":"overwrite conflicting files"}`,default:!1})||(n.fail("Aborting installation..."),process.exit(1)),r==="clear"&&(n.info(`Emptying ${z.cyan.bold(e)} and creating lx2 app...
|
|
66
|
+
`),q.emptyDirSync(s))}n.start(),q.copySync(t,s),q.renameSync(X.join(s,"_gitignore"),X.join(s,".gitignore"));let o=e==="."?"App":z.cyan.bold(e);n.succeed(`${o} ${z.green.bold("scaffolded successfully!")}
|
|
67
|
+
`)}import x from"path";import Z from"fs-extra";function Oe({packages:e,projectDir:s}){let a=x.join(c,"template/packages/src/app/layout"),i=e.payload.inUse,n=x.join(a,"base.tsx"),o=x.join(s,`src/app/${i?"(frontend)":""}/layout.tsx`);Z.copySync(n,o)}function Re({packages:e,projectDir:s}){let a=x.join(c,"template/packages/src/app/page"),i=e.payload.inUse,t=e.authjs.inUse,n=e.betterAuth.inUse,o=e.prisma.inUse,r=e.drizzle.inUse,p="base.tsx";i&&(p="with-payload.tsx"),t&&(p="with-authjs.tsx"),n&&(p="with-better-auth.tsx"),o&&(p="with-prisma.tsx"),t&&o&&(p="with-authjs-prisma.tsx"),n&&o&&(p="with-better-auth-prisma.tsx"),r&&(p="with-drizzle.tsx"),t&&r&&(p="with-authjs-drizzle.tsx"),n&&r&&(p="with-better-auth-drizzle.tsx");let f=x.join(a,p),u=x.join(s,`src/app/${i?"(frontend)":""}/page.tsx`);Z.copySync(f,u)}function Ee({projectDir:e}){let s=x.join(c,"template/packages/src/styles"),i=x.join(s,"base.css"),t=x.join(e,"src/styles/globals.css");Z.copySync(i,t)}async function qe({projectName:e,scopedAppName:s,packages:a,install:i,databaseProvider:t}){let n=b(),o=kt.resolve(process.cwd(),e);return await Te({projectName:e,projectDir:o,pkgManager:n,scopedAppName:s,install:i,databaseProvider:t}),De({projectName:e,scopedAppName:s,projectDir:o,pkgManager:n,packages:a,install:i,databaseProvider:t}),Oe({packages:a,projectDir:o}),Re({packages:a,projectDir:o}),Ee({packages:a,projectDir:o}),o}import{execSync as te}from"child_process";import ee from"path";import{confirm as Me}from"@inquirer/prompts";import M from"chalk";import{execa as U}from"execa";import Ue from"fs-extra";import xt from"ora";function St(e){try{return te("git --version",{cwd:e}),!0}catch{return!1}}function se(e){return Ue.existsSync(ee.join(e,".git"))}async function ie(e){try{return await U("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}}function Pt(){let s=te("git --version").toString().trim().split(" ")[2],a=s?.split(".")[0],i=s?.split(".")[1];return{major:Number(a),minor:Number(i)}}function _t(){return te("git config --global init.defaultBranch || echo main").toString().trim()}async function $e(e){if(l.info("Initializing Git..."),!St(e)){l.warn("Git is not installed. Skipping Git initialization.");return}let s=xt(`Creating a new git repo...
|
|
68
|
+
`).start(),a=se(e),i=await ie(e),t=ee.parse(e).name;if(i&&a){if(s.stop(),!await Me({message:`${M.redBright.bold("Warning:")} Git is already initialized in "${t}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`,default:!1})){s.info("Skipping Git initialization.");return}Ue.removeSync(ee.join(e,".git"))}else if(i&&!a&&(s.stop(),!await Me({message:`${M.redBright.bold("Warning:")} "${t}" is already in a git worktree. Would you still like to initialize a new git repository in this directory?`,default:!1}))){s.info("Skipping Git initialization.");return}try{let n=_t(),{major:o,minor:r}=Pt();o<2||o==2&&r<28?(await U("git",["init"],{cwd:e}),await U("git",["symbolic-ref","HEAD",`refs/heads/${n}`],{cwd:e})):await U("git",["init",`--initial-branch=${n}`],{cwd:e}),await U("git",["add","."],{cwd:e}),s.succeed(`${M.green("Successfully initialized and staged")} ${M.green.bold("git")}
|
|
69
|
+
`)}catch{s.fail(`${M.bold.red("Failed:")} could not initialize git. Update git to the latest version!
|
|
70
|
+
`)}}import At from"chalk";import{execa as Fe}from"execa";import Le from"ora";var ae=async(e,s,a)=>{let{onDataHandle:i,args:t=["install"],stdout:n="pipe"}=a,o=Le(`Running ${s} install...`).start(),r=Fe(s,t,{cwd:e,stdout:n});return await new Promise((p,f)=>{i&&r.stdout?.on("data",i(o)),r.on("error",u=>f(u)),r.on("close",()=>p())}),o},jt=async(e,s)=>{switch(e){case"npm":return await Fe(e,["install"],{cwd:s,stderr:"inherit"}),null;case"pnpm":return ae(s,e,{onDataHandle:a=>i=>{let t=i.toString();t.includes("Progress")&&(a.text=t.includes("|")?t.split(" | ")[1]??"":t)}});case"yarn":return ae(s,e,{onDataHandle:a=>i=>{a.text=i.toString()}});case"bun":return ae(s,e,{stdout:"ignore"})}},Be=async({projectDir:e})=>{l.info("Installing dependencies...");let s=b();(await jt(s,e)??Le()).succeed(At.green(`Successfully installed dependencies!
|
|
71
|
+
`))};var Ne=async({projectName:e=O,packages:s,install:a,projectDir:i,databaseProvider:t})=>{let n=b();l.info("Next steps:"),e!=="."&&l.info(` cd ${e}`),a===!1&&(n==="yarn"?l.info(` ${n}`):l.info(` ${n} install`)),["postgresql","mysql"].includes(t)&&l.info(" Add your database connection string to .env"),s?.authjs.inUse&&l.info(" Fill in your .env with necessary values. See https://create.lx2.dev/docs/first-steps for more info."),s?.betterAuth.inUse&&l.info(" Fill in your .env with necessary values. See https://create.lx2.dev/docs/first-steps for more info."),s?.prisma.inUse&&l.info(` Run "${n} db:push" to create you database tables.`),["npm"].includes(n)?l.info(` ${n} run dev`):l.info(` ${n} dev`),!await ie(i)&&!se(i)&&l.info(" git init"),l.info(' git commit -m "initial commit"')};import G from"fs";import It from"path";function Ge(e,s,a){G.readdirSync(e).forEach(t=>{let n=It.join(e,t);if(G.statSync(n).isDirectory())Ge(n,s,a);else{let r=G.readFileSync(n,"utf8").replace(new RegExp(s,"g"),a);G.writeFileSync(n,r,"utf8")}})}function We(e,s){let a=s.replace(/\*/g,"").replace(/[^\/]$/,"$&/");Ge(e,"@/",a)}import Je from"path";function Ve(e){let a=N(e).split("/"),i=a[a.length-1];if(i==="."){let o=Je.resolve(process.cwd());i=Je.basename(o)}let t=a.findIndex(o=>o.startsWith("@"));a.findIndex(o=>o.startsWith("@"))!==-1&&(i=a.slice(t).join("/"));let n=a.filter(o=>!o.startsWith("@")).join("/");return[i,n]}import zt from"gradient-string";var Ct={primary:"#bf95f9",accent:"#6071a4",secondary:"#ff7ac5"};function He(){let e=zt(Object.values(Ct)),s=b();(s==="yarn"||s==="pnpm")&&console.log(""),console.log(e.multiline(oe))}import{execSync as Dt}from"child_process";import Tt from"https";function Ke(e){let s=D();s.includes("beta")?(l.warn(" You are using a beta version of create-lx2-app."),l.warn(" Please report any bugs you encounter.")):s!==e&&(l.warn(" You are using an outdated version of create-lx2-app."),l.warn(" Your version:",s+".","Latest version in the npm registry:",e),l.warn(" Please run the CLI with @latest to get the latest updates.")),console.log("")}function Ot(){return new Promise((e,s)=>{Tt.get("https://registry.npmjs.org/-/package/create-lx2-app/dist-tags",a=>{if(a.statusCode===200){let i="";a.on("data",t=>i+=t),a.on("end",()=>{e(JSON.parse(i).latest)})}else s()}).on("error",()=>{s()})})}var Ye=()=>Ot().catch(()=>{try{return Dt("npm view create-lx2-app version").toString().trim()}catch{return null}});async function Et(){let e=await Ye(),s=b();He(),e&&Ke(e);let{appName:a,packages:i,flags:{git:t,install:n,importAlias:o},databaseProvider:r}=await ze(),p=_e(i),[f,u]=Ve(a),d=await qe({projectName:u,scopedAppName:f,packages:p,install:n,databaseProvider:r}),g=Xe.readJsonSync(Qe.join(d,"package.json"));if(g.name=f,g.clx2aMetadata={initVersion:D()},s!=="bun"){let{stdout:h}=await Rt(s,["-v"],{cwd:d});g.packageManager=`${s}@${h.trim()}`}Xe.writeJSONSync(Qe.join(d,"package.json"),g,{spaces:2}),o!=="@/"&&We(d,o),n&&await Be({projectDir:d}),t&&await $e(d),await Ne({projectDir:d,projectName:u,packages:p,install:n,databaseProvider:r}),process.exit(0)}Et().catch(e=>{l.error("Aborting installation..."),e instanceof Error?l.error(e.message):(l.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.db923f0",
|
|
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",
|
|
@@ -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() {
|