create-better-t-stack 1.0.4 → 1.0.6

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 (82) hide show
  1. package/dist/index.js +21 -21
  2. package/package.json +1 -1
  3. package/template/base/{packages → apps}/client/package.json +3 -3
  4. package/template/base/package.json +1 -1
  5. package/template/examples/todo/{packages → apps}/server/src/routers/with-drizzle-todo.ts +4 -7
  6. package/template/with-pnpm/pnpm-workspace.yaml +1 -1
  7. /package/template/base/{packages → apps}/client/_gitignore +0 -0
  8. /package/template/base/{packages → apps}/client/components.json +0 -0
  9. /package/template/base/{packages → apps}/client/index.html +0 -0
  10. /package/template/base/{packages → apps}/client/src/components/header.tsx +0 -0
  11. /package/template/base/{packages → apps}/client/src/components/loader.tsx +0 -0
  12. /package/template/base/{packages → apps}/client/src/components/mode-toggle.tsx +0 -0
  13. /package/template/base/{packages → apps}/client/src/components/theme-provider.tsx +0 -0
  14. /package/template/base/{packages → apps}/client/src/components/ui/button.tsx +0 -0
  15. /package/template/base/{packages → apps}/client/src/components/ui/card.tsx +0 -0
  16. /package/template/base/{packages → apps}/client/src/components/ui/checkbox.tsx +0 -0
  17. /package/template/base/{packages → apps}/client/src/components/ui/dropdown-menu.tsx +0 -0
  18. /package/template/base/{packages → apps}/client/src/components/ui/input.tsx +0 -0
  19. /package/template/base/{packages → apps}/client/src/components/ui/label.tsx +0 -0
  20. /package/template/base/{packages → apps}/client/src/components/ui/skeleton.tsx +0 -0
  21. /package/template/base/{packages → apps}/client/src/components/ui/sonner.tsx +0 -0
  22. /package/template/base/{packages → apps}/client/src/index.css +0 -0
  23. /package/template/base/{packages → apps}/client/src/lib/utils.ts +0 -0
  24. /package/template/base/{packages → apps}/client/src/main.tsx +0 -0
  25. /package/template/base/{packages → apps}/client/src/routes/__root.tsx +0 -0
  26. /package/template/base/{packages → apps}/client/src/routes/index.tsx +0 -0
  27. /package/template/base/{packages → apps}/client/src/utils/trpc.ts +0 -0
  28. /package/template/base/{packages → apps}/client/tsconfig.json +0 -0
  29. /package/template/base/{packages → apps}/client/vite.config.ts +0 -0
  30. /package/template/base/{packages → apps}/server/_gitignore +0 -0
  31. /package/template/base/{packages → apps}/server/package.json +0 -0
  32. /package/template/base/{packages → apps}/server/src/index.ts +0 -0
  33. /package/template/base/{packages → apps}/server/src/lib/context.ts +0 -0
  34. /package/template/base/{packages → apps}/server/src/lib/trpc.ts +0 -0
  35. /package/template/base/{packages → apps}/server/src/routers/index.ts +0 -0
  36. /package/template/base/{packages → apps}/server/tsconfig.json +0 -0
  37. /package/template/examples/todo/{packages → apps}/client/src/routes/todos.tsx +0 -0
  38. /package/template/examples/todo/{packages → apps}/server/src/routers/with-prisma-todo.ts +0 -0
  39. /package/template/with-auth/{packages → apps}/client/src/components/auth-forms.tsx +0 -0
  40. /package/template/with-auth/{packages → apps}/client/src/components/header.tsx +0 -0
  41. /package/template/with-auth/{packages → apps}/client/src/components/sign-in-form.tsx +0 -0
  42. /package/template/with-auth/{packages → apps}/client/src/components/sign-up-form.tsx +0 -0
  43. /package/template/with-auth/{packages → apps}/client/src/components/user-menu.tsx +0 -0
  44. /package/template/with-auth/{packages → apps}/client/src/lib/auth-client.ts +0 -0
  45. /package/template/with-auth/{packages → apps}/client/src/main.tsx +0 -0
  46. /package/template/with-auth/{packages → apps}/client/src/routes/dashboard.tsx +0 -0
  47. /package/template/with-auth/{packages → apps}/client/src/routes/login.tsx +0 -0
  48. /package/template/with-auth/{packages → apps}/server/src/index.ts +0 -0
  49. /package/template/with-auth/{packages → apps}/server/src/lib/trpc.ts +0 -0
  50. /package/template/with-auth/{packages → apps}/server/src/routers/index.ts +0 -0
  51. /package/template/with-drizzle-postgres/{packages → apps}/server/drizzle.config.ts +0 -0
  52. /package/template/with-drizzle-postgres/{packages → apps}/server/src/db/index.ts +0 -0
  53. /package/template/with-drizzle-postgres/{packages → apps}/server/src/db/schema/auth.ts +0 -0
  54. /package/template/with-drizzle-postgres/{packages → apps}/server/src/db/schema/todo.ts +0 -0
  55. /package/template/with-drizzle-postgres/{packages → apps}/server/src/routers/todo.ts +0 -0
  56. /package/template/with-drizzle-postgres/{packages → apps}/server/src/with-auth-lib/auth.ts +0 -0
  57. /package/template/with-drizzle-postgres/{packages → apps}/server/src/with-auth-lib/context.ts +0 -0
  58. /package/template/with-drizzle-postgres/{packages → apps}/server/src/with-auth-lib/trpc.ts +0 -0
  59. /package/template/with-drizzle-sqlite/{packages → apps}/server/drizzle.config.ts +0 -0
  60. /package/template/with-drizzle-sqlite/{packages → apps}/server/src/db/index.ts +0 -0
  61. /package/template/with-drizzle-sqlite/{packages → apps}/server/src/db/schema/auth.ts +0 -0
  62. /package/template/with-drizzle-sqlite/{packages → apps}/server/src/db/schema/todo.ts +0 -0
  63. /package/template/with-drizzle-sqlite/{packages → apps}/server/src/with-auth-lib/auth.ts +0 -0
  64. /package/template/with-drizzle-sqlite/{packages → apps}/server/src/with-auth-lib/context.ts +0 -0
  65. /package/template/with-drizzle-sqlite/{packages → apps}/server/src/with-auth-lib/trpc.ts +0 -0
  66. /package/template/with-prisma-postgres/{packages → apps}/server/prisma/index.ts +0 -0
  67. /package/template/with-prisma-postgres/{packages → apps}/server/prisma/schema/auth.prisma +0 -0
  68. /package/template/with-prisma-postgres/{packages → apps}/server/prisma/schema/schema.prisma +0 -0
  69. /package/template/with-prisma-postgres/{packages → apps}/server/prisma/schema/todo.prisma +0 -0
  70. /package/template/with-prisma-postgres/{packages → apps}/server/src/with-auth-lib/auth.ts +0 -0
  71. /package/template/with-prisma-postgres/{packages → apps}/server/src/with-auth-lib/context.ts +0 -0
  72. /package/template/with-prisma-postgres/{packages → apps}/server/src/with-auth-lib/trpc.ts +0 -0
  73. /package/template/with-prisma-sqlite/{packages → apps}/server/prisma/index.ts +0 -0
  74. /package/template/with-prisma-sqlite/{packages → apps}/server/prisma/schema/auth.prisma +0 -0
  75. /package/template/with-prisma-sqlite/{packages → apps}/server/prisma/schema/schema.prisma +0 -0
  76. /package/template/with-prisma-sqlite/{packages → apps}/server/prisma/schema/todo.prisma +0 -0
  77. /package/template/with-prisma-sqlite/{packages → apps}/server/src/with-auth-lib/auth.ts +0 -0
  78. /package/template/with-prisma-sqlite/{packages → apps}/server/src/with-auth-lib/context.ts +0 -0
  79. /package/template/with-prisma-sqlite/{packages → apps}/server/src/with-auth-lib/trpc.ts +0 -0
  80. /package/template/with-pwa/{packages → apps}/client/public/logo.png +0 -0
  81. /package/template/with-pwa/{packages → apps}/client/pwa-assets.config.ts +0 -0
  82. /package/template/with-pwa/{packages → apps}/client/vite.config.ts +0 -0
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as Ia,intro as Ra,log as j,outro as za,spinner as La}from"@clack/prompts";import{Command as Na}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 Lt from"node:path";import{cancel as Nt,spinner as Ft}from"@clack/prompts";import Ut from"fs-extra";import ke from"picocolors";import S from"node:path";import m from"fs-extra";import Qe from"node:path";import X from"fs-extra";var g=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,"packages/client");try{a.start("Setting up Tauri desktop app support..."),g({devDependencies:["@tauri-apps/cli"],projectDir:o});let r=N.join(o,"package.json");if(await G.pathExists(r)){let s=await G.readJson(r);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await G.writeJson(r,s,{spaces:2})}await Ye("npx",["@tauri-apps/cli@latest","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`],{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}),g({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}),g({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,"packages/client");g({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,"packages/server"),o=te.join(e,"packages/client");try{g({dependencies:["better-auth"],projectDir:a}),g({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 Ia,intro as Ra,log as k,outro as za,spinner as La}from"@clack/prompts";import{Command as Na}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 Lt from"node:path";import{cancel as Nt,spinner as Ft}from"@clack/prompts";import Ut 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 s=await G.readJson(r);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await G.writeJson(r,s,{spaces:2})}await Ye("npx",["@tauri-apps/cli@latest","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`],{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}
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
 
@@ -30,7 +30,7 @@ The API is running at [http://localhost:3000](http://localhost:3000).
30
30
 
31
31
  \`\`\`
32
32
  ${t}/
33
- \u251C\u2500\u2500 packages/
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)
36
36
  \`\`\`
@@ -45,14 +45,14 @@ ${nt(n,o,i,r)}
45
45
 
46
46
  1. Start the local SQLite database:
47
47
  \`\`\`bash
48
- cd packages/server && ${a} db:local
48
+ cd apps/server && ${a} db:local
49
49
  \`\`\`
50
50
 
51
- 2. Update your \`.env\` file in the \`packages/server\` directory with the appropriate connection details if needed.
51
+ 2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed.
52
52
  `:e==="postgres"&&(r+=`This project uses PostgreSQL${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
53
53
 
54
54
  1. Make sure you have a PostgreSQL database set up.
55
- 2. Update your \`packages/server/.env\` file with your PostgreSQL connection details.
55
+ 2. Update your \`apps/server/.env\` file with your PostgreSQL connection details.
56
56
  `),r+=`
57
57
  ${t?"4":"3"}. ${o==="prisma"?`Generate the Prisma client and push the schema:
58
58
  \`\`\`bash
@@ -65,39 +65,39 @@ ${a} db:push
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 packages`;return t!=="none"&&(r+=`
68
+ - \`${e} check-types\`: Check TypeScript types across all apps`;return t!=="none"&&(r+=`
69
69
  - \`${e} db:push\`: Push schema changes to database
70
70
  - \`${e} db:studio\`: Open database studio UI`,t==="sqlite"&&a==="drizzle"&&(r+=`
71
- - \`cd packages/server && ${e} db:local\`: Start the local SQLite database`)),r}import pe from"node:path";import{log as Pt,spinner as kt}from"@clack/prompts";import jt 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 gt(){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 ht(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,"packages/server",".env"),o=t?`TURSO_CONNECTION_URL="${t.dbUrl}"
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
73
  TURSO_AUTH_TOKEN="${t.authToken}"`:`TURSO_CONNECTION_URL=
74
74
  TURSO_AUTH_TOKEN=`;await ut.writeFile(a,o)}function F(){A.info(`Manual Turso Setup Instructions:
75
75
 
76
76
  1. Visit https://turso.tech and create an account
77
77
  2. Create a new database from the dashboard
78
78
  3. Get your database URL and authentication token
79
- 4. Add these credentials to the .env file in packages/server/.env
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 ht(o)}await ft()||await gt();let n=await bt(),h=!1,v="",T=ne.basename(e);for(;!h;){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 I=await yt(v,n);await R(e,I),L.stop("Turso database configured successfully!"),h=!0}catch(I){if(I instanceof Error&&I.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")),I}}}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=kt(),s=pe.join(e,"packages/server");if(t==="none"){await jt.remove(pe.join(s,"src/db"));return}try{t==="sqlite"?(a==="drizzle"?g({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:s}):a==="prisma"&&g({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:s}),o&&await ce(e,!0)):t==="postgres"&&(a==="drizzle"?g({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:s}):a==="prisma"&&g({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 D from"fs-extra";async function ue(e,t){let a=U.join(e,"packages/server"),o=U.join(e,"packages/client"),r=U.join(a,".env"),s="";if(await D.pathExists(r)&&(s=await D.readFile(r,"utf8")),s.includes("CORS_ORIGIN")||(s+=`
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 I=await yt(v,n);await R(e,I),L.stop("Turso database configured successfully!"),g=!0}catch(I){if(I instanceof Error&&I.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")),I}}}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 D 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 D.pathExists(r)&&(s=await D.readFile(r,"utf8")),s.includes("CORS_ORIGIN")||(s+=`
83
83
  CORS_ORIGIN=http://localhost:3001`),t.auth&&(s.includes("BETTER_AUTH_SECRET")||(s+=`
84
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 h=t.database==="sqlite"?"":`
86
- DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;s+=h}t.database==="sqlite"&&!t.turso&&(s.includes("TURSO_CONNECTION_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
87
  TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}await D.writeFile(r,s.trim());let i=U.join(o,".env"),n="";await D.pathExists(i)&&(n=await D.readFile(i,"utf8")),n.includes("VITE_SERVER_URL")||(n+=`VITE_SERVER_URL=http://localhost:3000
88
- `),await D.writeFile(i,n.trim())}import 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,"packages/client/src/routes"),s=P.join(e,"packages/client/src/routes");if(await u.copy(r,s,{overwrite:!0}),t!=="none"){let i=P.join(o,`packages/server/src/routers/with-${t}-todo.ts`),n=P.join(e,"packages/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,"packages/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 = [
88
+ `),await D.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 = [
89
89
  { to: "/", label: "Home" },
90
90
  { to: "/dashboard", label: "Dashboard" },
91
91
  { to: "/todos", label: "Todos" },`):o=o.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,"packages/server/src/db/schema/todo.ts");await u.pathExists(o)&&await u.remove(o)}else if(t==="prisma"){let o=P.join(e,"packages/server/prisma/schema/todo.prisma");await u.pathExists(o)&&await u.remove(o)}let a=P.join(e,"packages/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,"packages/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,"packages/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 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">
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}`,h=s?.includes("husky")||s?.includes("biome"),v=e!=="none"?Ot(e,r,i):"",T=s?.includes("tauri")?At(i):"",x=h?St(i):"";Ct.info(`${p.cyan("Project created successfully!")}
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
101
 
102
102
  ${p.bold("Next steps:")}
103
103
  ${p.cyan("1.")} ${n}
@@ -113,16 +113,16 @@ ${T.trim()}`:""}${x?`
113
113
  ${x.trim()}`:""}`)}function St(e){return`${p.bold("Linting and formatting:")}
114
114
  ${p.cyan("\u2022")} Format and lint fix: ${p.dim(`${e} check`)}
115
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 packages/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:")}
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:")}
117
117
  ${o.join(`
118
118
  `)}
119
119
 
120
120
  `:""}function At(e){return`${p.bold("Desktop app with Tauri:")}
121
- ${p.cyan("\u2022")} Start desktop app: ${p.dim(`cd packages/client && ${e} desktop:dev`)}
122
- ${p.cyan("\u2022")} Build desktop app: ${p.dim(`cd packages/client && ${e} desktop:build`)}
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
123
  ${p.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: ${p.dim("https://v2.tauri.app/start/prerequisites/")}
124
124
 
125
- `}import M from"node:path";import{$ as Dt}from"execa";import C from"fs-extra";async function ge(e,t){await It(e,t),await Rt(e,t)}async function It(e,t){let a=M.join(e,"package.json");if(await C.pathExists(a)){let o=await C.readJson(a);if(o.name=t.projectName,t.packageManager!=="bun"&&(o.packageManager=t.packageManager==="npm"?"npm@10.9.2":t.packageManager==="pnpm"?"pnpm@10.6.4":"bun@1.2.5"),await C.writeJson(a,o,{spaces:2}),t.packageManager==="pnpm"){let r=M.join(f,"template/with-pnpm/pnpm-workspace.yaml"),s=M.join(e,"pnpm-workspace.yaml");await C.pathExists(r)&&await C.copy(r,s)}}}async function Rt(e,t){let a=M.join(e,"packages/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 he(e,t){t&&await Dt({cwd:e})`git init`}import k from"node:path";import b from"fs-extra";async function we(e){let t=k.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=k.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=k.join(f,zt(t,a));if(await b.pathExists(r)){await b.copy(r,e,{overwrite:!0});let s=k.join(e,"packages/server/src"),i=k.join(s,"lib"),n=k.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=[k.join(e,"_gitignore"),k.join(e,"packages/client/_gitignore"),k.join(e,"packages/server/_gitignore")];for(let a of t)if(await b.pathExists(a)){let o=k.join(k.dirname(a),".gitignore");await b.move(a,o)}}function zt(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 je(e){let t=Ft(),a=Lt.resolve(process.cwd(),e.projectName);try{return await Ut.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 he(a,e.git),e.addons.length>0&&await ee(a,e.addons,e.packageManager),await ge(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(ke.red("Failed")),o instanceof Error&&(Nt(ke.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 _ 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(_.red("Failed to install dependencies")),r instanceof Error&&ve.error(_.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(_.yellow("Biome check encountered issues")),ve.warn(_.yellow("Some files may need manual formatting"))}}import{cancel as Ca,group as Sa}from"@clack/prompts";import Oa from"picocolors";import{cancel as _t,isCancel as Bt,multiselect as Gt}from"@clack/prompts";import qt from"picocolors";async function $e(e){if(e!==void 0)return e;let t=await Gt({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 Bt(t)&&(_t(qt.red("Operation cancelled")),process.exit(0)),t.includes("husky")&&!t.includes("biome")&&t.push("biome"),t}import{cancel as Jt,confirm as Vt,isCancel as Ht}from"@clack/prompts";import Wt from"picocolors";async function Ee(e,t){if(!t)return!1;if(e!==void 0)return e;let a=await Vt({message:"Would you like to add authentication with Better-Auth?",initialValue:d.auth});return Ht(a)&&(Jt(Wt.red("Operation cancelled")),process.exit(0)),a}import{cancel as Qt,isCancel as Kt,select as Xt}from"@clack/prompts";import Yt from"picocolors";async function Ce(e){if(e!==void 0)return e;let t=await Xt({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 Kt(t)&&(Qt(Yt.red("Operation cancelled")),process.exit(0)),t}import{cancel as Zt,isCancel as ea,multiselect as ta}from"@clack/prompts";import aa from"picocolors";async function Se(e,t){if(e!==void 0)return e;if(t==="none")return[];let a=await ta({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:d.examples});return ea(a)&&(Zt(aa.red("Operation cancelled")),process.exit(0)),a}import{cancel as oa,confirm as ra,isCancel as sa}from"@clack/prompts";import ia from"picocolors";async function Oe(e){if(e!==void 0)return e;let t=await ra({message:"Initialize a new git repository?",initialValue:d.git});return sa(t)&&(oa(ia.red("Operation cancelled")),process.exit(0)),t}import{cancel as na,confirm as ca,isCancel as pa}from"@clack/prompts";import la from"picocolors";async function Ae(e){if(e!==void 0)return e;let t=await ca({message:"Do you want to install project dependencies?",initialValue:!d.noInstall});return pa(t)&&(na(la.red("Operation cancelled")),process.exit(0)),!t}import{cancel as da,isCancel as ua,select as ma}from"@clack/prompts";import fa from"picocolors";async function De(e,t){if(!t)return"none";if(e!==void 0)return e;let a=await ma({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 ua(a)&&(da(fa.red("Operation cancelled")),process.exit(0)),a}import{cancel as ga,isCancel as ha,select as wa}from"@clack/prompts";import ba from"picocolors";var Ie=()=>{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=Ie(),a=await wa({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 ha(a)&&(ga(ba.red("Operation cancelled")),process.exit(0)),a}import z from"node:path";import{cancel as ya,isCancel as Pa,text as ka}from"@clack/prompts";import O from"fs-extra";import ja from"picocolors";var va=["<",">",":",'"',"|","?","*"],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(va.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 h=z.resolve(process.cwd(),n),v=z.basename(h),T=Le(v);if(T)return T;if(!h.startsWith(process.cwd()))return"Project path must be within current directory";if(O.pathExistsSync(h)&&O.readdirSync(h).length>0)return`Directory "${n}" already exists and is not empty. Please choose a different name or path.`;t=!0}});Pa(s)&&(ya(ja.red("Operation cancelled.")),process.exit(0)),a=s||o}return a}import{cancel as Ta,confirm as xa,isCancel as $a}from"@clack/prompts";import Ea from"picocolors";async function Fe(e){if(e!==void 0)return e;let t=await xa({message:"Set up a Turso database for this project?",initialValue:!0});return $a(t)&&(Ta(Ea.red("Operation cancelled")),process.exit(0)),t}async function Ue(e){let t=await Sa({projectName:async()=>Ne(e.projectName),database:()=>Ce(e.database),orm:({results:a})=>De(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:()=>{Ca(Oa.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(`
125
+ `}import M from"node:path";import{$ as Dt}from"execa";import C from"fs-extra";async function he(e,t){await It(e,t),await Rt(e,t)}async function It(e,t){let a=M.join(e,"package.json");if(await C.pathExists(a)){let o=await C.readJson(a);if(o.name=t.projectName,t.packageManager!=="bun"&&(o.packageManager=t.packageManager==="npm"?"npm@10.9.2":t.packageManager==="pnpm"?"pnpm@10.6.4":"bun@1.2.5"),await C.writeJson(a,o,{spaces:2}),t.packageManager==="pnpm"){let r=M.join(f,"template/with-pnpm/pnpm-workspace.yaml"),s=M.join(e,"pnpm-workspace.yaml");await C.pathExists(r)&&await C.copy(r,s)}}}async function Rt(e,t){let a=M.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 Dt({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,zt(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 zt(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=Ft(),a=Lt.resolve(process.cwd(),e.projectName);try{return await Ut.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&&(Nt(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 _ 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(_.red("Failed to install dependencies")),r instanceof Error&&ve.error(_.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(_.yellow("Biome check encountered issues")),ve.warn(_.yellow("Some files may need manual formatting"))}}import{cancel as Ca,group as Sa}from"@clack/prompts";import Oa from"picocolors";import{cancel as _t,isCancel as Bt,multiselect as Gt}from"@clack/prompts";import qt from"picocolors";async function $e(e){if(e!==void 0)return e;let t=await Gt({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 Bt(t)&&(_t(qt.red("Operation cancelled")),process.exit(0)),t.includes("husky")&&!t.includes("biome")&&t.push("biome"),t}import{cancel as Jt,confirm as Vt,isCancel as Ht}from"@clack/prompts";import Wt from"picocolors";async function Ee(e,t){if(!t)return!1;if(e!==void 0)return e;let a=await Vt({message:"Would you like to add authentication with Better-Auth?",initialValue:d.auth});return Ht(a)&&(Jt(Wt.red("Operation cancelled")),process.exit(0)),a}import{cancel as Qt,isCancel as Kt,select as Xt}from"@clack/prompts";import Yt from"picocolors";async function Ce(e){if(e!==void 0)return e;let t=await Xt({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 Kt(t)&&(Qt(Yt.red("Operation cancelled")),process.exit(0)),t}import{cancel as Zt,isCancel as ea,multiselect as ta}from"@clack/prompts";import aa from"picocolors";async function Se(e,t){if(e!==void 0)return e;if(t==="none")return[];let a=await ta({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:d.examples});return ea(a)&&(Zt(aa.red("Operation cancelled")),process.exit(0)),a}import{cancel as oa,confirm as ra,isCancel as sa}from"@clack/prompts";import ia from"picocolors";async function Oe(e){if(e!==void 0)return e;let t=await ra({message:"Initialize a new git repository?",initialValue:d.git});return sa(t)&&(oa(ia.red("Operation cancelled")),process.exit(0)),t}import{cancel as na,confirm as ca,isCancel as pa}from"@clack/prompts";import la from"picocolors";async function Ae(e){if(e!==void 0)return e;let t=await ca({message:"Do you want to install project dependencies?",initialValue:!d.noInstall});return pa(t)&&(na(la.red("Operation cancelled")),process.exit(0)),!t}import{cancel as da,isCancel as ua,select as ma}from"@clack/prompts";import fa from"picocolors";async function De(e,t){if(!t)return"none";if(e!==void 0)return e;let a=await ma({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 ua(a)&&(da(fa.red("Operation cancelled")),process.exit(0)),a}import{cancel as ha,isCancel as ga,select as wa}from"@clack/prompts";import ba from"picocolors";var Ie=()=>{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=Ie(),a=await wa({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 ga(a)&&(ha(ba.red("Operation cancelled")),process.exit(0)),a}import z from"node:path";import{cancel as ya,isCancel as Pa,text as ja}from"@clack/prompts";import O from"fs-extra";import ka from"picocolors";var va=["<",">",":",'"',"|","?","*"],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(va.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 ja({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}});Pa(s)&&(ya(ka.red("Operation cancelled.")),process.exit(0)),a=s||o}return a}import{cancel as Ta,confirm as xa,isCancel as $a}from"@clack/prompts";import Ea from"picocolors";async function Fe(e){if(e!==void 0)return e;let t=await xa({message:"Set up a Turso database for this project?",initialValue:!0});return $a(t)&&(Ta(Ea.red("Operation cancelled")),process.exit(0)),t}async function Ue(e){let t=await Sa({projectName:async()=>Ne(e.projectName),database:()=>Ce(e.database),orm:({results:a})=>De(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:()=>{Ca(Oa.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
126
  `)}function Me(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 Aa from"node:path";import Da from"fs-extra";var _e=()=>{let e=Aa.join(f,"package.json");return Da.readJSONSync(e).version??"1.0.0"};import Be from"gradient-string";var Ge=`
127
127
  \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
128
  \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
@@ -142,5 +142,5 @@ ${p.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See
142
142
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
143
143
  \u2551 Better T-Stack \u2551
144
144
  \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",()=>{j.error($.red("Operation cancelled")),process.exit(0)});var Q=new Na;async function Fa(){let e=Date.now();Q.name("create-better-t-stack").description("Create a new Better-T Stack project").version(_e()).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=La();try{Je(),Ra($.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(h=>h==="todo"):[]}};!a.yes&&Object.keys(r).length>0&&(j.info($.yellow("Using these pre-selected options:")),j.message(W(r)),j.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&&(j.info($.yellow("Using these default options:")),j.message(W(s)),j.message(""));let i=await je(s);s.noInstall||await xe({projectDir:i,packageManager:s.packageManager,addons:s.addons}),j.success($.blue(`You can reproduce this setup with the following command:
146
- ${$.white(Me(s))}`));let n=((Date.now()-e)/1e3).toFixed(2);za($.magenta(`Project created successfully in ${$.bold(n)} seconds!`))}catch(a){t.stop($.red("Failed")),a instanceof Error&&(Ia($.red(`An unexpected error occurred: ${a.message}`)),process.exit(1))}}Fa().catch(e=>{j.error("Aborting installation..."),e instanceof Error?j.error(e.message):(j.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
145
+ `)):console.log(Be(Object.values(qe)).multiline(Ge))};process.on("SIGINT",()=>{k.error($.red("Operation cancelled")),process.exit(0)});var Q=new Na;async function Fa(){let e=Date.now();Q.name("create-better-t-stack").description("Create a new Better-T Stack project").version(_e()).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=La();try{Je(),Ra($.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(Me(s))}`));let n=((Date.now()-e)/1e3).toFixed(2);za($.magenta(`Project created successfully in ${$.bold(n)} seconds!`))}catch(a){t.stop($.red("Failed")),a instanceof Error&&(Ia($.red(`An unexpected error occurred: ${a.message}`)),process.exit(1))}}Fa().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)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "CLI tool to scaffold Better-T Stack projects",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -11,8 +11,10 @@
11
11
  "check-types": "tsc --noEmit"
12
12
  },
13
13
  "devDependencies": {
14
+ "@tanstack/react-query-devtools": "^5.69.0",
15
+ "@tanstack/react-router-devtools": "^1.114.27",
14
16
  "@tanstack/router-plugin": "^1.114.27",
15
- "@types/node": "^22.13.11",
17
+ "@types/node": "^22.13.13",
16
18
  "@types/react": "^19.0.12",
17
19
  "@types/react-dom": "^19.0.4",
18
20
  "@vitejs/plugin-react": "^4.3.4",
@@ -29,9 +31,7 @@
29
31
  "@tanstack/react-form": "^1.0.5",
30
32
  "@tailwindcss/vite": "^4.0.15",
31
33
  "@tanstack/react-query": "^5.69.0",
32
- "@tanstack/react-query-devtools": "^5.69.0",
33
34
  "@tanstack/react-router": "^1.114.25",
34
- "@tanstack/router-devtools": "^1.114.25",
35
35
  "@trpc/client": "^11.0.0",
36
36
  "@trpc/react-query": "^11.0.0",
37
37
  "@trpc/server": "^11.0.0",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "better-t-stack",
3
3
  "private": true,
4
- "workspaces": ["packages/*"],
4
+ "workspaces": ["apps/*"],
5
5
  "scripts": {
6
6
  "dev": "turbo dev",
7
7
  "build": "turbo build",
@@ -6,7 +6,7 @@ import { db } from "../db";
6
6
 
7
7
  export const todoRouter = router({
8
8
  getAll: publicProcedure.query(async () => {
9
- return await db.select().from(todo).all();
9
+ return await db.select().from(todo);
10
10
  }),
11
11
 
12
12
  create: publicProcedure
@@ -17,8 +17,7 @@ export const todoRouter = router({
17
17
  .values({
18
18
  text: input.text,
19
19
  })
20
- .returning()
21
- .get();
20
+ .returning();
22
21
  }),
23
22
 
24
23
  toggle: publicProcedure
@@ -28,8 +27,7 @@ export const todoRouter = router({
28
27
  .update(todo)
29
28
  .set({ completed: input.completed })
30
29
  .where(eq(todo.id, input.id))
31
- .returning()
32
- .get();
30
+ .returning();
33
31
  }),
34
32
 
35
33
  delete: publicProcedure
@@ -38,7 +36,6 @@ export const todoRouter = router({
38
36
  return await db
39
37
  .delete(todo)
40
38
  .where(eq(todo.id, input.id))
41
- .returning()
42
- .get();
39
+ .returning();
43
40
  }),
44
41
  });
@@ -1,2 +1,2 @@
1
1
  packages:
2
- - "packages/*"
2
+ - "apps/*"