create-better-t-stack 1.4.5 → 1.6.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 (61) hide show
  1. package/dist/index.js +150 -98
  2. package/package.json +1 -1
  3. package/template/base/apps/{web → web-base}/_gitignore +3 -0
  4. package/template/base/apps/{web → web-base}/components.json +2 -2
  5. package/template/base/apps/{web → web-base}/src/components/mode-toggle.tsx +1 -1
  6. package/template/base/apps/{web → web-base}/src/components/theme-provider.tsx +1 -1
  7. package/template/base/apps/web-base/src/components/ui/button.tsx +59 -0
  8. package/template/base/apps/{web → web-base}/src/components/ui/card.tsx +10 -10
  9. package/template/base/apps/{web → web-base}/src/components/ui/checkbox.tsx +6 -6
  10. package/template/base/apps/web-base/src/components/ui/dropdown-menu.tsx +255 -0
  11. package/template/base/apps/web-base/src/components/ui/input.tsx +21 -0
  12. package/template/base/apps/web-base/src/components/ui/label.tsx +24 -0
  13. package/template/base/apps/web-base/src/components/ui/skeleton.tsx +13 -0
  14. package/template/base/apps/web-base/src/components/ui/sonner.tsx +23 -0
  15. package/template/base/apps/web-base/src/index.css +134 -0
  16. package/template/base/apps/web-react-router/package.json +49 -0
  17. package/template/base/apps/web-react-router/public/favicon.ico +0 -0
  18. package/template/base/apps/web-react-router/react-router.config.ts +6 -0
  19. package/template/base/apps/web-react-router/src/components/header.tsx +31 -0
  20. package/template/base/apps/web-react-router/src/root.tsx +91 -0
  21. package/template/base/apps/web-react-router/src/routes/_index.tsx +89 -0
  22. package/template/base/apps/web-react-router/src/routes.ts +4 -0
  23. package/template/base/apps/web-react-router/tsconfig.json +27 -0
  24. package/template/base/apps/web-react-router/vite.config.ts +8 -0
  25. package/template/base/apps/{web → web-tanstack-router}/package.json +2 -2
  26. package/template/base/apps/{web → web-tanstack-router}/src/routes/index.tsx +1 -4
  27. package/template/examples/ai/apps/web-react-router/src/routes/ai.tsx +64 -0
  28. package/template/examples/todo/apps/web-react-router/src/routes/todos.tsx +130 -0
  29. package/template/examples/todo/apps/{web → web-tanstack-router}/src/routes/todos.tsx +6 -8
  30. package/template/with-auth/apps/web-react-router/src/components/header.tsx +34 -0
  31. package/template/with-auth/apps/web-react-router/src/components/sign-in-form.tsx +135 -0
  32. package/template/with-auth/apps/web-react-router/src/components/sign-up-form.tsx +160 -0
  33. package/template/with-auth/apps/web-react-router/src/components/user-menu.tsx +60 -0
  34. package/template/with-auth/apps/web-react-router/src/routes/dashboard.tsx +30 -0
  35. package/template/with-auth/apps/web-react-router/src/routes/login.tsx +13 -0
  36. package/template/base/apps/web/src/components/ui/button.tsx +0 -57
  37. package/template/base/apps/web/src/components/ui/dropdown-menu.tsx +0 -199
  38. package/template/base/apps/web/src/components/ui/input.tsx +0 -22
  39. package/template/base/apps/web/src/components/ui/label.tsx +0 -24
  40. package/template/base/apps/web/src/components/ui/skeleton.tsx +0 -15
  41. package/template/base/apps/web/src/components/ui/sonner.tsx +0 -29
  42. package/template/base/apps/web/src/index.css +0 -119
  43. package/template/with-pwa/apps/web/vite.config.ts +0 -35
  44. /package/template/base/apps/{web → web-base}/src/components/loader.tsx +0 -0
  45. /package/template/base/apps/{web → web-base}/src/lib/utils.ts +0 -0
  46. /package/template/base/apps/{web → web-base}/src/utils/trpc.ts +0 -0
  47. /package/template/base/apps/{web → web-tanstack-router}/index.html +0 -0
  48. /package/template/base/apps/{web → web-tanstack-router}/src/components/header.tsx +0 -0
  49. /package/template/base/apps/{web → web-tanstack-router}/src/main.tsx +0 -0
  50. /package/template/base/apps/{web → web-tanstack-router}/src/routes/__root.tsx +0 -0
  51. /package/template/base/apps/{web → web-tanstack-router}/tsconfig.json +0 -0
  52. /package/template/base/apps/{web → web-tanstack-router}/vite.config.ts +0 -0
  53. /package/template/examples/ai/apps/{web → web-tanstack-router}/src/routes/ai.tsx +0 -0
  54. /package/template/with-auth/apps/{web → web-base}/src/lib/auth-client.ts +0 -0
  55. /package/template/with-auth/apps/{web → web-base}/src/utils/trpc.ts +0 -0
  56. /package/template/with-auth/apps/{web → web-tanstack-router}/src/components/header.tsx +0 -0
  57. /package/template/with-auth/apps/{web → web-tanstack-router}/src/components/sign-in-form.tsx +0 -0
  58. /package/template/with-auth/apps/{web → web-tanstack-router}/src/components/sign-up-form.tsx +0 -0
  59. /package/template/with-auth/apps/{web → web-tanstack-router}/src/components/user-menu.tsx +0 -0
  60. /package/template/with-auth/apps/{web → web-tanstack-router}/src/routes/dashboard.tsx +0 -0
  61. /package/template/with-auth/apps/{web → web-tanstack-router}/src/routes/login.tsx +0 -0
package/dist/index.js CHANGED
@@ -1,11 +1,33 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as j,intro as br,log as E,outro as wr,spinner as Pr}from"@clack/prompts";import{Command as yr}from"commander";import l from"picocolors";import te from"node:path";import{fileURLToPath as pt}from"node:url";var U=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var dt=pt(import.meta.url),lt=te.dirname(dt),k=te.join(lt,"../"),m={projectName:"my-better-t-app",frontend:["web"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:U(),noInstall:!1,turso:!1,backend:"hono",runtime:"bun"},Q={"better-auth":"^1.2.4","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",postgres:"^3.4.5","@prisma/client":"^6.5.0",prisma:"^6.5.0","vite-plugin-pwa":"^0.21.2","@vite-pwa/assets-generator":"^0.2.6","@tauri-apps/cli":"^2.4.0","@biomejs/biome":"1.9.4",husky:"^9.1.7","lint-staged":"^15.5.0","@hono/node-server":"^1.14.0",tsx:"^4.19.2","@types/node":"^22.13.11","@types/bun":"^1.2.6","@elysiajs/node":"^1.2.6","@elysiajs/cors":"^1.2.0","@elysiajs/trpc":"^1.1.0",elysia:"^1.2.25","@hono/trpc-server":"^0.3.4",hono:"^4.7.5",ai:"^4.2.8","@ai-sdk/google":"^1.2.3"};import da from"node:path";import{cancel as la,spinner as ua}from"@clack/prompts";import ma from"fs-extra";import Re from"picocolors";import D from"node:path";import T from"fs-extra";import ut from"node:path";import ae from"fs-extra";var b=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,n=ut.join(r,"package.json"),o=ae.readJSONSync(n);o.dependencies||(o.dependencies={}),o.devDependencies||(o.devDependencies={});for(let i of a){let s=Q[i];o.dependencies[i]=s}for(let i of t){let s=Q[i];o.devDependencies[i]=s}ae.writeJSONSync(n,o,{spaces:2})};import G from"node:path";import{log as mt,spinner as ft}from"@clack/prompts";import{execa as ht}from"execa";import q from"fs-extra";import re from"picocolors";async function ne(e,a){let t=ft(),r=G.join(e,"apps/web");if(await q.pathExists(r))try{t.start("Setting up Tauri desktop app support..."),b({devDependencies:["@tauri-apps/cli"],projectDir:r});let n=G.join(r,"package.json");if(await q.pathExists(n)){let s=await q.readJson(n);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await q.writeJson(n,s,{spaces:2})}let o,i;switch(a){case"npm":o="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":o="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":o="bunx",i=["@tauri-apps/cli@latest"];break;default:o="npx",i=["@tauri-apps/cli@latest"]}i=[...i,"init",`--app-name=${G.basename(e)}`,`--window-title=${G.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ht(o,i,{cwd:r,env:{CI:"true"}}),t.stop("Tauri desktop app support configured successfully!")}catch(n){throw t.stop(re.red("Failed to set up Tauri")),n instanceof Error&&mt.error(re.red(n.message)),n}}async function oe(e,a,t,r){let n=r.includes("web");a.includes("pwa")&&n&&await wt(e),a.includes("tauri")&&n&&await ne(e,t),a.includes("biome")&&await gt(e),a.includes("husky")&&await bt(e)}async function gt(e){let a=D.join(k,"template/with-biome");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0}),b({devDependencies:["@biomejs/biome"],projectDir:e});let t=D.join(e,"package.json");if(await T.pathExists(t)){let r=await T.readJson(t);r.scripts={...r.scripts,check:"biome check --write ."},await T.writeJson(t,r,{spaces:2})}}async function bt(e){let a=D.join(k,"template/with-husky");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0}),b({devDependencies:["husky","lint-staged"],projectDir:e});let t=D.join(e,"package.json");if(await T.pathExists(t)){let r=await T.readJson(t);r.scripts={...r.scripts,prepare:"husky"},r["lint-staged"]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":["biome check --write ."]},await T.writeJson(t,r,{spaces:2})}}async function wt(e){let a=D.join(k,"template/with-pwa");await T.pathExists(a)&&await T.copy(a,e,{overwrite:!0});let t=D.join(e,"apps/web");if(!await T.pathExists(t))return;b({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let r=D.join(t,"package.json");if(await T.pathExists(r)){let n=await T.readJson(r);n.scripts={...n.scripts,"generate-pwa-assets":"pwa-assets-generator"},await T.writeJson(r,n,{spaces:2})}}import ie from"node:path";import{log as se}from"@clack/prompts";import ce from"picocolors";function pe(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",r=a.length;for(let n=0;n<e;n++)t+=a.charAt(Math.floor(Math.random()*r));return t}async function de(e,a){if(!a)return;let t=ie.join(e,"apps/server"),r=ie.join(e,"apps/web");try{b({dependencies:["better-auth"],projectDir:t}),b({dependencies:["better-auth"],projectDir:r})}catch(n){throw se.error(ce.red("Failed to configure authentication")),n instanceof Error&&se.error(ce.red(n.message)),n}}import Pt from"node:path";async function le(e,a,t){let r=Pt.join(e,"apps/server"),n=[],o=[];a==="hono"?(n.push("hono","@hono/trpc-server"),t==="node"&&(n.push("@hono/node-server"),o.push("tsx","@types/node"))):a==="elysia"&&(n.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(n.push("@elysiajs/node"),o.push("tsx","@types/node"))),t==="bun"&&o.push("@types/bun"),b({dependencies:n,devDependencies:o,projectDir:r})}import yt from"node:path";import jt from"fs-extra";async function ue(e,a){let t=yt.join(e,"README.md"),r=vt(a);try{await jt.writeFile(t,r)}catch(n){console.error("Failed to create README.md file:",n)}}function vt(e){let{projectName:a,packageManager:t,database:r,auth:n,addons:o=[],orm:i="drizzle",runtime:s="bun"}=e,c=t==="npm"?"npm run":t;return`# ${a}
3
-
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.
2
+ import{cancel as k,intro as Gr,log as R,outro as Vr,spinner as qr}from"@clack/prompts";import{Command as Jr}from"commander";import h from"picocolors";import pe from"node:path";import{fileURLToPath as xt}from"node:url";var H=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var $t=xt(import.meta.url),Et=pe.dirname($t),$=pe.join(Et,"../"),g={projectName:"my-better-t-app",frontend:["tanstack-router"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:H(),noInstall:!1,turso:!1,prismaPostgres:!1,backend:"hono",runtime:"bun"},ae={"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","@prisma/extension-accelerate":"^1.3.0"};import Sa from"node:path";import{cancel as Da,spinner as La}from"@clack/prompts";import Na from"fs-extra";import Je from"picocolors";import N from"node:path";import E from"fs-extra";import Tt from"node:path";import le from"fs-extra";var P=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,n=Tt.join(r,"package.json"),i=le.readJSONSync(n);i.dependencies||(i.dependencies={}),i.devDependencies||(i.devDependencies={});for(let s of a){let o=ae[s];i.dependencies[s]=o}for(let s of t){let o=ae[s];i.devDependencies[s]=o}le.writeJSONSync(n,i,{spaces:2})};import Q from"node:path";import{log as At,spinner as Ct}from"@clack/prompts";import{execa as Rt}from"execa";import K from"fs-extra";import de from"picocolors";async function ue(e,a,t){let r=Ct(),n=Q.join(e,"apps/web");if(await K.pathExists(n))try{r.start("Setting up Tauri desktop app support..."),P({devDependencies:["@tauri-apps/cli"],projectDir:n});let i=Q.join(n,"package.json");if(await K.pathExists(i)){let d=await K.readJson(i);d.scripts={...d.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await K.writeJson(i,d,{spaces:2})}let s,o;switch(a){case"npm":s="npx",o=["@tauri-apps/cli@latest"];break;case"pnpm":s="pnpm",o=["dlx","@tauri-apps/cli@latest"];break;case"bun":s="bunx",o=["@tauri-apps/cli@latest"];break;default:s="npx",o=["@tauri-apps/cli@latest"]}let c=t.includes("react-router")?"http://localhost:5173":"http://localhost:3001";o=[...o,"init",`--app-name=${Q.basename(e)}`,`--window-title=${Q.basename(e)}`,"--frontend-dist=dist",`--dev-url=${c}`,`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await Rt(s,o,{cwd:n,env:{CI:"true"}}),r.stop("Tauri desktop app support configured successfully!")}catch(i){throw r.stop(de.red("Failed to set up Tauri")),i instanceof Error&&At.error(de.red(i.message)),i}}async function me(e,a,t,r){let n=r.includes("react-router")||r.includes("tanstack-router");a.includes("pwa")&&n&&await St(e,r),a.includes("tauri")&&n&&await ue(e,t,r),a.includes("biome")&&await It(e),a.includes("husky")&&await Ot(e)}function Ft(e,a){return N.join(e,"apps/web")}async function It(e){let a=N.join($,"template/with-biome");await E.pathExists(a)&&await E.copy(a,e,{overwrite:!0}),P({devDependencies:["@biomejs/biome"],projectDir:e});let t=N.join(e,"package.json");if(await E.pathExists(t)){let r=await E.readJson(t);r.scripts={...r.scripts,check:"biome check --write ."},await E.writeJson(t,r,{spaces:2})}}async function Ot(e){let a=N.join($,"template/with-husky");await E.pathExists(a)&&await E.copy(a,e,{overwrite:!0}),P({devDependencies:["husky","lint-staged"],projectDir:e});let t=N.join(e,"package.json");if(await E.pathExists(t)){let r=await E.readJson(t);r.scripts={...r.scripts,prepare:"husky"},r["lint-staged"]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":["biome check --write ."]},await E.writeJson(t,r,{spaces:2})}}async function St(e,a){let t=N.join($,"template/with-pwa");await E.pathExists(t)&&await E.copy(t,e,{overwrite:!0});let r=Ft(e,a);if(!await E.pathExists(r))return;P({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:r});let n=N.join(r,"vite.config.ts");if(await E.pathExists(n)){let s=await E.readFile(n,"utf8");if(!s.includes("vite-plugin-pwa")){let p=s.match(/^import .* from ['"](.*)['"]/m);p?s=s.replace(p[0],`import { VitePWA } from "vite-plugin-pwa";
3
+ ${p[0]}`):s=`import { VitePWA } from "vite-plugin-pwa";
4
+ ${s}`}let o=`VitePWA({
5
+ registerType: "autoUpdate",
6
+ manifest: {
7
+ name: "My App",
8
+ short_name: "My App",
9
+ description: "My App",
10
+ theme_color: "#0c0c0c",
11
+ },
12
+ pwaAssets: {
13
+ disabled: false,
14
+ config: true,
15
+ },
16
+ devOptions: {
17
+ enabled: true,
18
+ },
19
+ })`;s.includes("VitePWA(")||(a.includes("react-router")?s=s.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
20
+ tailwindcss(),
21
+ ${o}`):a.includes("tanstack-router")?s=s.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
22
+ tailwindcss(),
23
+ ${o}`):s=s.replace(/plugins: \[/,`plugins: [
24
+ ${o},`)),await E.writeFile(n,s)}let i=N.join(r,"package.json");if(await E.pathExists(i)){let s=await E.readJson(i);s.scripts={...s.scripts,"generate-pwa-assets":"pwa-assets-generator"},await E.writeJson(i,s,{spaces:2})}}import fe from"node:path";import{log as he}from"@clack/prompts";import ge from"picocolors";function we(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",r=a.length;for(let n=0;n<e;n++)t+=a.charAt(Math.floor(Math.random()*r));return t}async function be(e,a){if(!a)return;let t=fe.join(e,"apps/server"),r=fe.join(e,"apps/web");try{P({dependencies:["better-auth"],projectDir:t}),P({dependencies:["better-auth"],projectDir:r})}catch(n){throw he.error(ge.red("Failed to configure authentication")),n instanceof Error&&he.error(ge.red(n.message)),n}}import Dt from"node:path";async function Pe(e,a,t){let r=Dt.join(e,"apps/server"),n=[],i=[];a==="hono"?(n.push("hono","@hono/trpc-server"),t==="node"&&(n.push("@hono/node-server"),i.push("tsx","@types/node"))):a==="elysia"&&(n.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(n.push("@elysiajs/node"),i.push("tsx","@types/node"))),t==="bun"&&i.push("@types/bun"),P({dependencies:n,devDependencies:i,projectDir:r})}import Lt from"node:path";import Nt from"fs-extra";async function ye(e,a){let t=Lt.join(e,"README.md"),r=_t(a);try{await Nt.writeFile(t,r)}catch(n){console.error("Failed to create README.md file:",n)}}function _t(e){let{projectName:a,packageManager:t,database:r,auth:n,addons:i=[],orm:s="drizzle",runtime:o="bun",frontend:p=["tanstack-router"]}=e,c=p.includes("react-router"),d=p.includes("tanstack-router"),j=p.includes("native"),A=t==="npm"?"npm run":t,b=c?"5173":"3001";return`# ${a}
25
+
26
+ This project was created with [Better-T-Stack](https://github.com/better-t-stack/Better-T-Stack), a modern TypeScript stack that combines React, ${d?"TanStack Router":"React Router"}, Hono, tRPC, and more.
5
27
 
6
28
  ## Features
7
29
 
8
- ${xt(r,n,o,i,s)}
30
+ ${Ut(r,n,i,s,o,p)}
9
31
 
10
32
  ## Getting Started
11
33
 
@@ -15,31 +37,41 @@ First, install the dependencies:
15
37
  ${t} install
16
38
  \`\`\`
17
39
 
18
- ${kt(r,n,c,i)}
40
+ ${Mt(r,n,A,s)}
19
41
 
20
42
  Then, run the development server:
21
43
 
22
44
  \`\`\`bash
23
- ${c} dev
45
+ ${A} dev
24
46
  \`\`\`
25
47
 
26
- Open [http://localhost:3001](http://localhost:3001) in your browser to see the web application.
48
+ ${d||c?`Open [http://localhost:${b}](http://localhost:${b}) in your browser to see the web application.`:""}
49
+ ${j?`Use the Expo Go app to run the mobile application.
50
+ `:""}
27
51
  The API is running at [http://localhost:3000](http://localhost:3000).
28
52
 
53
+ ${i.includes("pwa")&&c?`
54
+ ## PWA Support with React Router v7
55
+
56
+ There is a known compatibility issue between VitePWA and React Router v7.
57
+ See: https://github.com/vite-pwa/vite-plugin-pwa/issues/809
58
+ `:""}
59
+
29
60
  ## Project Structure
30
61
 
31
62
  \`\`\`
32
63
  ${a}/
33
64
  \u251C\u2500\u2500 apps/
34
- \u2502 \u251C\u2500\u2500 web/ # Frontend application (React, TanStack Router)
35
- \u2502 \u2514\u2500\u2500 server/ # Backend API (Hono, tRPC)
65
+ ${d||c?`\u2502 \u251C\u2500\u2500 web/ # Frontend application (React, ${d?"TanStack Router":"React Router"})
66
+ `:""}${j?`\u2502 \u251C\u2500\u2500 native/ # Mobile application (React Native, Expo)
67
+ `:""}\u2502 \u2514\u2500\u2500 server/ # Backend API (Hono, tRPC)
36
68
  \`\`\`
37
69
 
38
70
  ## Available Scripts
39
71
 
40
- ${Tt(c,r,i,n)}
41
- `}function xt(e,a,t,r,n){let o=["- **TypeScript** - For type safety and improved developer experience","- **TanStack Router** - File-based routing with full type safety","- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs",`- **${n==="bun"?"Bun":"Node.js"}** - Runtime environment`];e!=="none"&&o.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&o.push("- **Authentication** - Email & password authentication with Better Auth");for(let i of t)i==="pwa"?o.push("- **PWA** - Progressive Web App support"):i==="tauri"?o.push("- **Tauri** - Build native desktop applications"):i==="biome"?o.push("- **Biome** - Linting and formatting"):i==="husky"&&o.push("- **Husky** - Git hooks for code quality");return o.join(`
42
- `)}function kt(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
72
+ ${Bt(A,r,s,n,j)}
73
+ `}function Ut(e,a,t,r,n,i){let s=i.includes("tanstack-router"),o=i.includes("react-router"),p=i.includes("native"),c=["- **TypeScript** - For type safety and improved developer experience"];s?c.push("- **TanStack Router** - File-based routing with full type safety"):o&&c.push("- **React Router** - Declarative routing for React"),p&&(c.push("- **React Native** - Build mobile apps using React"),c.push("- **Expo** - Tools for React Native development")),c.push("- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs",`- **${n==="bun"?"Bun":"Node.js"}** - Runtime environment`),e!=="none"&&c.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&c.push("- **Authentication** - Email & password authentication with Better Auth");for(let d of t)d==="pwa"?c.push("- **PWA** - Progressive Web App support"):d==="tauri"?c.push("- **Tauri** - Build native desktop applications"):d==="biome"?c.push("- **Biome** - Linting and formatting"):d==="husky"&&c.push("- **Husky** - Git hooks for code quality");return c.join(`
74
+ `)}function Mt(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
43
75
 
44
76
  `;return e==="sqlite"?n+=`This project uses SQLite${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
45
77
 
@@ -61,17 +93,35 @@ ${t} db:push
61
93
  \`\`\`bash
62
94
  ${t} db:push
63
95
  \`\`\``}
64
- `,n}function Tt(e,a,t,r){let n=`- \`${e} dev\`: Start both web and server in development mode
96
+ `,n}function Bt(e,a,t,r,n){let i=`- \`${e} dev\`: Start both web and server in development mode
65
97
  - \`${e} build\`: Build both web and server
66
98
  - \`${e} dev:web\`: Start only the web application
67
99
  - \`${e} dev:server\`: Start only the server
68
- - \`${e} check-types\`: Check TypeScript types across all apps`;return a!=="none"&&(n+=`
100
+ - \`${e} check-types\`: Check TypeScript types across all apps`;return n&&(i+=`
101
+ - \`${e} dev:native\`: Start the React Native/Expo development server`),a!=="none"&&(i+=`
69
102
  - \`${e} db:push\`: Push schema changes to database
70
- - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(n+=`
71
- - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),n}import he from"node:path";import{log as _t,spinner as Bt}from"@clack/prompts";import zt from"fs-extra";import ge from"picocolors";import Et from"node:os";import me from"node:path";import{cancel as K,confirm as $t,isCancel as X,log as L,select as Ct,spinner as Y,text as At}from"@clack/prompts";import{$ as O}from"execa";import Ot from"fs-extra";import A from"picocolors";async function It(){try{return(await O`turso --version`).exitCode===0}catch{return!1}}async function Ft(){try{return!(await O`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function St(){let e=Y();try{return e.start("Logging in to Turso..."),await O`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(A.red("Failed to log in to Turso")),a}}async function Dt(e){let a=Y();try{if(a.start("Installing Turso CLI..."),e)await O`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await O`curl -sSfL https://get.tur.so/install.sh`;await O`bash -c '${t}'`}return a.stop("Turso CLI installed successfully!"),!0}catch(t){throw t instanceof Error&&t.message.includes("User force closed")?(a.stop(),L.warn(A.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(A.red("Failed to install Turso CLI")),t)}}async function Rt(){try{let{stdout:e}=await O`turso group list`,a=e.trim().split(`
72
- `);return a.length<=1?[]:a.slice(1).map(r=>{let[n,o,i,s]=r.trim().split(/\s{2,}/);return{name:n,locations:o,version:i,status:s}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function Lt(){let e=await Rt();if(e.length===0)return null;if(e.length===1)return e[0].name;let a=e.map(r=>({value:r.name,label:`${r.name} (${r.locations})`})),t=await Ct({message:"Select a Turso database group:",options:a});return X(t)&&(K(A.red("Operation cancelled")),process.exit(0)),t}async function Nt(e,a){try{a?await O`turso db create ${e} --group ${a}`:await O`turso db create ${e}`}catch(n){throw n instanceof Error&&n.message.includes("already exists")?new Error("DATABASE_EXISTS"):n}let{stdout:t}=await O`turso db show ${e} --url`,{stdout:r}=await O`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function B(e,a){let t=me.join(e,"apps/server",".env"),r=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
103
+ - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(i+=`
104
+ - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),i}import $e from"node:path";import{log as sa,spinner as oa}from"@clack/prompts";import ca from"fs-extra";import Ee from"picocolors";import q from"node:path";import{cancel as zt,isCancel as Gt,log as S,password as Vt}from"@clack/prompts";import{execa as qt}from"execa";import _ from"fs-extra";import B from"picocolors";async function Jt(e,a){try{S.info(B.blue("Initializing Prisma PostgreSQL"));let t=q.join(e,"prisma");await _.ensureDir(t),await qt(a==="npm"?"npx":a==="pnpm"?"pnpm dlx":"bunx",["prisma","init","--db"],{cwd:e,stdio:"inherit"}),S.info(B.yellow(`Please copy the Prisma Postgres URL from the output above.
105
+ It looks like: prisma+postgres://accelerate.prisma-data.net/?api_key=...`));let n=await Vt({message:"Paste your Prisma Postgres database URL:",validate(i){if(!i)return"Please enter a database URL";if(!i.startsWith("prisma+postgres://"))return"URL should start with prisma+postgres://"}});return Gt(n)?(zt("Database setup cancelled"),null):{databaseUrl:n}}catch(t){return t instanceof Error&&S.error(B.red(t.message)),null}}async function X(e,a){let t=q.join(e,"apps/server",".env"),r="";await _.pathExists(t)&&(r=await _.readFile(t,"utf8"));let n=a?`DATABASE_URL="${a.databaseUrl}"`:'DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"';r.includes("DATABASE_URL=")?r=r.replace(/DATABASE_URL=.*(\r?\n|$)/,`${n}$1`):r+=`
106
+ ${n}`,await _.writeFile(t,r.trim())}function je(){S.info(`Manual Prisma PostgreSQL Setup Instructions:
107
+
108
+ 1. Visit https://console.prisma.io and create an account
109
+ 2. Create a new PostgreSQL database from the dashboard
110
+ 3. Get your database URL
111
+ 4. Add the database URL to the .env file in apps/server/.env
112
+
113
+ DATABASE_URL="your_database_url"`)}async function ve(e,a,t="npm"){let r=q.join(e,"apps/server");if(!a){await X(e),S.info(B.blue("Using default Postgres configuration. You'll need to provide your own database."));return}try{let n=await Jt(r,t);n?(await X(e,n),await Wt(r),S.success(B.green("Prisma PostgreSQL database configured successfully!"))):(await X(e),je())}catch(n){S.error(B.red(`Error during Prisma PostgreSQL setup: ${n}`)),await X(e),je(),S.info("Setup completed with manual configuration required.")}}async function Wt(e){try{P({dependencies:["@prisma/extension-accelerate"],projectDir:e});let a=q.join(e,"prisma/index.ts");await _.writeFile(a,`
114
+ import { PrismaClient } from '@prisma/client';
115
+ import { withAccelerate } from "@prisma/extension-accelerate";
116
+
117
+ const prisma = new PrismaClient().$extends(withAccelerate());
118
+
119
+ export default prisma;
120
+ `.trim());let r=q.join(e,"src/db/index.ts");if(await _.pathExists(r)){let n=await _.readFile(r,"utf8");n.includes("@prisma/extension-accelerate")||(n=`import { withAccelerate } from "@prisma/extension-accelerate";
121
+ ${n}`,n=n.replace("export const db = new PrismaClient();","export const db = new PrismaClient().$extends(withAccelerate());"),await _.writeFile(r,n))}}catch{S.warn(B.yellow("Could not add Prisma Accelerate extension automatically"))}}import Ht from"node:os";import ke from"node:path";import{cancel as re,confirm as Qt,isCancel as ne,log as G,select as Kt,spinner as ie,text as Xt}from"@clack/prompts";import{$ as O}from"execa";import Yt from"fs-extra";import I from"picocolors";async function Zt(){try{return(await O`turso --version`).exitCode===0}catch{return!1}}async function ea(){try{return!(await O`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function ta(){let e=ie();try{return e.start("Logging in to Turso..."),await O`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(I.red("Failed to log in to Turso")),a}}async function aa(e){let a=ie();try{if(a.start("Installing Turso CLI..."),e)await O`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await O`curl -sSfL https://get.tur.so/install.sh`;await O`bash -c '${t}'`}return a.stop("Turso CLI installed successfully!"),!0}catch(t){throw t instanceof Error&&t.message.includes("User force closed")?(a.stop(),G.warn(I.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(I.red("Failed to install Turso CLI")),t)}}async function ra(){try{let{stdout:e}=await O`turso group list`,a=e.trim().split(`
122
+ `);return a.length<=1?[]:a.slice(1).map(r=>{let[n,i,s,o]=r.trim().split(/\s{2,}/);return{name:n,locations:i,version:s,status:o}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function na(){let e=await ra();if(e.length===0)return null;if(e.length===1)return e[0].name;let a=e.map(r=>({value:r.name,label:`${r.name} (${r.locations})`})),t=await Kt({message:"Select a Turso database group:",options:a});return ne(t)&&(re(I.red("Operation cancelled")),process.exit(0)),t}async function ia(e,a){try{a?await O`turso db create ${e} --group ${a}`:await O`turso db create ${e}`}catch(n){throw n instanceof Error&&n.message.includes("already exists")?new Error("DATABASE_EXISTS"):n}let{stdout:t}=await O`turso db show ${e} --url`,{stdout:r}=await O`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function J(e,a){let t=ke.join(e,"apps/server",".env"),r=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
73
123
  TURSO_AUTH_TOKEN="${a.authToken}"`:`TURSO_CONNECTION_URL=
74
- TURSO_AUTH_TOKEN=`;await Ot.writeFile(t,r)}function J(){L.info(`Manual Turso Setup Instructions:
124
+ TURSO_AUTH_TOKEN=`;await Yt.writeFile(t,r)}function Y(){G.info(`Manual Turso Setup Instructions:
75
125
 
76
126
  1. Visit https://turso.tech and create an account
77
127
  2. Create a new database from the dashboard
@@ -79,90 +129,92 @@ TURSO_AUTH_TOKEN=`;await Ot.writeFile(t,r)}function J(){L.info(`Manual Turso Set
79
129
  4. Add these credentials to the .env file in apps/server/.env
80
130
 
81
131
  TURSO_CONNECTION_URL=your_database_url
82
- TURSO_AUTH_TOKEN=your_auth_token`)}async function fe(e,a){if(!a){await B(e),L.info(A.blue("Skipping Turso setup. Setting up empty configuration.")),J();return}let t=Et.platform(),r=t==="darwin";if(!(t!=="win32")){L.warn(A.yellow("Automatic Turso setup is not supported on Windows.")),await B(e),J();return}try{if(!await It()){let v=await $t({message:"Would you like to install Turso CLI?",initialValue:!0});if(X(v)&&(K(A.red("Operation cancelled")),process.exit(0)),!v){await B(e),J();return}await Dt(r)}await Ft()||await St();let s=await Lt(),c=!1,w="",y=me.basename(e);for(;!c;){let v=await At({message:"Enter a name for your database:",defaultValue:y,initialValue:y,placeholder:y});X(v)&&(K(A.red("Operation cancelled")),process.exit(0)),w=v;let g=Y();try{g.start(`Creating Turso database "${w}"${s?` in group "${s}"`:""}...`);let C=await Nt(w,s);await B(e,C),g.stop("Turso database configured successfully!"),c=!0}catch(C){if(C instanceof Error&&C.message==="DATABASE_EXISTS")g.stop(A.yellow(`Database "${A.red(w)}" already exists`)),y=`${w}-${Math.floor(Math.random()*1e3)}`;else throw g.stop(A.red("Failed to create Turso database")),C}}}catch(o){L.error(A.red(`Error during Turso setup: ${o}`)),await B(e),J(),L.success("Setup completed with manual configuration required.")}}async function be(e,a,t,r=!0){let n=Bt(),o=he.join(e,"apps/server");if(a==="none"){await zt.remove(he.join(o,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?b({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&b({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}),r&&await fe(e,!0)):a==="postgres"&&(t==="drizzle"?b({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&b({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}))}catch(i){throw n.stop(ge.red("Failed to set up database")),i instanceof Error&&_t.error(ge.red(i.message)),i}}import N from"node:path";import I from"fs-extra";async function we(e,a){let t=N.join(e,"apps/server"),r=N.join(t,".env"),n="";if(await I.pathExists(r)&&(n=await I.readFile(r,"utf8")),n.includes("CORS_ORIGIN")||(n+=`
83
- CORS_ORIGIN=http://localhost:3001`),a.auth&&(n.includes("BETTER_AUTH_SECRET")||(n+=`
84
- BETTER_AUTH_SECRET=${pe()}`),n.includes("BETTER_AUTH_URL")||(n+=`
132
+ TURSO_AUTH_TOKEN=your_auth_token`)}async function xe(e,a){if(!a){await J(e),G.info(I.blue("Skipping Turso setup. Setting up empty configuration.")),Y();return}let t=Ht.platform(),r=t==="darwin";if(!(t!=="win32")){G.warn(I.yellow("Automatic Turso setup is not supported on Windows.")),await J(e),Y();return}try{if(!await Zt()){let j=await Qt({message:"Would you like to install Turso CLI?",initialValue:!0});if(ne(j)&&(re(I.red("Operation cancelled")),process.exit(0)),!j){await J(e),Y();return}await aa(r)}await ea()||await ta();let o=await na(),p=!1,c="",d=ke.basename(e);for(;!p;){let j=await Xt({message:"Enter a name for your database:",defaultValue:d,initialValue:d,placeholder:d});ne(j)&&(re(I.red("Operation cancelled")),process.exit(0)),c=j;let A=ie();try{A.start(`Creating Turso database "${c}"${o?` in group "${o}"`:""}...`);let b=await ia(c,o);await J(e,b),A.stop("Turso database configured successfully!"),p=!0}catch(b){if(b instanceof Error&&b.message==="DATABASE_EXISTS")A.stop(I.yellow(`Database "${I.red(c)}" already exists`)),d=`${c}-${Math.floor(Math.random()*1e3)}`;else throw A.stop(I.red("Failed to create Turso database")),b}}}catch(i){G.error(I.red(`Error during Turso setup: ${i}`)),await J(e),Y(),G.success("Setup completed with manual configuration required.")}}async function Te(e,a,t,r,n=!0){let i=oa(),s=$e.join(e,"apps/server");if(a==="none"){await ca.remove($e.join(s,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?P({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:s}):t==="prisma"&&P({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:s}),n&&await xe(e,!0)):a==="postgres"&&(t==="drizzle"?P({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:s}):t==="prisma"&&(P({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:s}),a==="postgres"&&t==="prisma"&&await ve(e,!0,r)))}catch(o){throw i.stop(Ee.red("Failed to set up database")),o instanceof Error&&sa.error(Ee.red(o.message)),o}}import V from"node:path";import D from"fs-extra";async function Ae(e,a){let t=V.join(e,"apps/server"),r=V.join(t,".env"),n="";if(await D.pathExists(r)&&(n=await D.readFile(r,"utf8")),!n.includes("CORS_ORIGIN")){let o=a.frontend.includes("react-router"),p=a.frontend.includes("tanstack-router"),c="http://localhost:3000";o?c="http://localhost:5173":p&&(c="http://localhost:3001"),n+=`
133
+ CORS_ORIGIN=${c}`}if(a.auth&&(n.includes("BETTER_AUTH_SECRET")||(n+=`
134
+ BETTER_AUTH_SECRET=${we()}`),n.includes("BETTER_AUTH_URL")||(n+=`
85
135
  BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!n.includes("DATABASE_URL")){let o=a.database==="sqlite"?"":`
86
136
  DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;n+=o}a.database==="sqlite"&&!a.turso&&(n.includes("TURSO_CONNECTION_URL")||(n+=`
87
- TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}if(a.examples?.includes("ai")&&!n.includes("GOOGLE_GENERATIVE_AI_API_KEY")&&(n+=`
88
- GOOGLE_GENERATIVE_AI_API_KEY=`),await I.writeFile(r,n.trim()),a.frontend.includes("web")){let o=N.join(e,"apps/web"),i=N.join(o,".env"),s="";await I.pathExists(i)&&(s=await I.readFile(i,"utf8")),s.includes("VITE_SERVER_URL")||(s+=`VITE_SERVER_URL=http://localhost:3000
89
- `),await I.writeFile(i,s.trim())}if(a.frontend.includes("native")){let o=N.join(e,"apps/native"),i=N.join(o,".env"),s="";await I.pathExists(i)&&(s=await I.readFile(i,"utf8")),s.includes("EXPO_PUBLIC_SERVER_URL")||(s+=`EXPO_PUBLIC_SERVER_URL=http://localhost:3000
90
- `),await I.writeFile(i,s.trim())}}import x from"node:path";import f from"fs-extra";async function Pe(e,a,t,r,n,o=["web"]){let i=o.includes("web"),s=await f.pathExists(x.join(e,"apps/web"));a.includes("todo")&&i&&s?await qt(e,t,r):await Vt(e,t),a.includes("ai")&&n==="hono"&&i&&s&&await Mt(e)}async function Mt(e){let a=x.join(k,"template/examples/ai");if(await f.pathExists(a)){await f.copy(a,e),await Gt(e);let t=x.join(e,"apps/web");b({dependencies:["ai"],projectDir:t});let r=x.join(e,"apps/server");b({dependencies:["ai","@ai-sdk/google"],projectDir:r}),await Ut(e)}}async function Ut(e){let a=x.join(e,"apps/server/src/index.ts");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");if(t.includes("hono")){let n=`import { streamText } from "ai";
137
+ TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}a.examples?.includes("ai")&&!n.includes("GOOGLE_GENERATIVE_AI_API_KEY")&&(n+=`
138
+ GOOGLE_GENERATIVE_AI_API_KEY=`),await D.writeFile(r,n.trim());let i=a.frontend.includes("react-router"),s=a.frontend.includes("tanstack-router");if(i||s){let o=V.join(e,"apps/web");await pa(o)}if(a.frontend.includes("native")){let o=V.join(e,"apps/native"),p=V.join(o,".env"),c="";await D.pathExists(p)&&(c=await D.readFile(p,"utf8")),c.includes("EXPO_PUBLIC_SERVER_URL")||(c+=`EXPO_PUBLIC_SERVER_URL=http://localhost:3000
139
+ `),await D.writeFile(p,c.trim())}}async function pa(e){let a=V.join(e,".env"),t="";await D.pathExists(a)&&(t=await D.readFile(a,"utf8")),t.includes("VITE_SERVER_URL")||(t+=`VITE_SERVER_URL=http://localhost:3000
140
+ `),await D.writeFile(a,t.trim())}import T from"node:path";import w from"fs-extra";async function Ce(e,a,t,r,n,i=["tanstack-router"]){let s=i.includes("tanstack-router"),o=i.includes("react-router"),p=s||o,c=s?"web-tanstack-router":"web-react-router",d=await w.pathExists(T.join(e,"apps/web"));a.includes("todo")&&p&&d?await ma(e,t,r,c):await ga(e,t),a.includes("ai")&&n==="hono"&&p&&d&&await la(e,c)}async function la(e,a){let t=T.join($,"template/examples/ai");if(await w.pathExists(t)){let r=T.join(t,`apps/${a}/src/routes/ai.tsx`),n=T.join(e,"apps/web/src/routes/ai.tsx");await w.pathExists(r)&&await w.copy(r,n,{overwrite:!0}),await ua(e,a);let i=T.join(e,"apps/web");P({dependencies:["ai"],projectDir:i});let s=T.join(e,"apps/server");P({dependencies:["ai","@ai-sdk/google"],projectDir:s}),await da(e)}}async function da(e){let a=T.join(e,"apps/server/src/index.ts");if(await w.pathExists(a)){let t=await w.readFile(a,"utf8");if(t.includes("hono")){let n=`import { streamText } from "ai";
91
141
  import { google } from "@ai-sdk/google";
92
- import { stream } from "hono/streaming";`,o=`
93
- app.post("/ai", async (c) => {
94
- const body = await c.req.json();
95
- const messages = body.messages || [];
96
-
97
- const result = streamText({
98
- model: google("gemini-2.0-flash-exp"),
99
- messages,
100
- });
101
-
102
- c.header("X-Vercel-AI-Data-Stream", "v1");
103
- c.header("Content-Type", "text/plain; charset=utf-8");
104
-
105
- return stream(c, (stream) => stream.pipe(result.toDataStream()));
106
- });`;if(t.includes("import {")){let s=t.lastIndexOf("import"),c=t.indexOf(`
107
- `,s);t=`${t.substring(0,c+1)}
108
- ${n}
109
- ${t.substring(c+1)}`}else t=`${n}
110
-
111
- ${t}`;let i=t.indexOf('app.use("/trpc"')||t.indexOf("app.use(trpc(");if(i!==-1)t=`${t.substring(0,i)}${o}
112
-
113
- ${t.substring(i)}`;else{let s=t.indexOf("export default");s!==-1?t=`${t.substring(0,s)}${o}
114
-
115
- ${t.substring(s)}`:t=`${t}
116
-
117
- ${o}`}await f.writeFile(a,t)}}}async function Gt(e){let a=x.join(e,"apps/web/src/components/header.tsx");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t.includes('{ to: "/todos"')?t=t.replace(/{ to: "\/todos", label: "Todos" },/,`{ to: "/todos", label: "Todos" },
118
- { to: "/ai", label: "AI Chat" },`):t.includes('{ to: "/dashboard"')?t=t.replace(/{ to: "\/dashboard", label: "Dashboard" },/,`{ to: "/dashboard", label: "Dashboard" },
119
- { to: "/ai", label: "AI Chat" },`):t=t.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
120
- { to: "/", label: "Home" },
121
- { to: "/ai", label: "AI Chat" },`),await f.writeFile(a,t)}}async function qt(e,a,t){let r=x.join(k,"template/examples/todo");if(await f.pathExists(r)){let n=x.join(r,"apps/web/src/routes"),o=x.join(e,"apps/web/src/routes");if(await f.copy(n,o,{overwrite:!0}),a!=="none"){let i=x.join(r,`apps/server/src/routers/with-${a}-todo.ts`),s=x.join(e,"apps/server/src/routers/todo.ts");await f.pathExists(i)&&await f.copy(i,s,{overwrite:!0})}await Jt(e,t),await Wt(e)}}async function Jt(e,a){let t=x.join(e,"apps/web/src/components/header.tsx");if(await f.pathExists(t)){let r=await f.readFile(t,"utf8");a?r=r.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
122
- { to: "/", label: "Home" },
123
- { to: "/dashboard", label: "Dashboard" },
124
- { to: "/todos", label: "Todos" },`):r=r.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
125
- { to: "/", label: "Home" },
126
- { to: "/todos", label: "Todos" },`),await f.writeFile(t,r)}}async function Vt(e,a){if(a==="drizzle"){let r=x.join(e,"apps/server/src/db/schema/todo.ts");await f.pathExists(r)&&await f.remove(r)}else if(a==="prisma"){let r=x.join(e,"apps/server/prisma/schema/todo.prisma");await f.pathExists(r)&&await f.remove(r)}let t=x.join(e,"apps/server/src/routers/todo.ts");await f.pathExists(t)&&await f.remove(t),await Ht(e)}async function Ht(e){let a=x.join(e,"apps/server/src/routers/index.ts");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await f.writeFile(a,t)}}async function Wt(e){let a=x.join(e,"apps/web/src/routes/index.tsx");if(await f.pathExists(a)){let t=await f.readFile(a,"utf8");t=t.replace(/<div id="buttons"><\/div>/,`<div id="buttons" className="mt-4 flex flex-col gap-4 sm:flex-row sm:items-center">
127
- <Button asChild>
128
- <Link to="/todos" className="flex items-center">
129
- View Todo Demo
130
- <ArrowRight className="ml-1 h-4 w-4" />
131
- </Link>
132
- </Button>
133
- </div>`),await f.writeFile(a,t)}}import{log as ye,spinner as je}from"@clack/prompts";import{$ as ve}from"execa";import V from"picocolors";async function xe({projectDir:e,packageManager:a,addons:t=[]}){let r=je();try{r.start(`Running ${a} install...`),await ve({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await Qt(e,a)}catch(n){throw r.stop(V.red("Failed to install dependencies")),n instanceof Error&&ye.error(V.red(`Installation error: ${n.message}`)),n}}async function Qt(e,a){let t=je();try{t.start("Running Biome format check..."),await ve({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(V.yellow("Biome check encountered issues")),ye.warn(V.yellow("Some files may need manual formatting"))}}import{note as Kt}from"@clack/prompts";import P from"picocolors";function ke(e,a,t,r,n,o,i,s){let c=t==="npm"?"npm run":t,w=`cd ${a}`,y=o?.includes("husky")||o?.includes("biome"),v=e!=="none"?Zt(e,n,c,i):"",g=o?.includes("tauri")?ea(c):"",C=y?Yt(c):"",M=s?.includes("native")?Xt():"",_=s?.includes("web"),st=s?.includes("native"),ct=_||st;Kt(`${P.cyan("1.")} ${w}
134
- ${r?"":`${P.cyan("2.")} ${t} install
135
- `}${P.cyan(r?"2.":"3.")} ${c} dev
136
-
137
- ${P.bold("Your project will be available at:")}
138
- ${ct?`${_?`${P.cyan("\u2022")} Frontend: http://localhost:3001
139
- `:""}`:`${P.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
140
- `}${P.cyan("\u2022")} API: http://localhost:3000
141
- ${M?`
142
- ${M.trim()}`:""}${v?`
143
- ${v.trim()}`:""}${g?`
144
- ${g.trim()}`:""}${C?`
145
- ${C.trim()}`:""}`,"Next steps")}function Xt(){return`${P.yellow("NOTE:")} For Expo connectivity issues, update apps/native/.env
142
+ import { stream } from "hono/streaming";`,i=`
143
+ app.post("/ai", async (c) => {
144
+ const body = await c.req.json();
145
+ const messages = body.messages || [];
146
+
147
+ const result = streamText({
148
+ model: google("gemini-2.0-flash-exp"),
149
+ messages,
150
+ });
151
+
152
+ c.header("X-Vercel-AI-Data-Stream", "v1");
153
+ c.header("Content-Type", "text/plain; charset=utf-8");
154
+
155
+ return stream(c, (stream) => stream.pipe(result.toDataStream()));
156
+ });`;if(t.includes("import {")){let o=t.lastIndexOf("import"),p=t.indexOf(`
157
+ `,o);t=`${t.substring(0,p+1)}
158
+ ${n}
159
+ ${t.substring(p+1)}`}else t=`${n}
160
+
161
+ ${t}`;let s=t.indexOf('app.use("/trpc"')||t.indexOf("app.use(trpc(");if(s!==-1)t=`${t.substring(0,s)}${i}
162
+
163
+ ${t.substring(s)}`;else{let o=t.indexOf("export default");o!==-1?t=`${t.substring(0,o)}${i}
164
+
165
+ ${t.substring(o)}`:t=`${t}
166
+
167
+ ${i}`}await w.writeFile(a,t)}}}async function ua(e,a){let t=T.join(e,"apps/web/src/components/header.tsx");if(await w.pathExists(t)){let r=await w.readFile(t,"utf8"),n=/const links = \[\s*([^;]*?)\s*\];/s,i=r.match(n);if(i){let s=i[1];if(!s.includes('"/ai"')){let o=`const links = [
168
+ ${s}${s.trim().endsWith(",")?"":","}
169
+ { to: "/ai", label: "AI Chat" },
170
+ ];`;r=r.replace(n,o),await w.writeFile(t,r)}}}}async function ma(e,a,t,r){let n=T.join($,"template/examples/todo");if(await w.pathExists(n)){let i=T.join(n,`apps/${r}/src/routes/todos.tsx`),s=T.join(e,"apps/web/src/routes/todos.tsx");if(await w.pathExists(i)&&await w.copy(i,s,{overwrite:!0}),a!=="none"){let o=T.join(n,`apps/server/src/routers/with-${a}-todo.ts`),p=T.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(o)&&await w.copy(o,p,{overwrite:!0}),await fa(e)}await ha(e,r)}}async function fa(e){let a=T.join(e,"apps/server/src/routers/index.ts");if(await w.pathExists(a)){let t=await w.readFile(a,"utf8");if(!t.includes("import { todoRouter }")){let r=t.lastIndexOf("import"),n=t.indexOf(`
171
+
172
+ `,r);n!==-1?t=`${t.slice(0,n)}
173
+ import { todoRouter } from "./todo";${t.slice(n)}`:t=`import { todoRouter } from "./todo";
174
+ ${t}`;let i=t.indexOf("export const appRouter = router({");if(i!==-1){let s=t.indexOf("{",i)+1;t=`${t.slice(0,s)}
175
+ todo: todoRouter,${t.slice(s)}`}await w.writeFile(a,t)}}}async function ha(e,a){let t=T.join(e,"apps/web/src/components/header.tsx");if(await w.pathExists(t)){let r=await w.readFile(t,"utf8"),n=/const links = \[\s*([^;]*?)\s*\];/s,i=r.match(n);if(i){let s=i[1];if(!s.includes('"/todos"')){let o=`const links = [
176
+ ${s}${s.trim().endsWith(",")?"":","}
177
+ { to: "/todos", label: "Todos" },
178
+ ];`;r=r.replace(n,o),await w.writeFile(t,r)}}}}async function ga(e,a){if(a==="drizzle"){let r=T.join(e,"apps/server/src/db/schema/todo.ts");await w.pathExists(r)&&await w.remove(r)}else if(a==="prisma"){let r=T.join(e,"apps/server/prisma/schema/todo.prisma");await w.pathExists(r)&&await w.remove(r)}let t=T.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(t)&&await w.remove(t),await wa(e)}async function wa(e){let a=T.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)}}import{log as Re,spinner as Fe}from"@clack/prompts";import{$ as Ie}from"execa";import Z from"picocolors";async function Oe({projectDir:e,packageManager:a,addons:t=[]}){let r=Fe();try{r.start(`Running ${a} install...`),await Ie({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await ba(e,a)}catch(n){throw r.stop(Z.red("Failed to install dependencies")),n instanceof Error&&Re.error(Z.red(`Installation error: ${n.message}`)),n}}async function ba(e,a){let t=Fe();try{t.start("Running Biome format check..."),await Ie({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(Z.yellow("Biome check encountered issues")),Re.warn(Z.yellow("Some files may need manual formatting"))}}import{note as Pa}from"@clack/prompts";import y from"picocolors";function Se(e,a,t,r,n,i,s,o){let p=t==="npm"?"npm run":t,c=`cd ${a}`,d=i?.includes("husky")||i?.includes("biome"),j=e!=="none"?va(e,n,p,s):"",A=i?.includes("tauri")?ka(p):"",b=d?ja(p):"",v=o?.includes("native")?ya():"",x=i?.includes("pwa")&&o?.includes("react-router")?xa():"",F=o?.includes("tanstack-router"),L=o?.includes("react-router"),ce=F||L,vt=o?.includes("native"),kt=ce||vt;Pa(`${y.cyan("1.")} ${c}
179
+ ${r?"":`${y.cyan("2.")} ${t} install
180
+ `}${y.cyan(r?"2.":"3.")} ${p} dev
181
+
182
+ ${y.bold("Your project will be available at:")}
183
+ ${kt?`${ce?`${y.cyan("\u2022")} Frontend: http://localhost:${L?"5173":"3001"}
184
+ `:""}`:`${y.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
185
+ `}${y.cyan("\u2022")} API: http://localhost:3000
186
+ ${v?`
187
+ ${v.trim()}`:""}${j?`
188
+ ${j.trim()}`:""}${A?`
189
+ ${A.trim()}`:""}${b?`
190
+ ${b.trim()}`:""}${x?`
191
+ ${x.trim()}`:""}`,"Next steps")}function ya(){return`${y.yellow("NOTE:")} For Expo connectivity issues, update apps/native/.env
146
192
  with your local IP:
147
193
  EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000
148
- `}function Yt(e){return`${P.bold(`
194
+ `}function ja(e){return`${y.bold(`
149
195
  Linting and formatting:`)}
150
- ${P.cyan("\u2022")} Format and lint fix: ${`${e} check`}
196
+ ${y.cyan("\u2022")} Format and lint fix: ${`${e} check`}
151
197
 
152
- `}function Zt(e,a,t,r){let n=[];return a==="prisma"?(e==="sqlite"&&n.push(`${P.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,"Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso"),r==="bun"&&n.push(`${P.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors, follow the guidance provided in the error messages`),n.push(`${P.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${P.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)):a==="drizzle"&&(e==="sqlite"&&n.push(`${P.cyan("\u2022")} Start local DB: ${`cd apps/server && ${t} db:local`}`),n.push(`${P.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${P.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)),n.length?`${P.bold("Database commands:")}
198
+ `}function va(e,a,t,r){let n=[];return a==="prisma"?(e==="sqlite"&&n.push(`${y.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,"Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso"),r==="bun"&&n.push(`${y.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors,
199
+ follow the guidance provided in the error messages`),n.push(`${y.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${y.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)):a==="drizzle"&&(e==="sqlite"&&n.push(`${y.cyan("\u2022")} Start local DB: ${`cd apps/server && ${t} db:local`}`),n.push(`${y.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${y.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)),n.length?`${y.bold("Database commands:")}
153
200
  ${n.join(`
154
201
  `)}
155
202
 
156
- `:""}function ea(e){return`${P.bold("Desktop app with Tauri:")}
157
- ${P.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
158
- ${P.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
159
- ${P.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: https://v2.tauri.app/start/prerequisites/
203
+ `:""}function ka(e){return`
204
+ ${y.bold("Desktop app with Tauri:")}
205
+ ${y.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
206
+ ${y.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
207
+ ${y.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies.
208
+ See: https://v2.tauri.app/start/prerequisites/
160
209
 
161
- `}import H from"node:path";import{log as ta}from"@clack/prompts";import{$ as Te,execa as aa}from"execa";import F from"fs-extra";import ra from"picocolors";async function Ee(e,a){await na(e,a),await oa(e,a)}async function na(e,a){let t=H.join(e,"package.json");if(await F.pathExists(t)){let r=await F.readJson(t);r.name=a.projectName;let{stdout:n}=await aa(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await F.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let o=H.join(k,"template/with-pnpm/pnpm-workspace.yaml"),i=H.join(e,"pnpm-workspace.yaml");await F.pathExists(o)&&await F.copy(o,i)}}}async function oa(e,a){let t=H.join(e,"apps/server/package.json");if(await F.pathExists(t)){let r=await F.readJson(t);a.database!=="none"&&(a.database==="sqlite"&&(r.scripts["db:local"]="turso dev --db-file local.db"),a.orm==="prisma"?(r.scripts["db:push"]="prisma db push --schema ./prisma/schema",r.scripts["db:studio"]="prisma studio"):a.orm==="drizzle"&&(r.scripts["db:push"]="drizzle-kit push",r.scripts["db:studio"]="drizzle-kit studio")),await F.writeJson(t,r,{spaces:2})}}async function $e(e,a){if(!a)return;if((await Te({cwd:e,reject:!1,stderr:"pipe"})`git --version`).exitCode!==0){ta.warn(ra.yellow("Git is not installed"));return}let r=await Te({cwd:e,reject:!1,stderr:"pipe"})`git init`;if(r.exitCode!==0)throw new Error(`Git initialization failed: ${r.stderr}`)}import W from"node:path";import S from"fs-extra";async function Ce(e,a,t){let r=W.join(e,"apps/server"),n=W.join(r,"src/index.ts"),o=await S.readFile(n,"utf-8");a==="bun"?await ia(r,n,o,t):a==="node"&&await sa(r,n,o,t)}async function ia(e,a,t,r){let n=W.join(e,"package.json"),o=await S.readJson(n);if(o.scripts={...o.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await S.writeJson(n,o,{spaces:2}),b({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let i=`${t}
210
+ `}function xa(){return`${y.bold("PWA with React Router v7:")}
211
+ ${y.yellow("NOTE:")} There is a known compatibility issue between VitePWA and React Router v7.
212
+ See: https://github.com/vite-pwa/vite-plugin-pwa/issues/809
213
+ `}import ee from"node:path";import{log as $a}from"@clack/prompts";import{$ as De,execa as Ea}from"execa";import U from"fs-extra";import Ta from"picocolors";async function Le(e,a){await Aa(e,a),await Ca(e,a)}async function Aa(e,a){let t=ee.join(e,"package.json");if(await U.pathExists(t)){let r=await U.readJson(t);r.name=a.projectName;let{stdout:n}=await Ea(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await U.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let i=ee.join($,"template/with-pnpm/pnpm-workspace.yaml"),s=ee.join(e,"pnpm-workspace.yaml");await U.pathExists(i)&&await U.copy(i,s)}}}async function Ca(e,a){let t=ee.join(e,"apps/server/package.json");if(await U.pathExists(t)){let r=await U.readJson(t);a.database!=="none"&&(a.database==="sqlite"&&(r.scripts["db:local"]="turso dev --db-file local.db"),a.orm==="prisma"?(r.scripts["db:push"]="prisma db push --schema ./prisma/schema",r.scripts["db:studio"]="prisma studio"):a.orm==="drizzle"&&(r.scripts["db:push"]="drizzle-kit push",r.scripts["db:studio"]="drizzle-kit studio")),await U.writeJson(t,r,{spaces:2})}}async function Ne(e,a){if(!a)return;if((await De({cwd:e,reject:!1,stderr:"pipe"})`git --version`).exitCode!==0){$a.warn(Ta.yellow("Git is not installed"));return}let r=await De({cwd:e,reject:!1,stderr:"pipe"})`git init`;if(r.exitCode!==0)throw new Error(`Git initialization failed: ${r.stderr}`)}import te from"node:path";import M from"fs-extra";async function _e(e,a,t){let r=te.join(e,"apps/server"),n=te.join(r,"src/index.ts"),i=await M.readFile(n,"utf-8");a==="bun"?await Ra(r,n,i,t):a==="node"&&await Fa(r,n,i,t)}async function Ra(e,a,t,r){let n=te.join(e,"package.json"),i=await M.readJson(n);if(i.scripts={...i.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await M.writeJson(n,i,{spaces:2}),P({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let s=`${t}
162
214
 
163
215
  export default app;
164
- `;await S.writeFile(a,i)}}async function sa(e,a,t,r){let n=W.join(e,"package.json"),o=await S.readJson(n);if(o.scripts={...o.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await S.writeJson(n,o,{spaces:2}),b({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){b({dependencies:["@hono/node-server"],projectDir:e});let i=`import { serve } from "@hono/node-server";
165
- `,s=`
216
+ `;await M.writeFile(a,s)}}async function Fa(e,a,t,r){let n=te.join(e,"package.json"),i=await M.readJson(n);if(i.scripts={...i.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await M.writeJson(n,i,{spaces:2}),P({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){P({dependencies:["@hono/node-server"],projectDir:e});let s=`import { serve } from "@hono/node-server";
217
+ `,o=`
166
218
  serve(
167
219
  {
168
220
  fetch: app.fetch,
@@ -172,11 +224,11 @@ serve(
172
224
  console.log(\`Server is running on http://localhost:\${info.port}\`);
173
225
  },
174
226
  );
175
- `;if(!t.includes("@hono/node-server")){let c=t.lastIndexOf("import"),w=t.substring(0,c),y=t.substring(c),v=w+i+y+s;await S.writeFile(a,v)}}else if(r==="elysia"&&(b({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let i=`import { node } from "@elysiajs/node";
176
- `,s=t.indexOf(`
177
- `,t.indexOf("import")),c=t.substring(0,s+1),w=t.substring(s+1),y=c+i+w;y=y.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await S.writeFile(a,y)}}import u from"node:path";import h from"fs-extra";async function Ae(e){let a=u.join(k,"template/base");if(!await h.pathExists(a))throw new Error(`Template directory not found: ${a}`);await h.copy(a,e)}async function Oe(e,a){if(!a.includes("web")){let t=u.join(e,"apps/web");await h.pathExists(t)&&await h.remove(t)}if(a.includes("native"))await h.writeFile(u.join(e,".npmrc"),`node-linker=hoisted
178
- `);else{let t=u.join(e,"apps/native");await h.pathExists(t)&&await h.remove(t)}}async function Ie(e,a){let t=u.join(k,`template/with-${a}`);await h.pathExists(t)&&await h.copy(t,e,{overwrite:!0})}async function Fe(e,a,t,r){if(a==="none"||t==="none")return;let n=u.join(k,ca(a,t));if(await h.pathExists(n)&&(await h.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let o=u.join(e,"apps/server/prisma/schema/auth.prisma");await h.pathExists(o)&&await h.remove(o)}else if(a==="drizzle"){let o=u.join(e,"apps/server/src/db/schema/auth.ts");await h.pathExists(o)&&await h.remove(o)}}}async function Se(e,a,t,r,n){if(!a)return;let o=u.join(k,"template/with-auth");if(await h.pathExists(o)){let i=u.join(o,"apps/web"),s=u.join(e,"apps/web");await h.copy(i,s,{overwrite:!0});let c=u.join(o,"apps/server/src"),w=u.join(e,"apps/server/src");await h.copy(u.join(c,"lib/trpc.ts"),u.join(w,"lib/trpc.ts"),{overwrite:!0}),await h.copy(u.join(c,"routers/index.ts"),u.join(w,"routers/index.ts"),{overwrite:!0});let y=`with-${t}-context.ts`;await h.copy(u.join(c,"lib",y),u.join(w,"lib/context.ts"),{overwrite:!0});let v=`with-${t}-index.ts`;await h.copy(u.join(c,v),u.join(w,"index.ts"),{overwrite:!0});let g=pa(r,n),C=u.join(c,g);if(await h.pathExists(C)){let M=await h.readdir(C);for(let _ of M)await h.copy(u.join(C,_),u.join(w,"lib",_),{overwrite:!0})}}}async function De(e){let a=[u.join(e,"_gitignore"),u.join(e,"apps/web/_gitignore"),u.join(e,"apps/native/_gitignore"),u.join(e,"apps/server/_gitignore")];for(let t of a)if(await h.pathExists(t)){let r=u.join(u.dirname(t),".gitignore");await h.move(t,r)}}function ca(e,a){return e==="drizzle"?a==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?a==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}function pa(e,a){if(e==="drizzle")return a==="sqlite"?"with-drizzle-sqlite-lib":"with-drizzle-postgres-lib";if(e==="prisma")return a==="sqlite"?"with-prisma-sqlite-lib":"with-prisma-postgres-lib";throw new Error("Invalid ORM or database configuration for auth setup")}async function Le(e){let a=ua(),t=da.resolve(process.cwd(),e.projectName);try{return await ma.ensureDir(t),await Ae(t),await Oe(t,e.frontend),await De(t),await Ie(t,e.backend),await le(t,e.backend,e.runtime),await Fe(t,e.orm,e.database,e.auth),await be(t,e.database,e.orm,e.turso??e.database==="sqlite"),await Se(t,e.auth,e.backend,e.orm,e.database),await de(t,e.auth),await Ce(t,e.runtime,e.backend),await Pe(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await we(t,e),await $e(t,e.git),e.addons.length>0&&await oe(t,e.addons,e.packageManager,e.frontend),await Ee(t,e),await ue(t,e),e.noInstall||await xe({projectDir:t,packageManager:e.packageManager,addons:e.addons}),ke(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(Re.red("Failed")),r instanceof Error&&(la(Re.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as ur,group as mr}from"@clack/prompts";import fr from"picocolors";import{cancel as fa,isCancel as ha,multiselect as ga}from"@clack/prompts";import ba from"picocolors";async function Ne(e,a){if(e!==void 0)return e;let t=a?.includes("web"),r=[{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],o=t?[...[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"}],...r]:r,i=m.addons.filter(c=>t||c!=="pwa"&&c!=="tauri"),s=await ga({message:"Select addons",options:o,initialValues:i,required:!1});return ha(s)&&(fa(ba.red("Operation cancelled")),process.exit(0)),s.includes("husky")&&!s.includes("biome")&&s.push("biome"),s}import{cancel as wa,confirm as Pa,isCancel as ya,log as ja}from"@clack/prompts";import _e from"picocolors";async function Be(e,a,t){if(!a)return!1;let r=t?.includes("native"),n=t?.includes("web");if(r&&ja.warn(_e.yellow("Note: Authentication is not yet available with native")),!n)return!1;if(e!==void 0)return e;let o=await Pa({message:"Add authentication with Better-Auth?",initialValue:m.auth});return ya(o)&&(wa(_e.red("Operation cancelled")),process.exit(0)),o}import{cancel as va,isCancel as xa,select as ka}from"@clack/prompts";import Ta from"picocolors";async function ze(e){if(e!==void 0)return e;let a=await ka({message:"Select backend framework",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"elysia",label:"Elysia",hint:"Ergonomic web framework for building backend servers"}],initialValue:m.backend});return xa(a)&&(va(Ta.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ea,isCancel as $a,select as Ca}from"@clack/prompts";import Aa from"picocolors";async function Me(e){if(e!==void 0)return e;let a=await Ca({message:"Select database",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:m.database});return $a(a)&&(Ea(Aa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Oa,isCancel as Ia,multiselect as Ue}from"@clack/prompts";import Fa from"picocolors";async function Ge(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!t?.includes("web"))return[];let o=[];return r==="elysia"&&(o=await Ue({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:m.examples})),r==="hono"&&(o=await Ue({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"},{value:"ai",label:"AI Chat",hint:"A simple AI chat interface using AI SDK"}],required:!1,initialValues:m.examples})),Ia(o)&&(Oa(Fa.red("Operation cancelled")),process.exit(0)),o}import{cancel as Sa,isCancel as Da,multiselect as Ra}from"@clack/prompts";import La from"picocolors";async function qe(e){if(e!==void 0)return e;let a=await Ra({message:"Choose frontends",options:[{value:"web",label:"Web App",hint:"React + TanStack Router web application"},{value:"native",label:"Native App",hint:"React Native + Expo application"}],initialValues:m.frontend,required:!1});return Da(a)&&(Sa(La.red("Operation cancelled")),process.exit(0)),a}import{cancel as Na,confirm as _a,isCancel as Ba}from"@clack/prompts";import za from"picocolors";async function Je(e){if(e!==void 0)return e;let a=await _a({message:"Initialize git repository?",initialValue:m.git});return Ba(a)&&(Na(za.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ma,confirm as Ua,isCancel as Ga}from"@clack/prompts";import qa from"picocolors";async function Ve(e){if(e!==void 0)return e;let a=await Ua({message:"Install dependencies?",initialValue:!m.noInstall});return Ga(a)&&(Ma(qa.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Ja,isCancel as Va,select as Ha}from"@clack/prompts";import Wa from"picocolors";async function He(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Ha({message:"Select ORM",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:m.orm});return Va(t)&&(Ja(Wa.red("Operation cancelled")),process.exit(0)),t}import{cancel as Qa,isCancel as Ka,select as Xa}from"@clack/prompts";import Ya from"picocolors";async function We(e){if(e!==void 0)return e;let a=U(),t=await Xa({message:"Choose package manager",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:a});return Ka(t)&&(Qa(Ya.red("Operation cancelled")),process.exit(0)),t}import z from"node:path";import{cancel as Za,isCancel as er,text as tr}from"@clack/prompts";import R from"fs-extra";import ar from"picocolors";var rr=["<",">",":",'"',"|","?","*"],Qe=255;function Ke(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Qe)return`Project name must be less than ${Qe} characters`;if(rr.some(a=>e.includes(a)))return"Project name contains invalid characters";if(e.startsWith(".")||e.startsWith("-"))return"Project name cannot start with a dot or dash";if(e.toLowerCase()==="node_modules"||e.toLowerCase()==="favicon.ico")return"Project name is reserved"}}async function Xe(e){if(e)if(e==="."){let o=process.cwd();if(R.readdirSync(o).length===0)return e}else{let o=z.basename(e);if(!Ke(o)){let s=z.resolve(process.cwd(),e);if(!R.pathExistsSync(s)||R.readdirSync(s).length===0)return e}}let a=!1,t="",r=m.projectName,n=1;for(;R.pathExistsSync(z.resolve(process.cwd(),r));)r=`${m.projectName}-${n}`,n++;for(;!a;){let o=await tr({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:i=>{let s=i.trim()||r;if(s==="."){if(R.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let c=z.resolve(process.cwd(),s),w=z.basename(c),y=Ke(w);if(y)return y;if(!c.startsWith(process.cwd()))return"Project path must be within current directory";if(R.pathExistsSync(c)&&R.readdirSync(c).length>0)return`Directory "${s}" already exists and is not empty. Please choose a different name or path.`;a=!0}});er(o)&&(Za(ar.red("Operation cancelled.")),process.exit(0)),t=o||r}return t}import{cancel as nr,isCancel as or,select as ir}from"@clack/prompts";import sr from"picocolors";async function Ye(e){if(e!==void 0)return e;let a=await ir({message:"Select runtime",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:m.runtime});return or(a)&&(nr(sr.red("Operation cancelled")),process.exit(0)),a}import{cancel as cr,confirm as pr,isCancel as dr}from"@clack/prompts";import lr from"picocolors";async function Ze(e){if(e!==void 0)return e;let a=await pr({message:"Set up Turso database?",initialValue:m.turso});return dr(a)&&(cr(lr.red("Operation cancelled")),process.exit(0)),a}async function et(e){let a=await mr({projectName:async()=>Xe(e.projectName),frontend:()=>qe(e.frontend),backend:()=>ze(e.backend),runtime:()=>Ye(e.runtime),database:()=>Me(e.database),orm:({results:t})=>He(e.orm,t.database!=="none"),auth:({results:t})=>Be(e.auth,t.database!=="none",t.frontend),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Ze(e.turso):Promise.resolve(!1),addons:({results:t})=>Ne(e.addons,t.frontend),examples:({results:t})=>Ge(e.examples,t.database,t.frontend,t.backend),git:()=>Je(e.git),packageManager:()=>We(e.packageManager),noInstall:()=>Ve(e.noInstall)},{onCancel:()=>{ur(fr.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,frontend:a.frontend,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,turso:a.turso,backend:a.backend,runtime:a.runtime}}import $ from"picocolors";function Z(e){let a=[];if(e.projectName&&a.push(`${$.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${$.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${$.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${$.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${$.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${$.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${$.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${$.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${$.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${$.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${$.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${$.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${$.blue("Turso Setup:")} ${e.turso}`),a.join(`
179
- `)}function tt(e){let a=[];e.database==="none"?a.push("--database none"):(a.push(`--database ${e.database}`),e.orm&&a.push(`--orm ${e.orm}`),e.database==="sqlite"&&a.push(e.turso?"--turso":"--no-turso")),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.runtime&&a.push(`--runtime ${e.runtime}`),e.backend&&a.push(`--backend ${e.backend}`),e.frontend&&e.frontend.length>0&&a.push(`--frontend ${e.frontend.join(" ")}`),e.addons&&e.addons.length>0?a.push(`--addons ${e.addons.join(" ")}`):a.push("--addons none"),e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(" ")}`):a.push("--no-examples"),e.packageManager&&a.push(`--package-manager ${e.packageManager}`);let t="",r=e.packageManager;r==="npm"?t="npx create-better-t-stack@latest":r==="pnpm"?t="pnpm create better-t-stack@latest":r==="bun"&&(t="bun create better-t-stack@latest");let n=e.projectName?` ${e.projectName}`:"";return`${t}${n} ${a.join(" ")}`}import hr from"node:path";import gr from"fs-extra";var at=()=>{let e=hr.join(k,"package.json");return gr.readJSONSync(e).version??"1.0.0"};import rt from"gradient-string";var nt=`
227
+ `;if(!t.includes("@hono/node-server")){let p=t.lastIndexOf("import"),c=t.substring(0,p),d=t.substring(p),j=c+s+d+o;await M.writeFile(a,j)}}else if(r==="elysia"&&(P({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let s=`import { node } from "@elysiajs/node";
228
+ `,o=t.indexOf(`
229
+ `,t.indexOf("import")),p=t.substring(0,o+1),c=t.substring(o+1),d=p+s+c;d=d.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await M.writeFile(a,d)}}import u from"node:path";import l from"fs-extra";async function Ue(e){let a=u.join($,"template/base");if(!await l.pathExists(a))throw new Error(`Template directory not found: ${a}`);await l.ensureDir(e);let t=await l.readdir(a);for(let i of t){let s=u.join(a,i),o=u.join(e,i);i!=="apps"&&(await l.stat(s).then(p=>p.isDirectory())?await l.copy(s,o):await l.copy(s,o))}await l.ensureDir(u.join(e,"apps"));let r=u.join(a,"apps/server"),n=u.join(e,"apps/server");await l.pathExists(r)&&await l.copy(r,n)}async function Me(e,a){let t=a.includes("tanstack-router"),r=a.includes("react-router"),n=a.includes("native");if(t||r){let i=u.join(e,"apps/web");await l.ensureDir(i);let s=u.join($,"template/base/apps/web-base");await l.pathExists(s)&&await l.copy(s,i);let o=t?"web-tanstack-router":"web-react-router",p=u.join($,`template/base/apps/${o}`);await l.pathExists(p)&&await l.copy(p,i,{overwrite:!0});let c=u.join(i,"package.json");if(await l.pathExists(c)){let d=await l.readJson(c);d.name="web",await l.writeJson(c,d,{spaces:2})}}if(n){let i=u.join($,"template/base/apps/native"),s=u.join(e,"apps/native");await l.pathExists(i)&&await l.copy(i,s),await l.writeFile(u.join(e,".npmrc"),`node-linker=hoisted
230
+ `)}}async function Be(e,a){let t=u.join($,`template/with-${a}`);await l.pathExists(t)&&await l.copy(t,e,{overwrite:!0})}async function ze(e,a,t,r){if(a==="none"||t==="none")return;let n=u.join($,Ia(a,t));if(await l.pathExists(n)&&(await l.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let i=u.join(e,"apps/server/prisma/schema/auth.prisma");await l.pathExists(i)&&await l.remove(i)}else if(a==="drizzle"){let i=u.join(e,"apps/server/src/db/schema/auth.ts");await l.pathExists(i)&&await l.remove(i)}}}async function Ge(e,a,t,r,n,i){if(!a)return;let s=u.join($,"template/with-auth");if(await l.pathExists(s)){let o=i.includes("react-router"),p=i.includes("tanstack-router");if(o||p){let x=u.join(e,"apps/web"),F=u.join(s,"apps/web-base");if(await l.pathExists(F)&&await l.copy(F,x,{overwrite:!0}),o){let L=u.join(s,"apps/web-react-router");await l.pathExists(L)&&await l.copy(L,x,{overwrite:!0})}if(p){let L=u.join(s,"apps/web-tanstack-router");await l.pathExists(L)&&await l.copy(L,x,{overwrite:!0})}}let c=u.join(s,"apps/server/src"),d=u.join(e,"apps/server/src");await l.copy(u.join(c,"lib/trpc.ts"),u.join(d,"lib/trpc.ts"),{overwrite:!0}),await l.copy(u.join(c,"routers/index.ts"),u.join(d,"routers/index.ts"),{overwrite:!0});let j=`with-${t}-context.ts`;await l.copy(u.join(c,"lib",j),u.join(d,"lib/context.ts"),{overwrite:!0});let A=`with-${t}-index.ts`;await l.copy(u.join(c,A),u.join(d,"index.ts"),{overwrite:!0});let b=Oa(r,n),v=u.join(c,b);if(await l.pathExists(v)){let x=await l.readdir(v);for(let F of x)await l.copy(u.join(v,F),u.join(d,"lib",F),{overwrite:!0})}if(i.includes("native")){let x=u.join(s,"apps/native"),F=u.join(e,"apps/native");await l.pathExists(x)&&await l.copy(x,F,{overwrite:!0})}}}async function Ve(e){let a=await qe(e);for(let t of a)if(await l.pathExists(t)){let r=u.join(u.dirname(t),".gitignore");await l.move(t,r,{overwrite:!0})}}async function qe(e){let a=[],t=u.join(e,"_gitignore");await l.pathExists(t)&&a.push(t);try{let r=await l.readdir(e,{withFileTypes:!0});for(let n of r)if(n.isDirectory()&&n.name!=="node_modules"){let i=u.join(e,n.name),s=await qe(i);a.push(...s)}}catch{}return a}function Ia(e,a){return e==="drizzle"?a==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?a==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}function Oa(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 We(e){let a=La(),t=Sa.resolve(process.cwd(),e.projectName);try{return await Na.ensureDir(t),await Ue(t),await Me(t,e.frontend),await Ve(t),await Be(t,e.backend),await Pe(t,e.backend,e.runtime),await ze(t,e.orm,e.database,e.auth),await Te(t,e.database,e.orm,e.packageManager,e.turso??e.database==="sqlite"),await Ge(t,e.auth,e.backend,e.orm,e.database,e.frontend),await be(t,e.auth),await _e(t,e.runtime,e.backend),await Ce(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await Ae(t,e),await Ne(t,e.git),e.addons.length>0&&await me(t,e.addons,e.packageManager,e.frontend),await Le(t,e),await ye(t,e),e.noInstall||await Oe({projectDir:t,packageManager:e.packageManager,addons:e.addons}),Se(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(Je.red("Failed")),r instanceof Error&&(Da(Je.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as _r,group as Ur}from"@clack/prompts";import Mr from"picocolors";import{cancel as _a,isCancel as Ua,multiselect as Ma}from"@clack/prompts";import Ba from"picocolors";async function He(e,a){if(e!==void 0)return e;let t=a?.includes("react-router")||a?.includes("tanstack-router"),r=[{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],i=t?[...[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"}],...r]:r,s=g.addons.filter(p=>t||p!=="pwa"&&p!=="tauri"),o=await Ma({message:"Select addons",options:i,initialValues:s,required:!1});return Ua(o)&&(_a(Ba.red("Operation cancelled")),process.exit(0)),o.includes("husky")&&!o.includes("biome")&&o.push("biome"),o}import{cancel as za,confirm as Ga,isCancel as Va,log as qa}from"@clack/prompts";import Qe from"picocolors";async function Ke(e,a,t){if(!a)return!1;let r=t?.includes("native"),n=t?.includes("tanstack-router")||t?.includes("react-router");if(r&&qa.warn(Qe.yellow("Note: Authentication is not yet available with native")),!n)return!1;if(e!==void 0)return e;let i=await Ga({message:"Add authentication with Better-Auth?",initialValue:g.auth});return Va(i)&&(za(Qe.red("Operation cancelled")),process.exit(0)),i}import{cancel as Ja,isCancel as Wa,select as Ha}from"@clack/prompts";import Qa from"picocolors";async function Xe(e){if(e!==void 0)return e;let a=await Ha({message:"Select backend framework",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"elysia",label:"Elysia",hint:"Ergonomic web framework for building backend servers"}],initialValue:g.backend});return Wa(a)&&(Ja(Qa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ka,isCancel as Xa,select as Ya}from"@clack/prompts";import Za from"picocolors";async function Ye(e){if(e!==void 0)return e;let a=await Ya({message:"Select database",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:g.database});return Xa(a)&&(Ka(Za.red("Operation cancelled")),process.exit(0)),a}import{cancel as er,isCancel as tr,multiselect as Ze}from"@clack/prompts";import ar from"picocolors";async function et(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!(t?.includes("react-router")||t?.includes("tanstack-router")))return[];let i=[];return r==="elysia"&&(i=await Ze({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:g.examples})),r==="hono"&&(i=await Ze({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"},{value:"ai",label:"AI Chat",hint:"A simple AI chat interface using AI SDK"}],required:!1,initialValues:g.examples})),tr(i)&&(er(ar.red("Operation cancelled")),process.exit(0)),i}import{cancel as tt,isCancel as at,multiselect as rr,select as nr}from"@clack/prompts";import rt from"picocolors";async function nt(e){if(e!==void 0)return e;let a=await rr({message:"Select platforms to develop for",options:[{value:"web",label:"Web",hint:"React Web Application"},{value:"native",label:"Native",hint:"Create a React Native/Expo app"}],initialValues:g.frontend.some(r=>r==="tanstack-router"||r==="react-router")?["web"]:[]});at(a)&&(tt(rt.red("Operation cancelled")),process.exit(0));let t=[];if(a.includes("web")){let r=await nr({message:"Choose frontend framework",options:[{value:"tanstack-router",label:"TanStack Router",hint:"Modern and scalable routing for React Applications"},{value:"react-router",label:"React Router",hint:"A user\u2011obsessed, standards\u2011focused, multi\u2011strategy router you can deploy anywhere."}],initialValue:g.frontend.find(n=>n==="tanstack-router"||n==="react-router")||"tanstack-router"});at(r)&&(tt(rt.red("Operation cancelled")),process.exit(0)),t.push(r)}return a.includes("native")&&t.push("native"),t}import{cancel as ir,confirm as sr,isCancel as or}from"@clack/prompts";import cr from"picocolors";async function it(e){if(e!==void 0)return e;let a=await sr({message:"Initialize git repository?",initialValue:g.git});return or(a)&&(ir(cr.red("Operation cancelled")),process.exit(0)),a}import{cancel as pr,confirm as lr,isCancel as dr}from"@clack/prompts";import ur from"picocolors";async function st(e){if(e!==void 0)return e;let a=await lr({message:"Install dependencies?",initialValue:!g.noInstall});return dr(a)&&(pr(ur.red("Operation cancelled")),process.exit(0)),!a}import{cancel as mr,isCancel as fr,select as hr}from"@clack/prompts";import gr from"picocolors";async function ot(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await hr({message:"Select ORM",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:g.orm});return fr(t)&&(mr(gr.red("Operation cancelled")),process.exit(0)),t}import{cancel as wr,isCancel as br,select as Pr}from"@clack/prompts";import yr from"picocolors";async function ct(e){if(e!==void 0)return e;let a=H(),t=await Pr({message:"Choose package manager",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:a});return br(t)&&(wr(yr.red("Operation cancelled")),process.exit(0)),t}import{cancel as jr,confirm as vr,isCancel as kr}from"@clack/prompts";import xr from"picocolors";async function pt(e){if(e!==void 0)return e;let a=await vr({message:"Set up Prisma Postgres database?",initialValue:g.prismaPostgres});return kr(a)&&(jr(xr.red("Operation cancelled")),process.exit(0)),a}import W from"node:path";import{cancel as $r,isCancel as Er,text as Tr}from"@clack/prompts";import z from"fs-extra";import Ar from"picocolors";var Cr=["<",">",":",'"',"|","?","*"],lt=255;function dt(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>lt)return`Project name must be less than ${lt} characters`;if(Cr.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 ut(e){if(e)if(e==="."){let i=process.cwd();if(z.readdirSync(i).length===0)return e}else{let i=W.basename(e);if(!dt(i)){let o=W.resolve(process.cwd(),e);if(!z.pathExistsSync(o)||z.readdirSync(o).length===0)return e}}let a=!1,t="",r=g.projectName,n=1;for(;z.pathExistsSync(W.resolve(process.cwd(),r));)r=`${g.projectName}-${n}`,n++;for(;!a;){let i=await Tr({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:s=>{let o=s.trim()||r;if(o==="."){if(z.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let p=W.resolve(process.cwd(),o),c=W.basename(p),d=dt(c);if(d)return d;if(!p.startsWith(process.cwd()))return"Project path must be within current directory";if(z.pathExistsSync(p)&&z.readdirSync(p).length>0)return`Directory "${o}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Er(i)&&($r(Ar.red("Operation cancelled.")),process.exit(0)),t=i||r}return t}import{cancel as Rr,isCancel as Fr,select as Ir}from"@clack/prompts";import Or from"picocolors";async function mt(e){if(e!==void 0)return e;let a=await Ir({message:"Select runtime",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:g.runtime});return Fr(a)&&(Rr(Or.red("Operation cancelled")),process.exit(0)),a}import{cancel as Sr,confirm as Dr,isCancel as Lr}from"@clack/prompts";import Nr from"picocolors";async function ft(e){if(e!==void 0)return e;let a=await Dr({message:"Set up Turso database?",initialValue:g.turso});return Lr(a)&&(Sr(Nr.red("Operation cancelled")),process.exit(0)),a}async function ht(e){let a=await Ur({projectName:async()=>ut(e.projectName),frontend:()=>nt(e.frontend),backend:()=>Xe(e.backend),runtime:()=>mt(e.runtime),database:()=>Ye(e.database),orm:({results:t})=>ot(e.orm,t.database!=="none"),auth:({results:t})=>Ke(e.auth,t.database!=="none",t.frontend),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?ft(e.turso):Promise.resolve(!1),prismaPostgres:({results:t})=>t.database==="postgres"&&t.orm==="prisma"?pt(e.prismaPostgres):Promise.resolve(!1),addons:({results:t})=>He(e.addons,t.frontend),examples:({results:t})=>et(e.examples,t.database,t.frontend,t.backend),git:()=>it(e.git),packageManager:()=>ct(e.packageManager),noInstall:()=>st(e.noInstall)},{onCancel:()=>{_r(Mr.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,prismaPostgres:a.prismaPostgres,backend:a.backend,runtime:a.runtime}}import C from"picocolors";function se(e){let a=[];if(e.projectName&&a.push(`${C.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${C.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${C.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${C.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${C.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${C.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${C.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${C.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${C.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${C.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${C.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${C.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${C.blue("Turso Setup:")} ${e.turso}`),e.prismaPostgres!==void 0&&a.push(`${C.blue("Prisma Postgres Setup:")} ${e.prismaPostgres?"Yes":"No"}`),a.join(`
231
+ `)}function gt(e){let a=[];e.database==="none"?a.push("--database none"):(a.push(`--database ${e.database}`),e.orm&&a.push(`--orm ${e.orm}`),e.database==="sqlite"&&a.push(e.turso?"--turso":"--no-turso")),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.runtime&&a.push(`--runtime ${e.runtime}`),e.backend&&a.push(`--backend ${e.backend}`),e.frontend&&e.frontend.length>0&&a.push(`--frontend ${e.frontend.join(" ")}`),e.addons&&e.addons.length>0?a.push(`--addons ${e.addons.join(" ")}`):a.push("--addons none"),e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(" ")}`):a.push("--no-examples"),e.packageManager&&a.push(`--package-manager ${e.packageManager}`);let t="",r=e.packageManager;r==="npm"?t="npx create-better-t-stack@latest":r==="pnpm"?t="pnpm create better-t-stack@latest":r==="bun"&&(t="bun create better-t-stack@latest");let n=e.projectName?` ${e.projectName}`:"";return`${t}${n} ${a.join(" ")}`}import Br from"node:path";import zr from"fs-extra";var wt=()=>{let e=Br.join($,"package.json");return zr.readJSONSync(e).version??"1.0.0"};import bt from"gradient-string";var Pt=`
180
232
  \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
181
233
  \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
182
234
  \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
@@ -190,10 +242,10 @@ serve(
190
242
  \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
191
243
  \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
192
244
  \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
193
- `,ot={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},it=()=>{let e=process.stdout.columns||80,a=nt.split(`
194
- `),t=Math.max(...a.map(r=>r.length));e<t?console.log(rt(Object.values(ot)).multiline(`
245
+ `,yt={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},jt=()=>{let e=process.stdout.columns||80,a=Pt.split(`
246
+ `),t=Math.max(...a.map(r=>r.length));e<t?console.log(bt(Object.values(yt)).multiline(`
195
247
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
196
248
  \u2551 Better T-Stack \u2551
197
249
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
198
- `)):console.log(rt(Object.values(ot)).multiline(nt))};process.on("SIGINT",()=>{E.error(l.red("Operation cancelled")),process.exit(0)});var ee=new yr;async function jr(){let e=Date.now();ee.name("create-better-t-stack").description("Create a new Better-T Stack project").version(at()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--database <type>","Database type (none, sqlite, postgres)").option("--orm <type>","ORM type (none, drizzle, prisma)").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--frontend <types...>","Frontend types (web, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, biome, husky, none)").option("--examples <types...>","Examples to include (todo, ai)").option("--no-examples","Skip all examples").option("--git","Initialize git repository").option("--no-git","Skip git initialization").option("--package-manager <pm>","Package manager (npm, pnpm, bun)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup").option("--backend <framework>","Backend framework (hono, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=Pr();try{it(),br(l.magenta("Creating a new Better-T-Stack project"));let t=ee.opts(),r=ee.args[0];vr(t);let n=xr(t,r);!t.yes&&Object.keys(n).length>0&&(E.info(l.yellow("Using these pre-selected options:")),E.message(Z(n)),E.message(""));let o=t.yes?{...m,projectName:r??m.projectName,...n}:await et(n);t.yes&&(E.info(l.yellow("Using these default options:")),E.message(Z(o)),E.message("")),await Le(o),E.success(l.blue(`You can reproduce this setup with the following command:
199
- ${l.white(tt(o))}`));let i=((Date.now()-e)/1e3).toFixed(2);wr(l.magenta(`Project created successfully in ${l.bold(i)} seconds!`))}catch(t){a.stop(l.red("Failed")),t instanceof Error&&(j(l.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function vr(e){if(e.database&&!["none","sqlite","postgres"].includes(e.database)&&(j(l.red(`Invalid database type: ${e.database}. Must be none, sqlite, or postgres.`)),process.exit(1)),e.orm&&!["none","drizzle","prisma"].includes(e.orm)&&(j(l.red(`Invalid ORM type: ${e.orm}. Must be none, drizzle, or prisma.`)),process.exit(1)),e.database==="none"&&(e.auth===!0&&(j(l.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(j(l.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),"turso"in e&&e.turso===!0&&(j(l.red("Turso setup requires a SQLite database. Cannot use --turso with --database none.")),process.exit(1))),"turso"in e&&e.turso===!0&&e.database&&e.database!=="sqlite"&&(j(l.red(`Turso setup requires a SQLite database. Cannot use --turso with --database ${e.database}`)),process.exit(1)),"turso"in e&&e.turso===!0&&e.orm==="prisma"&&(j(l.red("Turso setup is not compatible with Prisma. Cannot use --turso with --orm prisma")),process.exit(1)),e.packageManager&&!["npm","pnpm","bun"].includes(e.packageManager)&&(j(l.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),e.backend&&!["hono","elysia"].includes(e.backend)&&(j(l.red(`Invalid backend framework: ${e.backend}. Must be hono or elysia.`)),process.exit(1)),e.runtime&&!["bun","node"].includes(e.runtime)&&(j(l.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),e.examples&&Array.isArray(e.examples)&&e.examples.length>0){let a=["todo","ai"],t=e.examples.filter(r=>!a.includes(r));t.length>0&&(j(l.red(`Invalid example(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&e.backend==="elysia"&&(j(l.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1)),e.frontend&&!e.frontend.includes("web")&&!e.frontend.includes("none")&&(j(l.red("Examples require a web frontend. Cannot use --examples with --frontend native only")),process.exit(1))}if(e.frontend&&e.frontend.length>0){let a=["web","native","none"],t=e.frontend.filter(r=>!a.includes(r));t.length>0&&(j(l.red(`Invalid frontend(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.frontend.includes("none")&&e.frontend.length>1&&(j(l.red("Cannot combine 'none' with other frontend options.")),process.exit(1))}if(e.addons&&Array.isArray(e.addons)&&e.addons.length>0){let a=["pwa","tauri","biome","husky","none"],t=e.addons.filter(o=>!a.includes(o));t.length>0&&(j(l.red(`Invalid addon(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.addons.includes("none")&&e.addons.length>1&&(j(l.red("Cannot combine 'none' with other addons.")),process.exit(1));let r=["pwa","tauri"];e.addons.some(o=>r.includes(o))&&e.frontend&&!e.frontend.includes("web")&&!e.frontend.includes("none")&&(j(l.red(`PWA and Tauri addons require a web frontend. Cannot use --addons ${e.addons.filter(o=>r.includes(o)).join(", ")} with --frontend native only`)),process.exit(1))}}function xr(e,a){let t;e.frontend&&(e.frontend.includes("none")?t=[]:t=e.frontend.filter(g=>g==="web"||g==="native"));let r=e.database,n;e.orm&&(n=e.orm);let o="auth"in e?e.auth:void 0,i="turso"in e?e.turso:void 0;r==="none"&&(n="none",o=!1,i=!1);let s;"examples"in e&&(e.examples===!1?s=[]:Array.isArray(e.examples)&&(s=e.examples.filter(g=>g==="todo"||g==="ai"),t&&t.length>0&&!t.includes("web")&&(s=[],E.warn(l.yellow("Examples require web frontend - ignoring examples flag"))),s.includes("ai")&&e.backend==="elysia"&&(s=s.filter(g=>g!=="ai"),E.warn(l.yellow("AI example is not compatible with Elysia - removing AI example")))));let c;e.addons&&Array.isArray(e.addons)&&(e.addons.includes("none")?c=[]:(c=e.addons.filter(g=>g==="pwa"||g==="tauri"||g==="biome"||g==="husky"),t&&t.length>0&&!t.includes("web")&&(c=c.filter(g=>!["pwa","tauri"].includes(g)),c.length!==e.addons.length&&E.warn(l.yellow("PWA and Tauri addons require web frontend - removing these addons"))),c.includes("husky")&&!c.includes("biome")&&c.push("biome")));let w=e.backend,y=e.runtime,v=e.packageManager;return{...a&&{projectName:a},...r!==void 0&&{database:r},...n!==void 0&&{orm:n},...o!==void 0&&{auth:o},...v&&{packageManager:v},..."git"in e&&{git:e.git},..."install"in e&&{noInstall:!e.install},...i!==void 0&&{turso:i},...w&&{backend:w},...y&&{runtime:y},...t!==void 0&&{frontend:t},...c!==void 0&&{addons:c},...s!==void 0&&{examples:s}}}jr().catch(e=>{E.error("Aborting installation..."),e instanceof Error?E.error(e.message):(E.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
250
+ `)):console.log(bt(Object.values(yt)).multiline(Pt))};process.on("SIGINT",()=>{R.error(h.red("Operation cancelled")),process.exit(0)});var oe=new Jr;async function Wr(){let e=Date.now();oe.name("create-better-t-stack").description("Create a new Better-T Stack project").version(wt()).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 (tanstack-router, react-router, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, biome, husky, none)").option("--examples <types...>","Examples to include (todo, ai)").option("--no-examples","Skip all examples").option("--git","Initialize git repository").option("--no-git","Skip git initialization").option("--package-manager <pm>","Package manager (npm, pnpm, bun)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup").option("--prisma-postgres","Set up Prisma Postgres").option("--no-prisma-postgres","Skip Prisma Postgres setup").option("--backend <framework>","Backend framework (hono, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=qr();try{jt(),Gr(h.magenta("Creating a new Better-T-Stack project"));let t=oe.opts(),r=oe.args[0];Hr(t);let n=Qr(t,r);!t.yes&&Object.keys(n).length>0&&(R.info(h.yellow("Using these pre-selected options:")),R.message(se(n)),R.message(""));let i=t.yes?{...g,projectName:r??g.projectName,...n}:await ht(n);t.yes&&(R.info(h.yellow("Using these default options:")),R.message(se(i)),R.message("")),await We(i),R.success(h.blue(`You can reproduce this setup with the following command:
251
+ ${h.white(gt(i))}`));let s=((Date.now()-e)/1e3).toFixed(2);Vr(h.magenta(`Project created successfully in ${h.bold(s)} seconds!`))}catch(t){a.stop(h.red("Failed")),t instanceof Error&&(k(h.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function Hr(e){if(e.database&&!["none","sqlite","postgres"].includes(e.database)&&(k(h.red(`Invalid database type: ${e.database}. Must be none, sqlite, or postgres.`)),process.exit(1)),e.orm&&!["none","drizzle","prisma"].includes(e.orm)&&(k(h.red(`Invalid ORM type: ${e.orm}. Must be none, drizzle, or prisma.`)),process.exit(1)),e.database==="none"&&(e.auth===!0&&(k(h.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(k(h.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),"turso"in e&&e.turso===!0&&(k(h.red("Turso setup requires a SQLite database. Cannot use --turso with --database none.")),process.exit(1))),"turso"in e&&e.turso===!0&&e.database&&e.database!=="sqlite"&&(k(h.red(`Turso setup requires a SQLite database. Cannot use --turso with --database ${e.database}`)),process.exit(1)),"turso"in e&&e.turso===!0&&e.orm==="prisma"&&(k(h.red("Turso setup is not compatible with Prisma. Cannot use --turso with --orm prisma")),process.exit(1)),"prismaPostgres"in e&&e.prismaPostgres===!0&&(e.database&&e.database!=="postgres"||e.orm&&e.orm!=="prisma")&&(k(h.red("Prisma PostgreSQL setup requires PostgreSQL database with Prisma ORM. Cannot use --prisma-postgres with incompatible database or ORM options.")),process.exit(1)),e.packageManager&&!["npm","pnpm","bun"].includes(e.packageManager)&&(k(h.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),e.backend&&!["hono","elysia"].includes(e.backend)&&(k(h.red(`Invalid backend framework: ${e.backend}. Must be hono or elysia.`)),process.exit(1)),e.runtime&&!["bun","node"].includes(e.runtime)&&(k(h.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),e.examples&&Array.isArray(e.examples)&&e.examples.length>0){let a=["todo","ai"],t=e.examples.filter(r=>!a.includes(r));t.length>0&&(k(h.red(`Invalid example(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&e.backend==="elysia"&&(k(h.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1)),e.frontend&&!e.frontend.some(r=>["tanstack-router","react-router"].includes(r))&&!e.frontend.includes("none")&&(k(h.red("Examples require a web frontend. Cannot use --examples with --frontend native only")),process.exit(1))}if(e.frontend&&e.frontend.length>0){let a=["tanstack-router","react-router","native","none"],t=e.frontend.filter(n=>!a.includes(n));t.length>0&&(k(h.red(`Invalid frontend(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.frontend.filter(n=>n==="tanstack-router"||n==="react-router").length>1&&(k(h.red("Cannot select multiple web frameworks. Choose only one of: tanstack-router, react-router")),process.exit(1)),e.frontend.includes("none")&&e.frontend.length>1&&(k(h.red("Cannot combine 'none' with other frontend options.")),process.exit(1))}if(e.addons&&Array.isArray(e.addons)&&e.addons.length>0){let a=["pwa","tauri","biome","husky","none"],t=e.addons.filter(i=>!a.includes(i));t.length>0&&(k(h.red(`Invalid addon(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.addons.includes("none")&&e.addons.length>1&&(k(h.red("Cannot combine 'none' with other addons.")),process.exit(1));let r=["pwa","tauri"];e.addons.some(i=>r.includes(i))&&e.frontend&&!e.frontend.some(i=>["tanstack-router","react-router"].includes(i))&&!e.frontend.includes("none")&&(k(h.red(`PWA and Tauri addons require a web frontend. Cannot use --addons ${e.addons.filter(i=>r.includes(i)).join(", ")} with --frontend native only`)),process.exit(1))}}function Qr(e,a){let t;if(e.frontend)if(e.frontend.includes("none"))t=[];else{t=e.frontend.filter(x=>x==="tanstack-router"||x==="react-router"||x==="native");let v=t.filter(x=>x==="tanstack-router"||x==="react-router");if(v.length>1){let x=v[0];t=t.filter(F=>F==="native"||F===x)}}let r=e.database,n;e.orm&&(n=e.orm),"prismaPostgres"in e&&e.prismaPostgres===!0&&(r||(r="postgres"),n||(n="prisma"));let i="auth"in e?e.auth:void 0,s="turso"in e?e.turso:void 0,o="prismaPostgres"in e?e.prismaPostgres:void 0;(r==="none"||r==="sqlite"&&r!==void 0||n!==void 0&&n!=="prisma")&&(o=!1),r==="none"&&(n="none",i=!1,s=!1);let p;"examples"in e&&(e.examples===!1?p=[]:Array.isArray(e.examples)&&(p=e.examples.filter(v=>v==="todo"||v==="ai"),t&&t.length>0&&!t.includes("tanstack-router")&&!t.includes("react-router")&&(p=[],R.warn(h.yellow("Examples require web frontend - ignoring examples flag"))),p.includes("ai")&&e.backend==="elysia"&&(p=p.filter(v=>v!=="ai"),R.warn(h.yellow("AI example is not compatible with Elysia - removing AI example")))));let c;e.addons&&Array.isArray(e.addons)&&(e.addons.includes("none")?c=[]:(c=e.addons.filter(v=>v==="pwa"||v==="tauri"||v==="biome"||v==="husky"),t&&t.length>0&&!t.includes("tanstack-router")&&!t.includes("react-router")&&(c=c.filter(v=>!["pwa","tauri"].includes(v)),c.length!==e.addons.length&&R.warn(h.yellow("PWA and Tauri addons require web frontend - removing these addons"))),c.includes("husky")&&!c.includes("biome")&&c.push("biome")));let d=e.backend,j=e.runtime,A=e.packageManager,b={};return a&&(b.projectName=a),r!==void 0&&(b.database=r),n!==void 0&&(b.orm=n),i!==void 0&&(b.auth=i),A&&(b.packageManager=A),"git"in e&&(b.git=e.git),"install"in e&&(b.noInstall=!e.install),s!==void 0&&(b.turso=s),o!==void 0&&(b.prismaPostgres=o),d&&(b.backend=d),j&&(b.runtime=j),t!==void 0&&(b.frontend=t),c!==void 0&&(b.addons=c),p!==void 0&&(b.examples=p),b}Wr().catch(e=>{R.error("Aborting installation..."),e instanceof Error?R.error(e.message):(R.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});