create-better-t-stack 1.0.10 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +7 -0
  2. package/dist/index.js +74 -60
  3. package/package.json +1 -3
  4. package/template/base/apps/server/package.json +1 -9
  5. package/template/base/apps/server/tsconfig.json +1 -1
  6. package/template/with-auth/apps/client/src/components/sign-in-form.tsx +1 -1
  7. package/template/with-auth/apps/client/src/components/sign-up-form.tsx +142 -142
  8. package/template/{with-prisma-sqlite/apps/server/src/with-auth-lib/context.ts → with-auth/apps/server/src/lib/with-elysia-context.ts} +4 -4
  9. package/template/{with-drizzle-sqlite/apps/server/src/with-auth-lib/context.ts → with-auth/apps/server/src/lib/with-hono-context.ts} +3 -3
  10. package/template/with-auth/apps/server/src/routers/index.ts +11 -13
  11. package/template/with-auth/apps/server/src/with-elysia-index.ts +38 -0
  12. package/template/with-auth/apps/server/src/with-hono-index.ts +39 -0
  13. package/template/with-elysia/apps/server/src/index.ts +27 -0
  14. package/template/with-elysia/apps/server/src/lib/context.ts +13 -0
  15. package/template/with-hono/apps/server/src/index.ts +33 -0
  16. package/template/{base → with-hono}/apps/server/src/lib/context.ts +2 -2
  17. package/template/base/apps/server/src/index.ts +0 -41
  18. package/template/with-auth/apps/server/src/index.ts +0 -46
  19. package/template/with-drizzle-postgres/apps/server/src/routers/todo.ts +0 -44
  20. package/template/with-drizzle-postgres/apps/server/src/with-auth-lib/context.ts +0 -18
  21. package/template/with-drizzle-postgres/apps/server/src/with-auth-lib/trpc.ts +0 -24
  22. package/template/with-drizzle-sqlite/apps/server/src/with-auth-lib/trpc.ts +0 -24
  23. package/template/with-prisma-postgres/apps/server/src/with-auth-lib/context.ts +0 -18
  24. package/template/with-prisma-postgres/apps/server/src/with-auth-lib/trpc.ts +0 -24
  25. package/template/with-prisma-sqlite/apps/server/src/with-auth-lib/trpc.ts +0 -24
  26. package/template/{with-drizzle-postgres/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-drizzle-postgres-lib}/auth.ts +1 -1
  27. /package/template/{with-drizzle-sqlite/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-drizzle-sqlite-lib}/auth.ts +0 -0
  28. /package/template/{with-prisma-postgres/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-prisma-postgres-lib}/auth.ts +0 -0
  29. /package/template/{with-prisma-sqlite/apps/server/src/with-auth-lib → with-auth/apps/server/src/with-prisma-sqlite-lib}/auth.ts +0 -0
package/README.md CHANGED
@@ -19,6 +19,7 @@ Follow the prompts to configure your project.
19
19
  - **Monorepo**: Turborepo for optimized build system and workspace management
20
20
  - **Frontend**: React, TanStack Router, TanStack Query, Tailwind CSS with shadcn/ui components
21
21
  - **Backend**: Hono, tRPC
22
+ - **Runtime Options**: Choose between Bun or Node.js for your server
22
23
  - **Database Options**: SQLite (via Turso), PostgreSQL, or no database
23
24
  - **ORM Selection**: Choose between Drizzle ORM or Prisma
24
25
  - **Authentication**: Optional auth setup with Better-Auth
@@ -60,6 +61,7 @@ Options:
60
61
  --no-install Skip installing dependencies
61
62
  --turso Set up Turso for SQLite database (default with sqlite)
62
63
  --no-turso Skip Turso setup for SQLite database
64
+ --runtime <runtime> Specify runtime (bun or node)
63
65
  -h, --help Display help
64
66
  ```
65
67
 
@@ -75,6 +77,11 @@ Create a project with specific options:
75
77
  npx create-better-t-stack my-app --postgres --prisma --auth --pwa --biome
76
78
  ```
77
79
 
80
+ Create a project with Node.js runtime:
81
+ ```bash
82
+ npx create-better-t-stack my-app --runtime node
83
+ ```
84
+
78
85
  ## License
79
86
 
80
87
  MIT
package/dist/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as Ra,intro as za,log as k,outro as La,spinner as Na}from"@clack/prompts";import{Command as Fa}from"commander";import $ from"picocolors";import K from"node:path";import{fileURLToPath as Ve}from"node:url";var He=Ve(import.meta.url),We=K.dirname(He),f=K.join(We,"../"),d={projectName:"my-better-t-app",database:"sqlite",orm:"drizzle",auth:!0,addons:[],git:!0,packageManager:"npm",noInstall:!1,examples:["todo"]},B={"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"};import Nt from"node:path";import{cancel as Ft,spinner as Ut}from"@clack/prompts";import _t from"fs-extra";import je from"picocolors";import S from"node:path";import m from"fs-extra";import Qe from"node:path";import X from"fs-extra";var h=e=>{let{dependencies:t=[],devDependencies:a=[],projectDir:o}=e,r=Qe.join(o,"package.json"),s=X.readJSONSync(r);s.dependencies||(s.dependencies={}),s.devDependencies||(s.devDependencies={});for(let i of t){let n=B[i];s.dependencies[i]=n}for(let i of a){let n=B[i];s.devDependencies[i]=n}X.writeJSONSync(r,s,{spaces:2})};import N from"node:path";import{log as Ke,spinner as Xe}from"@clack/prompts";import{execa as Ye}from"execa";import G from"fs-extra";import Y from"picocolors";async function Z(e,t){let a=Xe(),o=N.join(e,"apps/client");try{a.start("Setting up Tauri desktop app support..."),h({devDependencies:["@tauri-apps/cli"],projectDir:o});let r=N.join(o,"package.json");if(await G.pathExists(r)){let n=await G.readJson(r);n.scripts={...n.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await G.writeJson(r,n,{spaces:2})}let s,i;switch(t){case"npm":s="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":s="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":s="bunx",i=["@tauri-apps/cli@latest"];break;default:s="npx",i=["@tauri-apps/cli@latest"]}i=[...i,"init",`--app-name=${N.basename(e)}`,`--window-title=${N.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${t} run dev`,`--before-build-command=${t} run build`],await Ye(s,i,{cwd:o,env:{CI:"true"}}),a.stop("Tauri desktop app support configured successfully!")}catch(r){throw a.stop(Y.red("Failed to set up Tauri")),r instanceof Error&&Ke.error(Y.red(r.message)),r}}async function ee(e,t,a){t.includes("pwa")&&await tt(e),t.includes("tauri")&&await Z(e,a),t.includes("biome")&&await Ze(e),t.includes("husky")&&await et(e)}async function Ze(e){let t=S.join(f,"template/with-biome");await m.pathExists(t)&&await m.copy(t,e,{overwrite:!0}),h({devDependencies:["@biomejs/biome"],projectDir:e});let a=S.join(e,"package.json");if(await m.pathExists(a)){let o=await m.readJson(a);o.scripts={...o.scripts,check:"biome check --write ."},await m.writeJson(a,o,{spaces:2})}}async function et(e){let t=S.join(f,"template/with-husky");await m.pathExists(t)&&await m.copy(t,e,{overwrite:!0}),h({devDependencies:["husky","lint-staged"],projectDir:e});let a=S.join(e,"package.json");if(await m.pathExists(a)){let o=await m.readJson(a);o.scripts={...o.scripts,prepare:"husky"},o["lint-staged"]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":["biome check --write ."]},await m.writeJson(a,o,{spaces:2})}}async function tt(e){let t=S.join(f,"template/with-pwa");await m.pathExists(t)&&await m.copy(t,e,{overwrite:!0});let a=S.join(e,"apps/client");h({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:a});let o=S.join(a,"package.json");if(await m.pathExists(o)){let r=await m.readJson(o);r.scripts={...r.scripts,"generate-pwa-assets":"pwa-assets-generator"},await m.writeJson(o,r,{spaces:2})}}import te from"node:path";import{log as ae}from"@clack/prompts";import oe from"picocolors";function re(e=32){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a="",o=t.length;for(let r=0;r<e;r++)a+=t.charAt(Math.floor(Math.random()*o));return a}async function se(e,t){if(!t)return;let a=te.join(e,"apps/server"),o=te.join(e,"apps/client");try{h({dependencies:["better-auth"],projectDir:a}),h({dependencies:["better-auth"],projectDir:o})}catch(r){throw ae.error(oe.red("Failed to configure authentication")),r instanceof Error&&ae.error(oe.red(r.message)),r}}import at from"node:path";import ot from"fs-extra";async function ie(e,t){let a=at.join(e,"README.md"),o=rt(t);try{await ot.writeFile(a,o)}catch(r){console.error("Failed to create README.md file:",r)}}function rt(e){let{projectName:t,packageManager:a,database:o,auth:r,addons:s=[],orm:i="drizzle"}=e,n=a==="npm"?"npm run":a;return`# ${t}
2
+ import{cancel as tr,intro as ar,log as $,outro as rr,spinner as or}from"@clack/prompts";import{Command as ir}from"commander";import E from"picocolors";import ee from"node:path";import{fileURLToPath as tt}from"node:url";var z=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var at=tt(import.meta.url),rt=ee.dirname(at),y=ee.join(rt,"../"),c={projectName:"my-better-t-app",database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:z(),noInstall:!1,turso:!1,backendFramework:"hono",runtime:"bun"},q={"better-auth":"^1.2.4","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",postgres:"^3.4.5","@prisma/client":"^6.5.0",prisma:"^6.5.0","vite-plugin-pwa":"^0.21.2","@vite-pwa/assets-generator":"^0.2.6","@tauri-apps/cli":"^2.4.0","@biomejs/biome":"1.9.4",husky:"^9.1.7","lint-staged":"^15.5.0","@hono/node-server":"^1.14.0",tsx:"^4.19.2","@types/node":"^22.13.11","@types/bun":"^1.2.6","@elysiajs/node":"^1.2.6","@elysiajs/cors":"^1.2.0","@elysiajs/trpc":"^1.1.0",elysia:"^1.2.25","@hono/trpc-server":"^0.3.4",hono:"^4.7.5"};import Kt from"node:path";import{cancel as Xt,spinner as Yt}from"@clack/prompts";import Zt from"fs-extra";import Ce from"picocolors";import S from"node:path";import k from"fs-extra";import ot from"node:path";import te from"fs-extra";var h=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,o=ot.join(r,"package.json"),i=te.readJSONSync(o);i.dependencies||(i.dependencies={}),i.devDependencies||(i.devDependencies={});for(let s of a){let n=q[s];i.dependencies[s]=n}for(let s of t){let n=q[s];i.devDependencies[s]=n}te.writeJSONSync(o,i,{spaces:2})};import U from"node:path";import{log as it,spinner as st}from"@clack/prompts";import{execa as nt}from"execa";import V from"fs-extra";import ae from"picocolors";async function re(e,a){let t=st(),r=U.join(e,"apps/client");try{t.start("Setting up Tauri desktop app support..."),h({devDependencies:["@tauri-apps/cli"],projectDir:r});let o=U.join(r,"package.json");if(await V.pathExists(o)){let n=await V.readJson(o);n.scripts={...n.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await V.writeJson(o,n,{spaces:2})}let i,s;switch(a){case"npm":i="npx",s=["@tauri-apps/cli@latest"];break;case"pnpm":i="pnpm",s=["dlx","@tauri-apps/cli@latest"];break;case"bun":i="bunx",s=["@tauri-apps/cli@latest"];break;default:i="npx",s=["@tauri-apps/cli@latest"]}s=[...s,"init",`--app-name=${U.basename(e)}`,`--window-title=${U.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await nt(i,s,{cwd:r,env:{CI:"true"}}),t.stop("Tauri desktop app support configured successfully!")}catch(o){throw t.stop(ae.red("Failed to set up Tauri")),o instanceof Error&&it.error(ae.red(o.message)),o}}async function oe(e,a,t){a.includes("pwa")&&await lt(e),a.includes("tauri")&&await re(e,t),a.includes("biome")&&await ct(e),a.includes("husky")&&await pt(e)}async function ct(e){let a=S.join(y,"template/with-biome");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),h({devDependencies:["@biomejs/biome"],projectDir:e});let t=S.join(e,"package.json");if(await k.pathExists(t)){let r=await k.readJson(t);r.scripts={...r.scripts,check:"biome check --write ."},await k.writeJson(t,r,{spaces:2})}}async function pt(e){let a=S.join(y,"template/with-husky");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),h({devDependencies:["husky","lint-staged"],projectDir:e});let t=S.join(e,"package.json");if(await k.pathExists(t)){let r=await k.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 k.writeJson(t,r,{spaces:2})}}async function lt(e){let a=S.join(y,"template/with-pwa");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0});let t=S.join(e,"apps/client");h({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let r=S.join(t,"package.json");if(await k.pathExists(r)){let o=await k.readJson(r);o.scripts={...o.scripts,"generate-pwa-assets":"pwa-assets-generator"},await k.writeJson(r,o,{spaces:2})}}import ie from"node:path";import{log as se}from"@clack/prompts";import ne from"picocolors";function ce(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",r=a.length;for(let o=0;o<e;o++)t+=a.charAt(Math.floor(Math.random()*r));return t}async function pe(e,a){if(!a)return;let t=ie.join(e,"apps/server"),r=ie.join(e,"apps/client");try{h({dependencies:["better-auth"],projectDir:t}),h({dependencies:["better-auth"],projectDir:r})}catch(o){throw se.error(ne.red("Failed to configure authentication")),o instanceof Error&&se.error(ne.red(o.message)),o}}import dt from"node:path";async function le(e,a,t){let r=dt.join(e,"apps/server"),o=[],i=[];a==="hono"?(o.push("hono","@hono/trpc-server"),t==="node"&&(o.push("@hono/node-server"),i.push("tsx","@types/node"))):a==="elysia"&&(o.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(o.push("@elysiajs/node"),i.push("tsx","@types/node"))),t==="bun"&&i.push("@types/bun"),h({dependencies:o,devDependencies:i,projectDir:r})}import ut from"node:path";import mt from"fs-extra";async function de(e,a){let t=ut.join(e,"README.md"),r=ft(a);try{await mt.writeFile(t,r)}catch(o){console.error("Failed to create README.md file:",o)}}function ft(e){let{projectName:a,packageManager:t,database:r,auth:o,addons:i=[],orm:s="drizzle",runtime:n="bun"}=e,u=t==="npm"?"npm run":t;return`# ${a}
3
3
 
4
4
  This project was created with [Better-T-Stack](https://github.com/better-t-stack/Better-T-Stack), a modern TypeScript stack that combines React, TanStack Router, Hono, tRPC, and more.
5
5
 
6
6
  ## Features
7
7
 
8
- ${st(o,r,s,i)}
8
+ ${ht(r,o,i,s,n)}
9
9
 
10
10
  ## Getting Started
11
11
 
12
12
  First, install the dependencies:
13
13
 
14
14
  \`\`\`bash
15
- ${a} install
15
+ ${t} install
16
16
  \`\`\`
17
17
 
18
- ${it(o,r,n,i)}
18
+ ${gt(r,o,u,s)}
19
19
 
20
20
  Then, run the development server:
21
21
 
22
22
  \`\`\`bash
23
- ${n} dev
23
+ ${u} dev
24
24
  \`\`\`
25
25
 
26
26
  Open [http://localhost:3001](http://localhost:3001) in your browser to see the client application.
@@ -29,7 +29,7 @@ The API is running at [http://localhost:3000](http://localhost:3000).
29
29
  ## Project Structure
30
30
 
31
31
  \`\`\`
32
- ${t}/
32
+ ${a}/
33
33
  \u251C\u2500\u2500 apps/
34
34
  \u2502 \u251C\u2500\u2500 client/ # Frontend application (React, TanStack Router)
35
35
  \u2502 \u2514\u2500\u2500 server/ # Backend API (Hono, tRPC)
@@ -37,41 +37,41 @@ ${t}/
37
37
 
38
38
  ## Available Scripts
39
39
 
40
- ${nt(n,o,i,r)}
41
- `}function st(e,t,a,o){let r=["- **TypeScript** - For type safety and improved developer experience","- **TanStack Router** - File-based routing with full type safety","- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs"];e!=="none"&&r.push(`- **${o==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),t&&r.push("- **Authentication** - Email & password authentication with Better Auth");for(let s of a)s==="docker"&&r.push("- **Docker** - Containerized deployment");return r.join(`
42
- `)}function it(e,t,a,o){if(e==="none")return"";let r=`## Database Setup
40
+ ${wt(u,r,s,o)}
41
+ `}function ht(e,a,t,r,o){let i=["- **TypeScript** - For type safety and improved developer experience","- **TanStack Router** - File-based routing with full type safety","- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs",`- **${o==="bun"?"Bun":"Node.js"}** - Runtime environment`];e!=="none"&&i.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&i.push("- **Authentication** - Email & password authentication with Better Auth");for(let s of t)s==="pwa"?i.push("- **PWA** - Progressive Web App support"):s==="tauri"?i.push("- **Tauri** - Build native desktop applications"):s==="biome"?i.push("- **Biome** - Linting and formatting"):s==="husky"&&i.push("- **Husky** - Git hooks for code quality");return i.join(`
42
+ `)}function gt(e,a,t,r){if(e==="none")return"";let o=`## Database Setup
43
43
 
44
- `;return e==="sqlite"?r+=`This project uses SQLite${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
44
+ `;return e==="sqlite"?o+=`This project uses SQLite${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
45
45
 
46
46
  1. Start the local SQLite database:
47
47
  \`\`\`bash
48
- cd apps/server && ${a} db:local
48
+ cd apps/server && ${t} db:local
49
49
  \`\`\`
50
50
 
51
51
  2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed.
52
- `:e==="postgres"&&(r+=`This project uses PostgreSQL${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
52
+ `:e==="postgres"&&(o+=`This project uses PostgreSQL${r==="drizzle"?" with Drizzle ORM":" with Prisma"}.
53
53
 
54
54
  1. Make sure you have a PostgreSQL database set up.
55
55
  2. Update your \`apps/server/.env\` file with your PostgreSQL connection details.
56
- `),r+=`
57
- ${t?"4":"3"}. ${o==="prisma"?`Generate the Prisma client and push the schema:
56
+ `),o+=`
57
+ ${a?"4":"3"}. ${r==="prisma"?`Generate the Prisma client and push the schema:
58
58
  \`\`\`bash
59
- ${a} db:push
59
+ ${t} db:push
60
60
  \`\`\``:`Apply the schema to your database:
61
61
  \`\`\`bash
62
- ${a} db:push
62
+ ${t} db:push
63
63
  \`\`\``}
64
- `,r}function nt(e,t,a,o){let r=`- \`${e} dev\`: Start both client and server in development mode
64
+ `,o}function wt(e,a,t,r){let o=`- \`${e} dev\`: Start both client and server in development mode
65
65
  - \`${e} build\`: Build both client and server
66
66
  - \`${e} dev:client\`: Start only the client
67
67
  - \`${e} dev:server\`: Start only the server
68
- - \`${e} check-types\`: Check TypeScript types across all apps`;return t!=="none"&&(r+=`
68
+ - \`${e} check-types\`: Check TypeScript types across all apps`;return a!=="none"&&(o+=`
69
69
  - \`${e} db:push\`: Push schema changes to database
70
- - \`${e} db:studio\`: Open database studio UI`,t==="sqlite"&&a==="drizzle"&&(r+=`
71
- - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),r}import pe from"node:path";import{log as Pt,spinner as jt}from"@clack/prompts";import kt from"fs-extra";import le from"picocolors";import ct from"node:os";import ne from"node:path";import{cancel as q,confirm as pt,isCancel as J,log as A,select as lt,spinner as V,text as dt}from"@clack/prompts";import{$ as y}from"execa";import ut from"fs-extra";import w from"picocolors";async function mt(){try{return(await y`turso --version`).exitCode===0}catch{return!1}}async function ft(){try{return!(await y`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function ht(){let e=V();try{return e.start("Logging in to Turso..."),await y`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(t){throw e.stop(w.red("Failed to log in to Turso")),t}}async function gt(e){let t=V();try{if(t.start("Installing Turso CLI..."),e)await y`brew install tursodatabase/tap/turso`;else{let{stdout:a}=await y`curl -sSfL https://get.tur.so/install.sh`;await y`bash -c '${a}'`}return t.stop("Turso CLI installed successfully!"),!0}catch(a){throw a instanceof Error&&a.message.includes("User force closed")?(t.stop(),A.warn(w.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(t.stop(w.red("Failed to install Turso CLI")),a)}}async function wt(){try{let{stdout:e}=await y`turso group list`,t=e.trim().split(`
72
- `);return t.length<=1?[]:t.slice(1).map(o=>{let[r,s,i,n]=o.trim().split(/\s{2,}/);return{name:r,locations:s,version:i,status:n}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function bt(){let e=await wt();if(e.length===0)return null;if(e.length===1)return e[0].name;let t=e.map(o=>({value:o.name,label:`${o.name} (${o.locations})`})),a=await lt({message:"Select a Turso database group:",options:t});return J(a)&&(q(w.red("Operation cancelled")),process.exit(0)),a}async function yt(e,t){try{t?await y`turso db create ${e} --group ${t}`:await y`turso db create ${e}`}catch(r){throw r instanceof Error&&r.message.includes("already exists")?new Error("DATABASE_EXISTS"):r}let{stdout:a}=await y`turso db show ${e} --url`,{stdout:o}=await y`turso db tokens create ${e}`;return{dbUrl:a.trim(),authToken:o.trim()}}async function R(e,t){let a=ne.join(e,"apps/server",".env"),o=t?`TURSO_CONNECTION_URL="${t.dbUrl}"
73
- TURSO_AUTH_TOKEN="${t.authToken}"`:`TURSO_CONNECTION_URL=
74
- TURSO_AUTH_TOKEN=`;await ut.writeFile(a,o)}function F(){A.info(`Manual Turso Setup Instructions:
70
+ - \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(o+=`
71
+ - \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),o}import fe from"node:path";import{log as Ot,spinner as Ft}from"@clack/prompts";import St from"fs-extra";import he from"picocolors";import bt from"node:os";import ue from"node:path";import{cancel as H,confirm as yt,isCancel as W,log as I,select as kt,spinner as Q,text as Pt}from"@clack/prompts";import{$ as x}from"execa";import jt from"fs-extra";import j from"picocolors";async function vt(){try{return(await x`turso --version`).exitCode===0}catch{return!1}}async function xt(){try{return!(await x`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function Tt(){let e=Q();try{return e.start("Logging in to Turso..."),await x`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(j.red("Failed to log in to Turso")),a}}async function $t(e){let a=Q();try{if(a.start("Installing Turso CLI..."),e)await x`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await x`curl -sSfL https://get.tur.so/install.sh`;await x`bash -c '${t}'`}return a.stop("Turso CLI installed successfully!"),!0}catch(t){throw t instanceof Error&&t.message.includes("User force closed")?(a.stop(),I.warn(j.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(j.red("Failed to install Turso CLI")),t)}}async function Et(){try{let{stdout:e}=await x`turso group list`,a=e.trim().split(`
72
+ `);return a.length<=1?[]:a.slice(1).map(r=>{let[o,i,s,n]=r.trim().split(/\s{2,}/);return{name:o,locations:i,version:s,status:n}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function Ct(){let e=await Et();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 W(t)&&(H(j.red("Operation cancelled")),process.exit(0)),t}async function Dt(e,a){try{a?await x`turso db create ${e} --group ${a}`:await x`turso db create ${e}`}catch(o){throw o instanceof Error&&o.message.includes("already exists")?new Error("DATABASE_EXISTS"):o}let{stdout:t}=await x`turso db show ${e} --url`,{stdout:r}=await x`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:r.trim()}}async function L(e,a){let t=ue.join(e,"apps/server",".env"),r=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
73
+ TURSO_AUTH_TOKEN="${a.authToken}"`:`TURSO_CONNECTION_URL=
74
+ TURSO_AUTH_TOKEN=`;await jt.writeFile(t,r)}function B(){I.info(`Manual Turso Setup Instructions:
75
75
 
76
76
  1. Visit https://turso.tech and create an account
77
77
  2. Create a new database from the dashboard
@@ -79,51 +79,65 @@ TURSO_AUTH_TOKEN=`;await ut.writeFile(a,o)}function F(){A.info(`Manual Turso Set
79
79
  4. Add these credentials to the .env file in apps/server/.env
80
80
 
81
81
  TURSO_CONNECTION_URL=your_database_url
82
- TURSO_AUTH_TOKEN=your_auth_token`)}async function ce(e,t){if(!t){await R(e),A.info(w.blue("Skipping Turso setup. Setting up empty configuration.")),F();return}let a=ct.platform(),o=a==="darwin";if(!(a!=="win32")){A.warn(w.yellow("Automatic Turso setup is not supported on Windows.")),await R(e),F();return}try{if(!await mt()){let x=await pt({message:"Would you like to install Turso CLI?",initialValue:!0});if(J(x)&&(q(w.red("Operation cancelled")),process.exit(0)),!x){await R(e),F();return}await gt(o)}await ft()||await ht();let n=await bt(),g=!1,v="",T=ne.basename(e);for(;!g;){let x=await dt({message:"Enter a name for your database:",defaultValue:T,initialValue:T,placeholder:T});J(x)&&(q(w.red("Operation cancelled")),process.exit(0)),v=x;let L=V();try{L.start(`Creating Turso database "${v}"${n?` in group "${n}"`:""}...`);let D=await yt(v,n);await R(e,D),L.stop("Turso database configured successfully!"),g=!0}catch(D){if(D instanceof Error&&D.message==="DATABASE_EXISTS")L.stop(w.yellow(`Database "${w.red(v)}" already exists`)),T=`${v}-${Math.floor(Math.random()*1e3)}`;else throw L.stop(w.red("Failed to create Turso database")),D}}}catch(s){A.error(w.red(`Error during Turso setup: ${s}`)),await R(e),F(),A.success("Setup completed with manual configuration required.")}}async function de(e,t,a,o=!0){let r=jt(),s=pe.join(e,"apps/server");if(t==="none"){await kt.remove(pe.join(s,"src/db"));return}try{t==="sqlite"?(a==="drizzle"?h({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:s}):a==="prisma"&&h({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:s}),o&&await ce(e,!0)):t==="postgres"&&(a==="drizzle"?h({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:s}):a==="prisma"&&h({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:s}))}catch(i){throw r.stop(le.red("Failed to set up database")),i instanceof Error&&Pt.error(le.red(i.message)),i}}import U from"node:path";import I from"fs-extra";async function ue(e,t){let a=U.join(e,"apps/server"),o=U.join(e,"apps/client"),r=U.join(a,".env"),s="";if(await I.pathExists(r)&&(s=await I.readFile(r,"utf8")),s.includes("CORS_ORIGIN")||(s+=`
83
- CORS_ORIGIN=http://localhost:3001`),t.auth&&(s.includes("BETTER_AUTH_SECRET")||(s+=`
84
- BETTER_AUTH_SECRET=${re()}`),s.includes("BETTER_AUTH_URL")||(s+=`
85
- BETTER_AUTH_URL=http://localhost:3000`)),t.database!=="none"){if(t.orm==="prisma"&&!s.includes("DATABASE_URL")){let g=t.database==="sqlite"?"":`
86
- DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;s+=g}t.database==="sqlite"&&!t.turso&&(s.includes("TURSO_CONNECTION_URL")||(s+=`
87
- TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}await I.writeFile(r,s.trim());let i=U.join(o,".env"),n="";await I.pathExists(i)&&(n=await I.readFile(i,"utf8")),n.includes("VITE_SERVER_URL")||(n+=`VITE_SERVER_URL=http://localhost:3000
88
- `),await I.writeFile(i,n.trim())}import P from"node:path";import u from"fs-extra";async function me(e,t,a,o){t.includes("todo")?await vt(e,a,o):await xt(e,a)}async function vt(e,t,a){let o=P.join(f,"template/examples/todo");if(await u.pathExists(o)){let r=P.join(o,"apps/client/src/routes"),s=P.join(e,"apps/client/src/routes");if(await u.copy(r,s,{overwrite:!0}),t!=="none"){let i=P.join(o,`apps/server/src/routers/with-${t}-todo.ts`),n=P.join(e,"apps/server/src/routers/todo.ts");await u.pathExists(i)&&await u.copy(i,n,{overwrite:!0})}await Tt(e,a),await Et(e)}}async function Tt(e,t){let a=P.join(e,"apps/client/src/components/header.tsx");if(await u.pathExists(a)){let o=await u.readFile(a,"utf8");t?o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
82
+ TURSO_AUTH_TOKEN=your_auth_token`)}async function me(e,a){if(!a){await L(e),I.info(j.blue("Skipping Turso setup. Setting up empty configuration.")),B();return}let t=bt.platform(),r=t==="darwin";if(!(t!=="win32")){I.warn(j.yellow("Automatic Turso setup is not supported on Windows.")),await L(e),B();return}try{if(!await vt()){let P=await yt({message:"Would you like to install Turso CLI?",initialValue:!0});if(W(P)&&(H(j.red("Operation cancelled")),process.exit(0)),!P){await L(e),B();return}await $t(r)}await xt()||await Tt();let n=await Ct(),u=!1,f="",b=ue.basename(e);for(;!u;){let P=await Pt({message:"Enter a name for your database:",defaultValue:b,initialValue:b,placeholder:b});W(P)&&(H(j.red("Operation cancelled")),process.exit(0)),f=P;let C=Q();try{C.start(`Creating Turso database "${f}"${n?` in group "${n}"`:""}...`);let D=await Dt(f,n);await L(e,D),C.stop("Turso database configured successfully!"),u=!0}catch(D){if(D instanceof Error&&D.message==="DATABASE_EXISTS")C.stop(j.yellow(`Database "${j.red(f)}" already exists`)),b=`${f}-${Math.floor(Math.random()*1e3)}`;else throw C.stop(j.red("Failed to create Turso database")),D}}}catch(i){I.error(j.red(`Error during Turso setup: ${i}`)),await L(e),B(),I.success("Setup completed with manual configuration required.")}}async function ge(e,a,t,r=!0){let o=Ft(),i=fe.join(e,"apps/server");if(a==="none"){await St.remove(fe.join(i,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?h({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:i}):t==="prisma"&&h({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:i}),r&&await me(e,!0)):a==="postgres"&&(t==="drizzle"?h({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:i}):t==="prisma"&&h({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:i}))}catch(s){throw o.stop(he.red("Failed to set up database")),s instanceof Error&&Ot.error(he.red(s.message)),s}}import _ from"node:path";import R from"fs-extra";async function we(e,a){let t=_.join(e,"apps/server"),r=_.join(e,"apps/client"),o=_.join(t,".env"),i="";if(await R.pathExists(o)&&(i=await R.readFile(o,"utf8")),i.includes("CORS_ORIGIN")||(i+=`
83
+ CORS_ORIGIN=http://localhost:3001`),a.auth&&(i.includes("BETTER_AUTH_SECRET")||(i+=`
84
+ BETTER_AUTH_SECRET=${ce()}`),i.includes("BETTER_AUTH_URL")||(i+=`
85
+ BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!i.includes("DATABASE_URL")){let u=a.database==="sqlite"?"":`
86
+ DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;i+=u}a.database==="sqlite"&&!a.turso&&(i.includes("TURSO_CONNECTION_URL")||(i+=`
87
+ TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}await R.writeFile(o,i.trim());let s=_.join(r,".env"),n="";await R.pathExists(s)&&(n=await R.readFile(s,"utf8")),n.includes("VITE_SERVER_URL")||(n+=`VITE_SERVER_URL=http://localhost:3000
88
+ `),await R.writeFile(s,n.trim())}import T from"node:path";import w from"fs-extra";async function be(e,a,t,r){a.includes("todo")?await At(e,t,r):await Rt(e,t)}async function At(e,a,t){let r=T.join(y,"template/examples/todo");if(await w.pathExists(r)){let o=T.join(r,"apps/client/src/routes"),i=T.join(e,"apps/client/src/routes");if(await w.copy(o,i,{overwrite:!0}),a!=="none"){let s=T.join(r,`apps/server/src/routers/with-${a}-todo.ts`),n=T.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(s)&&await w.copy(s,n,{overwrite:!0})}await It(e,t),await Nt(e)}}async function It(e,a){let t=T.join(e,"apps/client/src/components/header.tsx");if(await w.pathExists(t)){let r=await w.readFile(t,"utf8");a?r=r.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
89
89
  { to: "/", label: "Home" },
90
90
  { to: "/dashboard", label: "Dashboard" },
91
- { to: "/todos", label: "Todos" },`):o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
91
+ { to: "/todos", label: "Todos" },`):r=r.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
92
92
  { to: "/", label: "Home" },
93
- { to: "/todos", label: "Todos" },`),await u.writeFile(a,o)}}async function xt(e,t){if(t==="drizzle"){let o=P.join(e,"apps/server/src/db/schema/todo.ts");await u.pathExists(o)&&await u.remove(o)}else if(t==="prisma"){let o=P.join(e,"apps/server/prisma/schema/todo.prisma");await u.pathExists(o)&&await u.remove(o)}let a=P.join(e,"apps/server/src/routers/todo.ts");await u.pathExists(a)&&await u.remove(a),await $t(e)}async function $t(e){let t=P.join(e,"apps/server/src/routers/index.ts");if(await u.pathExists(t)){let a=await u.readFile(t,"utf8");a=a.replace(/import { todoRouter } from ".\/todo";/,""),a=a.replace(/todo: todoRouter,/,""),await u.writeFile(t,a)}}async function Et(e){let t=P.join(e,"apps/client/src/routes/index.tsx");if(await u.pathExists(t)){let a=await u.readFile(t,"utf8");a=a.replace(/<div id="buttons"><\/div>/,`<div id="buttons" className="mt-4 flex flex-col gap-4 sm:flex-row sm:items-center">
93
+ { to: "/todos", label: "Todos" },`),await w.writeFile(t,r)}}async function Rt(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 Lt(e)}async function Lt(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)}}async function Nt(e){let a=T.join(e,"apps/client/src/routes/index.tsx");if(await w.pathExists(a)){let t=await w.readFile(a,"utf8");t=t.replace(/<div id="buttons"><\/div>/,`<div id="buttons" className="mt-4 flex flex-col gap-4 sm:flex-row sm:items-center">
94
94
  <Button asChild>
95
95
  <Link to="/todos" className="flex items-center">
96
96
  View Todo Demo
97
97
  <ArrowRight className="ml-1 h-4 w-4" />
98
98
  </Link>
99
99
  </Button>
100
- </div>`),await u.writeFile(t,a)}}import{log as Ct}from"@clack/prompts";import p from"picocolors";function fe(e,t,a,o,r,s){let i=a==="npm"?"npm run":a,n=`cd ${t}`,g=s?.includes("husky")||s?.includes("biome"),v=e!=="none"?Ot(e,r,i):"",T=s?.includes("tauri")?At(i):"",x=g?St(i):"";Ct.info(`${p.cyan("Project created successfully!")}
101
-
102
- ${p.bold("Next steps:")}
103
- ${p.cyan("1.")} ${n}
104
- ${o?"":`${p.cyan("2.")} ${a} install
105
- `}${p.cyan(o?"2.":"3.")} ${i} dev
106
-
107
- ${p.bold("Your project will be available at:")}
108
- ${p.cyan("\u2022")} Frontend: http://localhost:3001
109
- ${p.cyan("\u2022")} API: http://localhost:3000
110
- ${v?`
111
- ${v.trim()}`:""}${T?`
112
- ${T.trim()}`:""}${x?`
113
- ${x.trim()}`:""}`)}function St(e){return`${p.bold("Linting and formatting:")}
114
- ${p.cyan("\u2022")} Format and lint fix: ${p.dim(`${e} check`)}
115
-
116
- `}function Ot(e,t,a){let o=[];return t==="prisma"?(e==="sqlite"&&o.push(`${p.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,`${p.dim("Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso")}`),o.push(`${p.cyan("\u2022")} Apply schema: ${p.dim(`${a} db:push`)}`),o.push(`${p.cyan("\u2022")} Database UI: ${p.dim(`${a} db:studio`)}`)):t==="drizzle"&&(e==="sqlite"&&o.push(`${p.cyan("\u2022")} Start local DB: ${p.dim(`cd apps/server && ${a} db:local`)}`),o.push(`${p.cyan("\u2022")} Apply schema: ${p.dim(`${a} db:push`)}`),o.push(`${p.cyan("\u2022")} Database UI: ${p.dim(`${a} db:studio`)}`)),o.length?`${p.bold("Database commands:")}
100
+ </div>`),await w.writeFile(a,t)}}import{log as zt}from"@clack/prompts";import d from"picocolors";function ye(e,a,t,r,o,i,s){let n=t==="npm"?"npm run":t,u=`cd ${a}`,f=i?.includes("husky")||i?.includes("biome"),b=e!=="none"?Bt(e,o,n,s):"",P=i?.includes("tauri")?_t(n):"",C=f?Ut(n):"";zt.info(`${d.bold("Next steps:")}
101
+ ${d.cyan("1.")} ${u}
102
+ ${r?"":`${d.cyan("2.")} ${t} install
103
+ `}${d.cyan(r?"2.":"3.")} ${n} dev
104
+
105
+ ${d.bold("Your project will be available at:")}
106
+ ${d.cyan("\u2022")} Frontend: http://localhost:3001
107
+ ${d.cyan("\u2022")} API: http://localhost:3000
108
+ ${b?`
109
+ ${b.trim()}`:""}${P?`
110
+ ${P.trim()}`:""}${C?`
111
+ ${C.trim()}`:""}`)}function Ut(e){return`${d.bold("Linting and formatting:")}
112
+ ${d.cyan("\u2022")} Format and lint fix: ${d.dim(`${e} check`)}
113
+
114
+ `}function Bt(e,a,t,r){let o=[];return a==="prisma"?(e==="sqlite"&&o.push(`${d.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,`${d.dim("Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso")}`),r==="bun"&&o.push(`${d.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors, follow the guidance provided in the error messages`),o.push(`${d.cyan("\u2022")} Apply schema: ${d.dim(`${t} db:push`)}`),o.push(`${d.cyan("\u2022")} Database UI: ${d.dim(`${t} db:studio`)}`)):a==="drizzle"&&(e==="sqlite"&&o.push(`${d.cyan("\u2022")} Start local DB: ${d.dim(`cd apps/server && ${t} db:local`)}`),o.push(`${d.cyan("\u2022")} Apply schema: ${d.dim(`${t} db:push`)}`),o.push(`${d.cyan("\u2022")} Database UI: ${d.dim(`${t} db:studio`)}`)),o.length?`${d.bold("Database commands:")}
117
115
  ${o.join(`
118
116
  `)}
119
117
 
120
- `:""}function At(e){return`${p.bold("Desktop app with Tauri:")}
121
- ${p.cyan("\u2022")} Start desktop app: ${p.dim(`cd apps/client && ${e} desktop:dev`)}
122
- ${p.cyan("\u2022")} Build desktop app: ${p.dim(`cd apps/client && ${e} desktop:build`)}
123
- ${p.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: ${p.dim("https://v2.tauri.app/start/prerequisites/")}
124
-
125
- `}import _ from"node:path";import{$ as It,execa as Dt}from"execa";import C from"fs-extra";async function he(e,t){await Rt(e,t),await zt(e,t)}async function Rt(e,t){let a=_.join(e,"package.json");if(await C.pathExists(a)){let o=await C.readJson(a);o.name=t.projectName;let{stdout:r}=await Dt(t.packageManager,["-v"],{cwd:e});if(o.packageManager=`${t.packageManager}@${r.trim()}`,await C.writeJson(a,o,{spaces:2}),t.packageManager==="pnpm"){let s=_.join(f,"template/with-pnpm/pnpm-workspace.yaml"),i=_.join(e,"pnpm-workspace.yaml");await C.pathExists(s)&&await C.copy(s,i)}}}async function zt(e,t){let a=_.join(e,"apps/server/package.json");if(await C.pathExists(a)){let o=await C.readJson(a);t.database!=="none"&&(t.database==="sqlite"&&(o.scripts["db:local"]="turso dev --db-file local.db"),t.orm==="prisma"?(o.scripts["db:push"]="prisma db push --schema ./prisma/schema",o.scripts["db:studio"]="prisma studio"):t.orm==="drizzle"&&(o.scripts["db:push"]="drizzle-kit push",o.scripts["db:studio"]="drizzle-kit studio")),await C.writeJson(a,o,{spaces:2})}}async function ge(e,t){t&&await It({cwd:e})`git init`}import j from"node:path";import b from"fs-extra";async function we(e){let t=j.join(f,"template/base");if(!await b.pathExists(t))throw new Error(`Template directory not found: ${t}`);await b.copy(t,e)}async function be(e,t){if(!t)return;let a=j.join(f,"template/with-auth");await b.pathExists(a)&&await b.copy(a,e,{overwrite:!0})}async function ye(e,t,a,o){if(t==="none"||a==="none")return;let r=j.join(f,Lt(t,a));if(await b.pathExists(r)){await b.copy(r,e,{overwrite:!0});let s=j.join(e,"apps/server/src"),i=j.join(s,"lib"),n=j.join(s,"with-auth-lib");o?await b.pathExists(n)&&(await b.remove(i),await b.move(n,i)):await b.remove(n)}}async function Pe(e){let t=[j.join(e,"_gitignore"),j.join(e,"apps/client/_gitignore"),j.join(e,"apps/server/_gitignore")];for(let a of t)if(await b.pathExists(a)){let o=j.join(j.dirname(a),".gitignore");await b.move(a,o)}}function Lt(e,t){return e==="drizzle"?t==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?t==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}async function ke(e){let t=Ut(),a=Nt.resolve(process.cwd(),e.projectName);try{return await _t.ensureDir(a),await we(a),await Pe(a),await be(a,e.auth),await ye(a,e.orm,e.database,e.auth),await me(a,e.examples,e.orm,e.auth),await de(a,e.database,e.orm,e.turso??e.database==="sqlite"),await se(a,e.auth),await ue(a,e),await ge(a,e.git),e.addons.length>0&&await ee(a,e.addons,e.packageManager),await he(a,e),await ie(a,e),fe(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons),a}catch(o){throw t.message(je.red("Failed")),o instanceof Error&&(Ft(je.red(`Error during project creation: ${o.message}`)),process.exit(1)),o}}import{log as ve,spinner as Te}from"@clack/prompts";import{$ as H}from"execa";import M from"picocolors";async function xe({projectDir:e,packageManager:t,addons:a=[]}){let o=Te();try{switch(o.start(`Running ${t} install...`),t){case"npm":await H({cwd:e,stderr:"inherit"})`${t} install`;break;case"pnpm":case"bun":await H({cwd:e})`${t} install`;break}o.stop("Dependencies installed successfully"),(a.includes("biome")||a.includes("husky"))&&await Mt(e,t)}catch(r){throw o.stop(M.red("Failed to install dependencies")),r instanceof Error&&ve.error(M.red(`Installation error: ${r.message}`)),r}}async function Mt(e,t){let a=Te();try{a.start("Running Biome format check..."),await H({cwd:e})`${t} biome check --write .`,a.stop("Biome check completed successfully")}catch{a.stop(M.yellow("Biome check encountered issues")),ve.warn(M.yellow("Some files may need manual formatting"))}}import{cancel as Sa,group as Oa}from"@clack/prompts";import Aa from"picocolors";import{cancel as Bt,isCancel as Gt,multiselect as qt}from"@clack/prompts";import Jt from"picocolors";async function $e(e){if(e!==void 0)return e;let t=await qt({message:"Which Addons would you like to add?",options:[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"},{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],required:!1});return Gt(t)&&(Bt(Jt.red("Operation cancelled")),process.exit(0)),t.includes("husky")&&!t.includes("biome")&&t.push("biome"),t}import{cancel as Vt,confirm as Ht,isCancel as Wt}from"@clack/prompts";import Qt from"picocolors";async function Ee(e,t){if(!t)return!1;if(e!==void 0)return e;let a=await Ht({message:"Would you like to add authentication with Better-Auth?",initialValue:d.auth});return Wt(a)&&(Vt(Qt.red("Operation cancelled")),process.exit(0)),a}import{cancel as Kt,isCancel as Xt,select as Yt}from"@clack/prompts";import Zt from"picocolors";async function Ce(e){if(e!==void 0)return e;let t=await Yt({message:"Which database would you like to use?",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:"sqlite"});return Xt(t)&&(Kt(Zt.red("Operation cancelled")),process.exit(0)),t}import{cancel as ea,isCancel as ta,multiselect as aa}from"@clack/prompts";import oa from"picocolors";async function Se(e,t){if(e!==void 0)return e;if(t==="none")return[];let a=await aa({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:d.examples});return ta(a)&&(ea(oa.red("Operation cancelled")),process.exit(0)),a}import{cancel as ra,confirm as sa,isCancel as ia}from"@clack/prompts";import na from"picocolors";async function Oe(e){if(e!==void 0)return e;let t=await sa({message:"Initialize a new git repository?",initialValue:d.git});return ia(t)&&(ra(na.red("Operation cancelled")),process.exit(0)),t}import{cancel as ca,confirm as pa,isCancel as la}from"@clack/prompts";import da from"picocolors";async function Ae(e){if(e!==void 0)return e;let t=await pa({message:"Do you want to install project dependencies?",initialValue:!d.noInstall});return la(t)&&(ca(da.red("Operation cancelled")),process.exit(0)),!t}import{cancel as ua,isCancel as ma,select as fa}from"@clack/prompts";import ha from"picocolors";async function Ie(e,t){if(!t)return"none";if(e!==void 0)return e;let a=await fa({message:"Which ORM would you like to use?",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM with schema migrations"}],initialValue:"drizzle"});return ma(a)&&(ua(ha.red("Operation cancelled")),process.exit(0)),a}import{cancel as ga,isCancel as wa,select as ba}from"@clack/prompts";import ya from"picocolors";var De=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};async function Re(e){if(e!==void 0)return e;let t=De(),a=await ba({message:"Which package manager do you want to use?",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:t});return wa(a)&&(ga(ya.red("Operation cancelled")),process.exit(0)),a}import z from"node:path";import{cancel as Pa,isCancel as ja,text as ka}from"@clack/prompts";import O from"fs-extra";import va from"picocolors";var Ta=["<",">",":",'"',"|","?","*"],ze=255;function Le(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>ze)return`Project name must be less than ${ze} characters`;if(Ta.some(t=>e.includes(t)))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 Ne(e){if(e)if(e==="."){let s=process.cwd();if(O.readdirSync(s).length===0)return e}else{let s=z.basename(e);if(!Le(s)){let n=z.resolve(process.cwd(),e);if(!O.pathExistsSync(n)||O.readdirSync(n).length===0)return e}}let t=!1,a="",o=d.projectName,r=1;for(;O.pathExistsSync(z.resolve(process.cwd(),o));)o=`${d.projectName}-${r}`,r++;for(;!t;){let s=await ka({message:"Enter your project name or path (relative to current directory)",placeholder:o,initialValue:e,defaultValue:o,validate:i=>{let n=i.trim()||o;if(n==="."){if(O.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";t=!0;return}let g=z.resolve(process.cwd(),n),v=z.basename(g),T=Le(v);if(T)return T;if(!g.startsWith(process.cwd()))return"Project path must be within current directory";if(O.pathExistsSync(g)&&O.readdirSync(g).length>0)return`Directory "${n}" already exists and is not empty. Please choose a different name or path.`;t=!0}});ja(s)&&(Pa(va.red("Operation cancelled.")),process.exit(0)),a=s||o}return a}import{cancel as xa,confirm as $a,isCancel as Ea}from"@clack/prompts";import Ca from"picocolors";async function Fe(e){if(e!==void 0)return e;let t=await $a({message:"Set up a Turso database for this project?",initialValue:!0});return Ea(t)&&(xa(Ca.red("Operation cancelled")),process.exit(0)),t}async function Ue(e){let t=await Oa({projectName:async()=>Ne(e.projectName),database:()=>Ce(e.database),orm:({results:a})=>Ie(e.orm,a.database!=="none"),auth:({results:a})=>Ee(e.auth,a.database!=="none"),turso:({results:a})=>a.database==="sqlite"&&a.orm!=="prisma"?Fe(e.turso):Promise.resolve(!1),addons:()=>$e(e.addons),examples:({results:a})=>Se(e.examples,a.database),git:()=>Oe(e.git),packageManager:()=>Re(e.packageManager),noInstall:()=>Ae(e.noInstall)},{onCancel:()=>{Sa(Aa.red("Operation cancelled")),process.exit(0)}});return{projectName:t.projectName,database:t.database,orm:t.orm,auth:t.auth,addons:t.addons,examples:t.examples,git:t.git,packageManager:t.packageManager,noInstall:t.noInstall,turso:t.turso}}import E from"picocolors";function W(e){let t=[];return e.projectName&&t.push(`${E.blue("Project Name:")} ${e.projectName}`),e.database&&t.push(`${E.blue("Database:")} ${e.database}`),e.orm&&t.push(`${E.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&t.push(`${E.blue("Authentication:")} ${e.auth}`),e.addons?.length&&t.push(`${E.blue("Addons:")} ${e.addons.join(", ")}`),e.git!==void 0&&t.push(`${E.blue("Git Init:")} ${e.git}`),e.packageManager&&t.push(`${E.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&t.push(`${E.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&t.push(`${E.blue("Turso Setup:")} ${e.turso}`),t.join(`
126
- `)}function _e(e){let t=[];if(e.database==="none"?t.push("--no-database"):e.database==="sqlite"?t.push("--sqlite"):e.database==="postgres"&&t.push("--postgres"),e.database!=="none"&&(e.orm==="drizzle"?t.push("--drizzle"):e.orm==="prisma"&&t.push("--prisma")),e.auth?t.push("--auth"):t.push("--no-auth"),e.git?t.push("--git"):t.push("--no-git"),e.noInstall?t.push("--no-install"):t.push("--install"),e.packageManager&&t.push(`--${e.packageManager}`),e.addons.length>0)for(let s of e.addons)t.push(`--${s}`);else t.push("--no-addons");e.examples&&e.examples.length>0?t.push(`--examples ${e.examples.join(",")}`):t.push("--no-examples"),e.database==="sqlite"&&(e.turso?t.push("--turso"):t.push("--no-turso"));let a="npx create-better-t-stack",o=e.projectName?` ${e.projectName}`:"",r=t.length>0?` ${t.join(" ")}`:"";return`${a}${o}${r}`}import Ia from"node:path";import Da from"fs-extra";var Me=()=>{let e=Ia.join(f,"package.json");return Da.readJSONSync(e).version??"1.0.0"};import Be from"gradient-string";var Ge=`
118
+ `:""}function _t(e){return`${d.bold("Desktop app with Tauri:")}
119
+ ${d.cyan("\u2022")} Start desktop app: ${d.dim(`cd apps/client && ${e} desktop:dev`)}
120
+ ${d.cyan("\u2022")} Build desktop app: ${d.dim(`cd apps/client && ${e} desktop:build`)}
121
+ ${d.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: ${d.dim("https://v2.tauri.app/start/prerequisites/")}
122
+
123
+ `}import M from"node:path";import{$ as Mt,execa as Gt}from"execa";import O from"fs-extra";async function ke(e,a){await Jt(e,a),await qt(e,a)}async function Jt(e,a){let t=M.join(e,"package.json");if(await O.pathExists(t)){let r=await O.readJson(t);r.name=a.projectName;let{stdout:o}=await Gt(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${o.trim()}`,await O.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let i=M.join(y,"template/with-pnpm/pnpm-workspace.yaml"),s=M.join(e,"pnpm-workspace.yaml");await O.pathExists(i)&&await O.copy(i,s)}}}async function qt(e,a){let t=M.join(e,"apps/server/package.json");if(await O.pathExists(t)){let r=await O.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 O.writeJson(t,r,{spaces:2})}}async function Pe(e,a){a&&await Mt({cwd:e})`git init`}import G from"node:path";import F from"fs-extra";async function je(e,a,t){let r=G.join(e,"apps/server"),o=G.join(r,"src/index.ts"),i=await F.readFile(o,"utf-8");a==="bun"?await Vt(r,o,i,t):a==="node"&&await Ht(r,o,i,t)}async function Vt(e,a,t,r){let o=G.join(e,"package.json"),i=await F.readJson(o);if(i.scripts={...i.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await F.writeJson(o,i,{spaces:2}),h({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let s=`${t}
124
+
125
+ export default app;
126
+ `;await F.writeFile(a,s)}}async function Ht(e,a,t,r){let o=G.join(e,"package.json"),i=await F.readJson(o);if(i.scripts={...i.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await F.writeJson(o,i,{spaces:2}),h({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){h({dependencies:["@hono/node-server"],projectDir:e});let s=`import { serve } from "@hono/node-server";
127
+ `,n=`
128
+ serve(
129
+ {
130
+ fetch: app.fetch,
131
+ port: 3000,
132
+ },
133
+ (info) => {
134
+ console.log(\`Server is running on http://localhost:\${info.port}\`);
135
+ },
136
+ );
137
+ `;if(!t.includes("@hono/node-server")){let u=t.lastIndexOf("import"),f=t.substring(0,u),b=t.substring(u),P=f+s+b+n;await F.writeFile(a,P)}}else if(r==="elysia"&&(h({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let s=`import { node } from "@elysiajs/node";
138
+ `,n=t.indexOf(`
139
+ `,t.indexOf("import")),u=t.substring(0,n+1),f=t.substring(n+1),b=u+s+f;b=b.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await F.writeFile(a,b)}}import m from"node:path";import g from"fs-extra";async function ve(e){let a=m.join(y,"template/base");if(!await g.pathExists(a))throw new Error(`Template directory not found: ${a}`);await g.copy(a,e)}async function xe(e,a){let t=m.join(y,`template/with-${a}`);await g.pathExists(t)&&await g.copy(t,e,{overwrite:!0})}async function Te(e,a,t,r){if(a==="none"||t==="none")return;let o=m.join(y,Wt(a,t));if(await g.pathExists(o)&&(await g.copy(o,e,{overwrite:!0}),!r)){if(a==="prisma"){let i=m.join(e,"apps/server/prisma/schema/auth.prisma");await g.pathExists(i)&&await g.remove(i)}else if(a==="drizzle"){let i=m.join(e,"apps/server/src/db/schema/auth.ts");await g.pathExists(i)&&await g.remove(i)}}}async function $e(e,a,t,r,o){if(!a)return;let i=m.join(y,"template/with-auth");if(await g.pathExists(i)){let s=m.join(i,"apps/client"),n=m.join(e,"apps/client");await g.copy(s,n,{overwrite:!0});let u=m.join(i,"apps/server/src"),f=m.join(e,"apps/server/src");await g.copy(m.join(u,"lib/trpc.ts"),m.join(f,"lib/trpc.ts"),{overwrite:!0}),await g.copy(m.join(u,"routers/index.ts"),m.join(f,"routers/index.ts"),{overwrite:!0});let b=`with-${t}-context.ts`;await g.copy(m.join(u,"lib",b),m.join(f,"lib/context.ts"),{overwrite:!0});let P=`with-${t}-index.ts`;await g.copy(m.join(u,P),m.join(f,"index.ts"),{overwrite:!0});let C=Qt(r,o),D=m.join(u,C);if(await g.pathExists(D)){let et=await g.readdir(D);for(let Z of et)await g.copy(m.join(D,Z),m.join(f,"lib",Z),{overwrite:!0})}}}async function Ee(e){let a=[m.join(e,"_gitignore"),m.join(e,"apps/client/_gitignore"),m.join(e,"apps/server/_gitignore")];for(let t of a)if(await g.pathExists(t)){let r=m.join(m.dirname(t),".gitignore");await g.move(t,r)}}function Wt(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 Qt(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 De(e){let a=Yt(),t=Kt.resolve(process.cwd(),e.projectName);try{return await Zt.ensureDir(t),await ve(t),await Ee(t),await xe(t,e.backendFramework),await le(t,e.backendFramework,e.runtime),await Te(t,e.orm,e.database,e.auth),await ge(t,e.database,e.orm,e.turso??e.database==="sqlite"),await $e(t,e.auth,e.backendFramework,e.orm,e.database),await pe(t,e.auth),await je(t,e.runtime,e.backendFramework),await be(t,e.examples,e.orm,e.auth),await we(t,e),await Pe(t,e.git),e.addons.length>0&&await oe(t,e.addons,e.packageManager),await ke(t,e),await de(t,e),ye(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime),t}catch(r){throw a.message(Ce.red("Failed")),r instanceof Error&&(Xt(Ce.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{log as Oe,spinner as Fe}from"@clack/prompts";import{$ as K}from"execa";import J from"picocolors";async function Se({projectDir:e,packageManager:a,addons:t=[]}){let r=Fe();try{switch(r.start(`Running ${a} install...`),a){case"npm":await K({cwd:e,stderr:"inherit"})`${a} install`;break;case"pnpm":case"bun":await K({cwd:e})`${a} install`;break}r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await ea(e,a)}catch(o){throw r.stop(J.red("Failed to install dependencies")),o instanceof Error&&Oe.error(J.red(`Installation error: ${o.message}`)),o}}async function ea(e,a){let t=Fe();try{t.start("Running Biome format check..."),await K({cwd:e})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(J.yellow("Biome check encountered issues")),Oe.warn(J.yellow("Some files may need manual formatting"))}}import{cancel as Ka,group as Xa}from"@clack/prompts";import Ya from"picocolors";import{cancel as ta,isCancel as aa,multiselect as ra}from"@clack/prompts";import oa from"picocolors";async function Ae(e){if(e!==void 0)return e;let a=await ra({message:"Which Addons would you like to add?",options:[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"},{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],initialValues:c.addons,required:!1});return aa(a)&&(ta(oa.red("Operation cancelled")),process.exit(0)),a.includes("husky")&&!a.includes("biome")&&a.push("biome"),a}import{cancel as ia,confirm as sa,isCancel as na}from"@clack/prompts";import ca from"picocolors";async function Ie(e,a){if(!a)return!1;if(e!==void 0)return e;let t=await sa({message:"Would you like to add authentication with Better-Auth?",initialValue:c.auth});return na(t)&&(ia(ca.red("Operation cancelled")),process.exit(0)),t}import{cancel as pa,isCancel as la,select as da}from"@clack/prompts";import ua from"picocolors";async function Re(e){if(e!==void 0)return e;let a=await da({message:"Which backend framework would you like to use?",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"elysia",label:"Elysia",hint:"TypeScript framework with end-to-end type safety)"}],initialValue:c.backendFramework});return la(a)&&(pa(ua.red("Operation cancelled")),process.exit(0)),a}import{cancel as ma,isCancel as fa,select as ha}from"@clack/prompts";import ga from"picocolors";async function Le(e){if(e!==void 0)return e;let a=await ha({message:"Which database would you like to use?",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:c.database});return fa(a)&&(ma(ga.red("Operation cancelled")),process.exit(0)),a}import{cancel as wa,isCancel as ba,multiselect as ya}from"@clack/prompts";import ka from"picocolors";async function Ne(e,a){if(e!==void 0)return e;if(a==="none")return[];let t=await ya({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:c.examples});return ba(t)&&(wa(ka.red("Operation cancelled")),process.exit(0)),t}import{cancel as Pa,confirm as ja,isCancel as va}from"@clack/prompts";import xa from"picocolors";async function ze(e){if(e!==void 0)return e;let a=await ja({message:"Initialize a new git repository?",initialValue:c.git});return va(a)&&(Pa(xa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ta,confirm as $a,isCancel as Ea}from"@clack/prompts";import Ca from"picocolors";async function Ue(e){if(e!==void 0)return e;let a=await $a({message:"Do you want to install project dependencies?",initialValue:!c.noInstall});return Ea(a)&&(Ta(Ca.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Da,isCancel as Oa,select as Fa}from"@clack/prompts";import Sa from"picocolors";async function Be(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Fa({message:"Which ORM would you like to use?",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM with schema migrations"}],initialValue:c.orm});return Oa(t)&&(Da(Sa.red("Operation cancelled")),process.exit(0)),t}import{cancel as Aa,isCancel as Ia,select as Ra}from"@clack/prompts";import La from"picocolors";async function _e(e){if(e!==void 0)return e;let a=z(),t=await Ra({message:"Which package manager do you want to use?",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:a});return Ia(t)&&(Aa(La.red("Operation cancelled")),process.exit(0)),t}import N from"node:path";import{cancel as Na,isCancel as za,text as Ua}from"@clack/prompts";import A from"fs-extra";import Ba from"picocolors";var _a=["<",">",":",'"',"|","?","*"],Me=255;function Ge(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Me)return`Project name must be less than ${Me} characters`;if(_a.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 Je(e){if(e)if(e==="."){let i=process.cwd();if(A.readdirSync(i).length===0)return e}else{let i=N.basename(e);if(!Ge(i)){let n=N.resolve(process.cwd(),e);if(!A.pathExistsSync(n)||A.readdirSync(n).length===0)return e}}let a=!1,t="",r=c.projectName,o=1;for(;A.pathExistsSync(N.resolve(process.cwd(),r));)r=`${c.projectName}-${o}`,o++;for(;!a;){let i=await Ua({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:s=>{let n=s.trim()||r;if(n==="."){if(A.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let u=N.resolve(process.cwd(),n),f=N.basename(u),b=Ge(f);if(b)return b;if(!u.startsWith(process.cwd()))return"Project path must be within current directory";if(A.pathExistsSync(u)&&A.readdirSync(u).length>0)return`Directory "${n}" already exists and is not empty. Please choose a different name or path.`;a=!0}});za(i)&&(Na(Ba.red("Operation cancelled.")),process.exit(0)),t=i||r}return t}import{cancel as Ma,isCancel as Ga,select as Ja}from"@clack/prompts";import qa from"picocolors";async function qe(e){if(e!==void 0)return e;let a=await Ja({message:"Which runtime would you like to use?",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:c.runtime});return Ga(a)&&(Ma(qa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Va,confirm as Ha,isCancel as Wa}from"@clack/prompts";import Qa from"picocolors";async function Ve(e){if(e!==void 0)return e;let a=await Ha({message:"Set up a Turso database for this project?",initialValue:c.turso});return Wa(a)&&(Va(Qa.red("Operation cancelled")),process.exit(0)),a}async function He(e){let a=await Xa({projectName:async()=>Je(e.projectName),backendFramework:()=>Re(e.backendFramework),runtime:()=>qe(e.runtime),database:()=>Le(e.database),orm:({results:t})=>Be(e.orm,t.database!=="none"),auth:({results:t})=>Ie(e.auth,t.database!=="none"),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Ve(e.turso):Promise.resolve(!1),addons:()=>Ae(e.addons),examples:({results:t})=>Ne(e.examples,t.database),git:()=>ze(e.git),packageManager:()=>_e(e.packageManager),noInstall:()=>Ue(e.noInstall)},{onCancel:()=>{Ka(Ya.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,turso:a.turso,backendFramework:a.backendFramework,runtime:a.runtime}}import v from"picocolors";function X(e){let a=[];if(e.projectName&&a.push(`${v.blue("Project Name:")} ${e.projectName}`),e.backendFramework!==void 0&&a.push(`${v.blue("Backend Framework:")} ${e.backendFramework}`),e.runtime!==void 0&&a.push(`${v.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${v.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${v.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${v.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${v.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${v.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${v.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${v.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${v.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${v.blue("Turso Setup:")} ${e.turso}`),a.join(`
140
+ `)}function We(e){let a=[];if(e.database==="none"?a.push("--no-database"):(a.push(`--${e.database}`),e.orm&&a.push(`--${e.orm}`),e.database==="sqlite"&&a.push(e.turso?"--turso":"--no-turso")),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.packageManager&&a.push(`--${e.packageManager}`),e.backendFramework&&a.push(`--${e.backendFramework}`),e.runtime&&a.push(`--runtime ${e.runtime}`),e.addons.length>0)for(let o of e.addons)a.push(`--${o}`);else a.push("--no-addons");e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(",")}`):a.push("--no-examples");let t="npx create-better-t-stack",r=e.projectName?` ${e.projectName}`:"";return`${t}${r} ${a.join(" ")}`}import Za from"node:path";import er from"fs-extra";var Qe=()=>{let e=Za.join(y,"package.json");return er.readJSONSync(e).version??"1.0.0"};import Ke from"gradient-string";var Xe=`
127
141
  \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
128
142
  \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
129
143
  \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
@@ -137,10 +151,10 @@ ${p.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See
137
151
  \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
138
152
  \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
139
153
  \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
140
- `,qe={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},Je=()=>{let e=process.stdout.columns||80,t=Ge.split(`
141
- `),a=Math.max(...t.map(o=>o.length));e<a?console.log(Be(Object.values(qe)).multiline(`
154
+ `,Ye={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},Ze=()=>{let e=process.stdout.columns||80,a=Xe.split(`
155
+ `),t=Math.max(...a.map(r=>r.length));e<t?console.log(Ke(Object.values(Ye)).multiline(`
142
156
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
143
157
  \u2551 Better T-Stack \u2551
144
158
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
145
- `)):console.log(Be(Object.values(qe)).multiline(Ge))};process.on("SIGINT",()=>{k.error($.red("Operation cancelled")),process.exit(0)});var Q=new Fa;async function Ua(){let e=Date.now();Q.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Me()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--no-database","Skip database setup").option("--sqlite","Use SQLite database").option("--postgres","Use PostgreSQL database").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--pwa","Include Progressive Web App support").option("--tauri","Include Tauri desktop app support").option("--biome","Include Biome for linting and formatting").option("--husky","Include Husky, lint-staged for Git hooks").option("--no-addons","Skip all additional addons").option("--examples <examples>","Include specified examples").option("--no-examples","Skip all examples").option("--git","Include git setup").option("--no-git","Skip git initialization").option("--npm","Use npm package manager").option("--pnpm","Use pnpm package manager").option("--bun","Use bun package manager").option("--drizzle","Use Drizzle ORM").option("--prisma","Use Prisma ORM (coming soon)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup for SQLite database").parse();let t=Na();try{Je(),za($.magenta("Creating a new Better-T-Stack project"));let a=Q.opts(),o=Q.args[0],r={...o&&{projectName:o},...a.database===!1&&{database:"none"},...a.sqlite&&{database:"sqlite"},...a.postgres&&{database:"postgres"},...a.drizzle&&{orm:"drizzle"},...a.prisma&&{orm:"prisma"},..."auth"in a&&{auth:a.auth},...a.npm&&{packageManager:"npm"},...a.pnpm&&{packageManager:" pnpm"},...a.bun&&{packageManager:"bun"},..."git"in a&&{git:a.git},..."install"in a&&{noInstall:!a.install},..."turso"in a&&{turso:a.turso},...(a.pwa||a.tauri||a.biome||a.husky||a.addons===!1)&&{addons:a.addons===!1?[]:[...a.pwa?["pwa"]:[],...a.tauri?["tauri"]:[],...a.biome?["biome"]:[],...a.husky?["husky"]:[]]},...(a.examples||a.examples===!1)&&{examples:a.examples===!1?[]:typeof a.examples=="string"?a.examples.split(",").filter(g=>g==="todo"):[]}};!a.yes&&Object.keys(r).length>0&&(k.info($.yellow("Using these pre-selected options:")),k.message(W(r)),k.message(""));let s=a.yes?{...d,projectName:o??d.projectName,database:a.database===!1?"none":a.database??d.database,orm:a.database===!1?"none":a.drizzle?"drizzle":a.prisma?"prisma":d.orm,auth:a.auth??d.auth,git:a.git??d.git,noInstall:"noInstall"in a?a.noInstall:d.noInstall,packageManager:r.packageManager??d.packageManager,addons:r.addons?.length?r.addons:d.addons,examples:r.examples?.length?r.examples:d.examples,turso:"turso"in a?a.turso:r.database==="sqlite"?d.turso:!1}:await Ue(r);a.yes&&(k.info($.yellow("Using these default options:")),k.message(W(s)),k.message(""));let i=await ke(s);s.noInstall||await xe({projectDir:i,packageManager:s.packageManager,addons:s.addons}),k.success($.blue(`You can reproduce this setup with the following command:
146
- ${$.white(_e(s))}`));let n=((Date.now()-e)/1e3).toFixed(2);La($.magenta(`Project created successfully in ${$.bold(n)} seconds!`))}catch(a){t.stop($.red("Failed")),a instanceof Error&&(Ra($.red(`An unexpected error occurred: ${a.message}`)),process.exit(1))}}Ua().catch(e=>{k.error("Aborting installation..."),e instanceof Error?k.error(e.message):(k.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
159
+ `)):console.log(Ke(Object.values(Ye)).multiline(Xe))};process.on("SIGINT",()=>{$.error(E.red("Operation cancelled")),process.exit(0)});var Y=new ir;async function sr(){let e=Date.now();Y.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Qe()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--no-database","Skip database setup").option("--sqlite","Use SQLite database").option("--postgres","Use PostgreSQL database").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--pwa","Include Progressive Web App support").option("--tauri","Include Tauri desktop app support").option("--biome","Include Biome for linting and formatting").option("--husky","Include Husky, lint-staged for Git hooks").option("--no-addons","Skip all additional addons").option("--examples <examples>","Include specified examples").option("--no-examples","Skip all examples").option("--git","Include git setup").option("--no-git","Skip git initialization").option("--npm","Use npm package manager").option("--pnpm","Use pnpm package manager").option("--bun","Use bun package manager").option("--drizzle","Use Drizzle ORM").option("--prisma","Use Prisma ORM (coming soon)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup for SQLite database").option("--hono","Use Hono backend framework").option("--elysia","Use Elysia backend framework").option("--runtime <runtime>","Specify runtime (bun or node)").parse();let a=or();try{Ze(),ar(E.magenta("Creating a new Better-T-Stack project"));let t=Y.opts(),r=Y.args[0],o;t.hono&&(o="hono"),t.elysia&&(o="elysia");let i={...r&&{projectName:r},...t.database===!1&&{database:"none"},...t.sqlite&&{database:"sqlite"},...t.postgres&&{database:"postgres"},...t.drizzle&&{orm:"drizzle"},...t.prisma&&{orm:"prisma"},..."auth"in t&&{auth:t.auth},...t.npm&&{packageManager:"npm"},...t.pnpm&&{packageManager:"pnpm"},...t.bun&&{packageManager:"bun"},..."git"in t&&{git:t.git},..."install"in t&&{noInstall:!t.install},..."turso"in t&&{turso:t.turso},...o&&{backendFramework:o},...t.runtime&&{runtime:t.runtime},...(t.pwa||t.tauri||t.biome||t.husky||t.addons===!1)&&{addons:t.addons===!1?[]:[...t.pwa?["pwa"]:[],...t.tauri?["tauri"]:[],...t.biome?["biome"]:[],...t.husky?["husky"]:[]]},...(t.examples||t.examples===!1)&&{examples:t.examples===!1?[]:typeof t.examples=="string"?t.examples.split(",").filter(f=>f==="todo"):[]}};!t.yes&&Object.keys(i).length>0&&($.info(E.yellow("Using these pre-selected options:")),$.message(X(i)),$.message(""));let s=t.yes?{...c,projectName:r??c.projectName,database:t.database===!1?"none":t.sqlite?"sqlite":t.postgres?"postgres":c.database,orm:t.database===!1?"none":t.drizzle?"drizzle":t.prisma?"prisma":c.orm,auth:"auth"in t?t.auth:c.auth,git:"git"in t?t.git:c.git,noInstall:"install"in t?!t.install:c.noInstall,packageManager:i.packageManager??c.packageManager,addons:i.addons?.length?i.addons:c.addons,examples:i.examples?.length?i.examples:c.examples,turso:"turso"in t?t.turso:i.database==="sqlite"?c.turso:!1,backendFramework:o??c.backendFramework,runtime:t.runtime?t.runtime:c.runtime}:await He(i);t.yes&&($.info(E.yellow("Using these default options:")),$.message(X(s)),$.message(""));let n=await De(s);s.noInstall||await Se({projectDir:n,packageManager:s.packageManager,addons:s.addons}),$.success(E.blue(`You can reproduce this setup with the following command:
160
+ ${E.white(We(s))}`));let u=((Date.now()-e)/1e3).toFixed(2);rr(E.magenta(`Project created successfully in ${E.bold(u)} seconds!`))}catch(t){a.stop(E.red("Failed")),t instanceof Error&&(tr(E.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}sr().catch(e=>{$.error("Aborting installation..."),e instanceof Error?$.error(e.message):($.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "1.0.10",
3
+ "version": "1.2.0",
4
4
  "description": "CLI tool to scaffold Better-T Stack projects",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,14 +29,12 @@
29
29
  "dependencies": {
30
30
  "@clack/prompts": "^0.10.0",
31
31
  "commander": "^13.1.0",
32
- "degit": "^2.8.4",
33
32
  "execa": "^8.0.1",
34
33
  "fs-extra": "^11.3.0",
35
34
  "gradient-string": "^3.0.0",
36
35
  "picocolors": "^1.1.1"
37
36
  },
38
37
  "devDependencies": {
39
- "@types/degit": "^2.8.6",
40
38
  "@types/fs-extra": "^11.0.4",
41
39
  "@types/node": "^20.17.19",
42
40
  "tsup": "^8.4.0",
@@ -3,25 +3,17 @@
3
3
  "main": "src/index.ts",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "dev": "tsx watch src/index.ts",
7
- "start": "node dist/src/index.js",
8
6
  "build": "tsc && tsc-alias",
9
- "dev:bun": "bun run --hot src/index.ts",
10
7
  "check-types": "tsc --noEmit",
11
8
  "compile": "bun build --compile --minify --sourcemap --bytecode ./src/index.ts --outfile server"
12
9
  },
13
10
  "dependencies": {
14
- "@hono/node-server": "^1.14.0",
15
- "@hono/trpc-server": "^0.3.4",
16
11
  "@trpc/server": "^11.0.0",
17
12
  "dotenv": "^16.4.7",
18
- "hono": "^4.7.5",
19
13
  "zod": "^3.24.2"
20
14
  },
21
15
  "devDependencies": {
22
- "tsc-alias": "^1.8.11",
23
- "tsx": "^4.19.2",
24
- "@types/node": "^22.13.11",
16
+ "tsc-alias": "^1.8.11",
25
17
  "typescript": "^5.8.2"
26
18
  }
27
19
  }
@@ -8,7 +8,7 @@
8
8
  "skipLibCheck": true,
9
9
  "baseUrl": "./",
10
10
  "outDir": "./dist",
11
- "types": ["node"],
11
+ "types": ["node", "bun"],
12
12
  "jsx": "react-jsx",
13
13
  "jsxImportSource": "hono/jsx"
14
14
  },
@@ -31,10 +31,10 @@ export default function SignInForm({
31
31
  },
32
32
  {
33
33
  onSuccess: () => {
34
- toast.success("Sign in successful");
35
34
  navigate({
36
35
  to: "/dashboard",
37
36
  });
37
+ toast.success("Sign in successful");
38
38
  },
39
39
  onError: (error) => {
40
40
  toast.error(error.error.message);