create-lx2-app 0.11.3 → 0.11.4-beta.8b33b2b

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.
Files changed (3) hide show
  1. package/dist/index.js +7 -7
  2. package/package.json +98 -98
  3. package/LICENSE.md +0 -20
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import Ye from"path";import{execa as Rt}from"execa";import Qe from"fs-extra";imp
3
3
  / __| _ \\ __| /_\\_ _| __| | | __ __|_ ) /_\\ | _ \\ _ \\
4
4
  | (__| / _| / _ \\| | | _| | |__\\ \\ / / / / _ \\| _/ _/
5
5
  \\___|_|_\\___/_/ \\_\\_| |___| |____/_\\_\\/___| /_/ \\_\\_| |_|
6
- `,O="my-lx2-app",J="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 P from"path";import V from"fs-extra";var oe={"next-auth":"^5.0.0-beta.25","@auth/prisma-adapter":"^2.11.1","@auth/drizzle-adapter":"^1.11.1","better-auth":"^1.4.1","better-sqlite3":"^12.4.6","@types/better-sqlite3":"^7.6.13",prisma:"^7.0.0","@prisma/client":"^7.0.0","drizzle-orm":"^0.44.7","drizzle-kit":"^0.31.7","@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.6.2","prettier-plugin-tailwindcss":"^0.7.1","@ianvs/prettier-plugin-sort-imports":"^4.7.0",eslint:"^9.39.1","eslint-config-next":"^16.0.4","@eslint/eslintrc":"^3.3.1","@biomejs/biome":"^2.3.7",typescript:"^5.9.3","@types/node":"^24.10.2","@types/react":"^19.2.7","@types/react-dom":"^19.2.3",payload:"^3.64.0","@payloadcms/next":"^3.64.0","@payloadcms/payload-cloud":"^3.64.0","@payloadcms/richtext-lexical":"^3.64.0","@payloadcms/db-vercel-postgres":"^3.64.0","@payloadcms/db-sqlite":"^3.64.0",graphql:"^16.12.0",sharp:"^0.34.5"};import re from"path";import le from"fs-extra";import ot from"sort-package-json";var u=e=>{let{dependencies:s,devMode:a,projectDir:i}=e,t=le.readJsonSync(re.join(i,"package.json"));s.forEach(o=>{let r=oe[o];a&&t.devDependencies?t.devDependencies[o]=r:t.dependencies&&(t.dependencies[o]=r)});let n=ot(t);le.writeJsonSync(re.join(i,"package.json"),n,{spaces:2})};var pe=({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"),u({projectDir:e,dependencies:t,devMode:!1});let n=P.join(c,"template/packages"),o="src/app/api/auth/[...nextauth]/route.ts",r=P.join(n,o),p=P.join(e,o),d=P.join(n,"src/server/auth/config",a?"authjs-with-prisma.ts":i?"authjs-with-drizzle.ts":"authjs.ts"),m=P.join(e,"src/server/auth/config.ts"),f=P.join(n,"src/server/auth/authjs.ts"),h=P.join(e,"src/server/auth/index.ts");V.copySync(r,p),V.copySync(d,m),V.copySync(f,h)};import x from"path";import R from"fs-extra";import rt from"path";import ce 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=ce.readJSONSync(i);t.scripts={...t.scripts,...s};let n=lt(t);ce.writeJSONSync(i,n,{spaces:2})}var de=({projectDir:e,packages:s,databaseProvider:a})=>{let i=s?.prisma.inUse,t=s?.drizzle.inUse,n=["better-auth"],o=[];(!i||!t)&&n.push("better-sqlite3"),(!i||!t)&&o.push("@types/better-sqlite3"),u({projectDir:e,dependencies:n,devMode:!1}),u({projectDir:e,dependencies:o,devMode:!0});let r=x.join(c,"template/packages"),p=x.join(r,"src/app/api/auth/[...betterauth]/route.ts"),d=x.join(e,"src/app/api/auth/[...all]/route.ts"),m=x.join(r,"src/server/auth",i?"better-auth-with-prisma.ts":t?"better-auth-with-drizzle.ts":"better-auth.ts"),f=R.readFileSync(m,"utf-8");(i||t)&&a!=="sqlite"&&(f=f.replace('provider: "sqlite",',`provider: "${{mysql:"mysql",postgresql:t?"pg":"postgresql"}[a]}",`));let h=x.join(e,"src/server/auth/index.ts");R.mkdirSync(x.dirname(h),{recursive:!0}),R.writeFileSync(h,f);let y=x.join(r,"src/lib/auth/better-auth-client.ts"),T=x.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(p,d),R.copySync(y,T)};import H from"path";import pt from"fs-extra";var me=({projectDir:e})=>{u({projectDir:e,dependencies:["@biomejs/biome"],devMode:!0});let s=H.join(c,"template/packages"),a=H.join(s,"config/biome.jsonc"),i=H.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 S from"path";import _ from"fs-extra";var fe=({projectDir:e,packages:s,scopedAppName:a,databaseProvider:i})=>{let t=s?.authjs.inUse,n=s?.betterAuth.inUse;u({projectDir:e,dependencies:["drizzle-kit"],devMode:!0}),u({projectDir:e,dependencies:["drizzle-orm",{sqlite:"@libsql/client",mysql:"mysql2",postgresql:"postgres"}[i]],devMode:!1});let o=S.join(c,"template/packages"),r=S.join(o,"config/drizzle",{sqlite:"with-sqlite",mysql:"with-mysql",postgresql:"with-postgresql"}[i]+".ts"),p=S.join(e,"drizzle.config.ts"),d=S.join(o,"src/server/db/schema-drizzle",t?`with-authjs-${i}.ts`:n?`with-better-auth-${i}.ts`:`base-${i}.ts`),m=S.join(e,"src/server/db/schema.ts"),f=_.readFileSync(d,"utf-8");f=f.replace("project1_${name}",`${a}_\${name}`);let h=_.readFileSync(r,"utf-8");h=h.replace("project1_*",`${a}_*`);let y=S.join(o,`src/server/db/index-drizzle/with-${i}.ts`),T=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"}}),_.copySync(r,p),_.mkdirSync(S.dirname(m),{recursive:!0}),_.writeFileSync(m,f),_.writeFileSync(p,h),_.copySync(y,T)};import $ from"path";import K from"fs-extra";var ue=({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,d=a?.payload.inUse,m=[];t&&(m.push("@t3-oss/env-nextjs"),m.push("zod")),u({projectDir:e,dependencies:m,devMode:!1});let f=r||p||d,h=ct(!!n,!!o,!!r,!!p,!!d,s,i),y="";if(f?n?y="with-authjs-db.js":o?y="with-better-auth-db.js":d?y="with-payload.js":y="with-db.js":n?y="with-authjs.js":o&&(y="with-better-auth.js"),y!==""){let tt=$.join(c,"template/packages/src/env",y),st=$.join(e,"src/env.ts");K.copyFileSync(tt,st)}let T=$.join(e,".env"),Xe=$.join(e,".env.example"),Ze=dt+h,W=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("base64"),et=h.replace('AUTH_SECRET=""',`AUTH_SECRET="${W}" # Generated by create-lx2-app`).replace('BETTER_AUTH_SECRET=""',`BETTER_AUTH_SECRET="${W}" # Generated by create-lx2-app`).replace('PAYLOAD_SECRET=""',`PAYLOAD_SECRET="${W}" # Generated by create-lx2-app`);K.writeFileSync(T,et,"utf-8"),K.writeFileSync(Xe,Ze,"utf-8")};function ct(e,s,a,i,t,n,o){let r=`
6
+ `,O="my-lx2-app",J="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 S from"path";import V from"fs-extra";var oe={"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","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 re from"path";import le from"fs-extra";import ot from"sort-package-json";var u=e=>{let{dependencies:s,devMode:a,projectDir:i}=e,t=le.readJsonSync(re.join(i,"package.json"));s.forEach(o=>{let r=oe[o];a&&t.devDependencies?t.devDependencies[o]=r:t.dependencies&&(t.dependencies[o]=r)});let n=ot(t);le.writeJsonSync(re.join(i,"package.json"),n,{spaces:2})};var pe=({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"),u({projectDir:e,dependencies:t,devMode:!1});let n=S.join(c,"template/packages"),o="src/app/api/auth/[...nextauth]/route.ts",r=S.join(n,o),p=S.join(e,o),d=S.join(n,"src/server/auth/config",a?"authjs-with-prisma.ts":i?"authjs-with-drizzle.ts":"authjs.ts"),m=S.join(e,"src/server/auth/config.ts"),f=S.join(n,"src/server/auth/authjs.ts"),h=S.join(e,"src/server/auth/index.ts");V.copySync(r,p),V.copySync(d,m),V.copySync(f,h)};import x from"path";import R from"fs-extra";import rt from"path";import ce 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=ce.readJSONSync(i);t.scripts={...t.scripts,...s};let n=lt(t);ce.writeJSONSync(i,n,{spaces:2})}var de=({projectDir:e,packages:s,databaseProvider:a})=>{let i=s?.prisma.inUse,t=s?.drizzle.inUse,n=["better-auth"],o=[];(!i||!t)&&n.push("better-sqlite3"),(!i||!t)&&o.push("@types/better-sqlite3"),u({projectDir:e,dependencies:n,devMode:!1}),u({projectDir:e,dependencies:o,devMode:!0});let r=x.join(c,"template/packages"),p=x.join(r,"src/app/api/auth/[...betterauth]/route.ts"),d=x.join(e,"src/app/api/auth/[...all]/route.ts"),m=x.join(r,"src/server/auth",i?"better-auth-with-prisma.ts":t?"better-auth-with-drizzle.ts":"better-auth.ts"),f=R.readFileSync(m,"utf-8");(i||t)&&a!=="sqlite"&&(f=f.replace('provider: "sqlite",',`provider: "${{mysql:"mysql",postgresql:t?"pg":"postgresql"}[a]}",`));let h=x.join(e,"src/server/auth/index.ts");R.mkdirSync(x.dirname(h),{recursive:!0}),R.writeFileSync(h,f);let y=x.join(r,"src/lib/auth/better-auth-client.ts"),T=x.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(p,d),R.copySync(y,T)};import H from"path";import pt from"fs-extra";var me=({projectDir:e})=>{u({projectDir:e,dependencies:["@biomejs/biome"],devMode:!0});let s=H.join(c,"template/packages"),a=H.join(s,"config/biome.jsonc"),i=H.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 P from"path";import _ from"fs-extra";var fe=({projectDir:e,packages:s,scopedAppName:a,databaseProvider:i})=>{let t=s?.authjs.inUse,n=s?.betterAuth.inUse;u({projectDir:e,dependencies:["drizzle-kit"],devMode:!0}),u({projectDir:e,dependencies:["drizzle-orm",{sqlite:"@libsql/client",mysql:"mysql2",postgresql:"postgres"}[i]],devMode:!1});let o=P.join(c,"template/packages"),r=P.join(o,"config/drizzle",{sqlite:"with-sqlite",mysql:"with-mysql",postgresql:"with-postgresql"}[i]+".ts"),p=P.join(e,"drizzle.config.ts"),d=P.join(o,"src/server/db/schema-drizzle",t?`with-authjs-${i}.ts`:n?`with-better-auth-${i}.ts`:`base-${i}.ts`),m=P.join(e,"src/server/db/schema.ts"),f=_.readFileSync(d,"utf-8");f=f.replace("project1_${name}",`${a}_\${name}`);let h=_.readFileSync(r,"utf-8");h=h.replace("project1_*",`${a}_*`);let y=P.join(o,`src/server/db/index-drizzle/with-${i}.ts`),T=P.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"}}),_.copySync(r,p),_.mkdirSync(P.dirname(m),{recursive:!0}),_.writeFileSync(m,f),_.writeFileSync(p,h),_.copySync(y,T)};import $ from"path";import K from"fs-extra";var ue=({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,d=a?.payload.inUse,m=[];t&&(m.push("@t3-oss/env-nextjs"),m.push("zod")),u({projectDir:e,dependencies:m,devMode:!1});let f=r||p||d,h=ct(!!n,!!o,!!r,!!p,!!d,s,i),y="";if(f?n?y="with-authjs-db.js":o?y="with-better-auth-db.js":d?y="with-payload.js":y="with-db.js":n?y="with-authjs.js":o&&(y="with-better-auth.js"),y!==""){let tt=$.join(c,"template/packages/src/env",y),st=$.join(e,"src/env.ts");K.copyFileSync(tt,st)}let T=$.join(e,".env"),Xe=$.join(e,".env.example"),Ze=dt+h,W=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("base64"),et=h.replace('AUTH_SECRET=""',`AUTH_SECRET="${W}" # Generated by create-lx2-app`).replace('BETTER_AUTH_SECRET=""',`BETTER_AUTH_SECRET="${W}" # Generated by create-lx2-app`).replace('PAYLOAD_SECRET=""',`PAYLOAD_SECRET="${W}" # Generated by create-lx2-app`);K.writeFileSync(T,et,"utf-8"),K.writeFileSync(Xe,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(`
@@ -53,19 +53,19 @@ DISCORD_CLIENT_SECRET=""
53
53
  # ".env" and populate it with your secrets.
54
54
  `.trim().concat(`
55
55
 
56
- `);import L from"path";import ge from"fs-extra";var he=({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")),u({projectDir:e,dependencies:i,devMode:!0});let t=L.join(c,"template/packages/config","eslint.config.mjs"),n=L.join(c,"template/packages/config","prettier.config.mjs"),o=L.join(e,"eslint.config.mjs"),r=L.join(e,"prettier.config.mjs");v({projectDir:e,scripts:{"lint:write":"eslint --fix",lint:"eslint",format:"prettier --write ."}}),ge.copyFileSync(t,o),ge.copyFileSync(n,r)};import w from"path";import I from"fs-extra";var ye=({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}u({projectDir:e,dependencies:i,devMode:!1}),u({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");I.copyFileSync(o,r);let p=w.join(n,"src/payload/collections"),d=w.join(e,"src/collections");I.mkdirSync(d,{recursive:!0}),I.copyFileSync(w.join(p,"Media.ts"),w.join(d,"Media.ts")),I.copyFileSync(w.join(p,"Users.ts"),w.join(d,"Users.ts"));let m=w.join(n,"src/app/(payload)"),f=w.join(e,"src/app/(payload)");I.mkdirSync(f,{recursive:!0}),I.copySync(m,f),v({projectDir:e,scripts:{payload:"payload","generate:importmap":"payload generate:importmap","generate:types":"payload generate:types"}})};import A from"path";import z from"fs-extra";var be=({projectDir:e,packages:s,databaseProvider:a})=>{let i=s?.authjs.inUse,t=s?.betterAuth.inUse;u({projectDir:e,dependencies:["prisma"],devMode:!0}),u({projectDir:e,dependencies:["@prisma/client"],devMode:!1});let n=A.join(c,"template/packages"),o=A.join(n,"prisma/schema",`${i?"with-authjs":t?"with-better-auth":"base"}.prisma`),r=z.readFileSync(o,"utf-8");a!=="sqlite"&&(r=r.replace('provider = "sqlite"',`provider = "${{mysql:"mysql",postgresql:"postgresql"}[a]}"`),["mysql"].includes(a)&&(r=r.replace("// @db.Text","@db.Text")));let p=A.join(e,"prisma/schema.prisma");z.mkdirSync(A.dirname(p),{recursive:!0}),z.writeFileSync(p,r);let d=A.join(n,"src/server/db/db-prisma.ts"),m=A.join(e,"src/server/db/index.ts");z.mkdirSync(A.dirname(m),{recursive:!0}),z.writeFileSync(m,z.readFileSync(d,"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 ve from"path";import mt from"fs-extra";var we=({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")),u({projectDir:e,dependencies:t,devMode:!0});let n=ve.join(c,"template/packages/config/tsconfig",`${i?"with-payload":"base"}.json`),o=ve.join(e,"tsconfig.json");mt.copyFileSync(n,o)};var ke=["nextjs","payload"],xe=["none","authjs","betterAuth"],Se=["none","prisma","drizzle"],F=["sqlite","mysql","postgresql"];var Pe=e=>({authjs:{inUse:e.includes("authjs"),installer:pe},betterAuth:{inUse:e.includes("betterAuth"),installer:de},prisma:{inUse:e.includes("prisma"),installer:be},drizzle:{inUse:e.includes("drizzle"),installer:fe},envVariables:{inUse:!0,installer:ue},"eslint/prettier":{inUse:e.includes("eslint/prettier"),installer:he},biome:{inUse:e.includes("biome"),installer:me},typescript:{inUse:!0,installer:we},payload:{inUse:e.includes("payload"),installer:ye}});import ft from"path";import ut from"fs-extra";function C(){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 _e(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 Ae=e=>e.startsWith(".")||e.startsWith("/")?"Import alias can't start with '.' or '/'":!0;var g={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 Ie(){let e=g,s=new ht().name(J).description("CLI for scaffolding new web apps with the Lx2 stack").version(C(),"-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: ${ke.join(", ")}`,g.flags.backend).option("--authProvider [provider]",`Choose an authentication provider to use. Possible values: ${xe.join(", ")}`,g.flags.authentication).option("--databaseORM [orm]",`Choose a database ORM to use. Possible values: ${Se.join(", ")}`,g.flags.orm).option("--linter [linter]",`Choose what linter and formatter to use. Possible values: ${g.flags.linter}`,g.flags.linter).option("-i, --import-alias [alias]","Explicitly tell the CLI to use a custom import alias",g.flags.importAlias).option("--dbProvider [provider]",`Choose a database provider to use. Possible values: ${F.join(", ")}`,g.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,
56
+ `);import L from"path";import ge from"fs-extra";var he=({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")),u({projectDir:e,dependencies:i,devMode:!0});let t=L.join(c,"template/packages/config","eslint.config.mjs"),n=L.join(c,"template/packages/config","prettier.config.mjs"),o=L.join(e,"eslint.config.mjs"),r=L.join(e,"prettier.config.mjs");v({projectDir:e,scripts:{"lint:write":"eslint --fix",lint:"eslint",format:"prettier --write ."}}),ge.copyFileSync(t,o),ge.copyFileSync(n,r)};import w from"path";import I from"fs-extra";var ye=({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}u({projectDir:e,dependencies:i,devMode:!1}),u({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");I.copyFileSync(o,r);let p=w.join(n,"src/payload/collections"),d=w.join(e,"src/collections");I.mkdirSync(d,{recursive:!0}),I.copyFileSync(w.join(p,"Media.ts"),w.join(d,"Media.ts")),I.copyFileSync(w.join(p,"Users.ts"),w.join(d,"Users.ts"));let m=w.join(n,"src/app/(payload)"),f=w.join(e,"src/app/(payload)");I.mkdirSync(f,{recursive:!0}),I.copySync(m,f),v({projectDir:e,scripts:{payload:"payload","generate:importmap":"payload generate:importmap","generate:types":"payload generate:types"}})};import A from"path";import z from"fs-extra";var be=({projectDir:e,packages:s,databaseProvider:a})=>{let i=s?.authjs.inUse,t=s?.betterAuth.inUse;u({projectDir:e,dependencies:["prisma"],devMode:!0}),u({projectDir:e,dependencies:["@prisma/client"],devMode:!1});let n=A.join(c,"template/packages"),o=A.join(n,"prisma/schema",`${i?"with-authjs":t?"with-better-auth":"base"}.prisma`),r=z.readFileSync(o,"utf-8");a!=="sqlite"&&(r=r.replace('provider = "sqlite"',`provider = "${{mysql:"mysql",postgresql:"postgresql"}[a]}"`),["mysql"].includes(a)&&(r=r.replace("// @db.Text","@db.Text")));let p=A.join(e,"prisma/schema.prisma");z.mkdirSync(A.dirname(p),{recursive:!0}),z.writeFileSync(p,r);let d=A.join(n,"src/server/db/db-prisma.ts"),m=A.join(e,"src/server/db/index.ts");z.mkdirSync(A.dirname(m),{recursive:!0}),z.writeFileSync(m,z.readFileSync(d,"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 ve from"path";import mt from"fs-extra";var we=({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")),u({projectDir:e,dependencies:t,devMode:!0});let n=ve.join(c,"template/packages/config/tsconfig",`${i?"with-payload":"base"}.json`),o=ve.join(e,"tsconfig.json");mt.copyFileSync(n,o)};var ke=["nextjs","payload"],xe=["none","authjs","betterAuth"],Pe=["none","prisma","drizzle"],F=["sqlite","mysql","postgresql"];var Se=e=>({authjs:{inUse:e.includes("authjs"),installer:pe},betterAuth:{inUse:e.includes("betterAuth"),installer:de},prisma:{inUse:e.includes("prisma"),installer:be},drizzle:{inUse:e.includes("drizzle"),installer:fe},envVariables:{inUse:!0,installer:ue},"eslint/prettier":{inUse:e.includes("eslint/prettier"),installer:he},biome:{inUse:e.includes("biome"),installer:me},typescript:{inUse:!0,installer:we},payload:{inUse:e.includes("payload"),installer:ye}});import ft from"path";import ut from"fs-extra";function C(){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 _e(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 Ae=e=>e.startsWith(".")||e.startsWith("/")?"Import alias can't start with '.' or '/'":!0;var g={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 Ie(){let e=g,s=new ht().name(J).description("CLI for scaffolding new web apps with the Lx2 stack").version(C(),"-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: ${ke.join(", ")}`,g.flags.backend).option("--authProvider [provider]",`Choose an authentication provider to use. Possible values: ${xe.join(", ")}`,g.flags.authentication).option("--databaseORM [orm]",`Choose a database ORM to use. Possible values: ${Pe.join(", ")}`,g.flags.orm).option("--linter [linter]",`Choose what linter and formatter to use. Possible values: ${g.flags.linter}`,g.flags.linter).option("-i, --import-alias [alias]","Explicitly tell the CLI to use a custom import alias",g.flags.importAlias).option("--dbProvider [provider]",`Choose a database provider to use. Possible values: ${F.join(", ")}`,g.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
- 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){case"payload":e.packages.push("payload");break;default:break}switch(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 F.includes(e.flags.dbProvider)===!1&&(l.warn(`Incompatible database provided. Use: ${F.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
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 F.includes(e.flags.dbProvider)===!1&&(l.warn(`Incompatible database provided. Use: ${F.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 je({message:"What will your project be called?",default:O,validate:o=>_e(o)})),t.backend=await D({message:"What backend framework would you like to use?",choices:[{value:"nextjs",name:"Next.js"},{value:"payload",name:"Payload CMS"}],default:!g.flags.backend}),t.backend==="payload"&&(t.databaseProvider=await D({message:"What database provider would you like to use?",choices:[{value:"sqlite",name:"SQLite"},{value:"postgresql",name:"PostgreSQL"}],default:!g.flags.dbProvider})),t.backend==="nextjs"&&(t.authentication=await D({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:!g.flags.authentication}),t.orm=await D({message:"What database ORM would you like to use?",choices:[{value:"none",name:"None"},{value:"prisma",name:"Prisma"},{value:"drizzle",name:"Drizzle"}],default:!g.flags.orm}),t.orm!=="none"&&(t.databaseProvider=await D({message:"What database provider would you like to use?",choices:[{value:"sqlite",name:"SQLite"},{value:"mysql",name:"MySQL"},{value:"postgresql",name:"PostgreSQL"}],default:!g.flags.dbProvider}))),t.linter=await D({message:"What linter and formatter would you like to use?",choices:[{value:"eslint/prettier",name:"ESLint/Prettier"},{value:"biome",name:"Biome"}],default:!g.flags.linter}),e.flags.git||(t.git=await Y({message:"Should we initialize a Git repository and stage the changes?",default:!g.flags.git})),e.flags.install||(t.install=await Y({message:`Should we run '${i}`+(i==="yarn"?"'?":" install' for you?"),default:!g.flags.install})),t.importAlias=await je({message:"What import alias would you like to use?",default:g.flags.importAlias,validate:Ae});let n=[];switch(t.backend){case"payload":n.push("payload");break;default:break}switch(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(`${J} needs an interactive terminal to run.`),await Y({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 ze from"chalk";import yt from"ora";function Ce(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(ze.green(`${ze.green.bold(a)}`))}l.info("")}import Q from"path";import{confirm as bt,select as vt}from"@inquirer/prompts";import j from"chalk";import M from"fs-extra";import wt from"ora";async function De({projectName:e,projectDir:s,pkgManager:a,install:i}){let t=Q.join(c,"template/base");i?l.info(""):l.info(`
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 je({message:"What will your project be called?",default:O,validate:o=>_e(o)})),t.backend=await D({message:"What backend framework would you like to use?",choices:[{value:"nextjs",name:"Next.js"},{value:"payload",name:"Payload CMS"}],default:g.flags.backend}),t.backend==="payload"&&(t.databaseProvider=await D({message:"What database provider would you like to use?",choices:[{value:"sqlite",name:"SQLite"},{value:"postgresql",name:"PostgreSQL"}],default:g.flags.dbProvider})),t.backend==="nextjs"&&(t.authentication=await D({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:g.flags.authentication}),t.orm=await D({message:"What database ORM would you like to use?",choices:[{value:"none",name:"None"},{value:"prisma",name:"Prisma"},{value:"drizzle",name:"Drizzle"}],default:g.flags.orm}),t.orm!=="none"&&(t.databaseProvider=await D({message:"What database provider would you like to use?",choices:[{value:"sqlite",name:"SQLite"},{value:"mysql",name:"MySQL"},{value:"postgresql",name:"PostgreSQL"}],default:g.flags.dbProvider}))),t.linter=await D({message:"What linter and formatter would you like to use?",choices:[{value:"eslint/prettier",name:"ESLint/Prettier"},{value:"biome",name:"Biome"}],default:g.flags.linter}),e.flags.git||(t.git=await Y({message:"Should we initialize a Git repository and stage the changes?",default:!g.flags.git})),e.flags.install||(t.install=await Y({message:`Should we run '${i}`+(i==="yarn"?"'?":" install' for you?"),default:!g.flags.install})),t.importAlias=await je({message:"What import alias would you like to use?",default:g.flags.importAlias,validate:Ae});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(`${J} needs an interactive terminal to run.`),await Y({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 ze from"chalk";import yt from"ora";function Ce(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(ze.green(`${ze.green.bold(a)}`))}l.info("")}import Q from"path";import{confirm as bt,select as vt}from"@inquirer/prompts";import j from"chalk";import M from"fs-extra";import wt from"ora";async function De({projectName:e,projectDir:s,pkgManager:a,install:i}){let t=Q.join(c,"template/base");i?l.info(""):l.info(`
62
62
  Using: ${j.cyan.bold(a)}
63
63
  `);let n=wt(`Scaffolding in: ${s}...
64
64
  `).start();if(M.existsSync(s))if(M.readdirSync(s).length===0)e!=="."&&n.info(`${j.cyan.bold(e)} exists but is empty, continuing...
65
65
  `);else{n.stopAndPersist();let r=await vt({message:`${j.redBright.bold("Warning:")} ${j.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 ${j.cyan.bold(e)} and creating lx2 app...
66
66
  `),M.emptyDirSync(s))}n.start(),M.copySync(t,s),M.renameSync(Q.join(s,"_gitignore"),Q.join(s,".gitignore"));let o=e==="."?"App":j.cyan.bold(e);n.succeed(`${o} ${j.green.bold("scaffolded successfully!")}
67
- `)}import k from"path";import X from"fs-extra";function Te({packages:e,projectDir:s}){let a=k.join(c,"template/packages/src/app/layout"),i=e.payload.inUse,n=k.join(a,"base.tsx"),o=k.join(s,`src/app/${i?"(frontend)":""}/layout.tsx`);X.copySync(n,o)}function Oe({packages:e,projectDir:s}){let a=k.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 d=k.join(a,p),m=k.join(s,`src/app/${i?"(frontend)":""}/page.tsx`);X.copySync(d,m)}function Re({projectDir:e}){let s=k.join(c,"template/packages/src/styles"),i=k.join(s,"base.css"),t=k.join(e,"src/styles/globals.css");X.copySync(i,t)}async function Ee({projectName:e,scopedAppName:s,packages:a,install:i,databaseProvider:t}){let n=b(),o=kt.resolve(process.cwd(),e);return await De({projectName:e,projectDir:o,pkgManager:n,scopedAppName:s,install:i,databaseProvider:t}),Ce({projectName:e,scopedAppName:s,projectDir:o,pkgManager:n,packages:a,install:i,databaseProvider:t}),Te({packages:a,projectDir:o}),Oe({packages:a,projectDir:o}),Re({packages:a,projectDir:o}),o}import{execSync as ee}from"child_process";import Z from"path";import{confirm as Me}from"@inquirer/prompts";import U from"chalk";import{execa as q}from"execa";import Ue from"fs-extra";import xt from"ora";function St(e){try{return ee("git --version",{cwd:e}),!0}catch{return!1}}function te(e){return Ue.existsSync(Z.join(e,".git"))}async function se(e){try{return await q("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}}function Pt(){let s=ee("git --version").toString().trim().split(" ")[2],a=s?.split(".")[0],i=s?.split(".")[1];return{major:Number(a),minor:Number(i)}}function _t(){return ee("git config --global init.defaultBranch || echo main").toString().trim()}async function qe(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=te(e),i=await se(e),t=Z.parse(e).name;if(i&&a){if(s.stop(),!await Me({message:`${U.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(Z.join(e,".git"))}else if(i&&!a&&(s.stop(),!await Me({message:`${U.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 q("git",["init"],{cwd:e}),await q("git",["symbolic-ref","HEAD",`refs/heads/${n}`],{cwd:e})):await q("git",["init",`--initial-branch=${n}`],{cwd:e}),await q("git",["add","."],{cwd:e}),s.succeed(`${U.green("Successfully initialized and staged")} ${U.green.bold("git")}
67
+ `)}import k from"path";import X from"fs-extra";function Te({packages:e,projectDir:s}){let a=k.join(c,"template/packages/src/app/layout"),i=e.payload.inUse,n=k.join(a,"base.tsx"),o=k.join(s,`src/app/${i?"(frontend)":""}/layout.tsx`);X.copySync(n,o)}function Oe({packages:e,projectDir:s}){let a=k.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 d=k.join(a,p),m=k.join(s,`src/app/${i?"(frontend)":""}/page.tsx`);X.copySync(d,m)}function Re({projectDir:e}){let s=k.join(c,"template/packages/src/styles"),i=k.join(s,"base.css"),t=k.join(e,"src/styles/globals.css");X.copySync(i,t)}async function Ee({projectName:e,scopedAppName:s,packages:a,install:i,databaseProvider:t}){let n=b(),o=kt.resolve(process.cwd(),e);return await De({projectName:e,projectDir:o,pkgManager:n,scopedAppName:s,install:i,databaseProvider:t}),Ce({projectName:e,scopedAppName:s,projectDir:o,pkgManager:n,packages:a,install:i,databaseProvider:t}),Te({packages:a,projectDir:o}),Oe({packages:a,projectDir:o}),Re({packages:a,projectDir:o}),o}import{execSync as ee}from"child_process";import Z from"path";import{confirm as Me}from"@inquirer/prompts";import U from"chalk";import{execa as q}from"execa";import Ue from"fs-extra";import xt from"ora";function Pt(e){try{return ee("git --version",{cwd:e}),!0}catch{return!1}}function te(e){return Ue.existsSync(Z.join(e,".git"))}async function se(e){try{return await q("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}}function St(){let s=ee("git --version").toString().trim().split(" ")[2],a=s?.split(".")[0],i=s?.split(".")[1];return{major:Number(a),minor:Number(i)}}function _t(){return ee("git config --global init.defaultBranch || echo main").toString().trim()}async function qe(e){if(l.info("Initializing Git..."),!Pt(e)){l.warn("Git is not installed. Skipping Git initialization.");return}let s=xt(`Creating a new git repo...
68
+ `).start(),a=te(e),i=await se(e),t=Z.parse(e).name;if(i&&a){if(s.stop(),!await Me({message:`${U.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(Z.join(e,".git"))}else if(i&&!a&&(s.stop(),!await Me({message:`${U.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}=St();o<2||o==2&&r<28?(await q("git",["init"],{cwd:e}),await q("git",["symbolic-ref","HEAD",`refs/heads/${n}`],{cwd:e})):await q("git",["init",`--initial-branch=${n}`],{cwd:e}),await q("git",["add","."],{cwd:e}),s.succeed(`${U.green("Successfully initialized and staged")} ${U.green.bold("git")}
69
69
  `)}catch{s.fail(`${U.bold.red("Failed:")} could not initialize git. Update git to the latest version!
70
70
  `)}}import At from"chalk";import{execa as $e}from"execa";import Le from"ora";var ie=async(e,s,a)=>{let{onDataHandle:i,args:t=["install"],stdout:n="pipe"}=a,o=Le(`Running ${s} install...`).start(),r=$e(s,t,{cwd:e,stdout:n});return await new Promise((p,d)=>{i&&r.stdout?.on("data",i(o)),r.on("error",m=>d(m)),r.on("close",()=>p())}),o},jt=async(e,s)=>{switch(e){case"npm":return await $e(e,["install"],{cwd:s,stderr:"inherit"}),null;case"pnpm":return ie(s,e,{onDataHandle:a=>i=>{let t=i.toString();t.includes("Progress")&&(a.text=t.includes("|")?t.split(" | ")[1]??"":t)}});case"yarn":return ie(s,e,{onDataHandle:a=>i=>{a.text=i.toString()}});case"bun":return ie(s,e,{stdout:"ignore"})}},Fe=async({projectDir:e})=>{l.info("Installing dependencies...");let s=b();(await jt(s,e)??Le()).succeed(At.green(`Successfully installed dependencies!
71
- `))};var Be=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 se(i)&&!te(i)&&l.info(" git init"),l.info(' git commit -m "initial commit"')};import G from"fs";import It from"path";function Ne(e,s,a){G.readdirSync(e).forEach(t=>{let n=It.join(e,t);if(G.statSync(n).isDirectory())Ne(n,s,a);else{let r=G.readFileSync(n,"utf8").replace(new RegExp(s,"g"),a);G.writeFileSync(n,r,"utf8")}})}function Ge(e,s){let a=s.replace(/\*/g,"").replace(/[^\/]$/,"$&/");Ne(e,"@/",a)}import We from"path";function Je(e){let a=N(e).split("/"),i=a[a.length-1];if(i==="."){let o=We.resolve(process.cwd());i=We.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 Ve(){let e=zt(Object.values(Ct)),s=b();(s==="yarn"||s==="pnpm")&&console.log(""),console.log(e.multiline(ne))}import{execSync as Dt}from"child_process";import Tt from"https";function He(e){let s=C();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 Ke=()=>Ot().catch(()=>{try{return Dt("npm view create-lx2-app version").toString().trim()}catch{return null}});async function Et(){let e=await Ke(),s=b();Ve(),e&&He(e);let{appName:a,packages:i,flags:{git:t,install:n,importAlias:o},databaseProvider:r}=await Ie(),p=Pe(i),[d,m]=Je(a),f=await Ee({projectName:m,scopedAppName:d,packages:p,install:n,databaseProvider:r}),h=Qe.readJsonSync(Ye.join(f,"package.json"));if(h.name=d,h.clx2aMetadata={initVersion:C()},s!=="bun"){let{stdout:y}=await Rt(s,["-v"],{cwd:f});h.packageManager=`${s}@${y.trim()}`}Qe.writeJSONSync(Ye.join(f,"package.json"),h,{spaces:2}),o!=="@/"&&Ge(f,o),n&&await Fe({projectDir:f}),t&&await qe(f),await Be({projectDir:f,projectName:m,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)});
71
+ `))};var Be=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 se(i)&&!te(i)&&l.info(" git init"),l.info(' git commit -m "initial commit"')};import G from"fs";import It from"path";function Ne(e,s,a){G.readdirSync(e).forEach(t=>{let n=It.join(e,t);if(G.statSync(n).isDirectory())Ne(n,s,a);else{let r=G.readFileSync(n,"utf8").replace(new RegExp(s,"g"),a);G.writeFileSync(n,r,"utf8")}})}function Ge(e,s){let a=s.replace(/\*/g,"").replace(/[^\/]$/,"$&/");Ne(e,"@/",a)}import We from"path";function Je(e){let a=N(e).split("/"),i=a[a.length-1];if(i==="."){let o=We.resolve(process.cwd());i=We.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 Ve(){let e=zt(Object.values(Ct)),s=b();(s==="yarn"||s==="pnpm")&&console.log(""),console.log(e.multiline(ne))}import{execSync as Dt}from"child_process";import Tt from"https";function He(e){let s=C();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 Ke=()=>Ot().catch(()=>{try{return Dt("npm view create-lx2-app version").toString().trim()}catch{return null}});async function Et(){let e=await Ke(),s=b();Ve(),e&&He(e);let{appName:a,packages:i,flags:{git:t,install:n,importAlias:o},databaseProvider:r}=await Ie(),p=Se(i),[d,m]=Je(a),f=await Ee({projectName:m,scopedAppName:d,packages:p,install:n,databaseProvider:r}),h=Qe.readJsonSync(Ye.join(f,"package.json"));if(h.name=d,h.clx2aMetadata={initVersion:C()},s!=="bun"){let{stdout:y}=await Rt(s,["-v"],{cwd:f});h.packageManager=`${s}@${y.trim()}`}Qe.writeJSONSync(Ye.join(f,"package.json"),h,{spaces:2}),o!=="@/"&&Ge(f,o),n&&await Fe({projectDir:f}),t&&await qe(f),await Be({projectDir:f,projectName:m,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,99 +1,99 @@
1
1
  {
2
- "name": "create-lx2-app",
3
- "version": "0.11.3",
4
- "description": "The Most Opinionated Way to Build Next.js Apps",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/slickyeet/create-lx2-app",
9
- "directory": "cli"
10
- },
11
- "keywords": [
12
- "create-lx2-app",
13
- "lx2-app",
14
- "typescript",
15
- "next.js",
16
- "tailwind"
17
- ],
18
- "type": "module",
19
- "exports": "./dist/index.js",
20
- "bin": {
21
- "create-lx2-app": "./dist/index.js"
22
- },
23
- "files": [
24
- "dist",
25
- "template",
26
- "README.md",
27
- "LICENSE",
28
- "package.json"
29
- ],
30
- "engines": {
31
- "node": ">=18"
32
- },
33
- "dependencies": {
34
- "@inquirer/prompts": "^8.0.1",
35
- "chalk": "^5.6.2",
36
- "commander": "^14.0.2",
37
- "execa": "^9.6.0",
38
- "fs-extra": "^11.3.2",
39
- "gradient-string": "^3.0.0",
40
- "ora": "^9.0.0",
41
- "sort-package-json": "^3.4.0"
42
- },
43
- "devDependencies": {
44
- "@auth/drizzle-adapter": "^1.11.1",
45
- "@auth/prisma-adapter": "^2.11.1",
46
- "@biomejs/biome": "^2.3.7",
47
- "@eslint/eslintrc": "^3.3.1",
48
- "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
49
- "@libsql/client": "^0.15.15",
50
- "@payloadcms/db-sqlite": "^3.64.0",
51
- "@payloadcms/db-vercel-postgres": "^3.64.0",
52
- "@payloadcms/next": "^3.64.0",
53
- "@payloadcms/payload-cloud": "^3.64.0",
54
- "@payloadcms/richtext-lexical": "^3.64.0",
55
- "@prisma/client": "^7.0.0",
56
- "@t3-oss/env-nextjs": "^0.13.8",
57
- "@types/better-sqlite3": "^7.6.13",
58
- "@types/fs-extra": "^11.0.4",
59
- "@types/node": "^24.10.2",
60
- "@types/react": "^19.2.7",
61
- "@types/react-dom": "^19.2.3",
62
- "better-auth": "^1.4.1",
63
- "better-sqlite3": "^12.4.6",
64
- "drizzle-kit": "^0.31.7",
65
- "drizzle-orm": "^0.44.7",
66
- "eslint": "^9.39.1",
67
- "eslint-config-next": "^16.0.4",
68
- "graphql": "^16.12.0",
69
- "mysql2": "^3.15.3",
70
- "next": "^16.0.8",
71
- "next-auth": "^5.0.0-beta.25",
72
- "payload": "^3.64.0",
73
- "postgres": "^3.4.7",
74
- "prettier": "^3.6.2",
75
- "prettier-plugin-tailwindcss": "^0.7.1",
76
- "prisma": "^7.0.0",
77
- "react": "^19.2.1",
78
- "react-dom": "^19.2.1",
79
- "sharp": "^0.34.5",
80
- "tailwindcss": "^4.1.17",
81
- "tsup": "^8.5.1",
82
- "type-fest": "^5.2.0",
83
- "typescript": "^5.9.3",
84
- "zod": "^4.1.13"
85
- },
86
- "scripts": {
87
- "dev": "tsup --watch",
88
- "build": "tsup",
89
- "start": "node dist/index.js",
90
- "format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
91
- "format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
92
- "typecheck": "tsc",
93
- "clean": "rm -rf dist .turbo node_modules",
94
- "link": "pnpm run build && npm link",
95
- "release": "changeset version",
96
- "pub:beta": "pnpm run build && npm publish --tag beta",
97
- "pub:release": "pnpm run build && npm publish"
98
- }
99
- }
2
+ "name": "create-lx2-app",
3
+ "version": "0.11.4-beta.8b33b2b",
4
+ "description": "The Most Opinionated Way to Build Next.js Apps",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/slickyeet/create-lx2-app",
9
+ "directory": "cli"
10
+ },
11
+ "keywords": [
12
+ "create-lx2-app",
13
+ "lx2-app",
14
+ "typescript",
15
+ "next.js",
16
+ "tailwind"
17
+ ],
18
+ "type": "module",
19
+ "exports": "./dist/index.js",
20
+ "bin": {
21
+ "create-lx2-app": "./dist/index.js"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "template",
26
+ "README.md",
27
+ "LICENSE",
28
+ "package.json"
29
+ ],
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "scripts": {
34
+ "dev": "tsup --watch",
35
+ "build": "tsup",
36
+ "start": "node dist/index.js",
37
+ "format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
38
+ "format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
39
+ "typecheck": "tsc",
40
+ "clean": "rm -rf dist .turbo node_modules",
41
+ "link": "pnpm run build && npm link",
42
+ "release": "changeset version",
43
+ "pub:beta": "pnpm run build && npm publish --tag beta",
44
+ "pub:release": "pnpm run build && npm publish"
45
+ },
46
+ "dependencies": {
47
+ "@inquirer/prompts": "^8.1.0",
48
+ "chalk": "^5.6.2",
49
+ "commander": "^14.0.2",
50
+ "execa": "^9.6.1",
51
+ "fs-extra": "^11.3.3",
52
+ "gradient-string": "^3.0.0",
53
+ "ora": "^9.0.0",
54
+ "sort-package-json": "^3.6.0"
55
+ },
56
+ "devDependencies": {
57
+ "@auth/drizzle-adapter": "^1.11.1",
58
+ "@auth/prisma-adapter": "^2.11.1",
59
+ "@biomejs/biome": "^2.3.10",
60
+ "@eslint/eslintrc": "^3.3.3",
61
+ "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
62
+ "@libsql/client": "^0.15.15",
63
+ "@payloadcms/db-sqlite": "^3.69.0",
64
+ "@payloadcms/db-vercel-postgres": "^3.69.0",
65
+ "@payloadcms/next": "^3.69.0",
66
+ "@payloadcms/payload-cloud": "^3.69.0",
67
+ "@payloadcms/richtext-lexical": "^3.69.0",
68
+ "@prisma/client": "^7.2.0",
69
+ "@t3-oss/env-nextjs": "^0.13.10",
70
+ "@types/better-sqlite3": "^7.6.13",
71
+ "@types/fs-extra": "^11.0.4",
72
+ "@types/node": "^25.0.3",
73
+ "@types/react": "^19.2.7",
74
+ "@types/react-dom": "^19.2.3",
75
+ "better-auth": "^1.4.10",
76
+ "better-sqlite3": "^12.5.0",
77
+ "drizzle-kit": "^0.31.8",
78
+ "drizzle-orm": "^0.45.1",
79
+ "eslint": "^9.39.2",
80
+ "eslint-config-next": "^16.1.1",
81
+ "graphql": "^16.12.0",
82
+ "mysql2": "^3.16.0",
83
+ "next": "^16.1.1",
84
+ "next-auth": "^5.0.0-beta.25",
85
+ "payload": "^3.69.0",
86
+ "postgres": "^3.4.7",
87
+ "prettier": "^3.7.4",
88
+ "prettier-plugin-tailwindcss": "^0.7.2",
89
+ "prisma": "^7.2.0",
90
+ "react": "^19.2.3",
91
+ "react-dom": "^19.2.3",
92
+ "sharp": "^0.34.5",
93
+ "tailwindcss": "^4.1.18",
94
+ "tsup": "^8.5.1",
95
+ "type-fest": "^5.3.1",
96
+ "typescript": "^5.9.3",
97
+ "zod": "^4.3.4"
98
+ }
99
+ }
package/LICENSE.md DELETED
@@ -1,20 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Lasse Lammers
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.