create-better-t-stack 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Create Better-T-Stack CLI
2
2
 
3
- A CLI tool for scaffolding type-safe full-stack apps with Hono/Elysia backends, React web frontends, and Expo native apps, all connected through tRPC.
3
+ A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations
4
4
 
5
5
  ## Quick Start
6
6
 
@@ -34,7 +34,7 @@ Follow the prompts to configure your project or use the `-y` flag for defaults.
34
34
  - **Desktop Apps**: Build native desktop apps with Tauri integration
35
35
  - **Code Quality**: Biome for linting and formatting
36
36
  - **Git Hooks**: Husky with lint-staged for pre-commit checks
37
- - **Examples**: Todo app with full CRUD functionality
37
+ - **Examples**: Todo app with full CRUD functionality, AI Chat using AI SDK
38
38
  - **Developer Experience**: Git initialization, various package manager support (npm, pnpm, bun)
39
39
 
40
40
  ## Usage
@@ -43,39 +43,27 @@ Follow the prompts to configure your project or use the `-y` flag for defaults.
43
43
  Usage: create-better-t-stack [project-directory] [options]
44
44
 
45
45
  Options:
46
- -V, --version Output the version number
47
- -y, --yes Use default configuration
48
- --no-database Skip database setup
49
- --sqlite Use SQLite database
50
- --postgres Use PostgreSQL database
51
- --auth Include authentication
52
- --no-auth Exclude authentication
53
- --pwa Include Progressive Web App support
54
- --tauri Include Tauri desktop app support
55
- --biome Include Biome for linting and formatting
56
- --husky Include Husky, lint-staged for Git hooks
57
- --no-addons Skip all additional addons
58
- --examples <examples> Include specified examples
59
- --no-examples Skip all examples
60
- --git Include git setup (default)
61
- --no-git Skip git initialization
62
- --npm Use npm as package manager
63
- --pnpm Use pnpm as package manager
64
- --bun Use bun as package manager
65
- --drizzle Use Drizzle ORM
66
- --prisma Use Prisma ORM
67
- --install Install dependencies (default)
68
- --no-install Skip installing dependencies
69
- --turso Set up Turso for SQLite database
70
- --no-turso Skip Turso setup for SQLite database
71
- --hono Use Hono backend framework (default)
72
- --elysia Use Elysia backend framework
73
- --runtime <runtime> Specify runtime (bun or node)
74
- --web Include web frontend (default)
75
- --native Include Expo frontend
76
- --no-web Exclude web frontend
77
- --no-native Exclude Expo frontend
78
- -h, --help Display help
46
+ -V, --version Output the version number
47
+ -y, --yes Use default configuration
48
+ --database <type> Database type (none, sqlite, postgres)
49
+ --orm <type> ORM type (none, drizzle, prisma)
50
+ --auth Include authentication
51
+ --no-auth Exclude authentication
52
+ --frontend <types...> Frontend types (web, native, none)
53
+ --addons <types...> Additional addons (pwa, tauri, biome, husky)
54
+ --no-addons Skip all additional addons
55
+ --examples <types...> Examples to include (todo, ai)
56
+ --no-examples Skip all examples
57
+ --git Initialize git repository
58
+ --no-git Skip git initialization
59
+ --package-manager <pm> Package manager (npm, pnpm, bun)
60
+ --install Install dependencies
61
+ --no-install Skip installing dependencies
62
+ --turso Set up Turso for SQLite database
63
+ --no-turso Skip Turso setup
64
+ --backend <framework> Backend framework (hono, elysia)
65
+ --runtime <runtime> Runtime (bun, node)
66
+ -h, --help Display help
79
67
  ```
80
68
 
81
69
  ## Examples
@@ -87,17 +75,20 @@ npx create-better-t-stack my-app -y
87
75
 
88
76
  Create a project with specific options:
89
77
  ```bash
90
- npx create-better-t-stack my-app --postgres --drizzle --auth --pwa --biome
78
+ npx create-better-t-stack my-app --database postgres --orm drizzle --auth --addons pwa biome
91
79
  ```
92
80
 
93
81
  Create a project with Elysia and Node.js runtime:
94
82
  ```bash
95
- npx create-better-t-stack my-app --elysia --runtime node
83
+ npx create-better-t-stack my-app --backend elysia --runtime node
96
84
  ```
97
85
 
98
- Create a project using Hono with no addons:
86
+ Create a project with specific frontend options:
99
87
  ```bash
100
- npx create-better-t-stack my-app --hono --no-addons
88
+ npx create-better-t-stack my-app --frontend web native
101
89
  ```
102
90
 
103
- Created by [Aman Varshney](https://github.com/AmanVarshney01) & [Nitish Singh](https://github.com/FgrReloaded)
91
+ Create a project with examples:
92
+ ```bash
93
+ npx create-better-t-stack my-app --examples todo ai
94
+ ```
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as S,intro as go,log as C,outro as bo,spinner as wo}from"@clack/prompts";import{Command as yo}from"commander";import v from"picocolors";import te from"node:path";import{fileURLToPath as ct}from"node:url";var M=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var pt=ct(import.meta.url),lt=te.dirname(pt),P=te.join(lt,"../"),m={projectName:"my-better-t-app",frontend:["web"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:M(),noInstall:!1,turso:!1,backend:"hono",runtime:"bun"},K={"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 sa from"node:path";import{cancel as ca,spinner as pa}from"@clack/prompts";import la from"fs-extra";import Ie from"picocolors";import F from"node:path";import j from"fs-extra";import dt from"node:path";import ae from"fs-extra";var g=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:o}=e,r=dt.join(o,"package.json"),n=ae.readJSONSync(r);n.dependencies||(n.dependencies={}),n.devDependencies||(n.devDependencies={});for(let i of a){let s=K[i];n.dependencies[i]=s}for(let i of t){let s=K[i];n.devDependencies[i]=s}ae.writeJSONSync(r,n,{spaces:2})};import G from"node:path";import{log as ut,spinner as mt}from"@clack/prompts";import{execa as ft}from"execa";import J from"fs-extra";import oe from"picocolors";async function re(e,a){let t=mt(),o=G.join(e,"apps/web");if(await J.pathExists(o))try{t.start("Setting up Tauri desktop app support..."),g({devDependencies:["@tauri-apps/cli"],projectDir:o});let r=G.join(o,"package.json");if(await J.pathExists(r)){let s=await J.readJson(r);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await J.writeJson(r,s,{spaces:2})}let n,i;switch(a){case"npm":n="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":n="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":n="bunx",i=["@tauri-apps/cli@latest"];break;default:n="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(n,i,{cwd:o,env:{CI:"true"}}),t.stop("Tauri desktop app support configured successfully!")}catch(r){throw t.stop(oe.red("Failed to set up Tauri")),r instanceof Error&&ut.error(oe.red(r.message)),r}}async function ne(e,a,t,o){let r=o.includes("web");a.includes("pwa")&&r&&await bt(e),a.includes("tauri")&&r&&await re(e,t),a.includes("biome")&&await ht(e),a.includes("husky")&&await gt(e)}async function ht(e){let a=F.join(P,"template/with-biome");await j.pathExists(a)&&await j.copy(a,e,{overwrite:!0}),g({devDependencies:["@biomejs/biome"],projectDir:e});let t=F.join(e,"package.json");if(await j.pathExists(t)){let o=await j.readJson(t);o.scripts={...o.scripts,check:"biome check --write ."},await j.writeJson(t,o,{spaces:2})}}async function gt(e){let a=F.join(P,"template/with-husky");await j.pathExists(a)&&await j.copy(a,e,{overwrite:!0}),g({devDependencies:["husky","lint-staged"],projectDir:e});let t=F.join(e,"package.json");if(await j.pathExists(t)){let o=await j.readJson(t);o.scripts={...o.scripts,prepare:"husky"},o["lint-staged"]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":["biome check --write ."]},await j.writeJson(t,o,{spaces:2})}}async function bt(e){let a=F.join(P,"template/with-pwa");await j.pathExists(a)&&await j.copy(a,e,{overwrite:!0});let t=F.join(e,"apps/web");if(!await j.pathExists(t))return;g({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let o=F.join(t,"package.json");if(await j.pathExists(o)){let r=await j.readJson(o);r.scripts={...r.scripts,"generate-pwa-assets":"pwa-assets-generator"},await j.writeJson(o,r,{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="",o=a.length;for(let r=0;r<e;r++)t+=a.charAt(Math.floor(Math.random()*o));return t}async function le(e,a){if(!a)return;let t=ie.join(e,"apps/server"),o=ie.join(e,"apps/web");try{g({dependencies:["better-auth"],projectDir:t}),g({dependencies:["better-auth"],projectDir:o})}catch(r){throw se.error(ce.red("Failed to configure authentication")),r instanceof Error&&se.error(ce.red(r.message)),r}}import wt from"node:path";async function de(e,a,t){let o=wt.join(e,"apps/server"),r=[],n=[];a==="hono"?(r.push("hono","@hono/trpc-server"),t==="node"&&(r.push("@hono/node-server"),n.push("tsx","@types/node"))):a==="elysia"&&(r.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(r.push("@elysiajs/node"),n.push("tsx","@types/node"))),t==="bun"&&n.push("@types/bun"),g({dependencies:r,devDependencies:n,projectDir:o})}import yt from"node:path";import Pt from"fs-extra";async function ue(e,a){let t=yt.join(e,"README.md"),o=jt(a);try{await Pt.writeFile(t,o)}catch(r){console.error("Failed to create README.md file:",r)}}function jt(e){let{projectName:a,packageManager:t,database:o,auth:r,addons:n=[],orm:i="drizzle",runtime:s="bun"}=e,c=t==="npm"?"npm run":t;return`# ${a}
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}
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(o,r,n,i,s)}
8
+ ${vt(r,n,o,i,s)}
9
9
 
10
10
  ## Getting Started
11
11
 
@@ -15,7 +15,7 @@ First, install the dependencies:
15
15
  ${t} install
16
16
  \`\`\`
17
17
 
18
- ${kt(o,r,c,i)}
18
+ ${kt(r,n,c,i)}
19
19
 
20
20
  Then, run the development server:
21
21
 
@@ -37,11 +37,11 @@ ${a}/
37
37
 
38
38
  ## Available Scripts
39
39
 
40
- ${xt(c,o,i,r)}
41
- `}function vt(e,a,t,o,r){let n=["- **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",`- **${r==="bun"?"Bun":"Node.js"}** - Runtime environment`];e!=="none"&&n.push(`- **${o==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&n.push("- **Authentication** - Email & password authentication with Better Auth");for(let i of t)i==="pwa"?n.push("- **PWA** - Progressive Web App support"):i==="tauri"?n.push("- **Tauri** - Build native desktop applications"):i==="biome"?n.push("- **Biome** - Linting and formatting"):i==="husky"&&n.push("- **Husky** - Git hooks for code quality");return n.join(`
42
- `)}function kt(e,a,t,o){if(e==="none")return"";let r=`## Database Setup
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(`
42
+ `)}function kt(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
43
43
 
44
- `;return e==="sqlite"?r+=`This project uses SQLite${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
44
+ `;return e==="sqlite"?n+=`This project uses SQLite${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
45
45
 
46
46
  1. Start the local SQLite database:
47
47
  \`\`\`bash
@@ -49,29 +49,29 @@ cd apps/server && ${t} db:local
49
49
  \`\`\`
50
50
 
51
51
  2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed.
52
- `:e==="postgres"&&(r+=`This project uses PostgreSQL${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
52
+ `:e==="postgres"&&(n+=`This project uses PostgreSQL${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
53
53
 
54
54
  1. Make sure you have a PostgreSQL database set up.
55
55
  2. Update your \`apps/server/.env\` file with your PostgreSQL connection details.
56
- `),r+=`
57
- ${a?"4":"3"}. ${o==="prisma"?`Generate the Prisma client and push the schema:
56
+ `),n+=`
57
+ ${a?"4":"3"}. ${r==="prisma"?`Generate the Prisma client and push the schema:
58
58
  \`\`\`bash
59
59
  ${t} db:push
60
60
  \`\`\``:`Apply the schema to your database:
61
61
  \`\`\`bash
62
62
  ${t} db:push
63
63
  \`\`\``}
64
- `,r}function xt(e,a,t,o){let r=`- \`${e} dev\`: Start both web and server in development mode
64
+ `,n}function xt(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
- - \`${e} check-types\`: Check TypeScript types across all apps`;return a!=="none"&&(r+=`
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
- - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(r+=`
71
- - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),r}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 Q,confirm as Et,isCancel as X,log as L,select as $t,spinner as Y,text as Ct}from"@clack/prompts";import{$}from"execa";import Ot from"fs-extra";import E from"picocolors";async function It(){try{return(await $`turso --version`).exitCode===0}catch{return!1}}async function At(){try{return!(await $`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function Dt(){let e=Y();try{return e.start("Logging in to Turso..."),await $`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(E.red("Failed to log in to Turso")),a}}async function Ft(e){let a=Y();try{if(a.start("Installing Turso CLI..."),e)await $`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await $`curl -sSfL https://get.tur.so/install.sh`;await $`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(E.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(E.red("Failed to install Turso CLI")),t)}}async function Rt(){try{let{stdout:e}=await $`turso group list`,a=e.trim().split(`
72
- `);return a.length<=1?[]:a.slice(1).map(o=>{let[r,n,i,s]=o.trim().split(/\s{2,}/);return{name:r,locations:n,version:i,status:s}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function St(){let e=await Rt();if(e.length===0)return null;if(e.length===1)return e[0].name;let a=e.map(o=>({value:o.name,label:`${o.name} (${o.locations})`})),t=await $t({message:"Select a Turso database group:",options:a});return X(t)&&(Q(E.red("Operation cancelled")),process.exit(0)),t}async function Lt(e,a){try{a?await $`turso db create ${e} --group ${a}`:await $`turso db create ${e}`}catch(r){throw r instanceof Error&&r.message.includes("already exists")?new Error("DATABASE_EXISTS"):r}let{stdout:t}=await $`turso db show ${e} --url`,{stdout:o}=await $`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:o.trim()}}async function B(e,a){let t=me.join(e,"apps/server",".env"),o=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
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}"
73
73
  TURSO_AUTH_TOKEN="${a.authToken}"`:`TURSO_CONNECTION_URL=
74
- TURSO_AUTH_TOKEN=`;await Ot.writeFile(t,o)}function V(){L.info(`Manual Turso Setup Instructions:
74
+ TURSO_AUTH_TOKEN=`;await At.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,17 +79,17 @@ TURSO_AUTH_TOKEN=`;await Ot.writeFile(t,o)}function V(){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(E.blue("Skipping Turso setup. Setting up empty configuration.")),V();return}let t=Tt.platform(),o=t==="darwin";if(!(t!=="win32")){L.warn(E.yellow("Automatic Turso setup is not supported on Windows.")),await B(e),V();return}try{if(!await It()){let k=await Et({message:"Would you like to install Turso CLI?",initialValue:!0});if(X(k)&&(Q(E.red("Operation cancelled")),process.exit(0)),!k){await B(e),V();return}await Ft(o)}await At()||await Dt();let s=await St(),c=!1,b="",w=me.basename(e);for(;!c;){let k=await Ct({message:"Enter a name for your database:",defaultValue:w,initialValue:w,placeholder:w});X(k)&&(Q(E.red("Operation cancelled")),process.exit(0)),b=k;let O=Y();try{O.start(`Creating Turso database "${b}"${s?` in group "${s}"`:""}...`);let T=await Lt(b,s);await B(e,T),O.stop("Turso database configured successfully!"),c=!0}catch(T){if(T instanceof Error&&T.message==="DATABASE_EXISTS")O.stop(E.yellow(`Database "${E.red(b)}" already exists`)),w=`${b}-${Math.floor(Math.random()*1e3)}`;else throw O.stop(E.red("Failed to create Turso database")),T}}}catch(n){L.error(E.red(`Error during Turso setup: ${n}`)),await B(e),V(),L.success("Setup completed with manual configuration required.")}}async function be(e,a,t,o=!0){let r=_t(),n=he.join(e,"apps/server");if(a==="none"){await Bt.remove(he.join(n,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?g({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:n}):t==="prisma"&&g({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:n}),o&&await fe(e,!0)):a==="postgres"&&(t==="drizzle"?g({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:n}):t==="prisma"&&g({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:n}))}catch(i){throw r.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"),o=N.join(t,".env"),r="";if(await I.pathExists(o)&&(r=await I.readFile(o,"utf8")),r.includes("CORS_ORIGIN")||(r+=`
83
- CORS_ORIGIN=http://localhost:3001`),a.auth&&(r.includes("BETTER_AUTH_SECRET")||(r+=`
84
- BETTER_AUTH_SECRET=${pe()}`),r.includes("BETTER_AUTH_URL")||(r+=`
85
- BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!r.includes("DATABASE_URL")){let n=a.database==="sqlite"?"":`
86
- DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;r+=n}a.database==="sqlite"&&!a.turso&&(r.includes("TURSO_CONNECTION_URL")||(r+=`
87
- TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}if(a.examples?.includes("ai")&&!r.includes("GOOGLE_GENERATIVE_AI_API_KEY")&&(r+=`
88
- GOOGLE_GENERATIVE_AI_API_KEY=`),await I.writeFile(o,r.trim()),a.frontend.includes("web")){let n=N.join(e,"apps/web"),i=N.join(n,".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
- `),await I.writeFile(i,s.trim())}if(a.frontend.includes("native")){let n=N.join(e,"apps/native"),i=N.join(n,".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 y from"node:path";import f from"fs-extra";async function ye(e,a,t,o,r,n=["web"]){let i=n.includes("web"),s=await f.pathExists(y.join(e,"apps/web"));a.includes("todo")&&i&&s?await Gt(e,t,o):await Vt(e,t),a.includes("ai")&&r==="hono"&&i&&s&&await zt(e)}async function zt(e){let a=y.join(P,"template/examples/ai");if(await f.pathExists(a)){await f.copy(a,e),await Mt(e);let t=y.join(e,"apps/web");g({dependencies:["ai"],projectDir:t});let o=y.join(e,"apps/server");g({dependencies:["ai","@ai-sdk/google"],projectDir:o}),await Ut(e)}}async function Ut(e){let a=y.join(e,"apps/server/src/index.ts");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");if(t.includes("hono")){let r=`import { streamText } from "ai";
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+=`
83
+ CORS_ORIGIN=http://localhost:3001`),a.auth&&(n.includes("BETTER_AUTH_SECRET")||(n+=`
84
+ BETTER_AUTH_SECRET=${pe()}`),n.includes("BETTER_AUTH_URL")||(n+=`
85
+ BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!n.includes("DATABASE_URL")){let o=a.database==="sqlite"?"":`
86
+ DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;n+=o}a.database==="sqlite"&&!a.turso&&(n.includes("TURSO_CONNECTION_URL")||(n+=`
87
+ TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}if(a.examples?.includes("ai")&&!n.includes("GOOGLE_GENERATIVE_AI_API_KEY")&&(n+=`
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
+ `),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";
91
91
  import { google } from "@ai-sdk/google";
92
- import { stream } from "hono/streaming";`,n=`
92
+ import { stream } from "hono/streaming";`,o=`
93
93
  app.post("/ai", async (c) => {
94
94
  const body = await c.req.json();
95
95
  const messages = body.messages || [];
@@ -105,62 +105,62 @@ app.post("/ai", async (c) => {
105
105
  return stream(c, (stream) => stream.pipe(result.toDataStream()));
106
106
  });`;if(t.includes("import {")){let s=t.lastIndexOf("import"),c=t.indexOf(`
107
107
  `,s);t=`${t.substring(0,c+1)}
108
- ${r}
109
- ${t.substring(c+1)}`}else t=`${r}
108
+ ${n}
109
+ ${t.substring(c+1)}`}else t=`${n}
110
110
 
111
- ${t}`;let i=t.indexOf('app.use("/trpc"')||t.indexOf("app.use(trpc(");if(i!==-1)t=`${t.substring(0,i)}${n}
111
+ ${t}`;let i=t.indexOf('app.use("/trpc"')||t.indexOf("app.use(trpc(");if(i!==-1)t=`${t.substring(0,i)}${o}
112
112
 
113
- ${t.substring(i)}`;else{let s=t.indexOf("export default");s!==-1?t=`${t.substring(0,s)}${n}
113
+ ${t.substring(i)}`;else{let s=t.indexOf("export default");s!==-1?t=`${t.substring(0,s)}${o}
114
114
 
115
115
  ${t.substring(s)}`:t=`${t}
116
116
 
117
- ${n}`}await f.writeFile(a,t)}}}async function Mt(e){let a=y.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 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" },
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 o=y.join(P,"template/examples/todo");if(await f.pathExists(o)){let r=y.join(o,"apps/web/src/routes"),n=y.join(e,"apps/web/src/routes");if(await f.copy(r,n,{overwrite:!0}),a!=="none"){let i=y.join(o,`apps/server/src/routers/with-${a}-todo.ts`),s=y.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=y.join(e,"apps/web/src/components/header.tsx");if(await f.pathExists(t)){let o=await f.readFile(t,"utf8");a?o=o.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 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 = [
122
122
  { to: "/", label: "Home" },
123
123
  { to: "/dashboard", label: "Dashboard" },
124
- { to: "/todos", label: "Todos" },`):o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
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,o)}}async function Vt(e,a){if(a==="drizzle"){let o=y.join(e,"apps/server/src/db/schema/todo.ts");await f.pathExists(o)&&await f.remove(o)}else if(a==="prisma"){let o=y.join(e,"apps/server/prisma/schema/todo.prisma");await f.pathExists(o)&&await f.remove(o)}let t=y.join(e,"apps/server/src/routers/todo.ts");await f.pathExists(t)&&await f.remove(t),await qt(e)}async function qt(e){let a=y.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=y.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 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">
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 Ht}from"@clack/prompts";import d from"picocolors";function Pe(e,a,t,o,r,n,i,s){let c=t==="npm"?"npm run":t,b=`cd ${a}`,w=n?.includes("husky")||n?.includes("biome"),k=e!=="none"?Xt(e,r,c,i):"",O=n?.includes("tauri")?Yt(c):"",T=w?Qt(c):"",U=s?.includes("native")?Kt():"",_=s?.includes("web"),it=s?.includes("native"),st=_||it;Ht.info(`${d.bold("Next steps:")}
134
- ${d.cyan("1.")} ${b}
135
- ${o?"":`${d.cyan("2.")} ${t} install
136
- `}${d.cyan(o?"2.":"3.")} ${c} dev
137
-
138
- ${d.bold("Your project will be available at:")}
139
- ${st?`${_?`${d.cyan("\u2022")} Frontend: http://localhost:3001
140
- `:""}`:`${d.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
141
- `}${d.cyan("\u2022")} API: http://localhost:3000
142
- ${U?`
143
- ${U.trim()}`:""}${k?`
144
- ${k.trim()}`:""}${O?`
145
- ${O.trim()}`:""}${T?`
146
- ${T.trim()}`:""}`)}function Kt(){return`${d.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:
147
- ${d.dim("EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000")}
148
- `}function Qt(e){return`${d.bold("Linting and formatting:")}
149
- ${d.cyan("\u2022")} Format and lint fix: ${d.dim(`${e} check`)}
150
-
151
- `}function Xt(e,a,t,o){let r=[];return a==="prisma"?(e==="sqlite"&&r.push(`${d.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,`${d.dim("Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso")}`),o==="bun"&&r.push(`${d.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors, follow the guidance provided in the error messages`),r.push(`${d.cyan("\u2022")} Apply schema: ${d.dim(`${t} db:push`)}`),r.push(`${d.cyan("\u2022")} Database UI: ${d.dim(`${t} db:studio`)}`)):a==="drizzle"&&(e==="sqlite"&&r.push(`${d.cyan("\u2022")} Start local DB: ${d.dim(`cd apps/server && ${t} db:local`)}`),r.push(`${d.cyan("\u2022")} Apply schema: ${d.dim(`${t} db:push`)}`),r.push(`${d.cyan("\u2022")} Database UI: ${d.dim(`${t} db:studio`)}`)),r.length?`${d.bold("Database commands:")}
152
- ${r.join(`
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
141
+ ${M?`
142
+ ${M.trim()}`:""}${v?`
143
+ ${v.trim()}`:""}${g?`
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:
146
+ EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000
147
+ `}function Xt(e){return`${y.bold(`
148
+ Linting and formatting:`)}
149
+ ${y.cyan("\u2022")} Format and lint fix: ${`${e} check`}
150
+
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
+ ${n.join(`
153
153
  `)}
154
154
 
155
- `:""}function Yt(e){return`${d.bold("Desktop app with Tauri:")}
156
- ${d.cyan("\u2022")} Start desktop app: ${d.dim(`cd apps/web && ${e} desktop:dev`)}
157
- ${d.cyan("\u2022")} Build desktop app: ${d.dim(`cd apps/web && ${e} desktop:build`)}
158
- ${d.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: ${d.dim("https://v2.tauri.app/start/prerequisites/")}
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/
159
159
 
160
- `}import q from"node:path";import{$ as Zt,execa as ea}from"execa";import A from"fs-extra";async function je(e,a){await ta(e,a),await aa(e,a)}async function ta(e,a){let t=q.join(e,"package.json");if(await A.pathExists(t)){let o=await A.readJson(t);o.name=a.projectName;let{stdout:r}=await ea(a.packageManager,["-v"],{cwd:e});if(o.packageManager=`${a.packageManager}@${r.trim()}`,await A.writeJson(t,o,{spaces:2}),a.packageManager==="pnpm"){let n=q.join(P,"template/with-pnpm/pnpm-workspace.yaml"),i=q.join(e,"pnpm-workspace.yaml");await A.pathExists(n)&&await A.copy(n,i)}}}async function aa(e,a){let t=q.join(e,"apps/server/package.json");if(await A.pathExists(t)){let o=await A.readJson(t);a.database!=="none"&&(a.database==="sqlite"&&(o.scripts["db:local"]="turso dev --db-file local.db"),a.orm==="prisma"?(o.scripts["db:push"]="prisma db push --schema ./prisma/schema",o.scripts["db:studio"]="prisma studio"):a.orm==="drizzle"&&(o.scripts["db:push"]="drizzle-kit push",o.scripts["db:studio"]="drizzle-kit studio")),await A.writeJson(t,o,{spaces:2})}}async function ve(e,a){a&&await Zt({cwd:e})`git init`}import W from"node:path";import D from"fs-extra";async function ke(e,a,t){let o=W.join(e,"apps/server"),r=W.join(o,"src/index.ts"),n=await D.readFile(r,"utf-8");a==="bun"?await oa(o,r,n,t):a==="node"&&await ra(o,r,n,t)}async function oa(e,a,t,o){let r=W.join(e,"package.json"),n=await D.readJson(r);if(n.scripts={...n.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await D.writeJson(r,n,{spaces:2}),g({devDependencies:["@types/bun"],projectDir:e}),o==="hono"){let i=`${t}
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
161
 
162
162
  export default app;
163
- `;await D.writeFile(a,i)}}async function ra(e,a,t,o){let r=W.join(e,"package.json"),n=await D.readJson(r);if(n.scripts={...n.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await D.writeJson(r,n,{spaces:2}),g({devDependencies:["tsx","@types/node"],projectDir:e}),o==="hono"){g({dependencies:["@hono/node-server"],projectDir:e});let i=`import { serve } from "@hono/node-server";
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
164
  `,s=`
165
165
  serve(
166
166
  {
@@ -171,11 +171,11 @@ serve(
171
171
  console.log(\`Server is running on http://localhost:\${info.port}\`);
172
172
  },
173
173
  );
174
- `;if(!t.includes("@hono/node-server")){let c=t.lastIndexOf("import"),b=t.substring(0,c),w=t.substring(c),k=b+i+w+s;await D.writeFile(a,k)}}else if(o==="elysia"&&(g({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let i=`import { node } from "@elysiajs/node";
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
175
  `,s=t.indexOf(`
176
- `,t.indexOf("import")),c=t.substring(0,s+1),b=t.substring(s+1),w=c+i+b;w=w.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await D.writeFile(a,w)}}import u from"node:path";import h from"fs-extra";async function xe(e){let a=u.join(P,"template/base");if(!await h.pathExists(a))throw new Error(`Template directory not found: ${a}`);await h.copy(a,e)}async function Te(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
177
- `);else{let t=u.join(e,"apps/native");await h.pathExists(t)&&await h.remove(t)}}async function Ee(e,a){let t=u.join(P,`template/with-${a}`);await h.pathExists(t)&&await h.copy(t,e,{overwrite:!0})}async function $e(e,a,t,o){if(a==="none"||t==="none")return;let r=u.join(P,na(a,t));if(await h.pathExists(r)&&(await h.copy(r,e,{overwrite:!0}),!o)){if(a==="prisma"){let n=u.join(e,"apps/server/prisma/schema/auth.prisma");await h.pathExists(n)&&await h.remove(n)}else if(a==="drizzle"){let n=u.join(e,"apps/server/src/db/schema/auth.ts");await h.pathExists(n)&&await h.remove(n)}}}async function Ce(e,a,t,o,r){if(!a)return;let n=u.join(P,"template/with-auth");if(await h.pathExists(n)){let i=u.join(n,"apps/web"),s=u.join(e,"apps/web");await h.copy(i,s,{overwrite:!0});let c=u.join(n,"apps/server/src"),b=u.join(e,"apps/server/src");await h.copy(u.join(c,"lib/trpc.ts"),u.join(b,"lib/trpc.ts"),{overwrite:!0}),await h.copy(u.join(c,"routers/index.ts"),u.join(b,"routers/index.ts"),{overwrite:!0});let w=`with-${t}-context.ts`;await h.copy(u.join(c,"lib",w),u.join(b,"lib/context.ts"),{overwrite:!0});let k=`with-${t}-index.ts`;await h.copy(u.join(c,k),u.join(b,"index.ts"),{overwrite:!0});let O=ia(o,r),T=u.join(c,O);if(await h.pathExists(T)){let U=await h.readdir(T);for(let _ of U)await h.copy(u.join(T,_),u.join(b,"lib",_),{overwrite:!0})}}}async function Oe(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 o=u.join(u.dirname(t),".gitignore");await h.move(t,o)}}function na(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 ia(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 Ae(e){let a=pa(),t=sa.resolve(process.cwd(),e.projectName);try{return await la.ensureDir(t),await xe(t),await Te(t,e.frontend),await Oe(t),await Ee(t,e.backend),await de(t,e.backend,e.runtime),await $e(t,e.orm,e.database,e.auth),await be(t,e.database,e.orm,e.turso??e.database==="sqlite"),await Ce(t,e.auth,e.backend,e.orm,e.database),await le(t,e.auth),await ke(t,e.runtime,e.backend),await ye(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await we(t,e),await ve(t,e.git),e.addons.length>0&&await ne(t,e.addons,e.packageManager,e.frontend),await je(t,e),await ue(t,e),Pe(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(o){throw a.message(Ie.red("Failed")),o instanceof Error&&(ca(Ie.red(`Error during project creation: ${o.message}`)),process.exit(1)),o}}import{log as De,spinner as Fe}from"@clack/prompts";import{$ as Re}from"execa";import H from"picocolors";async function Se({projectDir:e,packageManager:a,addons:t=[]}){let o=Fe();try{o.start(`Running ${a} install...`),await Re({cwd:e,stderr:"inherit"})`${a} install`,o.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await da(e,a)}catch(r){throw o.stop(H.red("Failed to install dependencies")),r instanceof Error&&De.error(H.red(`Installation error: ${r.message}`)),r}}async function da(e,a){let t=Fe();try{t.start("Running Biome format check..."),await Re({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(H.yellow("Biome check encountered issues")),De.warn(H.yellow("Some files may need manual formatting"))}}import{cancel as lo,group as uo}from"@clack/prompts";import mo 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"),o=[{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"}],...o]:o,i=m.addons.filter(c=>t||c!=="pwa"&&c!=="tauri"),s=await fa({message:"Which Addons would you like to add?",options:n,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 o=t?.includes("native"),r=t?.includes("web");if(o&&ya.warn(Ne.yellow("Note: Authentication is not yet available with native")),!r)return!1;if(e!==void 0)return e;let n=await ba({message:"Would you like to add authentication with Better-Auth?",initialValue:m.auth});return wa(n)&&(ga(Ne.red("Operation cancelled")),process.exit(0)),n}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 Oa,multiselect as Ue}from"@clack/prompts";import Ia from"picocolors";async function Me(e,a,t,o){if(e!==void 0)return e;if(a==="none")return[];if(!t?.includes("web"))return[];let n=[];return o==="elysia"&&(n=await Ue({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})),o==="hono"&&(n=await Ue({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})),Oa(n)&&(Ca(Ia.red("Operation cancelled")),process.exit(0)),n}import{cancel as Aa,isCancel as Da,multiselect as Fa}from"@clack/prompts";import Ra from"picocolors";async function Ge(e){if(e!==void 0)return e;let a=await Fa({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 Da(a)&&(Aa(Ra.red("Operation cancelled")),process.exit(0)),a}import{cancel as Sa,confirm as La,isCancel as Na}from"@clack/prompts";import _a from"picocolors";async function Je(e){if(e!==void 0)return e;let a=await La({message:"Initialize a new git repository?",initialValue:m.git});return Na(a)&&(Sa(_a.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ba,confirm as za,isCancel as Ua}from"@clack/prompts";import Ma from"picocolors";async function Ve(e){if(e!==void 0)return e;let a=await za({message:"Do you want to install project dependencies?",initialValue:!m.noInstall});return Ua(a)&&(Ba(Ma.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Ga,isCancel as Ja,select as Va}from"@clack/prompts";import qa from"picocolors";async function qe(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Va({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 Ja(t)&&(Ga(qa.red("Operation cancelled")),process.exit(0)),t}import{cancel as Wa,isCancel as Ha,select as Ka}from"@clack/prompts";import Qa from"picocolors";async function We(e){if(e!==void 0)return e;let a=M(),t=await Ka({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(Qa.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 eo from"picocolors";var to=["<",">",":",'"',"|","?","*"],He=255;function Ke(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(to.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 Qe(e){if(e)if(e==="."){let n=process.cwd();if(R.readdirSync(n).length===0)return e}else{let n=z.basename(e);if(!Ke(n)){let s=z.resolve(process.cwd(),e);if(!R.pathExistsSync(s)||R.readdirSync(s).length===0)return e}}let a=!1,t="",o=m.projectName,r=1;for(;R.pathExistsSync(z.resolve(process.cwd(),o));)o=`${m.projectName}-${r}`,r++;for(;!a;){let n=await Za({message:"Enter your project name or path (relative to current directory)",placeholder:o,initialValue:e,defaultValue:o,validate:i=>{let s=i.trim()||o;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),b=z.basename(c),w=Ke(b);if(w)return w;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(n)&&(Xa(eo.red("Operation cancelled.")),process.exit(0)),t=n||o}return t}import{cancel as ao,isCancel as oo,select as ro}from"@clack/prompts";import no from"picocolors";async function Xe(e){if(e!==void 0)return e;let a=await ro({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 oo(a)&&(ao(no.red("Operation cancelled")),process.exit(0)),a}import{cancel as io,confirm as so,isCancel as co}from"@clack/prompts";import po from"picocolors";async function Ye(e){if(e!==void 0)return e;let a=await so({message:"Set up a Turso database for this project?",initialValue:m.turso});return co(a)&&(io(po.red("Operation cancelled")),process.exit(0)),a}async function Ze(e){let a=await uo({projectName:async()=>Qe(e.projectName),frontend:()=>Ge(e.frontend),backend:()=>Be(e.backend),runtime:()=>Xe(e.runtime),database:()=>ze(e.database),orm:({results:t})=>qe(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})=>Me(e.examples,t.database,t.frontend,t.backend),git:()=>Je(e.git),packageManager:()=>We(e.packageManager),noInstall:()=>Ve(e.noInstall)},{onCancel:()=>{lo(mo.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 x from"picocolors";function Z(e){let a=[];if(e.projectName&&a.push(`${x.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${x.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${x.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${x.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${x.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${x.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${x.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${x.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${x.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${x.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${x.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${x.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${x.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="",o=e.packageManager;o==="npm"?t="npm create better-t-stack@latest":o==="pnpm"?t="pnpm create better-t-stack@latest":o==="bun"&&(t="bun create better-t-stack@latest");let r=e.projectName?` ${e.projectName}`:"";return`${t}${r} ${a.join(" ")}`}import fo from"node:path";import ho from"fs-extra";var tt=()=>{let e=fo.join(P,"package.json");return ho.readJSONSync(e).version??"1.0.0"};import at from"gradient-string";var ot=`
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=`
179
179
  \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
180
  \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
181
  \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 +189,10 @@ serve(
189
189
  \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
190
  \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
191
  \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
- `,rt={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},nt=()=>{let e=process.stdout.columns||80,a=ot.split(`
193
- `),t=Math.max(...a.map(o=>o.length));e<t?console.log(at(Object.values(rt)).multiline(`
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(`
194
194
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
195
195
  \u2551 Better T-Stack \u2551
196
196
  \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(rt)).multiline(ot))};process.on("SIGINT",()=>{C.error(v.red("Operation cancelled")),process.exit(0)});var ee=new yo;async function Po(){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 or both)",t=>t.split(",")).option("--addons <types>","Additional addons (pwa,tauri,biome,husky)",t=>t.split(",")).option("--no-addons","Skip all additional addons").option("--examples <types>","Examples to include (todo,ai)",t=>t.split(",")).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=wo();try{nt(),go(v.magenta("Creating a new Better-T-Stack project"));let t=ee.opts(),o=ee.args[0];if(t.database&&!["none","sqlite","postgres"].includes(t.database)&&(S(v.red(`Invalid database type: ${t.database}. Must be none, sqlite, or postgres.`)),process.exit(1)),t.orm&&!["none","drizzle","prisma"].includes(t.orm)&&(S(v.red(`Invalid ORM type: ${t.orm}. Must be none, drizzle, or prisma.`)),process.exit(1)),t.packageManager&&!["npm","pnpm","bun"].includes(t.packageManager)&&(S(v.red(`Invalid package manager: ${t.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),t.backend&&!["hono","elysia"].includes(t.backend)&&(S(v.red(`Invalid backend framework: ${t.backend}. Must be hono or elysia.`)),process.exit(1)),t.runtime&&!["bun","node"].includes(t.runtime)&&(S(v.red(`Invalid runtime: ${t.runtime}. Must be bun or node.`)),process.exit(1)),t.examples&&t.examples.length>0){let c=["todo","ai"],b=t.examples.filter(w=>!c.includes(w));b.length>0&&(S(v.red(`Invalid example(s): ${b.join(", ")}. Valid options are: ${c.join(", ")}.`)),process.exit(1))}let r={...o&&{projectName:o},...t.database&&{database:t.database},...t.orm&&{orm:t.orm},..."auth"in t&&{auth:t.auth},...t.packageManager&&{packageManager:t.packageManager},..."git"in t&&{git:t.git},..."install"in t&&{noInstall:!t.install},..."turso"in t&&{turso:t.turso},...t.backend&&{backend:t.backend},...t.runtime&&{runtime:t.runtime},...t.frontend&&{frontend:t.frontend},...(t.addons||t.addons===!1)&&{addons:t.addons===!1?[]:t.addons},...(t.examples||t.examples===!1)&&{examples:t.examples===!1?[]:t.examples}};!t.yes&&Object.keys(r).length>0&&(C.info(v.yellow("Using these pre-selected options:")),C.message(Z(r)),C.message(""));let n=t.yes?{...m,projectName:o??m.projectName,...r}:await Ze(r);t.yes&&(C.info(v.yellow("Using these default options:")),C.message(Z(n)),C.message(""));let i=await Ae(n);n.noInstall||await Se({projectDir:i,packageManager:n.packageManager,addons:n.addons}),C.success(v.blue(`You can reproduce this setup with the following command:
198
- ${v.white(et(n))}`));let s=((Date.now()-e)/1e3).toFixed(2);bo(v.magenta(`Project created successfully in ${v.bold(s)} seconds!`))}catch(t){a.stop(v.red("Failed")),t instanceof Error&&(S(v.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}Po().catch(e=>{C.error("Aborting installation..."),e instanceof Error?C.error(e.message):(C.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
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)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
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",
@@ -1,18 +1,18 @@
1
1
  export const NAV_THEME = {
2
2
  light: {
3
- background: "hsl(0 0% 100%)", // background
4
- border: "hsl(240 5.9% 90%)", // border
5
- card: "hsl(0 0% 100%)", // card
6
- notification: "hsl(0 84.2% 60.2%)", // destructive
7
- primary: "hsl(240 5.9% 10%)", // primary
8
- text: "hsl(240 10% 3.9%)", // foreground
3
+ background: "hsl(0 0% 100%)",
4
+ border: "hsl(240 5.9% 90%)",
5
+ card: "hsl(0 0% 100%)",
6
+ notification: "hsl(0 84.2% 60.2%)",
7
+ primary: "hsl(240 5.9% 10%)",
8
+ text: "hsl(240 10% 3.9%)",
9
9
  },
10
10
  dark: {
11
- background: "hsl(240 10% 3.9%)", // background
12
- border: "hsl(240 3.7% 15.9%)", // border
13
- card: "hsl(240 10% 3.9%)", // card
14
- notification: "hsl(0 72% 51%)", // destructive
15
- primary: "hsl(0 0% 98%)", // primary
16
- text: "hsl(0 0% 98%)", // foreground
11
+ background: "hsl(240 10% 3.9%)",
12
+ border: "hsl(240 3.7% 15.9%)",
13
+ card: "hsl(240 10% 3.9%)",
14
+ notification: "hsl(0 72% 51%)",
15
+ primary: "hsl(0 0% 98%)",
16
+ text: "hsl(0 0% 98%)",
17
17
  },
18
18
  };
@@ -19,9 +19,8 @@ const app = new Elysia()
19
19
  const { request } = context;
20
20
  if (["POST", "GET"].includes(request.method)) {
21
21
  return auth.handler(request);
22
- } else {
23
- context.error(405);
24
22
  }
23
+ context.error(405);
25
24
  })
26
25
  .all("/trpc/*", async (context) => {
27
26
  const res = await fetchRequestHandler({
@@ -34,5 +33,5 @@ const app = new Elysia()
34
33
  })
35
34
  .get("/", () => "OK")
36
35
  .listen(3000, () => {
37
- console.log(`Server is running on http://localhost:3000`);
36
+ console.log("Server is running on http://localhost:3000");
38
37
  });