create-better-t-stack 1.12.1 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{cancel as j,intro as Rn,log as L,outro as Fn,spinner as In}from"@clack/prompts";import{Command as On}from"commander";import h from"picocolors";import Se from"node:path";import{fileURLToPath as Yt}from"node:url";var ee=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var Zt=Yt(import.meta.url),ea=Se.dirname(Zt),v=Se.join(ea,"../"),
|
|
2
|
+
import{cancel as j,intro as Rn,log as L,outro as Fn,spinner as In}from"@clack/prompts";import{Command as On}from"commander";import h from"picocolors";import Se from"node:path";import{fileURLToPath as Yt}from"node:url";var ee=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var Zt=Yt(import.meta.url),ea=Se.dirname(Zt),v=Se.join(ea,"../"),g={projectName:"my-better-t-app",frontend:["tanstack-router"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:ee(),noInstall:!1,dbSetup:"none",backend:"hono",runtime:"bun"},le={"better-auth":"^1.2.4","@better-auth/expo":"^1.2.5","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",pg:"^8.14.1","@types/pg":"^8.11.11",mysql2:"^3.14.0","@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",cors:"^2.8.5",express:"^5.1.0","@types/express":"^5.0.1","@types/cors":"^2.8.17",ai:"^4.2.8","@ai-sdk/google":"^1.2.3","@prisma/extension-accelerate":"^1.3.0"};import $r from"node:path";import{cancel as Sr,spinner as Ar}from"@clack/prompts";import Er from"fs-extra";import yt from"picocolors";import B from"node:path";import k from"fs-extra";import ta from"node:path";import Ae from"fs-extra";var b=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:r}=e,n=ta.join(r,"package.json"),s=Ae.readJSONSync(n);s.dependencies||(s.dependencies={}),s.devDependencies||(s.devDependencies={});for(let o of a){let i=le[o];s.dependencies[o]=i}for(let o of t){let i=le[o];s.devDependencies[o]=i}Ae.writeJSONSync(n,s,{spaces:2})};import aa from"node:path";import{log as ra,spinner as na}from"@clack/prompts";import{execa as sa}from"execa";import Ee from"picocolors";async function De(e,a){let t=na();try{t.start("Setting up Starlight documentation site...");let r,n;switch(a){case"npm":r="npx",n=["create-astro@latest"];break;case"pnpm":r="pnpm",n=["dlx","create-astro@latest"];break;case"bun":r="bunx",n=["create-astro@latest"];break;default:r="npx",n=["create-astro@latest"]}n=[...n,"docs","--template","starlight","--no-install","--add","tailwind","--no-git","--skip-houston"],await sa(r,n,{cwd:aa.join(e,"apps"),env:{CI:"true"}}),t.stop("Starlight documentation site setup successfully!")}catch(r){throw t.stop(Ee.red("Failed to set up Starlight documentation site")),r instanceof Error&&ra.error(Ee.red(r.message)),r}}import te from"node:path";import{log as oa,spinner as ia}from"@clack/prompts";import{execa as ca}from"execa";import ae from"fs-extra";import Ce from"picocolors";async function Te(e,a,t){let r=ia(),n=te.join(e,"apps/web");if(await ae.pathExists(n))try{r.start("Setting up Tauri desktop app support..."),b({devDependencies:["@tauri-apps/cli"],projectDir:n});let s=te.join(n,"package.json");if(await ae.pathExists(s)){let u=await ae.readJson(s);u.scripts={...u.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await ae.writeJson(s,u,{spaces:2})}let o,i;switch(a){case"npm":o="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":o="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":o="bunx",i=["@tauri-apps/cli@latest"];break;default:o="npx",i=["@tauri-apps/cli@latest"]}let c=t.includes("react-router")?"http://localhost:5173":"http://localhost:3001";i=[...i,"init",`--app-name=${te.basename(e)}`,`--window-title=${te.basename(e)}`,"--frontend-dist=dist",`--dev-url=${c}`,`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ca(o,i,{cwd:n,env:{CI:"true"}}),r.stop("Tauri desktop app support configured successfully!")}catch(s){throw r.stop(Ce.red("Failed to set up Tauri")),s instanceof Error&&oa.error(Ce.red(s.message)),s}}async function Re(e,a,t,r){let n=r.includes("react-router")||r.includes("tanstack-router");a.includes("pwa")&&n&&await da(e,r),a.includes("tauri")&&n&&await Te(e,t,r),a.includes("biome")&&await la(e),a.includes("husky")&&await ua(e),a.includes("starlight")&&await De(e,t)}function pa(e,a){return B.join(e,"apps/web")}async function la(e){let a=B.join(v,"template/with-biome");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),b({devDependencies:["@biomejs/biome"],projectDir:e});let t=B.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 ua(e){let a=B.join(v,"template/with-husky");await k.pathExists(a)&&await k.copy(a,e,{overwrite:!0}),b({devDependencies:["husky","lint-staged"],projectDir:e});let t=B.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 da(e,a){let t=B.join(v,"template/with-pwa");await k.pathExists(t)&&await k.copy(t,e,{overwrite:!0});let r=pa(e,a);if(!await k.pathExists(r))return;b({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:r});let n=B.join(r,"vite.config.ts");if(await k.pathExists(n)){let o=await k.readFile(n,"utf8");if(!o.includes("vite-plugin-pwa")){let p=o.match(/^import .* from ['"](.*)['"]/m);p?o=o.replace(p[0],`import { VitePWA } from "vite-plugin-pwa";
|
|
3
3
|
${p[0]}`):o=`import { VitePWA } from "vite-plugin-pwa";
|
|
4
4
|
${o}`}let i=`VitePWA({
|
|
5
5
|
registerType: "autoUpdate",
|
|
@@ -21,7 +21,7 @@ ${o}`}let i=`VitePWA({
|
|
|
21
21
|
${i}`):a.includes("tanstack-router")?o=o.replace(/plugins: \[\s*tailwindcss\(\)/,`plugins: [
|
|
22
22
|
tailwindcss(),
|
|
23
23
|
${i}`):o=o.replace(/plugins: \[/,`plugins: [
|
|
24
|
-
${i},`)),await k.writeFile(n,o)}let s=B.join(r,"package.json");if(await k.pathExists(s)){let o=await k.readJson(s);o.scripts={...o.scripts,"generate-pwa-assets":"pwa-assets-generator"},await k.writeJson(s,o,{spaces:2})}}import ue from"node:path";import{log as Fe}from"@clack/prompts";import Ie from"picocolors";function Oe(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",r=a.length;for(let n=0;n<e;n++)t+=a.charAt(Math.floor(Math.random()*r));return t}async function Le(e,a,t=[]){if(!a)return;let r=ue.join(e,"apps/server"),n=ue.join(e,"apps/web"),s=ue.join(e,"apps/native");try{
|
|
24
|
+
${i},`)),await k.writeFile(n,o)}let s=B.join(r,"package.json");if(await k.pathExists(s)){let o=await k.readJson(s);o.scripts={...o.scripts,"generate-pwa-assets":"pwa-assets-generator"},await k.writeJson(s,o,{spaces:2})}}import ue from"node:path";import{log as Fe}from"@clack/prompts";import Ie from"picocolors";function Oe(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",r=a.length;for(let n=0;n<e;n++)t+=a.charAt(Math.floor(Math.random()*r));return t}async function Le(e,a,t=[]){if(!a)return;let r=ue.join(e,"apps/server"),n=ue.join(e,"apps/web"),s=ue.join(e,"apps/native");try{b({dependencies:["better-auth"],projectDir:r}),(t.includes("react-router")||t.includes("tanstack-router")||t.includes("tanstack-start"))&&b({dependencies:["better-auth"],projectDir:n}),t.includes("native")&&(b({dependencies:["better-auth","@better-auth/expo"],projectDir:s}),b({dependencies:["@better-auth/expo"],projectDir:r}))}catch(o){throw Fe.error(Ie.red("Failed to configure authentication")),o instanceof Error&&Fe.error(Ie.red(o.message)),o}}import ma from"node:path";async function Be(e,a,t){let r=ma.join(e,"apps/server"),n=[],s=[];a==="hono"?(n.push("hono","@hono/trpc-server"),t==="node"&&(n.push("@hono/node-server"),s.push("tsx","@types/node"))):a==="elysia"?(n.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(n.push("@elysiajs/node"),s.push("tsx","@types/node"))):a==="express"&&(n.push("express","cors"),s.push("@types/express","@types/cors"),t==="node"&&s.push("tsx","@types/node")),t==="bun"&&s.push("@types/bun"),b({dependencies:n,devDependencies:s,projectDir:r})}import fa from"node:path";import ha from"fs-extra";async function Me(e,a){let t=fa.join(e,"README.md"),r=ga(a);try{await ha.writeFile(t,r)}catch(n){console.error("Failed to create README.md file:",n)}}function ga(e){let{projectName:a,packageManager:t,database:r,auth:n,addons:s=[],orm:o="drizzle",runtime:i="bun",frontend:p=["tanstack-router"]}=e,c=p.includes("react-router"),u=p.includes("tanstack-router"),P=p.includes("native"),$=t==="npm"?"npm run":t,S=c?"5173":"3001";return`# ${a}
|
|
25
25
|
|
|
26
26
|
This project was created with [Better-T-Stack](https://github.com/AmanVarshney01/create-better-t-stack), a modern TypeScript stack that combines React, ${u?"TanStack Router":"React Router"}, Hono, tRPC, and more.
|
|
27
27
|
|
|
@@ -46,7 +46,7 @@ ${$} dev
|
|
|
46
46
|
\`\`\`
|
|
47
47
|
|
|
48
48
|
${u||c?`Open [http://localhost:${S}](http://localhost:${S}) in your browser to see the web application.`:""}
|
|
49
|
-
${
|
|
49
|
+
${P?`Use the Expo Go app to run the mobile application.
|
|
50
50
|
`:""}
|
|
51
51
|
The API is running at [http://localhost:3000](http://localhost:3000).
|
|
52
52
|
|
|
@@ -63,13 +63,13 @@ See: https://github.com/vite-pwa/vite-plugin-pwa/issues/809
|
|
|
63
63
|
${a}/
|
|
64
64
|
\u251C\u2500\u2500 apps/
|
|
65
65
|
${u||c?`\u2502 \u251C\u2500\u2500 web/ # Frontend application (React, ${u?"TanStack Router":"React Router"})
|
|
66
|
-
`:""}${
|
|
66
|
+
`:""}${P?`\u2502 \u251C\u2500\u2500 native/ # Mobile application (React Native, Expo)
|
|
67
67
|
`:""}\u2502 \u2514\u2500\u2500 server/ # Backend API (Hono, tRPC)
|
|
68
68
|
\`\`\`
|
|
69
69
|
|
|
70
70
|
## Available Scripts
|
|
71
71
|
|
|
72
|
-
${ya($,r,o,n,
|
|
72
|
+
${ya($,r,o,n,P)}
|
|
73
73
|
`}function ba(e,a,t,r,n,s){let o=s.includes("tanstack-router"),i=s.includes("react-router"),p=s.includes("native"),c=["- **TypeScript** - For type safety and improved developer experience"];o?c.push("- **TanStack Router** - File-based routing with full type safety"):i&&c.push("- **React Router** - Declarative routing for React"),p&&(c.push("- **React Native** - Build mobile apps using React"),c.push("- **Expo** - Tools for React Native development")),c.push("- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs",`- **${n==="bun"?"Bun":"Node.js"}** - Runtime environment`),e!=="none"&&c.push(`- **${r==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&c.push("- **Authentication** - Email & password authentication with Better Auth");for(let u of t)u==="pwa"?c.push("- **PWA** - Progressive Web App support"):u==="tauri"?c.push("- **Tauri** - Build native desktop applications"):u==="biome"?c.push("- **Biome** - Linting and formatting"):u==="husky"&&c.push("- **Husky** - Git hooks for code quality");return c.join(`
|
|
74
74
|
`)}function wa(e,a,t,r){if(e==="none")return"";let n=`## Database Setup
|
|
75
75
|
|
|
@@ -132,7 +132,7 @@ ${n}`,await I.writeFile(t,r.trim())}catch(t){throw M.error("Failed to update env
|
|
|
132
132
|
3. Get your database URL
|
|
133
133
|
4. Add the database URL to the .env file in apps/server/.env
|
|
134
134
|
|
|
135
|
-
DATABASE_URL="your_database_url"`)}async function Ma(e){try{
|
|
135
|
+
DATABASE_URL="your_database_url"`)}async function Ma(e){try{b({dependencies:["@prisma/extension-accelerate"],projectDir:e});let a=H.join(e,"prisma/index.ts");await I.writeFile(a,`
|
|
136
136
|
import { PrismaClient } from '@prisma/client';
|
|
137
137
|
import { withAccelerate } from "@prisma/extension-accelerate";
|
|
138
138
|
|
|
@@ -151,8 +151,8 @@ DATABASE_AUTH_TOKEN=`;await Ke.ensureDir(we.dirname(t)),await Ke.writeFile(t,r)}
|
|
|
151
151
|
4. Add these credentials to the .env file in apps/server/.env
|
|
152
152
|
|
|
153
153
|
DATABASE_URL=your_database_url
|
|
154
|
-
DATABASE_AUTH_TOKEN=your_auth_token`)}async function Xe(e,a){let t=K();t.start("Setting up Turso database");try{if(!a){t.stop("Skipping Turso setup"),await Y(e),N.info(A.blue("Skipping Turso setup. Setting up empty configuration.")),se();return}let r=Na.platform(),n=r==="darwin";if(!(r!=="win32")){t.stop(A.yellow("Turso setup not supported on Windows")),N.warn(A.yellow("Automatic Turso setup is not supported on Windows.")),await Y(e),se();return}if(t.stop("Checking Turso CLI"),!await qa()){let $=await za({message:"Would you like to install Turso CLI?",initialValue:!0});if(Pe($)&&(ye(A.red("Operation cancelled")),process.exit(0)),!$){await Y(e),se();return}await Wa(n)}await Va()||await Ga();let p=await Qa(),c=!1,u="",
|
|
155
|
-
${n}=${s}`,r=!0)}r&&await oe.writeFile(e,t.trim())}async function tt(e,a){let t=G.join(e,"apps/server"),r=G.join(t,".env"),n=a.frontend.includes("react-router"),s=a.frontend.includes("tanstack-router"),o=a.frontend.includes("tanstack-start"),i=n||s||o,p="http://localhost:3000";n?p="http://localhost:5173":(s||o)&&(p="http://localhost:3001");let c="",u=a.dbSetup==="turso"||a.dbSetup==="prisma-postgres"||a.dbSetup==="mongodb-atlas"||a.dbSetup==="neon";u||(a.database==="postgres"?c="postgresql://postgres:postgres@localhost:5432/mydb?schema=public":a.database==="mysql"?c="mysql://root:password@localhost:3306/mydb":a.database==="mongodb"?c="mongodb://localhost:27017/mydatabase":a.database==="sqlite"&&(c="file:./local.db"));let
|
|
154
|
+
DATABASE_AUTH_TOKEN=your_auth_token`)}async function Xe(e,a){let t=K();t.start("Setting up Turso database");try{if(!a){t.stop("Skipping Turso setup"),await Y(e),N.info(A.blue("Skipping Turso setup. Setting up empty configuration.")),se();return}let r=Na.platform(),n=r==="darwin";if(!(r!=="win32")){t.stop(A.yellow("Turso setup not supported on Windows")),N.warn(A.yellow("Automatic Turso setup is not supported on Windows.")),await Y(e),se();return}if(t.stop("Checking Turso CLI"),!await qa()){let $=await za({message:"Would you like to install Turso CLI?",initialValue:!0});if(Pe($)&&(ye(A.red("Operation cancelled")),process.exit(0)),!$){await Y(e),se();return}await Wa(n)}await Va()||await Ga();let p=await Qa(),c=!1,u="",P=we.basename(e);for(;!c;){let $=await Ua({message:"Enter a name for your database:",defaultValue:P,initialValue:P,placeholder:P});Pe($)&&(ye(A.red("Operation cancelled")),process.exit(0)),u=$;try{let S=await Ha(u,p),U=K();U.start("Writing configuration to .env file"),await Y(e,S),U.stop("Turso database configured successfully!"),c=!0}catch(S){if(S instanceof Error&&S.message==="DATABASE_EXISTS")N.warn(A.yellow(`Database "${A.red(u)}" already exists`)),P=`${u}-${Math.floor(Math.random()*1e3)}`;else throw S}}}catch(r){t.stop(A.red("Failed to set up Turso database")),N.error(A.red(`Error during Turso setup: ${r instanceof Error?r.message:String(r)}`)),await Y(e),se(),N.success("Setup completed with manual configuration required.")}}async function et(e,a,t,r,n,s,o,i){let p=Xa(),c=Ye.join(e,"apps/server");if(a==="none"){await Ya.remove(Ye.join(c,"src/db"));return}try{t==="prisma"?b({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:c}):t==="drizzle"&&(a==="sqlite"?b({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:c}):a==="postgres"?b({dependencies:["drizzle-orm","pg"],devDependencies:["drizzle-kit","@types/pg"],projectDir:c}):a==="mysql"&&b({dependencies:["drizzle-orm","mysql2"],devDependencies:["drizzle-kit"],projectDir:c})),a==="sqlite"&&n?await Xe(e,t==="drizzle"):a==="postgres"?t==="prisma"&&s?await He(e,r):i&&await Je(e,r):a==="mongodb"&&o&&await Ue(e)}catch(u){throw p.stop(Ze.red("Failed to set up database")),u instanceof Error&&Ka.error(Ze.red(u.message)),u}}import G from"node:path";import oe from"fs-extra";async function je(e,a){await oe.ensureDir(G.dirname(e));let t="";await oe.pathExists(e)&&(t=await oe.readFile(e,"utf8"));let r=!1;for(let{key:n,value:s,condition:o}of a)if(o){let i=new RegExp(`^${n}=.*$`,"m");i.test(t)?s&&(t=t.replace(i,`${n}=${s}`),r=!0):(t+=`
|
|
155
|
+
${n}=${s}`,r=!0)}r&&await oe.writeFile(e,t.trim())}async function tt(e,a){let t=G.join(e,"apps/server"),r=G.join(t,".env"),n=a.frontend.includes("react-router"),s=a.frontend.includes("tanstack-router"),o=a.frontend.includes("tanstack-start"),i=n||s||o,p="http://localhost:3000";n?p="http://localhost:5173":(s||o)&&(p="http://localhost:3001");let c="",u=a.dbSetup==="turso"||a.dbSetup==="prisma-postgres"||a.dbSetup==="mongodb-atlas"||a.dbSetup==="neon";u||(a.database==="postgres"?c="postgresql://postgres:postgres@localhost:5432/mydb?schema=public":a.database==="mysql"?c="mysql://root:password@localhost:3306/mydb":a.database==="mongodb"?c="mongodb://localhost:27017/mydatabase":a.database==="sqlite"&&(c="file:./local.db"));let P=[{key:"CORS_ORIGIN",value:p,condition:!0},{key:"BETTER_AUTH_SECRET",value:Oe(),condition:!!a.auth},{key:"BETTER_AUTH_URL",value:"http://localhost:3000",condition:!!a.auth},{key:"DATABASE_URL",value:c,condition:a.database!=="none"&&c!==""&&!u},{key:"GOOGLE_GENERATIVE_AI_API_KEY",value:"",condition:a.examples?.includes("ai")||!1}];if(await je(r,P),i){let $=G.join(e,"apps/web"),S=[{key:"VITE_SERVER_URL",value:"http://localhost:3000",condition:!0}];await je(G.join($,".env"),S)}if(a.frontend.includes("native")){let $=G.join(e,"apps/native"),S=[{key:"EXPO_PUBLIC_SERVER_URL",value:"http://localhost:3000",condition:!0}];await je(G.join($,".env"),S)}}import x from"node:path";import w from"fs-extra";async function at(e,a,t,r,n,s=["tanstack-router"]){let o=s.includes("tanstack-router"),i=s.includes("tanstack-start"),p=s.includes("react-router"),c=o||p||i,u;o?u="web-tanstack-router":i?u="web-tanstack-start":u="web-react-router";let P=await w.pathExists(x.join(e,"apps/web"));a.includes("todo")&&c&&P?await ar(e,t,r,u):await sr(e,t),a.includes("ai")&&(n==="hono"||n==="express")&&c&&P&&await Za(e,u)}async function Za(e,a){let t=x.join(v,"template/examples/ai");if(await w.pathExists(t)){let r=x.join(t,`apps/${a}/src/routes/ai.tsx`),n=x.join(e,"apps/web/src/routes/ai.tsx");await w.pathExists(r)&&await w.copy(r,n,{overwrite:!0}),await tr(e,a);let s=x.join(e,"apps/web");b({dependencies:["ai"],projectDir:s});let o=x.join(e,"apps/server");b({dependencies:["ai","@ai-sdk/google"],projectDir:o}),await er(e)}}async function er(e){let a=x.join(e,"apps/server/src/index.ts");if(await w.pathExists(a)){let t=await w.readFile(a,"utf8"),r=t.includes("hono"),n=t.includes("express");if(r){let s=`import { streamText } from "ai";
|
|
156
156
|
import { google } from "@ai-sdk/google";
|
|
157
157
|
import { stream } from "hono/streaming";`,o=`
|
|
158
158
|
// AI chat endpoint
|
|
@@ -204,26 +204,26 @@ ${t.substring(i)}`;else{let p=t.indexOf("app.listen(");if(p!==-1){let c=t.lastIn
|
|
|
204
204
|
|
|
205
205
|
${t.substring(c)}`}else t=`${t}
|
|
206
206
|
|
|
207
|
-
${o}`}}await
|
|
207
|
+
${o}`}}await w.writeFile(a,t)}}async function tr(e,a){let t=x.join(e,"apps/web/src/components/header.tsx");if(await w.pathExists(t)){let r=await w.readFile(t,"utf8"),n=/const links = \[\s*([^;]*?)\s*\];/s,s=r.match(n);if(s){let o=s[1];if(!o.includes('"/ai"')){let i=`const links = [
|
|
208
208
|
${o}${o.trim().endsWith(",")?"":","}
|
|
209
209
|
{ to: "/ai", label: "AI Chat" },
|
|
210
|
-
];`;r=r.replace(n,i),await
|
|
210
|
+
];`;r=r.replace(n,i),await w.writeFile(t,r)}}}}async function ar(e,a,t,r){let n=x.join(v,"template/examples/todo");if(await w.pathExists(n)){let s=x.join(n,`apps/${r}/src/routes/todos.tsx`),o=x.join(e,"apps/web/src/routes/todos.tsx");if(await w.pathExists(s)&&await w.copy(s,o,{overwrite:!0}),a!=="none"){let i=x.join(n,`apps/server/src/routers/with-${a}-todo.ts`),p=x.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(i)&&await w.copy(i,p,{overwrite:!0}),await rr(e)}await nr(e,r)}}async function rr(e){let a=x.join(e,"apps/server/src/routers/index.ts");if(await w.pathExists(a)){let t=await w.readFile(a,"utf8");if(!t.includes("import { todoRouter }")){let r=t.lastIndexOf("import"),n=t.indexOf(`
|
|
211
211
|
|
|
212
212
|
`,r);n!==-1?t=`${t.slice(0,n)}
|
|
213
213
|
import { todoRouter } from "./todo";${t.slice(n)}`:t=`import { todoRouter } from "./todo";
|
|
214
214
|
${t}`;let s=t.indexOf("export const appRouter = router({");if(s!==-1){let o=t.indexOf("{",s)+1;t=`${t.slice(0,o)}
|
|
215
|
-
todo: todoRouter,${t.slice(o)}`}await
|
|
215
|
+
todo: todoRouter,${t.slice(o)}`}await w.writeFile(a,t)}}}async function nr(e,a){let t=x.join(e,"apps/web/src/components/header.tsx");if(await w.pathExists(t)){let r=await w.readFile(t,"utf8"),n=/const links = \[\s*([^;]*?)\s*\];/s,s=r.match(n);if(s){let o=s[1];if(!o.includes('"/todos"')){let i=`const links = [
|
|
216
216
|
${o}${o.trim().endsWith(",")?"":","}
|
|
217
217
|
{ to: "/todos", label: "Todos" },
|
|
218
|
-
];`;r=r.replace(n,i),await
|
|
219
|
-
${r?"":`${
|
|
220
|
-
`}${
|
|
221
|
-
|
|
222
|
-
${
|
|
223
|
-
${Kt?`${$e?`${
|
|
224
|
-
`:""}`:`${
|
|
225
|
-
`}${
|
|
226
|
-
${s?.includes("starlight")?`${
|
|
218
|
+
];`;r=r.replace(n,i),await w.writeFile(t,r)}}}}async function sr(e,a){if(a==="drizzle"){let r=x.join(e,"apps/server/src/db/schema/todo.ts");await w.pathExists(r)&&await w.remove(r)}else if(a==="prisma"){let r=x.join(e,"apps/server/prisma/schema/todo.prisma");await w.pathExists(r)&&await w.remove(r)}let t=x.join(e,"apps/server/src/routers/todo.ts");await w.pathExists(t)&&await w.remove(t),await or(e)}async function or(e){let a=x.join(e,"apps/server/src/routers/index.ts");if(await w.pathExists(a)){let t=await w.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await w.writeFile(a,t)}}import{log as rt,spinner as nt}from"@clack/prompts";import{$ as st}from"execa";import ie from"picocolors";async function ot({projectDir:e,packageManager:a,addons:t=[]}){let r=nt();try{r.start(`Running ${a} install...`),await st({cwd:e,stderr:"inherit"})`${a} install`,r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await ir(e,a)}catch(n){throw r.stop(ie.red("Failed to install dependencies")),n instanceof Error&&rt.error(ie.red(`Installation error: ${n.message}`)),n}}async function ir(e,a){let t=nt();try{t.start("Running Biome format check..."),await st({cwd:e,stderr:"inherit"})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(ie.yellow("Biome check encountered issues")),rt.warn(ie.yellow("Some files may need manual formatting"))}}import{note as cr}from"@clack/prompts";import y from"picocolors";function it(e,a,t,r,n,s,o,i,p){let c=t==="npm"?"npm run":t,u=`cd ${a}`,P=s?.includes("husky")||s?.includes("biome"),$=e!=="none"?ur(e,n,c,o):"",S=s?.includes("tauri")?dr(c):"",U=P?lr(c):"",J=i?.includes("native")?pr():"",C=s?.includes("pwa")&&i?.includes("react-router")?mr():"",T=s?.includes("starlight")?fr(c):"",R=i?.includes("tanstack-router"),Qt=i?.includes("tanstack-start"),xe=i?.includes("react-router"),$e=R||xe||Qt,Ht=i?.includes("native"),Kt=$e||Ht,Xt=xe?"5173":"3001";cr(`${y.cyan("1.")} ${u}
|
|
219
|
+
${r?"":`${y.cyan("2.")} ${t} install
|
|
220
|
+
`}${y.cyan(r?"2.":"3.")} ${c} dev
|
|
221
|
+
|
|
222
|
+
${y.bold("Your project will be available at:")}
|
|
223
|
+
${Kt?`${$e?`${y.cyan("\u2022")} Frontend: http://localhost:${Xt}
|
|
224
|
+
`:""}`:`${y.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
|
|
225
|
+
`}${y.cyan("\u2022")} API: http://localhost:3000
|
|
226
|
+
${s?.includes("starlight")?`${y.cyan("\u2022")} Docs: http://localhost:4321
|
|
227
227
|
`:""}${J?`
|
|
228
228
|
${J.trim()}`:""}${$?`
|
|
229
229
|
${$.trim()}`:""}${S?`
|
|
@@ -232,35 +232,35 @@ ${U.trim()}`:""}${C?`
|
|
|
232
232
|
${C.trim()}`:""}${T?`
|
|
233
233
|
${T.trim()}`:""}
|
|
234
234
|
|
|
235
|
-
${
|
|
236
|
-
${
|
|
235
|
+
${y.bold("Like Better-T Stack?")} Please consider giving us a star on GitHub:
|
|
236
|
+
${y.cyan("https://github.com/AmanVarshney01/create-better-t-stack")}`,"Next steps")}function pr(){return`${y.yellow("NOTE:")} For Expo connectivity issues, update apps/native/.env
|
|
237
237
|
with your local IP:
|
|
238
238
|
EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000
|
|
239
|
-
`}function lr(e){return`${
|
|
240
|
-
${
|
|
239
|
+
`}function lr(e){return`${y.bold("Linting and formatting:")}
|
|
240
|
+
${y.cyan("\u2022")} Format and lint fix: ${`${e} check`}
|
|
241
241
|
|
|
242
|
-
`}function ur(e,a,t,r){let n=[];return a==="prisma"?(e==="sqlite"&&n.push(`${
|
|
243
|
-
follow the guidance provided in the error messages`),n.push(`${
|
|
242
|
+
`}function ur(e,a,t,r){let n=[];return a==="prisma"?(e==="sqlite"&&n.push(`${y.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,"Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso"),r==="bun"&&n.push(`${y.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors,
|
|
243
|
+
follow the guidance provided in the error messages`),n.push(`${y.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${y.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)):a==="drizzle"&&(n.push(`${y.cyan("\u2022")} Apply schema: ${`${t} db:push`}`),n.push(`${y.cyan("\u2022")} Database UI: ${`${t} db:studio`}`)),n.length?`${y.bold("Database commands:")}
|
|
244
244
|
${n.join(`
|
|
245
245
|
`)}
|
|
246
246
|
|
|
247
247
|
`:""}function dr(e){return`
|
|
248
|
-
${
|
|
249
|
-
${
|
|
250
|
-
${
|
|
251
|
-
${
|
|
248
|
+
${y.bold("Desktop app with Tauri:")}
|
|
249
|
+
${y.cyan("\u2022")} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}
|
|
250
|
+
${y.cyan("\u2022")} Build desktop app: ${`cd apps/web && ${e} desktop:build`}
|
|
251
|
+
${y.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies.
|
|
252
252
|
See: https://v2.tauri.app/start/prerequisites/
|
|
253
253
|
|
|
254
|
-
`}function mr(){return`${
|
|
255
|
-
${
|
|
254
|
+
`}function mr(){return`${y.bold("PWA with React Router v7:")}
|
|
255
|
+
${y.yellow("NOTE:")} There is a known compatibility issue between VitePWA and React Router v7.
|
|
256
256
|
See: https://github.com/vite-pwa/vite-plugin-pwa/issues/809
|
|
257
|
-
`}function fr(e){return`${
|
|
258
|
-
${
|
|
259
|
-
${
|
|
260
|
-
`}import ce from"node:path";import{log as hr}from"@clack/prompts";import{$ as ct,execa as gr}from"execa";import z from"fs-extra";import br from"picocolors";async function pt(e,a){await wr(e,a),await yr(e,a)}async function wr(e,a){let t=ce.join(e,"package.json");if(await z.pathExists(t)){let r=await z.readJson(t);r.name=a.projectName;let{stdout:n}=await gr(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await z.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let s=ce.join(v,"template/with-pnpm/pnpm-workspace.yaml"),o=ce.join(e,"pnpm-workspace.yaml");await z.pathExists(s)&&await z.copy(s,o)}}}async function yr(e,a){let t=ce.join(e,"apps/server/package.json");if(await z.pathExists(t)){let r=await z.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 z.writeJson(t,r,{spaces:2})}}async function lt(e,a){if(!a)return;if((await ct({cwd:e,reject:!1,stderr:"pipe"})`git --version`).exitCode!==0){hr.warn(br.yellow("Git is not installed"));return}let r=await ct({cwd:e,reject:!1,stderr:"pipe"})`git init`;if(r.exitCode!==0)throw new Error(`Git initialization failed: ${r.stderr}`)}import pe from"node:path";import _ from"fs-extra";async function ut(e,a,t){let r=pe.join(e,"apps/server"),n=pe.join(r,"src/index.ts"),s=await _.readFile(n,"utf-8");a==="bun"?await Pr(r,n,s,t):a==="node"&&await jr(r,n,s,t)}async function Pr(e,a,t,r){let n=pe.join(e,"package.json"),s=await _.readJson(n);if(s.scripts={...s.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await _.writeJson(n,s,{spaces:2}),
|
|
257
|
+
`}function fr(e){return`${y.bold("Documentation with Starlight:")}
|
|
258
|
+
${y.cyan("\u2022")} Start docs site: ${`cd apps/docs && ${e} dev`}
|
|
259
|
+
${y.cyan("\u2022")} Build docs site: ${`cd apps/docs && ${e} build`}
|
|
260
|
+
`}import ce from"node:path";import{log as hr}from"@clack/prompts";import{$ as ct,execa as gr}from"execa";import z from"fs-extra";import br from"picocolors";async function pt(e,a){await wr(e,a),await yr(e,a)}async function wr(e,a){let t=ce.join(e,"package.json");if(await z.pathExists(t)){let r=await z.readJson(t);r.name=a.projectName;let{stdout:n}=await gr(a.packageManager,["-v"],{cwd:e});if(r.packageManager=`${a.packageManager}@${n.trim()}`,await z.writeJson(t,r,{spaces:2}),a.packageManager==="pnpm"){let s=ce.join(v,"template/with-pnpm/pnpm-workspace.yaml"),o=ce.join(e,"pnpm-workspace.yaml");await z.pathExists(s)&&await z.copy(s,o)}}}async function yr(e,a){let t=ce.join(e,"apps/server/package.json");if(await z.pathExists(t)){let r=await z.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 z.writeJson(t,r,{spaces:2})}}async function lt(e,a){if(!a)return;if((await ct({cwd:e,reject:!1,stderr:"pipe"})`git --version`).exitCode!==0){hr.warn(br.yellow("Git is not installed"));return}let r=await ct({cwd:e,reject:!1,stderr:"pipe"})`git init`;if(r.exitCode!==0)throw new Error(`Git initialization failed: ${r.stderr}`)}import pe from"node:path";import _ from"fs-extra";async function ut(e,a,t){let r=pe.join(e,"apps/server"),n=pe.join(r,"src/index.ts"),s=await _.readFile(n,"utf-8");a==="bun"?await Pr(r,n,s,t):a==="node"&&await jr(r,n,s,t)}async function Pr(e,a,t,r){let n=pe.join(e,"package.json"),s=await _.readJson(n);if(s.scripts={...s.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await _.writeJson(n,s,{spaces:2}),b({devDependencies:["@types/bun"],projectDir:e}),r==="hono"){let o=`${t}
|
|
261
261
|
|
|
262
262
|
export default app;
|
|
263
|
-
`;await _.writeFile(a,o)}}async function jr(e,a,t,r){let n=pe.join(e,"package.json"),s=await _.readJson(n);if(s.scripts={...s.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await _.writeJson(n,s,{spaces:2}),
|
|
263
|
+
`;await _.writeFile(a,o)}}async function jr(e,a,t,r){let n=pe.join(e,"package.json"),s=await _.readJson(n);if(s.scripts={...s.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await _.writeJson(n,s,{spaces:2}),b({devDependencies:["tsx","@types/node"],projectDir:e}),r==="hono"){b({dependencies:["@hono/node-server"],projectDir:e});let o=`import { serve } from "@hono/node-server";
|
|
264
264
|
`,i=`
|
|
265
265
|
serve(
|
|
266
266
|
{
|
|
@@ -271,13 +271,13 @@ serve(
|
|
|
271
271
|
console.log(\`Server is running on http://localhost:\${info.port}\`);
|
|
272
272
|
},
|
|
273
273
|
);
|
|
274
|
-
`;if(!t.includes("@hono/node-server")){let p=t.lastIndexOf("import"),c=t.substring(0,p),u=t.substring(p),
|
|
274
|
+
`;if(!t.includes("@hono/node-server")){let p=t.lastIndexOf("import"),c=t.substring(0,p),u=t.substring(p),P=c+o+u+i;await _.writeFile(a,P)}}else if(r==="elysia"&&(b({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let o=`import { node } from "@elysiajs/node";
|
|
275
275
|
`,i=t.indexOf(`
|
|
276
|
-
`,t.indexOf("import")),p=t.substring(0,i+1),c=t.substring(i+1),u=p+o+c;u=u.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await _.writeFile(a,u)}}import d from"node:path";import l from"fs-extra";async function dt(e){let a=d.join(v,"template/base");if(!await l.pathExists(a))throw new Error(`Template directory not found: ${a}`);await l.ensureDir(e);let t=await l.readdir(a);for(let s of t){let o=d.join(a,s),i=d.join(e,s);s!=="apps"&&(await l.stat(o).then(p=>p.isDirectory())?await l.copy(o,i):await l.copy(o,i))}await l.ensureDir(d.join(e,"apps"));let r=d.join(a,"apps/server"),n=d.join(e,"apps/server");await l.pathExists(r)&&await l.copy(r,n)}async function mt(e,a){let t=a.includes("tanstack-router"),r=a.includes("tanstack-start"),n=a.includes("react-router"),s=a.includes("native");if(t||n||r){let o=d.join(e,"apps/web");await l.ensureDir(o);let i=d.join(v,"template/base/apps/web-base");await l.pathExists(i)&&await l.copy(i,o);let p="web-react-router";t?p="web-tanstack-router":r&&(p="web-tanstack-start");let c=d.join(v,`template/base/apps/${p}`);await l.pathExists(c)&&await l.copy(c,o,{overwrite:!0});let u=d.join(o,"package.json");if(await l.pathExists(u)){let
|
|
277
|
-
`)}}async function ft(e,a){let t=d.join(v,`template/with-${a}`);await l.pathExists(t)&&await l.copy(t,e,{overwrite:!0})}async function ht(e,a,t,r){if(a==="none"||t==="none")return;let n=d.join(v,kr(a,t));if(await l.pathExists(n)&&(await l.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let s=d.join(e,"apps/server/prisma/schema/auth.prisma");await l.pathExists(s)&&await l.remove(s)}else if(a==="drizzle"){let s=d.join(e,"apps/server/src/db/schema/auth.ts");await l.pathExists(s)&&await l.remove(s)}}}async function gt(e,a,t,r,n,s){if(!a)return;let o=d.join(v,"template/with-auth");if(await l.pathExists(o)){let i=s.includes("react-router"),p=s.includes("tanstack-router"),c=s.includes("tanstack-start");if(i||p||c){let C=d.join(e,"apps/web"),T=d.join(o,"apps/web-base");if(await l.pathExists(T)&&await l.copy(T,C,{overwrite:!0}),i){let R=d.join(o,"apps/web-react-router");await l.pathExists(R)&&await l.copy(R,C,{overwrite:!0})}if(p){let R=d.join(o,"apps/web-tanstack-router");await l.pathExists(R)&&await l.copy(R,C,{overwrite:!0})}if(c){let R=d.join(o,"apps/web-tanstack-start");await l.pathExists(R)&&await l.copy(R,C,{overwrite:!0})}}let u=d.join(o,"apps/server/src"),
|
|
276
|
+
`,t.indexOf("import")),p=t.substring(0,i+1),c=t.substring(i+1),u=p+o+c;u=u.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await _.writeFile(a,u)}}import d from"node:path";import l from"fs-extra";async function dt(e){let a=d.join(v,"template/base");if(!await l.pathExists(a))throw new Error(`Template directory not found: ${a}`);await l.ensureDir(e);let t=await l.readdir(a);for(let s of t){let o=d.join(a,s),i=d.join(e,s);s!=="apps"&&(await l.stat(o).then(p=>p.isDirectory())?await l.copy(o,i):await l.copy(o,i))}await l.ensureDir(d.join(e,"apps"));let r=d.join(a,"apps/server"),n=d.join(e,"apps/server");await l.pathExists(r)&&await l.copy(r,n)}async function mt(e,a){let t=a.includes("tanstack-router"),r=a.includes("tanstack-start"),n=a.includes("react-router"),s=a.includes("native");if(t||n||r){let o=d.join(e,"apps/web");await l.ensureDir(o);let i=d.join(v,"template/base/apps/web-base");await l.pathExists(i)&&await l.copy(i,o);let p="web-react-router";t?p="web-tanstack-router":r&&(p="web-tanstack-start");let c=d.join(v,`template/base/apps/${p}`);await l.pathExists(c)&&await l.copy(c,o,{overwrite:!0});let u=d.join(o,"package.json");if(await l.pathExists(u)){let P=await l.readJson(u);P.name="web",await l.writeJson(u,P,{spaces:2})}}if(s){let o=d.join(v,"template/base/apps/native"),i=d.join(e,"apps/native");await l.pathExists(o)&&await l.copy(o,i),await l.writeFile(d.join(e,".npmrc"),`node-linker=hoisted
|
|
277
|
+
`)}}async function ft(e,a){let t=d.join(v,`template/with-${a}`);await l.pathExists(t)&&await l.copy(t,e,{overwrite:!0})}async function ht(e,a,t,r){if(a==="none"||t==="none")return;let n=d.join(v,kr(a,t));if(await l.pathExists(n)&&(await l.copy(n,e,{overwrite:!0}),!r)){if(a==="prisma"){let s=d.join(e,"apps/server/prisma/schema/auth.prisma");await l.pathExists(s)&&await l.remove(s)}else if(a==="drizzle"){let s=d.join(e,"apps/server/src/db/schema/auth.ts");await l.pathExists(s)&&await l.remove(s)}}}async function gt(e,a,t,r,n,s){if(!a)return;let o=d.join(v,"template/with-auth");if(await l.pathExists(o)){let i=s.includes("react-router"),p=s.includes("tanstack-router"),c=s.includes("tanstack-start");if(i||p||c){let C=d.join(e,"apps/web"),T=d.join(o,"apps/web-base");if(await l.pathExists(T)&&await l.copy(T,C,{overwrite:!0}),i){let R=d.join(o,"apps/web-react-router");await l.pathExists(R)&&await l.copy(R,C,{overwrite:!0})}if(p){let R=d.join(o,"apps/web-tanstack-router");await l.pathExists(R)&&await l.copy(R,C,{overwrite:!0})}if(c){let R=d.join(o,"apps/web-tanstack-start");await l.pathExists(R)&&await l.copy(R,C,{overwrite:!0})}}let u=d.join(o,"apps/server/src"),P=d.join(e,"apps/server/src");await l.copy(d.join(u,"lib/trpc.ts"),d.join(P,"lib/trpc.ts"),{overwrite:!0}),await l.copy(d.join(u,"routers/index.ts"),d.join(P,"routers/index.ts"),{overwrite:!0});let $=`with-${t}-context.ts`;await l.copy(d.join(u,"lib",$),d.join(P,"lib/context.ts"),{overwrite:!0});let S=`with-${t}-index.ts`;await l.copy(d.join(u,S),d.join(P,"index.ts"),{overwrite:!0});let U=xr(r,n),J=d.join(u,U);if(await l.pathExists(J)){let C=await l.readdir(J);for(let T of C)await l.copy(d.join(J,T),d.join(P,"lib",T),{overwrite:!0})}if(s.includes("native")){let C=d.join(o,"apps/native"),T=d.join(e,"apps/native");await l.pathExists(C)&&await l.copy(C,T,{overwrite:!0}),b({dependencies:["@better-auth/expo"],projectDir:d.join(e,"apps/server")}),await vr(e,r,n)}}}async function vr(e,a,t){let r=d.join(e,"apps/server"),n;if(a==="drizzle"?t==="sqlite"?n=d.join(r,"src/lib/auth.ts"):t==="postgres"&&(n=d.join(r,"src/lib/auth.ts")):a==="prisma"&&(t==="sqlite"?n=d.join(r,"src/lib/auth.ts"):t==="postgres"&&(n=d.join(r,"src/lib/auth.ts"))),n&&await l.pathExists(n)){let s=await l.readFile(n,"utf8");if(!s.includes("@better-auth/expo")){let o=`import { expo } from "@better-auth/expo";
|
|
278
278
|
`,i=s.lastIndexOf("import"),p=s.indexOf(`
|
|
279
279
|
`,i)+1;s=s.substring(0,p)+o+s.substring(p)}s.includes("plugins:")?s.includes("expo()")||(s=s.replace(/plugins: \[(.*?)\]/s,(o,i)=>`plugins: [${i}${i.trim()?", ":""}expo()]`)):s=s.replace(/}\);/,` plugins: [expo()],
|
|
280
|
-
});`),s.includes("my-better-t-app://")||(s=s.replace(/trustedOrigins: \[(.*?)\]/s,(o,i)=>`trustedOrigins: [${i}${i.trim()?", ":""}"my-better-t-app://"]`)),await l.writeFile(n,s)}}async function bt(e){let a=await wt(e);for(let t of a)if(await l.pathExists(t)){let r=d.join(d.dirname(t),".gitignore");await l.move(t,r,{overwrite:!0})}}async function wt(e){let a=[],t=d.join(e,"_gitignore");await l.pathExists(t)&&a.push(t);try{let r=await l.readdir(e,{withFileTypes:!0});for(let n of r)if(n.isDirectory()&&n.name!=="node_modules"){let s=d.join(e,n.name),o=await wt(s);a.push(...o)}}catch{}return a}function kr(e,a){if(e==="drizzle"){if(a==="sqlite")return"template/with-drizzle-sqlite";if(a==="postgres")return"template/with-drizzle-postgres";if(a==="mysql")return"template/with-drizzle-mysql"}if(e==="prisma"){if(a==="sqlite")return"template/with-prisma-sqlite";if(a==="postgres")return"template/with-prisma-postgres";if(a==="mysql")return"template/with-prisma-mysql";if(a==="mongodb")return"template/with-prisma-mongodb"}return"template/base"}function xr(e,a){if(e==="drizzle"){if(a==="sqlite")return"with-drizzle-sqlite-lib";if(a==="postgres")return"with-drizzle-postgres-lib";if(a==="mysql")return"with-drizzle-mysql-lib"}if(e==="prisma"){if(a==="sqlite")return"with-prisma-sqlite-lib";if(a==="postgres")return"with-prisma-postgres-lib";if(a==="mysql")return"with-prisma-mysql-lib";if(a==="mongodb")return"with-prisma-mongodb-lib"}throw new Error("Invalid ORM or database configuration for auth setup")}async function Pt(e){let a=Ar(),t=$r.resolve(process.cwd(),e.projectName);try{return await Er.ensureDir(t),await dt(t),await mt(t,e.frontend),await bt(t),await ft(t,e.backend),await Be(t,e.backend,e.runtime),await ht(t,e.orm,e.database,e.auth),await et(t,e.database,e.orm,e.packageManager,e.dbSetup==="turso",e.dbSetup==="prisma-postgres",e.dbSetup==="mongodb-atlas",e.dbSetup==="neon"),await gt(t,e.auth,e.backend,e.orm,e.database,e.frontend),await Le(t,e.auth,e.frontend),await ut(t,e.runtime,e.backend),await at(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await tt(t,e),await lt(t,e.git),e.addons.length>0&&await Re(t,e.addons,e.packageManager,e.frontend),await pt(t,e),await Me(t,e),e.noInstall||await ot({projectDir:t,packageManager:e.packageManager,addons:e.addons}),it(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(yt.red("Failed")),r instanceof Error&&(Sr(yt.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as An,group as En}from"@clack/prompts";import Dn from"picocolors";import{cancel as Dr,isCancel as Cr,multiselect as Tr}from"@clack/prompts";import Rr from"picocolors";async function jt(e,a){if(e!==void 0)return e;let t=a?.includes("react-router")||a?.includes("tanstack-router"),r=[{value:"starlight",label:"Starlight",hint:"Add Astro Starlight documentation site"},{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],s=t?[...[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"}],...r]:r,o=P.addons.filter(p=>t||p!=="pwa"&&p!=="tauri"),i=await Tr({message:"Select addons",options:s,initialValues:o,required:!1});return Cr(i)&&(Dr(Rr.red("Operation cancelled")),process.exit(0)),i.includes("husky")&&!i.includes("biome")&&i.push("biome"),i}import{cancel as Fr,confirm as Ir,isCancel as Or}from"@clack/prompts";import Lr from"picocolors";async function vt(e,a,t){if(!a)return!1;if(e!==void 0)return e;let r=await Ir({message:"Add authentication with Better-Auth?",initialValue:P.auth});return Or(r)&&(Fr(Lr.red("Operation cancelled")),process.exit(0)),r}import{cancel as Br,isCancel as Mr,select as Nr}from"@clack/prompts";import zr from"picocolors";async function kt(e){if(e!==void 0)return e;let a=await Nr({message:"Select backend framework",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"express",label:"Express",hint:"Fast, unopinionated, minimalist web framework for Node.js"},{value:"elysia",label:"Elysia",hint:"Ergonomic web framework for building backend servers"}],initialValue:P.backend});return Mr(a)&&(Br(zr.red("Operation cancelled")),process.exit(0)),a}import{cancel as _r,isCancel as Ur,select as qr}from"@clack/prompts";import Vr from"picocolors";async function xt(e){if(e!==void 0)return e;let a=await qr({message:"Select database",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"lightweight, server-less, embedded relational database management system"},{value:"postgres",label:"PostgreSQL",hint:"powerful, open source object-relational database system"},{value:"mysql",label:"MySQL",hint:"popular open-source relational database system"},{value:"mongodb",label:"MongoDB",hint:"open-source NoSQL database that stores data in JSON-like documents called BSON"}],initialValue:P.database});return Ur(a)&&(_r(Vr.red("Operation cancelled")),process.exit(0)),a}import{cancel as Gr,isCancel as Wr,select as Jr}from"@clack/prompts";import Qr from"picocolors";async function $t(e,a,t){if(a!==void 0)return a;if(e==="sqlite"&&t==="prisma")return"none";let r=[];if(e==="sqlite")r=[{value:"turso",label:"Turso",hint:"SQLite for Production. Powered by libSQL"},{value:"none",label:"None",hint:"Manual setup"}];else if(e==="postgres")r=[{value:"neon",label:"Neon Postgres",hint:"Serverless Postgres with branching capability"},...t==="prisma"?[{value:"prisma-postgres",label:"Prisma Postgres",hint:"Instant Postgres for Global Applications"}]:[],{value:"none",label:"None",hint:"Manual setup"}];else if(e==="mongodb")r=[{value:"mongodb-atlas",label:"MongoDB Atlas",hint:"The most effective way to deploy MongoDB"},{value:"none",label:"None",hint:"Manual setup"}];else return"none";let n=await Jr({message:`Select ${e} setup option`,options:r,initialValue:"none"});return Wr(n)&&(Gr(Qr.red("Operation cancelled")),process.exit(0)),n}import{cancel as Hr,isCancel as Kr,multiselect as St}from"@clack/prompts";import Xr from"picocolors";async function At(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!(t?.includes("react-router")||t?.includes("tanstack-router")||t?.includes("tanstack-start")))return[];let s=[];return r==="elysia"&&(s=await St({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:P.examples})),(r==="hono"||r==="express")&&(s=await St({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"},{value:"ai",label:"AI Chat",hint:"A simple AI chat interface using AI SDK"}],required:!1,initialValues:P.examples})),Kr(s)&&(Hr(Xr.red("Operation cancelled")),process.exit(0)),s}import{cancel as Et,isCancel as Dt,multiselect as Yr,select as Zr}from"@clack/prompts";import Ct from"picocolors";async function Tt(e){if(e!==void 0)return e;let a=await Yr({message:"Select platforms to develop for",options:[{value:"web",label:"Web",hint:"React Web Application"},{value:"native",label:"Native",hint:"Create a React Native/Expo app"}],required:!1,initialValues:P.frontend.some(r=>r==="tanstack-router"||r==="react-router"||r==="tanstack-start")?["web"]:[]});Dt(a)&&(Et(Ct.red("Operation cancelled")),process.exit(0));let t=[];if(a.includes("web")){let r=await Zr({message:"Choose frontend framework",options:[{value:"tanstack-router",label:"TanStack Router",hint:"Modern and scalable routing for React Applications"},{value:"react-router",label:"React Router",hint:"A user\u2011obsessed, standards\u2011focused, multi\u2011strategy router"},{value:"tanstack-start",label:"TanStack Start (beta)",hint:"SSR, Server Functions, API Routes and more with TanStack Router"}],initialValue:P.frontend.find(n=>n==="tanstack-router"||n==="react-router"||n==="tanstack-start")||"tanstack-router"});Dt(r)&&(Et(Ct.red("Operation cancelled")),process.exit(0)),t.push(r)}return a.includes("native")&&t.push("native"),t}import{cancel as en,confirm as tn,isCancel as an}from"@clack/prompts";import rn from"picocolors";async function Rt(e){if(e!==void 0)return e;let a=await tn({message:"Initialize git repository?",initialValue:P.git});return an(a)&&(en(rn.red("Operation cancelled")),process.exit(0)),a}import{cancel as nn,confirm as sn,isCancel as on}from"@clack/prompts";import cn from"picocolors";async function Ft(e){if(e!==void 0)return e;let a=await sn({message:"Install dependencies?",initialValue:!P.noInstall});return on(a)&&(nn(cn.red("Operation cancelled")),process.exit(0)),!a}import{cancel as pn,isCancel as ln,log as un,select as dn}from"@clack/prompts";import mn from"picocolors";async function It(e,a,t){if(!a)return"none";if(e!==void 0)return e;if(t==="mongodb")return un.info("Only Prisma is supported with MongoDB."),"prisma";let r=await dn({message:"Select ORM",options:[{value:"drizzle",label:"Drizzle",hint:"lightweight and performant TypeScript ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:P.orm});return ln(r)&&(pn(mn.red("Operation cancelled")),process.exit(0)),r}import{cancel as fn,isCancel as hn,select as gn}from"@clack/prompts";import bn from"picocolors";async function Ot(e){if(e!==void 0)return e;let a=ee(),t=await gn({message:"Choose package manager",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"}],initialValue:a});return hn(t)&&(fn(bn.red("Operation cancelled")),process.exit(0)),t}import Z from"node:path";import{cancel as wn,isCancel as yn,text as Pn}from"@clack/prompts";import W from"fs-extra";import jn from"picocolors";var vn=["<",">",":",'"',"|","?","*"],Lt=255;function Bt(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Lt)return`Project name must be less than ${Lt} characters`;if(vn.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")return"Project name is reserved"}}async function Mt(e){if(e)if(e==="."){let s=process.cwd();if(W.readdirSync(s).length===0)return e}else{let s=Z.basename(e);if(!Bt(s)){let i=Z.resolve(process.cwd(),e);if(!W.pathExistsSync(i)||W.readdirSync(i).length===0)return e}}let a=!1,t="",r=P.projectName,n=1;for(;W.pathExistsSync(Z.resolve(process.cwd(),r));)r=`${P.projectName}-${n}`,n++;for(;!a;){let s=await Pn({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:o=>{let i=o.trim()||r;if(i==="."){if(W.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let p=Z.resolve(process.cwd(),i),c=Z.basename(p),u=Bt(c);if(u)return u;if(!p.startsWith(process.cwd()))return"Project path must be within current directory";if(W.pathExistsSync(p)&&W.readdirSync(p).length>0)return`Directory "${i}" already exists and is not empty. Please choose a different name or path.`;a=!0}});yn(s)&&(wn(jn.red("Operation cancelled.")),process.exit(0)),t=s||r}return t}import{cancel as kn,isCancel as xn,select as $n}from"@clack/prompts";import Sn from"picocolors";async function Nt(e){if(e!==void 0)return e;let a=await $n({message:"Select runtime",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:P.runtime});return xn(a)&&(kn(Sn.red("Operation cancelled")),process.exit(0)),a}async function zt(e){let a=await En({projectName:async()=>Mt(e.projectName),frontend:()=>Tt(e.frontend),backend:()=>kt(e.backend),runtime:()=>Nt(e.runtime),database:()=>xt(e.database),orm:({results:t})=>It(e.orm,t.database!=="none",t.database),auth:({results:t})=>vt(e.auth,t.database!=="none",t.frontend),addons:({results:t})=>jt(e.addons,t.frontend),examples:({results:t})=>At(e.examples,t.database,t.frontend,t.backend),dbSetup:({results:t})=>$t(t.database??"none",e.dbSetup,t.orm),git:()=>Rt(e.git),packageManager:()=>Ot(e.packageManager),noInstall:()=>Ft(e.noInstall)},{onCancel:()=>{An(Dn.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,frontend:a.frontend,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,dbSetup:a.dbSetup,backend:a.backend,runtime:a.runtime}}import D from"picocolors";function ve(e){let a=[];if(e.projectName&&a.push(`${D.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${D.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${D.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${D.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${D.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${D.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${D.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${D.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${D.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${D.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${D.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${D.blue("Skip Install:")} ${e.noInstall}`),e.dbSetup!==void 0&&a.push(`${D.blue("Database Setup:")} ${e.dbSetup}`),a.join(`
|
|
280
|
+
});`),s.includes("my-better-t-app://")||(s=s.replace(/trustedOrigins: \[(.*?)\]/s,(o,i)=>`trustedOrigins: [${i}${i.trim()?", ":""}"my-better-t-app://"]`)),await l.writeFile(n,s)}}async function bt(e){let a=await wt(e);for(let t of a)if(await l.pathExists(t)){let r=d.join(d.dirname(t),".gitignore");await l.move(t,r,{overwrite:!0})}}async function wt(e){let a=[],t=d.join(e,"_gitignore");await l.pathExists(t)&&a.push(t);try{let r=await l.readdir(e,{withFileTypes:!0});for(let n of r)if(n.isDirectory()&&n.name!=="node_modules"){let s=d.join(e,n.name),o=await wt(s);a.push(...o)}}catch{}return a}function kr(e,a){if(e==="drizzle"){if(a==="sqlite")return"template/with-drizzle-sqlite";if(a==="postgres")return"template/with-drizzle-postgres";if(a==="mysql")return"template/with-drizzle-mysql"}if(e==="prisma"){if(a==="sqlite")return"template/with-prisma-sqlite";if(a==="postgres")return"template/with-prisma-postgres";if(a==="mysql")return"template/with-prisma-mysql";if(a==="mongodb")return"template/with-prisma-mongodb"}return"template/base"}function xr(e,a){if(e==="drizzle"){if(a==="sqlite")return"with-drizzle-sqlite-lib";if(a==="postgres")return"with-drizzle-postgres-lib";if(a==="mysql")return"with-drizzle-mysql-lib"}if(e==="prisma"){if(a==="sqlite")return"with-prisma-sqlite-lib";if(a==="postgres")return"with-prisma-postgres-lib";if(a==="mysql")return"with-prisma-mysql-lib";if(a==="mongodb")return"with-prisma-mongodb-lib"}throw new Error("Invalid ORM or database configuration for auth setup")}async function Pt(e){let a=Ar(),t=$r.resolve(process.cwd(),e.projectName);try{return await Er.ensureDir(t),await dt(t),await mt(t,e.frontend),await bt(t),await ft(t,e.backend),await Be(t,e.backend,e.runtime),await ht(t,e.orm,e.database,e.auth),await et(t,e.database,e.orm,e.packageManager,e.dbSetup==="turso",e.dbSetup==="prisma-postgres",e.dbSetup==="mongodb-atlas",e.dbSetup==="neon"),await gt(t,e.auth,e.backend,e.orm,e.database,e.frontend),await Le(t,e.auth,e.frontend),await ut(t,e.runtime,e.backend),await at(t,e.examples,e.orm,e.auth,e.backend,e.frontend),await tt(t,e),await lt(t,e.git),e.addons.length>0&&await Re(t,e.addons,e.packageManager,e.frontend),await pt(t,e),await Me(t,e),e.noInstall||await ot({projectDir:t,packageManager:e.packageManager,addons:e.addons}),it(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(r){throw a.message(yt.red("Failed")),r instanceof Error&&(Sr(yt.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{cancel as An,group as En}from"@clack/prompts";import Dn from"picocolors";import{cancel as Dr,isCancel as Cr,multiselect as Tr}from"@clack/prompts";import Rr from"picocolors";async function jt(e,a){if(e!==void 0)return e;let t=a?.includes("react-router")||a?.includes("tanstack-router"),r=[{value:"starlight",label:"Starlight",hint:"Add Astro Starlight documentation site"},{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],s=t?[...[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"}],...r]:r,o=g.addons.filter(p=>t||p!=="pwa"&&p!=="tauri"),i=await Tr({message:"Select addons",options:s,initialValues:o,required:!1});return Cr(i)&&(Dr(Rr.red("Operation cancelled")),process.exit(0)),i.includes("husky")&&!i.includes("biome")&&i.push("biome"),i}import{cancel as Fr,confirm as Ir,isCancel as Or}from"@clack/prompts";import Lr from"picocolors";async function vt(e,a,t){if(!a)return!1;if(e!==void 0)return e;let r=await Ir({message:"Add authentication with Better-Auth?",initialValue:g.auth});return Or(r)&&(Fr(Lr.red("Operation cancelled")),process.exit(0)),r}import{cancel as Br,isCancel as Mr,select as Nr}from"@clack/prompts";import zr from"picocolors";async function kt(e){if(e!==void 0)return e;let a=await Nr({message:"Select backend framework",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"express",label:"Express",hint:"Fast, unopinionated, minimalist web framework for Node.js"},{value:"elysia",label:"Elysia",hint:"Ergonomic web framework for building backend servers"}],initialValue:g.backend});return Mr(a)&&(Br(zr.red("Operation cancelled")),process.exit(0)),a}import{cancel as _r,isCancel as Ur,select as qr}from"@clack/prompts";import Vr from"picocolors";async function xt(e){if(e!==void 0)return e;let a=await qr({message:"Select database",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"lightweight, server-less, embedded relational database management system"},{value:"postgres",label:"PostgreSQL",hint:"powerful, open source object-relational database system"},{value:"mysql",label:"MySQL",hint:"popular open-source relational database system"},{value:"mongodb",label:"MongoDB",hint:"open-source NoSQL database that stores data in JSON-like documents called BSON"}],initialValue:g.database});return Ur(a)&&(_r(Vr.red("Operation cancelled")),process.exit(0)),a}import{cancel as Gr,isCancel as Wr,select as Jr}from"@clack/prompts";import Qr from"picocolors";async function $t(e,a,t){if(a!==void 0)return a;if(e==="sqlite"&&t==="prisma")return"none";let r=[];if(e==="sqlite")r=[{value:"turso",label:"Turso",hint:"SQLite for Production. Powered by libSQL"},{value:"none",label:"None",hint:"Manual setup"}];else if(e==="postgres")r=[{value:"neon",label:"Neon Postgres",hint:"Serverless Postgres with branching capability"},...t==="prisma"?[{value:"prisma-postgres",label:"Prisma Postgres",hint:"Instant Postgres for Global Applications"}]:[],{value:"none",label:"None",hint:"Manual setup"}];else if(e==="mongodb")r=[{value:"mongodb-atlas",label:"MongoDB Atlas",hint:"The most effective way to deploy MongoDB"},{value:"none",label:"None",hint:"Manual setup"}];else return"none";let n=await Jr({message:`Select ${e} setup option`,options:r,initialValue:"none"});return Wr(n)&&(Gr(Qr.red("Operation cancelled")),process.exit(0)),n}import{cancel as Hr,isCancel as Kr,multiselect as St}from"@clack/prompts";import Xr from"picocolors";async function At(e,a,t,r){if(e!==void 0)return e;if(a==="none")return[];if(!(t?.includes("react-router")||t?.includes("tanstack-router")||t?.includes("tanstack-start")))return[];let s=[];return r==="elysia"&&(s=await St({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:g.examples})),(r==="hono"||r==="express")&&(s=await St({message:"Include examples",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"},{value:"ai",label:"AI Chat",hint:"A simple AI chat interface using AI SDK"}],required:!1,initialValues:g.examples})),Kr(s)&&(Hr(Xr.red("Operation cancelled")),process.exit(0)),s}import{cancel as Et,isCancel as Dt,multiselect as Yr,select as Zr}from"@clack/prompts";import Ct from"picocolors";async function Tt(e){if(e!==void 0)return e;let a=await Yr({message:"Select platforms to develop for",options:[{value:"web",label:"Web",hint:"React Web Application"},{value:"native",label:"Native",hint:"Create a React Native/Expo app"}],required:!1,initialValues:g.frontend.some(r=>r==="tanstack-router"||r==="react-router"||r==="tanstack-start")?["web"]:[]});Dt(a)&&(Et(Ct.red("Operation cancelled")),process.exit(0));let t=[];if(a.includes("web")){let r=await Zr({message:"Choose frontend framework",options:[{value:"tanstack-router",label:"TanStack Router",hint:"Modern and scalable routing for React Applications"},{value:"react-router",label:"React Router",hint:"A user\u2011obsessed, standards\u2011focused, multi\u2011strategy router"},{value:"tanstack-start",label:"TanStack Start (beta)",hint:"SSR, Server Functions, API Routes and more with TanStack Router"}],initialValue:g.frontend.find(n=>n==="tanstack-router"||n==="react-router"||n==="tanstack-start")||"tanstack-router"});Dt(r)&&(Et(Ct.red("Operation cancelled")),process.exit(0)),t.push(r)}return a.includes("native")&&t.push("native"),t}import{cancel as en,confirm as tn,isCancel as an}from"@clack/prompts";import rn from"picocolors";async function Rt(e){if(e!==void 0)return e;let a=await tn({message:"Initialize git repository?",initialValue:g.git});return an(a)&&(en(rn.red("Operation cancelled")),process.exit(0)),a}import{cancel as nn,confirm as sn,isCancel as on}from"@clack/prompts";import cn from"picocolors";async function Ft(e){if(e!==void 0)return e;let a=await sn({message:"Install dependencies?",initialValue:!g.noInstall});return on(a)&&(nn(cn.red("Operation cancelled")),process.exit(0)),!a}import{cancel as pn,isCancel as ln,log as un,select as dn}from"@clack/prompts";import mn from"picocolors";async function It(e,a,t){if(!a)return"none";if(e!==void 0)return e;if(t==="mongodb")return un.info("Only Prisma is supported with MongoDB."),"prisma";let r=await dn({message:"Select ORM",options:[{value:"drizzle",label:"Drizzle",hint:"lightweight and performant TypeScript ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:g.orm});return ln(r)&&(pn(mn.red("Operation cancelled")),process.exit(0)),r}import{cancel as fn,isCancel as hn,select as gn}from"@clack/prompts";import bn from"picocolors";async function Ot(e){if(e!==void 0)return e;let a=ee(),t=await gn({message:"Choose package manager",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"}],initialValue:a});return hn(t)&&(fn(bn.red("Operation cancelled")),process.exit(0)),t}import Z from"node:path";import{cancel as wn,isCancel as yn,text as Pn}from"@clack/prompts";import W from"fs-extra";import jn from"picocolors";var vn=["<",">",":",'"',"|","?","*"],Lt=255;function Bt(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Lt)return`Project name must be less than ${Lt} characters`;if(vn.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")return"Project name is reserved"}}async function Mt(e){if(e)if(e==="."){let s=process.cwd();if(W.readdirSync(s).length===0)return e}else{let s=Z.basename(e);if(!Bt(s)){let i=Z.resolve(process.cwd(),e);if(!W.pathExistsSync(i)||W.readdirSync(i).length===0)return e}}let a=!1,t="",r=g.projectName,n=1;for(;W.pathExistsSync(Z.resolve(process.cwd(),r));)r=`${g.projectName}-${n}`,n++;for(;!a;){let s=await Pn({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:o=>{let i=o.trim()||r;if(i==="."){if(W.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let p=Z.resolve(process.cwd(),i),c=Z.basename(p),u=Bt(c);if(u)return u;if(!p.startsWith(process.cwd()))return"Project path must be within current directory";if(W.pathExistsSync(p)&&W.readdirSync(p).length>0)return`Directory "${i}" already exists and is not empty. Please choose a different name or path.`;a=!0}});yn(s)&&(wn(jn.red("Operation cancelled.")),process.exit(0)),t=s||r}return t}import{cancel as kn,isCancel as xn,select as $n}from"@clack/prompts";import Sn from"picocolors";async function Nt(e){if(e!==void 0)return e;let a=await $n({message:"Select runtime",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:g.runtime});return xn(a)&&(kn(Sn.red("Operation cancelled")),process.exit(0)),a}async function zt(e){let a=await En({projectName:async()=>Mt(e.projectName),frontend:()=>Tt(e.frontend),backend:()=>kt(e.backend),runtime:()=>Nt(e.runtime),database:()=>xt(e.database),orm:({results:t})=>It(e.orm,t.database!=="none",t.database),auth:({results:t})=>vt(e.auth,t.database!=="none",t.frontend),addons:({results:t})=>jt(e.addons,t.frontend),examples:({results:t})=>At(e.examples,t.database,t.frontend,t.backend),dbSetup:({results:t})=>$t(t.database??"none",e.dbSetup,t.orm),git:()=>Rt(e.git),packageManager:()=>Ot(e.packageManager),noInstall:()=>Ft(e.noInstall)},{onCancel:()=>{An(Dn.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,frontend:a.frontend,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,dbSetup:a.dbSetup,backend:a.backend,runtime:a.runtime}}import D from"picocolors";function ve(e){let a=[];if(e.projectName&&a.push(`${D.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${D.blue("Frontend:")} ${t}`)}if(e.backend!==void 0&&a.push(`${D.blue("Backend Framework:")} ${e.backend}`),e.runtime!==void 0&&a.push(`${D.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${D.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${D.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${D.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${D.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${D.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${D.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${D.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${D.blue("Skip Install:")} ${e.noInstall}`),e.dbSetup!==void 0&&a.push(`${D.blue("Database Setup:")} ${e.dbSetup}`),a.join(`
|
|
281
281
|
`)}function _t(e){let a=[];e.database==="none"?a.push("--database none"):(a.push(`--database ${e.database}`),e.orm&&a.push(`--orm ${e.orm}`),e.dbSetup&&a.push(`--db-setup ${e.dbSetup}`)),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.runtime&&a.push(`--runtime ${e.runtime}`),e.backend&&a.push(`--backend ${e.backend}`),e.frontend&&e.frontend.length>0&&a.push(`--frontend ${e.frontend.join(" ")}`),e.addons&&e.addons.length>0?a.push(`--addons ${e.addons.join(" ")}`):a.push("--addons none"),e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(" ")}`):a.push("--no-examples"),e.packageManager&&a.push(`--package-manager ${e.packageManager}`);let t="",r=e.packageManager;r==="npm"?t="npx create-better-t-stack@latest":r==="pnpm"?t="pnpm create better-t-stack@latest":r==="bun"&&(t="bun create better-t-stack@latest");let n=e.projectName?` ${e.projectName}`:"";return`${t}${n} ${a.join(" ")}`}import Cn from"node:path";import Tn from"fs-extra";var Ut=()=>{let e=Cn.join(v,"package.json");return Tn.readJSONSync(e).version??"1.0.0"};import qt from"gradient-string";var Vt=`
|
|
282
282
|
\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
|
|
283
283
|
\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
|
|
@@ -297,5 +297,5 @@ serve(
|
|
|
297
297
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
298
298
|
\u2551 Better T-Stack \u2551
|
|
299
299
|
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
300
|
-
`)):console.log(qt(Object.values(Gt)).multiline(Vt))};var Jt=()=>process.exit(0);process.on("SIGINT",Jt);process.on("SIGTERM",Jt);var ke=new On;async function Ln(){let e=Date.now();ke.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Ut()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--database <type>","Database type (none, sqlite, postgres, mysql, mongodb)").option("--orm <type>","ORM type (drizzle, prisma)").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--frontend <types...>","Frontend types (tanstack-router, react-router, tanstack-start, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, starlight, biome, husky, none)").option("--examples <types...>","Examples to include (todo, ai)").option("--no-examples","Skip all examples").option("--git","Initialize git repository").option("--no-git","Skip git initialization").option("--package-manager <pm>","Package manager (npm, pnpm, bun)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--db-setup <setup>","Database setup (turso, neon, prisma-postgres, mongodb-atlas, none)").option("--backend <framework>","Backend framework (hono, express, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=In();try{Wt(),Rn(h.magenta("Creating a new Better-T-Stack project"));let t=ke.opts(),r=ke.args[0],n=Bn(t,r);!t.yes&&Object.keys(n).length>0&&(L.info(h.yellow("Using these pre-selected options:")),L.message(ve(n)),L.message(""));let s=t.yes?{...
|
|
301
|
-
${h.white(_t(s))}`));let o=((Date.now()-e)/1e3).toFixed(2);Fn(h.magenta(`Project created successfully in ${h.bold(o)} seconds!`))}catch(t){a.stop(h.red("Failed")),t instanceof Error&&(j(h.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function Bn(e,a){let t={};if(e.database&&(["none","sqlite","postgres","mysql","mongodb"].includes(e.database)||(j(h.red(`Invalid database type: ${e.database}. Must be none, sqlite, postgres, mysql, or mongodb.`)),process.exit(1)),t.database=e.database),e.orm&&(["drizzle","prisma"].includes(e.orm)||(j(h.red(`Invalid ORM type: ${e.orm}. Must be drizzle or prisma.`)),process.exit(1)),t.orm=e.orm),t.database==="mongodb"&&t.orm==="drizzle"&&(j(h.red("MongoDB is only available with Prisma. Cannot use --database mongodb with --orm drizzle")),process.exit(1)),e.dbSetup&&(["turso","prisma-postgres","mongodb-atlas","neon","none"].includes(e.dbSetup)||(j(h.red(`Invalid database setup: ${e.dbSetup}. Must be turso, prisma-postgres, mongodb-atlas, neon, or none.`)),process.exit(1)),e.dbSetup!=="none"?(t.dbSetup=e.dbSetup,e.dbSetup==="turso"?(e.database&&e.database!=="sqlite"&&(j(h.red(`Turso setup requires a SQLite database. Cannot use --db-setup turso with --database ${e.database}`)),process.exit(1)),t.database="sqlite",e.orm==="prisma"&&(j(h.red("Turso setup is not compatible with Prisma. Cannot use --db-setup turso with --orm prisma")),process.exit(1)),t.orm="drizzle"):e.dbSetup==="prisma-postgres"?(e.database&&e.database!=="postgres"&&(j(h.red("Prisma PostgreSQL setup requires PostgreSQL database. Cannot use --db-setup prisma-postgres with a different database type.")),process.exit(1)),t.database="postgres",e.orm&&e.orm!=="prisma"&&(j(h.red("Prisma PostgreSQL setup requires Prisma ORM. Cannot use --db-setup prisma-postgres with a different ORM.")),process.exit(1)),t.orm="prisma"):e.dbSetup==="mongodb-atlas"?(e.database&&e.database!=="mongodb"&&(j(h.red("MongoDB Atlas setup requires MongoDB database. Cannot use --db-setup mongodb-atlas with a different database type.")),process.exit(1)),t.database="mongodb",t.orm="prisma"):e.dbSetup==="neon"&&(e.database&&e.database!=="postgres"&&(j(h.red("Neon PostgreSQL setup requires PostgreSQL database. Cannot use --db-setup neon with a different database type.")),process.exit(1)),t.database="postgres")):t.dbSetup="none"),t.database==="none"&&(e.auth===!0&&(j(h.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(j(h.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),e.dbSetup&&e.dbSetup!=="none"&&(j(h.red(`Database setup requires a database. Cannot use --db-setup ${e.dbSetup} with --database none.`)),process.exit(1))),"auth"in e&&(t.auth=e.auth),e.backend&&(["hono","elysia","express"].includes(e.backend)||(j(h.red(`Invalid backend framework: ${e.backend}. Must be hono, elysia, or express.`)),process.exit(1)),t.backend=e.backend),e.runtime&&(["bun","node"].includes(e.runtime)||(j(h.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),t.runtime=e.runtime),e.frontend&&e.frontend.length>0){let r=["tanstack-router","react-router","tanstack-start","native","none"],n=e.frontend.filter(s=>!r.includes(s));if(n.length>0&&(j(h.red(`Invalid frontend(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.frontend.includes("none"))e.frontend.length>1&&(j(h.red("Cannot combine 'none' with other frontend options.")),process.exit(1)),t.frontend=[];else{let s=e.frontend.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start"||i==="native");s.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start").length>1&&(j(h.red("Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router")),process.exit(1)),t.frontend=s}}if(e.addons&&e.addons.length>0){let r=["pwa","tauri","biome","husky","starlight","none"],n=e.addons.filter(s=>!r.includes(s));if(n.length>0&&(j(h.red(`Invalid addon(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.addons.includes("none"))e.addons.length>1&&(j(h.red("Cannot combine 'none' with other addons.")),process.exit(1)),t.addons=[];else{let s=e.addons.filter(c=>c==="pwa"||c==="tauri"||c==="biome"||c==="husky"||c==="starlight"),o=["pwa","tauri"],i=s.some(c=>o.includes(c)),p=t.frontend?.some(c=>c==="tanstack-router"||c==="react-router");i&&!p&&(j(h.red("PWA and Tauri addons require tanstack-router or react-router. Cannot use these addons with your frontend selection.")),process.exit(1)),s.includes("husky")&&!s.includes("biome")&&s.push("biome"),t.addons=s}}if("examples"in e){if(e.examples===!1)t.examples=[];else if(Array.isArray(e.examples)){let r=["todo","ai"],n=e.examples.filter(o=>!r.includes(o));n.length>0&&(j(h.red(`Invalid example(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&(e.backend==="elysia"||t.backend==="elysia")&&(j(h.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1));let s=t.frontend?.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o));e.examples.length>0&&!s&&(!e.frontend||!e.frontend.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o)))&&(j(h.red("Examples require a web frontend (tanstack-router, react-router, or tanstack-start). Cannot use --examples without a compatible frontend.")),process.exit(1)),t.examples=e.examples.filter(o=>o==="todo"||o==="ai")}}return e.packageManager&&(["npm","pnpm","bun"].includes(e.packageManager)||(j(h.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),t.packageManager=e.packageManager),"git"in e&&(t.git=e.git),"install"in e&&(t.noInstall=!e.install),a&&(t.projectName=a),t}Ln().catch(e=>{L.error("Aborting installation..."),e instanceof Error?L.error(e.message):(L.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
|
|
300
|
+
`)):console.log(qt(Object.values(Gt)).multiline(Vt))};var Jt=()=>process.exit(0);process.on("SIGINT",Jt);process.on("SIGTERM",Jt);var ke=new On;async function Ln(){let e=Date.now();ke.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Ut()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--database <type>","Database type (none, sqlite, postgres, mysql, mongodb)").option("--orm <type>","ORM type (drizzle, prisma)").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--frontend <types...>","Frontend types (tanstack-router, react-router, tanstack-start, native, none)").option("--addons <types...>","Additional addons (pwa, tauri, starlight, biome, husky, none)").option("--examples <types...>","Examples to include (todo, ai)").option("--no-examples","Skip all examples").option("--git","Initialize git repository").option("--no-git","Skip git initialization").option("--package-manager <pm>","Package manager (npm, pnpm, bun)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--db-setup <setup>","Database setup (turso, neon, prisma-postgres, mongodb-atlas, none)").option("--backend <framework>","Backend framework (hono, express, elysia)").option("--runtime <runtime>","Runtime (bun, node)").parse();let a=In();try{Wt(),Rn(h.magenta("Creating a new Better-T-Stack project"));let t=ke.opts(),r=ke.args[0],n=Bn(t,r);!t.yes&&Object.keys(n).length>0&&(L.info(h.yellow("Using these pre-selected options:")),L.message(ve(n)),L.message(""));let s=t.yes?{...g,projectName:r??g.projectName,...n}:await zt(n);t.yes&&(L.info(h.yellow("Using these default options:")),L.message(ve(s)),L.message("")),await Pt(s),L.success(h.blue(`You can reproduce this setup with the following command:
|
|
301
|
+
${h.white(_t(s))}`));let o=((Date.now()-e)/1e3).toFixed(2);Fn(h.magenta(`Project created successfully in ${h.bold(o)} seconds!`))}catch(t){a.stop(h.red("Failed")),t instanceof Error&&(j(h.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}function Bn(e,a){let t={};if(e.database&&(["none","sqlite","postgres","mysql","mongodb"].includes(e.database)||(j(h.red(`Invalid database type: ${e.database}. Must be none, sqlite, postgres, mysql, or mongodb.`)),process.exit(1)),t.database=e.database),e.orm&&(["drizzle","prisma"].includes(e.orm)||(j(h.red(`Invalid ORM type: ${e.orm}. Must be drizzle or prisma.`)),process.exit(1)),t.orm=e.orm),t.database==="mongodb"&&t.orm==="drizzle"&&(j(h.red("MongoDB is only available with Prisma. Cannot use --database mongodb with --orm drizzle")),process.exit(1)),e.dbSetup&&(["turso","prisma-postgres","mongodb-atlas","neon","none"].includes(e.dbSetup)||(j(h.red(`Invalid database setup: ${e.dbSetup}. Must be turso, prisma-postgres, mongodb-atlas, neon, or none.`)),process.exit(1)),e.dbSetup!=="none"?(t.dbSetup=e.dbSetup,e.dbSetup==="turso"?(e.database&&e.database!=="sqlite"&&(j(h.red(`Turso setup requires a SQLite database. Cannot use --db-setup turso with --database ${e.database}`)),process.exit(1)),t.database="sqlite",e.orm==="prisma"&&(j(h.red("Turso setup is not compatible with Prisma. Cannot use --db-setup turso with --orm prisma")),process.exit(1)),t.orm="drizzle"):e.dbSetup==="prisma-postgres"?(e.database&&e.database!=="postgres"&&(j(h.red("Prisma PostgreSQL setup requires PostgreSQL database. Cannot use --db-setup prisma-postgres with a different database type.")),process.exit(1)),t.database="postgres",e.orm&&e.orm!=="prisma"&&(j(h.red("Prisma PostgreSQL setup requires Prisma ORM. Cannot use --db-setup prisma-postgres with a different ORM.")),process.exit(1)),t.orm="prisma"):e.dbSetup==="mongodb-atlas"?(e.database&&e.database!=="mongodb"&&(j(h.red("MongoDB Atlas setup requires MongoDB database. Cannot use --db-setup mongodb-atlas with a different database type.")),process.exit(1)),t.database="mongodb",t.orm="prisma"):e.dbSetup==="neon"&&(e.database&&e.database!=="postgres"&&(j(h.red("Neon PostgreSQL setup requires PostgreSQL database. Cannot use --db-setup neon with a different database type.")),process.exit(1)),t.database="postgres")):t.dbSetup="none"),t.database==="none"&&(e.auth===!0&&(j(h.red("Authentication requires a database. Cannot use --auth with --database none.")),process.exit(1)),e.orm&&e.orm!=="none"&&(j(h.red(`Cannot use ORM with no database. Cannot use --orm ${e.orm} with --database none.`)),process.exit(1)),e.dbSetup&&e.dbSetup!=="none"&&(j(h.red(`Database setup requires a database. Cannot use --db-setup ${e.dbSetup} with --database none.`)),process.exit(1))),"auth"in e&&(t.auth=e.auth),e.backend&&(["hono","elysia","express"].includes(e.backend)||(j(h.red(`Invalid backend framework: ${e.backend}. Must be hono, elysia, or express.`)),process.exit(1)),t.backend=e.backend),e.runtime&&(["bun","node"].includes(e.runtime)||(j(h.red(`Invalid runtime: ${e.runtime}. Must be bun or node.`)),process.exit(1)),t.runtime=e.runtime),e.frontend&&e.frontend.length>0){let r=["tanstack-router","react-router","tanstack-start","native","none"],n=e.frontend.filter(s=>!r.includes(s));if(n.length>0&&(j(h.red(`Invalid frontend(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.frontend.includes("none"))e.frontend.length>1&&(j(h.red("Cannot combine 'none' with other frontend options.")),process.exit(1)),t.frontend=[];else{let s=e.frontend.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start"||i==="native");s.filter(i=>i==="tanstack-router"||i==="react-router"||i==="tanstack-start").length>1&&(j(h.red("Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router")),process.exit(1)),t.frontend=s}}if(e.addons&&e.addons.length>0){let r=["pwa","tauri","biome","husky","starlight","none"],n=e.addons.filter(s=>!r.includes(s));if(n.length>0&&(j(h.red(`Invalid addon(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.addons.includes("none"))e.addons.length>1&&(j(h.red("Cannot combine 'none' with other addons.")),process.exit(1)),t.addons=[];else{let s=e.addons.filter(c=>c==="pwa"||c==="tauri"||c==="biome"||c==="husky"||c==="starlight"),o=["pwa","tauri"],i=s.some(c=>o.includes(c)),p=t.frontend?.some(c=>c==="tanstack-router"||c==="react-router");i&&!p&&!(e.yes&&g.frontend.some(c=>c==="tanstack-router"||c==="react-router"))&&(j(h.red("PWA and Tauri addons require tanstack-router or react-router. Cannot use these addons with your frontend selection.")),process.exit(1)),s.includes("husky")&&!s.includes("biome")&&s.push("biome"),t.addons=s}}if("examples"in e){if(e.examples===!1)t.examples=[];else if(Array.isArray(e.examples)){let r=["todo","ai"],n=e.examples.filter(o=>!r.includes(o));n.length>0&&(j(h.red(`Invalid example(s): ${n.join(", ")}. Valid options are: ${r.join(", ")}.`)),process.exit(1)),e.examples.includes("ai")&&(e.backend==="elysia"||t.backend==="elysia")&&!(e.yes&&g.backend!=="elysia")&&(j(h.red("AI example is only compatible with Hono backend. Cannot use --examples ai with --backend elysia")),process.exit(1));let s=t.frontend?.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o));e.examples.length>0&&!s&&(!e.frontend||!e.frontend.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o)))&&!(e.yes&&g.frontend.some(o=>["tanstack-router","react-router","tanstack-start"].includes(o)))&&(j(h.red("Examples require a web frontend (tanstack-router, react-router, or tanstack-start). Cannot use --examples without a compatible frontend.")),process.exit(1)),t.examples=e.examples.filter(o=>o==="todo"||o==="ai")}}return e.packageManager&&(["npm","pnpm","bun"].includes(e.packageManager)||(j(h.red(`Invalid package manager: ${e.packageManager}. Must be npm, pnpm, or bun.`)),process.exit(1)),t.packageManager=e.packageManager),"git"in e&&(t.git=e.git),"install"in e&&(t.noInstall=!e.install),a&&(t.projectName=a),t}Ln().catch(e=>{L.error("Aborting installation..."),e instanceof Error?L.error(e.message):(L.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.12.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|