create-better-t-stack 1.6.1 → 1.7.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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
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"),s=le.readJSONSync(n);s.dependencies||(s.dependencies={}),s.devDependencies||(s.devDependencies={});for(let i of a){let o=ae[i];s.dependencies[i]=o}for(let i of t){let o=ae[i];s.devDependencies[i]=o}le.writeJSONSync(n,s,{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 s=Q.join(n,"package.json");if(await K.pathExists(s)){let d=await K.readJson(s);d.scripts={...d.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await K.writeJson(s,d,{spaces:2})}let i,o;switch(a){case"npm":i="npx",o=["@tauri-apps/cli@latest"];break;case"pnpm":i="pnpm",o=["dlx","@tauri-apps/cli@latest"];break;case"bun":i="bunx",o=["@tauri-apps/cli@latest"];break;default:i="npx",o=["@tauri-apps/cli@latest"]}let p=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=${p}`,`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await Rt(i,o,{cwd:n,env:{CI:"true"}}),r.stop("Tauri desktop app support configured successfully!")}catch(s){throw r.stop(de.red("Failed to set up Tauri")),s instanceof Error&&At.error(de.red(s.message)),s}}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 i=await E.readFile(n,"utf8");if(!i.includes("vite-plugin-pwa")){let c=i.match(/^import .* from ['"](.*)['"]/m);c?i=i.replace(c[0],`import { VitePWA } from "vite-plugin-pwa";
3
- ${c[0]}`):i=`import { VitePWA } from "vite-plugin-pwa";
4
- ${i}`}let o=`VitePWA({
2
+ import{cancel as x,intro as Gr,log as R,outro as qr,spinner as Vr}from"@clack/prompts";import{Command as Jr}from"commander";import h from"picocolors";import le 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 kt=xt(import.meta.url),$t=le.dirname(kt),$=le.join($t,"../"),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"},te={"better-auth":"^1.2.4","@better-auth/expo":"^1.2.5","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 L from"node:path";import E from"fs-extra";import Et from"node:path";import de from"fs-extra";var w=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,n=Et.join(r,"package.json"),i=de.readJSONSync(n);i.dependencies||(i.dependencies={}),i.devDependencies||(i.devDependencies={});for(let s of a){let o=te[s];i.dependencies[s]=o}for(let s of t){let o=te[s];i.devDependencies[s]=o}de.writeJSONSync(n,i,{spaces:2})};import Q from"node:path";import{log as Tt,spinner as Ct}from"@clack/prompts";import{execa as At}from"execa";import K from"fs-extra";import ue from"picocolors";async function me(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..."),w({devDependencies:["@tauri-apps/cli"],projectDir:n});let i=Q.join(n,"package.json");if(await K.pathExists(i)){let u=await K.readJson(i);u.scripts={...u.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await K.writeJson(i,u,{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 p=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=${p}`,`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await At(s,o,{cwd:n,env:{CI:"true"}}),r.stop("Tauri desktop app support configured successfully!")}catch(i){throw r.stop(ue.red("Failed to set up Tauri")),i instanceof Error&&Tt.error(ue.red(i.message)),i}}async function fe(e,a,t,r){let n=r.includes("react-router")||r.includes("tanstack-router");a.includes("pwa")&&n&&await It(e,r),a.includes("tauri")&&n&&await me(e,t,r),a.includes("biome")&&await Ft(e),a.includes("husky")&&await Ot(e)}function Rt(e,a){return L.join(e,"apps/web")}async function Ft(e){let a=L.join($,"template/with-biome");await E.pathExists(a)&&await E.copy(a,e,{overwrite:!0}),w({devDependencies:["@biomejs/biome"],projectDir:e});let t=L.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=L.join($,"template/with-husky");await E.pathExists(a)&&await E.copy(a,e,{overwrite:!0}),w({devDependencies:["husky","lint-staged"],projectDir:e});let t=L.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 It(e,a){let t=L.join($,"template/with-pwa");await E.pathExists(t)&&await E.copy(t,e,{overwrite:!0});let r=Rt(e,a);if(!await E.pathExists(r))return;w({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:r});let n=L.join(r,"vite.config.ts");if(await E.pathExists(n)){let s=await E.readFile(n,"utf8");if(!s.includes("vite-plugin-pwa")){let c=s.match(/^import .* from ['"](.*)['"]/m);c?s=s.replace(c[0],`import { VitePWA } from "vite-plugin-pwa";
3
+ ${c[0]}`):s=`import { VitePWA } from "vite-plugin-pwa";
4
+ ${s}`}let o=`VitePWA({
5
5
  registerType: "autoUpdate",
6
6
  manifest: {
7
7
  name: "My App",
@@ -16,18 +16,18 @@ ${i}`}let o=`VitePWA({
16
16
  devOptions: {
17
17
  enabled: true,
18
18
  },
19
- })`;i.includes("VitePWA(")||(a.includes("react-router")?i=i.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
19
+ })`;s.includes("VitePWA(")||(a.includes("react-router")?s=s.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
20
20
  tailwindcss(),
21
- ${o}`):a.includes("tanstack-router")?i=i.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
21
+ ${o}`):a.includes("tanstack-router")?s=s.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
22
22
  tailwindcss(),
23
- ${o}`):i=i.replace(/plugins: \[/,`plugins: [
24
- ${o},`)),await E.writeFile(n,i)}let s=N.join(r,"package.json");if(await E.pathExists(s)){let i=await E.readJson(s);i.scripts={...i.scripts,"generate-pwa-assets":"pwa-assets-generator"},await E.writeJson(s,i,{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=[],s=[];a==="hono"?(n.push("hono","@hono/trpc-server"),t==="node"&&(n.push("@hono/node-server"),s.push("tsx","@types/node"))):a==="elysia"&&(n.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(n.push("@elysiajs/node"),s.push("tsx","@types/node"))),t==="bun"&&s.push("@types/bun"),P({dependencies:n,devDependencies:s,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:s=[],orm:i="drizzle",runtime:o="bun",frontend:c=["tanstack-router"]}=e,p=c.includes("react-router"),d=c.includes("tanstack-router"),j=c.includes("native"),A=t==="npm"?"npm run":t,b=p?"5173":"3001";return`# ${a}
23
+ ${o}`):s=s.replace(/plugins: \[/,`plugins: [
24
+ ${o},`)),await E.writeFile(n,s)}let i=L.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 ae 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,t=[]){if(!a)return;let r=ae.join(e,"apps/server"),n=ae.join(e,"apps/web"),i=ae.join(e,"apps/native");try{(t.includes("react-router")||t.includes("tanstack-router"))&&(w({dependencies:["better-auth"],projectDir:r}),w({dependencies:["better-auth"],projectDir:n})),t.includes("native")&&(w({dependencies:["better-auth","@better-auth/expo"],projectDir:i}),w({dependencies:["better-auth","@better-auth/expo"],projectDir:r}))}catch(s){throw he.error(ge.red("Failed to configure authentication")),s instanceof Error&&he.error(ge.red(s.message)),s}}import St from"node:path";async function Pe(e,a,t){let r=St.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"),w({dependencies:n,devDependencies:i,projectDir:r})}import Dt from"node:path";import Lt from"fs-extra";async function ye(e,a){let t=Dt.join(e,"README.md"),r=Nt(a);try{await Lt.writeFile(t,r)}catch(n){console.error("Failed to create README.md file:",n)}}function Nt(e){let{projectName:a,packageManager:t,database:r,auth:n,addons:i=[],orm:s="drizzle",runtime:o="bun",frontend:c=["tanstack-router"]}=e,p=c.includes("react-router"),u=c.includes("tanstack-router"),j=c.includes("native"),C=t==="npm"?"npm run":t,P=p?"5173":"3001";return`# ${a}
25
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.
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, ${u?"TanStack Router":"React Router"}, Hono, tRPC, and more.
27
27
 
28
28
  ## Features
29
29
 
30
- ${Ut(r,n,s,i,o,c)}
30
+ ${_t(r,n,i,s,o,c)}
31
31
 
32
32
  ## Getting Started
33
33
 
@@ -37,20 +37,20 @@ First, install the dependencies:
37
37
  ${t} install
38
38
  \`\`\`
39
39
 
40
- ${Mt(r,n,A,i)}
40
+ ${Ut(r,n,C,s)}
41
41
 
42
42
  Then, run the development server:
43
43
 
44
44
  \`\`\`bash
45
- ${A} dev
45
+ ${C} dev
46
46
  \`\`\`
47
47
 
48
- ${d||p?`Open [http://localhost:${b}](http://localhost:${b}) in your browser to see the web application.`:""}
48
+ ${u||p?`Open [http://localhost:${P}](http://localhost:${P}) in your browser to see the web application.`:""}
49
49
  ${j?`Use the Expo Go app to run the mobile application.
50
50
  `:""}
51
51
  The API is running at [http://localhost:3000](http://localhost:3000).
52
52
 
53
- ${s.includes("pwa")&&p?`
53
+ ${i.includes("pwa")&&p?`
54
54
  ## PWA Support with React Router v7
55
55
 
56
56
  There is a known compatibility issue between VitePWA and React Router v7.
@@ -62,16 +62,16 @@ See: https://github.com/vite-pwa/vite-plugin-pwa/issues/809
62
62
  \`\`\`
63
63
  ${a}/
64
64
  \u251C\u2500\u2500 apps/
65
- ${d||p?`\u2502 \u251C\u2500\u2500 web/ # Frontend application (React, ${d?"TanStack Router":"React Router"})
65
+ ${u||p?`\u2502 \u251C\u2500\u2500 web/ # Frontend application (React, ${u?"TanStack Router":"React Router"})
66
66
  `:""}${j?`\u2502 \u251C\u2500\u2500 native/ # Mobile application (React Native, Expo)
67
67
  `:""}\u2502 \u2514\u2500\u2500 server/ # Backend API (Hono, tRPC)
68
68
  \`\`\`
69
69
 
70
70
  ## Available Scripts
71
71
 
72
- ${Bt(A,r,i,n,j)}
73
- `}function Ut(e,a,t,r,n,s){let i=s.includes("tanstack-router"),o=s.includes("react-router"),c=s.includes("native"),p=["- **TypeScript** - For type safety and improved developer experience"];i?p.push("- **TanStack Router** - File-based routing with full type safety"):o&&p.push("- **React Router** - Declarative routing for React"),c&&(p.push("- **React Native** - Build mobile apps using React"),p.push("- **Expo** - Tools for React Native development")),p.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"&&p.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&p.push("- **Authentication** - Email & password authentication with Better Auth");for(let d of t)d==="pwa"?p.push("- **PWA** - Progressive Web App support"):d==="tauri"?p.push("- **Tauri** - Build native desktop applications"):d==="biome"?p.push("- **Biome** - Linting and formatting"):d==="husky"&&p.push("- **Husky** - Git hooks for code quality");return p.join(`
74
- `)}function Mt(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
72
+ ${Mt(C,r,s,n,j)}
73
+ `}function _t(e,a,t,r,n,i){let s=i.includes("tanstack-router"),o=i.includes("react-router"),c=i.includes("native"),p=["- **TypeScript** - For type safety and improved developer experience"];s?p.push("- **TanStack Router** - File-based routing with full type safety"):o&&p.push("- **React Router** - Declarative routing for React"),c&&(p.push("- **React Native** - Build mobile apps using React"),p.push("- **Expo** - Tools for React Native development")),p.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"&&p.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&p.push("- **Authentication** - Email & password authentication with Better Auth");for(let u of t)u==="pwa"?p.push("- **PWA** - Progressive Web App support"):u==="tauri"?p.push("- **Tauri** - Build native desktop applications"):u==="biome"?p.push("- **Biome** - Linting and formatting"):u==="husky"&&p.push("- **Husky** - Git hooks for code quality");return p.join(`
74
+ `)}function Ut(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
75
75
 
76
76
  `;return e==="sqlite"?n+=`This project uses SQLite${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
77
77
 
@@ -93,35 +93,35 @@ ${t} db:push
93
93
  \`\`\`bash
94
94
  ${t} db:push
95
95
  \`\`\``}
96
- `,n}function Bt(e,a,t,r,n){let s=`- \`${e} dev\`: Start both web and server in development mode
96
+ `,n}function Mt(e,a,t,r,n){let i=`- \`${e} dev\`: Start both web and server in development mode
97
97
  - \`${e} build\`: Build both web and server
98
98
  - \`${e} dev:web\`: Start only the web application
99
99
  - \`${e} dev:server\`: Start only the server
100
- - \`${e} check-types\`: Check TypeScript types across all apps`;return n&&(s+=`
101
- - \`${e} dev:native\`: Start the React Native/Expo development server`),a!=="none"&&(s+=`
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+=`
102
102
  - \`${e} db:push\`: Push schema changes to database
103
- - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(s+=`
104
- - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),s}import $e from"node:path";import{log as ia,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(s){if(!s)return"Please enter a database URL";if(!s.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:
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 ia,spinner as sa}from"@clack/prompts";import oa from"fs-extra";import Ee from"picocolors";import V from"node:path";import{cancel as Bt,isCancel as zt,log as _,password as Gt}from"@clack/prompts";import{execa as qt}from"execa";import N from"fs-extra";import z from"picocolors";async function Vt(e,a){try{_.info(z.blue("Initializing Prisma PostgreSQL"));let t=V.join(e,"prisma");await N.ensureDir(t),await qt(a==="npm"?"npx":a==="pnpm"?"pnpm dlx":"bunx",["prisma","init","--db"],{cwd:e,stdio:"inherit"}),_.info(z.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 Gt({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 zt(n)?(Bt("Database setup cancelled"),null):{databaseUrl:n}}catch(t){return t instanceof Error&&_.error(z.red(t.message)),null}}async function re(e,a){let t=V.join(e,"apps/server",".env"),r="";await N.pathExists(t)&&(r=await N.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 N.writeFile(t,r.trim())}function je(){_.info(`Manual Prisma PostgreSQL Setup Instructions:
107
107
 
108
108
  1. Visit https://console.prisma.io and create an account
109
109
  2. Create a new PostgreSQL database from the dashboard
110
110
  3. Get your database URL
111
111
  4. Add the database URL to the .env file in apps/server/.env
112
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,`
113
+ DATABASE_URL="your_database_url"`)}async function ve(e,a="npm"){let t=V.join(e,"apps/server");try{let r=await Vt(t,a);r?(await re(e,r),await Jt(t),_.success(z.green("Prisma PostgreSQL database configured successfully!"))):(await re(e),je())}catch(r){_.error(z.red(`Error during Prisma PostgreSQL setup: ${r}`)),await re(e),je(),_.info("Setup completed with manual configuration required.")}}async function Jt(e){try{w({dependencies:["@prisma/extension-accelerate"],projectDir:e});let a=V.join(e,"prisma/index.ts");await N.writeFile(a,`
114
114
  import { PrismaClient } from '@prisma/client';
115
115
  import { withAccelerate } from "@prisma/extension-accelerate";
116
116
 
117
117
  const prisma = new PrismaClient().$extends(withAccelerate());
118
118
 
119
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 se,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=se();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=se();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,s,i,o]=r.trim().split(/\s{2,}/);return{name:n,locations:s,version:i,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 sa(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}"
120
+ `.trim());let r=V.join(e,"src/db/index.ts");if(await N.pathExists(r)){let n=await N.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 N.writeFile(r,n))}}catch{_.warn(z.yellow("Could not add Prisma Accelerate extension automatically"))}}import Wt from"node:os";import xe from"node:path";import{cancel as ne,confirm as Ht,isCancel as ie,log as G,select as Qt,spinner as se,text as Kt}from"@clack/prompts";import{$ as I}from"execa";import Xt from"fs-extra";import O from"picocolors";async function Yt(){try{return(await I`turso --version`).exitCode===0}catch{return!1}}async function Zt(){try{return!(await I`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function ea(){let e=se();try{return e.start("Logging in to Turso..."),await I`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(O.red("Failed to log in to Turso")),a}}async function ta(e){let a=se();try{if(a.start("Installing Turso CLI..."),e)await I`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await I`curl -sSfL https://get.tur.so/install.sh`;await I`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(O.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(O.red("Failed to install Turso CLI")),t)}}async function aa(){try{let{stdout:e}=await I`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 ra(){let e=await aa();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 Qt({message:"Select a Turso database group:",options:a});return ie(t)&&(ne(O.red("Operation cancelled")),process.exit(0)),t}async function na(e,a){try{a?await I`turso db create ${e} --group ${a}`:await I`turso db create ${e}`}catch(n){throw n instanceof Error&&n.message.includes("already exists")?new Error("DATABASE_EXISTS"):n}let{stdout:t}=await I`turso db show ${e} --url`,{stdout:r}=await I`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function J(e,a){let t=xe.join(e,"apps/server",".env"),r=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
123
123
  TURSO_AUTH_TOKEN="${a.authToken}"`:`TURSO_CONNECTION_URL=
124
- TURSO_AUTH_TOKEN=`;await Yt.writeFile(t,r)}function Y(){G.info(`Manual Turso Setup Instructions:
124
+ TURSO_AUTH_TOKEN=`;await Xt.writeFile(t,r)}function X(){G.info(`Manual Turso Setup Instructions:
125
125
 
126
126
  1. Visit https://turso.tech and create an account
127
127
  2. Create a new database from the dashboard
@@ -129,17 +129,17 @@ TURSO_AUTH_TOKEN=`;await Yt.writeFile(t,r)}function Y(){G.info(`Manual Turso Set
129
129
  4. Add these credentials to the .env file in apps/server/.env
130
130
 
131
131
  TURSO_CONNECTION_URL=your_database_url
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(),c=!1,p="",d=ke.basename(e);for(;!c;){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)),p=j;let A=se();try{A.start(`Creating Turso database "${p}"${o?` in group "${o}"`:""}...`);let b=await sa(p,o);await J(e,b),A.stop("Turso database configured successfully!"),c=!0}catch(b){if(b instanceof Error&&b.message==="DATABASE_EXISTS")A.stop(I.yellow(`Database "${I.red(p)}" already exists`)),d=`${p}-${Math.floor(Math.random()*1e3)}`;else throw A.stop(I.red("Failed to create Turso database")),b}}}catch(s){G.error(I.red(`Error during Turso setup: ${s}`)),await J(e),Y(),G.success("Setup completed with manual configuration required.")}}async function Te(e,a,t,r,n,s){let i=oa(),o=$e.join(e,"apps/server");if(a==="none"){await ca.remove($e.join(o,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?P({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&P({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}),n&&await xe(e,!0)):a==="postgres"&&(t==="drizzle"?P({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&(P({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}),a==="postgres"&&t==="prisma"&&s&&await ve(e,!0,r)))}catch(c){throw i.stop(Ee.red("Failed to set up database")),c instanceof Error&&ia.error(Ee.red(c.message)),c}}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"),c=a.frontend.includes("tanstack-router"),p="http://localhost:3000";o?p="http://localhost:5173":c&&(p="http://localhost:3001"),n+=`
132
+ TURSO_AUTH_TOKEN=your_auth_token`)}async function ke(e,a){if(!a){await J(e),G.info(O.blue("Skipping Turso setup. Setting up empty configuration.")),X();return}let t=Wt.platform(),r=t==="darwin";if(!(t!=="win32")){G.warn(O.yellow("Automatic Turso setup is not supported on Windows.")),await J(e),X();return}try{if(!await Yt()){let j=await Ht({message:"Would you like to install Turso CLI?",initialValue:!0});if(ie(j)&&(ne(O.red("Operation cancelled")),process.exit(0)),!j){await J(e),X();return}await ta(r)}await Zt()||await ea();let o=await ra(),c=!1,p="",u=xe.basename(e);for(;!c;){let j=await Kt({message:"Enter a name for your database:",defaultValue:u,initialValue:u,placeholder:u});ie(j)&&(ne(O.red("Operation cancelled")),process.exit(0)),p=j;let C=se();try{C.start(`Creating Turso database "${p}"${o?` in group "${o}"`:""}...`);let P=await na(p,o);await J(e,P),C.stop("Turso database configured successfully!"),c=!0}catch(P){if(P instanceof Error&&P.message==="DATABASE_EXISTS")C.stop(O.yellow(`Database "${O.red(p)}" already exists`)),u=`${p}-${Math.floor(Math.random()*1e3)}`;else throw C.stop(O.red("Failed to create Turso database")),P}}}catch(i){G.error(O.red(`Error during Turso setup: ${i}`)),await J(e),X(),G.success("Setup completed with manual configuration required.")}}async function Te(e,a,t,r,n,i){let s=sa(),o=$e.join(e,"apps/server");if(a==="none"){await oa.remove($e.join(o,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?w({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&w({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}),n&&await ke(e,!0)):a==="postgres"&&(t==="drizzle"?w({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:o}):t==="prisma"&&(w({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:o}),a==="postgres"&&t==="prisma"&&i&&await ve(e,r)))}catch(c){throw s.stop(Ee.red("Failed to set up database")),c instanceof Error&&ia.error(Ee.red(c.message)),c}}import q from"node:path";import S from"fs-extra";async function Ce(e,a){let t=q.join(e,"apps/server"),r=q.join(t,".env"),n="";if(await S.pathExists(r)&&(n=await S.readFile(r,"utf8")),!n.includes("CORS_ORIGIN")){let o=a.frontend.includes("react-router"),c=a.frontend.includes("tanstack-router"),p="http://localhost:3000";o?p="http://localhost:5173":c&&(p="http://localhost:3001"),n+=`
133
133
  CORS_ORIGIN=${p}`}if(a.auth&&(n.includes("BETTER_AUTH_SECRET")||(n+=`
134
134
  BETTER_AUTH_SECRET=${we()}`),n.includes("BETTER_AUTH_URL")||(n+=`
135
135
  BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!n.includes("DATABASE_URL")){let o=a.database==="sqlite"?"":`
136
136
  DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;n+=o}a.database==="sqlite"&&!a.turso&&(n.includes("TURSO_CONNECTION_URL")||(n+=`
137
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 s=a.frontend.includes("react-router"),i=a.frontend.includes("tanstack-router");if(s||i){let o=V.join(e,"apps/web");await pa(o)}if(a.frontend.includes("native")){let o=V.join(e,"apps/native"),c=V.join(o,".env"),p="";await D.pathExists(c)&&(p=await D.readFile(c,"utf8")),p.includes("EXPO_PUBLIC_SERVER_URL")||(p+=`EXPO_PUBLIC_SERVER_URL=http://localhost:3000
139
- `),await D.writeFile(c,p.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,s=["tanstack-router"]){let i=s.includes("tanstack-router"),o=s.includes("react-router"),c=i||o,p=i?"web-tanstack-router":"web-react-router",d=await w.pathExists(T.join(e,"apps/web"));a.includes("todo")&&c&&d?await ma(e,t,r,p):await ga(e,t),a.includes("ai")&&n==="hono"&&c&&d&&await la(e,p)}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 s=T.join(e,"apps/web");P({dependencies:["ai"],projectDir:s});let i=T.join(e,"apps/server");P({dependencies:["ai","@ai-sdk/google"],projectDir:i}),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";
138
+ GOOGLE_GENERATIVE_AI_API_KEY=`),await S.writeFile(r,n.trim());let i=a.frontend.includes("react-router"),s=a.frontend.includes("tanstack-router");if(i||s){let o=q.join(e,"apps/web");await ca(o)}if(a.frontend.includes("native")){let o=q.join(e,"apps/native"),c=q.join(o,".env"),p="";await S.pathExists(c)&&(p=await S.readFile(c,"utf8")),p.includes("EXPO_PUBLIC_SERVER_URL")||(p+=`EXPO_PUBLIC_SERVER_URL=http://localhost:3000
139
+ `),await S.writeFile(c,p.trim())}}async function ca(e){let a=q.join(e,".env"),t="";await S.pathExists(a)&&(t=await S.readFile(a,"utf8")),t.includes("VITE_SERVER_URL")||(t+=`VITE_SERVER_URL=http://localhost:3000
140
+ `),await S.writeFile(a,t.trim())}import T from"node:path";import b from"fs-extra";async function Ae(e,a,t,r,n,i=["tanstack-router"]){let s=i.includes("tanstack-router"),o=i.includes("react-router"),c=s||o,p=s?"web-tanstack-router":"web-react-router",u=await b.pathExists(T.join(e,"apps/web"));a.includes("todo")&&c&&u?await ua(e,t,r,p):await ha(e,t),a.includes("ai")&&n==="hono"&&c&&u&&await pa(e,p)}async function pa(e,a){let t=T.join($,"template/examples/ai");if(await b.pathExists(t)){let r=T.join(t,`apps/${a}/src/routes/ai.tsx`),n=T.join(e,"apps/web/src/routes/ai.tsx");await b.pathExists(r)&&await b.copy(r,n,{overwrite:!0}),await da(e,a);let i=T.join(e,"apps/web");w({dependencies:["ai"],projectDir:i});let s=T.join(e,"apps/server");w({dependencies:["ai","@ai-sdk/google"],projectDir:s}),await la(e)}}async function la(e){let a=T.join(e,"apps/server/src/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8");if(t.includes("hono")){let n=`import { streamText } from "ai";
141
141
  import { google } from "@ai-sdk/google";
142
- import { stream } from "hono/streaming";`,s=`
142
+ import { stream } from "hono/streaming";`,i=`
143
143
  app.post("/ai", async (c) => {
144
144
  const body = await c.req.json();
145
145
  const messages = body.messages || [];
@@ -158,49 +158,48 @@ import { stream } from "hono/streaming";`,s=`
158
158
  ${n}
159
159
  ${t.substring(c+1)}`}else t=`${n}
160
160
 
161
- ${t}`;let i=t.indexOf('app.use("/trpc"')||t.indexOf("app.use(trpc(");if(i!==-1)t=`${t.substring(0,i)}${s}
161
+ ${t}`;let s=t.indexOf('app.use("/trpc"')||t.indexOf("app.use(trpc(");if(s!==-1)t=`${t.substring(0,s)}${i}
162
162
 
163
- ${t.substring(i)}`;else{let o=t.indexOf("export default");o!==-1?t=`${t.substring(0,o)}${s}
163
+ ${t.substring(s)}`;else{let o=t.indexOf("export default");o!==-1?t=`${t.substring(0,o)}${i}
164
164
 
165
165
  ${t.substring(o)}`:t=`${t}
166
166
 
167
- ${s}`}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,s=r.match(n);if(s){let i=s[1];if(!i.includes('"/ai"')){let o=`const links = [
168
- ${i}${i.trim().endsWith(",")?"":","}
167
+ ${i}`}await b.writeFile(a,t)}}}async function da(e,a){let t=T.join(e,"apps/web/src/components/header.tsx");if(await b.pathExists(t)){let r=await b.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
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 s=T.join(n,`apps/${r}/src/routes/todos.tsx`),i=T.join(e,"apps/web/src/routes/todos.tsx");if(await w.pathExists(s)&&await w.copy(s,i,{overwrite:!0}),a!=="none"){let o=T.join(n,`apps/server/src/routers/with-${a}-todo.ts`),c=T.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(o)&&await w.copy(o,c,{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(`
170
+ ];`;r=r.replace(n,o),await b.writeFile(t,r)}}}}async function ua(e,a,t,r){let n=T.join($,"template/examples/todo");if(await b.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 b.pathExists(i)&&await b.copy(i,s,{overwrite:!0}),a!=="none"){let o=T.join(n,`apps/server/src/routers/with-${a}-todo.ts`),c=T.join(e,"apps/server/src/routers/todo.ts");await b.pathExists(o)&&await b.copy(o,c,{overwrite:!0}),await ma(e)}await fa(e,r)}}async function ma(e){let a=T.join(e,"apps/server/src/routers/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8");if(!t.includes("import { todoRouter }")){let r=t.lastIndexOf("import"),n=t.indexOf(`
171
171
 
172
172
  `,r);n!==-1?t=`${t.slice(0,n)}
173
173
  import { todoRouter } from "./todo";${t.slice(n)}`:t=`import { todoRouter } from "./todo";
174
- ${t}`;let s=t.indexOf("export const appRouter = router({");if(s!==-1){let i=t.indexOf("{",s)+1;t=`${t.slice(0,i)}
175
- todo: todoRouter,${t.slice(i)}`}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,s=r.match(n);if(s){let i=s[1];if(!i.includes('"/todos"')){let o=`const links = [
176
- ${i}${i.trim().endsWith(",")?"":","}
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 b.writeFile(a,t)}}}async function fa(e,a){let t=T.join(e,"apps/web/src/components/header.tsx");if(await b.pathExists(t)){let r=await b.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
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,s,i,o){let c=t==="npm"?"npm run":t,p=`cd ${a}`,d=s?.includes("husky")||s?.includes("biome"),j=e!=="none"?va(e,n,c,i):"",A=s?.includes("tauri")?ka(c):"",b=d?ja(c):"",v=o?.includes("native")?ya():"",x=s?.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.")} ${p}
178
+ ];`;r=r.replace(n,o),await b.writeFile(t,r)}}}}async function ha(e,a){if(a==="drizzle"){let r=T.join(e,"apps/server/src/db/schema/todo.ts");await b.pathExists(r)&&await b.remove(r)}else if(a==="prisma"){let r=T.join(e,"apps/server/prisma/schema/todo.prisma");await b.pathExists(r)&&await b.remove(r)}let t=T.join(e,"apps/server/src/routers/todo.ts");await b.pathExists(t)&&await b.remove(t),await ga(e)}async function ga(e){let a=T.join(e,"apps/server/src/routers/index.ts");if(await b.pathExists(a)){let t=await b.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await b.writeFile(a,t)}}import{log as Re,spinner as Fe}from"@clack/prompts";import{$ as Oe}from"execa";import Y from"picocolors";async function Ie({projectDir:e,packageManager:a,addons:t=[]}){let r=Fe();try{r.start(`Running ${a} install...`),await Oe({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await wa(e,a)}catch(n){throw r.stop(Y.red("Failed to install dependencies")),n instanceof Error&&Re.error(Y.red(`Installation error: ${n.message}`)),n}}async function wa(e,a){let t=Fe();try{t.start("Running Biome format check..."),await Oe({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(Y.yellow("Biome check encountered issues")),Re.warn(Y.yellow("Some files may need manual formatting"))}}import{note as ba}from"@clack/prompts";import y from"picocolors";function Se(e,a,t,r,n,i,s,o){let c=t==="npm"?"npm run":t,p=`cd ${a}`,u=i?.includes("husky")||i?.includes("biome"),j=e!=="none"?ja(e,n,c,s):"",C=i?.includes("tauri")?va(c):"",P=u?ya(c):"",v=o?.includes("native")?Pa():"",k=i?.includes("pwa")&&o?.includes("react-router")?xa():"",F=o?.includes("tanstack-router"),D=o?.includes("react-router"),pe=F||D,jt=o?.includes("native"),vt=pe||jt;ba(`${y.cyan("1.")} ${p}
179
179
  ${r?"":`${y.cyan("2.")} ${t} install
180
180
  `}${y.cyan(r?"2.":"3.")} ${c} dev
181
181
 
182
182
  ${y.bold("Your project will be available at:")}
183
- ${kt?`${ce?`${y.cyan("\u2022")} Frontend: http://localhost:${L?"5173":"3001"}
183
+ ${vt?`${pe?`${y.cyan("\u2022")} Frontend: http://localhost:${D?"5173":"3001"}
184
184
  `:""}`:`${y.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
185
185
  `}${y.cyan("\u2022")} API: http://localhost:3000
186
186
  ${v?`
187
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
188
+ ${j.trim()}`:""}${C?`
189
+ ${C.trim()}`:""}${P?`
190
+ ${P.trim()}`:""}${k?`
191
+ ${k.trim()}`:""}`,"Next steps")}function Pa(){return`${y.yellow("NOTE:")} For Expo connectivity issues, update apps/native/.env
192
192
  with your local IP:
193
193
  EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000
194
- `}function ja(e){return`${y.bold(`
195
- Linting and formatting:`)}
194
+ `}function ya(e){return`${y.bold("Linting and formatting:")}
196
195
  ${y.cyan("\u2022")} Format and lint fix: ${`${e} check`}
197
196
 
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,
197
+ `}function ja(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
198
  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:")}
200
199
  ${n.join(`
201
200
  `)}
202
201
 
203
- `:""}function ka(e){return`
202
+ `:""}function va(e){return`
204
203
  ${y.bold("Desktop app with Tauri:")}
205
204
  ${y.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
206
205
  ${y.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
@@ -210,10 +209,10 @@ See: https://v2.tauri.app/start/prerequisites/
210
209
  `}function xa(){return`${y.bold("PWA with React Router v7:")}
211
210
  ${y.yellow("NOTE:")} There is a known compatibility issue between VitePWA and React Router v7.
212
211
  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 s=ee.join($,"template/with-pnpm/pnpm-workspace.yaml"),i=ee.join(e,"pnpm-workspace.yaml");await U.pathExists(s)&&await U.copy(s,i)}}}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"),s=await M.readFile(n,"utf-8");a==="bun"?await Ra(r,n,s,t):a==="node"&&await Fa(r,n,s,t)}async function Ra(e,a,t,r){let n=te.join(e,"package.json"),s=await M.readJson(n);if(s.scripts={...s.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await M.writeJson(n,s,{spaces:2}),P({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let i=`${t}
212
+ `}import Z from"node:path";import{log as ka}from"@clack/prompts";import{$ as De,execa as $a}from"execa";import U from"fs-extra";import Ea from"picocolors";async function Le(e,a){await Ta(e,a),await Ca(e,a)}async function Ta(e,a){let t=Z.join(e,"package.json");if(await U.pathExists(t)){let r=await U.readJson(t);r.name=a.projectName;let{stdout:n}=await $a(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await U.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let i=Z.join($,"template/with-pnpm/pnpm-workspace.yaml"),s=Z.join(e,"pnpm-workspace.yaml");await U.pathExists(i)&&await U.copy(i,s)}}}async function Ca(e,a){let t=Z.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){ka.warn(Ea.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 ee from"node:path";import M from"fs-extra";async function _e(e,a,t){let r=ee.join(e,"apps/server"),n=ee.join(r,"src/index.ts"),i=await M.readFile(n,"utf-8");a==="bun"?await Aa(r,n,i,t):a==="node"&&await Ra(r,n,i,t)}async function Aa(e,a,t,r){let n=ee.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}),w({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let s=`${t}
214
213
 
215
214
  export default app;
216
- `;await M.writeFile(a,i)}}async function Fa(e,a,t,r){let n=te.join(e,"package.json"),s=await M.readJson(n);if(s.scripts={...s.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await M.writeJson(n,s,{spaces:2}),P({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){P({dependencies:["@hono/node-server"],projectDir:e});let i=`import { serve } from "@hono/node-server";
215
+ `;await M.writeFile(a,s)}}async function Ra(e,a,t,r){let n=ee.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}),w({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){w({dependencies:["@hono/node-server"],projectDir:e});let s=`import { serve } from "@hono/node-server";
217
216
  `,o=`
218
217
  serve(
219
218
  {
@@ -224,11 +223,14 @@ serve(
224
223
  console.log(\`Server is running on http://localhost:\${info.port}\`);
225
224
  },
226
225
  );
227
- `;if(!t.includes("@hono/node-server")){let c=t.lastIndexOf("import"),p=t.substring(0,c),d=t.substring(c),j=p+i+d+o;await M.writeFile(a,j)}}else if(r==="elysia"&&(P({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let i=`import { node } from "@elysiajs/node";
226
+ `;if(!t.includes("@hono/node-server")){let c=t.lastIndexOf("import"),p=t.substring(0,c),u=t.substring(c),j=p+s+u+o;await M.writeFile(a,j)}}else if(r==="elysia"&&(w({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let s=`import { node } from "@elysiajs/node";
228
227
  `,o=t.indexOf(`
229
- `,t.indexOf("import")),c=t.substring(0,o+1),p=t.substring(o+1),d=c+i+p;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 s of t){let i=u.join(a,s),o=u.join(e,s);s!=="apps"&&(await l.stat(i).then(c=>c.isDirectory())?await l.copy(i,o):await l.copy(i,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 s=u.join(e,"apps/web");await l.ensureDir(s);let i=u.join($,"template/base/apps/web-base");await l.pathExists(i)&&await l.copy(i,s);let o=t?"web-tanstack-router":"web-react-router",c=u.join($,`template/base/apps/${o}`);await l.pathExists(c)&&await l.copy(c,s,{overwrite:!0});let p=u.join(s,"package.json");if(await l.pathExists(p)){let d=await l.readJson(p);d.name="web",await l.writeJson(p,d,{spaces:2})}}if(n){let s=u.join($,"template/base/apps/native"),i=u.join(e,"apps/native");await l.pathExists(s)&&await l.copy(s,i),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 s=u.join(e,"apps/server/prisma/schema/auth.prisma");await l.pathExists(s)&&await l.remove(s)}else if(a==="drizzle"){let s=u.join(e,"apps/server/src/db/schema/auth.ts");await l.pathExists(s)&&await l.remove(s)}}}async function Ge(e,a,t,r,n,s){if(!a)return;let i=u.join($,"template/with-auth");if(await l.pathExists(i)){let o=s.includes("react-router"),c=s.includes("tanstack-router");if(o||c){let x=u.join(e,"apps/web"),F=u.join(i,"apps/web-base");if(await l.pathExists(F)&&await l.copy(F,x,{overwrite:!0}),o){let L=u.join(i,"apps/web-react-router");await l.pathExists(L)&&await l.copy(L,x,{overwrite:!0})}if(c){let L=u.join(i,"apps/web-tanstack-router");await l.pathExists(L)&&await l.copy(L,x,{overwrite:!0})}}let p=u.join(i,"apps/server/src"),d=u.join(e,"apps/server/src");await l.copy(u.join(p,"lib/trpc.ts"),u.join(d,"lib/trpc.ts"),{overwrite:!0}),await l.copy(u.join(p,"routers/index.ts"),u.join(d,"routers/index.ts"),{overwrite:!0});let j=`with-${t}-context.ts`;await l.copy(u.join(p,"lib",j),u.join(d,"lib/context.ts"),{overwrite:!0});let A=`with-${t}-index.ts`;await l.copy(u.join(p,A),u.join(d,"index.ts"),{overwrite:!0});let b=Oa(r,n),v=u.join(p,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(s.includes("native")){let x=u.join(i,"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 s=u.join(e,n.name),i=await qe(s);a.push(...i)}}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",e.prismaPostgres),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)"}],s=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=g.addons.filter(c=>t||c!=="pwa"&&c!=="tauri"),o=await Ma({message:"Select addons",options:s,initialValues:i,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 s=await Ga({message:"Add authentication with Better-Auth?",initialValue:g.auth});return Va(s)&&(za(Qe.red("Operation cancelled")),process.exit(0)),s}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 s=[];return r==="elysia"&&(s=await Ze({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:g.examples})),r==="hono"&&(s=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(s)&&(er(ar.red("Operation cancelled")),process.exit(0)),s}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 sr,confirm as ir,isCancel as or}from"@clack/prompts";import cr from"picocolors";async function st(e){if(e!==void 0)return e;let a=await ir({message:"Initialize git repository?",initialValue:g.git});return or(a)&&(sr(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 it(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 s=process.cwd();if(z.readdirSync(s).length===0)return e}else{let s=W.basename(e);if(!dt(s)){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 s=await Tr({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:i=>{let o=i.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 c=W.resolve(process.cwd(),o),p=W.basename(c),d=dt(p);if(d)return d;if(!c.startsWith(process.cwd()))return"Project path must be within current directory";if(z.pathExistsSync(c)&&z.readdirSync(c).length>0)return`Directory "${o}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Er(s)&&($r(Ar.red("Operation cancelled.")),process.exit(0)),t=s||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:()=>st(e.git),packageManager:()=>ct(e.packageManager),noInstall:()=>it(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 ie(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=`
228
+ `,t.indexOf("import")),c=t.substring(0,o+1),p=t.substring(o+1),u=c+s+p;u=u.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await M.writeFile(a,u)}}import d from"node:path";import l from"fs-extra";async function Ue(e){let a=d.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=d.join(a,i),o=d.join(e,i);i!=="apps"&&(await l.stat(s).then(c=>c.isDirectory())?await l.copy(s,o):await l.copy(s,o))}await l.ensureDir(d.join(e,"apps"));let r=d.join(a,"apps/server"),n=d.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=d.join(e,"apps/web");await l.ensureDir(i);let s=d.join($,"template/base/apps/web-base");await l.pathExists(s)&&await l.copy(s,i);let o=t?"web-tanstack-router":"web-react-router",c=d.join($,`template/base/apps/${o}`);await l.pathExists(c)&&await l.copy(c,i,{overwrite:!0});let p=d.join(i,"package.json");if(await l.pathExists(p)){let u=await l.readJson(p);u.name="web",await l.writeJson(p,u,{spaces:2})}}if(n){let i=d.join($,"template/base/apps/native"),s=d.join(e,"apps/native");await l.pathExists(i)&&await l.copy(i,s),await l.writeFile(d.join(e,".npmrc"),`node-linker=hoisted
229
+ `)}}async function Be(e,a){let t=d.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=d.join($,Oa(a,t));if(await l.pathExists(n)&&(await l.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let i=d.join(e,"apps/server/prisma/schema/auth.prisma");await l.pathExists(i)&&await l.remove(i)}else if(a==="drizzle"){let i=d.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=d.join($,"template/with-auth");if(await l.pathExists(s)){let o=i.includes("react-router"),c=i.includes("tanstack-router");if(o||c){let k=d.join(e,"apps/web"),F=d.join(s,"apps/web-base");if(await l.pathExists(F)&&await l.copy(F,k,{overwrite:!0}),o){let D=d.join(s,"apps/web-react-router");await l.pathExists(D)&&await l.copy(D,k,{overwrite:!0})}if(c){let D=d.join(s,"apps/web-tanstack-router");await l.pathExists(D)&&await l.copy(D,k,{overwrite:!0})}}let p=d.join(s,"apps/server/src"),u=d.join(e,"apps/server/src");await l.copy(d.join(p,"lib/trpc.ts"),d.join(u,"lib/trpc.ts"),{overwrite:!0}),await l.copy(d.join(p,"routers/index.ts"),d.join(u,"routers/index.ts"),{overwrite:!0});let j=`with-${t}-context.ts`;await l.copy(d.join(p,"lib",j),d.join(u,"lib/context.ts"),{overwrite:!0});let C=`with-${t}-index.ts`;await l.copy(d.join(p,C),d.join(u,"index.ts"),{overwrite:!0});let P=Ia(r,n),v=d.join(p,P);if(await l.pathExists(v)){let k=await l.readdir(v);for(let F of k)await l.copy(d.join(v,F),d.join(u,"lib",F),{overwrite:!0})}if(i.includes("native")){let k=d.join(s,"apps/native"),F=d.join(e,"apps/native");await l.pathExists(k)&&await l.copy(k,F,{overwrite:!0}),w({dependencies:["@better-auth/expo"],projectDir:d.join(e,"apps/server")}),await Fa(e,r,n)}}}async function Fa(e,a,t){let r=d.join(e,"apps/server"),n;if(a==="drizzle"?t==="sqlite"?n=d.join(r,"src/lib/auth.ts"):t==="postgres"&&(n=d.join(r,"src/lib/auth.ts")):a==="prisma"&&(t==="sqlite"?n=d.join(r,"src/lib/auth.ts"):t==="postgres"&&(n=d.join(r,"src/lib/auth.ts"))),n&&await l.pathExists(n)){let i=await l.readFile(n,"utf8");if(!i.includes("@better-auth/expo")){let s=`import { expo } from "@better-auth/expo";
230
+ `,o=i.lastIndexOf("import"),c=i.indexOf(`
231
+ `,o)+1;i=i.substring(0,c)+s+i.substring(c)}i.includes("plugins:")?i.includes("expo()")||(i=i.replace(/plugins: \[(.*?)\]/s,(s,o)=>`plugins: [${o}${o.trim()?", ":""}expo()]`)):i=i.replace(/}\);/,` plugins: [expo()],
232
+ });`),i.includes("my-better-t-app://")||(i=i.replace(/trustedOrigins: \[(.*?)\]/s,(s,o)=>`trustedOrigins: [${o}${o.trim()?", ":""}"my-better-t-app://"]`)),await l.writeFile(n,i)}}async function qe(e){let a=await Ve(e);for(let t of a)if(await l.pathExists(t)){let r=d.join(d.dirname(t),".gitignore");await l.move(t,r,{overwrite:!0})}}async function Ve(e){let a=[],t=d.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=d.join(e,n.name),s=await Ve(i);a.push(...s)}}catch{}return a}function Oa(e,a){return e==="drizzle"?a==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?a==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}function Ia(e,a){if(e==="drizzle")return a==="sqlite"?"with-drizzle-sqlite-lib":"with-drizzle-postgres-lib";if(e==="prisma")return a==="sqlite"?"with-prisma-sqlite-lib":"with-prisma-postgres-lib";throw new Error("Invalid ORM or database configuration for auth setup")}async function 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 qe(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",e.prismaPostgres),await Ge(t,e.auth,e.backend,e.orm,e.database,e.frontend),await be(t,e.auth,e.frontend),await _e(t,e.runtime,e.backend),await Ae(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await Ce(t,e),await Ne(t,e.git),e.addons.length>0&&await fe(t,e.addons,e.packageManager,e.frontend),await Le(t,e),await ye(t,e),e.noInstall||await Ie({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(c=>t||c!=="pwa"&&c!=="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 qa}from"@clack/prompts";import Va from"picocolors";async function Qe(e,a,t){if(!a)return!1;if(e!==void 0)return e;let r=await Ga({message:"Add authentication with Better-Auth?",initialValue:g.auth});return qa(r)&&(za(Va.red("Operation cancelled")),process.exit(0)),r}import{cancel as Ja,isCancel as Wa,select as Ha}from"@clack/prompts";import Qa from"picocolors";async function Ke(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 Xe(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 Ye}from"@clack/prompts";import ar from"picocolors";async function Ze(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 Ye({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:g.examples})),r==="hono"&&(i=await Ye({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 et,isCancel as tt,multiselect as rr,select as nr}from"@clack/prompts";import at from"picocolors";async function rt(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"]:[]});tt(a)&&(et(at.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"});tt(r)&&(et(at.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 nt(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 it(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 st(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 ot(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:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"}],initialValue:a});return br(t)&&(wr(yr.red("Operation cancelled")),process.exit(0)),t}import{cancel as jr,confirm as vr,isCancel as xr}from"@clack/prompts";import kr from"picocolors";async function ct(e){if(e!==void 0)return e;let a=await vr({message:"Set up Prisma Postgres database?",initialValue:g.prismaPostgres});return xr(a)&&(jr(kr.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 B from"fs-extra";import Cr from"picocolors";var Ar=["<",">",":",'"',"|","?","*"],pt=255;function lt(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>pt)return`Project name must be less than ${pt} characters`;if(Ar.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 dt(e){if(e)if(e==="."){let i=process.cwd();if(B.readdirSync(i).length===0)return e}else{let i=W.basename(e);if(!lt(i)){let o=W.resolve(process.cwd(),e);if(!B.pathExistsSync(o)||B.readdirSync(o).length===0)return e}}let a=!1,t="",r=g.projectName,n=1;for(;B.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(B.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let c=W.resolve(process.cwd(),o),p=W.basename(c),u=lt(p);if(u)return u;if(!c.startsWith(process.cwd()))return"Project path must be within current directory";if(B.pathExistsSync(c)&&B.readdirSync(c).length>0)return`Directory "${o}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Er(i)&&($r(Cr.red("Operation cancelled.")),process.exit(0)),t=i||r}return t}import{cancel as Rr,isCancel as Fr,select as Or}from"@clack/prompts";import Ir from"picocolors";async function ut(e){if(e!==void 0)return e;let a=await Or({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(Ir.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 mt(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 ft(e){let a=await Ur({projectName:async()=>dt(e.projectName),frontend:()=>rt(e.frontend),backend:()=>Ke(e.backend),runtime:()=>ut(e.runtime),database:()=>Xe(e.database),orm:({results:t})=>st(e.orm,t.database!=="none"),auth:({results:t})=>Qe(e.auth,t.database!=="none",t.frontend),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?mt(e.turso):Promise.resolve(!1),prismaPostgres:({results:t})=>t.database==="postgres"&&t.orm==="prisma"?ct(e.prismaPostgres):Promise.resolve(!1),addons:({results:t})=>He(e.addons,t.frontend),examples:({results:t})=>Ze(e.examples,t.database,t.frontend,t.backend),git:()=>nt(e.git),packageManager:()=>ot(e.packageManager),noInstall:()=>it(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 A from"picocolors";function oe(e){let a=[];if(e.projectName&&a.push(`${A.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${A.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${A.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${A.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${A.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${A.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${A.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${A.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${A.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${A.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${A.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${A.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${A.blue("Turso Setup:")} ${e.turso}`),e.prismaPostgres!==void 0&&a.push(`${A.blue("Prisma Postgres Setup:")} ${e.prismaPostgres?"Yes":"No"}`),a.join(`
233
+ `)}function ht(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 gt=()=>{let e=Br.join($,"package.json");return zr.readJSONSync(e).version??"1.0.0"};import wt from"gradient-string";var bt=`
232
234
  \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
233
235
  \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
234
236
  \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
@@ -242,10 +244,10 @@ serve(
242
244
  \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
243
245
  \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
244
246
  \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
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(`
247
+ `,Pt={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},yt=()=>{let e=process.stdout.columns||80,a=bt.split(`
248
+ `),t=Math.max(...a.map(r=>r.length));e<t?console.log(wt(Object.values(Pt)).multiline(`
247
249
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
248
250
  \u2551 Better T-Stack \u2551
249
251
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
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(ie(n)),R.message(""));let s=t.yes?{...g,projectName:r??g.projectName,...n}:await ht(n);t.yes&&(R.info(h.yellow("Using these default options:")),R.message(ie(s)),R.message("")),await We(s),R.success(h.blue(`You can reproduce this setup with the following command:
251
- ${h.white(gt(s))}`));let i=((Date.now()-e)/1e3).toFixed(2);Vr(h.magenta(`Project created successfully in ${h.bold(i)} 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(s=>!a.includes(s));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(s=>r.includes(s))&&e.frontend&&!e.frontend.some(s=>["tanstack-router","react-router"].includes(s))&&!e.frontend.includes("none")&&(k(h.red(`PWA and Tauri addons require a web frontend. Cannot use --addons ${e.addons.filter(s=>r.includes(s)).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 s="auth"in e?e.auth:void 0,i="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",s=!1,i=!1);let c;"examples"in e&&(e.examples===!1?c=[]:Array.isArray(e.examples)&&(c=e.examples.filter(v=>v==="todo"||v==="ai"),t&&t.length>0&&!t.includes("tanstack-router")&&!t.includes("react-router")&&(c=[],R.warn(h.yellow("Examples require web frontend - ignoring examples flag"))),c.includes("ai")&&e.backend==="elysia"&&(c=c.filter(v=>v!=="ai"),R.warn(h.yellow("AI example is not compatible with Elysia - removing AI example")))));let p;e.addons&&Array.isArray(e.addons)&&(e.addons.includes("none")?p=[]:(p=e.addons.filter(v=>v==="pwa"||v==="tauri"||v==="biome"||v==="husky"),t&&t.length>0&&!t.includes("tanstack-router")&&!t.includes("react-router")&&(p=p.filter(v=>!["pwa","tauri"].includes(v)),p.length!==e.addons.length&&R.warn(h.yellow("PWA and Tauri addons require web frontend - removing these addons"))),p.includes("husky")&&!p.includes("biome")&&p.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),s!==void 0&&(b.auth=s),A&&(b.packageManager=A),"git"in e&&(b.git=e.git),"install"in e&&(b.noInstall=!e.install),i!==void 0&&(b.turso=i),o!==void 0&&(b.prismaPostgres=o),d&&(b.backend=d),j&&(b.runtime=j),t!==void 0&&(b.frontend=t),p!==void 0&&(b.addons=p),c!==void 0&&(b.examples=c),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)});
252
+ `)):console.log(wt(Object.values(Pt)).multiline(bt))};process.on("SIGINT",()=>{R.error(h.red("Operation cancelled")),process.exit(0)});var ce=new Jr;async function Wr(){let e=Date.now();ce.name("create-better-t-stack").description("Create a new Better-T Stack project").version(gt()).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=Vr();try{yt(),Gr(h.magenta("Creating a new Better-T-Stack project"));let t=ce.opts(),r=ce.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(oe(n)),R.message(""));let i=t.yes?{...g,projectName:r??g.projectName,...n}:await ft(n);t.yes&&(R.info(h.yellow("Using these default options:")),R.message(oe(i)),R.message("")),await We(i),R.success(h.blue(`You can reproduce this setup with the following command:
253
+ ${h.white(ht(i))}`));let s=((Date.now()-e)/1e3).toFixed(2);qr(h.magenta(`Project created successfully in ${h.bold(s)} seconds!`))}catch(t){a.stop(h.red("Failed")),t instanceof Error&&(x(h.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function Hr(e){if(e.database&&!["none","sqlite","postgres"].includes(e.database)&&(x(h.red(`Invalid database type: ${e.database}. Must be none, sqlite, or postgres.`)),process.exit(1)),e.orm&&!["none","drizzle","prisma"].includes(e.orm)&&(x(h.red(`Invalid ORM type: ${e.orm}. Must be none, drizzle, or prisma.`)),process.exit(1)),e.database==="none"&&(e.auth===!0&&(x(h.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(x(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&&(x(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"&&(x(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"&&(x(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")&&(x(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)&&(x(h.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),e.backend&&!["hono","elysia"].includes(e.backend)&&(x(h.red(`Invalid backend framework: ${e.backend}. Must be hono or elysia.`)),process.exit(1)),e.runtime&&!["bun","node"].includes(e.runtime)&&(x(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&&(x(h.red(`Invalid example(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&e.backend==="elysia"&&(x(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")&&(x(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&&(x(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&&(x(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&&(x(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&&(x(h.red(`Invalid addon(s): ${t.join(", ")}. Valid options are: ${a.join(", ")}.`)),process.exit(1)),e.addons.includes("none")&&e.addons.length>1&&(x(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")&&(x(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(k=>k==="tanstack-router"||k==="react-router"||k==="native");let v=t.filter(k=>k==="tanstack-router"||k==="react-router");if(v.length>1){let k=v[0];t=t.filter(F=>F==="native"||F===k)}}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 c;"examples"in e&&(e.examples===!1?c=[]:Array.isArray(e.examples)&&(c=e.examples.filter(v=>v==="todo"||v==="ai"),t&&t.length>0&&!t.includes("tanstack-router")&&!t.includes("react-router")&&(c=[],R.warn(h.yellow("Examples require web frontend - ignoring examples flag"))),c.includes("ai")&&e.backend==="elysia"&&(c=c.filter(v=>v!=="ai"),R.warn(h.yellow("AI example is not compatible with Elysia - removing AI example")))));let p;e.addons&&Array.isArray(e.addons)&&(e.addons.includes("none")?p=[]:(p=e.addons.filter(v=>v==="pwa"||v==="tauri"||v==="biome"||v==="husky"),t&&t.length>0&&!t.includes("tanstack-router")&&!t.includes("react-router")&&(p=p.filter(v=>!["pwa","tauri"].includes(v)),p.length!==e.addons.length&&R.warn(h.yellow("PWA and Tauri addons require web frontend - removing these addons"))),p.includes("husky")&&!p.includes("biome")&&p.push("biome")));let u=e.backend,j=e.runtime,C=e.packageManager,P={};return a&&(P.projectName=a),r!==void 0&&(P.database=r),n!==void 0&&(P.orm=n),i!==void 0&&(P.auth=i),C&&(P.packageManager=C),"git"in e&&(P.git=e.git),"install"in e&&(P.noInstall=!e.install),s!==void 0&&(P.turso=s),o!==void 0&&(P.prismaPostgres=o),u&&(P.backend=u),j&&(P.runtime=j),t!==void 0&&(P.frontend=t),p!==void 0&&(P.addons=p),c!==void 0&&(P.examples=c),P}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)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,8 +8,8 @@
8
8
  "create-better-t-stack": "dist/index.js"
9
9
  },
10
10
  "files": [
11
- "dist",
12
- "template"
11
+ "template",
12
+ "dist"
13
13
  ],
14
14
  "keywords": [
15
15
  "typescript",
@@ -1,9 +1,17 @@
1
- import { View, Text } from "react-native";
1
+ import { Container } from "@/components/container";
2
+ import { Text, View } from "react-native";
2
3
 
3
- export default function App() {
4
- return (
5
- <View>
6
- <Text>Hello, World!</Text>
7
- </View>
8
- );
4
+ export default function TabOne() {
5
+ return (
6
+ <Container>
7
+ <View className="p-6 flex-1 justify-center">
8
+ <Text className="text-2xl font-bold text-foreground text-center mb-4">
9
+ Tab One
10
+ </Text>
11
+ <Text className="text-foreground text-center">
12
+ This is the first tab of the application.
13
+ </Text>
14
+ </View>
15
+ </Container>
16
+ );
9
17
  }
@@ -1,16 +1,17 @@
1
- import { Stack } from "expo-router";
2
- import { View, Text } from "react-native";
3
-
4
1
  import { Container } from "@/components/container";
2
+ import { Text, View } from "react-native";
5
3
 
6
- export default function Home() {
7
- return (
8
- <>
9
- <Container>
10
- <View>
11
- <Text>Tab Two</Text>
12
- </View>
13
- </Container>
14
- </>
15
- );
4
+ export default function TabTwo() {
5
+ return (
6
+ <Container>
7
+ <View className="p-6 flex-1 justify-center">
8
+ <Text className="text-2xl font-bold text-foreground text-center mb-4">
9
+ Tab Two
10
+ </Text>
11
+ <Text className="text-foreground text-center">
12
+ This is the second tab of the application.
13
+ </Text>
14
+ </View>
15
+ </Container>
16
+ );
16
17
  }
@@ -1,15 +1,12 @@
1
- import { Text, View } from "react-native";
2
-
3
1
  import { Container } from "@/components/container";
2
+ import { Text, View } from "react-native";
4
3
 
5
4
  export default function Modal() {
6
- return (
7
- <>
8
- <Container>
9
- <View>
10
- <Text>HI MODAL</Text>
11
- </View>
12
- </Container>
13
- </>
14
- );
5
+ return (
6
+ <Container>
7
+ <View className="flex-1 justify-center items-center">
8
+ <Text className="text-xl font-bold text-foreground">Modal View</Text>
9
+ </View>
10
+ </Container>
11
+ );
15
12
  }
@@ -9,7 +9,10 @@
9
9
  "output": "static",
10
10
  "favicon": "./assets/favicon.png"
11
11
  },
12
- "plugins": ["expo-router"],
12
+ "plugins": [
13
+ "expo-router",
14
+ "expo-secure-store"
15
+ ],
13
16
  "experiments": {
14
17
  "typedRoutes": true,
15
18
  "tsconfigPaths": true
@@ -15,6 +15,8 @@ const config = withTurborepoManagedCache(
15
15
 
16
16
  config.resolver.unstable_enablePackageExports = true;
17
17
 
18
+ config.resolver.disableHierarchicalLookup = true;
19
+
18
20
  module.exports = config;
19
21
 
20
22
  /**
@@ -3,7 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "main": "expo-router/entry",
5
5
  "scripts": {
6
- "dev": "expo start",
6
+ "dev": "expo start --clear",
7
7
  "android": "expo run:android",
8
8
  "ios": "expo run:ios",
9
9
  "prebuild": "expo prebuild",
@@ -19,18 +19,19 @@
19
19
  "@trpc/client": "^11.0.0",
20
20
  "@trpc/server": "^11.0.0",
21
21
  "@trpc/tanstack-react-query": "^11.0.0",
22
- "expo": "^52.0.41",
22
+ "expo": "^52.0.44",
23
23
  "expo-constants": "~17.0.8",
24
24
  "expo-linking": "~7.0.5",
25
25
  "expo-navigation-bar": "~4.0.8",
26
26
  "expo-router": "~4.0.19",
27
+ "expo-secure-store": "~14.0.1",
27
28
  "expo-status-bar": "~2.0.1",
28
29
  "expo-system-ui": "~4.0.8",
29
30
  "expo-web-browser": "~14.0.2",
30
31
  "nativewind": "^4.1.23",
31
32
  "react": "18.3.1",
32
33
  "react-dom": "18.3.1",
33
- "react-native": "0.76.7",
34
+ "react-native": "0.76.9",
34
35
  "react-native-gesture-handler": "~2.20.2",
35
36
  "react-native-reanimated": "3.16.2",
36
37
  "react-native-safe-area-context": "4.12.0",
@@ -3,13 +3,13 @@ import { RouterProvider, createRouter } from "@tanstack/react-router";
3
3
  import ReactDOM from "react-dom/client";
4
4
  import Loader from "./components/loader";
5
5
  import { routeTree } from "./routeTree.gen";
6
- import { queryClient, trpcClient } from "./utils/trpc";
6
+ import { queryClient, trpc } from "./utils/trpc";
7
7
 
8
8
  const router = createRouter({
9
9
  routeTree,
10
10
  defaultPreload: "intent",
11
11
  defaultPendingComponent: () => <Loader />,
12
- context: { trpcClient },
12
+ context: { trpc, queryClient },
13
13
  Wrap: function WrapComponent({ children }) {
14
14
  return (
15
15
  <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
@@ -2,7 +2,8 @@ import Header from "@/components/header";
2
2
  import Loader from "@/components/loader";
3
3
  import { ThemeProvider } from "@/components/theme-provider";
4
4
  import { Toaster } from "@/components/ui/sonner";
5
- import type { trpcClient } from "@/utils/trpc";
5
+ import type { trpc } from "@/utils/trpc";
6
+ import type { QueryClient } from "@tanstack/react-query";
6
7
  import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
7
8
  import {
8
9
  HeadContent,
@@ -14,7 +15,8 @@ import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
14
15
  import "../index.css";
15
16
 
16
17
  export interface RouterAppContext {
17
- trpcClient: typeof trpcClient;
18
+ trpc: typeof trpc;
19
+ queryClient: QueryClient;
18
20
  }
19
21
 
20
22
  export const Route = createRootRouteWithContext<RouterAppContext>()({
@@ -0,0 +1,84 @@
1
+ import { authClient } from "@/lib/auth-client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { ScrollView, Text, TouchableOpacity, View } from "react-native";
4
+
5
+ import { Container } from "@/components/container";
6
+ import { SignIn } from "@/components/sign-in";
7
+ import { SignUp } from "@/components/sign-up";
8
+ import { queryClient, trpc } from "@/utils/trpc";
9
+
10
+ export default function Home() {
11
+ const healthCheck = useQuery(trpc.healthCheck.queryOptions());
12
+ const privateData = useQuery(trpc.privateData.queryOptions());
13
+ const { data: session } = authClient.useSession();
14
+
15
+ return (
16
+ <Container>
17
+ <ScrollView className="flex-1">
18
+ <View className="px-4">
19
+ <Text className="font-mono text-foreground text-3xl font-bold mb-4">
20
+ BETTER T STACK
21
+ </Text>
22
+ {session?.user ? (
23
+ <View className="mb-6 p-4 bg-card rounded-lg border border-border">
24
+ <View className="flex-row justify-between items-center mb-2">
25
+ <Text className="text-foreground text-base">
26
+ Welcome,{" "}
27
+ <Text className="font-medium">{session.user.name}</Text>
28
+ </Text>
29
+ </View>
30
+ <Text className="text-muted-foreground text-sm mb-4">
31
+ {session.user.email}
32
+ </Text>
33
+
34
+ <TouchableOpacity
35
+ className="bg-destructive py-2 px-4 rounded-md self-start"
36
+ onPress={() => {
37
+ authClient.signOut();
38
+ queryClient.invalidateQueries();
39
+ }}
40
+ >
41
+ <Text className="text-white font-medium">Sign Out</Text>
42
+ </TouchableOpacity>
43
+ </View>
44
+ ) : null}
45
+ <View className="mb-6 rounded-lg border border-border p-4">
46
+ <Text className="mb-3 font-medium text-foreground">API Status</Text>
47
+ <View className="flex-row items-center gap-2">
48
+ <View
49
+ className={`h-3 w-3 rounded-full ${
50
+ healthCheck.data ? "bg-green-500" : "bg-red-500"
51
+ }`}
52
+ />
53
+ <Text className="text-muted-foreground">
54
+ {healthCheck.isLoading
55
+ ? "Checking..."
56
+ : healthCheck.data
57
+ ? "Connected to API"
58
+ : "API Disconnected"}
59
+ </Text>
60
+ </View>
61
+ </View>
62
+ <View className="mb-6 rounded-lg border border-border p-4">
63
+ <Text className="mb-3 font-medium text-foreground">
64
+ Private Data
65
+ </Text>
66
+ {privateData && (
67
+ <View>
68
+ <Text className="text-muted-foreground">
69
+ {privateData.data?.message}
70
+ </Text>
71
+ </View>
72
+ )}
73
+ </View>
74
+ {!session?.user && (
75
+ <>
76
+ <SignIn />
77
+ <SignUp />
78
+ </>
79
+ )}
80
+ </View>
81
+ </ScrollView>
82
+ </Container>
83
+ );
84
+ }
@@ -0,0 +1,88 @@
1
+ import { authClient } from "@/lib/auth-client";
2
+ import { queryClient } from "@/utils/trpc";
3
+ import { useState } from "react";
4
+ import {
5
+ ActivityIndicator,
6
+ Text,
7
+ TextInput,
8
+ TouchableOpacity,
9
+ View,
10
+ } from "react-native";
11
+
12
+ export function SignIn() {
13
+ const [email, setEmail] = useState("");
14
+ const [password, setPassword] = useState("");
15
+ const [isLoading, setIsLoading] = useState(false);
16
+ const [error, setError] = useState<string | null>(null);
17
+
18
+ const handleLogin = async () => {
19
+ setIsLoading(true);
20
+ setError(null);
21
+
22
+ await authClient.signIn.email(
23
+ {
24
+ email,
25
+ password,
26
+ },
27
+ {
28
+ onError: (error) => {
29
+ setError(error.error?.message || "Failed to sign in");
30
+ setIsLoading(false);
31
+ },
32
+ onSuccess: () => {
33
+ setEmail("");
34
+ setPassword("");
35
+ queryClient.refetchQueries();
36
+ },
37
+ onFinished: () => {
38
+ setIsLoading(false);
39
+ },
40
+ },
41
+ );
42
+ };
43
+
44
+ return (
45
+ <View className="mt-6 p-4 bg-card rounded-lg border border-border">
46
+ <Text className="text-lg font-semibold text-foreground mb-4">
47
+ Sign In
48
+ </Text>
49
+
50
+ {error && (
51
+ <View className="mb-4 p-3 bg-destructive/10 rounded-md">
52
+ <Text className="text-destructive text-sm">{error}</Text>
53
+ </View>
54
+ )}
55
+
56
+ <TextInput
57
+ className="mb-3 p-4 rounded-md bg-input text-foreground border border-input"
58
+ placeholder="Email"
59
+ value={email}
60
+ onChangeText={setEmail}
61
+ placeholderTextColor="#9CA3AF"
62
+ keyboardType="email-address"
63
+ autoCapitalize="none"
64
+ />
65
+
66
+ <TextInput
67
+ className="mb-4 p-4 rounded-md bg-input text-foreground border border-input"
68
+ placeholder="Password"
69
+ value={password}
70
+ onChangeText={setPassword}
71
+ placeholderTextColor="#9CA3AF"
72
+ secureTextEntry
73
+ />
74
+
75
+ <TouchableOpacity
76
+ onPress={handleLogin}
77
+ disabled={isLoading}
78
+ className="bg-primary p-4 rounded-md flex-row justify-center items-center"
79
+ >
80
+ {isLoading ? (
81
+ <ActivityIndicator size="small" color="#fff" />
82
+ ) : (
83
+ <Text className="text-primary-foreground font-medium">Sign In</Text>
84
+ )}
85
+ </TouchableOpacity>
86
+ </View>
87
+ );
88
+ }
@@ -0,0 +1,99 @@
1
+ import { authClient } from "@/lib/auth-client";
2
+ import { queryClient } from "@/utils/trpc";
3
+ import { useState } from "react";
4
+ import {
5
+ ActivityIndicator,
6
+ Text,
7
+ TextInput,
8
+ TouchableOpacity,
9
+ View,
10
+ } from "react-native";
11
+
12
+ export function SignUp() {
13
+ const [name, setName] = useState("");
14
+ const [email, setEmail] = useState("");
15
+ const [password, setPassword] = useState("");
16
+ const [isLoading, setIsLoading] = useState(false);
17
+ const [error, setError] = useState<string | null>(null);
18
+
19
+ const handleSignUp = async () => {
20
+ setIsLoading(true);
21
+ setError(null);
22
+
23
+ await authClient.signUp.email(
24
+ {
25
+ name,
26
+ email,
27
+ password,
28
+ },
29
+ {
30
+ onError: (error) => {
31
+ setError(error.error?.message || "Failed to sign up");
32
+ setIsLoading(false);
33
+ },
34
+ onSuccess: () => {
35
+ setName("");
36
+ setEmail("");
37
+ setPassword("");
38
+ queryClient.refetchQueries();
39
+ },
40
+ onFinished: () => {
41
+ setIsLoading(false);
42
+ },
43
+ },
44
+ );
45
+ };
46
+
47
+ return (
48
+ <View className="mt-6 p-4 bg-card rounded-lg border border-border">
49
+ <Text className="text-lg font-semibold text-foreground mb-4">
50
+ Create Account
51
+ </Text>
52
+
53
+ {error && (
54
+ <View className="mb-4 p-3 bg-destructive/10 rounded-md">
55
+ <Text className="text-destructive text-sm">{error}</Text>
56
+ </View>
57
+ )}
58
+
59
+ <TextInput
60
+ className="mb-3 p-4 rounded-md bg-input text-foreground border border-input"
61
+ placeholder="Name"
62
+ value={name}
63
+ onChangeText={setName}
64
+ placeholderTextColor="#9CA3AF"
65
+ />
66
+
67
+ <TextInput
68
+ className="mb-3 p-4 rounded-md bg-input text-foreground border border-input"
69
+ placeholder="Email"
70
+ value={email}
71
+ onChangeText={setEmail}
72
+ placeholderTextColor="#9CA3AF"
73
+ keyboardType="email-address"
74
+ autoCapitalize="none"
75
+ />
76
+
77
+ <TextInput
78
+ className="mb-4 p-4 rounded-md bg-input text-foreground border border-input"
79
+ placeholder="Password"
80
+ value={password}
81
+ onChangeText={setPassword}
82
+ placeholderTextColor="#9CA3AF"
83
+ secureTextEntry
84
+ />
85
+
86
+ <TouchableOpacity
87
+ onPress={handleSignUp}
88
+ disabled={isLoading}
89
+ className="bg-primary p-4 rounded-md flex-row justify-center items-center"
90
+ >
91
+ {isLoading ? (
92
+ <ActivityIndicator size="small" color="#fff" />
93
+ ) : (
94
+ <Text className="text-primary-foreground font-medium">Sign Up</Text>
95
+ )}
96
+ </TouchableOpacity>
97
+ </View>
98
+ );
99
+ }
@@ -0,0 +1,13 @@
1
+ import { createAuthClient } from "better-auth/react";
2
+ import { expoClient } from "@better-auth/expo/client";
3
+ import * as SecureStore from "expo-secure-store";
4
+
5
+ export const authClient = createAuthClient({
6
+ baseURL: process.env.EXPO_PUBLIC_SERVER_URL,
7
+ plugins: [
8
+ expoClient({
9
+ storagePrefix: "my-better-t-app",
10
+ storage: SecureStore,
11
+ }),
12
+ ],
13
+ });
@@ -0,0 +1,28 @@
1
+ import { authClient } from "@/lib/auth-client";
2
+ import { QueryClient } from "@tanstack/react-query";
3
+ import { createTRPCClient, httpBatchLink } from "@trpc/client";
4
+ import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
5
+ import type { AppRouter } from "../../server/src/routers";
6
+
7
+ export const queryClient = new QueryClient();
8
+
9
+ const trpcClient = createTRPCClient<AppRouter>({
10
+ links: [
11
+ httpBatchLink({
12
+ url: `${process.env.EXPO_PUBLIC_SERVER_URL}/trpc`,
13
+ headers() {
14
+ const headers = new Map<string, string>();
15
+ const cookies = authClient.getCookie();
16
+ if (cookies) {
17
+ headers.set("Cookie", cookies);
18
+ }
19
+ return Object.fromEntries(headers);
20
+ },
21
+ }),
22
+ ],
23
+ });
24
+
25
+ export const trpc = createTRPCOptionsProxy<AppRouter>({
26
+ client: trpcClient,
27
+ queryClient,
28
+ });
@@ -31,6 +31,15 @@
31
31
  "recommended": true,
32
32
  "correctness": {
33
33
  "useExhaustiveDependencies": "info"
34
+ },
35
+ "nursery": {
36
+ "useSortedClasses": {
37
+ "level": "warn",
38
+ "fix": "safe",
39
+ "options": {
40
+ "functions": ["clsx", "cva", "cn"]
41
+ }
42
+ }
34
43
  }
35
44
  }
36
45
  },