create-better-t-stack 1.4.3 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -2
  2. package/dist/index.js +40 -39
  3. package/package.json +29 -2
package/README.md CHANGED
@@ -50,8 +50,7 @@ Options:
50
50
  --auth Include authentication
51
51
  --no-auth Exclude authentication
52
52
  --frontend <types...> Frontend types (web, native, none)
53
- --addons <types...> Additional addons (pwa, tauri, biome, husky)
54
- --no-addons Skip all additional addons
53
+ --addons <types...> Additional addons (pwa, tauri, biome, husky, none)
55
54
  --examples <types...> Examples to include (todo, ai)
56
55
  --no-examples Skip all examples
57
56
  --git Initialize git repository
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as j,intro as hr,log as E,outro as gr,spinner as br}from"@clack/prompts";import{Command as wr}from"commander";import u from"picocolors";import te from"node:path";import{fileURLToPath as ct}from"node:url";var U=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var pt=ct(import.meta.url),dt=te.dirname(pt),x=te.join(dt,"../"),m={projectName:"my-better-t-app",frontend:["web"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:U(),noInstall:!1,turso:!1,backend:"hono",runtime:"bun"},Q={"better-auth":"^1.2.4","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",postgres:"^3.4.5","@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",ai:"^4.2.8","@ai-sdk/google":"^1.2.3"};import ca from"node:path";import{cancel as pa,spinner as da}from"@clack/prompts";import la from"fs-extra";import Se from"picocolors";import S from"node:path";import T from"fs-extra";import lt from"node:path";import ae from"fs-extra";var b=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,n=lt.join(r,"package.json"),o=ae.readJSONSync(n);o.dependencies||(o.dependencies={}),o.devDependencies||(o.devDependencies={});for(let i of a){let s=Q[i];o.dependencies[i]=s}for(let i of t){let s=Q[i];o.devDependencies[i]=s}ae.writeJSONSync(n,o,{spaces:2})};import G from"node:path";import{log as ut,spinner as mt}from"@clack/prompts";import{execa as ft}from"execa";import q from"fs-extra";import re from"picocolors";async function ne(e,a){let t=mt(),r=G.join(e,"apps/web");if(await q.pathExists(r))try{t.start("Setting up Tauri desktop app support..."),b({devDependencies:["@tauri-apps/cli"],projectDir:r});let n=G.join(r,"package.json");if(await q.pathExists(n)){let s=await q.readJson(n);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await q.writeJson(n,s,{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"]}i=[...i,"init",`--app-name=${G.basename(e)}`,`--window-title=${G.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ft(o,i,{cwd:r,env:{CI:"true"}}),t.stop("Tauri desktop app support configured successfully!")}catch(n){throw t.stop(re.red("Failed to set up Tauri")),n instanceof Error&&ut.error(re.red(n.message)),n}}async function oe(e,a,t,r){let n=r.includes("web");a.includes("pwa")&&n&&await bt(e),a.includes("tauri")&&n&&await ne(e,t),a.includes("biome")&&await ht(e),a.includes("husky")&&await gt(e)}async function ht(e){let a=S.join(x,"template/with-biome");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0}),b({devDependencies:["@biomejs/biome"],projectDir:e});let t=S.join(e,"package.json");if(await T.pathExists(t)){let r=await T.readJson(t);r.scripts={...r.scripts,check:"biome check --write ."},await T.writeJson(t,r,{spaces:2})}}async function gt(e){let a=S.join(x,"template/with-husky");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0}),b({devDependencies:["husky","lint-staged"],projectDir:e});let t=S.join(e,"package.json");if(await T.pathExists(t)){let r=await T.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 T.writeJson(t,r,{spaces:2})}}async function bt(e){let a=S.join(x,"template/with-pwa");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0});let t=S.join(e,"apps/web");if(!await T.pathExists(t))return;b({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let r=S.join(t,"package.json");if(await T.pathExists(r)){let n=await T.readJson(r);n.scripts={...n.scripts,"generate-pwa-assets":"pwa-assets-generator"},await T.writeJson(r,n,{spaces:2})}}import ie from"node:path";import{log as se}from"@clack/prompts";import ce from"picocolors";function pe(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 de(e,a){if(!a)return;let t=ie.join(e,"apps/server"),r=ie.join(e,"apps/web");try{b({dependencies:["better-auth"],projectDir:t}),b({dependencies:["better-auth"],projectDir:r})}catch(n){throw se.error(ce.red("Failed to configure authentication")),n instanceof Error&&se.error(ce.red(n.message)),n}}import wt from"node:path";async function le(e,a,t){let r=wt.join(e,"apps/server"),n=[],o=[];a==="hono"?(n.push("hono","@hono/trpc-server"),t==="node"&&(n.push("@hono/node-server"),o.push("tsx","@types/node"))):a==="elysia"&&(n.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(n.push("@elysiajs/node"),o.push("tsx","@types/node"))),t==="bun"&&o.push("@types/bun"),b({dependencies:n,devDependencies:o,projectDir:r})}import yt from"node:path";import Pt from"fs-extra";async function ue(e,a){let t=yt.join(e,"README.md"),r=jt(a);try{await Pt.writeFile(t,r)}catch(n){console.error("Failed to create README.md file:",n)}}function jt(e){let{projectName:a,packageManager:t,database:r,auth:n,addons:o=[],orm:i="drizzle",runtime:s="bun"}=e,c=t==="npm"?"npm run":t;return`# ${a}
2
+ import{cancel as j,intro as br,log as E,outro as wr,spinner as Pr}from"@clack/prompts";import{Command as yr}from"commander";import l from"picocolors";import te from"node:path";import{fileURLToPath as pt}from"node:url";var U=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var dt=pt(import.meta.url),lt=te.dirname(dt),k=te.join(lt,"../"),m={projectName:"my-better-t-app",frontend:["web"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:U(),noInstall:!1,turso:!1,backend:"hono",runtime:"bun"},Q={"better-auth":"^1.2.4","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",postgres:"^3.4.5","@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",ai:"^4.2.8","@ai-sdk/google":"^1.2.3"};import da from"node:path";import{cancel as la,spinner as ua}from"@clack/prompts";import ma from"fs-extra";import Re from"picocolors";import D from"node:path";import T from"fs-extra";import ut from"node:path";import ae from"fs-extra";var b=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,n=ut.join(r,"package.json"),o=ae.readJSONSync(n);o.dependencies||(o.dependencies={}),o.devDependencies||(o.devDependencies={});for(let i of a){let s=Q[i];o.dependencies[i]=s}for(let i of t){let s=Q[i];o.devDependencies[i]=s}ae.writeJSONSync(n,o,{spaces:2})};import G from"node:path";import{log as mt,spinner as ft}from"@clack/prompts";import{execa as ht}from"execa";import q from"fs-extra";import re from"picocolors";async function ne(e,a){let t=ft(),r=G.join(e,"apps/web");if(await q.pathExists(r))try{t.start("Setting up Tauri desktop app support..."),b({devDependencies:["@tauri-apps/cli"],projectDir:r});let n=G.join(r,"package.json");if(await q.pathExists(n)){let s=await q.readJson(n);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await q.writeJson(n,s,{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"]}i=[...i,"init",`--app-name=${G.basename(e)}`,`--window-title=${G.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ht(o,i,{cwd:r,env:{CI:"true"}}),t.stop("Tauri desktop app support configured successfully!")}catch(n){throw t.stop(re.red("Failed to set up Tauri")),n instanceof Error&&mt.error(re.red(n.message)),n}}async function oe(e,a,t,r){let n=r.includes("web");a.includes("pwa")&&n&&await wt(e),a.includes("tauri")&&n&&await ne(e,t),a.includes("biome")&&await gt(e),a.includes("husky")&&await bt(e)}async function gt(e){let a=D.join(k,"template/with-biome");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0}),b({devDependencies:["@biomejs/biome"],projectDir:e});let t=D.join(e,"package.json");if(await T.pathExists(t)){let r=await T.readJson(t);r.scripts={...r.scripts,check:"biome check --write ."},await T.writeJson(t,r,{spaces:2})}}async function bt(e){let a=D.join(k,"template/with-husky");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0}),b({devDependencies:["husky","lint-staged"],projectDir:e});let t=D.join(e,"package.json");if(await T.pathExists(t)){let r=await T.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 T.writeJson(t,r,{spaces:2})}}async function wt(e){let a=D.join(k,"template/with-pwa");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0});let t=D.join(e,"apps/web");if(!await T.pathExists(t))return;b({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let r=D.join(t,"package.json");if(await T.pathExists(r)){let n=await T.readJson(r);n.scripts={...n.scripts,"generate-pwa-assets":"pwa-assets-generator"},await T.writeJson(r,n,{spaces:2})}}import ie from"node:path";import{log as se}from"@clack/prompts";import ce from"picocolors";function pe(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 de(e,a){if(!a)return;let t=ie.join(e,"apps/server"),r=ie.join(e,"apps/web");try{b({dependencies:["better-auth"],projectDir:t}),b({dependencies:["better-auth"],projectDir:r})}catch(n){throw se.error(ce.red("Failed to configure authentication")),n instanceof Error&&se.error(ce.red(n.message)),n}}import Pt from"node:path";async function le(e,a,t){let r=Pt.join(e,"apps/server"),n=[],o=[];a==="hono"?(n.push("hono","@hono/trpc-server"),t==="node"&&(n.push("@hono/node-server"),o.push("tsx","@types/node"))):a==="elysia"&&(n.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(n.push("@elysiajs/node"),o.push("tsx","@types/node"))),t==="bun"&&o.push("@types/bun"),b({dependencies:n,devDependencies:o,projectDir:r})}import yt from"node:path";import jt from"fs-extra";async function ue(e,a){let t=yt.join(e,"README.md"),r=vt(a);try{await jt.writeFile(t,r)}catch(n){console.error("Failed to create README.md file:",n)}}function vt(e){let{projectName:a,packageManager:t,database:r,auth:n,addons:o=[],orm:i="drizzle",runtime:s="bun"}=e,c=t==="npm"?"npm run":t;return`# ${a}
3
3
 
4
4
  This project was created with [Better-T-Stack](https://github.com/better-t-stack/Better-T-Stack), a modern TypeScript stack that combines React, TanStack Router, Hono, tRPC, and more.
5
5
 
6
6
  ## Features
7
7
 
8
- ${vt(r,n,o,i,s)}
8
+ ${xt(r,n,o,i,s)}
9
9
 
10
10
  ## Getting Started
11
11
 
@@ -37,8 +37,8 @@ ${a}/
37
37
 
38
38
  ## Available Scripts
39
39
 
40
- ${xt(c,r,i,n)}
41
- `}function vt(e,a,t,r,n){let o=["- **TypeScript** - For type safety and improved developer experience","- **TanStack Router** - File-based routing with full type safety","- **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"&&o.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&o.push("- **Authentication** - Email & password authentication with Better Auth");for(let i of t)i==="pwa"?o.push("- **PWA** - Progressive Web App support"):i==="tauri"?o.push("- **Tauri** - Build native desktop applications"):i==="biome"?o.push("- **Biome** - Linting and formatting"):i==="husky"&&o.push("- **Husky** - Git hooks for code quality");return o.join(`
40
+ ${Tt(c,r,i,n)}
41
+ `}function xt(e,a,t,r,n){let o=["- **TypeScript** - For type safety and improved developer experience","- **TanStack Router** - File-based routing with full type safety","- **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"&&o.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&o.push("- **Authentication** - Email & password authentication with Better Auth");for(let i of t)i==="pwa"?o.push("- **PWA** - Progressive Web App support"):i==="tauri"?o.push("- **Tauri** - Build native desktop applications"):i==="biome"?o.push("- **Biome** - Linting and formatting"):i==="husky"&&o.push("- **Husky** - Git hooks for code quality");return o.join(`
42
42
  `)}function kt(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
43
43
 
44
44
  `;return e==="sqlite"?n+=`This project uses SQLite${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
@@ -61,17 +61,17 @@ ${t} db:push
61
61
  \`\`\`bash
62
62
  ${t} db:push
63
63
  \`\`\``}
64
- `,n}function xt(e,a,t,r){let n=`- \`${e} dev\`: Start both web and server in development mode
64
+ `,n}function Tt(e,a,t,r){let n=`- \`${e} dev\`: Start both web and server in development mode
65
65
  - \`${e} build\`: Build both web and server
66
66
  - \`${e} dev:web\`: Start only the web application
67
67
  - \`${e} dev:server\`: Start only the server
68
68
  - \`${e} check-types\`: Check TypeScript types across all apps`;return a!=="none"&&(n+=`
69
69
  - \`${e} db:push\`: Push schema changes to database
70
70
  - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(n+=`
71
- - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),n}import he from"node:path";import{log as Nt,spinner as _t}from"@clack/prompts";import Bt from"fs-extra";import ge from"picocolors";import Tt from"node:os";import me from"node:path";import{cancel as K,confirm as Et,isCancel as X,log as L,select as $t,spinner as Y,text as Ct}from"@clack/prompts";import{$ as O}from"execa";import At from"fs-extra";import A from"picocolors";async function Ot(){try{return(await O`turso --version`).exitCode===0}catch{return!1}}async function It(){try{return!(await O`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function Ft(){let e=Y();try{return e.start("Logging in to Turso..."),await O`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(A.red("Failed to log in to Turso")),a}}async function Dt(e){let a=Y();try{if(a.start("Installing Turso CLI..."),e)await O`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await O`curl -sSfL https://get.tur.so/install.sh`;await O`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(),L.warn(A.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(A.red("Failed to install Turso CLI")),t)}}async function St(){try{let{stdout:e}=await O`turso group list`,a=e.trim().split(`
72
- `);return a.length<=1?[]:a.slice(1).map(r=>{let[n,o,i,s]=r.trim().split(/\s{2,}/);return{name:n,locations:o,version:i,status:s}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function Rt(){let e=await St();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 $t({message:"Select a Turso database group:",options:a});return X(t)&&(K(A.red("Operation cancelled")),process.exit(0)),t}async function Lt(e,a){try{a?await O`turso db create ${e} --group ${a}`:await O`turso db create ${e}`}catch(n){throw n instanceof Error&&n.message.includes("already exists")?new Error("DATABASE_EXISTS"):n}let{stdout:t}=await O`turso db show ${e} --url`,{stdout:r}=await O`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function B(e,a){let t=me.join(e,"apps/server",".env"),r=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
71
+ - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),n}import he from"node:path";import{log as _t,spinner as Bt}from"@clack/prompts";import zt from"fs-extra";import ge from"picocolors";import Et from"node:os";import me from"node:path";import{cancel as K,confirm as $t,isCancel as X,log as L,select as Ct,spinner as Y,text as At}from"@clack/prompts";import{$ as O}from"execa";import Ot from"fs-extra";import A from"picocolors";async function It(){try{return(await O`turso --version`).exitCode===0}catch{return!1}}async function Ft(){try{return!(await O`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function St(){let e=Y();try{return e.start("Logging in to Turso..."),await O`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(A.red("Failed to log in to Turso")),a}}async function Dt(e){let a=Y();try{if(a.start("Installing Turso CLI..."),e)await O`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await O`curl -sSfL https://get.tur.so/install.sh`;await O`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(),L.warn(A.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(A.red("Failed to install Turso CLI")),t)}}async function Rt(){try{let{stdout:e}=await O`turso group list`,a=e.trim().split(`
72
+ `);return a.length<=1?[]:a.slice(1).map(r=>{let[n,o,i,s]=r.trim().split(/\s{2,}/);return{name:n,locations:o,version:i,status:s}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function Lt(){let e=await Rt();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 Ct({message:"Select a Turso database group:",options:a});return X(t)&&(K(A.red("Operation cancelled")),process.exit(0)),t}async function Nt(e,a){try{a?await O`turso db create ${e} --group ${a}`:await O`turso db create ${e}`}catch(n){throw n instanceof Error&&n.message.includes("already exists")?new Error("DATABASE_EXISTS"):n}let{stdout:t}=await O`turso db show ${e} --url`,{stdout:r}=await O`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function B(e,a){let t=me.join(e,"apps/server",".env"),r=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
73
73
  TURSO_AUTH_TOKEN="${a.authToken}"`:`TURSO_CONNECTION_URL=
74
- TURSO_AUTH_TOKEN=`;await At.writeFile(t,r)}function J(){L.info(`Manual Turso Setup Instructions:
74
+ TURSO_AUTH_TOKEN=`;await Ot.writeFile(t,r)}function J(){L.info(`Manual Turso Setup Instructions:
75
75
 
76
76
  1. Visit https://turso.tech and create an account
77
77
  2. Create a new database from the dashboard
@@ -79,7 +79,7 @@ TURSO_AUTH_TOKEN=`;await At.writeFile(t,r)}function J(){L.info(`Manual Turso Set
79
79
  4. Add these credentials to the .env file in apps/server/.env
80
80
 
81
81
  TURSO_CONNECTION_URL=your_database_url
82
- TURSO_AUTH_TOKEN=your_auth_token`)}async function fe(e,a){if(!a){await B(e),L.info(A.blue("Skipping Turso setup. Setting up empty configuration.")),J();return}let t=Tt.platform(),r=t==="darwin";if(!(t!=="win32")){L.warn(A.yellow("Automatic Turso setup is not supported on Windows.")),await B(e),J();return}try{if(!await Ot()){let v=await Et({message:"Would you like to install Turso CLI?",initialValue:!0});if(X(v)&&(K(A.red("Operation cancelled")),process.exit(0)),!v){await B(e),J();return}await Dt(r)}await It()||await Ft();let s=await Rt(),c=!1,w="",P=me.basename(e);for(;!c;){let v=await Ct({message:"Enter a name for your database:",defaultValue:P,initialValue:P,placeholder:P});X(v)&&(K(A.red("Operation cancelled")),process.exit(0)),w=v;let g=Y();try{g.start(`Creating Turso database "${w}"${s?` in group "${s}"`:""}...`);let C=await Lt(w,s);await B(e,C),g.stop("Turso database configured successfully!"),c=!0}catch(C){if(C instanceof Error&&C.message==="DATABASE_EXISTS")g.stop(A.yellow(`Database "${A.red(w)}" already exists`)),P=`${w}-${Math.floor(Math.random()*1e3)}`;else throw g.stop(A.red("Failed to create Turso database")),C}}}catch(o){L.error(A.red(`Error during Turso setup: ${o}`)),await B(e),J(),L.success("Setup completed with manual configuration required.")}}async function be(e,a,t,r=!0){let n=_t(),o=he.join(e,"apps/server");if(a==="none"){await Bt.remove(he.join(o,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?b({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&b({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}),r&&await fe(e,!0)):a==="postgres"&&(t==="drizzle"?b({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&b({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}))}catch(i){throw n.stop(ge.red("Failed to set up database")),i instanceof Error&&Nt.error(ge.red(i.message)),i}}import N from"node:path";import I from"fs-extra";async function we(e,a){let t=N.join(e,"apps/server"),r=N.join(t,".env"),n="";if(await I.pathExists(r)&&(n=await I.readFile(r,"utf8")),n.includes("CORS_ORIGIN")||(n+=`
82
+ TURSO_AUTH_TOKEN=your_auth_token`)}async function fe(e,a){if(!a){await B(e),L.info(A.blue("Skipping Turso setup. Setting up empty configuration.")),J();return}let t=Et.platform(),r=t==="darwin";if(!(t!=="win32")){L.warn(A.yellow("Automatic Turso setup is not supported on Windows.")),await B(e),J();return}try{if(!await It()){let v=await $t({message:"Would you like to install Turso CLI?",initialValue:!0});if(X(v)&&(K(A.red("Operation cancelled")),process.exit(0)),!v){await B(e),J();return}await Dt(r)}await Ft()||await St();let s=await Lt(),c=!1,w="",y=me.basename(e);for(;!c;){let v=await At({message:"Enter a name for your database:",defaultValue:y,initialValue:y,placeholder:y});X(v)&&(K(A.red("Operation cancelled")),process.exit(0)),w=v;let g=Y();try{g.start(`Creating Turso database "${w}"${s?` in group "${s}"`:""}...`);let C=await Nt(w,s);await B(e,C),g.stop("Turso database configured successfully!"),c=!0}catch(C){if(C instanceof Error&&C.message==="DATABASE_EXISTS")g.stop(A.yellow(`Database "${A.red(w)}" already exists`)),y=`${w}-${Math.floor(Math.random()*1e3)}`;else throw g.stop(A.red("Failed to create Turso database")),C}}}catch(o){L.error(A.red(`Error during Turso setup: ${o}`)),await B(e),J(),L.success("Setup completed with manual configuration required.")}}async function be(e,a,t,r=!0){let n=Bt(),o=he.join(e,"apps/server");if(a==="none"){await zt.remove(he.join(o,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?b({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&b({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}),r&&await fe(e,!0)):a==="postgres"&&(t==="drizzle"?b({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&b({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}))}catch(i){throw n.stop(ge.red("Failed to set up database")),i instanceof Error&&_t.error(ge.red(i.message)),i}}import N from"node:path";import I from"fs-extra";async function we(e,a){let t=N.join(e,"apps/server"),r=N.join(t,".env"),n="";if(await I.pathExists(r)&&(n=await I.readFile(r,"utf8")),n.includes("CORS_ORIGIN")||(n+=`
83
83
  CORS_ORIGIN=http://localhost:3001`),a.auth&&(n.includes("BETTER_AUTH_SECRET")||(n+=`
84
84
  BETTER_AUTH_SECRET=${pe()}`),n.includes("BETTER_AUTH_URL")||(n+=`
85
85
  BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!n.includes("DATABASE_URL")){let o=a.database==="sqlite"?"":`
@@ -87,7 +87,7 @@ DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`
87
87
  TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}if(a.examples?.includes("ai")&&!n.includes("GOOGLE_GENERATIVE_AI_API_KEY")&&(n+=`
88
88
  GOOGLE_GENERATIVE_AI_API_KEY=`),await I.writeFile(r,n.trim()),a.frontend.includes("web")){let o=N.join(e,"apps/web"),i=N.join(o,".env"),s="";await I.pathExists(i)&&(s=await I.readFile(i,"utf8")),s.includes("VITE_SERVER_URL")||(s+=`VITE_SERVER_URL=http://localhost:3000
89
89
  `),await I.writeFile(i,s.trim())}if(a.frontend.includes("native")){let o=N.join(e,"apps/native"),i=N.join(o,".env"),s="";await I.pathExists(i)&&(s=await I.readFile(i,"utf8")),s.includes("EXPO_PUBLIC_SERVER_URL")||(s+=`EXPO_PUBLIC_SERVER_URL=http://localhost:3000
90
- `),await I.writeFile(i,s.trim())}}import k from"node:path";import f from"fs-extra";async function ye(e,a,t,r,n,o=["web"]){let i=o.includes("web"),s=await f.pathExists(k.join(e,"apps/web"));a.includes("todo")&&i&&s?await Gt(e,t,r):await Jt(e,t),a.includes("ai")&&n==="hono"&&i&&s&&await zt(e)}async function zt(e){let a=k.join(x,"template/examples/ai");if(await f.pathExists(a)){await f.copy(a,e),await Ut(e);let t=k.join(e,"apps/web");b({dependencies:["ai"],projectDir:t});let r=k.join(e,"apps/server");b({dependencies:["ai","@ai-sdk/google"],projectDir:r}),await Mt(e)}}async function Mt(e){let a=k.join(e,"apps/server/src/index.ts");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");if(t.includes("hono")){let n=`import { streamText } from "ai";
90
+ `),await I.writeFile(i,s.trim())}}import x from"node:path";import f from"fs-extra";async function Pe(e,a,t,r,n,o=["web"]){let i=o.includes("web"),s=await f.pathExists(x.join(e,"apps/web"));a.includes("todo")&&i&&s?await qt(e,t,r):await Vt(e,t),a.includes("ai")&&n==="hono"&&i&&s&&await Mt(e)}async function Mt(e){let a=x.join(k,"template/examples/ai");if(await f.pathExists(a)){await f.copy(a,e),await Gt(e);let t=x.join(e,"apps/web");b({dependencies:["ai"],projectDir:t});let r=x.join(e,"apps/server");b({dependencies:["ai","@ai-sdk/google"],projectDir:r}),await Ut(e)}}async function Ut(e){let a=x.join(e,"apps/server/src/index.ts");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");if(t.includes("hono")){let n=`import { streamText } from "ai";
91
91
  import { google } from "@ai-sdk/google";
92
92
  import { stream } from "hono/streaming";`,o=`
93
93
  app.post("/ai", async (c) => {
@@ -114,53 +114,54 @@ ${t.substring(i)}`;else{let s=t.indexOf("export default");s!==-1?t=`${t.substrin
114
114
 
115
115
  ${t.substring(s)}`:t=`${t}
116
116
 
117
- ${o}`}await f.writeFile(a,t)}}}async function Ut(e){let a=k.join(e,"apps/web/src/components/header.tsx");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t.includes('{ to: "/todos"')?t=t.replace(/{ to: "\/todos", label: "Todos" },/,`{ to: "/todos", label: "Todos" },
117
+ ${o}`}await f.writeFile(a,t)}}}async function Gt(e){let a=x.join(e,"apps/web/src/components/header.tsx");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t.includes('{ to: "/todos"')?t=t.replace(/{ to: "\/todos", label: "Todos" },/,`{ to: "/todos", label: "Todos" },
118
118
  { to: "/ai", label: "AI Chat" },`):t.includes('{ to: "/dashboard"')?t=t.replace(/{ to: "\/dashboard", label: "Dashboard" },/,`{ to: "/dashboard", label: "Dashboard" },
119
119
  { to: "/ai", label: "AI Chat" },`):t=t.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
120
120
  { to: "/", label: "Home" },
121
- { to: "/ai", label: "AI Chat" },`),await f.writeFile(a,t)}}async function Gt(e,a,t){let r=k.join(x,"template/examples/todo");if(await f.pathExists(r)){let n=k.join(r,"apps/web/src/routes"),o=k.join(e,"apps/web/src/routes");if(await f.copy(n,o,{overwrite:!0}),a!=="none"){let i=k.join(r,`apps/server/src/routers/with-${a}-todo.ts`),s=k.join(e,"apps/server/src/routers/todo.ts");await f.pathExists(i)&&await f.copy(i,s,{overwrite:!0})}await qt(e,t),await Wt(e)}}async function qt(e,a){let t=k.join(e,"apps/web/src/components/header.tsx");if(await f.pathExists(t)){let r=await f.readFile(t,"utf8");a?r=r.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
121
+ { to: "/ai", label: "AI Chat" },`),await f.writeFile(a,t)}}async function qt(e,a,t){let r=x.join(k,"template/examples/todo");if(await f.pathExists(r)){let n=x.join(r,"apps/web/src/routes"),o=x.join(e,"apps/web/src/routes");if(await f.copy(n,o,{overwrite:!0}),a!=="none"){let i=x.join(r,`apps/server/src/routers/with-${a}-todo.ts`),s=x.join(e,"apps/server/src/routers/todo.ts");await f.pathExists(i)&&await f.copy(i,s,{overwrite:!0})}await Jt(e,t),await Wt(e)}}async function Jt(e,a){let t=x.join(e,"apps/web/src/components/header.tsx");if(await f.pathExists(t)){let r=await f.readFile(t,"utf8");a?r=r.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
122
122
  { to: "/", label: "Home" },
123
123
  { to: "/dashboard", label: "Dashboard" },
124
124
  { to: "/todos", label: "Todos" },`):r=r.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
125
125
  { to: "/", label: "Home" },
126
- { to: "/todos", label: "Todos" },`),await f.writeFile(t,r)}}async function Jt(e,a){if(a==="drizzle"){let r=k.join(e,"apps/server/src/db/schema/todo.ts");await f.pathExists(r)&&await f.remove(r)}else if(a==="prisma"){let r=k.join(e,"apps/server/prisma/schema/todo.prisma");await f.pathExists(r)&&await f.remove(r)}let t=k.join(e,"apps/server/src/routers/todo.ts");await f.pathExists(t)&&await f.remove(t),await Vt(e)}async function Vt(e){let a=k.join(e,"apps/server/src/routers/index.ts");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await f.writeFile(a,t)}}async function Wt(e){let a=k.join(e,"apps/web/src/routes/index.tsx");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t=t.replace(/<div id="buttons"><\/div>/,`<div id="buttons" className="mt-4 flex flex-col gap-4 sm:flex-row sm:items-center">
126
+ { to: "/todos", label: "Todos" },`),await f.writeFile(t,r)}}async function Vt(e,a){if(a==="drizzle"){let r=x.join(e,"apps/server/src/db/schema/todo.ts");await f.pathExists(r)&&await f.remove(r)}else if(a==="prisma"){let r=x.join(e,"apps/server/prisma/schema/todo.prisma");await f.pathExists(r)&&await f.remove(r)}let t=x.join(e,"apps/server/src/routers/todo.ts");await f.pathExists(t)&&await f.remove(t),await Ht(e)}async function Ht(e){let a=x.join(e,"apps/server/src/routers/index.ts");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await f.writeFile(a,t)}}async function Wt(e){let a=x.join(e,"apps/web/src/routes/index.tsx");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t=t.replace(/<div id="buttons"><\/div>/,`<div id="buttons" className="mt-4 flex flex-col gap-4 sm:flex-row sm:items-center">
127
127
  <Button asChild>
128
128
  <Link to="/todos" className="flex items-center">
129
129
  View Todo Demo
130
130
  <ArrowRight className="ml-1 h-4 w-4" />
131
131
  </Link>
132
132
  </Button>
133
- </div>`),await f.writeFile(a,t)}}import{log as Pe,spinner as je}from"@clack/prompts";import{$ as ve}from"execa";import V from"picocolors";async function ke({projectDir:e,packageManager:a,addons:t=[]}){let r=je();try{r.start(`Running ${a} install...`),await ve({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await Ht(e,a)}catch(n){throw r.stop(V.red("Failed to install dependencies")),n instanceof Error&&Pe.error(V.red(`Installation error: ${n.message}`)),n}}async function Ht(e,a){let t=je();try{t.start("Running Biome format check..."),await ve({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(V.yellow("Biome check encountered issues")),Pe.warn(V.yellow("Some files may need manual formatting"))}}import{note as Qt}from"@clack/prompts";import y from"picocolors";function xe(e,a,t,r,n,o,i,s){let c=t==="npm"?"npm run":t,w=`cd ${a}`,P=o?.includes("husky")||o?.includes("biome"),v=e!=="none"?Yt(e,n,c,i):"",g=o?.includes("tauri")?Zt(c):"",C=P?Xt(c):"",M=s?.includes("native")?Kt():"",_=s?.includes("web"),it=s?.includes("native"),st=_||it;Qt(`${y.cyan("1.")} ${w}
134
- ${r?"":`${y.cyan("2.")} ${t} install
135
- `}${y.cyan(r?"2.":"3.")} ${c} dev
136
-
137
- ${y.bold("Your project will be available at:")}
138
- ${st?`${_?`${y.cyan("\u2022")} Frontend: http://localhost:3001
139
- `:""}`:`${y.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
140
- `}${y.cyan("\u2022")} API: http://localhost:3000
133
+ </div>`),await f.writeFile(a,t)}}import{log as ye,spinner as je}from"@clack/prompts";import{$ as ve}from"execa";import V from"picocolors";async function xe({projectDir:e,packageManager:a,addons:t=[]}){let r=je();try{r.start(`Running ${a} install...`),await ve({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await Qt(e,a)}catch(n){throw r.stop(V.red("Failed to install dependencies")),n instanceof Error&&ye.error(V.red(`Installation error: ${n.message}`)),n}}async function Qt(e,a){let t=je();try{t.start("Running Biome format check..."),await ve({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(V.yellow("Biome check encountered issues")),ye.warn(V.yellow("Some files may need manual formatting"))}}import{note as Kt}from"@clack/prompts";import P from"picocolors";function ke(e,a,t,r,n,o,i,s){let c=t==="npm"?"npm run":t,w=`cd ${a}`,y=o?.includes("husky")||o?.includes("biome"),v=e!=="none"?Zt(e,n,c,i):"",g=o?.includes("tauri")?ea(c):"",C=y?Yt(c):"",M=s?.includes("native")?Xt():"",_=s?.includes("web"),st=s?.includes("native"),ct=_||st;Kt(`${P.cyan("1.")} ${w}
134
+ ${r?"":`${P.cyan("2.")} ${t} install
135
+ `}${P.cyan(r?"2.":"3.")} ${c} dev
136
+
137
+ ${P.bold("Your project will be available at:")}
138
+ ${ct?`${_?`${P.cyan("\u2022")} Frontend: http://localhost:3001
139
+ `:""}`:`${P.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
140
+ `}${P.cyan("\u2022")} API: http://localhost:3000
141
141
  ${M?`
142
142
  ${M.trim()}`:""}${v?`
143
143
  ${v.trim()}`:""}${g?`
144
144
  ${g.trim()}`:""}${C?`
145
- ${C.trim()}`:""}`,"Next steps")}function Kt(){return`${y.yellow("NOTE:")} If the Expo app cannot connect to the server, update the EXPO_PUBLIC_SERVER_URL in apps/native/.env to use your local IP address instead of localhost:
145
+ ${C.trim()}`:""}`,"Next steps")}function Xt(){return`${P.yellow("NOTE:")} For Expo connectivity issues, update apps/native/.env
146
+ with your local IP:
146
147
  EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000
147
- `}function Xt(e){return`${y.bold(`
148
+ `}function Yt(e){return`${P.bold(`
148
149
  Linting and formatting:`)}
149
- ${y.cyan("\u2022")} Format and lint fix: ${`${e} check`}
150
+ ${P.cyan("\u2022")} Format and lint fix: ${`${e} check`}
150
151
 
151
- `}function Yt(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, 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"&&(e==="sqlite"&&n.push(`${y.cyan("\u2022")} Start local DB: ${`cd apps/server && ${t} db:local`}`),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:")}
152
+ `}function Zt(e,a,t,r){let n=[];return a==="prisma"?(e==="sqlite"&&n.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"&&n.push(`${P.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors, follow the guidance provided in the error messages`),n.push(`${P.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${P.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)):a==="drizzle"&&(e==="sqlite"&&n.push(`${P.cyan("\u2022")} Start local DB: ${`cd apps/server && ${t} db:local`}`),n.push(`${P.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${P.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)),n.length?`${P.bold("Database commands:")}
152
153
  ${n.join(`
153
154
  `)}
154
155
 
155
- `:""}function Zt(e){return`${y.bold("Desktop app with Tauri:")}
156
- ${y.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
157
- ${y.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
158
- ${y.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: https://v2.tauri.app/start/prerequisites/
156
+ `:""}function ea(e){return`${P.bold("Desktop app with Tauri:")}
157
+ ${P.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
158
+ ${P.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
159
+ ${P.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: https://v2.tauri.app/start/prerequisites/
159
160
 
160
- `}import W from"node:path";import{$ as ea,execa as ta}from"execa";import F from"fs-extra";async function Te(e,a){await aa(e,a),await ra(e,a)}async function aa(e,a){let t=W.join(e,"package.json");if(await F.pathExists(t)){let r=await F.readJson(t);r.name=a.projectName;let{stdout:n}=await ta(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await F.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let o=W.join(x,"template/with-pnpm/pnpm-workspace.yaml"),i=W.join(e,"pnpm-workspace.yaml");await F.pathExists(o)&&await F.copy(o,i)}}}async function ra(e,a){let t=W.join(e,"apps/server/package.json");if(await F.pathExists(t)){let r=await F.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 F.writeJson(t,r,{spaces:2})}}async function Ee(e,a){a&&await ea({cwd:e})`git init`}import H from"node:path";import D from"fs-extra";async function $e(e,a,t){let r=H.join(e,"apps/server"),n=H.join(r,"src/index.ts"),o=await D.readFile(n,"utf-8");a==="bun"?await na(r,n,o,t):a==="node"&&await oa(r,n,o,t)}async function na(e,a,t,r){let n=H.join(e,"package.json"),o=await D.readJson(n);if(o.scripts={...o.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await D.writeJson(n,o,{spaces:2}),b({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let i=`${t}
161
+ `}import H from"node:path";import{log as ta}from"@clack/prompts";import{$ as Te,execa as aa}from"execa";import F from"fs-extra";import ra from"picocolors";async function Ee(e,a){await na(e,a),await oa(e,a)}async function na(e,a){let t=H.join(e,"package.json");if(await F.pathExists(t)){let r=await F.readJson(t);r.name=a.projectName;let{stdout:n}=await aa(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await F.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let o=H.join(k,"template/with-pnpm/pnpm-workspace.yaml"),i=H.join(e,"pnpm-workspace.yaml");await F.pathExists(o)&&await F.copy(o,i)}}}async function oa(e,a){let t=H.join(e,"apps/server/package.json");if(await F.pathExists(t)){let r=await F.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 F.writeJson(t,r,{spaces:2})}}async function $e(e,a){if(!a)return;if((await Te({cwd:e,reject:!1,stderr:"pipe"})`git --version`).exitCode!==0){ta.warn(ra.yellow("Git is not installed"));return}let r=await Te({cwd:e,reject:!1,stderr:"pipe"})`git init`;if(r.exitCode!==0)throw new Error(`Git initialization failed: ${r.stderr}`)}import W from"node:path";import S from"fs-extra";async function Ce(e,a,t){let r=W.join(e,"apps/server"),n=W.join(r,"src/index.ts"),o=await S.readFile(n,"utf-8");a==="bun"?await ia(r,n,o,t):a==="node"&&await sa(r,n,o,t)}async function ia(e,a,t,r){let n=W.join(e,"package.json"),o=await S.readJson(n);if(o.scripts={...o.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await S.writeJson(n,o,{spaces:2}),b({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let i=`${t}
161
162
 
162
163
  export default app;
163
- `;await D.writeFile(a,i)}}async function oa(e,a,t,r){let n=H.join(e,"package.json"),o=await D.readJson(n);if(o.scripts={...o.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await D.writeJson(n,o,{spaces:2}),b({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){b({dependencies:["@hono/node-server"],projectDir:e});let i=`import { serve } from "@hono/node-server";
164
+ `;await S.writeFile(a,i)}}async function sa(e,a,t,r){let n=W.join(e,"package.json"),o=await S.readJson(n);if(o.scripts={...o.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await S.writeJson(n,o,{spaces:2}),b({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){b({dependencies:["@hono/node-server"],projectDir:e});let i=`import { serve } from "@hono/node-server";
164
165
  `,s=`
165
166
  serve(
166
167
  {
@@ -171,11 +172,11 @@ serve(
171
172
  console.log(\`Server is running on http://localhost:\${info.port}\`);
172
173
  },
173
174
  );
174
- `;if(!t.includes("@hono/node-server")){let c=t.lastIndexOf("import"),w=t.substring(0,c),P=t.substring(c),v=w+i+P+s;await D.writeFile(a,v)}}else if(r==="elysia"&&(b({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let i=`import { node } from "@elysiajs/node";
175
+ `;if(!t.includes("@hono/node-server")){let c=t.lastIndexOf("import"),w=t.substring(0,c),y=t.substring(c),v=w+i+y+s;await S.writeFile(a,v)}}else if(r==="elysia"&&(b({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let i=`import { node } from "@elysiajs/node";
175
176
  `,s=t.indexOf(`
176
- `,t.indexOf("import")),c=t.substring(0,s+1),w=t.substring(s+1),P=c+i+w;P=P.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await D.writeFile(a,P)}}import l from"node:path";import h from"fs-extra";async function Ce(e){let a=l.join(x,"template/base");if(!await h.pathExists(a))throw new Error(`Template directory not found: ${a}`);await h.copy(a,e)}async function Ae(e,a){if(!a.includes("web")){let t=l.join(e,"apps/web");await h.pathExists(t)&&await h.remove(t)}if(a.includes("native"))await h.writeFile(l.join(e,".npmrc"),`node-linker=hoisted
177
- `);else{let t=l.join(e,"apps/native");await h.pathExists(t)&&await h.remove(t)}}async function Oe(e,a){let t=l.join(x,`template/with-${a}`);await h.pathExists(t)&&await h.copy(t,e,{overwrite:!0})}async function Ie(e,a,t,r){if(a==="none"||t==="none")return;let n=l.join(x,ia(a,t));if(await h.pathExists(n)&&(await h.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let o=l.join(e,"apps/server/prisma/schema/auth.prisma");await h.pathExists(o)&&await h.remove(o)}else if(a==="drizzle"){let o=l.join(e,"apps/server/src/db/schema/auth.ts");await h.pathExists(o)&&await h.remove(o)}}}async function Fe(e,a,t,r,n){if(!a)return;let o=l.join(x,"template/with-auth");if(await h.pathExists(o)){let i=l.join(o,"apps/web"),s=l.join(e,"apps/web");await h.copy(i,s,{overwrite:!0});let c=l.join(o,"apps/server/src"),w=l.join(e,"apps/server/src");await h.copy(l.join(c,"lib/trpc.ts"),l.join(w,"lib/trpc.ts"),{overwrite:!0}),await h.copy(l.join(c,"routers/index.ts"),l.join(w,"routers/index.ts"),{overwrite:!0});let P=`with-${t}-context.ts`;await h.copy(l.join(c,"lib",P),l.join(w,"lib/context.ts"),{overwrite:!0});let v=`with-${t}-index.ts`;await h.copy(l.join(c,v),l.join(w,"index.ts"),{overwrite:!0});let g=sa(r,n),C=l.join(c,g);if(await h.pathExists(C)){let M=await h.readdir(C);for(let _ of M)await h.copy(l.join(C,_),l.join(w,"lib",_),{overwrite:!0})}}}async function De(e){let a=[l.join(e,"_gitignore"),l.join(e,"apps/web/_gitignore"),l.join(e,"apps/native/_gitignore"),l.join(e,"apps/server/_gitignore")];for(let t of a)if(await h.pathExists(t)){let r=l.join(l.dirname(t),".gitignore");await h.move(t,r)}}function ia(e,a){return e==="drizzle"?a==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?a==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}function sa(e,a){if(e==="drizzle")return a==="sqlite"?"with-drizzle-sqlite-lib":"with-drizzle-postgres-lib";if(e==="prisma")return a==="sqlite"?"with-prisma-sqlite-lib":"with-prisma-postgres-lib";throw new Error("Invalid ORM or database configuration for auth setup")}async function Re(e){let a=da(),t=ca.resolve(process.cwd(),e.projectName);try{return await la.ensureDir(t),await Ce(t),await Ae(t,e.frontend),await De(t),await Oe(t,e.backend),await le(t,e.backend,e.runtime),await Ie(t,e.orm,e.database,e.auth),await be(t,e.database,e.orm,e.turso??e.database==="sqlite"),await Fe(t,e.auth,e.backend,e.orm,e.database),await de(t,e.auth),await $e(t,e.runtime,e.backend),await ye(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await we(t,e),await Ee(t,e.git),e.addons.length>0&&await oe(t,e.addons,e.packageManager,e.frontend),await Te(t,e),await ue(t,e),e.noInstall||await ke({projectDir:t,packageManager:e.packageManager,addons:e.addons}),xe(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(Se.red("Failed")),r instanceof Error&&(pa(Se.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as dr,group as lr}from"@clack/prompts";import ur from"picocolors";import{cancel as ua,isCancel as ma,multiselect as fa}from"@clack/prompts";import ha from"picocolors";async function Le(e,a){if(e!==void 0)return e;let t=a?.includes("web"),r=[{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)"}],o=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,i=m.addons.filter(c=>t||c!=="pwa"&&c!=="tauri"),s=await fa({message:"Which Addons would you like to add?",options:o,initialValues:i,required:!1});return ma(s)&&(ua(ha.red("Operation cancelled")),process.exit(0)),s.includes("husky")&&!s.includes("biome")&&s.push("biome"),s}import{cancel as ga,confirm as ba,isCancel as wa,log as ya}from"@clack/prompts";import Ne from"picocolors";async function _e(e,a,t){if(!a)return!1;let r=t?.includes("native"),n=t?.includes("web");if(r&&ya.warn(Ne.yellow("Note: Authentication is not yet available with native")),!n)return!1;if(e!==void 0)return e;let o=await ba({message:"Would you like to add authentication with Better-Auth?",initialValue:m.auth});return wa(o)&&(ga(Ne.red("Operation cancelled")),process.exit(0)),o}import{cancel as Pa,isCancel as ja,select as va}from"@clack/prompts";import ka from"picocolors";async function Be(e){if(e!==void 0)return e;let a=await va({message:"Which backend framework would you like to use?",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"elysia",label:"Elysia",hint:"TypeScript framework with end-to-end type safety)"}],initialValue:m.backend});return ja(a)&&(Pa(ka.red("Operation cancelled")),process.exit(0)),a}import{cancel as xa,isCancel as Ta,select as Ea}from"@clack/prompts";import $a from"picocolors";async function ze(e){if(e!==void 0)return e;let a=await Ea({message:"Which database would you like to use?",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:m.database});return Ta(a)&&(xa($a.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ca,isCancel as Aa,multiselect as Me}from"@clack/prompts";import Oa from"picocolors";async function Ue(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!t?.includes("web"))return[];let o=[];return r==="elysia"&&(o=await Me({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:m.examples})),r==="hono"&&(o=await Me({message:"Which examples would you like to include?",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:m.examples})),Aa(o)&&(Ca(Oa.red("Operation cancelled")),process.exit(0)),o}import{cancel as Ia,isCancel as Fa,multiselect as Da}from"@clack/prompts";import Sa from"picocolors";async function Ge(e){if(e!==void 0)return e;let a=await Da({message:"Which frontend applications would you like to create?",options:[{value:"web",label:"Web App",hint:"React + TanStack Router web application"},{value:"native",label:"Native App",hint:"React Native + Expo application"}],initialValues:m.frontend,required:!1});return Fa(a)&&(Ia(Sa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ra,confirm as La,isCancel as Na}from"@clack/prompts";import _a from"picocolors";async function qe(e){if(e!==void 0)return e;let a=await La({message:"Initialize a new git repository?",initialValue:m.git});return Na(a)&&(Ra(_a.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ba,confirm as za,isCancel as Ma}from"@clack/prompts";import Ua from"picocolors";async function Je(e){if(e!==void 0)return e;let a=await za({message:"Do you want to install project dependencies?",initialValue:!m.noInstall});return Ma(a)&&(Ba(Ua.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Ga,isCancel as qa,select as Ja}from"@clack/prompts";import Va from"picocolors";async function Ve(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Ja({message:"Which ORM would you like to use?",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:m.orm});return qa(t)&&(Ga(Va.red("Operation cancelled")),process.exit(0)),t}import{cancel as Wa,isCancel as Ha,select as Qa}from"@clack/prompts";import Ka from"picocolors";async function We(e){if(e!==void 0)return e;let a=U(),t=await Qa({message:"Which package manager do you want to use?",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:a});return Ha(t)&&(Wa(Ka.red("Operation cancelled")),process.exit(0)),t}import z from"node:path";import{cancel as Xa,isCancel as Ya,text as Za}from"@clack/prompts";import R from"fs-extra";import er from"picocolors";var tr=["<",">",":",'"',"|","?","*"],He=255;function Qe(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>He)return`Project name must be less than ${He} characters`;if(tr.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"||e.toLowerCase()==="favicon.ico")return"Project name is reserved"}}async function Ke(e){if(e)if(e==="."){let o=process.cwd();if(R.readdirSync(o).length===0)return e}else{let o=z.basename(e);if(!Qe(o)){let s=z.resolve(process.cwd(),e);if(!R.pathExistsSync(s)||R.readdirSync(s).length===0)return e}}let a=!1,t="",r=m.projectName,n=1;for(;R.pathExistsSync(z.resolve(process.cwd(),r));)r=`${m.projectName}-${n}`,n++;for(;!a;){let o=await Za({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:i=>{let s=i.trim()||r;if(s==="."){if(R.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let c=z.resolve(process.cwd(),s),w=z.basename(c),P=Qe(w);if(P)return P;if(!c.startsWith(process.cwd()))return"Project path must be within current directory";if(R.pathExistsSync(c)&&R.readdirSync(c).length>0)return`Directory "${s}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Ya(o)&&(Xa(er.red("Operation cancelled.")),process.exit(0)),t=o||r}return t}import{cancel as ar,isCancel as rr,select as nr}from"@clack/prompts";import or from"picocolors";async function Xe(e){if(e!==void 0)return e;let a=await nr({message:"Which runtime would you like to use?",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:m.runtime});return rr(a)&&(ar(or.red("Operation cancelled")),process.exit(0)),a}import{cancel as ir,confirm as sr,isCancel as cr}from"@clack/prompts";import pr from"picocolors";async function Ye(e){if(e!==void 0)return e;let a=await sr({message:"Set up a Turso database for this project?",initialValue:m.turso});return cr(a)&&(ir(pr.red("Operation cancelled")),process.exit(0)),a}async function Ze(e){let a=await lr({projectName:async()=>Ke(e.projectName),frontend:()=>Ge(e.frontend),backend:()=>Be(e.backend),runtime:()=>Xe(e.runtime),database:()=>ze(e.database),orm:({results:t})=>Ve(e.orm,t.database!=="none"),auth:({results:t})=>_e(e.auth,t.database!=="none",t.frontend),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Ye(e.turso):Promise.resolve(!1),addons:({results:t})=>Le(e.addons,t.frontend),examples:({results:t})=>Ue(e.examples,t.database,t.frontend,t.backend),git:()=>qe(e.git),packageManager:()=>We(e.packageManager),noInstall:()=>Je(e.noInstall)},{onCancel:()=>{dr(ur.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,turso:a.turso,backend:a.backend,runtime:a.runtime}}import $ from"picocolors";function Z(e){let a=[];if(e.projectName&&a.push(`${$.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${$.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${$.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${$.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${$.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${$.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${$.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${$.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${$.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${$.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${$.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${$.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${$.blue("Turso Setup:")} ${e.turso}`),a.join(`
178
- `)}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.database==="sqlite"&&a.push(e.turso?"--turso":"--no-turso")),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("--no-addons"),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="npm 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 mr from"node:path";import fr from"fs-extra";var tt=()=>{let e=mr.join(x,"package.json");return fr.readJSONSync(e).version??"1.0.0"};import at from"gradient-string";var rt=`
177
+ `,t.indexOf("import")),c=t.substring(0,s+1),w=t.substring(s+1),y=c+i+w;y=y.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await S.writeFile(a,y)}}import u from"node:path";import h from"fs-extra";async function Ae(e){let a=u.join(k,"template/base");if(!await h.pathExists(a))throw new Error(`Template directory not found: ${a}`);await h.copy(a,e)}async function Oe(e,a){if(!a.includes("web")){let t=u.join(e,"apps/web");await h.pathExists(t)&&await h.remove(t)}if(a.includes("native"))await h.writeFile(u.join(e,".npmrc"),`node-linker=hoisted
178
+ `);else{let t=u.join(e,"apps/native");await h.pathExists(t)&&await h.remove(t)}}async function Ie(e,a){let t=u.join(k,`template/with-${a}`);await h.pathExists(t)&&await h.copy(t,e,{overwrite:!0})}async function Fe(e,a,t,r){if(a==="none"||t==="none")return;let n=u.join(k,ca(a,t));if(await h.pathExists(n)&&(await h.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let o=u.join(e,"apps/server/prisma/schema/auth.prisma");await h.pathExists(o)&&await h.remove(o)}else if(a==="drizzle"){let o=u.join(e,"apps/server/src/db/schema/auth.ts");await h.pathExists(o)&&await h.remove(o)}}}async function Se(e,a,t,r,n){if(!a)return;let o=u.join(k,"template/with-auth");if(await h.pathExists(o)){let i=u.join(o,"apps/web"),s=u.join(e,"apps/web");await h.copy(i,s,{overwrite:!0});let c=u.join(o,"apps/server/src"),w=u.join(e,"apps/server/src");await h.copy(u.join(c,"lib/trpc.ts"),u.join(w,"lib/trpc.ts"),{overwrite:!0}),await h.copy(u.join(c,"routers/index.ts"),u.join(w,"routers/index.ts"),{overwrite:!0});let y=`with-${t}-context.ts`;await h.copy(u.join(c,"lib",y),u.join(w,"lib/context.ts"),{overwrite:!0});let v=`with-${t}-index.ts`;await h.copy(u.join(c,v),u.join(w,"index.ts"),{overwrite:!0});let g=pa(r,n),C=u.join(c,g);if(await h.pathExists(C)){let M=await h.readdir(C);for(let _ of M)await h.copy(u.join(C,_),u.join(w,"lib",_),{overwrite:!0})}}}async function De(e){let a=[u.join(e,"_gitignore"),u.join(e,"apps/web/_gitignore"),u.join(e,"apps/native/_gitignore"),u.join(e,"apps/server/_gitignore")];for(let t of a)if(await h.pathExists(t)){let r=u.join(u.dirname(t),".gitignore");await h.move(t,r)}}function ca(e,a){return e==="drizzle"?a==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?a==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}function pa(e,a){if(e==="drizzle")return a==="sqlite"?"with-drizzle-sqlite-lib":"with-drizzle-postgres-lib";if(e==="prisma")return a==="sqlite"?"with-prisma-sqlite-lib":"with-prisma-postgres-lib";throw new Error("Invalid ORM or database configuration for auth setup")}async function Le(e){let a=ua(),t=da.resolve(process.cwd(),e.projectName);try{return await ma.ensureDir(t),await Ae(t),await Oe(t,e.frontend),await De(t),await Ie(t,e.backend),await le(t,e.backend,e.runtime),await Fe(t,e.orm,e.database,e.auth),await be(t,e.database,e.orm,e.turso??e.database==="sqlite"),await Se(t,e.auth,e.backend,e.orm,e.database),await de(t,e.auth),await Ce(t,e.runtime,e.backend),await Pe(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await we(t,e),await $e(t,e.git),e.addons.length>0&&await oe(t,e.addons,e.packageManager,e.frontend),await Ee(t,e),await ue(t,e),e.noInstall||await xe({projectDir:t,packageManager:e.packageManager,addons:e.addons}),ke(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(Re.red("Failed")),r instanceof Error&&(la(Re.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as ur,group as mr}from"@clack/prompts";import fr from"picocolors";import{cancel as fa,isCancel as ha,multiselect as ga}from"@clack/prompts";import ba from"picocolors";async function Ne(e,a){if(e!==void 0)return e;let t=a?.includes("web"),r=[{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)"}],o=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,i=m.addons.filter(c=>t||c!=="pwa"&&c!=="tauri"),s=await ga({message:"Select addons",options:o,initialValues:i,required:!1});return ha(s)&&(fa(ba.red("Operation cancelled")),process.exit(0)),s.includes("husky")&&!s.includes("biome")&&s.push("biome"),s}import{cancel as wa,confirm as Pa,isCancel as ya,log as ja}from"@clack/prompts";import _e from"picocolors";async function Be(e,a,t){if(!a)return!1;let r=t?.includes("native"),n=t?.includes("web");if(r&&ja.warn(_e.yellow("Note: Authentication is not yet available with native")),!n)return!1;if(e!==void 0)return e;let o=await Pa({message:"Add authentication with Better-Auth?",initialValue:m.auth});return ya(o)&&(wa(_e.red("Operation cancelled")),process.exit(0)),o}import{cancel as va,isCancel as xa,select as ka}from"@clack/prompts";import Ta from"picocolors";async function ze(e){if(e!==void 0)return e;let a=await ka({message:"Select backend framework",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"elysia",label:"Elysia",hint:"Ergonomic web framework for building backend servers"}],initialValue:m.backend});return xa(a)&&(va(Ta.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ea,isCancel as $a,select as Ca}from"@clack/prompts";import Aa from"picocolors";async function Me(e){if(e!==void 0)return e;let a=await Ca({message:"Select database",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:m.database});return $a(a)&&(Ea(Aa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Oa,isCancel as Ia,multiselect as Ue}from"@clack/prompts";import Fa from"picocolors";async function Ge(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!t?.includes("web"))return[];let o=[];return r==="elysia"&&(o=await Ue({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:m.examples})),r==="hono"&&(o=await Ue({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:m.examples})),Ia(o)&&(Oa(Fa.red("Operation cancelled")),process.exit(0)),o}import{cancel as Sa,isCancel as Da,multiselect as Ra}from"@clack/prompts";import La from"picocolors";async function qe(e){if(e!==void 0)return e;let a=await Ra({message:"Choose frontends",options:[{value:"web",label:"Web App",hint:"React + TanStack Router web application"},{value:"native",label:"Native App",hint:"React Native + Expo application"}],initialValues:m.frontend,required:!1});return Da(a)&&(Sa(La.red("Operation cancelled")),process.exit(0)),a}import{cancel as Na,confirm as _a,isCancel as Ba}from"@clack/prompts";import za from"picocolors";async function Je(e){if(e!==void 0)return e;let a=await _a({message:"Initialize git repository?",initialValue:m.git});return Ba(a)&&(Na(za.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ma,confirm as Ua,isCancel as Ga}from"@clack/prompts";import qa from"picocolors";async function Ve(e){if(e!==void 0)return e;let a=await Ua({message:"Install dependencies?",initialValue:!m.noInstall});return Ga(a)&&(Ma(qa.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Ja,isCancel as Va,select as Ha}from"@clack/prompts";import Wa from"picocolors";async function He(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Ha({message:"Select ORM",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:m.orm});return Va(t)&&(Ja(Wa.red("Operation cancelled")),process.exit(0)),t}import{cancel as Qa,isCancel as Ka,select as Xa}from"@clack/prompts";import Ya from"picocolors";async function We(e){if(e!==void 0)return e;let a=U(),t=await Xa({message:"Choose package manager",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:a});return Ka(t)&&(Qa(Ya.red("Operation cancelled")),process.exit(0)),t}import z from"node:path";import{cancel as Za,isCancel as er,text as tr}from"@clack/prompts";import R from"fs-extra";import ar from"picocolors";var rr=["<",">",":",'"',"|","?","*"],Qe=255;function Ke(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Qe)return`Project name must be less than ${Qe} characters`;if(rr.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"||e.toLowerCase()==="favicon.ico")return"Project name is reserved"}}async function Xe(e){if(e)if(e==="."){let o=process.cwd();if(R.readdirSync(o).length===0)return e}else{let o=z.basename(e);if(!Ke(o)){let s=z.resolve(process.cwd(),e);if(!R.pathExistsSync(s)||R.readdirSync(s).length===0)return e}}let a=!1,t="",r=m.projectName,n=1;for(;R.pathExistsSync(z.resolve(process.cwd(),r));)r=`${m.projectName}-${n}`,n++;for(;!a;){let o=await tr({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:i=>{let s=i.trim()||r;if(s==="."){if(R.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let c=z.resolve(process.cwd(),s),w=z.basename(c),y=Ke(w);if(y)return y;if(!c.startsWith(process.cwd()))return"Project path must be within current directory";if(R.pathExistsSync(c)&&R.readdirSync(c).length>0)return`Directory "${s}" already exists and is not empty. Please choose a different name or path.`;a=!0}});er(o)&&(Za(ar.red("Operation cancelled.")),process.exit(0)),t=o||r}return t}import{cancel as nr,isCancel as or,select as ir}from"@clack/prompts";import sr from"picocolors";async function Ye(e){if(e!==void 0)return e;let a=await ir({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:m.runtime});return or(a)&&(nr(sr.red("Operation cancelled")),process.exit(0)),a}import{cancel as cr,confirm as pr,isCancel as dr}from"@clack/prompts";import lr from"picocolors";async function Ze(e){if(e!==void 0)return e;let a=await pr({message:"Set up Turso database?",initialValue:m.turso});return dr(a)&&(cr(lr.red("Operation cancelled")),process.exit(0)),a}async function et(e){let a=await mr({projectName:async()=>Xe(e.projectName),frontend:()=>qe(e.frontend),backend:()=>ze(e.backend),runtime:()=>Ye(e.runtime),database:()=>Me(e.database),orm:({results:t})=>He(e.orm,t.database!=="none"),auth:({results:t})=>Be(e.auth,t.database!=="none",t.frontend),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Ze(e.turso):Promise.resolve(!1),addons:({results:t})=>Ne(e.addons,t.frontend),examples:({results:t})=>Ge(e.examples,t.database,t.frontend,t.backend),git:()=>Je(e.git),packageManager:()=>We(e.packageManager),noInstall:()=>Ve(e.noInstall)},{onCancel:()=>{ur(fr.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,turso:a.turso,backend:a.backend,runtime:a.runtime}}import $ from"picocolors";function Z(e){let a=[];if(e.projectName&&a.push(`${$.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${$.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${$.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${$.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${$.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${$.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${$.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${$.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${$.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${$.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${$.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${$.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${$.blue("Turso Setup:")} ${e.turso}`),a.join(`
179
+ `)}function tt(e){let a=[];e.database==="none"?a.push("--database none"):(a.push(`--database ${e.database}`),e.orm&&a.push(`--orm ${e.orm}`),e.database==="sqlite"&&a.push(e.turso?"--turso":"--no-turso")),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 hr from"node:path";import gr from"fs-extra";var at=()=>{let e=hr.join(k,"package.json");return gr.readJSONSync(e).version??"1.0.0"};import rt from"gradient-string";var nt=`
179
180
  \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
180
181
  \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
181
182
  \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
@@ -189,10 +190,10 @@ serve(
189
190
  \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
190
191
  \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
191
192
  \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
192
- `,nt={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},ot=()=>{let e=process.stdout.columns||80,a=rt.split(`
193
- `),t=Math.max(...a.map(r=>r.length));e<t?console.log(at(Object.values(nt)).multiline(`
193
+ `,ot={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=nt.split(`
194
+ `),t=Math.max(...a.map(r=>r.length));e<t?console.log(rt(Object.values(ot)).multiline(`
194
195
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
195
196
  \u2551 Better T-Stack \u2551
196
197
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
197
- `)):console.log(at(Object.values(nt)).multiline(rt))};process.on("SIGINT",()=>{E.error(u.red("Operation cancelled")),process.exit(0)});var ee=new wr;async function yr(){let e=Date.now();ee.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)").option("--orm <type>","ORM type (none, drizzle, prisma)").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--frontend <types...>","Frontend types (web, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, biome, husky)").option("--no-addons","Skip all additional addons").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("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup").option("--backend <framework>","Backend framework (hono, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=br();try{ot(),hr(u.magenta("Creating a new Better-T-Stack project"));let t=ee.opts(),r=ee.args[0];Pr(t);let n=jr(t,r);!t.yes&&Object.keys(n).length>0&&(E.info(u.yellow("Using these pre-selected options:")),E.message(Z(n)),E.message(""));let o=t.yes?{...m,projectName:r??m.projectName,...n}:await Ze(n);t.yes&&(E.info(u.yellow("Using these default options:")),E.message(Z(o)),E.message("")),await Re(o),E.success(u.blue(`You can reproduce this setup with the following command:
198
- ${u.white(et(o))}`));let i=((Date.now()-e)/1e3).toFixed(2);gr(u.magenta(`Project created successfully in ${u.bold(i)} seconds!`))}catch(t){a.stop(u.red("Failed")),t instanceof Error&&(j(u.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function Pr(e){if(e.database&&!["none","sqlite","postgres"].includes(e.database)&&(j(u.red(`Invalid database type: ${e.database}. Must be none, sqlite, or postgres.`)),process.exit(1)),e.orm&&!["none","drizzle","prisma"].includes(e.orm)&&(j(u.red(`Invalid ORM type: ${e.orm}. Must be none, drizzle, or prisma.`)),process.exit(1)),e.database==="none"&&(e.auth===!0&&(j(u.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(j(u.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),"turso"in e&&e.turso===!0&&(j(u.red("Turso setup requires a SQLite database. Cannot use --turso with --database none.")),process.exit(1))),"turso"in e&&e.turso===!0&&e.database&&e.database!=="sqlite"&&(j(u.red(`Turso setup requires a SQLite database. Cannot use --turso with --database ${e.database}`)),process.exit(1)),"turso"in e&&e.turso===!0&&e.orm==="prisma"&&(j(u.red("Turso setup is not compatible with Prisma. Cannot use --turso with --orm prisma")),process.exit(1)),e.packageManager&&!["npm","pnpm","bun"].includes(e.packageManager)&&(j(u.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),e.backend&&!["hono","elysia"].includes(e.backend)&&(j(u.red(`Invalid backend framework: ${e.backend}. Must be hono or elysia.`)),process.exit(1)),e.runtime&&!["bun","node"].includes(e.runtime)&&(j(u.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),e.examples&&Array.isArray(e.examples)&&e.examples.length>0){let a=["todo","ai"],t=e.examples.filter(r=>!a.includes(r));t.length>0&&(j(u.red(`Invalid example(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&e.backend==="elysia"&&(j(u.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1)),e.frontend&&!e.frontend.includes("web")&&!e.frontend.includes("none")&&(j(u.red("Examples require a web frontend. Cannot use --examples with --frontend native only")),process.exit(1))}if(e.frontend&&e.frontend.length>0){let a=["web","native","none"],t=e.frontend.filter(r=>!a.includes(r));t.length>0&&(j(u.red(`Invalid frontend(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.frontend.includes("none")&&e.frontend.length>1&&(j(u.red("Cannot combine 'none' with other frontend options.")),process.exit(1))}if(e.addons&&e.addons.length>0){let a=["pwa","tauri","biome","husky"],t=e.addons.filter(o=>!a.includes(o));t.length>0&&(j(u.red(`Invalid addon(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1));let r=["pwa","tauri"];e.addons.some(o=>r.includes(o))&&e.frontend&&!e.frontend.includes("web")&&!e.frontend.includes("none")&&(j(u.red(`PWA and Tauri addons require a web frontend. Cannot use --addons ${e.addons.filter(o=>r.includes(o)).join(", ")} with --frontend native only`)),process.exit(1))}}function jr(e,a){let t;e.frontend&&(e.frontend.includes("none")?t=[]:t=e.frontend.filter(g=>g==="web"||g==="native"));let r=e.database,n;e.orm&&(n=e.orm);let o="auth"in e?e.auth:void 0,i="turso"in e?e.turso:void 0;r==="none"&&(n="none",o=!1,i=!1);let s;"examples"in e&&(e.examples===!1?s=[]:Array.isArray(e.examples)&&(s=e.examples.filter(g=>g==="todo"||g==="ai"),t&&t.length>0&&!t.includes("web")&&(s=[],E.warn(u.yellow("Examples require web frontend - ignoring examples flag"))),s.includes("ai")&&e.backend==="elysia"&&(s=s.filter(g=>g!=="ai"),E.warn(u.yellow("AI example is not compatible with Elysia - removing AI example")))));let c;"addons"in e&&(e.addons===void 0?c=[]:e.addons&&(c=e.addons.filter(g=>g==="pwa"||g==="tauri"||g==="biome"||g==="husky"),t&&t.length>0&&!t.includes("web")&&(c=c.filter(g=>!["pwa","tauri"].includes(g)),c.length!==e.addons.length&&E.warn(u.yellow("PWA and Tauri addons require web frontend - removing these addons"))),c.includes("husky")&&!c.includes("biome")&&c.push("biome")));let w=e.backend,P=e.runtime,v=e.packageManager;return{...a&&{projectName:a},...r!==void 0&&{database:r},...n!==void 0&&{orm:n},...o!==void 0&&{auth:o},...v&&{packageManager:v},..."git"in e&&{git:e.git},..."install"in e&&{noInstall:!e.install},...i!==void 0&&{turso:i},...w&&{backend:w},...P&&{runtime:P},...t!==void 0&&{frontend:t},...c!==void 0&&{addons:c},...s!==void 0&&{examples:s}}}yr().catch(e=>{E.error("Aborting installation..."),e instanceof Error?E.error(e.message):(E.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
198
+ `)):console.log(rt(Object.values(ot)).multiline(nt))};process.on("SIGINT",()=>{E.error(l.red("Operation cancelled")),process.exit(0)});var ee=new yr;async function jr(){let e=Date.now();ee.name("create-better-t-stack").description("Create a new Better-T Stack project").version(at()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--database <type>","Database type (none, sqlite, postgres)").option("--orm <type>","ORM type (none, drizzle, prisma)").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--frontend <types...>","Frontend types (web, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, 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("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup").option("--backend <framework>","Backend framework (hono, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=Pr();try{it(),br(l.magenta("Creating a new Better-T-Stack project"));let t=ee.opts(),r=ee.args[0];vr(t);let n=xr(t,r);!t.yes&&Object.keys(n).length>0&&(E.info(l.yellow("Using these pre-selected options:")),E.message(Z(n)),E.message(""));let o=t.yes?{...m,projectName:r??m.projectName,...n}:await et(n);t.yes&&(E.info(l.yellow("Using these default options:")),E.message(Z(o)),E.message("")),await Le(o),E.success(l.blue(`You can reproduce this setup with the following command:
199
+ ${l.white(tt(o))}`));let i=((Date.now()-e)/1e3).toFixed(2);wr(l.magenta(`Project created successfully in ${l.bold(i)} seconds!`))}catch(t){a.stop(l.red("Failed")),t instanceof Error&&(j(l.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function vr(e){if(e.database&&!["none","sqlite","postgres"].includes(e.database)&&(j(l.red(`Invalid database type: ${e.database}. Must be none, sqlite, or postgres.`)),process.exit(1)),e.orm&&!["none","drizzle","prisma"].includes(e.orm)&&(j(l.red(`Invalid ORM type: ${e.orm}. Must be none, drizzle, or prisma.`)),process.exit(1)),e.database==="none"&&(e.auth===!0&&(j(l.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(j(l.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),"turso"in e&&e.turso===!0&&(j(l.red("Turso setup requires a SQLite database. Cannot use --turso with --database none.")),process.exit(1))),"turso"in e&&e.turso===!0&&e.database&&e.database!=="sqlite"&&(j(l.red(`Turso setup requires a SQLite database. Cannot use --turso with --database ${e.database}`)),process.exit(1)),"turso"in e&&e.turso===!0&&e.orm==="prisma"&&(j(l.red("Turso setup is not compatible with Prisma. Cannot use --turso with --orm prisma")),process.exit(1)),e.packageManager&&!["npm","pnpm","bun"].includes(e.packageManager)&&(j(l.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),e.backend&&!["hono","elysia"].includes(e.backend)&&(j(l.red(`Invalid backend framework: ${e.backend}. Must be hono or elysia.`)),process.exit(1)),e.runtime&&!["bun","node"].includes(e.runtime)&&(j(l.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),e.examples&&Array.isArray(e.examples)&&e.examples.length>0){let a=["todo","ai"],t=e.examples.filter(r=>!a.includes(r));t.length>0&&(j(l.red(`Invalid example(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&e.backend==="elysia"&&(j(l.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1)),e.frontend&&!e.frontend.includes("web")&&!e.frontend.includes("none")&&(j(l.red("Examples require a web frontend. Cannot use --examples with --frontend native only")),process.exit(1))}if(e.frontend&&e.frontend.length>0){let a=["web","native","none"],t=e.frontend.filter(r=>!a.includes(r));t.length>0&&(j(l.red(`Invalid frontend(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.frontend.includes("none")&&e.frontend.length>1&&(j(l.red("Cannot combine 'none' with other frontend options.")),process.exit(1))}if(e.addons&&Array.isArray(e.addons)&&e.addons.length>0){let a=["pwa","tauri","biome","husky","none"],t=e.addons.filter(o=>!a.includes(o));t.length>0&&(j(l.red(`Invalid addon(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.addons.includes("none")&&e.addons.length>1&&(j(l.red("Cannot combine 'none' with other addons.")),process.exit(1));let r=["pwa","tauri"];e.addons.some(o=>r.includes(o))&&e.frontend&&!e.frontend.includes("web")&&!e.frontend.includes("none")&&(j(l.red(`PWA and Tauri addons require a web frontend. Cannot use --addons ${e.addons.filter(o=>r.includes(o)).join(", ")} with --frontend native only`)),process.exit(1))}}function xr(e,a){let t;e.frontend&&(e.frontend.includes("none")?t=[]:t=e.frontend.filter(g=>g==="web"||g==="native"));let r=e.database,n;e.orm&&(n=e.orm);let o="auth"in e?e.auth:void 0,i="turso"in e?e.turso:void 0;r==="none"&&(n="none",o=!1,i=!1);let s;"examples"in e&&(e.examples===!1?s=[]:Array.isArray(e.examples)&&(s=e.examples.filter(g=>g==="todo"||g==="ai"),t&&t.length>0&&!t.includes("web")&&(s=[],E.warn(l.yellow("Examples require web frontend - ignoring examples flag"))),s.includes("ai")&&e.backend==="elysia"&&(s=s.filter(g=>g!=="ai"),E.warn(l.yellow("AI example is not compatible with Elysia - removing AI example")))));let c;e.addons&&Array.isArray(e.addons)&&(e.addons.includes("none")?c=[]:(c=e.addons.filter(g=>g==="pwa"||g==="tauri"||g==="biome"||g==="husky"),t&&t.length>0&&!t.includes("web")&&(c=c.filter(g=>!["pwa","tauri"].includes(g)),c.length!==e.addons.length&&E.warn(l.yellow("PWA and Tauri addons require web frontend - removing these addons"))),c.includes("husky")&&!c.includes("biome")&&c.push("biome")));let w=e.backend,y=e.runtime,v=e.packageManager;return{...a&&{projectName:a},...r!==void 0&&{database:r},...n!==void 0&&{orm:n},...o!==void 0&&{auth:o},...v&&{packageManager:v},..."git"in e&&{git:e.git},..."install"in e&&{noInstall:!e.install},...i!==void 0&&{turso:i},...w&&{backend:w},...y&&{runtime:y},...t!==void 0&&{frontend:t},...c!==void 0&&{addons:c},...s!==void 0&&{examples:s}}}jr().catch(e=>{E.error("Aborting installation..."),e instanceof Error?E.error(e.message):(E.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.4.3",
3
+ "version": "1.4.5",
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",
@@ -11,7 +11,34 @@
11
11
  "dist",
12
12
  "template"
13
13
  ],
14
- "keywords": [],
14
+ "keywords": [
15
+ "typescript",
16
+ "scaffold",
17
+ "generator",
18
+ "boilerplate",
19
+ "starter",
20
+ "cli",
21
+ "create-app",
22
+ "t3-stack",
23
+ "turborepo",
24
+ "trpc",
25
+ "monorepo",
26
+ "fullstack",
27
+ "type-safety",
28
+ "react",
29
+ "react-native",
30
+ "expo",
31
+ "hono",
32
+ "elysia",
33
+ "drizzle",
34
+ "prisma",
35
+ "tanstack",
36
+ "tailwind",
37
+ "shadcn",
38
+ "pwa",
39
+ "tauri",
40
+ "biome"
41
+ ],
15
42
  "repository": {
16
43
  "type": "git",
17
44
  "url": "git+https://github.com/better-t-stack/create-better-t-stack.git",