create-better-t-stack 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +30 -39
  2. package/dist/index.js +30 -30
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -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 or both)
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,5 +1,5 @@
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 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,"../"),u={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 h=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..."),h({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}),h({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}),h({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;h({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{h({dependencies:["better-auth"],projectDir:t}),h({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"),h({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}
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
 
@@ -79,7 +79,7 @@ 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+=`
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,g="",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)),g=k;let O=Y();try{O.start(`Creating Turso database "${g}"${s?` in group "${s}"`:""}...`);let T=await Lt(g,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(g)}" already exists`)),w=`${g}-${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"?h({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:n}):t==="prisma"&&h({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:n}),o&&await fe(e,!0)):a==="postgres"&&(t==="drizzle"?h({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:n}):t==="prisma"&&h({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
83
  CORS_ORIGIN=http://localhost:3001`),a.auth&&(r.includes("BETTER_AUTH_SECRET")||(r+=`
84
84
  BETTER_AUTH_SECRET=${pe()}`),r.includes("BETTER_AUTH_URL")||(r+=`
85
85
  BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!r.includes("DATABASE_URL")){let n=a.database==="sqlite"?"":`
@@ -87,7 +87,7 @@ DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`
87
87
  TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}if(a.examples?.includes("ai")&&!r.includes("GOOGLE_GENERATIVE_AI_API_KEY")&&(r+=`
88
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
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";
90
+ `),await I.writeFile(i,s.trim())}}import y from"node:path";import m from"fs-extra";async function ye(e,a,t,o,r,n=["web"]){let i=n.includes("web"),s=await m.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 m.pathExists(a)){await m.copy(a,e),await Mt(e);let t=y.join(e,"apps/web");h({dependencies:["ai"],projectDir:t});let o=y.join(e,"apps/server");h({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 m.pathExists(a)){let t=await m.readFile(a,"utf8");if(t.includes("hono")){let r=`import { streamText } from "ai";
91
91
  import { google } from "@ai-sdk/google";
92
92
  import { stream } from "hono/streaming";`,n=`
93
93
  app.post("/ai", async (c) => {
@@ -114,53 +114,53 @@ ${t.substring(i)}`;else{let s=t.indexOf("export default");s!==-1?t=`${t.substrin
114
114
 
115
115
  ${t.substring(s)}`:t=`${t}
116
116
 
117
- ${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
+ ${n}`}await m.writeFile(a,t)}}}async function Mt(e){let a=y.join(e,"apps/web/src/components/header.tsx");if(await m.pathExists(a)){let t=await m.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 m.writeFile(a,t)}}async function Gt(e,a,t){let o=y.join(P,"template/examples/todo");if(await m.pathExists(o)){let r=y.join(o,"apps/web/src/routes"),n=y.join(e,"apps/web/src/routes");if(await m.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 m.pathExists(i)&&await m.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 m.pathExists(t)){let o=await m.readFile(t,"utf8");a?o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
122
122
  { to: "/", label: "Home" },
123
123
  { to: "/dashboard", label: "Dashboard" },
124
124
  { to: "/todos", label: "Todos" },`):o=o.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 m.writeFile(t,o)}}async function Vt(e,a){if(a==="drizzle"){let o=y.join(e,"apps/server/src/db/schema/todo.ts");await m.pathExists(o)&&await m.remove(o)}else if(a==="prisma"){let o=y.join(e,"apps/server/prisma/schema/todo.prisma");await m.pathExists(o)&&await m.remove(o)}let t=y.join(e,"apps/server/src/routers/todo.ts");await m.pathExists(t)&&await m.remove(t),await qt(e)}async function qt(e){let a=y.join(e,"apps/server/src/routers/index.ts");if(await m.pathExists(a)){let t=await m.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await m.writeFile(a,t)}}async function Wt(e){let a=y.join(e,"apps/web/src/routes/index.tsx");if(await m.pathExists(a)){let t=await m.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
133
+ </div>`),await m.writeFile(a,t)}}import{note as Ht}from"@clack/prompts";import b from"picocolors";function Pe(e,a,t,o,r,n,i,s){let c=t==="npm"?"npm run":t,g=`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(`${b.cyan("1.")} ${g}
134
+ ${o?"":`${b.cyan("2.")} ${t} install
135
+ `}${b.cyan(o?"2.":"3.")} ${c} dev
136
+
137
+ ${b.bold("Your project will be available at:")}
138
+ ${st?`${_?`${b.cyan("\u2022")} Frontend: http://localhost:3001
139
+ `:""}`:`${b.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
140
+ `}${b.cyan("\u2022")} API: http://localhost:3000
142
141
  ${U?`
143
142
  ${U.trim()}`:""}${k?`
144
143
  ${k.trim()}`:""}${O?`
145
144
  ${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`)}
145
+ ${T.trim()}`:""}`,"Next steps")}function Kt(){return`${b.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 Qt(e){return`${b.bold(`
148
+ Linting and formatting:`)}
149
+ ${b.cyan("\u2022")} Format and lint fix: ${`${e} check`}
150
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:")}
151
+ `}function Xt(e,a,t,o){let r=[];return a==="prisma"?(e==="sqlite"&&r.push(`${b.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"),o==="bun"&&r.push(`${b.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors, follow the guidance provided in the error messages`),r.push(`${b.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),r.push(`${b.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)):a==="drizzle"&&(e==="sqlite"&&r.push(`${b.cyan("\u2022")} Start local DB: ${`cd apps/server && ${t} db:local`}`),r.push(`${b.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),r.push(`${b.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)),r.length?`${b.bold("Database commands:")}
152
152
  ${r.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 Yt(e){return`${b.bold("Desktop app with Tauri:")}
156
+ ${b.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
157
+ ${b.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
158
+ ${b.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 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}),h({devDependencies:["@types/bun"],projectDir:e}),o==="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 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}),h({devDependencies:["tsx","@types/node"],projectDir:e}),o==="hono"){h({dependencies:["@hono/node-server"],projectDir:e});let i=`import { serve } from "@hono/node-server";
164
164
  `,s=`
165
165
  serve(
166
166
  {
@@ -171,10 +171,10 @@ 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"),g=t.substring(0,c),w=t.substring(c),k=g+i+w+s;await D.writeFile(a,k)}}else if(o==="elysia"&&(h({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(`
176
+ `,t.indexOf("import")),c=t.substring(0,s+1),g=t.substring(s+1),w=c+i+g;w=w.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await D.writeFile(a,w)}}import d from"node:path";import f from"fs-extra";async function xe(e){let a=d.join(P,"template/base");if(!await f.pathExists(a))throw new Error(`Template directory not found: ${a}`);await f.copy(a,e)}async function Te(e,a){if(!a.includes("web")){let t=d.join(e,"apps/web");await f.pathExists(t)&&await f.remove(t)}if(a.includes("native"))await f.writeFile(d.join(e,".npmrc"),`node-linker=hoisted
177
+ `);else{let t=d.join(e,"apps/native");await f.pathExists(t)&&await f.remove(t)}}async function Ee(e,a){let t=d.join(P,`template/with-${a}`);await f.pathExists(t)&&await f.copy(t,e,{overwrite:!0})}async function $e(e,a,t,o){if(a==="none"||t==="none")return;let r=d.join(P,na(a,t));if(await f.pathExists(r)&&(await f.copy(r,e,{overwrite:!0}),!o)){if(a==="prisma"){let n=d.join(e,"apps/server/prisma/schema/auth.prisma");await f.pathExists(n)&&await f.remove(n)}else if(a==="drizzle"){let n=d.join(e,"apps/server/src/db/schema/auth.ts");await f.pathExists(n)&&await f.remove(n)}}}async function Ce(e,a,t,o,r){if(!a)return;let n=d.join(P,"template/with-auth");if(await f.pathExists(n)){let i=d.join(n,"apps/web"),s=d.join(e,"apps/web");await f.copy(i,s,{overwrite:!0});let c=d.join(n,"apps/server/src"),g=d.join(e,"apps/server/src");await f.copy(d.join(c,"lib/trpc.ts"),d.join(g,"lib/trpc.ts"),{overwrite:!0}),await f.copy(d.join(c,"routers/index.ts"),d.join(g,"routers/index.ts"),{overwrite:!0});let w=`with-${t}-context.ts`;await f.copy(d.join(c,"lib",w),d.join(g,"lib/context.ts"),{overwrite:!0});let k=`with-${t}-index.ts`;await f.copy(d.join(c,k),d.join(g,"index.ts"),{overwrite:!0});let O=ia(o,r),T=d.join(c,O);if(await f.pathExists(T)){let U=await f.readdir(T);for(let _ of U)await f.copy(d.join(T,_),d.join(g,"lib",_),{overwrite:!0})}}}async function Oe(e){let a=[d.join(e,"_gitignore"),d.join(e,"apps/web/_gitignore"),d.join(e,"apps/native/_gitignore"),d.join(e,"apps/server/_gitignore")];for(let t of a)if(await f.pathExists(t)){let o=d.join(d.dirname(t),".gitignore");await f.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=u.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:u.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:u.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:u.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:u.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:u.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:u.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:u.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:!u.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:u.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=u.projectName,r=1;for(;R.pathExistsSync(z.resolve(process.cwd(),o));)o=`${u.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),g=z.basename(c),w=Ke(g);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:u.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:u.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
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=`
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
@@ -194,5 +194,5 @@ serve(
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:
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"],g=t.examples.filter(w=>!c.includes(w));g.length>0&&(S(v.red(`Invalid example(s): ${g.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?{...u,projectName:o??u.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
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)});
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.2",
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",