create-better-t-stack 2.9.9 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -133,10 +133,19 @@ import { withAccelerate } from "@prisma/extension-accelerate";
133
133
  const prisma = new PrismaClient().$extends(withAccelerate());
134
134
 
135
135
  export default prisma;
136
- `;await h.writeFile(n,r.trim());let i=e.join(t,`src/db/index.ts`);if(await h.pathExists(i)){let e=await h.readFile(i,`utf8`);e.includes(`@prisma/extension-accelerate`)||(e=`import { withAccelerate } from "@prisma/extension-accelerate";\n${e}`,e=e.replace(`export const db = new PrismaClient();`,`export const db = new PrismaClient().$extends(withAccelerate());`),await h.writeFile(i,e))}return!0}catch{return o.warn(g.yellow(`Could not add Prisma Accelerate extension automatically`)),!1}}async function xe(t){let{projectName:n,packageManager:r,projectDir:i}=t,a=e.join(i,`apps/server`),s=d();s.start(`Setting up Prisma PostgreSQL`);try{await h.ensureDir(a),s.stop(`Starting Prisma setup`);let e=await ye(a,r);if(e)await L(i,e),await be(a),o.success(g.green(`Prisma PostgreSQL database configured successfully!`));else{let e=d();e.start(`Setting up fallback configuration`),await L(i),e.stop(`Manual setup required`),R()}}catch(e){s.stop(g.red(`Prisma PostgreSQL setup failed`)),m.error(g.red(`Error during Prisma PostgreSQL setup: ${e instanceof Error?e.message:String(e)}`));try{await L(i),R()}catch{}o.info(`Setup completed with manual configuration required.`)}}async function Se(){return P(`turso`)}async function Ce(){try{let e=await b`turso auth whoami`;return!e.stdout.includes(`You are not logged in`)}catch{return!1}}async function we(){let e=d();try{return e.start(`Logging in to Turso...`),await b`turso auth login`,e.stop(`Logged in to Turso successfully!`),!0}catch{e.stop(g.red(`Failed to log in to Turso`))}}async function Te(e){let t=d();try{if(t.start(`Installing Turso CLI...`),e)await b`brew install tursodatabase/tap/turso`;else{let{stdout:e}=await b`curl -sSfL https://get.tur.so/install.sh`;await b`bash -c '${e}'`}return t.stop(`Turso CLI installed successfully!`),!0}catch(e){if(e instanceof Error&&e.message.includes(`User force closed`))throw t.stop(`Turso CLI installation cancelled`),o.warn(g.yellow(`Turso CLI installation cancelled by user`)),Error(`Installation cancelled`);t.stop(g.red(`Failed to install Turso CLI`))}}async function Ee(){let e=d();try{e.start(`Fetching Turso groups...`);let{stdout:t}=await b`turso group list`,n=t.trim().split(`
137
- `);if(n.length<=1)return e.stop(`No Turso groups found`),[];let r=n.slice(1).map(e=>{let[t,n,r,i]=e.trim().split(/\s{2,}/);return{name:t,locations:n,version:r,status:i}});return e.stop(`Found ${r.length} Turso groups`),r}catch(t){return e.stop(g.red(`Error fetching Turso groups`)),console.error(`Error fetching Turso groups:`,t),[]}}async function De(){let e=await Ee();if(e.length===0)return null;if(e.length===1)return o.info(`Using the only available group: ${g.blue(e[0].name)}`),e[0].name;let n=e.map(e=>({value:e.name,label:`${e.name} (${e.locations})`})),r=await u({message:`Select a Turso database group:`,options:n});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function Oe(e,t){let n=d();try{n.start(`Creating Turso database "${e}"${t?` in group "${t}"`:``}...`),t?await b`turso db create ${e} --group ${t}`:await b`turso db create ${e}`,n.stop(`Created database "${e}"`)}catch(t){if(n.stop(g.red(`Failed to create database "${e}"`)),t instanceof Error&&t.message.includes(`already exists`))throw Error(`DATABASE_EXISTS`)}n.start(`Retrieving database connection details...`);try{let{stdout:t}=await b`turso db show ${e} --url`,{stdout:r}=await b`turso db tokens create ${e}`;return n.stop(`Retrieved database connection details`),{dbUrl:t.trim(),authToken:r.trim()}}catch{n.stop(g.red(`Failed to retrieve database connection details`))}}async function z(t,n){let r=e.join(t,`apps/server`,`.env`),i=n?`DATABASE_URL="${n.dbUrl}"
136
+ `;await h.writeFile(n,r.trim());let i=e.join(t,`src/db/index.ts`);if(await h.pathExists(i)){let e=await h.readFile(i,`utf8`);e.includes(`@prisma/extension-accelerate`)||(e=`import { withAccelerate } from "@prisma/extension-accelerate";\n${e}`,e=e.replace(`export const db = new PrismaClient();`,`export const db = new PrismaClient().$extends(withAccelerate());`),await h.writeFile(i,e))}return!0}catch{return o.warn(g.yellow(`Could not add Prisma Accelerate extension automatically`)),!1}}async function xe(t){let{packageManager:n,projectDir:r}=t,i=e.join(r,`apps/server`),a=d();a.start(`Setting up Prisma PostgreSQL`);try{await h.ensureDir(i),a.stop(`Starting Prisma setup`);let e=await ye(i,n);if(e)await L(r,e),await be(i),o.success(g.green(`Prisma PostgreSQL database configured successfully!`)),o.info(g.cyan('NOTE: Make sure to uncomment `import "dotenv/config";` in `apps/server/src/prisma.config.ts` to load environment variables.'));else{let e=d();e.start(`Setting up fallback configuration`),await L(r),e.stop(`Manual setup required`),R()}}catch(e){a.stop(g.red(`Prisma PostgreSQL setup failed`)),m.error(g.red(`Error during Prisma PostgreSQL setup: ${e instanceof Error?e.message:String(e)}`));try{await L(r),R()}catch{}o.info(`Setup completed with manual configuration required.`)}}async function Se(t,n){try{let r=e.join(t,`apps/server`,`.env`);await h.ensureDir(e.dirname(r));let i=``;await h.pathExists(r)&&(i=await h.readFile(r,`utf8`));let a=n||`postgresql://postgres:postgres@127.0.0.1:54322/postgres`,o=`DATABASE_URL="${a}"`,s=`DIRECT_URL="${a}"`;return i.includes(`DATABASE_URL=`)?i=i.replace(/DATABASE_URL=.*(\r?\n|$)/,`${o}$1`):i+=`\n${o}`,i.includes(`DIRECT_URL=`)?i=i.replace(/DIRECT_URL=.*(\r?\n|$)/,`${s}$1`):i+=`\n${s}`,await h.writeFile(r,i.trim()),!0}catch(e){return m.error(g.red(`Failed to update .env file for Supabase.`)),e instanceof Error&&m.error(e.message),!1}}function Ce(e){let t=e.match(/DB URL:\s*(postgresql:\/\/[^\s]+)/),n=t?.[1];return n||null}async function we(e,t){o.info(`Initializing Supabase project...`);try{let n=N(t,`supabase init`);return await x(n,{cwd:e,stdio:`inherit`,shell:!0}),o.success(`Supabase project initialized successfully.`),!0}catch(e){return m.error(g.red(`Failed to initialize Supabase project.`)),e instanceof Error?m.error(e.message):m.error(String(e)),e instanceof Error&&e.message.includes(`ENOENT`)&&(o.error(g.red(`Supabase CLI not found. Please install it globally or ensure it's in your PATH.`)),o.info(`You can install it using: npm install -g supabase`)),!1}}async function Te(e,t){o.info(`Starting Supabase services (this may take a moment)...`);let n=N(t,`supabase start`);try{let t=x(n,{cwd:e,shell:!0}),r=``;return t.stdout&&t.stdout.on(`data`,e=>{let t=e.toString();process.stdout.write(t),r+=t}),t.stderr&&t.stderr.pipe(process.stderr),await t,await new Promise(e=>setTimeout(e,100)),r}catch(e){m.error(g.red(`Failed to start Supabase services.`));let t=e;return t?.message?(m.error(`Error details: ${t.message}`),t.message.includes(`Docker is not running`)&&o.error(g.red(`Docker is not running. Please start Docker and try again.`))):m.error(String(e)),null}}function z(e){o.info(`"Manual Supabase Setup Instructions:"
137
+ 1. Ensure Docker is installed and running.
138
+ 2. Install the Supabase CLI (e.g., \`npm install -g supabase\`).
139
+ 3. Run \`supabase init\` in your project's \`apps/server\` directory.
140
+ 4. Run \`supabase start\` in your project's \`apps/server\` directory.
141
+ 5. Copy the 'DB URL' from the output.${e?`
142
+ ${g.bold("Relevant output from `supabase start`:")}
143
+ ${g.dim(e)}`:``}
144
+ 6. Add the DB URL to the .env file in \`apps/server/.env\` as \`DATABASE_URL\`:
145
+ ${g.gray(`DATABASE_URL="your_supabase_db_url"`)}`)}async function Ee(t){let{projectDir:n,packageManager:r}=t,i=e.join(n,`apps`,`server`);try{await h.ensureDir(i);let e=await we(i,r);if(!e){z();return}let t=await Te(i,r);if(!t){z();return}let a=Ce(t);if(a){let e=await Se(n,a);e?o.success(g.green(`Supabase local development setup complete!`)):(o.error(g.red(`Supabase setup completed, but failed to update .env automatically.`)),z(t))}else o.error(g.yellow(`Supabase started, but could not extract DB URL automatically.`)),z(t)}catch(e){e instanceof Error?m.error(g.red(`Error during Supabase setup: ${e.message}`)):m.error(g.red(`An unknown error occurred during Supabase setup: ${String(e)}`)),z()}}async function De(){return P(`turso`)}async function Oe(){try{let e=await b`turso auth whoami`;return!e.stdout.includes(`You are not logged in`)}catch{return!1}}async function ke(){let e=d();try{return e.start(`Logging in to Turso...`),await b`turso auth login`,e.stop(`Logged in to Turso successfully!`),!0}catch{e.stop(g.red(`Failed to log in to Turso`))}}async function Ae(e){let t=d();try{if(t.start(`Installing Turso CLI...`),e)await b`brew install tursodatabase/tap/turso`;else{let{stdout:e}=await b`curl -sSfL https://get.tur.so/install.sh`;await b`bash -c '${e}'`}return t.stop(`Turso CLI installed successfully!`),!0}catch(e){if(e instanceof Error&&e.message.includes(`User force closed`))throw t.stop(`Turso CLI installation cancelled`),o.warn(g.yellow(`Turso CLI installation cancelled by user`)),Error(`Installation cancelled`);t.stop(g.red(`Failed to install Turso CLI`))}}async function je(){let e=d();try{e.start(`Fetching Turso groups...`);let{stdout:t}=await b`turso group list`,n=t.trim().split(`
146
+ `);if(n.length<=1)return e.stop(`No Turso groups found`),[];let r=n.slice(1).map(e=>{let[t,n,r,i]=e.trim().split(/\s{2,}/);return{name:t,locations:n,version:r,status:i}});return e.stop(`Found ${r.length} Turso groups`),r}catch(t){return e.stop(g.red(`Error fetching Turso groups`)),console.error(`Error fetching Turso groups:`,t),[]}}async function Me(){let e=await je();if(e.length===0)return null;if(e.length===1)return o.info(`Using the only available group: ${g.blue(e[0].name)}`),e[0].name;let n=e.map(e=>({value:e.name,label:`${e.name} (${e.locations})`})),r=await u({message:`Select a Turso database group:`,options:n});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function Ne(e,t){let n=d();try{n.start(`Creating Turso database "${e}"${t?` in group "${t}"`:``}...`),t?await b`turso db create ${e} --group ${t}`:await b`turso db create ${e}`,n.stop(`Created database "${e}"`)}catch(t){if(n.stop(g.red(`Failed to create database "${e}"`)),t instanceof Error&&t.message.includes(`already exists`))throw Error(`DATABASE_EXISTS`)}n.start(`Retrieving database connection details...`);try{let{stdout:t}=await b`turso db show ${e} --url`,{stdout:r}=await b`turso db tokens create ${e}`;return n.stop(`Retrieved database connection details`),{dbUrl:t.trim(),authToken:r.trim()}}catch{n.stop(g.red(`Failed to retrieve database connection details`))}}async function B(t,n){let r=e.join(t,`apps/server`,`.env`),i=n?`DATABASE_URL="${n.dbUrl}"
138
147
  DATABASE_AUTH_TOKEN="${n.authToken}"`:`DATABASE_URL=
139
- DATABASE_AUTH_TOKEN=`;await h.ensureDir(e.dirname(r)),await h.writeFile(r,i)}function B(){o.info(`Manual Turso Setup Instructions:
148
+ DATABASE_AUTH_TOKEN=`;await h.ensureDir(e.dirname(r)),await h.writeFile(r,i)}function V(){o.info(`Manual Turso Setup Instructions:
140
149
 
141
150
  1. Visit https://turso.tech and create an account
142
151
  2. Create a new database from the dashboard
@@ -144,19 +153,19 @@ DATABASE_AUTH_TOKEN=`;await h.ensureDir(e.dirname(r)),await h.writeFile(r,i)}fun
144
153
  4. Add these credentials to the .env file in apps/server/.env
145
154
 
146
155
  DATABASE_URL=your_database_url
147
- DATABASE_AUTH_TOKEN=your_auth_token`)}async function ke(r){let{projectName:i,orm:s,projectDir:c}=r,l=s===`drizzle`,u=d();u.start(`Setting up Turso database`);try{let r=S.platform(),i=r===`darwin`,s=r===`linux`,l=r===`win32`;if(l){u.stop(g.yellow(`Turso setup not supported on Windows`)),o.warn(g.yellow(`Automatic Turso setup is not supported on Windows.`)),await z(c),B();return}u.stop(`Checking Turso CLI`);let p=await Se();if(!p){let e=await n({message:`Would you like to install Turso CLI?`,initialValue:!0});if(a(e)&&(t(g.red(`Operation cancelled`)),process.exit(0)),!e){await z(c),B();return}await Te(i)}let m=await Ce();m||await we();let h=await De(),_=!1,v=``,y=e.basename(c);for(;!_;){let e=await f({message:`Enter a name for your database:`,defaultValue:y,initialValue:y,placeholder:y});a(e)&&(t(g.red(`Operation cancelled`)),process.exit(0)),v=e;try{let e=await Oe(v,h),t=d();t.start(`Writing configuration to .env file`),await z(c,e),t.stop(`Turso database configured successfully!`),_=!0}catch(e){e instanceof Error&&e.message===`DATABASE_EXISTS`&&(o.warn(g.yellow(`Database "${g.red(v)}" already exists`)),y=`${v}-${Math.floor(Math.random()*1e3)}`)}}}catch(e){u.stop(g.red(`Failed to set up Turso database`)),p.error(g.red(`Error during Turso setup: ${e instanceof Error?e.message:String(e)}`)),await z(c),B(),o.success(`Setup completed with manual configuration required.`)}}async function V(e,t,n){let r=d();try{let i=N(e,t);n&&r.start(n);let a=await x(i,{shell:!0});return n&&r.stop(g.green(`Completed`)),a}catch(e){throw r&&r.stop(g.red(`Failed: ${n}`)),e}}async function Ae(e){try{let t=`neonctl projects list`,n=await V(e,t);return!n.stdout.includes(`not authenticated`)&&!n.stdout.includes(`error`)}catch{return!1}}async function je(e){try{return await V(e,`neonctl auth`,`Authenticating with Neon...`),o.success(`Authenticated with Neon successfully!`),!0}catch{m.error(g.red(`Failed to authenticate with Neon`))}}async function Me(e,t){try{let n=`neonctl projects create --name "${e}" --output json`,{stdout:r}=await V(t,n,`Creating Neon project "${e}"...`),i=JSON.parse(r);if(i.project&&i.connection_uris&&i.connection_uris.length>0){let e=i.project.id,t=i.connection_uris[0].connection_uri,n=i.connection_uris[0].connection_parameters;return{connectionString:t,projectId:e,dbName:n.database,roleName:n.role}}return m.error(g.red(`Failed to extract connection information from response`)),null}catch{m.error(g.red(`Failed to create Neon project`))}}async function H(t,n){let r=e.join(t,`apps/server`,`.env`),i=n?`DATABASE_URL="${n.connectionString}"`:`DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;return await h.ensureDir(e.dirname(r)),await h.writeFile(r,i),!0}function Ne(){o.info(`Manual Neon PostgreSQL Setup Instructions:
156
+ DATABASE_AUTH_TOKEN=your_auth_token`)}async function Pe(r){let{projectName:i,orm:s,projectDir:c}=r,l=s===`drizzle`,u=d();u.start(`Setting up Turso database`);try{let r=S.platform(),i=r===`darwin`,s=r===`linux`,l=r===`win32`;if(l){u.stop(g.yellow(`Turso setup not supported on Windows`)),o.warn(g.yellow(`Automatic Turso setup is not supported on Windows.`)),await B(c),V();return}u.stop(`Checking Turso CLI`);let p=await De();if(!p){let e=await n({message:`Would you like to install Turso CLI?`,initialValue:!0});if(a(e)&&(t(g.red(`Operation cancelled`)),process.exit(0)),!e){await B(c),V();return}await Ae(i)}let m=await Oe();m||await ke();let h=await Me(),_=!1,v=``,y=e.basename(c);for(;!_;){let e=await f({message:`Enter a name for your database:`,defaultValue:y,initialValue:y,placeholder:y});a(e)&&(t(g.red(`Operation cancelled`)),process.exit(0)),v=e;try{let e=await Ne(v,h),t=d();t.start(`Writing configuration to .env file`),await B(c,e),t.stop(`Turso database configured successfully!`),_=!0}catch(e){e instanceof Error&&e.message===`DATABASE_EXISTS`&&(o.warn(g.yellow(`Database "${g.red(v)}" already exists`)),y=`${v}-${Math.floor(Math.random()*1e3)}`)}}}catch(e){u.stop(g.red(`Failed to set up Turso database`)),p.error(g.red(`Error during Turso setup: ${e instanceof Error?e.message:String(e)}`)),await B(c),V(),o.success(`Setup completed with manual configuration required.`)}}async function H(e,t,n){let r=d();try{let i=N(e,t);n&&r.start(n);let a=await x(i,{shell:!0});return n&&r.stop(g.green(`Completed`)),a}catch(e){throw r&&r.stop(g.red(`Failed: ${n}`)),e}}async function Fe(e){try{let t=`neonctl projects list`,n=await H(e,t);return!n.stdout.includes(`not authenticated`)&&!n.stdout.includes(`error`)}catch{return!1}}async function Ie(e){try{return await H(e,`neonctl auth`,`Authenticating with Neon...`),o.success(`Authenticated with Neon successfully!`),!0}catch{m.error(g.red(`Failed to authenticate with Neon`))}}async function Le(e,t){try{let n=`neonctl projects create --name "${e}" --output json`,{stdout:r}=await H(t,n,`Creating Neon project "${e}"...`),i=JSON.parse(r);if(i.project&&i.connection_uris&&i.connection_uris.length>0){let e=i.project.id,t=i.connection_uris[0].connection_uri,n=i.connection_uris[0].connection_parameters;return{connectionString:t,projectId:e,dbName:n.database,roleName:n.role}}return m.error(g.red(`Failed to extract connection information from response`)),null}catch{m.error(g.red(`Failed to create Neon project`))}}async function U(t,n){let r=e.join(t,`apps/server`,`.env`),i=n?`DATABASE_URL="${n.connectionString}"`:`DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;return await h.ensureDir(e.dirname(r)),await h.writeFile(r,i),!0}function Re(){o.info(`Manual Neon PostgreSQL Setup Instructions:
148
157
 
149
158
  1. Visit https://neon.tech and create an account
150
159
  2. Create a new project from the dashboard
151
160
  3. Get your connection string
152
161
  4. Add the database URL to the .env file in apps/server/.env
153
162
 
154
- DATABASE_URL="your_connection_string"`)}async function Pe(n){let{projectName:r,packageManager:i,projectDir:s}=n,c=d();c.start(`Setting up Neon PostgreSQL`);try{let n=await Ae(i);c.stop(`Setting up Neon PostgreSQL`),n||(o.info(`Please authenticate with Neon to continue:`),await je(i));let r=e.basename(s),l=await f({message:`Enter a name for your Neon project:`,defaultValue:r,initialValue:r});a(l)&&(t(g.red(`Operation cancelled`)),process.exit(0));let u=await Me(l,i);if(!u)throw Error(`Failed to create project - couldn't get connection information`);let p=d();p.start(`Configuring database connection`),await h.ensureDir(e.join(s,`apps/server`)),await H(s,u),p.stop(`Neon database configured successfully!`)}catch(e){c.stop(g.red(`Neon PostgreSQL setup failed`)),e instanceof Error&&m.error(g.red(e.message)),await H(s),Ne()}}async function Fe(t){let{projectName:n,database:r,orm:i,dbSetup:a,backend:o,projectDir:s}=t;if(o===`convex`||r===`none`){if(o!==`convex`){let t=e.join(s,`apps/server`),n=e.join(t,`src/db`);await h.pathExists(n)&&await h.remove(n)}return}let c=d(),l=e.join(s,`apps/server`);if(await h.pathExists(l))try{i===`prisma`?await M({dependencies:[`@prisma/client`],devDependencies:[`prisma`],projectDir:l}):i===`drizzle`?r===`sqlite`?await M({dependencies:[`drizzle-orm`,`@libsql/client`],devDependencies:[`drizzle-kit`],projectDir:l}):r===`postgres`?await M({dependencies:[`drizzle-orm`,`pg`],devDependencies:[`drizzle-kit`,`@types/pg`],projectDir:l}):r===`mysql`&&await M({dependencies:[`drizzle-orm`,`mysql2`],devDependencies:[`drizzle-kit`],projectDir:l}):i===`mongoose`&&await M({dependencies:[`mongoose`],devDependencies:[],projectDir:l}),r===`sqlite`&&a===`turso`?await ke(t):r===`postgres`?i===`prisma`&&a===`prisma-postgres`?await xe(t):a===`neon`&&await Pe(t):r===`mongodb`&&a===`mongodb-atlas`&&await ve(t)}catch(e){c.stop(g.red(`Failed to set up database`)),e instanceof Error&&p.error(g.red(e.message))}}async function U(t,n){await h.ensureDir(e.dirname(t));let r=``;await h.pathExists(t)&&(r=await h.readFile(t,`utf8`));let i=!1,a=``;for(let{key:e,value:t,condition:o}of n)if(o){let n=RegExp(`^${e}=.*$`,`m`),o=t??``;if(n.test(r)){let t=r.match(n);t&&t[0]!==`${e}=${o}`&&(r=r.replace(n,`${e}=${o}`),i=!0)}else a+=`${e}=${o}\n`,i=!0}a&&(r.length>0&&!r.endsWith(`
163
+ DATABASE_URL="your_connection_string"`)}async function ze(n){let{projectName:r,packageManager:i,projectDir:s}=n,c=d();c.start(`Setting up Neon PostgreSQL`);try{let n=await Fe(i);c.stop(`Setting up Neon PostgreSQL`),n||(o.info(`Please authenticate with Neon to continue:`),await Ie(i));let r=e.basename(s),l=await f({message:`Enter a name for your Neon project:`,defaultValue:r,initialValue:r});a(l)&&(t(g.red(`Operation cancelled`)),process.exit(0));let u=await Le(l,i);if(!u)throw Error(`Failed to create project - couldn't get connection information`);let p=d();p.start(`Configuring database connection`),await h.ensureDir(e.join(s,`apps/server`)),await U(s,u),p.stop(`Neon database configured successfully!`)}catch(e){c.stop(g.red(`Neon PostgreSQL setup failed`)),e instanceof Error&&m.error(g.red(e.message)),await U(s),Re()}}async function Be(t){let{database:n,orm:r,dbSetup:i,backend:a,projectDir:o}=t;if(a===`convex`||n===`none`){if(a!==`convex`){let t=e.join(o,`apps/server`),n=e.join(t,`src/db`);await h.pathExists(n)&&await h.remove(n)}return}let s=d(),c=e.join(o,`apps/server`);if(await h.pathExists(c))try{r===`prisma`?await M({dependencies:[`@prisma/client`],devDependencies:[`prisma`],projectDir:c}):r===`drizzle`?n===`sqlite`?await M({dependencies:[`drizzle-orm`,`@libsql/client`],devDependencies:[`drizzle-kit`],projectDir:c}):n===`postgres`?await M({dependencies:[`drizzle-orm`,`pg`],devDependencies:[`drizzle-kit`,`@types/pg`],projectDir:c}):n===`mysql`&&await M({dependencies:[`drizzle-orm`,`mysql2`],devDependencies:[`drizzle-kit`],projectDir:c}):r===`mongoose`&&await M({dependencies:[`mongoose`],devDependencies:[],projectDir:c}),n===`sqlite`&&i===`turso`?await Pe(t):n===`postgres`?r===`prisma`&&i===`prisma-postgres`?await xe(t):i===`neon`?await ze(t):i===`supabase`&&await Ee(t):n===`mongodb`&&i===`mongodb-atlas`&&await ve(t)}catch(e){s.stop(g.red(`Failed to set up database`)),e instanceof Error&&p.error(g.red(e.message))}}async function W(t,n){await h.ensureDir(e.dirname(t));let r=``;await h.pathExists(t)&&(r=await h.readFile(t,`utf8`));let i=!1,a=``;for(let{key:e,value:t,condition:o}of n)if(o){let n=RegExp(`^${e}=.*$`,`m`),o=t??``;if(n.test(r)){let t=r.match(n);t&&t[0]!==`${e}=${o}`&&(r=r.replace(n,`${e}=${o}`),i=!0)}else a+=`${e}=${o}\n`,i=!0}a&&(r.length>0&&!r.endsWith(`
155
164
  `)&&(r+=`
156
- `),r+=a),i&&await h.writeFile(t,r.trimEnd())}async function Ie(t){let{projectName:n,backend:r,frontend:i,database:a,orm:o,auth:s,examples:c,dbSetup:l,projectDir:u}=t,d=i.includes(`react-router`),f=i.includes(`tanstack-router`),p=i.includes(`tanstack-start`),m=i.includes(`next`),g=i.includes(`nuxt`),_=i.includes(`svelte`),v=i.includes(`solid`),y=d||f||p||m||g||v||_;if(y){let t=e.join(u,`apps/web`);if(await h.pathExists(t)){let n=`VITE_SERVER_URL`,i=`http://localhost:3000`;m?n=`NEXT_PUBLIC_SERVER_URL`:g?n=`NUXT_PUBLIC_SERVER_URL`:_&&(n=`PUBLIC_SERVER_URL`),r===`convex`&&(n=m?`NEXT_PUBLIC_CONVEX_URL`:g?`NUXT_PUBLIC_CONVEX_URL`:_?`PUBLIC_CONVEX_URL`:`VITE_CONVEX_URL`,i=`https://<YOUR_CONVEX_URL>`);let a=[{key:n,value:i,condition:!0}];await U(e.join(t,`.env`),a)}}if(i.includes(`native-nativewind`)||i.includes(`native-unistyles`)){let t=e.join(u,`apps/native`);if(await h.pathExists(t)){let n=`EXPO_PUBLIC_SERVER_URL`,i=`http://localhost:3000`;r===`convex`&&(n=`EXPO_PUBLIC_CONVEX_URL`,i=`https://<YOUR_CONVEX_URL>`);let a=[{key:n,value:i,condition:!0}];await U(e.join(t,`.env`),a)}}if(r===`convex`)return;let b=e.join(u,`apps/server`);if(!await h.pathExists(b))return;let x=e.join(b,`.env`),S=`http://localhost:3001`;(d||_)&&(S=`http://localhost:5173`);let C=null,w=l===`turso`||l===`prisma-postgres`||l===`mongodb-atlas`||l===`neon`;if(a!==`none`&&!w)switch(a){case`postgres`:C=`postgresql://postgres:postgres@localhost:5432/mydb?schema=public`;break;case`mysql`:C=`mysql://root:password@localhost:3306/mydb`;break;case`mongodb`:C=`mongodb://localhost:27017/mydatabase`;break;case`sqlite`:C=`file:./local.db`;break}let T=[{key:`CORS_ORIGIN`,value:S,condition:!0},{key:`BETTER_AUTH_SECRET`,value:le(),condition:!!s},{key:`BETTER_AUTH_URL`,value:`http://localhost:3000`,condition:!!s},{key:`DATABASE_URL`,value:C,condition:a!==`none`&&!w},{key:`GOOGLE_GENERATIVE_AI_API_KEY`,value:``,condition:c?.includes(`ai`)||!1}];await U(x,T)}async function Le(t){let{projectName:n,examples:r,frontend:i,backend:a,projectDir:o}=t;if(!(a===`convex`||!r||r.length===0||r[0]===`none`)&&r.includes(`ai`)){let t=e.join(o,`apps/web`),n=e.join(o,`apps/server`),r=await h.pathExists(t),s=await h.pathExists(n),c=i.includes(`nuxt`),l=i.includes(`svelte`);if(r){let e=[`ai`];c?e.push(`@ai-sdk/vue`):l&&e.push(`@ai-sdk/svelte`),await M({dependencies:e,projectDir:t})}s&&a!==`none`&&await M({dependencies:[`ai`,`@ai-sdk/google`],projectDir:n})}}async function Re({projectDir:e,packageManager:t,addons:n=[]}){let r=d();try{r.start(`Running ${t} install...`),await b({cwd:e,stderr:`inherit`})`${t} install`,r.stop(`Dependencies installed successfully`),(n.includes(`biome`)||n.includes(`husky`))&&await ze(e,t)}catch(e){r.stop(g.red(`Failed to install dependencies`)),e instanceof Error&&p.error(g.red(`Installation error: ${e.message}`))}}async function ze(e,t){let n=d();try{n.start(`Running Biome format check...`),await b({cwd:e,stderr:`inherit`})`${t} biome check --write .`,n.stop(`Biome check completed successfully`)}catch{n.stop(g.yellow(`Biome check encountered issues`)),o.warn(g.yellow(`Some files may need manual formatting`))}}function Be(e){let{database:t,projectName:n,relativePath:r,packageManager:i,depsInstalled:a,orm:o,addons:s,runtime:c,frontend:l,backend:u}=e,d=u===`convex`,f=i===`npm`?`npm run`:i,p=`cd ${r}`,h=s?.includes(`husky`)||s?.includes(`biome`),_=!d&&t!==`none`?Ue(t,o,f,c):``,v=s?.includes(`tauri`)?We(f):``,y=h?He(f):``,b=l?.includes(`native-nativewind`)||l?.includes(`native-unistyles`)?Ve(d):``,x=s?.includes(`pwa`)&&(l?.includes(`react-router`)||l?.includes(`tanstack-router`))?Ge():``,S=s?.includes(`starlight`)?Ke(f):``,C=l?.some(e=>[`tanstack-router`,`react-router`,`next`,`tanstack-start`,`nuxt`,`svelte`,`solid`].includes(e)),w=l?.includes(`native-nativewind`)||l?.includes(`native-unistyles`),T=i===`bun`&&w&&C?Je():``,E=!d&&t!==`none`&&o===`none`?qe():``,D=l?.includes(`react-router`),O=l?.includes(`svelte`),k=D||O?`5173`:`3001`,A=N(i,`taze -r`),j=`${g.bold(`Next steps`)}\n${g.cyan(`1.`)} ${p}\n`,M=2;a||(j+=`${g.cyan(`${M++}.`)} ${i} install\n`),d&&(j+=`${g.cyan(`${M++}.`)} ${f} dev:setup ${g.dim(`(this will guide you through Convex project setup)`)}\n`),j+=`${g.cyan(`${M++}.`)} ${f} dev\n\n`,j+=`${g.bold(`Your project will be available at:`)}\n`,C?j+=`${g.cyan(`•`)} Frontend: http://localhost:${k}\n`:!w&&!s?.includes(`starlight`)&&(j+=`${g.yellow(`NOTE:`)} You are creating a backend-only app (no frontend selected)\n`),d||(j+=`${g.cyan(`•`)} Backend API: http://localhost:3000\n`),s?.includes(`starlight`)&&(j+=`${g.cyan(`•`)} Docs: http://localhost:4321\n`),b&&(j+=`\n${b.trim()}\n`),_&&(j+=`\n${_.trim()}\n`),v&&(j+=`\n${v.trim()}\n`),y&&(j+=`\n${y.trim()}\n`),x&&(j+=`\n${x.trim()}\n`),S&&(j+=`\n${S.trim()}\n`),E&&(j+=`\n${E.trim()}\n`),T&&(j+=`\n${T.trim()}\n`),j+=`\n${g.bold(`Update all dependencies:
157
- `)}${g.cyan(A)}\n\n`,j+=`${g.bold(`Like Better-T Stack?`)} Please consider giving us a star on GitHub:\n`,j+=g.cyan(`https://github.com/AmanVarshney01/create-better-t-stack`),m.box(j)}function Ve(e){let t=e?`EXPO_PUBLIC_CONVEX_URL`:`EXPO_PUBLIC_SERVER_URL`,n=e?`https://<YOUR_CONVEX_URL>`:`http://<YOUR_LOCAL_IP>:3000`,r=`.env`,i=e?`your Convex deployment URL (find after running 'dev:setup')`:`your local IP address`;return`${g.yellow(`NOTE:`)} For Expo connectivity issues, update apps/native/${r} \nwith ${i}:\n${`${t}=${n}`}\n`}function He(e){return`${g.bold(`Linting and formatting:`)}\n${g.cyan(`•`)} Format and lint fix: ${`${e} check`}\n`}function Ue(e,t,n,r){let i=[];return t===`prisma`?(e===`sqlite`&&i.push(`${g.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`&&i.push(`${g.yellow(`NOTE:`)} Prisma with Bun may require additional configuration. If you encounter errors,\nfollow the guidance provided in the error messages`),i.push(`${g.cyan(`•`)} Apply schema: ${`${n} db:push`}`),i.push(`${g.cyan(`•`)} Database UI: ${`${n} db:studio`}`)):t===`drizzle`?(i.push(`${g.cyan(`•`)} Apply schema: ${`${n} db:push`}`),i.push(`${g.cyan(`•`)} Database UI: ${`${n} db:studio`}`),e===`sqlite`&&i.push(`${g.cyan(`•`)} Start local DB (if needed): ${`cd apps/server && ${n} db:local`}`)):t===`none`&&i.push(`${g.yellow(`NOTE:`)} Manual database schema setup required.`),i.length?`${g.bold(`Database commands:`)}\n${i.join(`
158
- `)}`:``}function We(e){return`\n${g.bold(`Desktop app with Tauri:`)}\n${g.cyan(`•`)} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}\n${g.cyan(`•`)} Build desktop app: ${`cd apps/web && ${e} desktop:build`}\n${g.yellow(`NOTE:`)} Tauri requires Rust and platform-specific dependencies.\nSee: https://v2.tauri.app/start/prerequisites/`}function Ge(){return`\n${g.bold(`PWA with React Router v7:`)}\n${g.yellow(`NOTE:`)} There is a known compatibility issue between VitePWA and React Router v7.\nSee: https://github.com/vite-pwa/vite-plugin-pwa/issues/809`}function Ke(e){return`\n${g.bold(`Documentation with Starlight:`)}\n${g.cyan(`•`)} Start docs site: ${`cd apps/docs && ${e} dev`}\n${g.cyan(`•`)} Build docs site: ${`cd apps/docs && ${e} build`}`}function qe(){return`\n${g.yellow(`WARNING:`)} Database selected without an ORM. Features requiring database access (e.g., examples, auth) need manual setup.`}function Je(){return`\n${g.yellow(`WARNING:`)} 'bun' might cause issues with web + native apps in a monorepo. Use 'pnpm' if problems arise.`}async function Ye(e,t){await Xe(e,t),t.backend===`convex`?await Qe(e,t):await Ze(e,t)}async function Xe(t,n){let r=e.join(t,`package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.name=n.projectName,i.scripts||={};let a=i.scripts,s=n.backend===`convex`?`@${n.projectName}/backend`:`server`,c=``;n.addons.includes(`turborepo`)?c=`turbo -F ${s} dev`:n.packageManager===`bun`?c=`bun run --filter ${s} dev`:n.packageManager===`pnpm`?c=`pnpm --filter ${s} dev`:n.packageManager===`npm`&&(c=`npm run dev --workspace ${s}`);let l=``;n.packageManager===`pnpm`?l=`pnpm -r dev`:n.packageManager===`npm`?l=`npm run dev --workspaces`:n.packageManager===`bun`&&(l=`bun run --filter '*' dev`);let u=n.backend!==`convex`&&n.database!==`none`&&n.orm!==`none`&&n.orm!==`mongoose`;n.addons.includes(`turborepo`)?(a.dev=`turbo dev`,a.build=`turbo build`,a[`check-types`]=`turbo check-types`,a[`dev:native`]=`turbo -F native dev`,a[`dev:web`]=`turbo -F web dev`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`turbo -F ${s} setup`),u&&(a[`db:push`]=`turbo -F ${s} db:push`,a[`db:studio`]=`turbo -F ${s} db:studio`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`turbo -F ${s} db:generate`,a[`db:migrate`]=`turbo -F ${s} db:migrate`))):n.packageManager===`pnpm`?(a.dev=l,a.build=`pnpm -r build`,a[`check-types`]=`pnpm -r check-types`,a[`dev:native`]=`pnpm --filter native dev`,a[`dev:web`]=`pnpm --filter web dev`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`pnpm --filter ${s} setup`),u&&(a[`db:push`]=`pnpm --filter ${s} db:push`,a[`db:studio`]=`pnpm --filter ${s} db:studio`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`pnpm --filter ${s} db:generate`,a[`db:migrate`]=`pnpm --filter ${s} db:migrate`))):n.packageManager===`npm`?(a.dev=l,a.build=`npm run build --workspaces`,a[`check-types`]=`npm run check-types --workspaces`,a[`dev:native`]=`npm run dev --workspace native`,a[`dev:web`]=`npm run dev --workspace web`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`npm run setup --workspace ${s}`),u&&(a[`db:push`]=`npm run db:push --workspace ${s}`,a[`db:studio`]=`npm run db:studio --workspace ${s}`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`npm run db:generate --workspace ${s}`,a[`db:migrate`]=`npm run db:migrate --workspace ${s}`))):n.packageManager===`bun`&&(a.dev=l,a.build=`bun run --filter '*' build`,a[`check-types`]=`bun run --filter '*' check-types`,a[`dev:native`]=`bun run --filter native dev`,a[`dev:web`]=`bun run --filter web dev`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`bun run --filter ${s} setup`),u&&(a[`db:push`]=`bun run --filter ${s} db:push`,a[`db:studio`]=`bun run --filter ${s} db:studio`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`bun run --filter ${s} db:generate`,a[`db:migrate`]=`bun run --filter ${s} db:migrate`))),n.addons.includes(`biome`)&&(a.check=`biome check --write .`),n.addons.includes(`husky`)&&(a.prepare=`husky`,i[`lint-staged`]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":[`biome check --write .`]});try{let{stdout:e}=await x(n.packageManager,[`-v`],{cwd:t});i.packageManager=`${n.packageManager}@${e.trim()}`}catch{o.warn(`Could not determine ${n.packageManager} version.`)}i.workspaces||=[];let d=i.workspaces;if(n.backend===`convex`){d.includes(`packages/*`)||d.push(`packages/*`);let e=n.frontend.length>0||n.addons.includes(`starlight`);e&&!d.includes(`apps/*`)&&d.push(`apps/*`)}else d.includes(`apps/*`)||d.push(`apps/*`),d.includes(`packages/*`)||d.push(`packages/*`);await h.writeJson(r,i,{spaces:2})}async function Ze(t,n){let r=e.join(t,`apps/server/package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.scripts||={};let a=i.scripts;n.database!==`none`&&(n.database===`sqlite`&&n.orm===`drizzle`&&(a[`db:local`]=`turso dev --db-file local.db`),n.orm===`prisma`?(a[`db:push`]=`prisma db push --schema ./prisma/schema`,a[`db:studio`]=`prisma studio`,a[`db:generate`]=`prisma generate --schema ./prisma/schema`,a[`db:migrate`]=`prisma migrate dev`):n.orm===`drizzle`&&(a[`db:push`]=`drizzle-kit push`,a[`db:studio`]=`drizzle-kit studio`,a[`db:generate`]=`drizzle-kit generate`,a[`db:migrate`]=`drizzle-kit migrate`)),await h.writeJson(r,i,{spaces:2})}async function Qe(t,n){let r=e.join(t,`packages/backend/package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.name=`@${n.projectName}/backend`,i.scripts||={},await h.writeJson(r,i,{spaces:2})}async function $e(e,t){if(!t)return;let n=await b({cwd:e,reject:!1,stderr:`pipe`})`git --version`;if(n.exitCode!==0){o.warn(g.yellow(`Git is not installed`));return}let r=await b({cwd:e,reject:!1,stderr:`pipe`})`git init`;if(r.exitCode!==0)throw Error(`Git initialization failed: ${r.stderr}`)}async function et(t){let{projectName:n,runtime:r,backend:i,projectDir:a}=t;if(i===`convex`||i===`next`||r===`none`)return;let o=e.join(a,`apps/server`);await h.pathExists(o)&&(r===`bun`?await tt(o,i):r===`node`&&await nt(o,i))}async function tt(t,n){let r=e.join(t,`package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.scripts={...i.scripts,dev:`bun run --hot src/index.ts`,start:`bun run dist/src/index.js`},await h.writeJson(r,i,{spaces:2}),await M({devDependencies:[`@types/bun`],projectDir:t})}async function nt(t,n){let r=e.join(t,`package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.scripts={...i.scripts,dev:`tsx watch src/index.ts`,start:`node dist/src/index.js`},await h.writeJson(r,i,{spaces:2}),await M({devDependencies:[`tsx`,`@types/node`],projectDir:t}),n===`hono`?await M({dependencies:[`@hono/node-server`],projectDir:t}):n===`elysia`&&await M({dependencies:[`@elysiajs/node`],projectDir:t})}async function W(t,n,r){try{let i=await h.readFile(t,`utf-8`),a=w.compile(i),o=a(r);await h.ensureDir(e.dirname(n)),await h.writeFile(n,o)}catch(e){throw p.error(`Error processing template ${t}:`,e),Error(`Failed to process template ${t}`)}}w.registerHelper(`or`,(e,t)=>e||t),w.registerHelper(`eq`,(e,t)=>e===t),w.registerHelper(`includes`,(e,t)=>Array.isArray(e)&&e.includes(t));async function G(t,n,r,i,a=!0){let o=await C(t,{cwd:n,dot:!0,onlyFiles:!0,absolute:!1});for(let t of o){let o=e.join(n,t),s=t;t.endsWith(`.hbs`)&&(s=t.slice(0,-4));let c=e.basename(t);c===`_gitignore`?s=e.join(e.dirname(t),`.gitignore`):c===`_npmrc`&&(s=e.join(e.dirname(t),`.npmrc`));let l=e.join(r,s);try{if(await h.ensureDir(e.dirname(l)),!a&&await h.pathExists(l))continue;o.endsWith(`.hbs`)?await W(o,l,i):await h.copy(o,l,{overwrite:!0})}catch{}}}async function rt(t,n){let r=e.join(k,`templates/base`);await G([`**/*`],r,t,n),await h.ensureDir(e.join(t,`packages`))}async function it(t,n){let r=n.frontend.some(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e)),i=n.frontend.includes(`nuxt`),a=n.frontend.includes(`svelte`),o=n.frontend.includes(`solid`),s=n.frontend.includes(`native-nativewind`),c=n.frontend.includes(`native-unistyles`),l=s||c,u=n.backend===`convex`;if(r||i||a||o){let s=e.join(t,`apps/web`);if(await h.ensureDir(s),r){let t=e.join(k,`templates/frontend/react/web-base`);await h.pathExists(t)&&await G(`**/*`,t,s,n);let r=n.frontend.find(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e));if(r){let t=e.join(k,`templates/frontend/react/${r}`);if(await h.pathExists(t)&&await G(`**/*`,t,s,n),!u&&n.api!==`none`){let t=e.join(k,`templates/api/${n.api}/web/react/base`);await h.pathExists(t)&&await G(`**/*`,t,s,n)}}}else if(i){let t=e.join(k,`templates/frontend/nuxt`);if(await h.pathExists(t)&&await G(`**/*`,t,s,n),!u&&n.api===`orpc`){let t=e.join(k,`templates/api/${n.api}/web/nuxt`);await h.pathExists(t)&&await G(`**/*`,t,s,n)}}else if(a){let t=e.join(k,`templates/frontend/svelte`);if(await h.pathExists(t)&&await G(`**/*`,t,s,n),!u&&n.api===`orpc`){let t=e.join(k,`templates/api/${n.api}/web/svelte`);await h.pathExists(t)&&await G(`**/*`,t,s,n)}}else if(o){let t=e.join(k,`templates/frontend/solid`);if(await h.pathExists(t)&&await G(`**/*`,t,s,n),!u&&n.api===`orpc`){let t=e.join(k,`templates/api/${n.api}/web/solid`);await h.pathExists(t)&&await G(`**/*`,t,s,n)}}}if(s||c){let r=e.join(t,`apps/native`);await h.ensureDir(r);let i=e.join(k,`templates/frontend/native/native-base`);await h.pathExists(i)&&await G(`**/*`,i,r,n);let a=``;s?a=`nativewind`:c&&(a=`unistyles`);let o=e.join(k,`templates/frontend/native/${a}`);if(await h.pathExists(o)&&await G(`**/*`,o,r,n,!0),!u&&(n.api===`trpc`||n.api===`orpc`)){let t=e.join(k,`templates/api/${n.api}/native`);await h.pathExists(t)&&await G(`**/*`,t,r,n)}}}async function at(t,n){if(n.backend===`none`)return;let r=e.join(t,`apps/server`);if(n.backend===`convex`){await h.pathExists(r)&&await h.remove(r);let i=e.join(t,`packages/backend`),a=e.join(k,`templates/backend/convex/packages/backend`);await h.ensureDir(i),await h.pathExists(a)&&await G(`**/*`,a,i,n);return}await h.ensureDir(r);let i=e.join(k,`templates/backend/server/server-base`);await h.pathExists(i)&&await G(`**/*`,i,r,n);let a=e.join(k,`templates/backend/server/${n.backend}`);if(await h.pathExists(a)&&await G(`**/*`,a,r,n,!0),n.api!==`none`){let t=e.join(k,`templates/api/${n.api}/server/base`);await h.pathExists(t)&&await G(`**/*`,t,r,n,!0);let i=e.join(k,`templates/api/${n.api}/server/${n.backend}`);await h.pathExists(i)&&await G(`**/*`,i,r,n,!0)}}async function ot(t,n){if(n.backend===`convex`||n.orm===`none`||n.database===`none`)return;let r=e.join(t,`apps/server`);await h.ensureDir(r);let i=e.join(k,`templates/db/${n.orm}/${n.database}`);await h.pathExists(i)&&await G(`**/*`,i,r,n)}async function st(t,n){if(n.backend===`convex`||!n.auth)return;let r=e.join(t,`apps/server`),i=e.join(t,`apps/web`),a=e.join(t,`apps/native`),o=await h.pathExists(r),s=await h.pathExists(i),c=await h.pathExists(a),l=n.frontend.some(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e)),u=n.frontend.includes(`nuxt`),d=n.frontend.includes(`svelte`),f=n.frontend.includes(`solid`),p=n.frontend.includes(`native-nativewind`),m=n.frontend.includes(`native-unistyles`),g=p||m;if(o){let t=e.join(k,`templates/auth/server/base`);if(await h.pathExists(t)&&await G(`**/*`,t,r,n),n.backend===`next`){let t=e.join(k,`templates/auth/server/next`);await h.pathExists(t)&&await G(`**/*`,t,r,n)}if(n.orm!==`none`&&n.database!==`none`){let t=n.orm,i=n.database,a=``;t===`drizzle`?a=e.join(k,`templates/auth/server/db/drizzle/${i}`):t===`prisma`?a=e.join(k,`templates/auth/server/db/prisma/${i}`):t===`mongoose`&&(a=e.join(k,`templates/auth/server/db/mongoose/${i}`)),a&&await h.pathExists(a)&&await G(`**/*`,a,r,n)}}if((l||u||d||f)&&s){if(l){let t=e.join(k,`templates/auth/web/react/base`);await h.pathExists(t)&&await G(`**/*`,t,i,n);let r=n.frontend.find(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e));if(r){let t=e.join(k,`templates/auth/web/react/${r}`);await h.pathExists(t)&&await G(`**/*`,t,i,n)}}else if(u){let t=e.join(k,`templates/auth/web/nuxt`);await h.pathExists(t)&&await G(`**/*`,t,i,n)}else if(d){if(n.api===`orpc`){let t=e.join(k,`templates/auth/web/svelte`);await h.pathExists(t)&&await G(`**/*`,t,i,n)}}else if(f&&n.api===`orpc`){let t=e.join(k,`templates/auth/web/solid`);await h.pathExists(t)&&await G(`**/*`,t,i,n)}}if(g&&c){let t=e.join(k,`templates/auth/native/native-base`);await h.pathExists(t)&&await G(`**/*`,t,a,n);let r=``;if(p?r=`nativewind`:m&&(r=`unistyles`),r){let t=e.join(k,`templates/auth/native/${r}`);await h.pathExists(t)&&await G(`**/*`,t,a,n)}}}async function ct(t,n){if(!(!n.addons||n.addons.length===0))for(let r of n.addons){if(r===`none`)continue;let i=e.join(k,`templates/addons/${r}`),a=t;if(r===`pwa`&&(i=e.join(k,`templates/addons/pwa/apps/web`),a=e.join(t,`apps/web`),!await h.pathExists(a)))continue;await h.pathExists(i)&&await G(`**/*`,i,a,n)}}async function lt(t,n){if(!n.examples||n.examples.length===0||n.examples[0]===`none`)return;let r=e.join(t,`apps/server`),i=e.join(t,`apps/web`),a=await h.pathExists(r),o=await h.pathExists(i),s=n.frontend.some(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e)),c=n.frontend.includes(`nuxt`),l=n.frontend.includes(`svelte`),u=n.frontend.includes(`solid`);for(let t of n.examples){if(t===`none`)continue;let d=e.join(k,`templates/examples/${t}`);if(a&&n.backend!==`convex`&&n.backend!==`none`){let i=e.join(d,`server`);if(t===`ai`&&n.backend===`next`){let t=e.join(i,`next`);await h.pathExists(t)&&await G(`**/*`,t,r,n,!1)}if(n.orm!==`none`&&n.database!==`none`){let t=e.join(i,n.orm,`base`);await h.pathExists(t)&&await G(`**/*`,t,r,n,!1);let a=e.join(i,n.orm,n.database);await h.pathExists(a)&&await G(`**/*`,a,r,n,!1)}let a=[`${n.orm}/**`];t===`ai`&&n.backend===`next`&&a.push(`next/**`);let o=await C([`**/*.ts`,`**/*.hbs`],{cwd:i,onlyFiles:!0,deep:1,ignore:a});for(let t of o){let a=e.join(i,t),o=e.join(r,t.replace(`.hbs`,``));try{a.endsWith(`.hbs`)?await W(a,o,n):await h.pathExists(o)||await h.copy(a,o,{overwrite:!1})}catch{}}}if(o){if(s){let t=e.join(d,`web/react`);if(await h.pathExists(t)){let r=n.frontend.find(e=>[`next`,`react-router`,`tanstack-router`,`tanstack-start`].includes(e));if(r){let a=e.join(t,r);await h.pathExists(a)&&await G(`**/*`,a,i,n,!1)}}}else if(c){let t=e.join(d,`web/nuxt`);await h.pathExists(t)&&await G(`**/*`,t,i,n,!1)}else if(l){let t=e.join(d,`web/svelte`);await h.pathExists(t)&&await G(`**/*`,t,i,n,!1)}else if(u){let t=e.join(d,`web/solid`);await h.pathExists(t)&&await G(`**/*`,t,i,n,!1)}}}}async function ut(t,n){let r=e.join(k,`templates/extras`),i=n.frontend.includes(`native-nativewind`),a=n.frontend.includes(`native-unistyles`),o=i||a;if(n.packageManager===`pnpm`){let n=e.join(r,`pnpm-workspace.yaml`),i=e.join(t,`pnpm-workspace.yaml`);await h.pathExists(n)&&await h.copy(n,i)}if(n.packageManager===`pnpm`&&(o||n.frontend.includes(`nuxt`))){let i=e.join(r,`_npmrc.hbs`),a=e.join(t,`.npmrc`);await h.pathExists(i)&&await W(i,a,n)}}async function dt(e){let n=e.projectDir,r=e.backend===`convex`;try{return await h.ensureDir(n),await rt(n,e),await it(n,e),await at(n,e),r||(await ot(n,e),await st(n,e)),e.examples.length>0&&e.examples[0]!==`none`&&await lt(n,e),await ct(n,e),await se(e),r||(await ue(e),await Fe(e),await et(e),e.examples.length>0&&e.examples[0]!==`none`&&await Le(e)),e.addons.length>0&&e.addons[0]!==`none`&&await ne(e),!r&&e.auth&&await ce(e),await ut(n,e),await Ie(e),await Ye(n,e),await de(n,e),await $e(n,e.git),o.success(`Project template successfully scaffolded!`),e.install&&await Re({projectDir:n,packageManager:e.packageManager,addons:e.addons}),Be({...e,depsInstalled:e.install}),n}catch(e){e instanceof Error?(t(g.red(`Error during project creation: ${e.message}`)),console.error(e.stack),process.exit(1)):(t(g.red(`An unexpected error occurred: ${String(e)}`)),console.error(e),process.exit(1))}}async function ft(e,n){if(e!==void 0)return e;let r=n?.includes(`react-router`)||n?.includes(`tanstack-router`)||n?.includes(`solid`),i=n?.includes(`react-router`)||n?.includes(`tanstack-router`)||n?.includes(`nuxt`)||n?.includes(`svelte`)||n?.includes(`solid`)||n?.includes(`next`),o=[{value:`turborepo`,label:`Turborepo (Recommended)`,hint:`Optimize builds for monorepos`},{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)`},{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`}],c=o.filter(e=>e.value===`pwa`?r:e.value===`tauri`?i:!0),l=A.addons.filter(e=>c.some(t=>t.value===e)),u=await s({message:`Select addons`,options:c,initialValues:l,required:!1});return a(u)&&(t(g.red(`Operation cancelled`)),process.exit(0)),u.includes(`husky`)&&!u.includes(`biome`)&&u.push(`biome`),u}async function pt(e,n,r){if(r===`convex`||r===`none`)return`none`;if(e)return e;let i=n?.includes(`nuxt`),o=n?.includes(`svelte`),s=n?.includes(`solid`),c=[{value:`trpc`,label:`tRPC`,hint:`End-to-end typesafe APIs made easy`},{value:`orpc`,label:`oRPC`,hint:`End-to-end type-safe APIs that adhere to OpenAPI standards`},{value:`none`,label:`None`,hint:`No API layer (e.g. for full-stack frameworks like Next.js with Route Handlers)`}];(i||o||s)&&(c=[{value:`orpc`,label:`oRPC`,hint:`End-to-end type-safe APIs (Recommended for ${i?`Nuxt`:o?`Svelte`:`Solid`} frontend)`},{value:`none`,label:`None`,hint:`No API layer`}]);let l=await u({message:`Select API type`,options:c,initialValue:c[0].value});return a(l)&&(t(g.red(`Operation cancelled`)),process.exit(0)),l}async function mt(e,r,i){if(i===`convex`||!r)return!1;if(e!==void 0)return e;let o=await n({message:`Add authentication with Better-Auth?`,initialValue:A.auth});return a(o)&&(t(g.red(`Operation cancelled`)),process.exit(0)),o}async function ht(e,n){if(e!==void 0)return e;let r=n?.some(e=>e===`nuxt`||e===`solid`),i=[{value:`hono`,label:`Hono`,hint:`Lightweight, ultrafast web framework`},{value:`next`,label:`Next.js`,hint:`Full-stack framework with API routes`},{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`}];r||i.push({value:`convex`,label:`Convex`,hint:`Reactive backend-as-a-service platform`}),i.push({value:`none`,label:`None`,hint:`No backend server (e.g., for a static site or client-only app)`});let o=A.backend;r&&o===`convex`&&(o=`hono`);let s=await u({message:`Select backend framework`,options:i,initialValue:o});return a(s)&&(t(g.red(`Operation cancelled`)),process.exit(0)),s}async function gt(e,n){if(n===`convex`||n===`none`)return`none`;if(e!==void 0)return e;let r=await u({message:`Select database`,options:[{value:`none`,label:`None`,hint:`No database setup`},{value:`sqlite`,label:`SQLite`,hint:`lightweight, server-less, embedded relational database`},{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:A.database});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function _t(e,n,r,i){if(i===`convex`)return`none`;if(n!==void 0)return n;if(e===`none`||e===`sqlite`&&r===`prisma`)return`none`;let o=[];if(e===`sqlite`)o=[{value:`turso`,label:`Turso`,hint:`SQLite for Production. Powered by libSQL`},{value:`none`,label:`None`,hint:`Manual setup`}];else if(e===`postgres`)o=[{value:`neon`,label:`Neon Postgres`,hint:`Serverless Postgres with branching capability`},...r===`prisma`?[{value:`prisma-postgres`,label:`Prisma Postgres`,hint:`Instant Postgres for Global Applications`}]:[],{value:`none`,label:`None`,hint:`Manual setup`}];else if(e===`mongodb`)o=[{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 s=await u({message:`Select ${e} setup option`,options:o,initialValue:`none`});return a(s)&&(t(g.red(`Operation cancelled`)),process.exit(0)),s}async function vt(e,n,r,i,o){if(o===`none`)return[];if(e!==void 0)return e;if(i===`convex`)return[`todo`];if(i===`none`||n===`none`)return[];let c=r&&r.length===1&&(r[0]===`native-nativewind`||r[0]===`native-unistyles`);if(c)return[];let l=r?.some(e=>[`react-router`,`tanstack-router`,`tanstack-start`,`next`,`nuxt`,`svelte`,`solid`].includes(e))??!1,u=!r||r.length===0;if(!l&&!u)return[];let d=[],f=[{value:`todo`,label:`Todo App`,hint:`A simple CRUD example app`}];return i!==`elysia`&&!r?.includes(`solid`)&&f.push({value:`ai`,label:`AI Chat`,hint:`A simple AI chat interface using AI SDK`}),d=await s({message:`Include examples`,options:f,required:!1,initialValues:A.examples}),a(d)&&(t(g.red(`Operation cancelled`)),process.exit(0)),d}async function yt(e,n){if(e!==void 0)return e;let r=await s({message:`Select platforms to develop for`,options:[{value:`web`,label:`Web`,hint:`React, Vue or Svelte Web Application`},{value:`native`,label:`Native`,hint:`Create a React Native/Expo app`}],required:!1,initialValues:[`web`]});a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0));let i=[];if(r.includes(`web`)){let e=[{value:`tanstack-router`,label:`TanStack Router`,hint:`Modern and scalable routing for React Applications`},{value:`react-router`,label:`React Router`,hint:`A user‑obsessed, standards‑focused, multi‑strategy router`},{value:`next`,label:`Next.js`,hint:`The React Framework for the Web`},{value:`nuxt`,label:`Nuxt`,hint:`The Progressive Web Framework for Vue.js`},{value:`svelte`,label:`Svelte`,hint:`web development for the rest of us`},{value:`solid`,label:`Solid`,hint:`Simple and performant reactivity for building user interfaces`},{value:`tanstack-start`,label:`TanStack Start (beta)`,hint:`SSR, Server Functions, API Routes and more with TanStack Router`}],r=e.filter(e=>n===`convex`?e.value!==`nuxt`&&e.value!==`solid`:!0),o=await u({message:`Choose frontend framework`,options:r,initialValue:A.frontend[0]});a(o)&&(t(g.red(`Operation cancelled`)),process.exit(0)),i.push(o)}if(r.includes(`native`)){let e=await u({message:`Choose native framework`,options:[{value:`native-nativewind`,label:`NativeWind`,hint:`Use Tailwind CSS for React Native`},{value:`native-unistyles`,label:`Unistyles`,hint:`Consistent styling for React Native`}],initialValue:`native-nativewind`});a(e)&&(t(g.red(`Operation cancelled`)),process.exit(0)),i.push(e)}return i}async function bt(e){if(e!==void 0)return e;let r=await n({message:`Initialize git repository?`,initialValue:A.git});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function xt(e){if(e!==void 0)return e;let r=await n({message:`Install dependencies?`,initialValue:A.install});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}const K={prisma:{value:`prisma`,label:`Prisma`,hint:`Powerful, feature-rich ORM`},mongoose:{value:`mongoose`,label:`Mongoose`,hint:`Elegant object modeling tool`},drizzle:{value:`drizzle`,label:`Drizzle`,hint:`Lightweight and performant TypeScript ORM`}};async function St(e,n,r,i){if(i===`convex`||!n)return`none`;if(e!==void 0)return e;let o=[...r===`mongodb`?[K.prisma,K.mongoose]:[K.drizzle,K.prisma]],s=await u({message:`Select ORM`,options:o,initialValue:r===`mongodb`?`prisma`:A.orm});return a(s)&&(t(g.red(`Operation cancelled`)),process.exit(0)),s}async function Ct(e){if(e!==void 0)return e;let n=E(),r=await u({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:n});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function wt(e,n){if(n===`convex`||n===`none`)return`none`;if(e!==void 0)return e;if(n===`next`)return`node`;let r=await u({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:A.runtime});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function Tt(e,n,i,a){let o=await r({frontend:({results:t})=>yt(e.frontend,e.backend),backend:({results:t})=>ht(e.backend,t.frontend),runtime:({results:t})=>wt(e.runtime,t.backend),database:({results:t})=>gt(e.database,t.backend),orm:({results:t})=>St(e.orm,t.database!==`none`,t.database,t.backend),api:({results:t})=>pt(e.api,t.frontend,t.backend),auth:({results:t})=>mt(e.auth,t.database!==`none`,t.backend),addons:({results:t})=>ft(e.addons,t.frontend),examples:({results:t})=>vt(e.examples,t.database,t.frontend,t.backend,t.api),dbSetup:({results:t})=>_t(t.database??`none`,e.dbSetup,t.orm,t.backend),git:()=>bt(e.git),packageManager:()=>Ct(e.packageManager),install:()=>xt(e.install)},{onCancel:()=>{t(g.red(`Operation cancelled`)),process.exit(0)}});return o.backend===`convex`&&(o.runtime=`none`,o.database=`none`,o.orm=`none`,o.api=`none`,o.auth=!1,o.dbSetup=`none`),o.backend===`none`&&(o.runtime=`none`,o.database=`none`,o.orm=`none`,o.api=`none`,o.auth=!1,o.dbSetup=`none`,o.examples=[]),{projectName:n,projectDir:i,relativePath:a,frontend:o.frontend,backend:o.backend,runtime:o.runtime,database:o.database,orm:o.orm,auth:o.auth,addons:o.addons,examples:o.examples,git:o.git,packageManager:o.packageManager,install:o.install,dbSetup:o.dbSetup,api:o.api}}const Et=[`<`,`>`,`:`,`"`,`|`,`?`,`*`],q=255;function J(e){if(e!==`.`){if(!e)return`Project name cannot be empty`;if(e.length>q)return`Project name must be less than ${q} characters`;if(Et.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`)return`Project name is reserved`}}async function Y(n){if(n){if(n===`.`)return n;let t=e.basename(n),r=J(t);if(!r)return n}let r=!1,i=``,o=A.projectName,s=1;for(;h.pathExistsSync(e.resolve(process.cwd(),o))&&h.readdirSync(e.resolve(process.cwd(),o)).length>0;)o=`${A.projectName}-${s}`,s++;for(;!r;){let s=await f({message:`Enter your project name or path (relative to current directory)`,placeholder:o,initialValue:n,defaultValue:o,validate:t=>{let n=t.trim()||o,r=e.basename(n),i=J(r);if(i)return i;if(n!==`.`){let t=e.resolve(process.cwd(),n);if(!t.startsWith(process.cwd()))return`Project path must be within current directory`}}});a(s)&&(t(g.red(`Operation cancelled.`)),process.exit(0)),i=s||o,r=!0}return i}function X(e){let t=[];if(e.projectName&&t.push(`${g.blue(`Project Name:`)} ${e.projectName}`),e.frontend!==void 0){let n=Array.isArray(e.frontend)?e.frontend:[e.frontend],r=n.length>0&&n[0]!==void 0?n.join(`, `):`none`;t.push(`${g.blue(`Frontend:`)} ${r}`)}if(e.backend!==void 0&&t.push(`${g.blue(`Backend:`)} ${String(e.backend)}`),e.runtime!==void 0&&t.push(`${g.blue(`Runtime:`)} ${String(e.runtime)}`),e.api!==void 0&&t.push(`${g.blue(`API:`)} ${String(e.api)}`),e.database!==void 0&&t.push(`${g.blue(`Database:`)} ${String(e.database)}`),e.orm!==void 0&&t.push(`${g.blue(`ORM:`)} ${String(e.orm)}`),e.auth!==void 0){let n=typeof e.auth==`boolean`?e.auth?`Yes`:`No`:String(e.auth);t.push(`${g.blue(`Authentication:`)} ${n}`)}if(e.addons!==void 0){let n=Array.isArray(e.addons)?e.addons:[e.addons],r=n.length>0&&n[0]!==void 0?n.join(`, `):`none`;t.push(`${g.blue(`Addons:`)} ${r}`)}if(e.examples!==void 0){let n=Array.isArray(e.examples)?e.examples:[e.examples],r=n.length>0&&n[0]!==void 0?n.join(`, `):`none`;t.push(`${g.blue(`Examples:`)} ${r}`)}if(e.git!==void 0){let n=typeof e.git==`boolean`?e.git?`Yes`:`No`:String(e.git);t.push(`${g.blue(`Git Init:`)} ${n}`)}if(e.packageManager!==void 0&&t.push(`${g.blue(`Package Manager:`)} ${String(e.packageManager)}`),e.install!==void 0){let n=typeof e.install==`boolean`?e.install?`Yes`:`No`:String(e.install);t.push(`${g.blue(`Install Dependencies:`)} ${n}`)}return e.dbSetup!==void 0&&t.push(`${g.blue(`Database Setup:`)} ${String(e.dbSetup)}`),t.length===0?g.yellow(`No configuration selected.`):t.join(`
159
- `)}function Dt(e){let t=[];e.frontend&&e.frontend.length>0?t.push(`--frontend ${e.frontend.join(` `)}`):t.push(`--frontend none`),t.push(`--backend ${e.backend}`),t.push(`--runtime ${e.runtime}`),t.push(`--database ${e.database}`),t.push(`--orm ${e.orm}`),t.push(`--api ${e.api}`),t.push(e.auth?`--auth`:`--no-auth`),e.addons&&e.addons.length>0?t.push(`--addons ${e.addons.join(` `)}`):t.push(`--addons none`),e.examples&&e.examples.length>0?t.push(`--examples ${e.examples.join(` `)}`):t.push(`--examples none`),t.push(`--db-setup ${e.dbSetup}`),t.push(e.git?`--git`:`--no-git`),t.push(`--package-manager ${e.packageManager}`),t.push(e.install?`--install`:`--no-install`);let n=``,r=e.packageManager;r===`npm`?n=`npx create-better-t-stack@latest`:r===`pnpm`?n=`pnpm create better-t-stack@latest`:r===`bun`&&(n=`bun create better-t-stack@latest`);let i=e.relativePath?` ${e.relativePath}`:``;return`${n}${i} ${t.join(` `)}`}const Ot=()=>{let t=e.join(k,`package.json`),n=h.readJSONSync(t);return n.version??`1.0.0`},Z=`
165
+ `),r+=a),i&&await h.writeFile(t,r.trimEnd())}async function Ve(t){let{projectName:n,backend:r,frontend:i,database:a,orm:o,auth:s,examples:c,dbSetup:l,projectDir:u}=t,d=i.includes(`react-router`),f=i.includes(`tanstack-router`),p=i.includes(`tanstack-start`),m=i.includes(`next`),g=i.includes(`nuxt`),_=i.includes(`svelte`),v=i.includes(`solid`),y=d||f||p||m||g||v||_;if(y){let t=e.join(u,`apps/web`);if(await h.pathExists(t)){let n=`VITE_SERVER_URL`,i=`http://localhost:3000`;m?n=`NEXT_PUBLIC_SERVER_URL`:g?n=`NUXT_PUBLIC_SERVER_URL`:_&&(n=`PUBLIC_SERVER_URL`),r===`convex`&&(n=m?`NEXT_PUBLIC_CONVEX_URL`:g?`NUXT_PUBLIC_CONVEX_URL`:_?`PUBLIC_CONVEX_URL`:`VITE_CONVEX_URL`,i=`https://<YOUR_CONVEX_URL>`);let a=[{key:n,value:i,condition:!0}];await W(e.join(t,`.env`),a)}}if(i.includes(`native-nativewind`)||i.includes(`native-unistyles`)){let t=e.join(u,`apps/native`);if(await h.pathExists(t)){let n=`EXPO_PUBLIC_SERVER_URL`,i=`http://localhost:3000`;r===`convex`&&(n=`EXPO_PUBLIC_CONVEX_URL`,i=`https://<YOUR_CONVEX_URL>`);let a=[{key:n,value:i,condition:!0}];await W(e.join(t,`.env`),a)}}if(r===`convex`)return;let b=e.join(u,`apps/server`);if(!await h.pathExists(b))return;let x=e.join(b,`.env`),S=`http://localhost:3001`;(d||_)&&(S=`http://localhost:5173`);let C=null,w=l===`turso`||l===`prisma-postgres`||l===`mongodb-atlas`||l===`neon`||l===`supabase`;if(a!==`none`&&!w)switch(a){case`postgres`:C=`postgresql://postgres:postgres@localhost:5432/mydb?schema=public`;break;case`mysql`:C=`mysql://root:password@localhost:3306/mydb`;break;case`mongodb`:C=`mongodb://localhost:27017/mydatabase`;break;case`sqlite`:C=`file:./local.db`;break}let T=[{key:`CORS_ORIGIN`,value:S,condition:!0},{key:`BETTER_AUTH_SECRET`,value:le(),condition:!!s},{key:`BETTER_AUTH_URL`,value:`http://localhost:3000`,condition:!!s},{key:`DATABASE_URL`,value:C,condition:a!==`none`&&!w},{key:`GOOGLE_GENERATIVE_AI_API_KEY`,value:``,condition:c?.includes(`ai`)||!1}];await W(x,T)}async function He(t){let{projectName:n,examples:r,frontend:i,backend:a,projectDir:o}=t;if(!(a===`convex`||!r||r.length===0||r[0]===`none`)&&r.includes(`ai`)){let t=e.join(o,`apps/web`),n=e.join(o,`apps/server`),r=await h.pathExists(t),s=await h.pathExists(n),c=i.includes(`nuxt`),l=i.includes(`svelte`);if(r){let e=[`ai`];c?e.push(`@ai-sdk/vue`):l&&e.push(`@ai-sdk/svelte`),await M({dependencies:e,projectDir:t})}s&&a!==`none`&&await M({dependencies:[`ai`,`@ai-sdk/google`],projectDir:n})}}async function Ue({projectDir:e,packageManager:t,addons:n=[]}){let r=d();try{r.start(`Running ${t} install...`),await b({cwd:e,stderr:`inherit`})`${t} install`,r.stop(`Dependencies installed successfully`),(n.includes(`biome`)||n.includes(`husky`))&&await We(e,t)}catch(e){r.stop(g.red(`Failed to install dependencies`)),e instanceof Error&&p.error(g.red(`Installation error: ${e.message}`))}}async function We(e,t){let n=d();try{n.start(`Running Biome format check...`),await b({cwd:e,stderr:`inherit`})`${t} biome check --write .`,n.stop(`Biome check completed successfully`)}catch{n.stop(g.yellow(`Biome check encountered issues`)),o.warn(g.yellow(`Some files may need manual formatting`))}}function Ge(e){let{database:t,projectName:n,relativePath:r,packageManager:i,depsInstalled:a,orm:o,addons:s,runtime:c,frontend:l,backend:u}=e,d=u===`convex`,f=i===`npm`?`npm run`:i,p=`cd ${r}`,h=s?.includes(`husky`)||s?.includes(`biome`),_=!d&&t!==`none`?Je(t,o,f,c):``,v=s?.includes(`tauri`)?Ye(f):``,y=h?qe(f):``,b=l?.includes(`native-nativewind`)||l?.includes(`native-unistyles`)?Ke(d):``,x=s?.includes(`pwa`)&&(l?.includes(`react-router`)||l?.includes(`tanstack-router`))?Xe():``,S=s?.includes(`starlight`)?Ze(f):``,C=l?.some(e=>[`tanstack-router`,`react-router`,`next`,`tanstack-start`,`nuxt`,`svelte`,`solid`].includes(e)),w=l?.includes(`native-nativewind`)||l?.includes(`native-unistyles`),T=i===`bun`&&w&&C?$e():``,E=!d&&t!==`none`&&o===`none`?Qe():``,D=l?.includes(`react-router`),O=l?.includes(`svelte`),k=D||O?`5173`:`3001`,A=N(i,`taze -r`),j=`${g.bold(`Next steps`)}\n${g.cyan(`1.`)} ${p}\n`,M=2;a||(j+=`${g.cyan(`${M++}.`)} ${i} install\n`),d&&(j+=`${g.cyan(`${M++}.`)} ${f} dev:setup ${g.dim(`(this will guide you through Convex project setup)`)}\n`),j+=`${g.cyan(`${M++}.`)} ${f} dev\n\n`,j+=`${g.bold(`Your project will be available at:`)}\n`,C?j+=`${g.cyan(`•`)} Frontend: http://localhost:${k}\n`:!w&&!s?.includes(`starlight`)&&(j+=`${g.yellow(`NOTE:`)} You are creating a backend-only app (no frontend selected)\n`),d||(j+=`${g.cyan(`•`)} Backend API: http://localhost:3000\n`),s?.includes(`starlight`)&&(j+=`${g.cyan(`•`)} Docs: http://localhost:4321\n`),b&&(j+=`\n${b.trim()}\n`),_&&(j+=`\n${_.trim()}\n`),v&&(j+=`\n${v.trim()}\n`),y&&(j+=`\n${y.trim()}\n`),x&&(j+=`\n${x.trim()}\n`),S&&(j+=`\n${S.trim()}\n`),E&&(j+=`\n${E.trim()}\n`),T&&(j+=`\n${T.trim()}\n`),j+=`\n${g.bold(`Update all dependencies:
166
+ `)}${g.cyan(A)}\n\n`,j+=`${g.bold(`Like Better-T Stack?`)} Please consider giving us a star on GitHub:\n`,j+=g.cyan(`https://github.com/AmanVarshney01/create-better-t-stack`),m.box(j)}function Ke(e){let t=e?`EXPO_PUBLIC_CONVEX_URL`:`EXPO_PUBLIC_SERVER_URL`,n=e?`https://<YOUR_CONVEX_URL>`:`http://<YOUR_LOCAL_IP>:3000`,r=`.env`,i=e?`your Convex deployment URL (find after running 'dev:setup')`:`your local IP address`;return`${g.yellow(`NOTE:`)} For Expo connectivity issues, update apps/native/${r} \nwith ${i}:\n${`${t}=${n}`}\n`}function qe(e){return`${g.bold(`Linting and formatting:`)}\n${g.cyan(`•`)} Format and lint fix: ${`${e} check`}\n`}function Je(e,t,n,r){let i=[];return t===`prisma`?(e===`sqlite`&&i.push(`${g.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`&&i.push(`${g.yellow(`NOTE:`)} Prisma with Bun may require additional configuration. If you encounter errors,\nfollow the guidance provided in the error messages`),i.push(`${g.cyan(`•`)} Apply schema: ${`${n} db:push`}`),i.push(`${g.cyan(`•`)} Database UI: ${`${n} db:studio`}`)):t===`drizzle`?(i.push(`${g.cyan(`•`)} Apply schema: ${`${n} db:push`}`),i.push(`${g.cyan(`•`)} Database UI: ${`${n} db:studio`}`),e===`sqlite`&&i.push(`${g.cyan(`•`)} Start local DB (if needed): ${`cd apps/server && ${n} db:local`}`)):t===`none`&&i.push(`${g.yellow(`NOTE:`)} Manual database schema setup required.`),i.length?`${g.bold(`Database commands:`)}\n${i.join(`
167
+ `)}`:``}function Ye(e){return`\n${g.bold(`Desktop app with Tauri:`)}\n${g.cyan(`•`)} Start desktop app: ${`cd apps/web && ${e} desktop:dev`}\n${g.cyan(`•`)} Build desktop app: ${`cd apps/web && ${e} desktop:build`}\n${g.yellow(`NOTE:`)} Tauri requires Rust and platform-specific dependencies.\nSee: https://v2.tauri.app/start/prerequisites/`}function Xe(){return`\n${g.bold(`PWA with React Router v7:`)}\n${g.yellow(`NOTE:`)} There is a known compatibility issue between VitePWA and React Router v7.\nSee: https://github.com/vite-pwa/vite-plugin-pwa/issues/809`}function Ze(e){return`\n${g.bold(`Documentation with Starlight:`)}\n${g.cyan(`•`)} Start docs site: ${`cd apps/docs && ${e} dev`}\n${g.cyan(`•`)} Build docs site: ${`cd apps/docs && ${e} build`}`}function Qe(){return`\n${g.yellow(`WARNING:`)} Database selected without an ORM. Features requiring database access (e.g., examples, auth) need manual setup.`}function $e(){return`\n${g.yellow(`WARNING:`)} 'bun' might cause issues with web + native apps in a monorepo. Use 'pnpm' if problems arise.`}async function et(e,t){await tt(e,t),t.backend===`convex`?await rt(e,t):await nt(e,t)}async function tt(t,n){let r=e.join(t,`package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.name=n.projectName,i.scripts||={};let a=i.scripts,s=n.backend===`convex`?`@${n.projectName}/backend`:`server`,c=``;n.addons.includes(`turborepo`)?c=`turbo -F ${s} dev`:n.packageManager===`bun`?c=`bun run --filter ${s} dev`:n.packageManager===`pnpm`?c=`pnpm --filter ${s} dev`:n.packageManager===`npm`&&(c=`npm run dev --workspace ${s}`);let l=``;n.packageManager===`pnpm`?l=`pnpm -r dev`:n.packageManager===`npm`?l=`npm run dev --workspaces`:n.packageManager===`bun`&&(l=`bun run --filter '*' dev`);let u=n.backend!==`convex`&&n.database!==`none`&&n.orm!==`none`&&n.orm!==`mongoose`;n.addons.includes(`turborepo`)?(a.dev=`turbo dev`,a.build=`turbo build`,a[`check-types`]=`turbo check-types`,a[`dev:native`]=`turbo -F native dev`,a[`dev:web`]=`turbo -F web dev`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`turbo -F ${s} setup`),u&&(a[`db:push`]=`turbo -F ${s} db:push`,a[`db:studio`]=`turbo -F ${s} db:studio`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`turbo -F ${s} db:generate`,a[`db:migrate`]=`turbo -F ${s} db:migrate`))):n.packageManager===`pnpm`?(a.dev=l,a.build=`pnpm -r build`,a[`check-types`]=`pnpm -r check-types`,a[`dev:native`]=`pnpm --filter native dev`,a[`dev:web`]=`pnpm --filter web dev`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`pnpm --filter ${s} setup`),u&&(a[`db:push`]=`pnpm --filter ${s} db:push`,a[`db:studio`]=`pnpm --filter ${s} db:studio`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`pnpm --filter ${s} db:generate`,a[`db:migrate`]=`pnpm --filter ${s} db:migrate`))):n.packageManager===`npm`?(a.dev=l,a.build=`npm run build --workspaces`,a[`check-types`]=`npm run check-types --workspaces`,a[`dev:native`]=`npm run dev --workspace native`,a[`dev:web`]=`npm run dev --workspace web`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`npm run setup --workspace ${s}`),u&&(a[`db:push`]=`npm run db:push --workspace ${s}`,a[`db:studio`]=`npm run db:studio --workspace ${s}`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`npm run db:generate --workspace ${s}`,a[`db:migrate`]=`npm run db:migrate --workspace ${s}`))):n.packageManager===`bun`&&(a.dev=l,a.build=`bun run --filter '*' build`,a[`check-types`]=`bun run --filter '*' check-types`,a[`dev:native`]=`bun run --filter native dev`,a[`dev:web`]=`bun run --filter web dev`,a[`dev:server`]=c,n.backend===`convex`&&(a[`dev:setup`]=`bun run --filter ${s} setup`),u&&(a[`db:push`]=`bun run --filter ${s} db:push`,a[`db:studio`]=`bun run --filter ${s} db:studio`,(n.orm===`prisma`||n.orm===`drizzle`)&&(a[`db:generate`]=`bun run --filter ${s} db:generate`,a[`db:migrate`]=`bun run --filter ${s} db:migrate`))),n.addons.includes(`biome`)&&(a.check=`biome check --write .`),n.addons.includes(`husky`)&&(a.prepare=`husky`,i[`lint-staged`]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":[`biome check --write .`]});try{let{stdout:e}=await x(n.packageManager,[`-v`],{cwd:t});i.packageManager=`${n.packageManager}@${e.trim()}`}catch{o.warn(`Could not determine ${n.packageManager} version.`)}i.workspaces||=[];let d=i.workspaces;if(n.backend===`convex`){d.includes(`packages/*`)||d.push(`packages/*`);let e=n.frontend.length>0||n.addons.includes(`starlight`);e&&!d.includes(`apps/*`)&&d.push(`apps/*`)}else d.includes(`apps/*`)||d.push(`apps/*`),d.includes(`packages/*`)||d.push(`packages/*`);await h.writeJson(r,i,{spaces:2})}async function nt(t,n){let r=e.join(t,`apps/server/package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.scripts||={};let a=i.scripts;n.database!==`none`&&(n.database===`sqlite`&&n.orm===`drizzle`&&(a[`db:local`]=`turso dev --db-file local.db`),n.orm===`prisma`?(a[`db:push`]=`prisma db push --schema ./prisma/schema`,a[`db:studio`]=`prisma studio`,a[`db:generate`]=`prisma generate --schema ./prisma/schema`,a[`db:migrate`]=`prisma migrate dev`):n.orm===`drizzle`&&(a[`db:push`]=`drizzle-kit push`,a[`db:studio`]=`drizzle-kit studio`,a[`db:generate`]=`drizzle-kit generate`,a[`db:migrate`]=`drizzle-kit migrate`)),await h.writeJson(r,i,{spaces:2})}async function rt(t,n){let r=e.join(t,`packages/backend/package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.name=`@${n.projectName}/backend`,i.scripts||={},await h.writeJson(r,i,{spaces:2})}async function it(e,t){if(!t)return;let n=await b({cwd:e,reject:!1,stderr:`pipe`})`git --version`;if(n.exitCode!==0){o.warn(g.yellow(`Git is not installed`));return}let r=await b({cwd:e,reject:!1,stderr:`pipe`})`git init`;if(r.exitCode!==0)throw Error(`Git initialization failed: ${r.stderr}`)}async function at(t){let{projectName:n,runtime:r,backend:i,projectDir:a}=t;if(i===`convex`||i===`next`||r===`none`)return;let o=e.join(a,`apps/server`);await h.pathExists(o)&&(r===`bun`?await ot(o,i):r===`node`&&await st(o,i))}async function ot(t,n){let r=e.join(t,`package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.scripts={...i.scripts,dev:`bun run --hot src/index.ts`,start:`bun run dist/src/index.js`},await h.writeJson(r,i,{spaces:2}),await M({devDependencies:[`@types/bun`],projectDir:t})}async function st(t,n){let r=e.join(t,`package.json`);if(!await h.pathExists(r))return;let i=await h.readJson(r);i.scripts={...i.scripts,dev:`tsx watch src/index.ts`,start:`node dist/src/index.js`},await h.writeJson(r,i,{spaces:2}),await M({devDependencies:[`tsx`,`@types/node`],projectDir:t}),n===`hono`?await M({dependencies:[`@hono/node-server`],projectDir:t}):n===`elysia`&&await M({dependencies:[`@elysiajs/node`],projectDir:t})}async function G(t,n,r){try{let i=await h.readFile(t,`utf-8`),a=w.compile(i),o=a(r);await h.ensureDir(e.dirname(n)),await h.writeFile(n,o)}catch(e){throw p.error(`Error processing template ${t}:`,e),Error(`Failed to process template ${t}`)}}w.registerHelper(`or`,(e,t)=>e||t),w.registerHelper(`eq`,(e,t)=>e===t),w.registerHelper(`includes`,(e,t)=>Array.isArray(e)&&e.includes(t));async function K(t,n,r,i,a=!0){let o=await C(t,{cwd:n,dot:!0,onlyFiles:!0,absolute:!1});for(let t of o){let o=e.join(n,t),s=t;t.endsWith(`.hbs`)&&(s=t.slice(0,-4));let c=e.basename(t);c===`_gitignore`?s=e.join(e.dirname(t),`.gitignore`):c===`_npmrc`&&(s=e.join(e.dirname(t),`.npmrc`));let l=e.join(r,s);try{if(await h.ensureDir(e.dirname(l)),!a&&await h.pathExists(l))continue;o.endsWith(`.hbs`)?await G(o,l,i):await h.copy(o,l,{overwrite:!0})}catch{}}}async function ct(t,n){let r=e.join(k,`templates/base`);await K([`**/*`],r,t,n),await h.ensureDir(e.join(t,`packages`))}async function lt(t,n){let r=n.frontend.some(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e)),i=n.frontend.includes(`nuxt`),a=n.frontend.includes(`svelte`),o=n.frontend.includes(`solid`),s=n.frontend.includes(`native-nativewind`),c=n.frontend.includes(`native-unistyles`),l=s||c,u=n.backend===`convex`;if(r||i||a||o){let s=e.join(t,`apps/web`);if(await h.ensureDir(s),r){let t=e.join(k,`templates/frontend/react/web-base`);await h.pathExists(t)&&await K(`**/*`,t,s,n);let r=n.frontend.find(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e));if(r){let t=e.join(k,`templates/frontend/react/${r}`);if(await h.pathExists(t)&&await K(`**/*`,t,s,n),!u&&n.api!==`none`){let t=e.join(k,`templates/api/${n.api}/web/react/base`);await h.pathExists(t)&&await K(`**/*`,t,s,n)}}}else if(i){let t=e.join(k,`templates/frontend/nuxt`);if(await h.pathExists(t)&&await K(`**/*`,t,s,n),!u&&n.api===`orpc`){let t=e.join(k,`templates/api/${n.api}/web/nuxt`);await h.pathExists(t)&&await K(`**/*`,t,s,n)}}else if(a){let t=e.join(k,`templates/frontend/svelte`);if(await h.pathExists(t)&&await K(`**/*`,t,s,n),!u&&n.api===`orpc`){let t=e.join(k,`templates/api/${n.api}/web/svelte`);await h.pathExists(t)&&await K(`**/*`,t,s,n)}}else if(o){let t=e.join(k,`templates/frontend/solid`);if(await h.pathExists(t)&&await K(`**/*`,t,s,n),!u&&n.api===`orpc`){let t=e.join(k,`templates/api/${n.api}/web/solid`);await h.pathExists(t)&&await K(`**/*`,t,s,n)}}}if(s||c){let r=e.join(t,`apps/native`);await h.ensureDir(r);let i=e.join(k,`templates/frontend/native/native-base`);await h.pathExists(i)&&await K(`**/*`,i,r,n);let a=``;s?a=`nativewind`:c&&(a=`unistyles`);let o=e.join(k,`templates/frontend/native/${a}`);if(await h.pathExists(o)&&await K(`**/*`,o,r,n,!0),!u&&(n.api===`trpc`||n.api===`orpc`)){let t=e.join(k,`templates/api/${n.api}/native`);await h.pathExists(t)&&await K(`**/*`,t,r,n)}}}async function ut(t,n){if(n.backend===`none`)return;let r=e.join(t,`apps/server`);if(n.backend===`convex`){await h.pathExists(r)&&await h.remove(r);let i=e.join(t,`packages/backend`),a=e.join(k,`templates/backend/convex/packages/backend`);await h.ensureDir(i),await h.pathExists(a)&&await K(`**/*`,a,i,n);return}await h.ensureDir(r);let i=e.join(k,`templates/backend/server/server-base`);await h.pathExists(i)&&await K(`**/*`,i,r,n);let a=e.join(k,`templates/backend/server/${n.backend}`);if(await h.pathExists(a)&&await K(`**/*`,a,r,n,!0),n.api!==`none`){let t=e.join(k,`templates/api/${n.api}/server/base`);await h.pathExists(t)&&await K(`**/*`,t,r,n,!0);let i=e.join(k,`templates/api/${n.api}/server/${n.backend}`);await h.pathExists(i)&&await K(`**/*`,i,r,n,!0)}}async function dt(t,n){if(n.backend===`convex`||n.orm===`none`||n.database===`none`)return;let r=e.join(t,`apps/server`);await h.ensureDir(r);let i=e.join(k,`templates/db/${n.orm}/${n.database}`);await h.pathExists(i)&&await K(`**/*`,i,r,n)}async function ft(t,n){if(n.backend===`convex`||!n.auth)return;let r=e.join(t,`apps/server`),i=e.join(t,`apps/web`),a=e.join(t,`apps/native`),o=await h.pathExists(r),s=await h.pathExists(i),c=await h.pathExists(a),l=n.frontend.some(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e)),u=n.frontend.includes(`nuxt`),d=n.frontend.includes(`svelte`),f=n.frontend.includes(`solid`),p=n.frontend.includes(`native-nativewind`),m=n.frontend.includes(`native-unistyles`),g=p||m;if(o){let t=e.join(k,`templates/auth/server/base`);if(await h.pathExists(t)&&await K(`**/*`,t,r,n),n.backend===`next`){let t=e.join(k,`templates/auth/server/next`);await h.pathExists(t)&&await K(`**/*`,t,r,n)}if(n.orm!==`none`&&n.database!==`none`){let t=n.orm,i=n.database,a=``;t===`drizzle`?a=e.join(k,`templates/auth/server/db/drizzle/${i}`):t===`prisma`?a=e.join(k,`templates/auth/server/db/prisma/${i}`):t===`mongoose`&&(a=e.join(k,`templates/auth/server/db/mongoose/${i}`)),a&&await h.pathExists(a)&&await K(`**/*`,a,r,n)}}if((l||u||d||f)&&s){if(l){let t=e.join(k,`templates/auth/web/react/base`);await h.pathExists(t)&&await K(`**/*`,t,i,n);let r=n.frontend.find(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e));if(r){let t=e.join(k,`templates/auth/web/react/${r}`);await h.pathExists(t)&&await K(`**/*`,t,i,n)}}else if(u){let t=e.join(k,`templates/auth/web/nuxt`);await h.pathExists(t)&&await K(`**/*`,t,i,n)}else if(d){if(n.api===`orpc`){let t=e.join(k,`templates/auth/web/svelte`);await h.pathExists(t)&&await K(`**/*`,t,i,n)}}else if(f&&n.api===`orpc`){let t=e.join(k,`templates/auth/web/solid`);await h.pathExists(t)&&await K(`**/*`,t,i,n)}}if(g&&c){let t=e.join(k,`templates/auth/native/native-base`);await h.pathExists(t)&&await K(`**/*`,t,a,n);let r=``;if(p?r=`nativewind`:m&&(r=`unistyles`),r){let t=e.join(k,`templates/auth/native/${r}`);await h.pathExists(t)&&await K(`**/*`,t,a,n)}}}async function pt(t,n){if(!(!n.addons||n.addons.length===0))for(let r of n.addons){if(r===`none`)continue;let i=e.join(k,`templates/addons/${r}`),a=t;if(r===`pwa`&&(i=e.join(k,`templates/addons/pwa/apps/web`),a=e.join(t,`apps/web`),!await h.pathExists(a)))continue;await h.pathExists(i)&&await K(`**/*`,i,a,n)}}async function mt(t,n){if(!n.examples||n.examples.length===0||n.examples[0]===`none`)return;let r=e.join(t,`apps/server`),i=e.join(t,`apps/web`),a=await h.pathExists(r),o=await h.pathExists(i),s=n.frontend.some(e=>[`tanstack-router`,`react-router`,`tanstack-start`,`next`].includes(e)),c=n.frontend.includes(`nuxt`),l=n.frontend.includes(`svelte`),u=n.frontend.includes(`solid`);for(let t of n.examples){if(t===`none`)continue;let d=e.join(k,`templates/examples/${t}`);if(a&&n.backend!==`convex`&&n.backend!==`none`){let i=e.join(d,`server`);if(t===`ai`&&n.backend===`next`){let t=e.join(i,`next`);await h.pathExists(t)&&await K(`**/*`,t,r,n,!1)}if(n.orm!==`none`&&n.database!==`none`){let t=e.join(i,n.orm,`base`);await h.pathExists(t)&&await K(`**/*`,t,r,n,!1);let a=e.join(i,n.orm,n.database);await h.pathExists(a)&&await K(`**/*`,a,r,n,!1)}let a=[`${n.orm}/**`];t===`ai`&&n.backend===`next`&&a.push(`next/**`);let o=await C([`**/*.ts`,`**/*.hbs`],{cwd:i,onlyFiles:!0,deep:1,ignore:a});for(let t of o){let a=e.join(i,t),o=e.join(r,t.replace(`.hbs`,``));try{a.endsWith(`.hbs`)?await G(a,o,n):await h.pathExists(o)||await h.copy(a,o,{overwrite:!1})}catch{}}}if(o){if(s){let t=e.join(d,`web/react`);if(await h.pathExists(t)){let r=n.frontend.find(e=>[`next`,`react-router`,`tanstack-router`,`tanstack-start`].includes(e));if(r){let a=e.join(t,r);await h.pathExists(a)&&await K(`**/*`,a,i,n,!1)}}}else if(c){let t=e.join(d,`web/nuxt`);await h.pathExists(t)&&await K(`**/*`,t,i,n,!1)}else if(l){let t=e.join(d,`web/svelte`);await h.pathExists(t)&&await K(`**/*`,t,i,n,!1)}else if(u){let t=e.join(d,`web/solid`);await h.pathExists(t)&&await K(`**/*`,t,i,n,!1)}}}}async function ht(t,n){let r=e.join(k,`templates/extras`),i=n.frontend.includes(`native-nativewind`),a=n.frontend.includes(`native-unistyles`),o=i||a;if(n.packageManager===`pnpm`){let n=e.join(r,`pnpm-workspace.yaml`),i=e.join(t,`pnpm-workspace.yaml`);await h.pathExists(n)&&await h.copy(n,i)}if(n.packageManager===`pnpm`&&(o||n.frontend.includes(`nuxt`))){let i=e.join(r,`_npmrc.hbs`),a=e.join(t,`.npmrc`);await h.pathExists(i)&&await G(i,a,n)}}async function gt(e){let n=e.projectDir,r=e.backend===`convex`;try{return await h.ensureDir(n),await ct(n,e),await lt(n,e),await ut(n,e),r||(await dt(n,e),await ft(n,e)),e.examples.length>0&&e.examples[0]!==`none`&&await mt(n,e),await pt(n,e),await se(e),r||(await ue(e),await Be(e),await at(e),e.examples.length>0&&e.examples[0]!==`none`&&await He(e)),e.addons.length>0&&e.addons[0]!==`none`&&await ne(e),!r&&e.auth&&await ce(e),await ht(n,e),await Ve(e),await et(n,e),await de(n,e),await it(n,e.git),o.success(`Project template successfully scaffolded!`),e.install&&await Ue({projectDir:n,packageManager:e.packageManager,addons:e.addons}),Ge({...e,depsInstalled:e.install}),n}catch(e){e instanceof Error?(t(g.red(`Error during project creation: ${e.message}`)),console.error(e.stack),process.exit(1)):(t(g.red(`An unexpected error occurred: ${String(e)}`)),console.error(e),process.exit(1))}}async function _t(e,n){if(e!==void 0)return e;let r=n?.includes(`react-router`)||n?.includes(`tanstack-router`)||n?.includes(`solid`),i=n?.includes(`react-router`)||n?.includes(`tanstack-router`)||n?.includes(`nuxt`)||n?.includes(`svelte`)||n?.includes(`solid`)||n?.includes(`next`),o=[{value:`turborepo`,label:`Turborepo (Recommended)`,hint:`Optimize builds for monorepos`},{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)`},{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`}],c=o.filter(e=>e.value===`pwa`?r:e.value===`tauri`?i:!0),l=A.addons.filter(e=>c.some(t=>t.value===e)),u=await s({message:`Select addons`,options:c,initialValues:l,required:!1});return a(u)&&(t(g.red(`Operation cancelled`)),process.exit(0)),u.includes(`husky`)&&!u.includes(`biome`)&&u.push(`biome`),u}async function vt(e,n,r){if(r===`convex`||r===`none`)return`none`;if(e)return e;let i=n?.includes(`nuxt`),o=n?.includes(`svelte`),s=n?.includes(`solid`),c=[{value:`trpc`,label:`tRPC`,hint:`End-to-end typesafe APIs made easy`},{value:`orpc`,label:`oRPC`,hint:`End-to-end type-safe APIs that adhere to OpenAPI standards`},{value:`none`,label:`None`,hint:`No API layer (e.g. for full-stack frameworks like Next.js with Route Handlers)`}];(i||o||s)&&(c=[{value:`orpc`,label:`oRPC`,hint:`End-to-end type-safe APIs (Recommended for ${i?`Nuxt`:o?`Svelte`:`Solid`} frontend)`},{value:`none`,label:`None`,hint:`No API layer`}]);let l=await u({message:`Select API type`,options:c,initialValue:c[0].value});return a(l)&&(t(g.red(`Operation cancelled`)),process.exit(0)),l}async function yt(e,r,i){if(i===`convex`||!r)return!1;if(e!==void 0)return e;let o=await n({message:`Add authentication with Better-Auth?`,initialValue:A.auth});return a(o)&&(t(g.red(`Operation cancelled`)),process.exit(0)),o}async function bt(e,n){if(e!==void 0)return e;let r=n?.some(e=>e===`nuxt`||e===`solid`),i=[{value:`hono`,label:`Hono`,hint:`Lightweight, ultrafast web framework`},{value:`next`,label:`Next.js`,hint:`Full-stack framework with API routes`},{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`}];r||i.push({value:`convex`,label:`Convex`,hint:`Reactive backend-as-a-service platform`}),i.push({value:`none`,label:`None`,hint:`No backend server (e.g., for a static site or client-only app)`});let o=A.backend;r&&o===`convex`&&(o=`hono`);let s=await u({message:`Select backend framework`,options:i,initialValue:o});return a(s)&&(t(g.red(`Operation cancelled`)),process.exit(0)),s}async function xt(e,n){if(n===`convex`||n===`none`)return`none`;if(e!==void 0)return e;let r=await u({message:`Select database`,options:[{value:`none`,label:`None`,hint:`No database setup`},{value:`sqlite`,label:`SQLite`,hint:`lightweight, server-less, embedded relational database`},{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:A.database});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function St(e,n,r,i){if(i===`convex`)return`none`;if(n!==void 0)return n;if(e===`none`||e===`sqlite`&&r===`prisma`)return`none`;let o=[];if(e===`sqlite`)o=[{value:`turso`,label:`Turso`,hint:`SQLite for Production. Powered by libSQL`},{value:`none`,label:`None`,hint:`Manual setup`}];else if(e===`postgres`)o=[{value:`neon`,label:`Neon Postgres`,hint:`Serverless Postgres with branching capability`},{value:`supabase`,label:`Supabase`,hint:`Local Supabase stack (requires Docker)`},...r===`prisma`?[{value:`prisma-postgres`,label:`Prisma Postgres`,hint:`Instant Postgres for Global Applications`}]:[],{value:`none`,label:`None`,hint:`Manual setup`}];else if(e===`mongodb`)o=[{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 s=await u({message:`Select ${e} setup option`,options:o,initialValue:`none`});return a(s)&&(t(g.red(`Operation cancelled`)),process.exit(0)),s}async function Ct(e,n,r,i,o){if(o===`none`)return[];if(e!==void 0)return e;if(i===`convex`)return[`todo`];if(i===`none`||n===`none`)return[];let c=r&&r.length===1&&(r[0]===`native-nativewind`||r[0]===`native-unistyles`);if(c)return[];let l=r?.some(e=>[`react-router`,`tanstack-router`,`tanstack-start`,`next`,`nuxt`,`svelte`,`solid`].includes(e))??!1,u=!r||r.length===0;if(!l&&!u)return[];let d=[],f=[{value:`todo`,label:`Todo App`,hint:`A simple CRUD example app`}];return i!==`elysia`&&!r?.includes(`solid`)&&f.push({value:`ai`,label:`AI Chat`,hint:`A simple AI chat interface using AI SDK`}),d=await s({message:`Include examples`,options:f,required:!1,initialValues:A.examples}),a(d)&&(t(g.red(`Operation cancelled`)),process.exit(0)),d}async function wt(e,n){if(e!==void 0)return e;let r=await s({message:`Select platforms to develop for`,options:[{value:`web`,label:`Web`,hint:`React, Vue or Svelte Web Application`},{value:`native`,label:`Native`,hint:`Create a React Native/Expo app`}],required:!1,initialValues:[`web`]});a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0));let i=[];if(r.includes(`web`)){let e=[{value:`tanstack-router`,label:`TanStack Router`,hint:`Modern and scalable routing for React Applications`},{value:`react-router`,label:`React Router`,hint:`A user‑obsessed, standards‑focused, multi‑strategy router`},{value:`next`,label:`Next.js`,hint:`The React Framework for the Web`},{value:`nuxt`,label:`Nuxt`,hint:`The Progressive Web Framework for Vue.js`},{value:`svelte`,label:`Svelte`,hint:`web development for the rest of us`},{value:`solid`,label:`Solid`,hint:`Simple and performant reactivity for building user interfaces`},{value:`tanstack-start`,label:`TanStack Start (beta)`,hint:`SSR, Server Functions, API Routes and more with TanStack Router`}],r=e.filter(e=>n===`convex`?e.value!==`nuxt`&&e.value!==`solid`:!0),o=await u({message:`Choose frontend framework`,options:r,initialValue:A.frontend[0]});a(o)&&(t(g.red(`Operation cancelled`)),process.exit(0)),i.push(o)}if(r.includes(`native`)){let e=await u({message:`Choose native framework`,options:[{value:`native-nativewind`,label:`NativeWind`,hint:`Use Tailwind CSS for React Native`},{value:`native-unistyles`,label:`Unistyles`,hint:`Consistent styling for React Native`}],initialValue:`native-nativewind`});a(e)&&(t(g.red(`Operation cancelled`)),process.exit(0)),i.push(e)}return i}async function Tt(e){if(e!==void 0)return e;let r=await n({message:`Initialize git repository?`,initialValue:A.git});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function Et(e){if(e!==void 0)return e;let r=await n({message:`Install dependencies?`,initialValue:A.install});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}const q={prisma:{value:`prisma`,label:`Prisma`,hint:`Powerful, feature-rich ORM`},mongoose:{value:`mongoose`,label:`Mongoose`,hint:`Elegant object modeling tool`},drizzle:{value:`drizzle`,label:`Drizzle`,hint:`Lightweight and performant TypeScript ORM`}};async function Dt(e,n,r,i){if(i===`convex`||!n)return`none`;if(e!==void 0)return e;let o=[...r===`mongodb`?[q.prisma,q.mongoose]:[q.drizzle,q.prisma]],s=await u({message:`Select ORM`,options:o,initialValue:r===`mongodb`?`prisma`:A.orm});return a(s)&&(t(g.red(`Operation cancelled`)),process.exit(0)),s}async function Ot(e){if(e!==void 0)return e;let n=E(),r=await u({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:n});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function kt(e,n){if(n===`convex`||n===`none`)return`none`;if(e!==void 0)return e;if(n===`next`)return`node`;let r=await u({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:A.runtime});return a(r)&&(t(g.red(`Operation cancelled`)),process.exit(0)),r}async function At(e,n,i,a){let o=await r({frontend:({results:t})=>wt(e.frontend,e.backend),backend:({results:t})=>bt(e.backend,t.frontend),runtime:({results:t})=>kt(e.runtime,t.backend),database:({results:t})=>xt(e.database,t.backend),orm:({results:t})=>Dt(e.orm,t.database!==`none`,t.database,t.backend),api:({results:t})=>vt(e.api,t.frontend,t.backend),auth:({results:t})=>yt(e.auth,t.database!==`none`,t.backend),addons:({results:t})=>_t(e.addons,t.frontend),examples:({results:t})=>Ct(e.examples,t.database,t.frontend,t.backend,t.api),dbSetup:({results:t})=>St(t.database??`none`,e.dbSetup,t.orm,t.backend),git:()=>Tt(e.git),packageManager:()=>Ot(e.packageManager),install:()=>Et(e.install)},{onCancel:()=>{t(g.red(`Operation cancelled`)),process.exit(0)}});return o.backend===`convex`&&(o.runtime=`none`,o.database=`none`,o.orm=`none`,o.api=`none`,o.auth=!1,o.dbSetup=`none`),o.backend===`none`&&(o.runtime=`none`,o.database=`none`,o.orm=`none`,o.api=`none`,o.auth=!1,o.dbSetup=`none`,o.examples=[]),{projectName:n,projectDir:i,relativePath:a,frontend:o.frontend,backend:o.backend,runtime:o.runtime,database:o.database,orm:o.orm,auth:o.auth,addons:o.addons,examples:o.examples,git:o.git,packageManager:o.packageManager,install:o.install,dbSetup:o.dbSetup,api:o.api}}const jt=[`<`,`>`,`:`,`"`,`|`,`?`,`*`],J=255;function Y(e){if(e!==`.`){if(!e)return`Project name cannot be empty`;if(e.length>J)return`Project name must be less than ${J} characters`;if(jt.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`)return`Project name is reserved`}}async function X(n){if(n){if(n===`.`)return n;let t=e.basename(n),r=Y(t);if(!r)return n}let r=!1,i=``,o=A.projectName,s=1;for(;h.pathExistsSync(e.resolve(process.cwd(),o))&&h.readdirSync(e.resolve(process.cwd(),o)).length>0;)o=`${A.projectName}-${s}`,s++;for(;!r;){let s=await f({message:`Enter your project name or path (relative to current directory)`,placeholder:o,initialValue:n,defaultValue:o,validate:t=>{let n=t.trim()||o,r=e.basename(n),i=Y(r);if(i)return i;if(n!==`.`){let t=e.resolve(process.cwd(),n);if(!t.startsWith(process.cwd()))return`Project path must be within current directory`}}});a(s)&&(t(g.red(`Operation cancelled.`)),process.exit(0)),i=s||o,r=!0}return i}function Z(e){let t=[];if(e.projectName&&t.push(`${g.blue(`Project Name:`)} ${e.projectName}`),e.frontend!==void 0){let n=Array.isArray(e.frontend)?e.frontend:[e.frontend],r=n.length>0&&n[0]!==void 0?n.join(`, `):`none`;t.push(`${g.blue(`Frontend:`)} ${r}`)}if(e.backend!==void 0&&t.push(`${g.blue(`Backend:`)} ${String(e.backend)}`),e.runtime!==void 0&&t.push(`${g.blue(`Runtime:`)} ${String(e.runtime)}`),e.api!==void 0&&t.push(`${g.blue(`API:`)} ${String(e.api)}`),e.database!==void 0&&t.push(`${g.blue(`Database:`)} ${String(e.database)}`),e.orm!==void 0&&t.push(`${g.blue(`ORM:`)} ${String(e.orm)}`),e.auth!==void 0){let n=typeof e.auth==`boolean`?e.auth?`Yes`:`No`:String(e.auth);t.push(`${g.blue(`Authentication:`)} ${n}`)}if(e.addons!==void 0){let n=Array.isArray(e.addons)?e.addons:[e.addons],r=n.length>0&&n[0]!==void 0?n.join(`, `):`none`;t.push(`${g.blue(`Addons:`)} ${r}`)}if(e.examples!==void 0){let n=Array.isArray(e.examples)?e.examples:[e.examples],r=n.length>0&&n[0]!==void 0?n.join(`, `):`none`;t.push(`${g.blue(`Examples:`)} ${r}`)}if(e.git!==void 0){let n=typeof e.git==`boolean`?e.git?`Yes`:`No`:String(e.git);t.push(`${g.blue(`Git Init:`)} ${n}`)}if(e.packageManager!==void 0&&t.push(`${g.blue(`Package Manager:`)} ${String(e.packageManager)}`),e.install!==void 0){let n=typeof e.install==`boolean`?e.install?`Yes`:`No`:String(e.install);t.push(`${g.blue(`Install Dependencies:`)} ${n}`)}return e.dbSetup!==void 0&&t.push(`${g.blue(`Database Setup:`)} ${String(e.dbSetup)}`),t.length===0?g.yellow(`No configuration selected.`):t.join(`
168
+ `)}function Mt(e){let t=[];e.frontend&&e.frontend.length>0?t.push(`--frontend ${e.frontend.join(` `)}`):t.push(`--frontend none`),t.push(`--backend ${e.backend}`),t.push(`--runtime ${e.runtime}`),t.push(`--database ${e.database}`),t.push(`--orm ${e.orm}`),t.push(`--api ${e.api}`),t.push(e.auth?`--auth`:`--no-auth`),e.addons&&e.addons.length>0?t.push(`--addons ${e.addons.join(` `)}`):t.push(`--addons none`),e.examples&&e.examples.length>0?t.push(`--examples ${e.examples.join(` `)}`):t.push(`--examples none`),t.push(`--db-setup ${e.dbSetup}`),t.push(e.git?`--git`:`--no-git`),t.push(`--package-manager ${e.packageManager}`),t.push(e.install?`--install`:`--no-install`);let n=``,r=e.packageManager;r===`npm`?n=`npx create-better-t-stack@latest`:r===`pnpm`?n=`pnpm create better-t-stack@latest`:r===`bun`&&(n=`bun create better-t-stack@latest`);let i=e.relativePath?` ${e.relativePath}`:``;return`${n}${i} ${t.join(` `)}`}const Nt=()=>{let t=e.join(k,`package.json`),n=h.readJSONSync(t);return n.version??`1.0.0`},Q=`
160
169
  ██████╗ ███████╗████████╗████████╗███████╗██████╗
161
170
  ██╔══██╗██╔════╝╚══██╔══╝╚══██╔══╝██╔════╝██╔══██╗
162
171
  ██████╔╝█████╗ ██║ ██║ █████╗ ██████╔╝
@@ -170,9 +179,9 @@ DATABASE_URL="your_connection_string"`)}async function Pe(n){let{projectName:r,p
170
179
  ██║ ╚════██║ ██║ ██╔══██║██║ ██╔═██╗
171
180
  ██║ ███████║ ██║ ██║ ██║╚██████╗██║ ██╗
172
181
  ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
173
- `,Q={pink:`#F5C2E7`,mauve:`#CBA6F7`,red:`#F38BA8`,maroon:`#E78284`,peach:`#FAB387`,yellow:`#F9E2AF`,green:`#A6E3A1`,teal:`#94E2D5`,sky:`#89DCEB`,sapphire:`#74C7EC`,lavender:`#B4BEFE`},kt=()=>{let e=process.stdout.columns||80,t=Z.split(`
182
+ `,Pt={pink:`#F5C2E7`,mauve:`#CBA6F7`,red:`#F38BA8`,maroon:`#E78284`,peach:`#FAB387`,yellow:`#F9E2AF`,green:`#A6E3A1`,teal:`#94E2D5`,sky:`#89DCEB`,sapphire:`#74C7EC`,lavender:`#B4BEFE`},Ft=()=>{let e=process.stdout.columns||80,t=Q.split(`
174
183
  `),n=Math.max(...t.map(e=>e.length));if(e<n){let e=`
175
184
  ╔══════════════════╗
176
185
  ║ Better T-Stack ║
177
186
  ╚══════════════════╝
178
- `;console.log(T(Object.values(Q)).multiline(e))}else console.log(T(Object.values(Q)).multiline(Z))},$=()=>process.exit(0);process.on(`SIGINT`,$),process.on(`SIGTERM`,$);async function At(){let n=Date.now();try{let r=await _(v(process.argv)).scriptName(`create-better-t-stack`).usage(`$0 [project-directory] [options]`,`Create a new Better-T Stack project`).positional(`project-directory`,{describe:`Project name/directory`,type:`string`}).option(`yes`,{alias:`y`,type:`boolean`,describe:`Use default configuration and skip prompts`,default:!1}).option(`database`,{type:`string`,describe:`Database type`,choices:[`none`,`sqlite`,`postgres`,`mysql`,`mongodb`]}).option(`orm`,{type:`string`,describe:`ORM type`,choices:[`drizzle`,`prisma`,`mongoose`,`none`]}).option(`auth`,{type:`boolean`,describe:`Include authentication (use --no-auth to exclude)`}).option(`frontend`,{type:`array`,string:!0,describe:`Frontend types`,choices:[`tanstack-router`,`react-router`,`tanstack-start`,`next`,`nuxt`,`native-nativewind`,`native-unistyles`,`svelte`,`solid`,`none`]}).option(`addons`,{type:`array`,string:!0,describe:`Additional addons`,choices:[`pwa`,`tauri`,`starlight`,`biome`,`husky`,`turborepo`,`none`]}).option(`examples`,{type:`array`,string:!0,describe:`Examples to include`,choices:[`todo`,`ai`,`none`]}).option(`git`,{type:`boolean`,describe:`Initialize git repository (use --no-git to skip)`}).option(`package-manager`,{alias:`pm`,type:`string`,describe:`Package manager`,choices:[`npm`,`pnpm`,`bun`]}).option(`install`,{type:`boolean`,describe:`Install dependencies (use --no-install to skip)`}).option(`db-setup`,{type:`string`,describe:`Database setup`,choices:[`turso`,`neon`,`prisma-postgres`,`mongodb-atlas`,`none`]}).option(`backend`,{type:`string`,describe:`Backend framework`,choices:[`hono`,`express`,`next`,`elysia`,`convex`,`none`]}).option(`runtime`,{type:`string`,describe:`Runtime`,choices:[`bun`,`node`,`none`]}).option(`api`,{type:`string`,describe:`API type`,choices:[`trpc`,`orpc`,`none`]}).completion().recommendCommands().version(Ot()).alias(`version`,`v`).help().alias(`help`,`h`).strict().wrap(null).parse(),s=r,l=s.projectDirectory;kt(),i(g.magenta(`Creating a new Better-T-Stack project`));let f,p,y,b,x=!1;if(s.yes&&l)f=l;else if(s.yes){let t=A.relativePath,n=1;for(;h.pathExistsSync(e.resolve(process.cwd(),t))&&h.readdirSync(e.resolve(process.cwd(),t)).length>0;)t=`${A.projectName}-${n}`,n++;f=t}else f=await Y(l);for(;;){let n=e.resolve(process.cwd(),f),r=h.pathExistsSync(n),i=r&&h.readdirSync(n).length>0;if(!i){p=f,x=!1;break}o.warn(`Directory "${g.yellow(f)}" already exists and is not empty.`);let s=await u({message:`What would you like to do?`,options:[{value:`overwrite`,label:`Overwrite`,hint:`Empty the directory and create the project`},{value:`merge`,label:`Merge`,hint:`Create project files inside, potentially overwriting conflicts`},{value:`rename`,label:`Choose a different name/path`,hint:`Keep the existing directory and create a new one`},{value:`cancel`,label:`Cancel`,hint:`Abort the process`}],initialValue:`rename`});if(a(s)&&(t(g.red(`Operation cancelled.`)),process.exit(0)),s===`overwrite`){p=f,x=!0;break}if(s===`merge`){p=f,x=!1,o.info(`Proceeding into existing directory "${g.yellow(f)}". Files may be overwritten.`);break}s===`rename`?(o.info(`Please choose a different project name or path.`),f=await Y(void 0)):s===`cancel`&&(t(g.red(`Operation cancelled.`)),process.exit(0))}if(p===`.`?(y=process.cwd(),b=e.basename(y)):(y=e.resolve(process.cwd(),p),b=e.basename(y)),x){let e=d();e.start(`Clearing directory "${y}"...`);try{await h.emptyDir(y),e.stop(`Directory "${y}" cleared.`)}catch(t){e.stop(g.red(`Failed to clear directory "${y}".`)),m.error(t),process.exit(1)}}else await h.ensureDir(y);let S=jt(s,b),{projectName:C,...w}=S;!s.yes&&Object.keys(w).length>0&&(o.info(g.yellow(`Using these pre-selected options:`)),o.message(X(w)),o.message(``));let T;s.yes?(T={...A,...S,projectName:b,projectDir:y,relativePath:p},T.backend===`convex`?(T.auth=!1,T.database=`none`,T.orm=`none`,T.api=`none`,T.runtime=`none`,T.dbSetup=`none`,T.examples=[`todo`],o.info(`Due to '--backend convex' flag, the following options have been automatically set: auth=false, database=none, orm=none, api=none, runtime=none, dbSetup=none, examples=todo`)):T.backend===`none`?(T.auth=!1,T.database=`none`,T.orm=`none`,T.api=`none`,T.runtime=`none`,T.dbSetup=`none`,T.examples=[],o.info(`Due to '--backend none', the following options have been automatically set: --auth=false, --database=none, --orm=none, --api=none, --runtime=none, --db-setup=none, --examples=none`)):T.database===`none`&&(T.orm=`none`,o.info(`Due to '--database none', '--orm' has been automatically set to 'none'.`),T.auth=!1,o.info(`Due to '--database none', '--auth' has been automatically set to 'false'.`),T.dbSetup=`none`,o.info(`Due to '--database none', '--db-setup' has been automatically set to 'none'.`)),o.info(g.yellow(`Using default/flag options (config prompts skipped):`)),o.message(X(T)),o.message(``)):T=await Tt(S,b,y,p),await dt(T),o.success(g.blue(`You can reproduce this setup with the following command:\n${Dt(T)}`));let E=((Date.now()-n)/1e3).toFixed(2);c(g.magenta(`Project created successfully in ${g.bold(E)} seconds!`))}catch(e){e instanceof Error?(e.name===`YError`?t(g.red(`Invalid arguments: ${e.message}`)):(m.error(`An unexpected error occurred: ${e.message}`),e.message.includes(`is only supported with`)||m.error(e.stack)),process.exit(1)):(m.error(`An unexpected error occurred.`),console.error(e),process.exit(1))}}function jt(t,n){let r={},i=new Set(Object.keys(t).filter(e=>e!==`_`&&e!==`$0`));if(t.api&&(r.api=t.api,t.api===`none`&&t.examples&&!(t.examples.length===1&&t.examples[0]===`none`)&&(m.fatal(`Cannot use '--examples' when '--api' is set to 'none'. Please remove the --examples flag or choose an API type.`),process.exit(1))),t.backend&&(r.backend=t.backend),i.has(`backend`)&&r.backend&&r.backend!==`convex`&&r.backend!==`none`&&i.has(`runtime`)&&t.runtime===`none`&&(m.fatal(`'--runtime none' is only supported with '--backend convex' or '--backend none'. Please choose 'bun', 'node', or remove the --runtime flag.`),process.exit(1)),t.database&&(r.database=t.database),t.orm&&(r.orm=t.orm),t.auth!==void 0&&(r.auth=t.auth),t.git!==void 0&&(r.git=t.git),t.install!==void 0&&(r.install=t.install),t.runtime&&(r.runtime=t.runtime),t.dbSetup&&(r.dbSetup=t.dbSetup),t.packageManager&&(r.packageManager=t.packageManager),n?r.projectName=n:t.projectDirectory&&(r.projectName=e.basename(e.resolve(process.cwd(),t.projectDirectory))),t.frontend&&t.frontend.length>0)if(t.frontend.includes(`none`))t.frontend.length>1&&(m.fatal(`Cannot combine 'none' with other frontend options.`),process.exit(1)),r.frontend=[];else{let e=t.frontend.filter(e=>e!==`none`),n=e.filter(e=>e===`tanstack-router`||e===`react-router`||e===`tanstack-start`||e===`next`||e===`nuxt`||e===`svelte`||e===`solid`),i=e.filter(e=>e===`native-nativewind`||e===`native-unistyles`);n.length>1&&(m.fatal(`Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router, next, nuxt, svelte, solid`),process.exit(1)),i.length>1&&(m.fatal(`Cannot select multiple native frameworks. Choose only one of: native-nativewind, native-unistyles`),process.exit(1)),r.frontend=e}if(t.addons&&t.addons.length>0&&(t.addons.includes(`none`)?(t.addons.length>1&&(m.fatal(`Cannot combine 'none' with other addons.`),process.exit(1)),r.addons=[]):r.addons=t.addons.filter(e=>e!==`none`)),t.examples&&t.examples.length>0&&(t.examples.includes(`none`)?(t.examples.length>1&&(m.fatal(`Cannot combine 'none' with other examples.`),process.exit(1)),r.examples=[]):(r.examples=t.examples.filter(e=>e!==`none`),t.examples.includes(`none`)&&r.backend!==`convex`&&(r.examples=[]))),r.backend===`convex`){let e=[];if(i.has(`auth`)&&t.auth===!0&&e.push(`--auth`),i.has(`database`)&&t.database!==`none`&&e.push(`--database ${t.database}`),i.has(`orm`)&&t.orm!==`none`&&e.push(`--orm ${t.orm}`),i.has(`api`)&&t.api!==`none`&&e.push(`--api ${t.api}`),i.has(`runtime`)&&t.runtime!==`none`&&e.push(`--runtime ${t.runtime}`),i.has(`dbSetup`)&&t.dbSetup!==`none`&&e.push(`--db-setup ${t.dbSetup}`),e.length>0&&(m.fatal(`The following flags are incompatible with '--backend convex': ${e.join(`, `)}. Please remove them.`),process.exit(1)),i.has(`frontend`)&&t.frontend){let e=t.frontend.filter(e=>e===`nuxt`||e===`solid`);e.length>0&&(m.fatal(`The following frontends are not compatible with '--backend convex': ${e.join(`, `)}. Please choose a different frontend or backend.`),process.exit(1))}r.auth=!1,r.database=`none`,r.orm=`none`,r.api=`none`,r.runtime=`none`,r.dbSetup=`none`,r.examples=[`todo`]}else if(r.backend===`none`){let e=[];i.has(`auth`)&&t.auth===!0&&e.push(`--auth`),i.has(`database`)&&t.database!==`none`&&e.push(`--database ${t.database}`),i.has(`orm`)&&t.orm!==`none`&&e.push(`--orm ${t.orm}`),i.has(`api`)&&t.api!==`none`&&e.push(`--api ${t.api}`),i.has(`runtime`)&&t.runtime!==`none`&&e.push(`--runtime ${t.runtime}`),i.has(`dbSetup`)&&t.dbSetup!==`none`&&e.push(`--db-setup ${t.dbSetup}`),e.length>0&&(m.fatal(`The following flags are incompatible with '--backend none': ${e.join(`, `)}. Please remove them.`),process.exit(1)),r.auth=!1,r.database=`none`,r.orm=`none`,r.api=`none`,r.runtime=`none`,r.dbSetup=`none`,t.examples&&!t.examples.includes(`none`)&&t.examples.length>0&&(m.fatal(`Cannot select examples when backend is 'none'. Please remove the --examples flag or set --examples none.`),process.exit(1)),r.examples=[],o.info(`Due to '--backend none', the following options have been automatically set: --auth=false, --database=none, --orm=none, --api=none, --runtime=none, --db-setup=none, --examples=none`)}else{let e=r.database??(t.yes?A.database:void 0),n=r.orm??(t.yes?A.orm:void 0),a=r.auth??(t.yes?A.auth:void 0),s=r.dbSetup??(t.yes?A.dbSetup:void 0),c=r.examples??(t.yes?A.examples:void 0),l=r.frontend??(t.yes?A.frontend:void 0),u=r.api??(t.yes?A.api:void 0),d=r.backend??(t.yes?A.backend:void 0);if(e===`none`&&(i.has(`orm`)&&t.orm!==`none`&&(m.fatal(`Cannot use ORM '--orm ${t.orm}' when database is 'none'.`),process.exit(1)),r.orm=`none`,o.info(`Due to '--database none', '--orm' has been automatically set to 'none'.`),i.has(`auth`)&&t.auth===!0&&(m.fatal(`Authentication requires a database. Cannot use --auth when database is 'none'.`),process.exit(1)),r.auth=!1,o.info(`Due to '--database none', '--auth' has been automatically set to 'false'.`),i.has(`dbSetup`)&&t.dbSetup!==`none`&&(m.fatal(`Database setup '--db-setup ${t.dbSetup}' requires a database. Cannot use when database is 'none'.`),process.exit(1)),r.dbSetup=`none`,o.info(`Due to '--database none', '--db-setup' has been automatically set to 'none'.`)),r.orm===`mongoose`&&!i.has(`database`)&&(e&&e!==`mongodb`&&(m.fatal(`Mongoose ORM requires MongoDB. Cannot use --orm mongoose with --database ${e}.`),process.exit(1)),r.database=`mongodb`),e===`mongodb`&&n===`drizzle`&&(m.fatal(`Drizzle ORM is not compatible with MongoDB. Please use --orm prisma or --orm mongoose.`),process.exit(1)),n===`mongoose`&&e&&e!==`mongodb`&&(m.fatal(`Mongoose ORM requires MongoDB. Cannot use --orm mongoose with --database ${e}.`),process.exit(1)),r.dbSetup&&r.dbSetup!==`none`){let t=r.dbSetup;(!e||e===`none`)&&(m.fatal(`Database setup '--db-setup ${t}' requires a database. Cannot use when database is 'none'.`),process.exit(1)),t===`turso`?(e&&e!==`sqlite`&&(m.fatal(`Turso setup requires SQLite. Cannot use --db-setup turso with --database ${e}`),process.exit(1)),n!==`drizzle`&&(m.fatal(`Turso setup requires Drizzle ORM. Cannot use --db-setup turso with --orm ${n??`none`}.`),process.exit(1))):t===`prisma-postgres`?(e!==`postgres`&&(m.fatal(`Prisma PostgreSQL setup requires PostgreSQL. Cannot use --db-setup prisma-postgres with --database ${e}.`),process.exit(1)),n!==`prisma`&&(m.fatal(`Prisma PostgreSQL setup requires Prisma ORM. Cannot use --db-setup prisma-postgres with --orm ${n}.`),process.exit(1))):t===`mongodb-atlas`?(e!==`mongodb`&&(m.fatal(`MongoDB Atlas setup requires MongoDB. Cannot use --db-setup mongodb-atlas with --database ${e}.`),process.exit(1)),n!==`prisma`&&n!==`mongoose`&&(m.fatal(`MongoDB Atlas setup requires Prisma or Mongoose ORM. Cannot use --db-setup mongodb-atlas with --orm ${n}.`),process.exit(1))):t===`neon`&&e!==`postgres`&&(m.fatal(`Neon PostgreSQL setup requires PostgreSQL. Cannot use --db-setup neon with --database ${e}.`),process.exit(1))}let f=l?.includes(`nuxt`),p=l?.includes(`svelte`),h=l?.includes(`solid`);if((f||p||h)&&u===`trpc`&&(m.fatal(`tRPC API is not supported with '${f?`nuxt`:p?`svelte`:`solid`}' frontend. Please use --api orpc or --api none or remove '${f?`nuxt`:p?`svelte`:`solid`}' from --frontend.`),process.exit(1)),r.addons&&r.addons.length>0){let e=[`pwa`,`tauri`],t=r.addons.some(t=>e.includes(t)),n=l?.some(e=>{let t=e===`tanstack-router`||e===`react-router`||e===`solid`,n=e===`tanstack-router`||e===`react-router`||e===`nuxt`||e===`svelte`||e===`solid`||e===`next`;return r.addons?.includes(`pwa`)&&r.addons?.includes(`tauri`)?t&&n:r.addons?.includes(`pwa`)?t:r.addons?.includes(`tauri`)?n:!0});if(t&&!n){let e=`Selected frontend is not compatible.`;r.addons.includes(`pwa`)&&(e=`PWA requires tanstack-router, react-router, or solid.`),r.addons.includes(`tauri`)&&(e=`Tauri requires tanstack-router, react-router, nuxt, svelte, solid, or next.`),m.fatal(`Incompatible addon/frontend combination: ${e}`),process.exit(1)}r.addons.includes(`husky`)&&!r.addons.includes(`biome`)&&m.warn(`Husky addon is recommended to be used with Biome for lint-staged configuration.`),r.addons=[...new Set(r.addons)]}let g=l&&l.length===1&&(l[0]===`native-nativewind`||l[0]===`native-unistyles`);g&&r.examples&&r.examples.length>0&&!r.examples.includes(`none`)&&(m.fatal(`Examples are not supported when only a native frontend (NativeWind or Unistyles) is selected.`),process.exit(1)),r.examples&&r.examples.length>0&&!r.examples.includes(`none`)&&(r.examples.includes(`todo`)&&d!==`convex`&&d!==`none`&&e===`none`&&(m.fatal(`The 'todo' example requires a database if a backend (other than Convex) is present. Cannot use --examples todo when database is 'none' and a backend is selected.`),process.exit(1)),r.examples.includes(`ai`)&&d===`elysia`&&(m.fatal(`The 'ai' example is not compatible with the Elysia backend.`),process.exit(1)),r.examples.includes(`ai`)&&h&&(m.fatal(`The 'ai' example is not compatible with the Solid frontend.`),process.exit(1)))}return r}At().catch(e=>{m.error(`Aborting installation due to unexpected error...`),e instanceof Error?!e.message.includes(`is only supported with`)&&!e.message.includes(`incompatible with`)&&!e.message.includes(`requires`)&&!e.message.includes(`Cannot use`)&&!e.message.includes(`Cannot select multiple`)&&!e.message.includes(`Cannot combine`)&&!e.message.includes(`not supported`)&&(m.error(e.message),m.error(e.stack)):console.error(e),process.exit(1)});
187
+ `;console.log(T(Object.values(Pt)).multiline(e))}else console.log(T(Object.values(Pt)).multiline(Q))},$=()=>process.exit(0);process.on(`SIGINT`,$),process.on(`SIGTERM`,$);async function It(){let n=Date.now();try{let r=await _(v(process.argv)).scriptName(`create-better-t-stack`).usage(`$0 [project-directory] [options]`,`Create a new Better-T Stack project`).positional(`project-directory`,{describe:`Project name/directory`,type:`string`}).option(`yes`,{alias:`y`,type:`boolean`,describe:`Use default configuration and skip prompts`,default:!1}).option(`database`,{type:`string`,describe:`Database type`,choices:[`none`,`sqlite`,`postgres`,`mysql`,`mongodb`]}).option(`orm`,{type:`string`,describe:`ORM type`,choices:[`drizzle`,`prisma`,`mongoose`,`none`]}).option(`auth`,{type:`boolean`,describe:`Include authentication (use --no-auth to exclude)`}).option(`frontend`,{type:`array`,string:!0,describe:`Frontend types`,choices:[`tanstack-router`,`react-router`,`tanstack-start`,`next`,`nuxt`,`native-nativewind`,`native-unistyles`,`svelte`,`solid`,`none`]}).option(`addons`,{type:`array`,string:!0,describe:`Additional addons`,choices:[`pwa`,`tauri`,`starlight`,`biome`,`husky`,`turborepo`,`none`]}).option(`examples`,{type:`array`,string:!0,describe:`Examples to include`,choices:[`todo`,`ai`,`none`]}).option(`git`,{type:`boolean`,describe:`Initialize git repository (use --no-git to skip)`}).option(`package-manager`,{alias:`pm`,type:`string`,describe:`Package manager`,choices:[`npm`,`pnpm`,`bun`]}).option(`install`,{type:`boolean`,describe:`Install dependencies (use --no-install to skip)`}).option(`db-setup`,{type:`string`,describe:`Database setup`,choices:[`turso`,`neon`,`prisma-postgres`,`mongodb-atlas`,`supabase`,`none`]}).option(`backend`,{type:`string`,describe:`Backend framework`,choices:[`hono`,`express`,`next`,`elysia`,`convex`,`none`]}).option(`runtime`,{type:`string`,describe:`Runtime`,choices:[`bun`,`node`,`none`]}).option(`api`,{type:`string`,describe:`API type`,choices:[`trpc`,`orpc`,`none`]}).completion().recommendCommands().version(Nt()).alias(`version`,`v`).help().alias(`help`,`h`).strict().wrap(null).parse(),s=r,l=s.projectDirectory;Ft(),i(g.magenta(`Creating a new Better-T-Stack project`));let f,p,y,b,x=!1;if(s.yes&&l)f=l;else if(s.yes){let t=A.relativePath,n=1;for(;h.pathExistsSync(e.resolve(process.cwd(),t))&&h.readdirSync(e.resolve(process.cwd(),t)).length>0;)t=`${A.projectName}-${n}`,n++;f=t}else f=await X(l);for(;;){let n=e.resolve(process.cwd(),f),r=h.pathExistsSync(n),i=r&&h.readdirSync(n).length>0;if(!i){p=f,x=!1;break}o.warn(`Directory "${g.yellow(f)}" already exists and is not empty.`);let s=await u({message:`What would you like to do?`,options:[{value:`overwrite`,label:`Overwrite`,hint:`Empty the directory and create the project`},{value:`merge`,label:`Merge`,hint:`Create project files inside, potentially overwriting conflicts`},{value:`rename`,label:`Choose a different name/path`,hint:`Keep the existing directory and create a new one`},{value:`cancel`,label:`Cancel`,hint:`Abort the process`}],initialValue:`rename`});if(a(s)&&(t(g.red(`Operation cancelled.`)),process.exit(0)),s===`overwrite`){p=f,x=!0;break}if(s===`merge`){p=f,x=!1,o.info(`Proceeding into existing directory "${g.yellow(f)}". Files may be overwritten.`);break}s===`rename`?(o.info(`Please choose a different project name or path.`),f=await X(void 0)):s===`cancel`&&(t(g.red(`Operation cancelled.`)),process.exit(0))}if(p===`.`?(y=process.cwd(),b=e.basename(y)):(y=e.resolve(process.cwd(),p),b=e.basename(y)),x){let e=d();e.start(`Clearing directory "${y}"...`);try{await h.emptyDir(y),e.stop(`Directory "${y}" cleared.`)}catch(t){e.stop(g.red(`Failed to clear directory "${y}".`)),m.error(t),process.exit(1)}}else await h.ensureDir(y);let S=Lt(s,b),{projectName:C,...w}=S;!s.yes&&Object.keys(w).length>0&&(o.info(g.yellow(`Using these pre-selected options:`)),o.message(Z(w)),o.message(``));let T;s.yes?(T={...A,...S,projectName:b,projectDir:y,relativePath:p},T.backend===`convex`?(T.auth=!1,T.database=`none`,T.orm=`none`,T.api=`none`,T.runtime=`none`,T.dbSetup=`none`,T.examples=[`todo`],o.info(`Due to '--backend convex' flag, the following options have been automatically set: auth=false, database=none, orm=none, api=none, runtime=none, dbSetup=none, examples=todo`)):T.backend===`none`?(T.auth=!1,T.database=`none`,T.orm=`none`,T.api=`none`,T.runtime=`none`,T.dbSetup=`none`,T.examples=[],o.info(`Due to '--backend none', the following options have been automatically set: --auth=false, --database=none, --orm=none, --api=none, --runtime=none, --db-setup=none, --examples=none`)):T.database===`none`&&(T.orm=`none`,o.info(`Due to '--database none', '--orm' has been automatically set to 'none'.`),T.auth=!1,o.info(`Due to '--database none', '--auth' has been automatically set to 'false'.`),T.dbSetup=`none`,o.info(`Due to '--database none', '--db-setup' has been automatically set to 'none'.`)),o.info(g.yellow(`Using default/flag options (config prompts skipped):`)),o.message(Z(T)),o.message(``)):T=await At(S,b,y,p),await gt(T),o.success(g.blue(`You can reproduce this setup with the following command:\n${Mt(T)}`));let E=((Date.now()-n)/1e3).toFixed(2);c(g.magenta(`Project created successfully in ${g.bold(E)} seconds!`))}catch(e){e instanceof Error?(e.name===`YError`?t(g.red(`Invalid arguments: ${e.message}`)):(m.error(`An unexpected error occurred: ${e.message}`),e.message.includes(`is only supported with`)||m.error(e.stack)),process.exit(1)):(m.error(`An unexpected error occurred.`),console.error(e),process.exit(1))}}function Lt(t,n){let r={},i=new Set(Object.keys(t).filter(e=>e!==`_`&&e!==`$0`));if(t.api&&(r.api=t.api,t.api===`none`&&t.examples&&!(t.examples.length===1&&t.examples[0]===`none`)&&(m.fatal(`Cannot use '--examples' when '--api' is set to 'none'. Please remove the --examples flag or choose an API type.`),process.exit(1))),t.backend&&(r.backend=t.backend),i.has(`backend`)&&r.backend&&r.backend!==`convex`&&r.backend!==`none`&&i.has(`runtime`)&&t.runtime===`none`&&(m.fatal(`'--runtime none' is only supported with '--backend convex' or '--backend none'. Please choose 'bun', 'node', or remove the --runtime flag.`),process.exit(1)),t.database&&(r.database=t.database),t.orm&&(r.orm=t.orm),t.auth!==void 0&&(r.auth=t.auth),t.git!==void 0&&(r.git=t.git),t.install!==void 0&&(r.install=t.install),t.runtime&&(r.runtime=t.runtime),t.dbSetup&&(r.dbSetup=t.dbSetup),t.packageManager&&(r.packageManager=t.packageManager),n?r.projectName=n:t.projectDirectory&&(r.projectName=e.basename(e.resolve(process.cwd(),t.projectDirectory))),t.frontend&&t.frontend.length>0)if(t.frontend.includes(`none`))t.frontend.length>1&&(m.fatal(`Cannot combine 'none' with other frontend options.`),process.exit(1)),r.frontend=[];else{let e=t.frontend.filter(e=>e!==`none`),n=e.filter(e=>e===`tanstack-router`||e===`react-router`||e===`tanstack-start`||e===`next`||e===`nuxt`||e===`svelte`||e===`solid`),i=e.filter(e=>e===`native-nativewind`||e===`native-unistyles`);n.length>1&&(m.fatal(`Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router, next, nuxt, svelte, solid`),process.exit(1)),i.length>1&&(m.fatal(`Cannot select multiple native frameworks. Choose only one of: native-nativewind, native-unistyles`),process.exit(1)),r.frontend=e}if(t.addons&&t.addons.length>0&&(t.addons.includes(`none`)?(t.addons.length>1&&(m.fatal(`Cannot combine 'none' with other addons.`),process.exit(1)),r.addons=[]):r.addons=t.addons.filter(e=>e!==`none`)),t.examples&&t.examples.length>0&&(t.examples.includes(`none`)?(t.examples.length>1&&(m.fatal(`Cannot combine 'none' with other examples.`),process.exit(1)),r.examples=[]):(r.examples=t.examples.filter(e=>e!==`none`),t.examples.includes(`none`)&&r.backend!==`convex`&&(r.examples=[]))),r.backend===`convex`){let e=[];if(i.has(`auth`)&&t.auth===!0&&e.push(`--auth`),i.has(`database`)&&t.database!==`none`&&e.push(`--database ${t.database}`),i.has(`orm`)&&t.orm!==`none`&&e.push(`--orm ${t.orm}`),i.has(`api`)&&t.api!==`none`&&e.push(`--api ${t.api}`),i.has(`runtime`)&&t.runtime!==`none`&&e.push(`--runtime ${t.runtime}`),i.has(`dbSetup`)&&t.dbSetup!==`none`&&e.push(`--db-setup ${t.dbSetup}`),e.length>0&&(m.fatal(`The following flags are incompatible with '--backend convex': ${e.join(`, `)}. Please remove them.`),process.exit(1)),i.has(`frontend`)&&t.frontend){let e=t.frontend.filter(e=>e===`nuxt`||e===`solid`);e.length>0&&(m.fatal(`The following frontends are not compatible with '--backend convex': ${e.join(`, `)}. Please choose a different frontend or backend.`),process.exit(1))}r.auth=!1,r.database=`none`,r.orm=`none`,r.api=`none`,r.runtime=`none`,r.dbSetup=`none`,r.examples=[`todo`]}else if(r.backend===`none`){let e=[];i.has(`auth`)&&t.auth===!0&&e.push(`--auth`),i.has(`database`)&&t.database!==`none`&&e.push(`--database ${t.database}`),i.has(`orm`)&&t.orm!==`none`&&e.push(`--orm ${t.orm}`),i.has(`api`)&&t.api!==`none`&&e.push(`--api ${t.api}`),i.has(`runtime`)&&t.runtime!==`none`&&e.push(`--runtime ${t.runtime}`),i.has(`dbSetup`)&&t.dbSetup!==`none`&&e.push(`--db-setup ${t.dbSetup}`),e.length>0&&(m.fatal(`The following flags are incompatible with '--backend none': ${e.join(`, `)}. Please remove them.`),process.exit(1)),r.auth=!1,r.database=`none`,r.orm=`none`,r.api=`none`,r.runtime=`none`,r.dbSetup=`none`,t.examples&&!t.examples.includes(`none`)&&t.examples.length>0&&(m.fatal(`Cannot select examples when backend is 'none'. Please remove the --examples flag or set --examples none.`),process.exit(1)),r.examples=[],o.info(`Due to '--backend none', the following options have been automatically set: --auth=false, --database=none, --orm=none, --api=none, --runtime=none, --db-setup=none, --examples=none`)}else{let e=r.database??(t.yes?A.database:void 0),n=r.orm??(t.yes?A.orm:void 0),a=r.auth??(t.yes?A.auth:void 0),s=r.dbSetup??(t.yes?A.dbSetup:void 0),c=r.examples??(t.yes?A.examples:void 0),l=r.frontend??(t.yes?A.frontend:void 0),u=r.api??(t.yes?A.api:void 0),d=r.backend??(t.yes?A.backend:void 0);if(e===`none`&&(i.has(`orm`)&&t.orm!==`none`&&(m.fatal(`Cannot use ORM '--orm ${t.orm}' when database is 'none'.`),process.exit(1)),r.orm=`none`,o.info(`Due to '--database none', '--orm' has been automatically set to 'none'.`),i.has(`auth`)&&t.auth===!0&&(m.fatal(`Authentication requires a database. Cannot use --auth when database is 'none'.`),process.exit(1)),r.auth=!1,o.info(`Due to '--database none', '--auth' has been automatically set to 'false'.`),i.has(`dbSetup`)&&t.dbSetup!==`none`&&(m.fatal(`Database setup '--db-setup ${t.dbSetup}' requires a database. Cannot use when database is 'none'.`),process.exit(1)),r.dbSetup=`none`,o.info(`Due to '--database none', '--db-setup' has been automatically set to 'none'.`)),r.orm===`mongoose`&&!i.has(`database`)&&(e&&e!==`mongodb`&&(m.fatal(`Mongoose ORM requires MongoDB. Cannot use --orm mongoose with --database ${e}.`),process.exit(1)),r.database=`mongodb`),e===`mongodb`&&n===`drizzle`&&(m.fatal(`Drizzle ORM is not compatible with MongoDB. Please use --orm prisma or --orm mongoose.`),process.exit(1)),n===`mongoose`&&e&&e!==`mongodb`&&(m.fatal(`Mongoose ORM requires MongoDB. Cannot use --orm mongoose with --database ${e}.`),process.exit(1)),r.dbSetup&&r.dbSetup!==`none`){let t=r.dbSetup;(!e||e===`none`)&&(m.fatal(`Database setup '--db-setup ${t}' requires a database. Cannot use when database is 'none'.`),process.exit(1)),t===`turso`?(e&&e!==`sqlite`&&(m.fatal(`Turso setup requires SQLite. Cannot use --db-setup turso with --database ${e}`),process.exit(1)),n!==`drizzle`&&(m.fatal(`Turso setup requires Drizzle ORM. Cannot use --db-setup turso with --orm ${n??`none`}.`),process.exit(1))):t===`supabase`?e!==`postgres`&&(m.fatal(`Supabase setup requires PostgreSQL. Cannot use --db-setup supabase with --database ${e}.`),process.exit(1)):t===`prisma-postgres`?(e!==`postgres`&&(m.fatal(`Prisma PostgreSQL setup requires PostgreSQL. Cannot use --db-setup prisma-postgres with --database ${e}.`),process.exit(1)),n!==`prisma`&&(m.fatal(`Prisma PostgreSQL setup requires Prisma ORM. Cannot use --db-setup prisma-postgres with --orm ${n}.`),process.exit(1))):t===`mongodb-atlas`?(e!==`mongodb`&&(m.fatal(`MongoDB Atlas setup requires MongoDB. Cannot use --db-setup mongodb-atlas with --database ${e}.`),process.exit(1)),n!==`prisma`&&n!==`mongoose`&&(m.fatal(`MongoDB Atlas setup requires Prisma or Mongoose ORM. Cannot use --db-setup mongodb-atlas with --orm ${n}.`),process.exit(1))):t===`neon`&&e!==`postgres`&&(m.fatal(`Neon PostgreSQL setup requires PostgreSQL. Cannot use --db-setup neon with --database ${e}.`),process.exit(1))}let f=l?.includes(`nuxt`),p=l?.includes(`svelte`),h=l?.includes(`solid`);if((f||p||h)&&u===`trpc`&&(m.fatal(`tRPC API is not supported with '${f?`nuxt`:p?`svelte`:`solid`}' frontend. Please use --api orpc or --api none or remove '${f?`nuxt`:p?`svelte`:`solid`}' from --frontend.`),process.exit(1)),r.addons&&r.addons.length>0){let e=[`pwa`,`tauri`],t=r.addons.some(t=>e.includes(t)),n=l?.some(e=>{let t=e===`tanstack-router`||e===`react-router`||e===`solid`,n=e===`tanstack-router`||e===`react-router`||e===`nuxt`||e===`svelte`||e===`solid`||e===`next`;return r.addons?.includes(`pwa`)&&r.addons?.includes(`tauri`)?t&&n:r.addons?.includes(`pwa`)?t:r.addons?.includes(`tauri`)?n:!0});if(t&&!n){let e=`Selected frontend is not compatible.`;r.addons.includes(`pwa`)&&(e=`PWA requires tanstack-router, react-router, or solid.`),r.addons.includes(`tauri`)&&(e=`Tauri requires tanstack-router, react-router, nuxt, svelte, solid, or next.`),m.fatal(`Incompatible addon/frontend combination: ${e}`),process.exit(1)}r.addons.includes(`husky`)&&!r.addons.includes(`biome`)&&m.warn(`Husky addon is recommended to be used with Biome for lint-staged configuration.`),r.addons=[...new Set(r.addons)]}let g=l&&l.length===1&&(l[0]===`native-nativewind`||l[0]===`native-unistyles`);g&&r.examples&&r.examples.length>0&&!r.examples.includes(`none`)&&(m.fatal(`Examples are not supported when only a native frontend (NativeWind or Unistyles) is selected.`),process.exit(1)),r.examples&&r.examples.length>0&&!r.examples.includes(`none`)&&(r.examples.includes(`todo`)&&d!==`convex`&&d!==`none`&&e===`none`&&(m.fatal(`The 'todo' example requires a database if a backend (other than Convex) is present. Cannot use --examples todo when database is 'none' and a backend is selected.`),process.exit(1)),r.examples.includes(`ai`)&&d===`elysia`&&(m.fatal(`The 'ai' example is not compatible with the Elysia backend.`),process.exit(1)),r.examples.includes(`ai`)&&h&&(m.fatal(`The 'ai' example is not compatible with the Solid frontend.`),process.exit(1)))}return r}It().catch(e=>{m.error(`Aborting installation due to unexpected error...`),e instanceof Error?!e.message.includes(`is only supported with`)&&!e.message.includes(`incompatible with`)&&!e.message.includes(`requires`)&&!e.message.includes(`Cannot use`)&&!e.message.includes(`Cannot select multiple`)&&!e.message.includes(`Cannot combine`)&&!e.message.includes(`not supported`)&&(m.error(e.message),m.error(e.stack)):console.error(e),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "2.9.9",
3
+ "version": "2.10.1",
4
4
  "description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,7 +8,8 @@
8
8
  "start": "next start"
9
9
  },
10
10
  "dependencies": {
11
- "next": "15.3.0"
11
+ "next": "15.3.0",
12
+ "dotenv": "^16.5.0"
12
13
  },
13
14
  "devDependencies": {
14
15
  "@types/node": "^20",
@@ -7,4 +7,7 @@ generator client {
7
7
  datasource db {
8
8
  provider = "postgres"
9
9
  url = env("DATABASE_URL")
10
+ {{#if (eq dbSetup "supabase")}}
11
+ directUrl = env("DIRECT_URL")
12
+ {{/if}}
10
13
  }
@@ -1,4 +1,4 @@
1
- import "dotenv/config";
1
+ // import "dotenv/config"; uncomment this to load .env
2
2
  import path from "node:path";
3
3
  import type { PrismaConfig } from "prisma";
4
4