create-better-t-stack 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +52 -38
  2. package/dist/index.js +66 -60
  3. package/package.json +1 -1
  4. package/template/base/apps/native/_gitignore +24 -0
  5. package/template/base/apps/native/app/(drawer)/(tabs)/_layout.tsx +29 -0
  6. package/template/base/apps/native/app/(drawer)/(tabs)/index.tsx +9 -0
  7. package/template/base/apps/native/app/(drawer)/(tabs)/two.tsx +16 -0
  8. package/template/base/apps/native/app/(drawer)/_layout.tsx +39 -0
  9. package/template/base/apps/native/app/(drawer)/index.tsx +36 -0
  10. package/template/base/apps/native/app/+html.tsx +46 -0
  11. package/template/base/apps/native/app/+not-found.tsx +18 -0
  12. package/template/base/apps/native/app/_layout.tsx +76 -0
  13. package/template/base/apps/native/app/modal.tsx +15 -0
  14. package/template/base/apps/native/app-env.d.ts +2 -0
  15. package/template/base/apps/native/app.json +38 -0
  16. package/template/base/apps/native/assets/adaptive-icon.png +0 -0
  17. package/template/base/apps/native/assets/favicon.png +0 -0
  18. package/template/base/apps/native/assets/icon.png +0 -0
  19. package/template/base/apps/native/assets/splash.png +0 -0
  20. package/template/base/apps/native/babel.config.js +12 -0
  21. package/template/base/apps/native/components/container.tsx +9 -0
  22. package/template/base/apps/native/components/header-button.tsx +31 -0
  23. package/template/base/apps/native/components/tabbar-icon.tsx +15 -0
  24. package/template/base/apps/native/global.css +25 -0
  25. package/template/base/apps/native/lib/android-navigation-bar.tsx +11 -0
  26. package/template/base/apps/native/lib/constants.ts +18 -0
  27. package/template/base/apps/native/lib/use-color-scheme.ts +12 -0
  28. package/template/base/apps/native/metro.config.js +57 -0
  29. package/template/base/apps/native/package.json +47 -0
  30. package/template/base/apps/native/tailwind.config.js +32 -0
  31. package/template/base/apps/native/tsconfig.json +18 -0
  32. package/template/base/apps/native/utils/trpc.ts +19 -0
  33. package/template/base/apps/server/package.json +0 -2
  34. package/template/base/apps/server/tsconfig.json +1 -1
  35. package/template/base/apps/{client → web}/package.json +1 -1
  36. package/template/base/apps/web/src/main.tsx +33 -0
  37. package/template/base/apps/{client → web}/src/routes/__root.tsx +3 -3
  38. package/template/base/apps/{client → web}/src/routes/index.tsx +7 -6
  39. package/template/base/apps/web/src/utils/trpc.ts +33 -0
  40. package/template/base/package.json +2 -1
  41. package/template/{with-drizzle-sqlite/apps/server/src/with-auth-lib/context.ts → with-auth/apps/server/src/lib/with-elysia-context.ts} +4 -4
  42. package/template/{with-drizzle-postgres/apps/server/src/with-auth-lib/context.ts → with-auth/apps/server/src/lib/with-hono-context.ts} +3 -3
  43. package/template/with-auth/apps/server/src/with-elysia-index.ts +38 -0
  44. package/template/with-auth/apps/server/src/{index.ts → with-hono-index.ts} +3 -2
  45. package/template/with-auth/apps/{client → web}/src/routes/dashboard.tsx +2 -1
  46. package/template/with-auth/apps/web/src/utils/trpc.ts +39 -0
  47. package/template/with-elysia/apps/server/src/index.ts +27 -0
  48. package/template/with-elysia/apps/server/src/lib/context.ts +13 -0
  49. package/template/{base → with-hono}/apps/server/src/index.ts +2 -2
  50. package/template/{base → with-hono}/apps/server/src/lib/context.ts +2 -2
  51. package/template/base/apps/client/src/main.tsx +0 -72
  52. package/template/base/apps/client/src/utils/trpc.ts +0 -4
  53. package/template/with-auth/apps/client/src/main.tsx +0 -78
  54. package/template/with-drizzle-postgres/apps/server/src/routers/todo.ts +0 -44
  55. package/template/with-drizzle-postgres/apps/server/src/with-auth-lib/trpc.ts +0 -24
  56. package/template/with-drizzle-sqlite/apps/server/src/with-auth-lib/trpc.ts +0 -24
  57. package/template/with-prisma-postgres/apps/server/src/with-auth-lib/context.ts +0 -18
  58. package/template/with-prisma-postgres/apps/server/src/with-auth-lib/trpc.ts +0 -24
  59. package/template/with-prisma-sqlite/apps/server/src/with-auth-lib/context.ts +0 -18
  60. package/template/with-prisma-sqlite/apps/server/src/with-auth-lib/trpc.ts +0 -24
  61. package/template/base/apps/{client → web}/_gitignore +0 -0
  62. package/template/base/apps/{client → web}/components.json +0 -0
  63. package/template/base/apps/{client → web}/index.html +0 -0
  64. package/template/base/apps/{client → web}/src/components/header.tsx +0 -0
  65. package/template/base/apps/{client → web}/src/components/loader.tsx +0 -0
  66. package/template/base/apps/{client → web}/src/components/mode-toggle.tsx +0 -0
  67. package/template/base/apps/{client → web}/src/components/theme-provider.tsx +0 -0
  68. package/template/base/apps/{client → web}/src/components/ui/button.tsx +0 -0
  69. package/template/base/apps/{client → web}/src/components/ui/card.tsx +0 -0
  70. package/template/base/apps/{client → web}/src/components/ui/checkbox.tsx +0 -0
  71. package/template/base/apps/{client → web}/src/components/ui/dropdown-menu.tsx +0 -0
  72. package/template/base/apps/{client → web}/src/components/ui/input.tsx +0 -0
  73. package/template/base/apps/{client → web}/src/components/ui/label.tsx +0 -0
  74. package/template/base/apps/{client → web}/src/components/ui/skeleton.tsx +0 -0
  75. package/template/base/apps/{client → web}/src/components/ui/sonner.tsx +0 -0
  76. package/template/base/apps/{client → web}/src/index.css +0 -0
  77. package/template/base/apps/{client → web}/src/lib/utils.ts +0 -0
  78. package/template/base/apps/{client → web}/tsconfig.json +0 -0
  79. package/template/base/apps/{client → web}/vite.config.ts +0 -0
  80. package/template/examples/todo/apps/{client → web}/src/routes/todos.tsx +0 -0
  81. package/template/{with-drizzle-postgres/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-drizzle-postgres-lib}/auth.ts +1 -1
  82. /package/template/{with-drizzle-sqlite/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-drizzle-sqlite-lib}/auth.ts +0 -0
  83. /package/template/{with-prisma-postgres/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-prisma-postgres-lib}/auth.ts +0 -0
  84. /package/template/{with-prisma-sqlite/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-prisma-sqlite-lib}/auth.ts +0 -0
  85. /package/template/with-auth/apps/{client → web}/src/components/auth-forms.tsx +0 -0
  86. /package/template/with-auth/apps/{client → web}/src/components/header.tsx +0 -0
  87. /package/template/with-auth/apps/{client → web}/src/components/sign-in-form.tsx +0 -0
  88. /package/template/with-auth/apps/{client → web}/src/components/sign-up-form.tsx +0 -0
  89. /package/template/with-auth/apps/{client → web}/src/components/user-menu.tsx +0 -0
  90. /package/template/with-auth/apps/{client → web}/src/lib/auth-client.ts +0 -0
  91. /package/template/with-auth/apps/{client → web}/src/routes/login.tsx +0 -0
  92. /package/template/with-pwa/apps/{client → web}/public/logo.png +0 -0
  93. /package/template/with-pwa/apps/{client → web}/pwa-assets.config.ts +0 -0
  94. /package/template/with-pwa/apps/{client → web}/vite.config.ts +0 -0
package/README.md CHANGED
@@ -1,24 +1,31 @@
1
1
  # Create Better-T-Stack CLI
2
2
 
3
- An interactive CLI tool to quickly scaffold full-stack TypeScript applications with React, Hono, and tRPC. The Better-T-Stack provides a modern, type-safe development experience with the best tools from the TypeScript ecosystem.
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.
4
4
 
5
5
  ## Quick Start
6
6
 
7
7
  Run without installing globally:
8
8
 
9
9
  ```bash
10
+ # Using npm
10
11
  npx create-better-t-stack@latest
11
- # OR
12
- bunx create-better-t-stack
12
+
13
+ # Using bun
14
+ bun create better-t-stack@latest
15
+
16
+ # Using pnpm
17
+ pnpm create better-t-stack@latest
13
18
  ```
14
19
 
15
- Follow the prompts to configure your project.
20
+ Follow the prompts to configure your project or use the `-y` flag for defaults.
16
21
 
17
22
  ## Features
18
23
 
19
24
  - **Monorepo**: Turborepo for optimized build system and workspace management
20
25
  - **Frontend**: React, TanStack Router, TanStack Query, Tailwind CSS with shadcn/ui components
21
- - **Backend**: Hono, tRPC
26
+ - **Native Apps**: Create React Native apps with Expo for iOS and Android
27
+ - **Backend Frameworks**: Choose between Hono or Elysia
28
+ - **API Layer**: End-to-end type safety with tRPC
22
29
  - **Runtime Options**: Choose between Bun or Node.js for your server
23
30
  - **Database Options**: SQLite (via Turso), PostgreSQL, or no database
24
31
  - **ORM Selection**: Choose between Drizzle ORM or Prisma
@@ -36,33 +43,39 @@ Follow the prompts to configure your project.
36
43
  Usage: create-better-t-stack [project-directory] [options]
37
44
 
38
45
  Options:
39
- -V, --version Output the version number
40
- -y, --yes Use default configuration
41
- --no-database Skip database setup
42
- --sqlite Use SQLite database
43
- --postgres Use PostgreSQL database
44
- --auth Include authentication
45
- --no-auth Disable authentication
46
- --pwa Include Progressive Web App support
47
- --tauri Include Tauri desktop app support
48
- --biome Include Biome for linting and formatting
49
- --husky Include Husky, lint-staged for Git hooks
50
- --no-addons Skip all additional addons
51
- --examples <examples> Include specified examples
52
- --no-examples Skip all examples
53
- --git Initialize a new git repo (default)
54
- --no-git Skip git initialization
55
- --npm Use npm as package manager
56
- --pnpm Use pnpm as package manager
57
- --bun Use bun as package manager
58
- --drizzle Use Drizzle ORM
59
- --prisma Use Prisma ORM
60
- --install Install dependencies (default)
61
- --no-install Skip installing dependencies
62
- --turso Set up Turso for SQLite database (default with sqlite)
63
- --no-turso Skip Turso setup for SQLite database
64
- --runtime <runtime> Specify runtime (bun or node)
65
- -h, --help Display help
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
66
79
  ```
67
80
 
68
81
  ## Examples
@@ -74,16 +87,17 @@ npx create-better-t-stack my-app -y
74
87
 
75
88
  Create a project with specific options:
76
89
  ```bash
77
- npx create-better-t-stack my-app --postgres --prisma --auth --pwa --biome
90
+ npx create-better-t-stack my-app --postgres --drizzle --auth --pwa --biome
78
91
  ```
79
92
 
80
- Create a project with Node.js runtime:
93
+ Create a project with Elysia and Node.js runtime:
81
94
  ```bash
82
- npx create-better-t-stack my-app --runtime node
95
+ npx create-better-t-stack my-app --elysia --runtime node
83
96
  ```
84
97
 
85
- ## License
86
-
87
- MIT
98
+ Create a project using Hono with no addons:
99
+ ```bash
100
+ npx create-better-t-stack my-app --hono --no-addons
101
+ ```
88
102
 
89
103
  Created by [Aman Varshney](https://github.com/AmanVarshney01) & [Nitish Singh](https://github.com/FgrReloaded)
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as qa,intro as Va,log as x,outro as Ha,spinner as Wa}from"@clack/prompts";import{Command as Qa}from"commander";import E from"picocolors";import Y from"node:path";import{fileURLToPath as Xe}from"node:url";var Ye=Xe(import.meta.url),Ze=Y.dirname(Ye),g=Y.join(Ze,"../"),u={projectName:"my-better-t-app",database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:"npm",noInstall:!1,turso:!1,backendFramework:"hono",runtime:"bun"},G={"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"};import Gt from"node:path";import{cancel as qt,spinner as Vt}from"@clack/prompts";import Ht from"fs-extra";import xe from"picocolors";import A from"node:path";import h from"fs-extra";import et from"node:path";import Z from"fs-extra";var f=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:o}=e,r=et.join(o,"package.json"),s=Z.readJSONSync(r);s.dependencies||(s.dependencies={}),s.devDependencies||(s.devDependencies={});for(let i of a){let n=G[i];s.dependencies[i]=n}for(let i of t){let n=G[i];s.devDependencies[i]=n}Z.writeJSONSync(r,s,{spaces:2})};import N from"node:path";import{log as tt,spinner as at}from"@clack/prompts";import{execa as ot}from"execa";import q from"fs-extra";import ee from"picocolors";async function te(e,a){let t=at(),o=N.join(e,"apps/client");try{t.start("Setting up Tauri desktop app support..."),f({devDependencies:["@tauri-apps/cli"],projectDir:o});let r=N.join(o,"package.json");if(await q.pathExists(r)){let n=await q.readJson(r);n.scripts={...n.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await q.writeJson(r,n,{spaces:2})}let s,i;switch(a){case"npm":s="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":s="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":s="bunx",i=["@tauri-apps/cli@latest"];break;default:s="npx",i=["@tauri-apps/cli@latest"]}i=[...i,"init",`--app-name=${N.basename(e)}`,`--window-title=${N.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ot(s,i,{cwd:o,env:{CI:"true"}}),t.stop("Tauri desktop app support configured successfully!")}catch(r){throw t.stop(ee.red("Failed to set up Tauri")),r instanceof Error&&tt.error(ee.red(r.message)),r}}async function ae(e,a,t){a.includes("pwa")&&await it(e),a.includes("tauri")&&await te(e,t),a.includes("biome")&&await rt(e),a.includes("husky")&&await st(e)}async function rt(e){let a=A.join(g,"template/with-biome");await h.pathExists(a)&&await h.copy(a,e,{overwrite:!0}),f({devDependencies:["@biomejs/biome"],projectDir:e});let t=A.join(e,"package.json");if(await h.pathExists(t)){let o=await h.readJson(t);o.scripts={...o.scripts,check:"biome check --write ."},await h.writeJson(t,o,{spaces:2})}}async function st(e){let a=A.join(g,"template/with-husky");await h.pathExists(a)&&await h.copy(a,e,{overwrite:!0}),f({devDependencies:["husky","lint-staged"],projectDir:e});let t=A.join(e,"package.json");if(await h.pathExists(t)){let o=await h.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 h.writeJson(t,o,{spaces:2})}}async function it(e){let a=A.join(g,"template/with-pwa");await h.pathExists(a)&&await h.copy(a,e,{overwrite:!0});let t=A.join(e,"apps/client");f({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let o=A.join(t,"package.json");if(await h.pathExists(o)){let r=await h.readJson(o);r.scripts={...r.scripts,"generate-pwa-assets":"pwa-assets-generator"},await h.writeJson(o,r,{spaces:2})}}import oe from"node:path";import{log as re}from"@clack/prompts";import se from"picocolors";function ie(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 ne(e,a){if(!a)return;let t=oe.join(e,"apps/server"),o=oe.join(e,"apps/client");try{f({dependencies:["better-auth"],projectDir:t}),f({dependencies:["better-auth"],projectDir:o})}catch(r){throw re.error(se.red("Failed to configure authentication")),r instanceof Error&&re.error(se.red(r.message)),r}}import nt from"node:path";import ct from"fs-extra";async function ce(e,a){let t=nt.join(e,"README.md"),o=pt(a);try{await ct.writeFile(t,o)}catch(r){console.error("Failed to create README.md file:",r)}}function pt(e){let{projectName:a,packageManager:t,database:o,auth:r,addons:s=[],orm:i="drizzle",runtime:n="bun"}=e,d=t==="npm"?"npm run":t;return`# ${a}
2
+ import{cancel as uo,intro as mo,log as $,outro as fo,spinner as ho}from"@clack/prompts";import{Command as go}from"commander";import F from"picocolors";import te from"node:path";import{fileURLToPath as it}from"node:url";var B=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var st=it(import.meta.url),ct=te.dirname(st),y=te.join(ct,"../"),c={projectName:"my-better-t-app",frontend:["web"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:B(),noInstall:!1,turso:!1,backendFramework:"hono",runtime:"bun"},W={"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"};import aa from"node:path";import{cancel as oa,spinner as ra}from"@clack/prompts";import na from"fs-extra";import Oe from"picocolors";import R from"node:path";import k from"fs-extra";import pt from"node:path";import ae from"fs-extra";var g=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:o}=e,r=pt.join(o,"package.json"),n=ae.readJSONSync(r);n.dependencies||(n.dependencies={}),n.devDependencies||(n.devDependencies={});for(let i of a){let s=W[i];n.dependencies[i]=s}for(let i of t){let s=W[i];n.devDependencies[i]=s}ae.writeJSONSync(r,n,{spaces:2})};import M from"node:path";import{log as lt,spinner as dt}from"@clack/prompts";import{execa as ut}from"execa";import H from"fs-extra";import oe from"picocolors";async function re(e,a){let t=dt(),o=M.join(e,"apps/web");try{t.start("Setting up Tauri desktop app support..."),g({devDependencies:["@tauri-apps/cli"],projectDir:o});let r=M.join(o,"package.json");if(await H.pathExists(r)){let s=await H.readJson(r);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await H.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=${M.basename(e)}`,`--window-title=${M.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ut(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&&lt.error(oe.red(r.message)),r}}async function ne(e,a,t){a.includes("pwa")&&await ht(e),a.includes("tauri")&&await re(e,t),a.includes("biome")&&await mt(e),a.includes("husky")&&await ft(e)}async function mt(e){let a=R.join(y,"template/with-biome");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),g({devDependencies:["@biomejs/biome"],projectDir:e});let t=R.join(e,"package.json");if(await k.pathExists(t)){let o=await k.readJson(t);o.scripts={...o.scripts,check:"biome check --write ."},await k.writeJson(t,o,{spaces:2})}}async function ft(e){let a=R.join(y,"template/with-husky");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),g({devDependencies:["husky","lint-staged"],projectDir:e});let t=R.join(e,"package.json");if(await k.pathExists(t)){let o=await k.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 k.writeJson(t,o,{spaces:2})}}async function ht(e){let a=R.join(y,"template/with-pwa");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0});let t=R.join(e,"apps/web");g({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let o=R.join(t,"package.json");if(await k.pathExists(o)){let r=await k.readJson(o);r.scripts={...r.scripts,"generate-pwa-assets":"pwa-assets-generator"},await k.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 gt from"node:path";async function de(e,a,t){let o=gt.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 wt from"node:path";import bt from"fs-extra";async function ue(e,a){let t=wt.join(e,"README.md"),o=yt(a);try{await bt.writeFile(t,o)}catch(r){console.error("Failed to create README.md file:",r)}}function yt(e){let{projectName:a,packageManager:t,database:o,auth:r,addons:n=[],orm:i="drizzle",runtime:s="bun"}=e,m=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
- ${lt(o,r,s,i,n)}
8
+ ${kt(o,r,n,i,s)}
9
9
 
10
10
  ## Getting Started
11
11
 
@@ -15,15 +15,15 @@ First, install the dependencies:
15
15
  ${t} install
16
16
  \`\`\`
17
17
 
18
- ${ut(o,r,d,i)}
18
+ ${Pt(o,r,m,i)}
19
19
 
20
20
  Then, run the development server:
21
21
 
22
22
  \`\`\`bash
23
- ${d} dev
23
+ ${m} dev
24
24
  \`\`\`
25
25
 
26
- Open [http://localhost:3001](http://localhost:3001) in your browser to see the client application.
26
+ Open [http://localhost:3001](http://localhost:3001) in your browser to see the web application.
27
27
  The API is running at [http://localhost:3000](http://localhost:3000).
28
28
 
29
29
  ## Project Structure
@@ -31,15 +31,15 @@ The API is running at [http://localhost:3000](http://localhost:3000).
31
31
  \`\`\`
32
32
  ${a}/
33
33
  \u251C\u2500\u2500 apps/
34
- \u2502 \u251C\u2500\u2500 client/ # Frontend application (React, TanStack Router)
34
+ \u2502 \u251C\u2500\u2500 web/ # Frontend application (React, TanStack Router)
35
35
  \u2502 \u2514\u2500\u2500 server/ # Backend API (Hono, tRPC)
36
36
  \`\`\`
37
37
 
38
38
  ## Available Scripts
39
39
 
40
- ${dt(d,o,i,r)}
41
- `}function lt(e,a,t,o,r){let s=["- **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"&&s.push(`- **${o==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&s.push("- **Authentication** - Email & password authentication with Better Auth");for(let i of t)i==="pwa"?s.push("- **PWA** - Progressive Web App support"):i==="tauri"?s.push("- **Tauri** - Build native desktop applications"):i==="biome"?s.push("- **Biome** - Linting and formatting"):i==="husky"&&s.push("- **Husky** - Git hooks for code quality");return s.join(`
42
- `)}function ut(e,a,t,o){if(e==="none")return"";let r=`## Database Setup
40
+ ${vt(m,o,i,r)}
41
+ `}function kt(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 Pt(e,a,t,o){if(e==="none")return"";let r=`## Database Setup
43
43
 
44
44
  `;return e==="sqlite"?r+=`This project uses SQLite${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
45
45
 
@@ -61,17 +61,17 @@ ${t} db:push
61
61
  \`\`\`bash
62
62
  ${t} db:push
63
63
  \`\`\``}
64
- `,r}function dt(e,a,t,o){let r=`- \`${e} dev\`: Start both client and server in development mode
65
- - \`${e} build\`: Build both client and server
66
- - \`${e} dev:client\`: Start only the client
64
+ `,r}function vt(e,a,t,o){let r=`- \`${e} dev\`: Start both web and server in development mode
65
+ - \`${e} build\`: Build both web and server
66
+ - \`${e} dev:web\`: Start only the web application
67
67
  - \`${e} dev:server\`: Start only the server
68
68
  - \`${e} check-types\`: Check TypeScript types across all apps`;return a!=="none"&&(r+=`
69
69
  - \`${e} db:push\`: Push schema changes to database
70
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 ue from"node:path";import{log as Tt,spinner as $t}from"@clack/prompts";import Et from"fs-extra";import de from"picocolors";import mt from"node:os";import pe from"node:path";import{cancel as V,confirm as ft,isCancel as H,log as I,select as ht,spinner as W,text as gt}from"@clack/prompts";import{$ as k}from"execa";import wt from"fs-extra";import b from"picocolors";async function bt(){try{return(await k`turso --version`).exitCode===0}catch{return!1}}async function yt(){try{return!(await k`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function Pt(){let e=W();try{return e.start("Logging in to Turso..."),await k`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(b.red("Failed to log in to Turso")),a}}async function kt(e){let a=W();try{if(a.start("Installing Turso CLI..."),e)await k`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await k`curl -sSfL https://get.tur.so/install.sh`;await k`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(),I.warn(b.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(b.red("Failed to install Turso CLI")),t)}}async function jt(){try{let{stdout:e}=await k`turso group list`,a=e.trim().split(`
72
- `);return a.length<=1?[]:a.slice(1).map(o=>{let[r,s,i,n]=o.trim().split(/\s{2,}/);return{name:r,locations:s,version:i,status:n}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function vt(){let e=await jt();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 ht({message:"Select a Turso database group:",options:a});return H(t)&&(V(b.red("Operation cancelled")),process.exit(0)),t}async function xt(e,a){try{a?await k`turso db create ${e} --group ${a}`:await k`turso db create ${e}`}catch(r){throw r instanceof Error&&r.message.includes("already exists")?new Error("DATABASE_EXISTS"):r}let{stdout:t}=await k`turso db show ${e} --url`,{stdout:o}=await k`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:o.trim()}}async function z(e,a){let t=pe.join(e,"apps/server",".env"),o=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
71
+ - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),r}import he from"node:path";import{log as At,spinner as Lt}from"@clack/prompts";import Nt from"fs-extra";import ge from"picocolors";import jt from"node:os";import me from"node:path";import{cancel as Q,confirm as xt,isCancel as K,log as A,select as Tt,spinner as X,text as Et}from"@clack/prompts";import{$ as T}from"execa";import $t from"fs-extra";import j from"picocolors";async function Ft(){try{return(await T`turso --version`).exitCode===0}catch{return!1}}async function Ct(){try{return!(await T`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function Ot(){let e=X();try{return e.start("Logging in to Turso..."),await T`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(j.red("Failed to log in to Turso")),a}}async function St(e){let a=X();try{if(a.start("Installing Turso CLI..."),e)await T`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await T`curl -sSfL https://get.tur.so/install.sh`;await T`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(),A.warn(j.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(j.red("Failed to install Turso CLI")),t)}}async function Dt(){try{let{stdout:e}=await T`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 Rt(){let e=await Dt();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 Tt({message:"Select a Turso database group:",options:a});return K(t)&&(Q(j.red("Operation cancelled")),process.exit(0)),t}async function It(e,a){try{a?await T`turso db create ${e} --group ${a}`:await T`turso db create ${e}`}catch(r){throw r instanceof Error&&r.message.includes("already exists")?new Error("DATABASE_EXISTS"):r}let{stdout:t}=await T`turso db show ${e} --url`,{stdout:o}=await T`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:o.trim()}}async function _(e,a){let t=me.join(e,"apps/server",".env"),o=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
73
73
  TURSO_AUTH_TOKEN="${a.authToken}"`:`TURSO_CONNECTION_URL=
74
- TURSO_AUTH_TOKEN=`;await wt.writeFile(t,o)}function U(){I.info(`Manual Turso Setup Instructions:
74
+ TURSO_AUTH_TOKEN=`;await $t.writeFile(t,o)}function G(){A.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,65 +79,71 @@ TURSO_AUTH_TOKEN=`;await wt.writeFile(t,o)}function U(){I.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 le(e,a){if(!a){await z(e),I.info(b.blue("Skipping Turso setup. Setting up empty configuration.")),U();return}let t=mt.platform(),o=t==="darwin";if(!(t!=="win32")){I.warn(b.yellow("Automatic Turso setup is not supported on Windows.")),await z(e),U();return}try{if(!await bt()){let T=await ft({message:"Would you like to install Turso CLI?",initialValue:!0});if(H(T)&&(V(b.red("Operation cancelled")),process.exit(0)),!T){await z(e),U();return}await kt(o)}await yt()||await Pt();let n=await vt(),d=!1,P="",w=pe.basename(e);for(;!d;){let T=await gt({message:"Enter a name for your database:",defaultValue:w,initialValue:w,placeholder:w});H(T)&&(V(b.red("Operation cancelled")),process.exit(0)),P=T;let O=W();try{O.start(`Creating Turso database "${P}"${n?` in group "${n}"`:""}...`);let F=await xt(P,n);await z(e,F),O.stop("Turso database configured successfully!"),d=!0}catch(F){if(F instanceof Error&&F.message==="DATABASE_EXISTS")O.stop(b.yellow(`Database "${b.red(P)}" already exists`)),w=`${P}-${Math.floor(Math.random()*1e3)}`;else throw O.stop(b.red("Failed to create Turso database")),F}}}catch(s){I.error(b.red(`Error during Turso setup: ${s}`)),await z(e),U(),I.success("Setup completed with manual configuration required.")}}async function me(e,a,t,o=!0){let r=$t(),s=ue.join(e,"apps/server");if(a==="none"){await Et.remove(ue.join(s,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?f({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:s}):t==="prisma"&&f({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:s}),o&&await le(e,!0)):a==="postgres"&&(t==="drizzle"?f({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:s}):t==="prisma"&&f({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:s}))}catch(i){throw r.stop(de.red("Failed to set up database")),i instanceof Error&&Tt.error(de.red(i.message)),i}}import _ from"node:path";import D from"fs-extra";async function fe(e,a){let t=_.join(e,"apps/server"),o=_.join(e,"apps/client"),r=_.join(t,".env"),s="";if(await D.pathExists(r)&&(s=await D.readFile(r,"utf8")),s.includes("CORS_ORIGIN")||(s+=`
83
- CORS_ORIGIN=http://localhost:3001`),a.auth&&(s.includes("BETTER_AUTH_SECRET")||(s+=`
84
- BETTER_AUTH_SECRET=${ie()}`),s.includes("BETTER_AUTH_URL")||(s+=`
85
- BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!s.includes("DATABASE_URL")){let d=a.database==="sqlite"?"":`
86
- DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;s+=d}a.database==="sqlite"&&!a.turso&&(s.includes("TURSO_CONNECTION_URL")||(s+=`
87
- TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}await D.writeFile(r,s.trim());let i=_.join(o,".env"),n="";await D.pathExists(i)&&(n=await D.readFile(i,"utf8")),n.includes("VITE_SERVER_URL")||(n+=`VITE_SERVER_URL=http://localhost:3000
88
- `),await D.writeFile(i,n.trim())}import j from"node:path";import m from"fs-extra";async function he(e,a,t,o){a.includes("todo")?await Ct(e,t,o):await Ot(e,t)}async function Ct(e,a,t){let o=j.join(g,"template/examples/todo");if(await m.pathExists(o)){let r=j.join(o,"apps/client/src/routes"),s=j.join(e,"apps/client/src/routes");if(await m.copy(r,s,{overwrite:!0}),a!=="none"){let i=j.join(o,`apps/server/src/routers/with-${a}-todo.ts`),n=j.join(e,"apps/server/src/routers/todo.ts");await m.pathExists(i)&&await m.copy(i,n,{overwrite:!0})}await St(e,t),await Rt(e)}}async function St(e,a){let t=j.join(e,"apps/client/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 = [
82
+ TURSO_AUTH_TOKEN=your_auth_token`)}async function fe(e,a){if(!a){await _(e),A.info(j.blue("Skipping Turso setup. Setting up empty configuration.")),G();return}let t=jt.platform(),o=t==="darwin";if(!(t!=="win32")){A.warn(j.yellow("Automatic Turso setup is not supported on Windows.")),await _(e),G();return}try{if(!await Ft()){let P=await xt({message:"Would you like to install Turso CLI?",initialValue:!0});if(K(P)&&(Q(j.red("Operation cancelled")),process.exit(0)),!P){await _(e),G();return}await St(o)}await Ct()||await Ot();let s=await Rt(),m=!1,h="",b=me.basename(e);for(;!m;){let P=await Et({message:"Enter a name for your database:",defaultValue:b,initialValue:b,placeholder:b});K(P)&&(Q(j.red("Operation cancelled")),process.exit(0)),h=P;let C=X();try{C.start(`Creating Turso database "${h}"${s?` in group "${s}"`:""}...`);let v=await It(h,s);await _(e,v),C.stop("Turso database configured successfully!"),m=!0}catch(v){if(v instanceof Error&&v.message==="DATABASE_EXISTS")C.stop(j.yellow(`Database "${j.red(h)}" already exists`)),b=`${h}-${Math.floor(Math.random()*1e3)}`;else throw C.stop(j.red("Failed to create Turso database")),v}}}catch(n){A.error(j.red(`Error during Turso setup: ${n}`)),await _(e),G(),A.success("Setup completed with manual configuration required.")}}async function we(e,a,t,o=!0){let r=Lt(),n=he.join(e,"apps/server");if(a==="none"){await Nt.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&&At.error(ge.red(i.message)),i}}import L from"node:path";import O from"fs-extra";async function be(e,a){let t=L.join(e,"apps/server"),o=L.join(t,".env"),r="";if(await O.pathExists(o)&&(r=await O.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(await O.writeFile(o,r.trim()),a.frontend.includes("web")){let n=L.join(e,"apps/web"),i=L.join(n,".env"),s="";await O.pathExists(i)&&(s=await O.readFile(i,"utf8")),s.includes("VITE_SERVER_URL")||(s+=`VITE_SERVER_URL=http://localhost:3000
88
+ `),await O.writeFile(i,s.trim())}if(a.frontend.includes("native")){let n=L.join(e,"apps/native"),i=L.join(n,".env"),s="";await O.pathExists(i)&&(s=await O.readFile(i,"utf8")),s.includes("EXPO_PUBLIC_SERVER_URL")||(s+=`EXPO_PUBLIC_SERVER_URL=http://localhost:3000
89
+ `),await O.writeFile(i,s.trim())}}import E from"node:path";import w from"fs-extra";async function ye(e,a,t,o){a.includes("todo")?await _t(e,t,o):await zt(e,t)}async function _t(e,a,t){let o=E.join(y,"template/examples/todo");if(await w.pathExists(o)){let r=E.join(o,"apps/web/src/routes"),n=E.join(e,"apps/web/src/routes");if(await w.copy(r,n,{overwrite:!0}),a!=="none"){let i=E.join(o,`apps/server/src/routers/with-${a}-todo.ts`),s=E.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(i)&&await w.copy(i,s,{overwrite:!0})}await Ut(e,t),await Mt(e)}}async function Ut(e,a){let t=E.join(e,"apps/web/src/components/header.tsx");if(await w.pathExists(t)){let o=await w.readFile(t,"utf8");a?o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
89
90
  { to: "/", label: "Home" },
90
91
  { to: "/dashboard", label: "Dashboard" },
91
92
  { to: "/todos", label: "Todos" },`):o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
92
93
  { to: "/", label: "Home" },
93
- { to: "/todos", label: "Todos" },`),await m.writeFile(t,o)}}async function Ot(e,a){if(a==="drizzle"){let o=j.join(e,"apps/server/src/db/schema/todo.ts");await m.pathExists(o)&&await m.remove(o)}else if(a==="prisma"){let o=j.join(e,"apps/server/prisma/schema/todo.prisma");await m.pathExists(o)&&await m.remove(o)}let t=j.join(e,"apps/server/src/routers/todo.ts");await m.pathExists(t)&&await m.remove(t),await At(e)}async function At(e){let a=j.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 Rt(e){let a=j.join(e,"apps/client/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">
94
+ { to: "/todos", label: "Todos" },`),await w.writeFile(t,o)}}async function zt(e,a){if(a==="drizzle"){let o=E.join(e,"apps/server/src/db/schema/todo.ts");await w.pathExists(o)&&await w.remove(o)}else if(a==="prisma"){let o=E.join(e,"apps/server/prisma/schema/todo.prisma");await w.pathExists(o)&&await w.remove(o)}let t=E.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(t)&&await w.remove(t),await Bt(e)}async function Bt(e){let a=E.join(e,"apps/server/src/routers/index.ts");if(await w.pathExists(a)){let t=await w.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await w.writeFile(a,t)}}async function Mt(e){let a=E.join(e,"apps/web/src/routes/index.tsx");if(await w.pathExists(a)){let t=await w.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">
94
95
  <Button asChild>
95
96
  <Link to="/todos" className="flex items-center">
96
97
  View Todo Demo
97
98
  <ArrowRight className="ml-1 h-4 w-4" />
98
99
  </Link>
99
100
  </Button>
100
- </div>`),await m.writeFile(a,t)}}import{log as It}from"@clack/prompts";import l from"picocolors";function ge(e,a,t,o,r,s,i){let n=t==="npm"?"npm run":t,d=`cd ${a}`,P=s?.includes("husky")||s?.includes("biome"),w=e!=="none"?Ft(e,r,n,i):"",T=s?.includes("tauri")?zt(n):"",O=P?Dt(n):"";It.info(`${l.cyan("Project created successfully!")}
101
-
102
- ${l.bold("Next steps:")}
103
- ${l.cyan("1.")} ${d}
104
- ${o?"":`${l.cyan("2.")} ${t} install
105
- `}${l.cyan(o?"2.":"3.")} ${n} dev
106
-
107
- ${l.bold("Your project will be available at:")}
108
- ${l.cyan("\u2022")} Frontend: http://localhost:3001
109
- ${l.cyan("\u2022")} API: http://localhost:3000
110
- ${w?`
111
- ${w.trim()}`:""}${T?`
112
- ${T.trim()}`:""}${O?`
113
- ${O.trim()}`:""}`)}function Dt(e){return`${l.bold("Linting and formatting:")}
114
- ${l.cyan("\u2022")} Format and lint fix: ${l.dim(`${e} check`)}
115
-
116
- `}function Ft(e,a,t,o){let r=[];return a==="prisma"?(e==="sqlite"&&r.push(`${l.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,`${l.dim("Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso")}`),o==="bun"&&r.push(`${l.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors, follow the guidance provided in the error messages`),r.push(`${l.cyan("\u2022")} Apply schema: ${l.dim(`${t} db:push`)}`),r.push(`${l.cyan("\u2022")} Database UI: ${l.dim(`${t} db:studio`)}`)):a==="drizzle"&&(e==="sqlite"&&r.push(`${l.cyan("\u2022")} Start local DB: ${l.dim(`cd apps/server && ${t} db:local`)}`),r.push(`${l.cyan("\u2022")} Apply schema: ${l.dim(`${t} db:push`)}`),r.push(`${l.cyan("\u2022")} Database UI: ${l.dim(`${t} db:studio`)}`)),r.length?`${l.bold("Database commands:")}
101
+ </div>`),await w.writeFile(a,t)}}import{log as Gt}from"@clack/prompts";import d from"picocolors";function ke(e,a,t,o,r,n,i,s){let m=t==="npm"?"npm run":t,h=`cd ${a}`,b=n?.includes("husky")||n?.includes("biome"),P=e!=="none"?Vt(e,r,m,i):"",C=n?.includes("tauri")?Wt(m):"",v=b?qt(m):"",z=s?.includes("native")?Jt():"",N=s?.includes("web"),rt=s?.includes("native"),nt=N||rt;Gt.info(`${d.bold("Next steps:")}
102
+ ${d.cyan("1.")} ${h}
103
+ ${o?"":`${d.cyan("2.")} ${t} install
104
+ `}${d.cyan(o?"2.":"3.")} ${m} dev
105
+
106
+ ${d.bold("Your project will be available at:")}
107
+ ${nt?`${N?`${d.cyan("\u2022")} Frontend: http://localhost:3001
108
+ `:""}`:`${d.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
109
+ `}${d.cyan("\u2022")} API: http://localhost:3000
110
+ ${z?`
111
+ ${z.trim()}`:""}${P?`
112
+ ${P.trim()}`:""}${C?`
113
+ ${C.trim()}`:""}${v?`
114
+ ${v.trim()}`:""}`)}function Jt(){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:
115
+ ${d.dim("EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000")}
116
+ `}function qt(e){return`${d.bold("Linting and formatting:")}
117
+ ${d.cyan("\u2022")} Format and lint fix: ${d.dim(`${e} check`)}
118
+
119
+ `}function Vt(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:")}
117
120
  ${r.join(`
118
121
  `)}
119
122
 
120
- `:""}function zt(e){return`${l.bold("Desktop app with Tauri:")}
121
- ${l.cyan("\u2022")} Start desktop app: ${l.dim(`cd apps/client && ${e} desktop:dev`)}
122
- ${l.cyan("\u2022")} Build desktop app: ${l.dim(`cd apps/client && ${e} desktop:build`)}
123
- ${l.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: ${l.dim("https://v2.tauri.app/start/prerequisites/")}
123
+ `:""}function Wt(e){return`${d.bold("Desktop app with Tauri:")}
124
+ ${d.cyan("\u2022")} Start desktop app: ${d.dim(`cd apps/web && ${e} desktop:dev`)}
125
+ ${d.cyan("\u2022")} Build desktop app: ${d.dim(`cd apps/web && ${e} desktop:build`)}
126
+ ${d.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: ${d.dim("https://v2.tauri.app/start/prerequisites/")}
124
127
 
125
- `}import M from"node:path";import{$ as Lt,execa as Nt}from"execa";import C from"fs-extra";async function we(e,a){await Ut(e,a),await _t(e,a)}async function Ut(e,a){let t=M.join(e,"package.json");if(await C.pathExists(t)){let o=await C.readJson(t);o.name=a.projectName;let{stdout:r}=await Nt(a.packageManager,["-v"],{cwd:e});if(o.packageManager=`${a.packageManager}@${r.trim()}`,await C.writeJson(t,o,{spaces:2}),a.packageManager==="pnpm"){let s=M.join(g,"template/with-pnpm/pnpm-workspace.yaml"),i=M.join(e,"pnpm-workspace.yaml");await C.pathExists(s)&&await C.copy(s,i)}}}async function _t(e,a){let t=M.join(e,"apps/server/package.json");if(await C.pathExists(t)){let o=await C.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 C.writeJson(t,o,{spaces:2})}}async function be(e,a){a&&await Lt({cwd:e})`git init`}import B from"node:path";import S from"fs-extra";async function ye(e,a){let t=B.join(e,"apps/server"),o=B.join(t,"src/index.ts"),r=await S.readFile(o,"utf-8");a==="bun"?await Mt(t,o,r):a==="node"&&await Bt(t,o,r)}async function Mt(e,a,t){let o=B.join(e,"package.json"),r=await S.readJson(o);if(r.scripts={...r.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await S.writeJson(o,r,{spaces:2}),f({devDependencies:["@types/bun"],projectDir:e}),!t.includes("export default app")){let s=`${t}
128
+ `}import J from"node:path";import{$ as Ht,execa as Qt}from"execa";import S from"fs-extra";async function Pe(e,a){await Kt(e,a),await Xt(e,a)}async function Kt(e,a){let t=J.join(e,"package.json");if(await S.pathExists(t)){let o=await S.readJson(t);o.name=a.projectName;let{stdout:r}=await Qt(a.packageManager,["-v"],{cwd:e});if(o.packageManager=`${a.packageManager}@${r.trim()}`,await S.writeJson(t,o,{spaces:2}),a.packageManager==="pnpm"){let n=J.join(y,"template/with-pnpm/pnpm-workspace.yaml"),i=J.join(e,"pnpm-workspace.yaml");await S.pathExists(n)&&await S.copy(n,i)}}}async function Xt(e,a){let t=J.join(e,"apps/server/package.json");if(await S.pathExists(t)){let o=await S.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 S.writeJson(t,o,{spaces:2})}}async function ve(e,a){a&&await Ht({cwd:e})`git init`}import q from"node:path";import D from"fs-extra";async function je(e,a,t){let o=q.join(e,"apps/server"),r=q.join(o,"src/index.ts"),n=await D.readFile(r,"utf-8");a==="bun"?await Yt(o,r,n,t):a==="node"&&await Zt(o,r,n,t)}async function Yt(e,a,t,o){let r=q.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}
126
129
 
127
130
  export default app;
128
- `;await S.writeFile(a,s)}}async function Bt(e,a,t){f({dependencies:["@hono/node-server"],devDependencies:["tsx","@types/node"],projectDir:e});let o=B.join(e,"package.json"),r=await S.readJson(o);r.scripts={...r.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await S.writeJson(o,r,{spaces:2});let s=`import { serve } from "@hono/node-server";
129
- `,i=`
131
+ `;await D.writeFile(a,i)}}async function Zt(e,a,t,o){let r=q.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";
132
+ `,s=`
130
133
  serve(
131
- {
132
- fetch: app.fetch,
133
- port: 3000,
134
- },
135
- (info) => {
136
- console.log(\`Server is running on http://localhost:\${info.port}\`);
137
- },
134
+ {
135
+ fetch: app.fetch,
136
+ port: 3000,
137
+ },
138
+ (info) => {
139
+ console.log(\`Server is running on http://localhost:\${info.port}\`);
140
+ },
138
141
  );
139
- `;if(t.includes("@hono/node-server")){if(!t.includes("serve(")){let n=t+i;await S.writeFile(a,n)}}else{let n=t.lastIndexOf("import"),d=t.substring(0,n),P=t.substring(n),w=d+s+P+i;await S.writeFile(a,w)}}import v from"node:path";import y from"fs-extra";async function Pe(e){let a=v.join(g,"template/base");if(!await y.pathExists(a))throw new Error(`Template directory not found: ${a}`);await y.copy(a,e)}async function ke(e,a){if(!a)return;let t=v.join(g,"template/with-auth");await y.pathExists(t)&&await y.copy(t,e,{overwrite:!0})}async function je(e,a,t,o){if(a==="none"||t==="none")return;let r=v.join(g,Jt(a,t));if(await y.pathExists(r)){await y.copy(r,e,{overwrite:!0});let s=v.join(e,"apps/server/src"),i=v.join(s,"lib"),n=v.join(s,"with-auth-lib");o?await y.pathExists(n)&&(await y.remove(i),await y.move(n,i)):await y.remove(n)}}async function ve(e){let a=[v.join(e,"_gitignore"),v.join(e,"apps/client/_gitignore"),v.join(e,"apps/server/_gitignore")];for(let t of a)if(await y.pathExists(t)){let o=v.join(v.dirname(t),".gitignore");await y.move(t,o)}}function Jt(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"}async function Te(e){let a=Vt(),t=Gt.resolve(process.cwd(),e.projectName);try{return await Ht.ensureDir(t),await Pe(t),await ve(t),await ke(t,e.auth),await je(t,e.orm,e.database,e.auth),await ye(t,e.runtime),await he(t,e.examples,e.orm,e.auth),await me(t,e.database,e.orm,e.turso??e.database==="sqlite"),await ne(t,e.auth),await fe(t,e),await be(t,e.git),e.addons.length>0&&await ae(t,e.addons,e.packageManager),await we(t,e),await ce(t,e),ge(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime),t}catch(o){throw a.message(xe.red("Failed")),o instanceof Error&&(qt(xe.red(`Error during project creation: ${o.message}`)),process.exit(1)),o}}import{log as $e,spinner as Ee}from"@clack/prompts";import{$ as Q}from"execa";import J from"picocolors";async function Ce({projectDir:e,packageManager:a,addons:t=[]}){let o=Ee();try{switch(o.start(`Running ${a} install...`),a){case"npm":await Q({cwd:e,stderr:"inherit"})`${a} install`;break;case"pnpm":case"bun":await Q({cwd:e})`${a} install`;break}o.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await Wt(e,a)}catch(r){throw o.stop(J.red("Failed to install dependencies")),r instanceof Error&&$e.error(J.red(`Installation error: ${r.message}`)),r}}async function Wt(e,a){let t=Ee();try{t.start("Running Biome format check..."),await Q({cwd:e})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(J.yellow("Biome check encountered issues")),$e.warn(J.yellow("Some files may need manual formatting"))}}import{cancel as _a,group as Ma}from"@clack/prompts";import Ba from"picocolors";import{cancel as Qt,isCancel as Kt,multiselect as Xt}from"@clack/prompts";import Yt from"picocolors";async function Se(e){if(e!==void 0)return e;let a=await Xt({message:"Which Addons would you like to add?",options:[{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"},{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)"}],required:!1});return Kt(a)&&(Qt(Yt.red("Operation cancelled")),process.exit(0)),a.includes("husky")&&!a.includes("biome")&&a.push("biome"),a}import{cancel as Zt,confirm as ea,isCancel as ta}from"@clack/prompts";import aa from"picocolors";async function Oe(e,a){if(!a)return!1;if(e!==void 0)return e;let t=await ea({message:"Would you like to add authentication with Better-Auth?",initialValue:u.auth});return ta(t)&&(Zt(aa.red("Operation cancelled")),process.exit(0)),t}async function Ae(e){return e!==void 0?e:"hono"}import{cancel as oa,isCancel as ra,select as sa}from"@clack/prompts";import ia from"picocolors";async function Re(e){if(e!==void 0)return e;let a=await sa({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:"sqlite"});return ra(a)&&(oa(ia.red("Operation cancelled")),process.exit(0)),a}import{cancel as na,isCancel as ca,multiselect as pa}from"@clack/prompts";import la from"picocolors";async function Ie(e,a){if(e!==void 0)return e;if(a==="none")return[];let t=await pa({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});return ca(t)&&(na(la.red("Operation cancelled")),process.exit(0)),t}import{cancel as ua,confirm as da,isCancel as ma}from"@clack/prompts";import fa from"picocolors";async function De(e){if(e!==void 0)return e;let a=await da({message:"Initialize a new git repository?",initialValue:u.git});return ma(a)&&(ua(fa.red("Operation cancelled")),process.exit(0)),a}import{cancel as ha,confirm as ga,isCancel as wa}from"@clack/prompts";import ba from"picocolors";async function Fe(e){if(e!==void 0)return e;let a=await ga({message:"Do you want to install project dependencies?",initialValue:!u.noInstall});return wa(a)&&(ha(ba.red("Operation cancelled")),process.exit(0)),!a}import{cancel as ya,isCancel as Pa,select as ka}from"@clack/prompts";import ja from"picocolors";async function ze(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await ka({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 with schema migrations"}],initialValue:"drizzle"});return Pa(t)&&(ya(ja.red("Operation cancelled")),process.exit(0)),t}import{cancel as va,isCancel as xa,select as Ta}from"@clack/prompts";import $a from"picocolors";var Le=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};async function Ne(e){if(e!==void 0)return e;let a=Le(),t=await Ta({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 xa(t)&&(va($a.red("Operation cancelled")),process.exit(0)),t}import L from"node:path";import{cancel as Ea,isCancel as Ca,text as Sa}from"@clack/prompts";import R from"fs-extra";import Oa from"picocolors";var Aa=["<",">",":",'"',"|","?","*"],Ue=255;function _e(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Ue)return`Project name must be less than ${Ue} characters`;if(Aa.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 Me(e){if(e)if(e==="."){let s=process.cwd();if(R.readdirSync(s).length===0)return e}else{let s=L.basename(e);if(!_e(s)){let n=L.resolve(process.cwd(),e);if(!R.pathExistsSync(n)||R.readdirSync(n).length===0)return e}}let a=!1,t="",o=u.projectName,r=1;for(;R.pathExistsSync(L.resolve(process.cwd(),o));)o=`${u.projectName}-${r}`,r++;for(;!a;){let s=await Sa({message:"Enter your project name or path (relative to current directory)",placeholder:o,initialValue:e,defaultValue:o,validate:i=>{let n=i.trim()||o;if(n==="."){if(R.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let d=L.resolve(process.cwd(),n),P=L.basename(d),w=_e(P);if(w)return w;if(!d.startsWith(process.cwd()))return"Project path must be within current directory";if(R.pathExistsSync(d)&&R.readdirSync(d).length>0)return`Directory "${n}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Ca(s)&&(Ea(Oa.red("Operation cancelled.")),process.exit(0)),t=s||o}return t}import{cancel as Ra,isCancel as Ia,select as Da}from"@clack/prompts";import Fa from"picocolors";async function Be(e){if(e!==void 0)return e;let a=await Da({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:"bun"});return Ia(a)&&(Ra(Fa.red("Operation cancelled")),process.exit(0)),a}import{cancel as za,confirm as La,isCancel as Na}from"@clack/prompts";import Ua from"picocolors";async function Je(e){if(e!==void 0)return e;let a=await La({message:"Set up a Turso database for this project?",initialValue:!0});return Na(a)&&(za(Ua.red("Operation cancelled")),process.exit(0)),a}async function Ge(e){let a=await Ma({projectName:async()=>Me(e.projectName),runtime:()=>Be(e.runtime),backendFramework:()=>Ae(e.backendFramework),database:()=>Re(e.database),orm:({results:t})=>ze(e.orm,t.database!=="none"),auth:({results:t})=>Oe(e.auth,t.database!=="none"),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Je(e.turso):Promise.resolve(!1),addons:()=>Se(e.addons),examples:({results:t})=>Ie(e.examples,t.database),git:()=>De(e.git),packageManager:()=>Ne(e.packageManager),noInstall:()=>Fe(e.noInstall)},{onCancel:()=>{_a(Ba.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,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,backendFramework:a.backendFramework,runtime:a.runtime}}import $ from"picocolors";function K(e){let a=[];return e.projectName&&a.push(`${$.blue("Project Name:")} ${e.projectName}`),e.database&&a.push(`${$.blue("Database:")} ${e.database}`),e.orm&&a.push(`${$.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${$.blue("Authentication:")} ${e.auth}`),e.runtime&&a.push(`${$.blue("Runtime:")} ${e.runtime}`),e.addons?.length&&a.push(`${$.blue("Addons:")} ${e.addons.join(", ")}`),e.git!==void 0&&a.push(`${$.blue("Git Init:")} ${e.git}`),e.packageManager&&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(`
140
- `)}function qe(e){let a=[];if(e.database==="none"?a.push("--no-database"):e.database==="sqlite"?a.push("--sqlite"):e.database==="postgres"&&a.push("--postgres"),e.database!=="none"&&(e.orm==="drizzle"?a.push("--drizzle"):e.orm==="prisma"&&a.push("--prisma")),e.auth?a.push("--auth"):a.push("--no-auth"),e.git?a.push("--git"):a.push("--no-git"),e.noInstall?a.push("--no-install"):a.push("--install"),e.packageManager&&a.push(`--${e.packageManager}`),e.addons.length>0)for(let s of e.addons)a.push(`--${s}`);else a.push("--no-addons");e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(",")}`):a.push("--no-examples"),e.database==="sqlite"&&(e.turso?a.push("--turso"):a.push("--no-turso")),e.runtime&&a.push(`--runtime ${e.runtime}`);let t="npx create-better-t-stack",o=e.projectName?` ${e.projectName}`:"",r=a.length>0?` ${a.join(" ")}`:"";return`${t}${o}${r}`}import Ja from"node:path";import Ga from"fs-extra";var Ve=()=>{let e=Ja.join(g,"package.json");return Ga.readJSONSync(e).version??"1.0.0"};import He from"gradient-string";var We=`
142
+ `;if(!t.includes("@hono/node-server")){let m=t.lastIndexOf("import"),h=t.substring(0,m),b=t.substring(m),P=h+i+b+s;await D.writeFile(a,P)}}else if(o==="elysia"&&(g({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let i=`import { node } from "@elysiajs/node";
143
+ `,s=t.indexOf(`
144
+ `,t.indexOf("import")),m=t.substring(0,s+1),h=t.substring(s+1),b=m+i+h;b=b.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await D.writeFile(a,b)}}import u from"node:path";import f from"fs-extra";async function xe(e){let a=u.join(y,"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=u.join(e,"apps/web");await f.pathExists(t)&&await f.remove(t)}if(a.includes("native"))await f.writeFile(u.join(e,".npmrc"),`node-linker=hoisted
145
+ `);else{let t=u.join(e,"apps/native");await f.pathExists(t)&&await f.remove(t)}}async function Ee(e,a){let t=u.join(y,`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=u.join(y,ea(a,t));if(await f.pathExists(r)&&(await f.copy(r,e,{overwrite:!0}),!o)){if(a==="prisma"){let n=u.join(e,"apps/server/prisma/schema/auth.prisma");await f.pathExists(n)&&await f.remove(n)}else if(a==="drizzle"){let n=u.join(e,"apps/server/src/db/schema/auth.ts");await f.pathExists(n)&&await f.remove(n)}}}async function Fe(e,a,t,o,r){if(!a)return;let n=u.join(y,"template/with-auth");if(await f.pathExists(n)){let i=u.join(n,"apps/web"),s=u.join(e,"apps/web");await f.copy(i,s,{overwrite:!0});let m=u.join(n,"apps/server/src"),h=u.join(e,"apps/server/src");await f.copy(u.join(m,"lib/trpc.ts"),u.join(h,"lib/trpc.ts"),{overwrite:!0}),await f.copy(u.join(m,"routers/index.ts"),u.join(h,"routers/index.ts"),{overwrite:!0});let b=`with-${t}-context.ts`;await f.copy(u.join(m,"lib",b),u.join(h,"lib/context.ts"),{overwrite:!0});let P=`with-${t}-index.ts`;await f.copy(u.join(m,P),u.join(h,"index.ts"),{overwrite:!0});let C=ta(o,r),v=u.join(m,C);if(await f.pathExists(v)){let z=await f.readdir(v);for(let N of z)await f.copy(u.join(v,N),u.join(h,"lib",N),{overwrite:!0})}}}async function Ce(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 f.pathExists(t)){let o=u.join(u.dirname(t),".gitignore");await f.move(t,o)}}function ea(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 ta(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 Se(e){let a=ra(),t=aa.resolve(process.cwd(),e.projectName);try{return await na.ensureDir(t),await xe(t),await Te(t,e.frontend),await Ce(t),await Ee(t,e.backendFramework),await de(t,e.backendFramework,e.runtime),await $e(t,e.orm,e.database,e.auth),await we(t,e.database,e.orm,e.turso??e.database==="sqlite"),await Fe(t,e.auth,e.backendFramework,e.orm,e.database),await le(t,e.auth),await je(t,e.runtime,e.backendFramework),await ye(t,e.examples,e.orm,e.auth),await be(t,e),await ve(t,e.git),e.addons.length>0&&await ne(t,e.addons,e.packageManager),await Pe(t,e),await ue(t,e),ke(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(o){throw a.message(Oe.red("Failed")),o instanceof Error&&(oa(Oe.red(`Error during project creation: ${o.message}`)),process.exit(1)),o}}import{log as De,spinner as Re}from"@clack/prompts";import{$ as Y}from"execa";import V from"picocolors";async function Ie({projectDir:e,packageManager:a,addons:t=[]}){let o=Re();try{switch(o.start(`Running ${a} install...`),a){case"npm":await Y({cwd:e,stderr:"inherit"})`${a} install`;break;case"pnpm":case"bun":await Y({cwd:e})`${a} install`;break}o.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await ia(e,a)}catch(r){throw o.stop(V.red("Failed to install dependencies")),r instanceof Error&&De.error(V.red(`Installation error: ${r.message}`)),r}}async function ia(e,a){let t=Re();try{t.start("Running Biome format check..."),await Y({cwd:e})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(V.yellow("Biome check encountered issues")),De.warn(V.yellow("Some files may need manual formatting"))}}import{cancel as io,group as so}from"@clack/prompts";import co from"picocolors";import{cancel as sa,isCancel as ca,multiselect as pa}from"@clack/prompts";import la from"picocolors";async function Ae(e){if(e!==void 0)return e;let a=await pa({message:"Which Addons would you like to add?",options:[{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"},{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)"}],initialValues:c.addons,required:!1});return ca(a)&&(sa(la.red("Operation cancelled")),process.exit(0)),a.includes("husky")&&!a.includes("biome")&&a.push("biome"),a}import{cancel as da,confirm as ua,isCancel as ma,log as fa}from"@clack/prompts";import Le from"picocolors";async function Ne(e,a,t){if(!a)return!1;let o=t?.includes("native"),r=t?.includes("web");if(o&&fa.warn(Le.yellow("Note: Authentication is not yet available with native")),!r)return!1;if(e!==void 0)return e;let n=await ua({message:"Would you like to add authentication with Better-Auth?",initialValue:c.auth});return ma(n)&&(da(Le.red("Operation cancelled")),process.exit(0)),n}import{cancel as ha,isCancel as ga,select as wa}from"@clack/prompts";import ba from"picocolors";async function _e(e){if(e!==void 0)return e;let a=await wa({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:c.backendFramework});return ga(a)&&(ha(ba.red("Operation cancelled")),process.exit(0)),a}import{cancel as ya,isCancel as ka,select as Pa}from"@clack/prompts";import va from"picocolors";async function Ue(e){if(e!==void 0)return e;let a=await Pa({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:c.database});return ka(a)&&(ya(va.red("Operation cancelled")),process.exit(0)),a}import{cancel as ja,isCancel as xa,multiselect as Ta}from"@clack/prompts";import Ea from"picocolors";async function ze(e,a){if(e!==void 0)return e;if(a==="none")return[];let t=await Ta({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:c.examples});return xa(t)&&(ja(Ea.red("Operation cancelled")),process.exit(0)),t}import{cancel as $a,isCancel as Fa,multiselect as Ca}from"@clack/prompts";import Oa from"picocolors";async function Be(e){if(e!==void 0)return e;let a=await Ca({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:c.frontend,required:!1});return Fa(a)&&($a(Oa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Sa,confirm as Da,isCancel as Ra}from"@clack/prompts";import Ia from"picocolors";async function Me(e){if(e!==void 0)return e;let a=await Da({message:"Initialize a new git repository?",initialValue:c.git});return Ra(a)&&(Sa(Ia.red("Operation cancelled")),process.exit(0)),a}import{cancel as Aa,confirm as La,isCancel as Na}from"@clack/prompts";import _a from"picocolors";async function Ge(e){if(e!==void 0)return e;let a=await La({message:"Do you want to install project dependencies?",initialValue:!c.noInstall});return Na(a)&&(Aa(_a.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Ua,isCancel as za,select as Ba}from"@clack/prompts";import Ma from"picocolors";async function Je(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Ba({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:c.orm});return za(t)&&(Ua(Ma.red("Operation cancelled")),process.exit(0)),t}import{cancel as Ga,isCancel as Ja,select as qa}from"@clack/prompts";import Va from"picocolors";async function qe(e){if(e!==void 0)return e;let a=B(),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 Ja(t)&&(Ga(Va.red("Operation cancelled")),process.exit(0)),t}import U from"node:path";import{cancel as Wa,isCancel as Ha,text as Qa}from"@clack/prompts";import I from"fs-extra";import Ka from"picocolors";var Xa=["<",">",":",'"',"|","?","*"],Ve=255;function We(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Ve)return`Project name must be less than ${Ve} characters`;if(Xa.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 He(e){if(e)if(e==="."){let n=process.cwd();if(I.readdirSync(n).length===0)return e}else{let n=U.basename(e);if(!We(n)){let s=U.resolve(process.cwd(),e);if(!I.pathExistsSync(s)||I.readdirSync(s).length===0)return e}}let a=!1,t="",o=c.projectName,r=1;for(;I.pathExistsSync(U.resolve(process.cwd(),o));)o=`${c.projectName}-${r}`,r++;for(;!a;){let n=await Qa({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(I.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let m=U.resolve(process.cwd(),s),h=U.basename(m),b=We(h);if(b)return b;if(!m.startsWith(process.cwd()))return"Project path must be within current directory";if(I.pathExistsSync(m)&&I.readdirSync(m).length>0)return`Directory "${s}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Ha(n)&&(Wa(Ka.red("Operation cancelled.")),process.exit(0)),t=n||o}return t}import{cancel as Ya,isCancel as Za,select as eo}from"@clack/prompts";import to from"picocolors";async function Qe(e){if(e!==void 0)return e;let a=await eo({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:c.runtime});return Za(a)&&(Ya(to.red("Operation cancelled")),process.exit(0)),a}import{cancel as ao,confirm as oo,isCancel as ro}from"@clack/prompts";import no from"picocolors";async function Ke(e){if(e!==void 0)return e;let a=await oo({message:"Set up a Turso database for this project?",initialValue:c.turso});return ro(a)&&(ao(no.red("Operation cancelled")),process.exit(0)),a}async function Xe(e){let a=await so({projectName:async()=>He(e.projectName),frontend:()=>Be(e.frontend),backendFramework:()=>_e(e.backendFramework),runtime:()=>Qe(e.runtime),database:()=>Ue(e.database),orm:({results:t})=>Je(e.orm,t.database!=="none"),auth:({results:t})=>Ne(e.auth,t.database!=="none",t.frontend),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Ke(e.turso):Promise.resolve(!1),addons:()=>Ae(e.addons),examples:({results:t})=>ze(e.examples,t.database),git:()=>Me(e.git),packageManager:()=>qe(e.packageManager),noInstall:()=>Ge(e.noInstall)},{onCancel:()=>{io(co.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,backendFramework:a.backendFramework,runtime:a.runtime}}import x from"picocolors";function Z(e){let a=[];if(e.projectName&&a.push(`${x.blue("Project Name:")} ${e.projectName}`),e.backendFramework!==void 0&&a.push(`${x.blue("Backend Framework:")} ${e.backendFramework}`),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(`
146
+ `)}function Ye(e){let a=[];if(e.database==="none"?a.push("--no-database"):(a.push(`--${e.database}`),e.orm&&a.push(`--${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.packageManager&&a.push(`--${e.packageManager}`),e.backendFramework&&a.push(`--${e.backendFramework}`),e.runtime&&a.push(`--runtime ${e.runtime}`),e.frontend&&(e.frontend.includes("web")?a.push("--web"):a.push("--no-web"),e.frontend.includes("native")?a.push("--native"):a.push("--no-native")),e.addons.length>0)for(let r of e.addons)a.push(`--${r}`);else a.push("--no-addons");e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(",")}`):a.push("--no-examples");let t="npx create-better-t-stack",o=e.projectName?` ${e.projectName}`:"";return`${t}${o} ${a.join(" ")}`}import po from"node:path";import lo from"fs-extra";var Ze=()=>{let e=po.join(y,"package.json");return lo.readJSONSync(e).version??"1.0.0"};import et from"gradient-string";var tt=`
141
147
  \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
142
148
  \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
143
149
  \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
@@ -151,10 +157,10 @@ serve(
151
157
  \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
152
158
  \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
153
159
  \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
154
- `,Qe={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},Ke=()=>{let e=process.stdout.columns||80,a=We.split(`
155
- `),t=Math.max(...a.map(o=>o.length));e<t?console.log(He(Object.values(Qe)).multiline(`
160
+ `,at={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=tt.split(`
161
+ `),t=Math.max(...a.map(o=>o.length));e<t?console.log(et(Object.values(at)).multiline(`
156
162
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
157
163
  \u2551 Better T-Stack \u2551
158
164
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
159
- `)):console.log(He(Object.values(Qe)).multiline(We))};process.on("SIGINT",()=>{x.error(E.red("Operation cancelled")),process.exit(0)});var X=new Qa;async function Ka(){let e=Date.now();X.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Ve()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--no-database","Skip database setup").option("--sqlite","Use SQLite database").option("--postgres","Use PostgreSQL database").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--pwa","Include Progressive Web App support").option("--tauri","Include Tauri desktop app support").option("--biome","Include Biome for linting and formatting").option("--husky","Include Husky, lint-staged for Git hooks").option("--no-addons","Skip all additional addons").option("--examples <examples>","Include specified examples").option("--no-examples","Skip all examples").option("--git","Include git setup").option("--no-git","Skip git initialization").option("--npm","Use npm package manager").option("--pnpm","Use pnpm package manager").option("--bun","Use bun package manager").option("--drizzle","Use Drizzle ORM").option("--prisma","Use Prisma ORM (coming soon)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup for SQLite database").option("--hono","Use Hono backend framework").option("--runtime <runtime>","Specify runtime (bun or node)").parse();let a=Wa();try{Ke(),Va(E.magenta("Creating a new Better-T-Stack project"));let t=X.opts(),o=X.args[0],r={...o&&{projectName:o},...t.database===!1&&{database:"none"},...t.sqlite&&{database:"sqlite"},...t.postgres&&{database:"postgres"},...t.drizzle&&{orm:"drizzle"},...t.prisma&&{orm:"prisma"},..."auth"in t&&{auth:t.auth},...t.npm&&{packageManager:"npm"},...t.pnpm&&{packageManager:"pnpm"},...t.bun&&{packageManager:"bun"},..."git"in t&&{git:t.git},..."install"in t&&{noInstall:!t.install},..."turso"in t&&{turso:t.turso},...t.hono&&{backendFramework:"hono"},...t.runtime&&{runtime:t.runtime},...(t.pwa||t.tauri||t.biome||t.husky||t.addons===!1)&&{addons:t.addons===!1?[]:[...t.pwa?["pwa"]:[],...t.tauri?["tauri"]:[],...t.biome?["biome"]:[],...t.husky?["husky"]:[]]},...(t.examples||t.examples===!1)&&{examples:t.examples===!1?[]:typeof t.examples=="string"?t.examples.split(",").filter(d=>d==="todo"):[]}};!t.yes&&Object.keys(r).length>0&&(x.info(E.yellow("Using these pre-selected options:")),x.message(K(r)),x.message(""));let s=t.yes?{...u,projectName:o??u.projectName,database:t.database===!1?"none":t.database??u.database,orm:t.database===!1?"none":t.drizzle?"drizzle":t.prisma?"prisma":u.orm,auth:t.auth??u.auth,git:t.git??u.git,noInstall:"noInstall"in t?t.noInstall:u.noInstall,packageManager:r.packageManager??u.packageManager,addons:r.addons?.length?r.addons:u.addons,examples:r.examples?.length?r.examples:u.examples,turso:"turso"in t?t.turso:r.database==="sqlite"?u.turso:!1,backendFramework:t.hono?"hono":u.backendFramework,runtime:t.runtime?t.runtime:u.runtime}:await Ge(r);t.yes&&(x.info(E.yellow("Using these default options:")),x.message(K(s)),x.message(""));let i=await Te(s);s.noInstall||await Ce({projectDir:i,packageManager:s.packageManager,addons:s.addons}),x.success(E.blue(`You can reproduce this setup with the following command:
160
- ${E.white(qe(s))}`));let n=((Date.now()-e)/1e3).toFixed(2);Ha(E.magenta(`Project created successfully in ${E.bold(n)} seconds!`))}catch(t){a.stop(E.red("Failed")),t instanceof Error&&(qa(E.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}Ka().catch(e=>{x.error("Aborting installation..."),e instanceof Error?x.error(e.message):(x.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
165
+ `)):console.log(et(Object.values(at)).multiline(tt))};process.on("SIGINT",()=>{$.error(F.red("Operation cancelled")),process.exit(0)});var ee=new go;async function wo(){let e=Date.now();ee.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Ze()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--no-database","Skip database setup").option("--sqlite","Use SQLite database").option("--postgres","Use PostgreSQL database").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--pwa","Include Progressive Web App support").option("--tauri","Include Tauri desktop app support").option("--biome","Include Biome for linting and formatting").option("--husky","Include Husky, lint-staged for Git hooks").option("--no-addons","Skip all additional addons").option("--examples <examples>","Include specified examples").option("--no-examples","Skip all examples").option("--git","Include git setup").option("--no-git","Skip git initialization").option("--npm","Use npm package manager").option("--pnpm","Use pnpm package manager").option("--bun","Use bun package manager").option("--drizzle","Use Drizzle ORM").option("--prisma","Use Prisma ORM (coming soon)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup for SQLite database").option("--hono","Use Hono backend framework").option("--elysia","Use Elysia backend framework").option("--runtime <runtime>","Specify runtime (bun or node)").option("--web","Include web frontend").option("--native","Include Expo frontend").option("--no-web","Exclude web frontend").option("--no-native","Exclude Expo frontend").parse();let a=ho();try{ot(),mo(F.magenta("Creating a new Better-T-Stack project"));let t=ee.opts(),o=ee.args[0],r;t.hono&&(r="hono"),t.elysia&&(r="elysia");let n={...o&&{projectName:o},...t.database===!1&&{database:"none"},...t.sqlite&&{database:"sqlite"},...t.postgres&&{database:"postgres"},...t.drizzle&&{orm:"drizzle"},...t.prisma&&{orm:"prisma"},..."auth"in t&&{auth:t.auth},...t.npm&&{packageManager:"npm"},...t.pnpm&&{packageManager:"pnpm"},...t.bun&&{packageManager:"bun"},..."git"in t&&{git:t.git},..."install"in t&&{noInstall:!t.install},..."turso"in t&&{turso:t.turso},...r&&{backendFramework:r},...t.runtime&&{runtime:t.runtime},...(t.pwa||t.tauri||t.biome||t.husky||t.addons===!1)&&{addons:t.addons===!1?[]:[...t.pwa?["pwa"]:[],...t.tauri?["tauri"]:[],...t.biome?["biome"]:[],...t.husky?["husky"]:[]]},...(t.examples||t.examples===!1)&&{examples:t.examples===!1?[]:typeof t.examples=="string"?t.examples.split(",").filter(h=>h==="todo"):[]},...(t.web!==void 0||t.native!==void 0)&&{frontend:[...t.web===!1?[]:t.web===!0?["web"]:[],...t.native===!1?[]:t.native===!0?["native"]:[]]}};!t.yes&&Object.keys(n).length>0&&($.info(F.yellow("Using these pre-selected options:")),$.message(Z(n)),$.message(""));let i=t.yes?{...c,projectName:o??c.projectName,database:t.database===!1?"none":t.sqlite?"sqlite":t.postgres?"postgres":c.database,orm:t.database===!1?"none":t.drizzle?"drizzle":t.prisma?"prisma":c.orm,auth:"auth"in t?t.auth:c.auth,git:"git"in t?t.git:c.git,noInstall:"install"in t?!t.install:c.noInstall,packageManager:n.packageManager??c.packageManager,addons:n.addons?.length?n.addons:c.addons,examples:n.examples?.length?n.examples:c.examples,turso:"turso"in t?t.turso:n.database==="sqlite"?c.turso:!1,backendFramework:r??c.backendFramework,runtime:t.runtime?t.runtime:c.runtime}:await Xe(n);t.yes&&($.info(F.yellow("Using these default options:")),$.message(Z(i)),$.message(""));let s=await Se(i);i.noInstall||await Ie({projectDir:s,packageManager:i.packageManager,addons:i.addons}),$.success(F.blue(`You can reproduce this setup with the following command:
166
+ ${F.white(Ye(i))}`));let m=((Date.now()-e)/1e3).toFixed(2);fo(F.magenta(`Project created successfully in ${F.bold(m)} seconds!`))}catch(t){a.stop(F.red("Failed")),t instanceof Error&&(uo(F.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}wo().catch(e=>{$.error("Aborting installation..."),e instanceof Error?$.error(e.message):($.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.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "CLI tool to scaffold Better-T Stack projects",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,24 @@
1
+ node_modules/
2
+ .expo/
3
+ dist/
4
+ npm-debug.*
5
+ *.jks
6
+ *.p8
7
+ *.p12
8
+ *.key
9
+ *.mobileprovision
10
+ *.orig.*
11
+ web-build/
12
+ # expo router
13
+ expo-env.d.ts
14
+
15
+
16
+
17
+ ios
18
+ android
19
+
20
+ # macOS
21
+ .DS_Store
22
+
23
+ # Temporary files created by Metro to check the health of the file watcher
24
+ .metro-health-check*
@@ -0,0 +1,29 @@
1
+ import { Tabs } from "expo-router";
2
+
3
+ import { TabBarIcon } from "@/components/tabbar-icon";
4
+
5
+ export default function TabLayout() {
6
+ return (
7
+ <Tabs
8
+ screenOptions={{
9
+ headerShown: false,
10
+ tabBarActiveTintColor: "black",
11
+ }}
12
+ >
13
+ <Tabs.Screen
14
+ name="index"
15
+ options={{
16
+ title: "Tab One",
17
+ tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
18
+ }}
19
+ />
20
+ <Tabs.Screen
21
+ name="two"
22
+ options={{
23
+ title: "Tab Two",
24
+ tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
25
+ }}
26
+ />
27
+ </Tabs>
28
+ );
29
+ }
@@ -0,0 +1,9 @@
1
+ import { View, Text } from "react-native";
2
+
3
+ export default function App() {
4
+ return (
5
+ <View>
6
+ <Text>Hello, World!</Text>
7
+ </View>
8
+ );
9
+ }