create-better-t-stack 1.11.0 → 1.12.0

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 (2) hide show
  1. package/dist/index.js +88 -81
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as j,intro as us,log as I,outro as ms,spinner as fs}from"@clack/prompts";import{Command as hs}from"commander";import h from"picocolors";import we from"node:path";import{fileURLToPath as zt}from"node:url";var K=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var Nt=zt(import.meta.url),Ut=we.dirname(Nt),v=we.join(Ut,"../"),y={projectName:"my-better-t-app",frontend:["tanstack-router"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:K(),noInstall:!1,dbSetup:"none",backend:"hono",runtime:"bun"},ne={"better-auth":"^1.2.4","@better-auth/expo":"^1.2.5","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",pg:"^8.14.1","@types/pg":"^8.11.11",mysql2:"^3.14.0","@prisma/client":"^6.5.0",prisma:"^6.5.0","vite-plugin-pwa":"^0.21.2","@vite-pwa/assets-generator":"^0.2.6","@tauri-apps/cli":"^2.4.0","@biomejs/biome":"1.9.4",husky:"^9.1.7","lint-staged":"^15.5.0","@hono/node-server":"^1.14.0",tsx:"^4.19.2","@types/node":"^22.13.11","@types/bun":"^1.2.6","@elysiajs/node":"^1.2.6","@elysiajs/cors":"^1.2.0","@elysiajs/trpc":"^1.1.0",elysia:"^1.2.25","@hono/trpc-server":"^0.3.4",hono:"^4.7.5",cors:"^2.8.5",express:"^5.1.0","@types/express":"^5.0.1","@types/cors":"^2.8.17",ai:"^4.2.8","@ai-sdk/google":"^1.2.3","@prisma/extension-accelerate":"^1.3.0"};import or from"node:path";import{cancel as ir,spinner as cr}from"@clack/prompts";import pr from"fs-extra";import ot from"picocolors";import F from"node:path";import k from"fs-extra";import _t from"node:path";import Pe from"fs-extra";var g=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,s=_t.join(r,"package.json"),n=Pe.readJSONSync(s);n.dependencies||(n.dependencies={}),n.devDependencies||(n.devDependencies={});for(let o of a){let i=ne[o];n.dependencies[o]=i}for(let o of t){let i=ne[o];n.devDependencies[o]=i}Pe.writeJSONSync(s,n,{spaces:2})};import qt from"node:path";import{log as Vt,spinner as Gt}from"@clack/prompts";import{execa as Wt}from"execa";import ye from"picocolors";async function je(e,a){let t=Gt();try{t.start("Setting up Starlight documentation site...");let r,s;switch(a){case"npm":r="npx",s=["create-astro@latest"];break;case"pnpm":r="pnpm",s=["dlx","create-astro@latest"];break;case"bun":r="bunx",s=["create-astro@latest"];break;default:r="npx",s=["create-astro@latest"]}s=[...s,"docs","--template","starlight","--no-install","--add","tailwind","--no-git","--skip-houston"],await Wt(r,s,{cwd:qt.join(e,"apps"),env:{CI:"true"}}),t.stop("Starlight documentation site setup successfully!")}catch(r){throw t.stop(ye.red("Failed to set up Starlight documentation site")),r instanceof Error&&Vt.error(ye.red(r.message)),r}}import X from"node:path";import{log as Jt,spinner as Ht}from"@clack/prompts";import{execa as Qt}from"execa";import Y from"fs-extra";import ve from"picocolors";async function ke(e,a,t){let r=Ht(),s=X.join(e,"apps/web");if(await Y.pathExists(s))try{r.start("Setting up Tauri desktop app support..."),g({devDependencies:["@tauri-apps/cli"],projectDir:s});let n=X.join(s,"package.json");if(await Y.pathExists(n)){let d=await Y.readJson(n);d.scripts={...d.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await Y.writeJson(n,d,{spaces:2})}let o,i;switch(a){case"npm":o="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":o="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":o="bunx",i=["@tauri-apps/cli@latest"];break;default:o="npx",i=["@tauri-apps/cli@latest"]}let c=t.includes("react-router")?"http://localhost:5173":"http://localhost:3001";i=[...i,"init",`--app-name=${X.basename(e)}`,`--window-title=${X.basename(e)}`,"--frontend-dist=dist",`--dev-url=${c}`,`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await Qt(o,i,{cwd:s,env:{CI:"true"}}),r.stop("Tauri desktop app support configured successfully!")}catch(n){throw r.stop(ve.red("Failed to set up Tauri")),n instanceof Error&&Jt.error(ve.red(n.message)),n}}async function xe(e,a,t,r){let s=r.includes("react-router")||r.includes("tanstack-router");a.includes("pwa")&&s&&await Zt(e,r),a.includes("tauri")&&s&&await ke(e,t,r),a.includes("biome")&&await Xt(e),a.includes("husky")&&await Yt(e),a.includes("starlight")&&await je(e,t)}function Kt(e,a){return F.join(e,"apps/web")}async function Xt(e){let a=F.join(v,"template/with-biome");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),g({devDependencies:["@biomejs/biome"],projectDir:e});let t=F.join(e,"package.json");if(await k.pathExists(t)){let r=await k.readJson(t);r.scripts={...r.scripts,check:"biome check --write ."},await k.writeJson(t,r,{spaces:2})}}async function Yt(e){let a=F.join(v,"template/with-husky");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),g({devDependencies:["husky","lint-staged"],projectDir:e});let t=F.join(e,"package.json");if(await k.pathExists(t)){let r=await k.readJson(t);r.scripts={...r.scripts,prepare:"husky"},r["lint-staged"]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":["biome check --write ."]},await k.writeJson(t,r,{spaces:2})}}async function Zt(e,a){let t=F.join(v,"template/with-pwa");await k.pathExists(t)&&await k.copy(t,e,{overwrite:!0});let r=Kt(e,a);if(!await k.pathExists(r))return;g({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:r});let s=F.join(r,"vite.config.ts");if(await k.pathExists(s)){let o=await k.readFile(s,"utf8");if(!o.includes("vite-plugin-pwa")){let p=o.match(/^import .* from ['"](.*)['"]/m);p?o=o.replace(p[0],`import { VitePWA } from "vite-plugin-pwa";
2
+ import{cancel as j,intro as Dn,log as F,outro as Cn,spinner as Rn}from"@clack/prompts";import{Command as Fn}from"commander";import h from"picocolors";import xe from"node:path";import{fileURLToPath as Jt}from"node:url";var Y=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var Ht=Jt(import.meta.url),Qt=xe.dirname(Ht),v=xe.join(Qt,"../"),P={projectName:"my-better-t-app",frontend:["tanstack-router"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:Y(),noInstall:!1,dbSetup:"none",backend:"hono",runtime:"bun"},ce={"better-auth":"^1.2.4","@better-auth/expo":"^1.2.5","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",pg:"^8.14.1","@types/pg":"^8.11.11",mysql2:"^3.14.0","@prisma/client":"^6.5.0",prisma:"^6.5.0","vite-plugin-pwa":"^0.21.2","@vite-pwa/assets-generator":"^0.2.6","@tauri-apps/cli":"^2.4.0","@biomejs/biome":"1.9.4",husky:"^9.1.7","lint-staged":"^15.5.0","@hono/node-server":"^1.14.0",tsx:"^4.19.2","@types/node":"^22.13.11","@types/bun":"^1.2.6","@elysiajs/node":"^1.2.6","@elysiajs/cors":"^1.2.0","@elysiajs/trpc":"^1.1.0",elysia:"^1.2.25","@hono/trpc-server":"^0.3.4",hono:"^4.7.5",cors:"^2.8.5",express:"^5.1.0","@types/express":"^5.0.1","@types/cors":"^2.8.17",ai:"^4.2.8","@ai-sdk/google":"^1.2.3","@prisma/extension-accelerate":"^1.3.0"};import xr from"node:path";import{cancel as kr,spinner as $r}from"@clack/prompts";import Ar from"fs-extra";import ft from"picocolors";import I from"node:path";import x from"fs-extra";import Kt from"node:path";import ke from"fs-extra";var g=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,n=Kt.join(r,"package.json"),s=ke.readJSONSync(n);s.dependencies||(s.dependencies={}),s.devDependencies||(s.devDependencies={});for(let o of a){let i=ce[o];s.dependencies[o]=i}for(let o of t){let i=ce[o];s.devDependencies[o]=i}ke.writeJSONSync(n,s,{spaces:2})};import Xt from"node:path";import{log as Yt,spinner as Zt}from"@clack/prompts";import{execa as ea}from"execa";import $e from"picocolors";async function Ae(e,a){let t=Zt();try{t.start("Setting up Starlight documentation site...");let r,n;switch(a){case"npm":r="npx",n=["create-astro@latest"];break;case"pnpm":r="pnpm",n=["dlx","create-astro@latest"];break;case"bun":r="bunx",n=["create-astro@latest"];break;default:r="npx",n=["create-astro@latest"]}n=[...n,"docs","--template","starlight","--no-install","--add","tailwind","--no-git","--skip-houston"],await ea(r,n,{cwd:Xt.join(e,"apps"),env:{CI:"true"}}),t.stop("Starlight documentation site setup successfully!")}catch(r){throw t.stop($e.red("Failed to set up Starlight documentation site")),r instanceof Error&&Yt.error($e.red(r.message)),r}}import Z from"node:path";import{log as ta,spinner as aa}from"@clack/prompts";import{execa as ra}from"execa";import ee from"fs-extra";import Se from"picocolors";async function Ee(e,a,t){let r=aa(),n=Z.join(e,"apps/web");if(await ee.pathExists(n))try{r.start("Setting up Tauri desktop app support..."),g({devDependencies:["@tauri-apps/cli"],projectDir:n});let s=Z.join(n,"package.json");if(await ee.pathExists(s)){let d=await ee.readJson(s);d.scripts={...d.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await ee.writeJson(s,d,{spaces:2})}let o,i;switch(a){case"npm":o="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":o="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":o="bunx",i=["@tauri-apps/cli@latest"];break;default:o="npx",i=["@tauri-apps/cli@latest"]}let c=t.includes("react-router")?"http://localhost:5173":"http://localhost:3001";i=[...i,"init",`--app-name=${Z.basename(e)}`,`--window-title=${Z.basename(e)}`,"--frontend-dist=dist",`--dev-url=${c}`,`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ra(o,i,{cwd:n,env:{CI:"true"}}),r.stop("Tauri desktop app support configured successfully!")}catch(s){throw r.stop(Se.red("Failed to set up Tauri")),s instanceof Error&&ta.error(Se.red(s.message)),s}}async function Te(e,a,t,r){let n=r.includes("react-router")||r.includes("tanstack-router");a.includes("pwa")&&n&&await ia(e,r),a.includes("tauri")&&n&&await Ee(e,t,r),a.includes("biome")&&await sa(e),a.includes("husky")&&await oa(e),a.includes("starlight")&&await Ae(e,t)}function na(e,a){return I.join(e,"apps/web")}async function sa(e){let a=I.join(v,"template/with-biome");await x.pathExists(a)&&await x.copy(a,e,{overwrite:!0}),g({devDependencies:["@biomejs/biome"],projectDir:e});let t=I.join(e,"package.json");if(await x.pathExists(t)){let r=await x.readJson(t);r.scripts={...r.scripts,check:"biome check --write ."},await x.writeJson(t,r,{spaces:2})}}async function oa(e){let a=I.join(v,"template/with-husky");await x.pathExists(a)&&await x.copy(a,e,{overwrite:!0}),g({devDependencies:["husky","lint-staged"],projectDir:e});let t=I.join(e,"package.json");if(await x.pathExists(t)){let r=await x.readJson(t);r.scripts={...r.scripts,prepare:"husky"},r["lint-staged"]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":["biome check --write ."]},await x.writeJson(t,r,{spaces:2})}}async function ia(e,a){let t=I.join(v,"template/with-pwa");await x.pathExists(t)&&await x.copy(t,e,{overwrite:!0});let r=na(e,a);if(!await x.pathExists(r))return;g({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:r});let n=I.join(r,"vite.config.ts");if(await x.pathExists(n)){let o=await x.readFile(n,"utf8");if(!o.includes("vite-plugin-pwa")){let p=o.match(/^import .* from ['"](.*)['"]/m);p?o=o.replace(p[0],`import { VitePWA } from "vite-plugin-pwa";
3
3
  ${p[0]}`):o=`import { VitePWA } from "vite-plugin-pwa";
4
4
  ${o}`}let i=`VitePWA({
5
5
  registerType: "autoUpdate",
@@ -21,13 +21,13 @@ ${o}`}let i=`VitePWA({
21
21
  ${i}`):a.includes("tanstack-router")?o=o.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
22
22
  tailwindcss(),
23
23
  ${i}`):o=o.replace(/plugins: \[/,`plugins: [
24
- ${i},`)),await k.writeFile(s,o)}let n=F.join(r,"package.json");if(await k.pathExists(n)){let o=await k.readJson(n);o.scripts={...o.scripts,"generate-pwa-assets":"pwa-assets-generator"},await k.writeJson(n,o,{spaces:2})}}import oe from"node:path";import{log as $e}from"@clack/prompts";import Ae from"picocolors";function Se(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",r=a.length;for(let s=0;s<e;s++)t+=a.charAt(Math.floor(Math.random()*r));return t}async function Ee(e,a,t=[]){if(!a)return;let r=oe.join(e,"apps/server"),s=oe.join(e,"apps/web"),n=oe.join(e,"apps/native");try{g({dependencies:["better-auth"],projectDir:r}),(t.includes("react-router")||t.includes("tanstack-router")||t.includes("tanstack-start"))&&g({dependencies:["better-auth"],projectDir:s}),t.includes("native")&&(g({dependencies:["better-auth","@better-auth/expo"],projectDir:n}),g({dependencies:["@better-auth/expo"],projectDir:r}))}catch(o){throw $e.error(Ae.red("Failed to configure authentication")),o instanceof Error&&$e.error(Ae.red(o.message)),o}}import ea from"node:path";async function Te(e,a,t){let r=ea.join(e,"apps/server"),s=[],n=[];a==="hono"?(s.push("hono","@hono/trpc-server"),t==="node"&&(s.push("@hono/node-server"),n.push("tsx","@types/node"))):a==="elysia"?(s.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(s.push("@elysiajs/node"),n.push("tsx","@types/node"))):a==="express"&&(s.push("express","cors"),n.push("@types/express","@types/cors"),t==="node"&&n.push("tsx","@types/node")),t==="bun"&&n.push("@types/bun"),g({dependencies:s,devDependencies:n,projectDir:r})}import ta from"node:path";import aa from"fs-extra";async function De(e,a){let t=ta.join(e,"README.md"),r=ra(a);try{await aa.writeFile(t,r)}catch(s){console.error("Failed to create README.md file:",s)}}function ra(e){let{projectName:a,packageManager:t,database:r,auth:s,addons:n=[],orm:o="drizzle",runtime:i="bun",frontend:p=["tanstack-router"]}=e,c=p.includes("react-router"),d=p.includes("tanstack-router"),w=p.includes("native"),$=t==="npm"?"npm run":t,A=c?"5173":"3001";return`# ${a}
24
+ ${i},`)),await x.writeFile(n,o)}let s=I.join(r,"package.json");if(await x.pathExists(s)){let o=await x.readJson(s);o.scripts={...o.scripts,"generate-pwa-assets":"pwa-assets-generator"},await x.writeJson(s,o,{spaces:2})}}import pe from"node:path";import{log as De}from"@clack/prompts";import Ce from"picocolors";function Re(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",r=a.length;for(let n=0;n<e;n++)t+=a.charAt(Math.floor(Math.random()*r));return t}async function Fe(e,a,t=[]){if(!a)return;let r=pe.join(e,"apps/server"),n=pe.join(e,"apps/web"),s=pe.join(e,"apps/native");try{g({dependencies:["better-auth"],projectDir:r}),(t.includes("react-router")||t.includes("tanstack-router")||t.includes("tanstack-start"))&&g({dependencies:["better-auth"],projectDir:n}),t.includes("native")&&(g({dependencies:["better-auth","@better-auth/expo"],projectDir:s}),g({dependencies:["@better-auth/expo"],projectDir:r}))}catch(o){throw De.error(Ce.red("Failed to configure authentication")),o instanceof Error&&De.error(Ce.red(o.message)),o}}import ca from"node:path";async function Ie(e,a,t){let r=ca.join(e,"apps/server"),n=[],s=[];a==="hono"?(n.push("hono","@hono/trpc-server"),t==="node"&&(n.push("@hono/node-server"),s.push("tsx","@types/node"))):a==="elysia"?(n.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(n.push("@elysiajs/node"),s.push("tsx","@types/node"))):a==="express"&&(n.push("express","cors"),s.push("@types/express","@types/cors"),t==="node"&&s.push("tsx","@types/node")),t==="bun"&&s.push("@types/bun"),g({dependencies:n,devDependencies:s,projectDir:r})}import pa from"node:path";import la from"fs-extra";async function Oe(e,a){let t=pa.join(e,"README.md"),r=da(a);try{await la.writeFile(t,r)}catch(n){console.error("Failed to create README.md file:",n)}}function da(e){let{projectName:a,packageManager:t,database:r,auth:n,addons:s=[],orm:o="drizzle",runtime:i="bun",frontend:p=["tanstack-router"]}=e,c=p.includes("react-router"),d=p.includes("tanstack-router"),w=p.includes("native"),$=t==="npm"?"npm run":t,A=c?"5173":"3001";return`# ${a}
25
25
 
26
26
  This project was created with [Better-T-Stack](https://github.com/AmanVarshney01/create-better-t-stack), a modern TypeScript stack that combines React, ${d?"TanStack Router":"React Router"}, Hono, tRPC, and more.
27
27
 
28
28
  ## Features
29
29
 
30
- ${sa(r,s,n,o,i,p)}
30
+ ${ua(r,n,s,o,i,p)}
31
31
 
32
32
  ## Getting Started
33
33
 
@@ -37,7 +37,7 @@ First, install the dependencies:
37
37
  ${t} install
38
38
  \`\`\`
39
39
 
40
- ${na(r,s,$,o)}
40
+ ${ma(r,n,$,o)}
41
41
 
42
42
  Then, run the development server:
43
43
 
@@ -50,7 +50,7 @@ ${w?`Use the Expo Go app to run the mobile application.
50
50
  `:""}
51
51
  The API is running at [http://localhost:3000](http://localhost:3000).
52
52
 
53
- ${n.includes("pwa")&&c?`
53
+ ${s.includes("pwa")&&c?`
54
54
  ## PWA Support with React Router v7
55
55
 
56
56
  There is a known compatibility issue between VitePWA and React Router v7.
@@ -69,11 +69,11 @@ ${d||c?`\u2502 \u251C\u2500\u2500 web/ # Frontend application (React,
69
69
 
70
70
  ## Available Scripts
71
71
 
72
- ${oa($,r,o,s,w)}
73
- `}function sa(e,a,t,r,s,n){let o=n.includes("tanstack-router"),i=n.includes("react-router"),p=n.includes("native"),c=["- **TypeScript** - For type safety and improved developer experience"];o?c.push("- **TanStack Router** - File-based routing with full type safety"):i&&c.push("- **React Router** - Declarative routing for React"),p&&(c.push("- **React Native** - Build mobile apps using React"),c.push("- **Expo** - Tools for React Native development")),c.push("- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs",`- **${s==="bun"?"Bun":"Node.js"}** - Runtime environment`),e!=="none"&&c.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&c.push("- **Authentication** - Email & password authentication with Better Auth");for(let d of t)d==="pwa"?c.push("- **PWA** - Progressive Web App support"):d==="tauri"?c.push("- **Tauri** - Build native desktop applications"):d==="biome"?c.push("- **Biome** - Linting and formatting"):d==="husky"&&c.push("- **Husky** - Git hooks for code quality");return c.join(`
74
- `)}function na(e,a,t,r){if(e==="none")return"";let s=`## Database Setup
72
+ ${fa($,r,o,n,w)}
73
+ `}function ua(e,a,t,r,n,s){let o=s.includes("tanstack-router"),i=s.includes("react-router"),p=s.includes("native"),c=["- **TypeScript** - For type safety and improved developer experience"];o?c.push("- **TanStack Router** - File-based routing with full type safety"):i&&c.push("- **React Router** - Declarative routing for React"),p&&(c.push("- **React Native** - Build mobile apps using React"),c.push("- **Expo** - Tools for React Native development")),c.push("- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs",`- **${n==="bun"?"Bun":"Node.js"}** - Runtime environment`),e!=="none"&&c.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&c.push("- **Authentication** - Email & password authentication with Better Auth");for(let d of t)d==="pwa"?c.push("- **PWA** - Progressive Web App support"):d==="tauri"?c.push("- **Tauri** - Build native desktop applications"):d==="biome"?c.push("- **Biome** - Linting and formatting"):d==="husky"&&c.push("- **Husky** - Git hooks for code quality");return c.join(`
74
+ `)}function ma(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
75
75
 
76
- `;return e==="sqlite"?s+=`This project uses SQLite${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
76
+ `;return e==="sqlite"?n+=`This project uses SQLite${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
77
77
 
78
78
  1. Start the local SQLite database:
79
79
  \`\`\`bash
@@ -81,11 +81,11 @@ cd apps/server && ${t} db:local
81
81
  \`\`\`
82
82
 
83
83
  2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed.
84
- `:e==="postgres"&&(s+=`This project uses PostgreSQL${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
84
+ `:e==="postgres"&&(n+=`This project uses PostgreSQL${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
85
85
 
86
86
  1. Make sure you have a PostgreSQL database set up.
87
87
  2. Update your \`apps/server/.env\` file with your PostgreSQL connection details.
88
- `),s+=`
88
+ `),n+=`
89
89
  ${a?"4":"3"}. ${r==="prisma"?`Generate the Prisma client and push the schema:
90
90
  \`\`\`bash
91
91
  ${t} db:push
@@ -93,42 +93,49 @@ ${t} db:push
93
93
  \`\`\`bash
94
94
  ${t} db:push
95
95
  \`\`\``}
96
- `,s}function oa(e,a,t,r,s){let n=`- \`${e} dev\`: Start both web and server in development mode
96
+ `,n}function fa(e,a,t,r,n){let s=`- \`${e} dev\`: Start both web and server in development mode
97
97
  - \`${e} build\`: Build both web and server
98
98
  - \`${e} dev:web\`: Start only the web application
99
99
  - \`${e} dev:server\`: Start only the server
100
- - \`${e} check-types\`: Check TypeScript types across all apps`;return s&&(n+=`
101
- - \`${e} dev:native\`: Start the React Native/Expo development server`),a!=="none"&&(n+=`
100
+ - \`${e} check-types\`: Check TypeScript types across all apps`;return n&&(s+=`
101
+ - \`${e} dev:native\`: Start the React Native/Expo development server`),a!=="none"&&(s+=`
102
102
  - \`${e} db:push\`: Push schema changes to database
103
- - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(n+=`
104
- - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),n}import ze from"node:path";import{log as Ca,spinner as Ra}from"@clack/prompts";import Ia from"fs-extra";import Ne from"picocolors";import Ie from"node:path";import{cancel as ia,isCancel as ca,log as z,text as pa}from"@clack/prompts";import{execa as la}from"execa";import ie from"fs-extra";import q from"picocolors";import{execa as Ce}from"execa";async function Z(e){try{return process.platform==="win32"?(await Ce("where",[e])).exitCode===0:(await Ce("which",[e])).exitCode===0}catch{return!1}}async function da(){return Z("atlas")}async function ua(e){try{if(!await da())return z.error(q.red("MongoDB Atlas CLI not found.")),z.info(q.yellow("Please install it from: https://www.mongodb.com/docs/atlas/cli/current/install-atlas-cli/")),null;z.info(q.yellow("Setting up MongoDB Atlas...")),await la("atlas",["deployments","setup"],{cwd:e,stdio:"inherit"});let t=await pa({message:"Paste your complete MongoDB connection string:",placeholder:"mongodb://USERNAME:PASSWORD@HOST/DATABASE",validate(r){if(!r)return"Please enter a connection string";if(!r.startsWith("mongodb"))return"URL should start with mongodb"}});return ca(t)?(ia("MongoDB setup cancelled"),null):{connectionString:t}}catch(a){return a instanceof Error&&z.error(q.red(a.message)),null}}async function ce(e,a){let t=Ie.join(e,"apps/server",".env"),r="";await ie.pathExists(t)&&(r=await ie.readFile(t,"utf8"));let s=a?`DATABASE_URL="${a.connectionString}"`:'DATABASE_URL="mongodb://localhost:27017/mydb"';r.includes("DATABASE_URL=")?r=r.replace(/DATABASE_URL=.*(\r?\n|$)/,`${s}$1`):r+=`
105
- ${s}`,await ie.writeFile(t,r.trim())}function Re(){z.info(`MongoDB Atlas Setup:
103
+ - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(s+=`
104
+ - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),s}import Je from"node:path";import{log as Ha,spinner as Qa}from"@clack/prompts";import Ka from"fs-extra";import He from"picocolors";import Me from"node:path";import{cancel as ha,isCancel as ga,log as z,text as ba}from"@clack/prompts";import{execa as wa}from"execa";import le from"fs-extra";import G from"picocolors";import{execa as Be}from"execa";async function te(e){try{return process.platform==="win32"?(await Be("where",[e])).exitCode===0:(await Be("which",[e])).exitCode===0}catch{return!1}}async function ya(){return te("atlas")}async function Pa(e){try{if(!await ya())return z.error(G.red("MongoDB Atlas CLI not found.")),z.info(G.yellow("Please install it from: https://www.mongodb.com/docs/atlas/cli/current/install-atlas-cli/")),null;z.info(G.yellow("Setting up MongoDB Atlas...")),await wa("atlas",["deployments","setup"],{cwd:e,stdio:"inherit"});let t=await ba({message:"Paste your complete MongoDB connection string:",placeholder:"mongodb://USERNAME:PASSWORD@HOST/DATABASE",validate(r){if(!r)return"Please enter a connection string";if(!r.startsWith("mongodb"))return"URL should start with mongodb"}});return ga(t)?(ha("MongoDB setup cancelled"),null):{connectionString:t}}catch(a){return a instanceof Error&&z.error(G.red(a.message)),null}}async function de(e,a){let t=Me.join(e,"apps/server",".env"),r="";await le.pathExists(t)&&(r=await le.readFile(t,"utf8"));let n=a?`DATABASE_URL="${a.connectionString}"`:'DATABASE_URL="mongodb://localhost:27017/mydb"';r.includes("DATABASE_URL=")?r=r.replace(/DATABASE_URL=.*(\r?\n|$)/,`${n}$1`):r+=`
105
+ ${n}`,await le.writeFile(t,r.trim())}function Le(){z.info(`MongoDB Atlas Setup:
106
106
 
107
107
  1. Install Atlas CLI: https://www.mongodb.com/docs/atlas/cli/stable/install-atlas-cli/
108
108
  2. Run 'atlas deployments setup' and follow prompts
109
109
  3. Get your connection string from the output
110
110
  4. Format: mongodb+srv://USERNAME:PASSWORD@CLUSTER.mongodb.net/DATABASE_NAME
111
- 5. Add to .env as DATABASE_URL="your_connection_string"`)}async function Fe(e){let a=Ie.join(e,"apps/server");try{let t=await ua(a);t?(await ce(e,t),z.success(q.green("MongoDB Atlas connection string saved to .env file!"))):(await ce(e),Re())}catch(t){z.error(q.red(`Error during MongoDB Atlas setup: ${t}`)),await ce(e),Re()}}import W from"node:path";import{cancel as ma,isCancel as fa,log as B,password as ha}from"@clack/prompts";import{execa as ga}from"execa";import O from"fs-extra";import V from"picocolors";async function ba(e,a){try{B.info(V.blue("Initializing Prisma PostgreSQL"));let t=W.join(e,"prisma");await O.ensureDir(t),await ga(a==="npm"?"npx":a==="pnpm"?"pnpm dlx":"bunx",["prisma","init","--db"],{cwd:e,stdio:"inherit"}),B.info(V.yellow(`Please copy the Prisma Postgres URL from the output above.
112
- It looks like: prisma+postgres://accelerate.prisma-data.net/?api_key=...`));let s=await ha({message:"Paste your Prisma Postgres database URL:",validate(n){if(!n)return"Please enter a database URL";if(!n.startsWith("prisma+postgres://"))return"URL should start with prisma+postgres://"}});return fa(s)?(ma("Database setup cancelled"),null):{databaseUrl:s}}catch(t){return t instanceof Error&&B.error(V.red(t.message)),null}}async function pe(e,a){let t=W.join(e,"apps/server",".env"),r="";await O.pathExists(t)&&(r=await O.readFile(t,"utf8"));let s=a?`DATABASE_URL="${a.databaseUrl}"`:'DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"';r.includes("DATABASE_URL=")?r=r.replace(/DATABASE_URL=.*(\r?\n|$)/,`${s}$1`):r+=`
113
- ${s}`,await O.writeFile(t,r.trim())}function Oe(){B.info(`Manual Prisma PostgreSQL Setup Instructions:
111
+ 5. Add to .env as DATABASE_URL="your_connection_string"`)}async function Ne(e){let a=Me.join(e,"apps/server");try{let t=await Pa(a);t?(await de(e,t),z.success(G.green("MongoDB Atlas connection string saved to .env file!"))):(await de(e),Le())}catch(t){z.error(G.red(`Error during MongoDB Atlas setup: ${t}`)),await de(e),Le()}}import ae from"node:path";import{cancel as ja,isCancel as va,log as O,spinner as _e,text as xa}from"@clack/prompts";import{execa as ka}from"execa";import ue from"fs-extra";import _ from"picocolors";function $a(e,a){let t,r;switch(e){case"pnpm":t="pnpm",r=["dlx","neonctl",...a];break;case"bun":t="bunx",r=["neonctl",...a];break;default:t="npx",r=["neonctl",...a]}return{cmd:t,cmdArgs:r}}async function me(e,a,t){let r=t?_e():null;try{let{cmd:n,cmdArgs:s}=$a(e,a);r&&r.start(t);let o=await ka(n,s);return r&&r.stop(),o}catch(n){throw r&&r.stop(_.red(`Failed: ${t}`)),n}}async function Aa(e){try{let{stdout:a}=await me(e,["projects","list"]);return!a.includes("not authenticated")&&!a.includes("error")}catch{return!1}}async function Sa(e){try{return await me(e,["auth"],"Authenticating with Neon..."),O.success("Authenticated with Neon successfully!"),!0}catch(a){throw O.error(_.red("Failed to authenticate with Neon")),a}}async function Ea(e,a){try{let{stdout:t}=await me(a,["projects","create","--name",e,"--output","json"],`Creating Neon project "${e}"...`),r=JSON.parse(t);if(r.project&&r.connection_uris&&r.connection_uris.length>0){let n=r.project.id,s=r.connection_uris[0].connection_uri,o=r.connection_uris[0].connection_parameters;return{connectionString:s,projectId:n,dbName:o.database,roleName:o.role}}return O.error(_.red("Failed to extract connection information from response")),null}catch(t){throw O.error(_.red("Failed to create Neon project")),t}}async function ze(e,a){let t=ae.join(e,"apps/server",".env"),r=a?`DATABASE_URL="${a.connectionString}"`:'DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"';return await ue.ensureDir(ae.dirname(t)),await ue.writeFile(t,r),!0}function Ta(){O.info(`Manual Neon PostgreSQL Setup Instructions:
112
+
113
+ 1. Visit https://neon.tech and create an account
114
+ 2. Create a new project from the dashboard
115
+ 3. Get your connection string
116
+ 4. Add the database URL to the .env file in apps/server/.env
117
+
118
+ DATABASE_URL="your_connection_string"`)}async function Ue(e,a){let t=_e();try{await Aa(a)||(O.info("Please authenticate with Neon to continue:"),await Sa(a));let n=ae.basename(e),s=await xa({message:"Enter a name for your Neon project:",defaultValue:n,initialValue:n});va(s)&&(ja(_.red("Operation cancelled")),process.exit(0));let o=await Ea(s,a);if(!o)throw new Error("Failed to create project - couldn't get connection information");await ue.ensureDir(ae.join(e,"apps/server")),await ze(e,o),O.success("Neon database configured successfully!")}catch(r){t.stop(_.red("Neon PostgreSQL setup failed")),r instanceof Error&&O.error(_.red(r.message)),await ze(e),Ta()}}import H from"node:path";import{cancel as Da,isCancel as Ca,log as L,password as Ra}from"@clack/prompts";import{execa as Fa}from"execa";import B from"fs-extra";import W from"picocolors";async function Ia(e,a){try{L.info(W.blue("Initializing Prisma PostgreSQL"));let t=H.join(e,"prisma");await B.ensureDir(t),await Fa(a==="npm"?"npx":a==="pnpm"?"pnpm dlx":"bunx",["prisma","init","--db"],{cwd:e,stdio:"inherit"}),L.info(W.yellow(`Please copy the Prisma Postgres URL from the output above.
119
+ It looks like: prisma+postgres://accelerate.prisma-data.net/?api_key=...`));let n=await Ra({message:"Paste your Prisma Postgres database URL:",validate(s){if(!s)return"Please enter a database URL";if(!s.startsWith("prisma+postgres://"))return"URL should start with prisma+postgres://"}});return Ca(n)?(Da("Database setup cancelled"),null):{databaseUrl:n}}catch(t){return t instanceof Error&&L.error(W.red(t.message)),null}}async function fe(e,a){let t=H.join(e,"apps/server",".env"),r="";await B.pathExists(t)&&(r=await B.readFile(t,"utf8"));let n=a?`DATABASE_URL="${a.databaseUrl}"`:'DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"';r.includes("DATABASE_URL=")?r=r.replace(/DATABASE_URL=.*(\r?\n|$)/,`${n}$1`):r+=`
120
+ ${n}`,await B.writeFile(t,r.trim())}function qe(){L.info(`Manual Prisma PostgreSQL Setup Instructions:
114
121
 
115
122
  1. Visit https://console.prisma.io and create an account
116
123
  2. Create a new PostgreSQL database from the dashboard
117
124
  3. Get your database URL
118
125
  4. Add the database URL to the .env file in apps/server/.env
119
126
 
120
- DATABASE_URL="your_database_url"`)}async function Be(e,a="npm"){let t=W.join(e,"apps/server");try{let r=await ba(t,a);r?(await pe(e,r),await wa(t),B.success(V.green("Prisma PostgreSQL database configured successfully!"))):(await pe(e),Oe())}catch(r){B.error(V.red(`Error during Prisma PostgreSQL setup: ${r}`)),await pe(e),Oe(),B.info("Setup completed with manual configuration required.")}}async function wa(e){try{g({dependencies:["@prisma/extension-accelerate"],projectDir:e});let a=W.join(e,"prisma/index.ts");await O.writeFile(a,`
127
+ DATABASE_URL="your_database_url"`)}async function Ve(e,a="npm"){let t=H.join(e,"apps/server");try{let r=await Ia(t,a);r?(await fe(e,r),await Oa(t),L.success(W.green("Prisma PostgreSQL database configured successfully!"))):(await fe(e),qe())}catch(r){L.error(W.red(`Error during Prisma PostgreSQL setup: ${r}`)),await fe(e),qe(),L.info("Setup completed with manual configuration required.")}}async function Oa(e){try{g({dependencies:["@prisma/extension-accelerate"],projectDir:e});let a=H.join(e,"prisma/index.ts");await B.writeFile(a,`
121
128
  import { PrismaClient } from '@prisma/client';
122
129
  import { withAccelerate } from "@prisma/extension-accelerate";
123
130
 
124
131
  const prisma = new PrismaClient().$extends(withAccelerate());
125
132
 
126
133
  export default prisma;
127
- `.trim());let r=W.join(e,"src/db/index.ts");if(await O.pathExists(r)){let s=await O.readFile(r,"utf8");s.includes("@prisma/extension-accelerate")||(s=`import { withAccelerate } from "@prisma/extension-accelerate";
128
- ${s}`,s=s.replace("export const db = new PrismaClient();","export const db = new PrismaClient().$extends(withAccelerate());"),await O.writeFile(r,s))}}catch{B.warn(V.yellow("Could not add Prisma Accelerate extension automatically"))}}import Pa from"node:os";import Le from"node:path";import{cancel as le,confirm as ya,isCancel as de,log as G,select as ja,spinner as ue,text as va}from"@clack/prompts";import{$ as R}from"execa";import ka from"fs-extra";import T from"picocolors";async function xa(){return Z("turso")}async function $a(){try{return!(await R`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function Aa(){let e=ue();try{return e.start("Logging in to Turso..."),await R`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(T.red("Failed to log in to Turso")),a}}async function Sa(e){let a=ue();try{if(a.start("Installing Turso CLI..."),e)await R`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await R`curl -sSfL https://get.tur.so/install.sh`;await R`bash -c '${t}'`}return a.stop("Turso CLI installed successfully!"),!0}catch(t){throw t instanceof Error&&t.message.includes("User force closed")?(a.stop(),G.warn(T.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(T.red("Failed to install Turso CLI")),t)}}async function Ea(){try{let{stdout:e}=await R`turso group list`,a=e.trim().split(`
129
- `);return a.length<=1?[]:a.slice(1).map(r=>{let[s,n,o,i]=r.trim().split(/\s{2,}/);return{name:s,locations:n,version:o,status:i}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function Ta(){let e=await Ea();if(e.length===0)return null;if(e.length===1)return e[0].name;let a=e.map(r=>({value:r.name,label:`${r.name} (${r.locations})`})),t=await ja({message:"Select a Turso database group:",options:a});return de(t)&&(le(T.red("Operation cancelled")),process.exit(0)),t}async function Da(e,a){try{a?await R`turso db create ${e} --group ${a}`:await R`turso db create ${e}`}catch(s){throw s instanceof Error&&s.message.includes("already exists")?new Error("DATABASE_EXISTS"):s}let{stdout:t}=await R`turso db show ${e} --url`,{stdout:r}=await R`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function J(e,a){let t=Le.join(e,"apps/server",".env"),r=a?`DATABASE_URL="${a.dbUrl}"
134
+ `.trim());let r=H.join(e,"src/db/index.ts");if(await B.pathExists(r)){let n=await B.readFile(r,"utf8");n.includes("@prisma/extension-accelerate")||(n=`import { withAccelerate } from "@prisma/extension-accelerate";
135
+ ${n}`,n=n.replace("export const db = new PrismaClient();","export const db = new PrismaClient().$extends(withAccelerate());"),await B.writeFile(r,n))}}catch{L.warn(W.yellow("Could not add Prisma Accelerate extension automatically"))}}import Ba from"node:os";import Ge from"node:path";import{cancel as he,confirm as La,isCancel as ge,log as J,select as Ma,spinner as be,text as Na}from"@clack/prompts";import{$ as R}from"execa";import za from"fs-extra";import T from"picocolors";async function _a(){return te("turso")}async function Ua(){try{return!(await R`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function qa(){let e=be();try{return e.start("Logging in to Turso..."),await R`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(T.red("Failed to log in to Turso")),a}}async function Va(e){let a=be();try{if(a.start("Installing Turso CLI..."),e)await R`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await R`curl -sSfL https://get.tur.so/install.sh`;await R`bash -c '${t}'`}return a.stop("Turso CLI installed successfully!"),!0}catch(t){throw t instanceof Error&&t.message.includes("User force closed")?(a.stop(),J.warn(T.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(T.red("Failed to install Turso CLI")),t)}}async function Ga(){try{let{stdout:e}=await R`turso group list`,a=e.trim().split(`
136
+ `);return a.length<=1?[]:a.slice(1).map(r=>{let[n,s,o,i]=r.trim().split(/\s{2,}/);return{name:n,locations:s,version:o,status:i}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function Wa(){let e=await Ga();if(e.length===0)return null;if(e.length===1)return e[0].name;let a=e.map(r=>({value:r.name,label:`${r.name} (${r.locations})`})),t=await Ma({message:"Select a Turso database group:",options:a});return ge(t)&&(he(T.red("Operation cancelled")),process.exit(0)),t}async function Ja(e,a){try{a?await R`turso db create ${e} --group ${a}`:await R`turso db create ${e}`}catch(n){throw n instanceof Error&&n.message.includes("already exists")?new Error("DATABASE_EXISTS"):n}let{stdout:t}=await R`turso db show ${e} --url`,{stdout:r}=await R`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function Q(e,a){let t=Ge.join(e,"apps/server",".env"),r=a?`DATABASE_URL="${a.dbUrl}"
130
137
  DATABASE_AUTH_TOKEN="${a.authToken}"`:`DATABASE_URL=
131
- DATABASE_AUTH_TOKEN=`;await ka.writeFile(t,r)}function ee(){G.info(`Manual Turso Setup Instructions:
138
+ DATABASE_AUTH_TOKEN=`;await za.writeFile(t,r)}function re(){J.info(`Manual Turso Setup Instructions:
132
139
 
133
140
  1. Visit https://turso.tech and create an account
134
141
  2. Create a new database from the dashboard
@@ -136,8 +143,8 @@ DATABASE_AUTH_TOKEN=`;await ka.writeFile(t,r)}function ee(){G.info(`Manual Turso
136
143
  4. Add these credentials to the .env file in apps/server/.env
137
144
 
138
145
  DATABASE_URL=your_database_url
139
- DATABASE_AUTH_TOKEN=your_auth_token`)}async function Me(e,a){if(!a){await J(e),G.info(T.blue("Skipping Turso setup. Setting up empty configuration.")),ee();return}let t=Pa.platform(),r=t==="darwin";if(!(t!=="win32")){G.warn(T.yellow("Automatic Turso setup is not supported on Windows.")),await J(e),ee();return}try{if(!await xa()){let w=await ya({message:"Would you like to install Turso CLI?",initialValue:!0});if(de(w)&&(le(T.red("Operation cancelled")),process.exit(0)),!w){await J(e),ee();return}await Sa(r)}await $a()||await Aa();let i=await Ta(),p=!1,c="",d=Le.basename(e);for(;!p;){let w=await va({message:"Enter a name for your database:",defaultValue:d,initialValue:d,placeholder:d});de(w)&&(le(T.red("Operation cancelled")),process.exit(0)),c=w;let $=ue();try{$.start(`Creating Turso database "${c}"${i?` in group "${i}"`:""}...`);let A=await Da(c,i);await J(e,A),$.stop("Turso database configured successfully!"),p=!0}catch(A){if(A instanceof Error&&A.message==="DATABASE_EXISTS")$.stop(T.yellow(`Database "${T.red(c)}" already exists`)),d=`${c}-${Math.floor(Math.random()*1e3)}`;else throw $.stop(T.red("Failed to create Turso database")),A}}}catch(n){G.error(T.red(`Error during Turso setup: ${n}`)),await J(e),ee(),G.success("Setup completed with manual configuration required.")}}async function Ue(e,a,t,r,s,n,o){let i=Ra(),p=ze.join(e,"apps/server");if(a==="none"){await Ia.remove(ze.join(p,"src/db"));return}try{t==="prisma"?g({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:p}):t==="drizzle"&&(a==="sqlite"?g({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:p}):a==="postgres"?g({dependencies:["drizzle-orm","pg"],devDependencies:["drizzle-kit","@types/pg"],projectDir:p}):a==="mysql"&&g({dependencies:["drizzle-orm","mysql2"],devDependencies:["drizzle-kit"],projectDir:p})),a==="sqlite"&&s?await Me(e,t==="drizzle"):a==="postgres"&&t==="prisma"&&n?await Be(e,r):a==="mongodb"&&o&&await Fe(e)}catch(c){throw i.stop(Ne.red("Failed to set up database")),c instanceof Error&&Ca.error(Ne.red(c.message)),c}}import N from"node:path";import te from"fs-extra";async function me(e,a){await te.ensureDir(N.dirname(e));let t="";await te.pathExists(e)&&(t=await te.readFile(e,"utf8"));let r=!1;for(let{key:s,value:n,condition:o}of a)if(o){let i=new RegExp(`^${s}=.*$`,"m");i.test(t)?n&&(t=t.replace(i,`${s}=${n}`),r=!0):(t+=`
140
- ${s}=${n}`,r=!0)}r&&await te.writeFile(e,t.trim())}async function _e(e,a){let t=N.join(e,"apps/server"),r=N.join(t,".env"),s=a.frontend.includes("react-router"),n=a.frontend.includes("tanstack-router"),o=a.frontend.includes("tanstack-start"),i=s||n||o,p="http://localhost:3000";s?p="http://localhost:5173":(n||o)&&(p="http://localhost:3001");let c="",d=a.dbSetup==="turso"||a.dbSetup==="prisma-postgres"||a.dbSetup==="mongodb-atlas";d||(a.database==="postgres"?c="postgresql://postgres:postgres@localhost:5432/mydb?schema=public":a.database==="mysql"?c="mysql://root:password@localhost:3306/mydb":a.database==="mongodb"?c="mongodb://localhost:27017/mydatabase":a.database==="sqlite"&&(c="file:./local.db"));let w=[{key:"CORS_ORIGIN",value:p,condition:!0},{key:"BETTER_AUTH_SECRET",value:Se(),condition:!!a.auth},{key:"BETTER_AUTH_URL",value:"http://localhost:3000",condition:!!a.auth},{key:"DATABASE_URL",value:c,condition:a.database!=="none"&&c!==""&&!d},{key:"GOOGLE_GENERATIVE_AI_API_KEY",value:"",condition:a.examples?.includes("ai")||!1}];if(await me(r,w),i){let $=N.join(e,"apps/web"),A=[{key:"VITE_SERVER_URL",value:"http://localhost:3000",condition:!0}];await me(N.join($,".env"),A)}if(a.frontend.includes("native")){let $=N.join(e,"apps/native"),A=[{key:"EXPO_PUBLIC_SERVER_URL",value:"http://localhost:3000",condition:!0}];await me(N.join($,".env"),A)}}import x from"node:path";import b from"fs-extra";async function qe(e,a,t,r,s,n=["tanstack-router"]){let o=n.includes("tanstack-router"),i=n.includes("tanstack-start"),p=n.includes("react-router"),c=o||p||i,d;o?d="web-tanstack-router":i?d="web-tanstack-start":d="web-react-router";let w=await b.pathExists(x.join(e,"apps/web"));a.includes("todo")&&c&&w?await La(e,t,r,d):await Na(e,t),a.includes("ai")&&(s==="hono"||s==="express")&&c&&w&&await Fa(e,d)}async function Fa(e,a){let t=x.join(v,"template/examples/ai");if(await b.pathExists(t)){let r=x.join(t,`apps/${a}/src/routes/ai.tsx`),s=x.join(e,"apps/web/src/routes/ai.tsx");await b.pathExists(r)&&await b.copy(r,s,{overwrite:!0}),await Ba(e,a);let n=x.join(e,"apps/web");g({dependencies:["ai"],projectDir:n});let o=x.join(e,"apps/server");g({dependencies:["ai","@ai-sdk/google"],projectDir:o}),await Oa(e)}}async function Oa(e){let a=x.join(e,"apps/server/src/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8"),r=t.includes("hono"),s=t.includes("express");if(r){let n=`import { streamText } from "ai";
146
+ DATABASE_AUTH_TOKEN=your_auth_token`)}async function We(e,a){if(!a){await Q(e),J.info(T.blue("Skipping Turso setup. Setting up empty configuration.")),re();return}let t=Ba.platform(),r=t==="darwin";if(!(t!=="win32")){J.warn(T.yellow("Automatic Turso setup is not supported on Windows.")),await Q(e),re();return}try{if(!await _a()){let w=await La({message:"Would you like to install Turso CLI?",initialValue:!0});if(ge(w)&&(he(T.red("Operation cancelled")),process.exit(0)),!w){await Q(e),re();return}await Va(r)}await Ua()||await qa();let i=await Wa(),p=!1,c="",d=Ge.basename(e);for(;!p;){let w=await Na({message:"Enter a name for your database:",defaultValue:d,initialValue:d,placeholder:d});ge(w)&&(he(T.red("Operation cancelled")),process.exit(0)),c=w;let $=be();try{$.start(`Creating Turso database "${c}"${i?` in group "${i}"`:""}...`);let A=await Ja(c,i);await Q(e,A),$.stop("Turso database configured successfully!"),p=!0}catch(A){if(A instanceof Error&&A.message==="DATABASE_EXISTS")$.stop(T.yellow(`Database "${T.red(c)}" already exists`)),d=`${c}-${Math.floor(Math.random()*1e3)}`;else throw $.stop(T.red("Failed to create Turso database")),A}}}catch(s){J.error(T.red(`Error during Turso setup: ${s}`)),await Q(e),re(),J.success("Setup completed with manual configuration required.")}}async function Qe(e,a,t,r,n,s,o,i){let p=Qa(),c=Je.join(e,"apps/server");if(a==="none"){await Ka.remove(Je.join(c,"src/db"));return}try{t==="prisma"?g({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:c}):t==="drizzle"&&(a==="sqlite"?g({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:c}):a==="postgres"?g({dependencies:["drizzle-orm","pg"],devDependencies:["drizzle-kit","@types/pg"],projectDir:c}):a==="mysql"&&g({dependencies:["drizzle-orm","mysql2"],devDependencies:["drizzle-kit"],projectDir:c})),a==="sqlite"&&n?await We(e,t==="drizzle"):a==="postgres"?t==="prisma"&&s?await Ve(e,r):i&&await Ue(e,r):a==="mongodb"&&o&&await Ne(e)}catch(d){throw p.stop(He.red("Failed to set up database")),d instanceof Error&&Ha.error(He.red(d.message)),d}}import U from"node:path";import ne from"fs-extra";async function we(e,a){await ne.ensureDir(U.dirname(e));let t="";await ne.pathExists(e)&&(t=await ne.readFile(e,"utf8"));let r=!1;for(let{key:n,value:s,condition:o}of a)if(o){let i=new RegExp(`^${n}=.*$`,"m");i.test(t)?s&&(t=t.replace(i,`${n}=${s}`),r=!0):(t+=`
147
+ ${n}=${s}`,r=!0)}r&&await ne.writeFile(e,t.trim())}async function Ke(e,a){let t=U.join(e,"apps/server"),r=U.join(t,".env"),n=a.frontend.includes("react-router"),s=a.frontend.includes("tanstack-router"),o=a.frontend.includes("tanstack-start"),i=n||s||o,p="http://localhost:3000";n?p="http://localhost:5173":(s||o)&&(p="http://localhost:3001");let c="",d=a.dbSetup==="turso"||a.dbSetup==="prisma-postgres"||a.dbSetup==="mongodb-atlas"||a.dbSetup==="neon";d||(a.database==="postgres"?c="postgresql://postgres:postgres@localhost:5432/mydb?schema=public":a.database==="mysql"?c="mysql://root:password@localhost:3306/mydb":a.database==="mongodb"?c="mongodb://localhost:27017/mydatabase":a.database==="sqlite"&&(c="file:./local.db"));let w=[{key:"CORS_ORIGIN",value:p,condition:!0},{key:"BETTER_AUTH_SECRET",value:Re(),condition:!!a.auth},{key:"BETTER_AUTH_URL",value:"http://localhost:3000",condition:!!a.auth},{key:"DATABASE_URL",value:c,condition:a.database!=="none"&&c!==""&&!d},{key:"GOOGLE_GENERATIVE_AI_API_KEY",value:"",condition:a.examples?.includes("ai")||!1}];if(await we(r,w),i){let $=U.join(e,"apps/web"),A=[{key:"VITE_SERVER_URL",value:"http://localhost:3000",condition:!0}];await we(U.join($,".env"),A)}if(a.frontend.includes("native")){let $=U.join(e,"apps/native"),A=[{key:"EXPO_PUBLIC_SERVER_URL",value:"http://localhost:3000",condition:!0}];await we(U.join($,".env"),A)}}import k from"node:path";import b from"fs-extra";async function Xe(e,a,t,r,n,s=["tanstack-router"]){let o=s.includes("tanstack-router"),i=s.includes("tanstack-start"),p=s.includes("react-router"),c=o||p||i,d;o?d="web-tanstack-router":i?d="web-tanstack-start":d="web-react-router";let w=await b.pathExists(k.join(e,"apps/web"));a.includes("todo")&&c&&w?await er(e,t,r,d):await rr(e,t),a.includes("ai")&&(n==="hono"||n==="express")&&c&&w&&await Xa(e,d)}async function Xa(e,a){let t=k.join(v,"template/examples/ai");if(await b.pathExists(t)){let r=k.join(t,`apps/${a}/src/routes/ai.tsx`),n=k.join(e,"apps/web/src/routes/ai.tsx");await b.pathExists(r)&&await b.copy(r,n,{overwrite:!0}),await Za(e,a);let s=k.join(e,"apps/web");g({dependencies:["ai"],projectDir:s});let o=k.join(e,"apps/server");g({dependencies:["ai","@ai-sdk/google"],projectDir:o}),await Ya(e)}}async function Ya(e){let a=k.join(e,"apps/server/src/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8"),r=t.includes("hono"),n=t.includes("express");if(r){let s=`import { streamText } from "ai";
141
148
  import { google } from "@ai-sdk/google";
142
149
  import { stream } from "hono/streaming";`,o=`
143
150
  // AI chat endpoint
@@ -156,8 +163,8 @@ app.post("/ai", async (c) => {
156
163
  return stream(c, (stream) => stream.pipe(result.toDataStream()));
157
164
  });`;if(t.includes("import {")){let p=t.lastIndexOf("import"),c=t.indexOf(`
158
165
  `,p);t=`${t.substring(0,c+1)}
159
- ${n}
160
- ${t.substring(c+1)}`}else t=`${n}
166
+ ${s}
167
+ ${t.substring(c+1)}`}else t=`${s}
161
168
 
162
169
  ${t}`;let i=t.indexOf('app.use("/trpc"')||t.indexOf("app.use(trpc(");if(i!==-1)t=`${t.substring(0,i)}${o}
163
170
 
@@ -165,7 +172,7 @@ ${t.substring(i)}`;else{let p=t.indexOf("export default");p!==-1?t=`${t.substrin
165
172
 
166
173
  ${t.substring(p)}`:t=`${t}
167
174
 
168
- ${o}`}}else if(s){let n=`import { streamText } from "ai";
175
+ ${o}`}}else if(n){let s=`import { streamText } from "ai";
169
176
  import { google } from "@ai-sdk/google";`,o=`
170
177
  // AI chat endpoint
171
178
  app.post("/ai", async (req, res) => {
@@ -179,8 +186,8 @@ app.post("/ai", async (req, res) => {
179
186
  result.pipeDataStreamToResponse(res);
180
187
  });`;if(t.includes("import {")||t.includes("import ")){let p=t.lastIndexOf("import"),c=t.indexOf(`
181
188
  `,p);t=`${t.substring(0,c+1)}
182
- ${n}
183
- ${t.substring(c+1)}`}else t=`${n}
189
+ ${s}
190
+ ${t.substring(c+1)}`}else t=`${s}
184
191
 
185
192
  ${t}`;let i=t.indexOf('app.use("/trpc"');if(i!==-1)t=`${t.substring(0,i)}${o}
186
193
 
@@ -189,63 +196,63 @@ ${t.substring(i)}`;else{let p=t.indexOf("app.listen(");if(p!==-1){let c=t.lastIn
189
196
 
190
197
  ${t.substring(c)}`}else t=`${t}
191
198
 
192
- ${o}`}}await b.writeFile(a,t)}}async function Ba(e,a){let t=x.join(e,"apps/web/src/components/header.tsx");if(await b.pathExists(t)){let r=await b.readFile(t,"utf8"),s=/const links = \[\s*([^;]*?)\s*\];/s,n=r.match(s);if(n){let o=n[1];if(!o.includes('"/ai"')){let i=`const links = [
199
+ ${o}`}}await b.writeFile(a,t)}}async function Za(e,a){let t=k.join(e,"apps/web/src/components/header.tsx");if(await b.pathExists(t)){let r=await b.readFile(t,"utf8"),n=/const links = \[\s*([^;]*?)\s*\];/s,s=r.match(n);if(s){let o=s[1];if(!o.includes('"/ai"')){let i=`const links = [
193
200
  ${o}${o.trim().endsWith(",")?"":","}
194
201
  { to: "/ai", label: "AI Chat" },
195
- ];`;r=r.replace(s,i),await b.writeFile(t,r)}}}}async function La(e,a,t,r){let s=x.join(v,"template/examples/todo");if(await b.pathExists(s)){let n=x.join(s,`apps/${r}/src/routes/todos.tsx`),o=x.join(e,"apps/web/src/routes/todos.tsx");if(await b.pathExists(n)&&await b.copy(n,o,{overwrite:!0}),a!=="none"){let i=x.join(s,`apps/server/src/routers/with-${a}-todo.ts`),p=x.join(e,"apps/server/src/routers/todo.ts");await b.pathExists(i)&&await b.copy(i,p,{overwrite:!0}),await Ma(e)}await za(e,r)}}async function Ma(e){let a=x.join(e,"apps/server/src/routers/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8");if(!t.includes("import { todoRouter }")){let r=t.lastIndexOf("import"),s=t.indexOf(`
202
+ ];`;r=r.replace(n,i),await b.writeFile(t,r)}}}}async function er(e,a,t,r){let n=k.join(v,"template/examples/todo");if(await b.pathExists(n)){let s=k.join(n,`apps/${r}/src/routes/todos.tsx`),o=k.join(e,"apps/web/src/routes/todos.tsx");if(await b.pathExists(s)&&await b.copy(s,o,{overwrite:!0}),a!=="none"){let i=k.join(n,`apps/server/src/routers/with-${a}-todo.ts`),p=k.join(e,"apps/server/src/routers/todo.ts");await b.pathExists(i)&&await b.copy(i,p,{overwrite:!0}),await tr(e)}await ar(e,r)}}async function tr(e){let a=k.join(e,"apps/server/src/routers/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8");if(!t.includes("import { todoRouter }")){let r=t.lastIndexOf("import"),n=t.indexOf(`
196
203
 
197
- `,r);s!==-1?t=`${t.slice(0,s)}
198
- import { todoRouter } from "./todo";${t.slice(s)}`:t=`import { todoRouter } from "./todo";
199
- ${t}`;let n=t.indexOf("export const appRouter = router({");if(n!==-1){let o=t.indexOf("{",n)+1;t=`${t.slice(0,o)}
200
- todo: todoRouter,${t.slice(o)}`}await b.writeFile(a,t)}}}async function za(e,a){let t=x.join(e,"apps/web/src/components/header.tsx");if(await b.pathExists(t)){let r=await b.readFile(t,"utf8"),s=/const links = \[\s*([^;]*?)\s*\];/s,n=r.match(s);if(n){let o=n[1];if(!o.includes('"/todos"')){let i=`const links = [
204
+ `,r);n!==-1?t=`${t.slice(0,n)}
205
+ import { todoRouter } from "./todo";${t.slice(n)}`:t=`import { todoRouter } from "./todo";
206
+ ${t}`;let s=t.indexOf("export const appRouter = router({");if(s!==-1){let o=t.indexOf("{",s)+1;t=`${t.slice(0,o)}
207
+ todo: todoRouter,${t.slice(o)}`}await b.writeFile(a,t)}}}async function ar(e,a){let t=k.join(e,"apps/web/src/components/header.tsx");if(await b.pathExists(t)){let r=await b.readFile(t,"utf8"),n=/const links = \[\s*([^;]*?)\s*\];/s,s=r.match(n);if(s){let o=s[1];if(!o.includes('"/todos"')){let i=`const links = [
201
208
  ${o}${o.trim().endsWith(",")?"":","}
202
209
  { to: "/todos", label: "Todos" },
203
- ];`;r=r.replace(s,i),await b.writeFile(t,r)}}}}async function Na(e,a){if(a==="drizzle"){let r=x.join(e,"apps/server/src/db/schema/todo.ts");await b.pathExists(r)&&await b.remove(r)}else if(a==="prisma"){let r=x.join(e,"apps/server/prisma/schema/todo.prisma");await b.pathExists(r)&&await b.remove(r)}let t=x.join(e,"apps/server/src/routers/todo.ts");await b.pathExists(t)&&await b.remove(t),await Ua(e)}async function Ua(e){let a=x.join(e,"apps/server/src/routers/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await b.writeFile(a,t)}}import{log as Ve,spinner as Ge}from"@clack/prompts";import{$ as We}from"execa";import ae from"picocolors";async function Je({projectDir:e,packageManager:a,addons:t=[]}){let r=Ge();try{r.start(`Running ${a} install...`),await We({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await _a(e,a)}catch(s){throw r.stop(ae.red("Failed to install dependencies")),s instanceof Error&&Ve.error(ae.red(`Installation error: ${s.message}`)),s}}async function _a(e,a){let t=Ge();try{t.start("Running Biome format check..."),await We({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(ae.yellow("Biome check encountered issues")),Ve.warn(ae.yellow("Some files may need manual formatting"))}}import{note as qa}from"@clack/prompts";import P from"picocolors";function He(e,a,t,r,s,n,o,i,p){let c=t==="npm"?"npm run":t,d=`cd ${a}`,w=n?.includes("husky")||n?.includes("biome"),$=e!=="none"?Wa(e,s,c,o):"",A=n?.includes("tauri")?Ja(c):"",Q=w?Ga(c):"",_=i?.includes("native")?Va():"",E=n?.includes("pwa")&&i?.includes("react-router")?Ha():"",D=n?.includes("starlight")?Qa(c):"",C=i?.includes("tanstack-router"),Ot=i?.includes("tanstack-start"),ge=i?.includes("react-router"),be=C||ge||Ot,Bt=i?.includes("native"),Lt=be||Bt,Mt=ge?"5173":"3001";qa(`${P.cyan("1.")} ${d}
204
- ${r?"":`${P.cyan("2.")} ${t} install
205
- `}${P.cyan(r?"2.":"3.")} ${c} dev
206
-
207
- ${P.bold("Your project will be available at:")}
208
- ${Lt?`${be?`${P.cyan("\u2022")} Frontend: http://localhost:${Mt}
209
- `:""}`:`${P.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
210
- `}${P.cyan("\u2022")} API: http://localhost:3000
211
- ${n?.includes("starlight")?`${P.cyan("\u2022")} Docs: http://localhost:4321
212
- `:""}${_?`
213
- ${_.trim()}`:""}${$?`
210
+ ];`;r=r.replace(n,i),await b.writeFile(t,r)}}}}async function rr(e,a){if(a==="drizzle"){let r=k.join(e,"apps/server/src/db/schema/todo.ts");await b.pathExists(r)&&await b.remove(r)}else if(a==="prisma"){let r=k.join(e,"apps/server/prisma/schema/todo.prisma");await b.pathExists(r)&&await b.remove(r)}let t=k.join(e,"apps/server/src/routers/todo.ts");await b.pathExists(t)&&await b.remove(t),await nr(e)}async function nr(e){let a=k.join(e,"apps/server/src/routers/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await b.writeFile(a,t)}}import{log as Ye,spinner as Ze}from"@clack/prompts";import{$ as et}from"execa";import se from"picocolors";async function tt({projectDir:e,packageManager:a,addons:t=[]}){let r=Ze();try{r.start(`Running ${a} install...`),await et({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await sr(e,a)}catch(n){throw r.stop(se.red("Failed to install dependencies")),n instanceof Error&&Ye.error(se.red(`Installation error: ${n.message}`)),n}}async function sr(e,a){let t=Ze();try{t.start("Running Biome format check..."),await et({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(se.yellow("Biome check encountered issues")),Ye.warn(se.yellow("Some files may need manual formatting"))}}import{note as or}from"@clack/prompts";import y from"picocolors";function at(e,a,t,r,n,s,o,i,p){let c=t==="npm"?"npm run":t,d=`cd ${a}`,w=s?.includes("husky")||s?.includes("biome"),$=e!=="none"?pr(e,n,c,o):"",A=s?.includes("tauri")?lr(c):"",X=w?cr(c):"",V=i?.includes("native")?ir():"",E=s?.includes("pwa")&&i?.includes("react-router")?dr():"",D=s?.includes("starlight")?ur(c):"",C=i?.includes("tanstack-router"),qt=i?.includes("tanstack-start"),je=i?.includes("react-router"),ve=C||je||qt,Vt=i?.includes("native"),Gt=ve||Vt,Wt=je?"5173":"3001";or(`${y.cyan("1.")} ${d}
211
+ ${r?"":`${y.cyan("2.")} ${t} install
212
+ `}${y.cyan(r?"2.":"3.")} ${c} dev
213
+
214
+ ${y.bold("Your project will be available at:")}
215
+ ${Gt?`${ve?`${y.cyan("\u2022")} Frontend: http://localhost:${Wt}
216
+ `:""}`:`${y.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
217
+ `}${y.cyan("\u2022")} API: http://localhost:3000
218
+ ${s?.includes("starlight")?`${y.cyan("\u2022")} Docs: http://localhost:4321
219
+ `:""}${V?`
220
+ ${V.trim()}`:""}${$?`
214
221
  ${$.trim()}`:""}${A?`
215
- ${A.trim()}`:""}${Q?`
216
- ${Q.trim()}`:""}${E?`
222
+ ${A.trim()}`:""}${X?`
223
+ ${X.trim()}`:""}${E?`
217
224
  ${E.trim()}`:""}${D?`
218
225
  ${D.trim()}`:""}
219
226
 
220
- ${P.bold("Like Better-T Stack?")} Please consider giving us a star on GitHub:
221
- ${P.cyan("https://github.com/AmanVarshney01/create-better-t-stack")}`,"Next steps")}function Va(){return`${P.yellow("NOTE:")} For Expo connectivity issues, update apps/native/.env
227
+ ${y.bold("Like Better-T Stack?")} Please consider giving us a star on GitHub:
228
+ ${y.cyan("https://github.com/AmanVarshney01/create-better-t-stack")}`,"Next steps")}function ir(){return`${y.yellow("NOTE:")} For Expo connectivity issues, update apps/native/.env
222
229
  with your local IP:
223
230
  EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000
224
- `}function Ga(e){return`${P.bold("Linting and formatting:")}
225
- ${P.cyan("\u2022")} Format and lint fix: ${`${e} check`}
231
+ `}function cr(e){return`${y.bold("Linting and formatting:")}
232
+ ${y.cyan("\u2022")} Format and lint fix: ${`${e} check`}
226
233
 
227
- `}function Wa(e,a,t,r){let s=[];return a==="prisma"?(e==="sqlite"&&s.push(`${P.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,"Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso"),r==="bun"&&s.push(`${P.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors,
228
- follow the guidance provided in the error messages`),s.push(`${P.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),s.push(`${P.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)):a==="drizzle"&&(s.push(`${P.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),s.push(`${P.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)),s.length?`${P.bold("Database commands:")}
229
- ${s.join(`
234
+ `}function pr(e,a,t,r){let n=[];return a==="prisma"?(e==="sqlite"&&n.push(`${y.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,"Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso"),r==="bun"&&n.push(`${y.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors,
235
+ follow the guidance provided in the error messages`),n.push(`${y.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${y.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)):a==="drizzle"&&(n.push(`${y.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${y.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)),n.length?`${y.bold("Database commands:")}
236
+ ${n.join(`
230
237
  `)}
231
238
 
232
- `:""}function Ja(e){return`
233
- ${P.bold("Desktop app with Tauri:")}
234
- ${P.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
235
- ${P.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
236
- ${P.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies.
239
+ `:""}function lr(e){return`
240
+ ${y.bold("Desktop app with Tauri:")}
241
+ ${y.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
242
+ ${y.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
243
+ ${y.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies.
237
244
  See: https://v2.tauri.app/start/prerequisites/
238
245
 
239
- `}function Ha(){return`${P.bold("PWA with React Router v7:")}
240
- ${P.yellow("NOTE:")} There is a known compatibility issue between VitePWA and React Router v7.
246
+ `}function dr(){return`${y.bold("PWA with React Router v7:")}
247
+ ${y.yellow("NOTE:")} There is a known compatibility issue between VitePWA and React Router v7.
241
248
  See: https://github.com/vite-pwa/vite-plugin-pwa/issues/809
242
- `}function Qa(e){return`${P.bold("Documentation with Starlight:")}
243
- ${P.cyan("\u2022")} Start docs site: ${`cd apps/docs && ${e} dev`}
244
- ${P.cyan("\u2022")} Build docs site: ${`cd apps/docs && ${e} build`}
245
- `}import re from"node:path";import{log as Ka}from"@clack/prompts";import{$ as Qe,execa as Xa}from"execa";import L from"fs-extra";import Ya from"picocolors";async function Ke(e,a){await Za(e,a),await er(e,a)}async function Za(e,a){let t=re.join(e,"package.json");if(await L.pathExists(t)){let r=await L.readJson(t);r.name=a.projectName;let{stdout:s}=await Xa(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${s.trim()}`,await L.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let n=re.join(v,"template/with-pnpm/pnpm-workspace.yaml"),o=re.join(e,"pnpm-workspace.yaml");await L.pathExists(n)&&await L.copy(n,o)}}}async function er(e,a){let t=re.join(e,"apps/server/package.json");if(await L.pathExists(t)){let r=await L.readJson(t);a.database!=="none"&&(a.database==="sqlite"&&(r.scripts["db:local"]="turso dev --db-file local.db"),a.orm==="prisma"?(r.scripts["db:push"]="prisma db push --schema ./prisma/schema",r.scripts["db:studio"]="prisma studio"):a.orm==="drizzle"&&(r.scripts["db:push"]="drizzle-kit push",r.scripts["db:studio"]="drizzle-kit studio")),await L.writeJson(t,r,{spaces:2})}}async function Xe(e,a){if(!a)return;if((await Qe({cwd:e,reject:!1,stderr:"pipe"})`git --version`).exitCode!==0){Ka.warn(Ya.yellow("Git is not installed"));return}let r=await Qe({cwd:e,reject:!1,stderr:"pipe"})`git init`;if(r.exitCode!==0)throw new Error(`Git initialization failed: ${r.stderr}`)}import se from"node:path";import M from"fs-extra";async function Ye(e,a,t){let r=se.join(e,"apps/server"),s=se.join(r,"src/index.ts"),n=await M.readFile(s,"utf-8");a==="bun"?await tr(r,s,n,t):a==="node"&&await ar(r,s,n,t)}async function tr(e,a,t,r){let s=se.join(e,"package.json"),n=await M.readJson(s);if(n.scripts={...n.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await M.writeJson(s,n,{spaces:2}),g({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let o=`${t}
249
+ `}function ur(e){return`${y.bold("Documentation with Starlight:")}
250
+ ${y.cyan("\u2022")} Start docs site: ${`cd apps/docs && ${e} dev`}
251
+ ${y.cyan("\u2022")} Build docs site: ${`cd apps/docs && ${e} build`}
252
+ `}import oe from"node:path";import{log as mr}from"@clack/prompts";import{$ as rt,execa as fr}from"execa";import M from"fs-extra";import hr from"picocolors";async function nt(e,a){await gr(e,a),await br(e,a)}async function gr(e,a){let t=oe.join(e,"package.json");if(await M.pathExists(t)){let r=await M.readJson(t);r.name=a.projectName;let{stdout:n}=await fr(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await M.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let s=oe.join(v,"template/with-pnpm/pnpm-workspace.yaml"),o=oe.join(e,"pnpm-workspace.yaml");await M.pathExists(s)&&await M.copy(s,o)}}}async function br(e,a){let t=oe.join(e,"apps/server/package.json");if(await M.pathExists(t)){let r=await M.readJson(t);a.database!=="none"&&(a.database==="sqlite"&&(r.scripts["db:local"]="turso dev --db-file local.db"),a.orm==="prisma"?(r.scripts["db:push"]="prisma db push --schema ./prisma/schema",r.scripts["db:studio"]="prisma studio"):a.orm==="drizzle"&&(r.scripts["db:push"]="drizzle-kit push",r.scripts["db:studio"]="drizzle-kit studio")),await M.writeJson(t,r,{spaces:2})}}async function st(e,a){if(!a)return;if((await rt({cwd:e,reject:!1,stderr:"pipe"})`git --version`).exitCode!==0){mr.warn(hr.yellow("Git is not installed"));return}let r=await rt({cwd:e,reject:!1,stderr:"pipe"})`git init`;if(r.exitCode!==0)throw new Error(`Git initialization failed: ${r.stderr}`)}import ie from"node:path";import N from"fs-extra";async function ot(e,a,t){let r=ie.join(e,"apps/server"),n=ie.join(r,"src/index.ts"),s=await N.readFile(n,"utf-8");a==="bun"?await wr(r,n,s,t):a==="node"&&await yr(r,n,s,t)}async function wr(e,a,t,r){let n=ie.join(e,"package.json"),s=await N.readJson(n);if(s.scripts={...s.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await N.writeJson(n,s,{spaces:2}),g({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let o=`${t}
246
253
 
247
254
  export default app;
248
- `;await M.writeFile(a,o)}}async function ar(e,a,t,r){let s=se.join(e,"package.json"),n=await M.readJson(s);if(n.scripts={...n.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await M.writeJson(s,n,{spaces:2}),g({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){g({dependencies:["@hono/node-server"],projectDir:e});let o=`import { serve } from "@hono/node-server";
255
+ `;await N.writeFile(a,o)}}async function yr(e,a,t,r){let n=ie.join(e,"package.json"),s=await N.readJson(n);if(s.scripts={...s.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await N.writeJson(n,s,{spaces:2}),g({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){g({dependencies:["@hono/node-server"],projectDir:e});let o=`import { serve } from "@hono/node-server";
249
256
  `,i=`
250
257
  serve(
251
258
  {
@@ -256,14 +263,14 @@ serve(
256
263
  console.log(\`Server is running on http://localhost:\${info.port}\`);
257
264
  },
258
265
  );
259
- `;if(!t.includes("@hono/node-server")){let p=t.lastIndexOf("import"),c=t.substring(0,p),d=t.substring(p),w=c+o+d+i;await M.writeFile(a,w)}}else if(r==="elysia"&&(g({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let o=`import { node } from "@elysiajs/node";
266
+ `;if(!t.includes("@hono/node-server")){let p=t.lastIndexOf("import"),c=t.substring(0,p),d=t.substring(p),w=c+o+d+i;await N.writeFile(a,w)}}else if(r==="elysia"&&(g({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let o=`import { node } from "@elysiajs/node";
260
267
  `,i=t.indexOf(`
261
- `,t.indexOf("import")),p=t.substring(0,i+1),c=t.substring(i+1),d=p+o+c;d=d.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await M.writeFile(a,d)}}import u from"node:path";import l from"fs-extra";async function Ze(e){let a=u.join(v,"template/base");if(!await l.pathExists(a))throw new Error(`Template directory not found: ${a}`);await l.ensureDir(e);let t=await l.readdir(a);for(let n of t){let o=u.join(a,n),i=u.join(e,n);n!=="apps"&&(await l.stat(o).then(p=>p.isDirectory())?await l.copy(o,i):await l.copy(o,i))}await l.ensureDir(u.join(e,"apps"));let r=u.join(a,"apps/server"),s=u.join(e,"apps/server");await l.pathExists(r)&&await l.copy(r,s)}async function et(e,a){let t=a.includes("tanstack-router"),r=a.includes("tanstack-start"),s=a.includes("react-router"),n=a.includes("native");if(t||s||r){let o=u.join(e,"apps/web");await l.ensureDir(o);let i=u.join(v,"template/base/apps/web-base");await l.pathExists(i)&&await l.copy(i,o);let p="web-react-router";t?p="web-tanstack-router":r&&(p="web-tanstack-start");let c=u.join(v,`template/base/apps/${p}`);await l.pathExists(c)&&await l.copy(c,o,{overwrite:!0});let d=u.join(o,"package.json");if(await l.pathExists(d)){let w=await l.readJson(d);w.name="web",await l.writeJson(d,w,{spaces:2})}}if(n){let o=u.join(v,"template/base/apps/native"),i=u.join(e,"apps/native");await l.pathExists(o)&&await l.copy(o,i),await l.writeFile(u.join(e,".npmrc"),`node-linker=hoisted
262
- `)}}async function tt(e,a){let t=u.join(v,`template/with-${a}`);await l.pathExists(t)&&await l.copy(t,e,{overwrite:!0})}async function at(e,a,t,r){if(a==="none"||t==="none")return;let s=u.join(v,sr(a,t));if(await l.pathExists(s)&&(await l.copy(s,e,{overwrite:!0}),!r)){if(a==="prisma"){let n=u.join(e,"apps/server/prisma/schema/auth.prisma");await l.pathExists(n)&&await l.remove(n)}else if(a==="drizzle"){let n=u.join(e,"apps/server/src/db/schema/auth.ts");await l.pathExists(n)&&await l.remove(n)}}}async function rt(e,a,t,r,s,n){if(!a)return;let o=u.join(v,"template/with-auth");if(await l.pathExists(o)){let i=n.includes("react-router"),p=n.includes("tanstack-router"),c=n.includes("tanstack-start");if(i||p||c){let E=u.join(e,"apps/web"),D=u.join(o,"apps/web-base");if(await l.pathExists(D)&&await l.copy(D,E,{overwrite:!0}),i){let C=u.join(o,"apps/web-react-router");await l.pathExists(C)&&await l.copy(C,E,{overwrite:!0})}if(p){let C=u.join(o,"apps/web-tanstack-router");await l.pathExists(C)&&await l.copy(C,E,{overwrite:!0})}if(c){let C=u.join(o,"apps/web-tanstack-start");await l.pathExists(C)&&await l.copy(C,E,{overwrite:!0})}}let d=u.join(o,"apps/server/src"),w=u.join(e,"apps/server/src");await l.copy(u.join(d,"lib/trpc.ts"),u.join(w,"lib/trpc.ts"),{overwrite:!0}),await l.copy(u.join(d,"routers/index.ts"),u.join(w,"routers/index.ts"),{overwrite:!0});let $=`with-${t}-context.ts`;await l.copy(u.join(d,"lib",$),u.join(w,"lib/context.ts"),{overwrite:!0});let A=`with-${t}-index.ts`;await l.copy(u.join(d,A),u.join(w,"index.ts"),{overwrite:!0});let Q=nr(r,s),_=u.join(d,Q);if(await l.pathExists(_)){let E=await l.readdir(_);for(let D of E)await l.copy(u.join(_,D),u.join(w,"lib",D),{overwrite:!0})}if(n.includes("native")){let E=u.join(o,"apps/native"),D=u.join(e,"apps/native");await l.pathExists(E)&&await l.copy(E,D,{overwrite:!0}),g({dependencies:["@better-auth/expo"],projectDir:u.join(e,"apps/server")}),await rr(e,r,s)}}}async function rr(e,a,t){let r=u.join(e,"apps/server"),s;if(a==="drizzle"?t==="sqlite"?s=u.join(r,"src/lib/auth.ts"):t==="postgres"&&(s=u.join(r,"src/lib/auth.ts")):a==="prisma"&&(t==="sqlite"?s=u.join(r,"src/lib/auth.ts"):t==="postgres"&&(s=u.join(r,"src/lib/auth.ts"))),s&&await l.pathExists(s)){let n=await l.readFile(s,"utf8");if(!n.includes("@better-auth/expo")){let o=`import { expo } from "@better-auth/expo";
263
- `,i=n.lastIndexOf("import"),p=n.indexOf(`
264
- `,i)+1;n=n.substring(0,p)+o+n.substring(p)}n.includes("plugins:")?n.includes("expo()")||(n=n.replace(/plugins: \[(.*?)\]/s,(o,i)=>`plugins: [${i}${i.trim()?", ":""}expo()]`)):n=n.replace(/}\);/,` plugins: [expo()],
265
- });`),n.includes("my-better-t-app://")||(n=n.replace(/trustedOrigins: \[(.*?)\]/s,(o,i)=>`trustedOrigins: [${i}${i.trim()?", ":""}"my-better-t-app://"]`)),await l.writeFile(s,n)}}async function st(e){let a=await nt(e);for(let t of a)if(await l.pathExists(t)){let r=u.join(u.dirname(t),".gitignore");await l.move(t,r,{overwrite:!0})}}async function nt(e){let a=[],t=u.join(e,"_gitignore");await l.pathExists(t)&&a.push(t);try{let r=await l.readdir(e,{withFileTypes:!0});for(let s of r)if(s.isDirectory()&&s.name!=="node_modules"){let n=u.join(e,s.name),o=await nt(n);a.push(...o)}}catch{}return a}function sr(e,a){if(e==="drizzle"){if(a==="sqlite")return"template/with-drizzle-sqlite";if(a==="postgres")return"template/with-drizzle-postgres";if(a==="mysql")return"template/with-drizzle-mysql"}if(e==="prisma"){if(a==="sqlite")return"template/with-prisma-sqlite";if(a==="postgres")return"template/with-prisma-postgres";if(a==="mysql")return"template/with-prisma-mysql";if(a==="mongodb")return"template/with-prisma-mongodb"}return"template/base"}function nr(e,a){if(e==="drizzle"){if(a==="sqlite")return"with-drizzle-sqlite-lib";if(a==="postgres")return"with-drizzle-postgres-lib";if(a==="mysql")return"with-drizzle-mysql-lib"}if(e==="prisma"){if(a==="sqlite")return"with-prisma-sqlite-lib";if(a==="postgres")return"with-prisma-postgres-lib";if(a==="mysql")return"with-prisma-mysql-lib";if(a==="mongodb")return"with-prisma-mongodb-lib"}throw new Error("Invalid ORM or database configuration for auth setup")}async function it(e){let a=cr(),t=or.resolve(process.cwd(),e.projectName);try{return await pr.ensureDir(t),await Ze(t),await et(t,e.frontend),await st(t),await tt(t,e.backend),await Te(t,e.backend,e.runtime),await at(t,e.orm,e.database,e.auth),await Ue(t,e.database,e.orm,e.packageManager,e.dbSetup==="turso",e.dbSetup==="prisma-postgres",e.dbSetup==="mongodb-atlas"),await rt(t,e.auth,e.backend,e.orm,e.database,e.frontend),await Ee(t,e.auth,e.frontend),await Ye(t,e.runtime,e.backend),await qe(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await _e(t,e),await Xe(t,e.git),e.addons.length>0&&await xe(t,e.addons,e.packageManager,e.frontend),await Ke(t,e),await De(t,e),e.noInstall||await Je({projectDir:t,packageManager:e.packageManager,addons:e.addons}),He(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(ot.red("Failed")),r instanceof Error&&(ir(ot.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as is,group as cs}from"@clack/prompts";import ps from"picocolors";import{cancel as lr,isCancel as dr,multiselect as ur}from"@clack/prompts";import mr from"picocolors";async function ct(e,a){if(e!==void 0)return e;let t=a?.includes("react-router")||a?.includes("tanstack-router"),r=[{value:"starlight",label:"Starlight",hint:"Add Astro Starlight documentation site"},{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],n=t?[...[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"}],...r]:r,o=y.addons.filter(p=>t||p!=="pwa"&&p!=="tauri"),i=await ur({message:"Select addons",options:n,initialValues:o,required:!1});return dr(i)&&(lr(mr.red("Operation cancelled")),process.exit(0)),i.includes("husky")&&!i.includes("biome")&&i.push("biome"),i}import{cancel as fr,confirm as hr,isCancel as gr}from"@clack/prompts";import br from"picocolors";async function pt(e,a,t){if(!a)return!1;if(e!==void 0)return e;let r=await hr({message:"Add authentication with Better-Auth?",initialValue:y.auth});return gr(r)&&(fr(br.red("Operation cancelled")),process.exit(0)),r}import{cancel as wr,isCancel as Pr,select as yr}from"@clack/prompts";import jr from"picocolors";async function lt(e){if(e!==void 0)return e;let a=await yr({message:"Select backend framework",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"express",label:"Express",hint:"Fast, unopinionated, minimalist web framework for Node.js"},{value:"elysia",label:"Elysia",hint:"Ergonomic web framework for building backend servers"}],initialValue:y.backend});return Pr(a)&&(wr(jr.red("Operation cancelled")),process.exit(0)),a}import{cancel as vr,isCancel as kr,select as xr}from"@clack/prompts";import $r from"picocolors";async function dt(e){if(e!==void 0)return e;let a=await xr({message:"Select database",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"lightweight, server-less, embedded relational database management system"},{value:"postgres",label:"PostgreSQL",hint:"powerful, open source object-relational database system"},{value:"mysql",label:"MySQL",hint:"popular open-source relational database system"},{value:"mongodb",label:"MongoDB",hint:"open-source NoSQL database that stores data in JSON-like documents called BSON"}],initialValue:y.database});return kr(a)&&(vr($r.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ar,isCancel as Sr,select as Er}from"@clack/prompts";import Tr from"picocolors";async function ut(e,a,t){if(a!==void 0)return a;if(e==="sqlite"&&t==="prisma")return"none";let r=[];if(e==="sqlite")r=[{value:"turso",label:"Turso",hint:"SQLite for Production. Powered by libSQL"},{value:"none",label:"None",hint:"Manual setup"}];else if(e==="postgres"&&t==="prisma")r=[{value:"prisma-postgres",label:"Prisma Postgres",hint:"Instant Postgres for Global Applications"},{value:"none",label:"None",hint:"Manual setup"}];else if(e==="mongodb")r=[{value:"mongodb-atlas",label:"MongoDB Atlas",hint:"The most effective way to deploy MongoDB"},{value:"none",label:"None",hint:"Manual setup"}];else return"none";let s=await Er({message:`Select ${e} setup option`,options:r,initialValue:"none"});return Sr(s)&&(Ar(Tr.red("Operation cancelled")),process.exit(0)),s}import{cancel as Dr,isCancel as Cr,multiselect as mt}from"@clack/prompts";import Rr from"picocolors";async function ft(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!(t?.includes("react-router")||t?.includes("tanstack-router")||t?.includes("tanstack-start")))return[];let n=[];return r==="elysia"&&(n=await mt({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:y.examples})),(r==="hono"||r==="express")&&(n=await mt({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"},{value:"ai",label:"AI Chat",hint:"A simple AI chat interface using AI SDK"}],required:!1,initialValues:y.examples})),Cr(n)&&(Dr(Rr.red("Operation cancelled")),process.exit(0)),n}import{cancel as ht,isCancel as gt,multiselect as Ir,select as Fr}from"@clack/prompts";import bt from"picocolors";async function wt(e){if(e!==void 0)return e;let a=await Ir({message:"Select platforms to develop for",options:[{value:"web",label:"Web",hint:"React Web Application"},{value:"native",label:"Native",hint:"Create a React Native/Expo app"}],required:!1,initialValues:y.frontend.some(r=>r==="tanstack-router"||r==="react-router"||r==="tanstack-start")?["web"]:[]});gt(a)&&(ht(bt.red("Operation cancelled")),process.exit(0));let t=[];if(a.includes("web")){let r=await Fr({message:"Choose frontend framework",options:[{value:"tanstack-router",label:"TanStack Router",hint:"Modern and scalable routing for React Applications"},{value:"react-router",label:"React Router",hint:"A user\u2011obsessed, standards\u2011focused, multi\u2011strategy router you can deploy anywhere."},{value:"tanstack-start",label:"TanStack Start (beta)",hint:"SSR, Streaming, Server Functions, API Routes, bundling and more powered by TanStack Router and Vite."}],initialValue:y.frontend.find(s=>s==="tanstack-router"||s==="react-router"||s==="tanstack-start")||"tanstack-router"});gt(r)&&(ht(bt.red("Operation cancelled")),process.exit(0)),t.push(r)}return a.includes("native")&&t.push("native"),t}import{cancel as Or,confirm as Br,isCancel as Lr}from"@clack/prompts";import Mr from"picocolors";async function Pt(e){if(e!==void 0)return e;let a=await Br({message:"Initialize git repository?",initialValue:y.git});return Lr(a)&&(Or(Mr.red("Operation cancelled")),process.exit(0)),a}import{cancel as zr,confirm as Nr,isCancel as Ur}from"@clack/prompts";import _r from"picocolors";async function yt(e){if(e!==void 0)return e;let a=await Nr({message:"Install dependencies?",initialValue:!y.noInstall});return Ur(a)&&(zr(_r.red("Operation cancelled")),process.exit(0)),!a}import{cancel as qr,isCancel as Vr,log as Gr,select as Wr}from"@clack/prompts";import Jr from"picocolors";async function jt(e,a,t){if(!a)return"none";if(e!==void 0)return e;if(t==="mongodb")return Gr.info("Only Prisma is supported with MongoDB."),"prisma";let r=await Wr({message:"Select ORM",options:[{value:"drizzle",label:"Drizzle",hint:"lightweight and performant TypeScript ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:y.orm});return Vr(r)&&(qr(Jr.red("Operation cancelled")),process.exit(0)),r}import{cancel as Hr,isCancel as Qr,select as Kr}from"@clack/prompts";import Xr from"picocolors";async function vt(e){if(e!==void 0)return e;let a=K(),t=await Kr({message:"Choose package manager",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"}],initialValue:a});return Qr(t)&&(Hr(Xr.red("Operation cancelled")),process.exit(0)),t}import H from"node:path";import{cancel as Yr,isCancel as Zr,text as es}from"@clack/prompts";import U from"fs-extra";import ts from"picocolors";var as=["<",">",":",'"',"|","?","*"],kt=255;function xt(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>kt)return`Project name must be less than ${kt} characters`;if(as.some(a=>e.includes(a)))return"Project name contains invalid characters";if(e.startsWith(".")||e.startsWith("-"))return"Project name cannot start with a dot or dash";if(e.toLowerCase()==="node_modules")return"Project name is reserved"}}async function $t(e){if(e)if(e==="."){let n=process.cwd();if(U.readdirSync(n).length===0)return e}else{let n=H.basename(e);if(!xt(n)){let i=H.resolve(process.cwd(),e);if(!U.pathExistsSync(i)||U.readdirSync(i).length===0)return e}}let a=!1,t="",r=y.projectName,s=1;for(;U.pathExistsSync(H.resolve(process.cwd(),r));)r=`${y.projectName}-${s}`,s++;for(;!a;){let n=await es({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:o=>{let i=o.trim()||r;if(i==="."){if(U.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let p=H.resolve(process.cwd(),i),c=H.basename(p),d=xt(c);if(d)return d;if(!p.startsWith(process.cwd()))return"Project path must be within current directory";if(U.pathExistsSync(p)&&U.readdirSync(p).length>0)return`Directory "${i}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Zr(n)&&(Yr(ts.red("Operation cancelled.")),process.exit(0)),t=n||r}return t}import{cancel as rs,isCancel as ss,select as ns}from"@clack/prompts";import os from"picocolors";async function At(e){if(e!==void 0)return e;let a=await ns({message:"Select runtime",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:y.runtime});return ss(a)&&(rs(os.red("Operation cancelled")),process.exit(0)),a}async function St(e){let a=await cs({projectName:async()=>$t(e.projectName),frontend:()=>wt(e.frontend),backend:()=>lt(e.backend),runtime:()=>At(e.runtime),database:()=>dt(e.database),orm:({results:t})=>jt(e.orm,t.database!=="none",t.database),auth:({results:t})=>pt(e.auth,t.database!=="none",t.frontend),addons:({results:t})=>ct(e.addons,t.frontend),examples:({results:t})=>ft(e.examples,t.database,t.frontend,t.backend),dbSetup:({results:t})=>ut(t.database??"none",e.dbSetup,t.orm),git:()=>Pt(e.git),packageManager:()=>vt(e.packageManager),noInstall:()=>yt(e.noInstall)},{onCancel:()=>{is(ps.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,frontend:a.frontend,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,dbSetup:a.dbSetup,backend:a.backend,runtime:a.runtime}}import S from"picocolors";function fe(e){let a=[];if(e.projectName&&a.push(`${S.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${S.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${S.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${S.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${S.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${S.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${S.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${S.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${S.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${S.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${S.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${S.blue("Skip Install:")} ${e.noInstall}`),e.dbSetup!==void 0&&a.push(`${S.blue("Database Setup:")} ${e.dbSetup}`),a.join(`
266
- `)}function Et(e){let a=[];e.database==="none"?a.push("--database none"):(a.push(`--database ${e.database}`),e.orm&&a.push(`--orm ${e.orm}`),e.dbSetup&&a.push(`--db-setup ${e.dbSetup}`)),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.runtime&&a.push(`--runtime ${e.runtime}`),e.backend&&a.push(`--backend ${e.backend}`),e.frontend&&e.frontend.length>0&&a.push(`--frontend ${e.frontend.join(" ")}`),e.addons&&e.addons.length>0?a.push(`--addons ${e.addons.join(" ")}`):a.push("--addons none"),e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(" ")}`):a.push("--no-examples"),e.packageManager&&a.push(`--package-manager ${e.packageManager}`);let t="",r=e.packageManager;r==="npm"?t="npx create-better-t-stack@latest":r==="pnpm"?t="pnpm create better-t-stack@latest":r==="bun"&&(t="bun create better-t-stack@latest");let s=e.projectName?` ${e.projectName}`:"";return`${t}${s} ${a.join(" ")}`}import ls from"node:path";import ds from"fs-extra";var Tt=()=>{let e=ls.join(v,"package.json");return ds.readJSONSync(e).version??"1.0.0"};import Dt from"gradient-string";var Ct=`
268
+ `,t.indexOf("import")),p=t.substring(0,i+1),c=t.substring(i+1),d=p+o+c;d=d.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await N.writeFile(a,d)}}import u from"node:path";import l from"fs-extra";async function it(e){let a=u.join(v,"template/base");if(!await l.pathExists(a))throw new Error(`Template directory not found: ${a}`);await l.ensureDir(e);let t=await l.readdir(a);for(let s of t){let o=u.join(a,s),i=u.join(e,s);s!=="apps"&&(await l.stat(o).then(p=>p.isDirectory())?await l.copy(o,i):await l.copy(o,i))}await l.ensureDir(u.join(e,"apps"));let r=u.join(a,"apps/server"),n=u.join(e,"apps/server");await l.pathExists(r)&&await l.copy(r,n)}async function ct(e,a){let t=a.includes("tanstack-router"),r=a.includes("tanstack-start"),n=a.includes("react-router"),s=a.includes("native");if(t||n||r){let o=u.join(e,"apps/web");await l.ensureDir(o);let i=u.join(v,"template/base/apps/web-base");await l.pathExists(i)&&await l.copy(i,o);let p="web-react-router";t?p="web-tanstack-router":r&&(p="web-tanstack-start");let c=u.join(v,`template/base/apps/${p}`);await l.pathExists(c)&&await l.copy(c,o,{overwrite:!0});let d=u.join(o,"package.json");if(await l.pathExists(d)){let w=await l.readJson(d);w.name="web",await l.writeJson(d,w,{spaces:2})}}if(s){let o=u.join(v,"template/base/apps/native"),i=u.join(e,"apps/native");await l.pathExists(o)&&await l.copy(o,i),await l.writeFile(u.join(e,".npmrc"),`node-linker=hoisted
269
+ `)}}async function pt(e,a){let t=u.join(v,`template/with-${a}`);await l.pathExists(t)&&await l.copy(t,e,{overwrite:!0})}async function lt(e,a,t,r){if(a==="none"||t==="none")return;let n=u.join(v,jr(a,t));if(await l.pathExists(n)&&(await l.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let s=u.join(e,"apps/server/prisma/schema/auth.prisma");await l.pathExists(s)&&await l.remove(s)}else if(a==="drizzle"){let s=u.join(e,"apps/server/src/db/schema/auth.ts");await l.pathExists(s)&&await l.remove(s)}}}async function dt(e,a,t,r,n,s){if(!a)return;let o=u.join(v,"template/with-auth");if(await l.pathExists(o)){let i=s.includes("react-router"),p=s.includes("tanstack-router"),c=s.includes("tanstack-start");if(i||p||c){let E=u.join(e,"apps/web"),D=u.join(o,"apps/web-base");if(await l.pathExists(D)&&await l.copy(D,E,{overwrite:!0}),i){let C=u.join(o,"apps/web-react-router");await l.pathExists(C)&&await l.copy(C,E,{overwrite:!0})}if(p){let C=u.join(o,"apps/web-tanstack-router");await l.pathExists(C)&&await l.copy(C,E,{overwrite:!0})}if(c){let C=u.join(o,"apps/web-tanstack-start");await l.pathExists(C)&&await l.copy(C,E,{overwrite:!0})}}let d=u.join(o,"apps/server/src"),w=u.join(e,"apps/server/src");await l.copy(u.join(d,"lib/trpc.ts"),u.join(w,"lib/trpc.ts"),{overwrite:!0}),await l.copy(u.join(d,"routers/index.ts"),u.join(w,"routers/index.ts"),{overwrite:!0});let $=`with-${t}-context.ts`;await l.copy(u.join(d,"lib",$),u.join(w,"lib/context.ts"),{overwrite:!0});let A=`with-${t}-index.ts`;await l.copy(u.join(d,A),u.join(w,"index.ts"),{overwrite:!0});let X=vr(r,n),V=u.join(d,X);if(await l.pathExists(V)){let E=await l.readdir(V);for(let D of E)await l.copy(u.join(V,D),u.join(w,"lib",D),{overwrite:!0})}if(s.includes("native")){let E=u.join(o,"apps/native"),D=u.join(e,"apps/native");await l.pathExists(E)&&await l.copy(E,D,{overwrite:!0}),g({dependencies:["@better-auth/expo"],projectDir:u.join(e,"apps/server")}),await Pr(e,r,n)}}}async function Pr(e,a,t){let r=u.join(e,"apps/server"),n;if(a==="drizzle"?t==="sqlite"?n=u.join(r,"src/lib/auth.ts"):t==="postgres"&&(n=u.join(r,"src/lib/auth.ts")):a==="prisma"&&(t==="sqlite"?n=u.join(r,"src/lib/auth.ts"):t==="postgres"&&(n=u.join(r,"src/lib/auth.ts"))),n&&await l.pathExists(n)){let s=await l.readFile(n,"utf8");if(!s.includes("@better-auth/expo")){let o=`import { expo } from "@better-auth/expo";
270
+ `,i=s.lastIndexOf("import"),p=s.indexOf(`
271
+ `,i)+1;s=s.substring(0,p)+o+s.substring(p)}s.includes("plugins:")?s.includes("expo()")||(s=s.replace(/plugins: \[(.*?)\]/s,(o,i)=>`plugins: [${i}${i.trim()?", ":""}expo()]`)):s=s.replace(/}\);/,` plugins: [expo()],
272
+ });`),s.includes("my-better-t-app://")||(s=s.replace(/trustedOrigins: \[(.*?)\]/s,(o,i)=>`trustedOrigins: [${i}${i.trim()?", ":""}"my-better-t-app://"]`)),await l.writeFile(n,s)}}async function ut(e){let a=await mt(e);for(let t of a)if(await l.pathExists(t)){let r=u.join(u.dirname(t),".gitignore");await l.move(t,r,{overwrite:!0})}}async function mt(e){let a=[],t=u.join(e,"_gitignore");await l.pathExists(t)&&a.push(t);try{let r=await l.readdir(e,{withFileTypes:!0});for(let n of r)if(n.isDirectory()&&n.name!=="node_modules"){let s=u.join(e,n.name),o=await mt(s);a.push(...o)}}catch{}return a}function jr(e,a){if(e==="drizzle"){if(a==="sqlite")return"template/with-drizzle-sqlite";if(a==="postgres")return"template/with-drizzle-postgres";if(a==="mysql")return"template/with-drizzle-mysql"}if(e==="prisma"){if(a==="sqlite")return"template/with-prisma-sqlite";if(a==="postgres")return"template/with-prisma-postgres";if(a==="mysql")return"template/with-prisma-mysql";if(a==="mongodb")return"template/with-prisma-mongodb"}return"template/base"}function vr(e,a){if(e==="drizzle"){if(a==="sqlite")return"with-drizzle-sqlite-lib";if(a==="postgres")return"with-drizzle-postgres-lib";if(a==="mysql")return"with-drizzle-mysql-lib"}if(e==="prisma"){if(a==="sqlite")return"with-prisma-sqlite-lib";if(a==="postgres")return"with-prisma-postgres-lib";if(a==="mysql")return"with-prisma-mysql-lib";if(a==="mongodb")return"with-prisma-mongodb-lib"}throw new Error("Invalid ORM or database configuration for auth setup")}async function ht(e){let a=$r(),t=xr.resolve(process.cwd(),e.projectName);try{return await Ar.ensureDir(t),await it(t),await ct(t,e.frontend),await ut(t),await pt(t,e.backend),await Ie(t,e.backend,e.runtime),await lt(t,e.orm,e.database,e.auth),await Qe(t,e.database,e.orm,e.packageManager,e.dbSetup==="turso",e.dbSetup==="prisma-postgres",e.dbSetup==="mongodb-atlas",e.dbSetup==="neon"),await dt(t,e.auth,e.backend,e.orm,e.database,e.frontend),await Fe(t,e.auth,e.frontend),await ot(t,e.runtime,e.backend),await Xe(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await Ke(t,e),await st(t,e.git),e.addons.length>0&&await Te(t,e.addons,e.packageManager,e.frontend),await nt(t,e),await Oe(t,e),e.noInstall||await tt({projectDir:t,packageManager:e.packageManager,addons:e.addons}),at(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(ft.red("Failed")),r instanceof Error&&(kr(ft.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as $n,group as An}from"@clack/prompts";import Sn from"picocolors";import{cancel as Sr,isCancel as Er,multiselect as Tr}from"@clack/prompts";import Dr from"picocolors";async function gt(e,a){if(e!==void 0)return e;let t=a?.includes("react-router")||a?.includes("tanstack-router"),r=[{value:"starlight",label:"Starlight",hint:"Add Astro Starlight documentation site"},{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],s=t?[...[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"}],...r]:r,o=P.addons.filter(p=>t||p!=="pwa"&&p!=="tauri"),i=await Tr({message:"Select addons",options:s,initialValues:o,required:!1});return Er(i)&&(Sr(Dr.red("Operation cancelled")),process.exit(0)),i.includes("husky")&&!i.includes("biome")&&i.push("biome"),i}import{cancel as Cr,confirm as Rr,isCancel as Fr}from"@clack/prompts";import Ir from"picocolors";async function bt(e,a,t){if(!a)return!1;if(e!==void 0)return e;let r=await Rr({message:"Add authentication with Better-Auth?",initialValue:P.auth});return Fr(r)&&(Cr(Ir.red("Operation cancelled")),process.exit(0)),r}import{cancel as Or,isCancel as Br,select as Lr}from"@clack/prompts";import Mr from"picocolors";async function wt(e){if(e!==void 0)return e;let a=await Lr({message:"Select backend framework",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"express",label:"Express",hint:"Fast, unopinionated, minimalist web framework for Node.js"},{value:"elysia",label:"Elysia",hint:"Ergonomic web framework for building backend servers"}],initialValue:P.backend});return Br(a)&&(Or(Mr.red("Operation cancelled")),process.exit(0)),a}import{cancel as Nr,isCancel as zr,select as _r}from"@clack/prompts";import Ur from"picocolors";async function yt(e){if(e!==void 0)return e;let a=await _r({message:"Select database",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"lightweight, server-less, embedded relational database management system"},{value:"postgres",label:"PostgreSQL",hint:"powerful, open source object-relational database system"},{value:"mysql",label:"MySQL",hint:"popular open-source relational database system"},{value:"mongodb",label:"MongoDB",hint:"open-source NoSQL database that stores data in JSON-like documents called BSON"}],initialValue:P.database});return zr(a)&&(Nr(Ur.red("Operation cancelled")),process.exit(0)),a}import{cancel as qr,isCancel as Vr,select as Gr}from"@clack/prompts";import Wr from"picocolors";async function Pt(e,a,t){if(a!==void 0)return a;if(e==="sqlite"&&t==="prisma")return"none";let r=[];if(e==="sqlite")r=[{value:"turso",label:"Turso",hint:"SQLite for Production. Powered by libSQL"},{value:"none",label:"None",hint:"Manual setup"}];else if(e==="postgres")r=[{value:"neon",label:"Neon Postgres",hint:"Serverless Postgres with branching capability"},...t==="prisma"?[{value:"prisma-postgres",label:"Prisma Postgres",hint:"Instant Postgres for Global Applications"}]:[],{value:"none",label:"None",hint:"Manual setup"}];else if(e==="mongodb")r=[{value:"mongodb-atlas",label:"MongoDB Atlas",hint:"The most effective way to deploy MongoDB"},{value:"none",label:"None",hint:"Manual setup"}];else return"none";let n=await Gr({message:`Select ${e} setup option`,options:r,initialValue:"none"});return Vr(n)&&(qr(Wr.red("Operation cancelled")),process.exit(0)),n}import{cancel as Jr,isCancel as Hr,multiselect as jt}from"@clack/prompts";import Qr from"picocolors";async function vt(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!(t?.includes("react-router")||t?.includes("tanstack-router")||t?.includes("tanstack-start")))return[];let s=[];return r==="elysia"&&(s=await jt({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:P.examples})),(r==="hono"||r==="express")&&(s=await jt({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"},{value:"ai",label:"AI Chat",hint:"A simple AI chat interface using AI SDK"}],required:!1,initialValues:P.examples})),Hr(s)&&(Jr(Qr.red("Operation cancelled")),process.exit(0)),s}import{cancel as xt,isCancel as kt,multiselect as Kr,select as Xr}from"@clack/prompts";import $t from"picocolors";async function At(e){if(e!==void 0)return e;let a=await Kr({message:"Select platforms to develop for",options:[{value:"web",label:"Web",hint:"React Web Application"},{value:"native",label:"Native",hint:"Create a React Native/Expo app"}],required:!1,initialValues:P.frontend.some(r=>r==="tanstack-router"||r==="react-router"||r==="tanstack-start")?["web"]:[]});kt(a)&&(xt($t.red("Operation cancelled")),process.exit(0));let t=[];if(a.includes("web")){let r=await Xr({message:"Choose frontend framework",options:[{value:"tanstack-router",label:"TanStack Router",hint:"Modern and scalable routing for React Applications"},{value:"react-router",label:"React Router",hint:"A user\u2011obsessed, standards\u2011focused, multi\u2011strategy router you can deploy anywhere."},{value:"tanstack-start",label:"TanStack Start (beta)",hint:"SSR, Streaming, Server Functions, API Routes, bundling and more powered by TanStack Router and Vite."}],initialValue:P.frontend.find(n=>n==="tanstack-router"||n==="react-router"||n==="tanstack-start")||"tanstack-router"});kt(r)&&(xt($t.red("Operation cancelled")),process.exit(0)),t.push(r)}return a.includes("native")&&t.push("native"),t}import{cancel as Yr,confirm as Zr,isCancel as en}from"@clack/prompts";import tn from"picocolors";async function St(e){if(e!==void 0)return e;let a=await Zr({message:"Initialize git repository?",initialValue:P.git});return en(a)&&(Yr(tn.red("Operation cancelled")),process.exit(0)),a}import{cancel as an,confirm as rn,isCancel as nn}from"@clack/prompts";import sn from"picocolors";async function Et(e){if(e!==void 0)return e;let a=await rn({message:"Install dependencies?",initialValue:!P.noInstall});return nn(a)&&(an(sn.red("Operation cancelled")),process.exit(0)),!a}import{cancel as on,isCancel as cn,log as pn,select as ln}from"@clack/prompts";import dn from"picocolors";async function Tt(e,a,t){if(!a)return"none";if(e!==void 0)return e;if(t==="mongodb")return pn.info("Only Prisma is supported with MongoDB."),"prisma";let r=await ln({message:"Select ORM",options:[{value:"drizzle",label:"Drizzle",hint:"lightweight and performant TypeScript ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:P.orm});return cn(r)&&(on(dn.red("Operation cancelled")),process.exit(0)),r}import{cancel as un,isCancel as mn,select as fn}from"@clack/prompts";import hn from"picocolors";async function Dt(e){if(e!==void 0)return e;let a=Y(),t=await fn({message:"Choose package manager",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"}],initialValue:a});return mn(t)&&(un(hn.red("Operation cancelled")),process.exit(0)),t}import K from"node:path";import{cancel as gn,isCancel as bn,text as wn}from"@clack/prompts";import q from"fs-extra";import yn from"picocolors";var Pn=["<",">",":",'"',"|","?","*"],Ct=255;function Rt(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Ct)return`Project name must be less than ${Ct} characters`;if(Pn.some(a=>e.includes(a)))return"Project name contains invalid characters";if(e.startsWith(".")||e.startsWith("-"))return"Project name cannot start with a dot or dash";if(e.toLowerCase()==="node_modules")return"Project name is reserved"}}async function Ft(e){if(e)if(e==="."){let s=process.cwd();if(q.readdirSync(s).length===0)return e}else{let s=K.basename(e);if(!Rt(s)){let i=K.resolve(process.cwd(),e);if(!q.pathExistsSync(i)||q.readdirSync(i).length===0)return e}}let a=!1,t="",r=P.projectName,n=1;for(;q.pathExistsSync(K.resolve(process.cwd(),r));)r=`${P.projectName}-${n}`,n++;for(;!a;){let s=await wn({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:o=>{let i=o.trim()||r;if(i==="."){if(q.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let p=K.resolve(process.cwd(),i),c=K.basename(p),d=Rt(c);if(d)return d;if(!p.startsWith(process.cwd()))return"Project path must be within current directory";if(q.pathExistsSync(p)&&q.readdirSync(p).length>0)return`Directory "${i}" already exists and is not empty. Please choose a different name or path.`;a=!0}});bn(s)&&(gn(yn.red("Operation cancelled.")),process.exit(0)),t=s||r}return t}import{cancel as jn,isCancel as vn,select as xn}from"@clack/prompts";import kn from"picocolors";async function It(e){if(e!==void 0)return e;let a=await xn({message:"Select runtime",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:P.runtime});return vn(a)&&(jn(kn.red("Operation cancelled")),process.exit(0)),a}async function Ot(e){let a=await An({projectName:async()=>Ft(e.projectName),frontend:()=>At(e.frontend),backend:()=>wt(e.backend),runtime:()=>It(e.runtime),database:()=>yt(e.database),orm:({results:t})=>Tt(e.orm,t.database!=="none",t.database),auth:({results:t})=>bt(e.auth,t.database!=="none",t.frontend),addons:({results:t})=>gt(e.addons,t.frontend),examples:({results:t})=>vt(e.examples,t.database,t.frontend,t.backend),dbSetup:({results:t})=>Pt(t.database??"none",e.dbSetup,t.orm),git:()=>St(e.git),packageManager:()=>Dt(e.packageManager),noInstall:()=>Et(e.noInstall)},{onCancel:()=>{$n(Sn.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,frontend:a.frontend,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,dbSetup:a.dbSetup,backend:a.backend,runtime:a.runtime}}import S from"picocolors";function ye(e){let a=[];if(e.projectName&&a.push(`${S.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${S.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${S.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${S.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${S.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${S.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${S.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${S.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${S.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${S.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${S.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${S.blue("Skip Install:")} ${e.noInstall}`),e.dbSetup!==void 0&&a.push(`${S.blue("Database Setup:")} ${e.dbSetup}`),a.join(`
273
+ `)}function Bt(e){let a=[];e.database==="none"?a.push("--database none"):(a.push(`--database ${e.database}`),e.orm&&a.push(`--orm ${e.orm}`),e.dbSetup&&a.push(`--db-setup ${e.dbSetup}`)),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.runtime&&a.push(`--runtime ${e.runtime}`),e.backend&&a.push(`--backend ${e.backend}`),e.frontend&&e.frontend.length>0&&a.push(`--frontend ${e.frontend.join(" ")}`),e.addons&&e.addons.length>0?a.push(`--addons ${e.addons.join(" ")}`):a.push("--addons none"),e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(" ")}`):a.push("--no-examples"),e.packageManager&&a.push(`--package-manager ${e.packageManager}`);let t="",r=e.packageManager;r==="npm"?t="npx create-better-t-stack@latest":r==="pnpm"?t="pnpm create better-t-stack@latest":r==="bun"&&(t="bun create better-t-stack@latest");let n=e.projectName?` ${e.projectName}`:"";return`${t}${n} ${a.join(" ")}`}import En from"node:path";import Tn from"fs-extra";var Lt=()=>{let e=En.join(v,"package.json");return Tn.readJSONSync(e).version??"1.0.0"};import Mt from"gradient-string";var Nt=`
267
274
  \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557
268
275
  \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
269
276
  \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
@@ -277,10 +284,10 @@ serve(
277
284
  \u2588\u2588\u2551 \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2588\u2588\u2557
278
285
  \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2557
279
286
  \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
280
- `,Rt={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},It=()=>{let e=process.stdout.columns||80,a=Ct.split(`
281
- `),t=Math.max(...a.map(r=>r.length));e<t?console.log(Dt(Object.values(Rt)).multiline(`
287
+ `,zt={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},_t=()=>{let e=process.stdout.columns||80,a=Nt.split(`
288
+ `),t=Math.max(...a.map(r=>r.length));e<t?console.log(Mt(Object.values(zt)).multiline(`
282
289
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
283
290
  \u2551 Better T-Stack \u2551
284
291
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
285
- `)):console.log(Dt(Object.values(Rt)).multiline(Ct))};var Ft=()=>process.exit(0);process.on("SIGINT",Ft);process.on("SIGTERM",Ft);var he=new hs;async function gs(){let e=Date.now();he.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Tt()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--database <type>","Database type (none, sqlite, postgres, mysql, mongodb)").option("--orm <type>","ORM type (drizzle, prisma)").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--frontend <types...>","Frontend types (tanstack-router, react-router, tanstack-start, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, starlight, biome, husky, none)").option("--examples <types...>","Examples to include (todo, ai)").option("--no-examples","Skip all examples").option("--git","Initialize git repository").option("--no-git","Skip git initialization").option("--package-manager <pm>","Package manager (npm, pnpm, bun)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--db-setup <setup>","Database setup (turso, prisma-postgres, mongodb-atlas, none)").option("--backend <framework>","Backend framework (hono, express, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=fs();try{It(),us(h.magenta("Creating a new Better-T-Stack project"));let t=he.opts(),r=he.args[0],s=bs(t,r);!t.yes&&Object.keys(s).length>0&&(I.info(h.yellow("Using these pre-selected options:")),I.message(fe(s)),I.message(""));let n=t.yes?{...y,projectName:r??y.projectName,...s}:await St(s);t.yes&&(I.info(h.yellow("Using these default options:")),I.message(fe(n)),I.message("")),await it(n),I.success(h.blue(`You can reproduce this setup with the following command:
286
- ${h.white(Et(n))}`));let o=((Date.now()-e)/1e3).toFixed(2);ms(h.magenta(`Project created successfully in ${h.bold(o)} seconds!`))}catch(t){a.stop(h.red("Failed")),t instanceof Error&&(j(h.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function bs(e,a){let t={};if(e.database&&(["none","sqlite","postgres","mysql","mongodb"].includes(e.database)||(j(h.red(`Invalid database type: ${e.database}. Must be none, sqlite, postgres, mysql, or mongodb.`)),process.exit(1)),t.database=e.database),e.orm&&(["drizzle","prisma"].includes(e.orm)||(j(h.red(`Invalid ORM type: ${e.orm}. Must be drizzle or prisma.`)),process.exit(1)),t.orm=e.orm),t.database==="mongodb"&&t.orm==="drizzle"&&(j(h.red("MongoDB is only available with Prisma. Cannot use --database mongodb with --orm drizzle")),process.exit(1)),e.dbSetup&&(["turso","prisma-postgres","mongodb-atlas","none"].includes(e.dbSetup)||(j(h.red(`Invalid database setup: ${e.dbSetup}. Must be turso, prisma-postgres, mongodb-atlas, or none.`)),process.exit(1)),e.dbSetup!=="none"?(t.dbSetup=e.dbSetup,e.dbSetup==="turso"?(e.database&&e.database!=="sqlite"&&(j(h.red(`Turso setup requires a SQLite database. Cannot use --db-setup turso with --database ${e.database}`)),process.exit(1)),t.database="sqlite",e.orm==="prisma"&&(j(h.red("Turso setup is not compatible with Prisma. Cannot use --db-setup turso with --orm prisma")),process.exit(1)),t.orm="drizzle"):e.dbSetup==="prisma-postgres"?(e.database&&e.database!=="postgres"&&(j(h.red("Prisma PostgreSQL setup requires PostgreSQL database. Cannot use --db-setup prisma-postgres with a different database type.")),process.exit(1)),t.database="postgres",e.orm&&e.orm!=="prisma"&&(j(h.red("Prisma PostgreSQL setup requires Prisma ORM. Cannot use --db-setup prisma-postgres with a different ORM.")),process.exit(1)),t.orm="prisma"):e.dbSetup==="mongodb-atlas"&&(e.database&&e.database!=="mongodb"&&(j(h.red("MongoDB Atlas setup requires MongoDB database. Cannot use --db-setup mongodb-atlas with a different database type.")),process.exit(1)),t.database="mongodb",t.orm="prisma")):t.dbSetup="none"),t.database==="none"&&(e.auth===!0&&(j(h.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(j(h.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),e.dbSetup&&e.dbSetup!=="none"&&(j(h.red(`Database setup requires a database. Cannot use --db-setup ${e.dbSetup} with --database none.`)),process.exit(1))),"auth"in e&&(t.auth=e.auth),e.backend&&(["hono","elysia","express"].includes(e.backend)||(j(h.red(`Invalid backend framework: ${e.backend}. Must be hono, elysia, or express.`)),process.exit(1)),t.backend=e.backend),e.runtime&&(["bun","node"].includes(e.runtime)||(j(h.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),t.runtime=e.runtime),e.frontend&&e.frontend.length>0){let r=["tanstack-router","react-router","tanstack-start","native","none"],s=e.frontend.filter(n=>!r.includes(n));if(s.length>0&&(j(h.red(`Invalid frontend(s): ${s.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.frontend.includes("none"))e.frontend.length>1&&(j(h.red("Cannot combine 'none' with other frontend options.")),process.exit(1)),t.frontend=[];else{let n=e.frontend.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start"||i==="native");n.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start").length>1&&(j(h.red("Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router")),process.exit(1)),t.frontend=n}}if(e.addons&&e.addons.length>0){let r=["pwa","tauri","biome","husky","starlight","none"],s=e.addons.filter(n=>!r.includes(n));if(s.length>0&&(j(h.red(`Invalid addon(s): ${s.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.addons.includes("none"))e.addons.length>1&&(j(h.red("Cannot combine 'none' with other addons.")),process.exit(1)),t.addons=[];else{let n=e.addons.filter(c=>c==="pwa"||c==="tauri"||c==="biome"||c==="husky"||c==="starlight"),o=["pwa","tauri"],i=n.some(c=>o.includes(c)),p=t.frontend?.some(c=>c==="tanstack-router"||c==="react-router");i&&!p&&(j(h.red("PWA and Tauri addons require tanstack-router or react-router. Cannot use these addons with your frontend selection.")),process.exit(1)),n.includes("husky")&&!n.includes("biome")&&n.push("biome"),t.addons=n}}if("examples"in e){if(e.examples===!1)t.examples=[];else if(Array.isArray(e.examples)){let r=["todo","ai"],s=e.examples.filter(o=>!r.includes(o));s.length>0&&(j(h.red(`Invalid example(s): ${s.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&(e.backend==="elysia"||t.backend==="elysia")&&(j(h.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1));let n=t.frontend?.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o));e.examples.length>0&&!n&&(!e.frontend||!e.frontend.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o)))&&(j(h.red("Examples require a web frontend (tanstack-router, react-router, or tanstack-start). Cannot use --examples without a compatible frontend.")),process.exit(1)),t.examples=e.examples.filter(o=>o==="todo"||o==="ai")}}return e.packageManager&&(["npm","pnpm","bun"].includes(e.packageManager)||(j(h.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),t.packageManager=e.packageManager),"git"in e&&(t.git=e.git),"install"in e&&(t.noInstall=!e.install),a&&(t.projectName=a),t}gs().catch(e=>{I.error("Aborting installation..."),e instanceof Error?I.error(e.message):(I.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
292
+ `)):console.log(Mt(Object.values(zt)).multiline(Nt))};var Ut=()=>process.exit(0);process.on("SIGINT",Ut);process.on("SIGTERM",Ut);var Pe=new Fn;async function In(){let e=Date.now();Pe.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Lt()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--database <type>","Database type (none, sqlite, postgres, mysql, mongodb)").option("--orm <type>","ORM type (drizzle, prisma)").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--frontend <types...>","Frontend types (tanstack-router, react-router, tanstack-start, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, starlight, biome, husky, none)").option("--examples <types...>","Examples to include (todo, ai)").option("--no-examples","Skip all examples").option("--git","Initialize git repository").option("--no-git","Skip git initialization").option("--package-manager <pm>","Package manager (npm, pnpm, bun)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--db-setup <setup>","Database setup (turso, neon, prisma-postgres, mongodb-atlas, none)").option("--backend <framework>","Backend framework (hono, express, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=Rn();try{_t(),Dn(h.magenta("Creating a new Better-T-Stack project"));let t=Pe.opts(),r=Pe.args[0],n=On(t,r);!t.yes&&Object.keys(n).length>0&&(F.info(h.yellow("Using these pre-selected options:")),F.message(ye(n)),F.message(""));let s=t.yes?{...P,projectName:r??P.projectName,...n}:await Ot(n);t.yes&&(F.info(h.yellow("Using these default options:")),F.message(ye(s)),F.message("")),await ht(s),F.success(h.blue(`You can reproduce this setup with the following command:
293
+ ${h.white(Bt(s))}`));let o=((Date.now()-e)/1e3).toFixed(2);Cn(h.magenta(`Project created successfully in ${h.bold(o)} seconds!`))}catch(t){a.stop(h.red("Failed")),t instanceof Error&&(j(h.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function On(e,a){let t={};if(e.database&&(["none","sqlite","postgres","mysql","mongodb"].includes(e.database)||(j(h.red(`Invalid database type: ${e.database}. Must be none, sqlite, postgres, mysql, or mongodb.`)),process.exit(1)),t.database=e.database),e.orm&&(["drizzle","prisma"].includes(e.orm)||(j(h.red(`Invalid ORM type: ${e.orm}. Must be drizzle or prisma.`)),process.exit(1)),t.orm=e.orm),t.database==="mongodb"&&t.orm==="drizzle"&&(j(h.red("MongoDB is only available with Prisma. Cannot use --database mongodb with --orm drizzle")),process.exit(1)),e.dbSetup&&(["turso","prisma-postgres","mongodb-atlas","neon","none"].includes(e.dbSetup)||(j(h.red(`Invalid database setup: ${e.dbSetup}. Must be turso, prisma-postgres, mongodb-atlas, neon, or none.`)),process.exit(1)),e.dbSetup!=="none"?(t.dbSetup=e.dbSetup,e.dbSetup==="turso"?(e.database&&e.database!=="sqlite"&&(j(h.red(`Turso setup requires a SQLite database. Cannot use --db-setup turso with --database ${e.database}`)),process.exit(1)),t.database="sqlite",e.orm==="prisma"&&(j(h.red("Turso setup is not compatible with Prisma. Cannot use --db-setup turso with --orm prisma")),process.exit(1)),t.orm="drizzle"):e.dbSetup==="prisma-postgres"?(e.database&&e.database!=="postgres"&&(j(h.red("Prisma PostgreSQL setup requires PostgreSQL database. Cannot use --db-setup prisma-postgres with a different database type.")),process.exit(1)),t.database="postgres",e.orm&&e.orm!=="prisma"&&(j(h.red("Prisma PostgreSQL setup requires Prisma ORM. Cannot use --db-setup prisma-postgres with a different ORM.")),process.exit(1)),t.orm="prisma"):e.dbSetup==="mongodb-atlas"?(e.database&&e.database!=="mongodb"&&(j(h.red("MongoDB Atlas setup requires MongoDB database. Cannot use --db-setup mongodb-atlas with a different database type.")),process.exit(1)),t.database="mongodb",t.orm="prisma"):e.dbSetup==="neon"&&(e.database&&e.database!=="postgres"&&(j(h.red("Neon PostgreSQL setup requires PostgreSQL database. Cannot use --db-setup neon with a different database type.")),process.exit(1)),t.database="postgres")):t.dbSetup="none"),t.database==="none"&&(e.auth===!0&&(j(h.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(j(h.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),e.dbSetup&&e.dbSetup!=="none"&&(j(h.red(`Database setup requires a database. Cannot use --db-setup ${e.dbSetup} with --database none.`)),process.exit(1))),"auth"in e&&(t.auth=e.auth),e.backend&&(["hono","elysia","express"].includes(e.backend)||(j(h.red(`Invalid backend framework: ${e.backend}. Must be hono, elysia, or express.`)),process.exit(1)),t.backend=e.backend),e.runtime&&(["bun","node"].includes(e.runtime)||(j(h.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),t.runtime=e.runtime),e.frontend&&e.frontend.length>0){let r=["tanstack-router","react-router","tanstack-start","native","none"],n=e.frontend.filter(s=>!r.includes(s));if(n.length>0&&(j(h.red(`Invalid frontend(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.frontend.includes("none"))e.frontend.length>1&&(j(h.red("Cannot combine 'none' with other frontend options.")),process.exit(1)),t.frontend=[];else{let s=e.frontend.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start"||i==="native");s.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start").length>1&&(j(h.red("Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router")),process.exit(1)),t.frontend=s}}if(e.addons&&e.addons.length>0){let r=["pwa","tauri","biome","husky","starlight","none"],n=e.addons.filter(s=>!r.includes(s));if(n.length>0&&(j(h.red(`Invalid addon(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.addons.includes("none"))e.addons.length>1&&(j(h.red("Cannot combine 'none' with other addons.")),process.exit(1)),t.addons=[];else{let s=e.addons.filter(c=>c==="pwa"||c==="tauri"||c==="biome"||c==="husky"||c==="starlight"),o=["pwa","tauri"],i=s.some(c=>o.includes(c)),p=t.frontend?.some(c=>c==="tanstack-router"||c==="react-router");i&&!p&&(j(h.red("PWA and Tauri addons require tanstack-router or react-router. Cannot use these addons with your frontend selection.")),process.exit(1)),s.includes("husky")&&!s.includes("biome")&&s.push("biome"),t.addons=s}}if("examples"in e){if(e.examples===!1)t.examples=[];else if(Array.isArray(e.examples)){let r=["todo","ai"],n=e.examples.filter(o=>!r.includes(o));n.length>0&&(j(h.red(`Invalid example(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&(e.backend==="elysia"||t.backend==="elysia")&&(j(h.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1));let s=t.frontend?.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o));e.examples.length>0&&!s&&(!e.frontend||!e.frontend.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o)))&&(j(h.red("Examples require a web frontend (tanstack-router, react-router, or tanstack-start). Cannot use --examples without a compatible frontend.")),process.exit(1)),t.examples=e.examples.filter(o=>o==="todo"||o==="ai")}}return e.packageManager&&(["npm","pnpm","bun"].includes(e.packageManager)||(j(h.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),t.packageManager=e.packageManager),"git"in e&&(t.git=e.git),"install"in e&&(t.noInstall=!e.install),a&&(t.projectName=a),t}In().catch(e=>{F.error("Aborting installation..."),e instanceof Error?F.error(e.message):(F.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
5
5
  "type": "module",
6
6
  "license": "MIT",