@better-t-stack/template-generator 3.31.0 → 3.31.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.mjs CHANGED
@@ -393,7 +393,7 @@ function getDbScriptSupport(config) {
393
393
  };
394
394
  return {
395
395
  hasDbScripts: true,
396
- hasDbPush: true,
396
+ hasDbPush: !isD1Alchemy,
397
397
  hasDbGenerate: true,
398
398
  hasDbMigrate: config.orm === "prisma" || config.orm === "drizzle" && !isD1Alchemy,
399
399
  hasDbStudio: !isD1Alchemy,
@@ -466,7 +466,7 @@ function updateRootPackageJson(vfs, config) {
466
466
  if (backend !== "self" && backend !== "none") scripts["dev:server"] = pmConfig.filter(backendPackageName, "dev");
467
467
  if (backend === "convex") scripts["dev:setup"] = pmConfig.filter(backendPackageName, "dev:setup");
468
468
  if (needsDbScripts) {
469
- scripts["db:push"] = pmConfig.filter(dbPackageName, "db:push");
469
+ if (dbSupport.hasDbPush) scripts["db:push"] = pmConfig.filter(dbPackageName, "db:push");
470
470
  if (!isD1Alchemy) scripts["db:studio"] = pmConfig.filter(dbPackageName, "db:studio");
471
471
  if (orm === "prisma") {
472
472
  scripts["db:generate"] = pmConfig.filter(dbPackageName, "db:generate");
@@ -588,17 +588,18 @@ function updateDbPackageJson(vfs, config) {
588
588
  pkgJson.scripts = pkgJson.scripts || {};
589
589
  const scripts = pkgJson.scripts;
590
590
  const { database, orm, dbSetup } = config;
591
- const { isD1Alchemy } = getDbScriptSupport(config);
591
+ const dbSupport = getDbScriptSupport(config);
592
+ const { isD1Alchemy } = dbSupport;
592
593
  if (database !== "none") {
593
594
  if (database === "sqlite" && dbSetup !== "d1") scripts["db:local"] = "turso dev --db-file local.db";
594
595
  if (orm === "prisma") {
595
- scripts["db:push"] = "prisma db push";
596
+ if (dbSupport.hasDbPush) scripts["db:push"] = "prisma db push";
596
597
  scripts["db:generate"] = "prisma generate";
597
598
  scripts["db:migrate"] = "prisma migrate dev";
598
599
  scripts.postinstall ??= "prisma generate";
599
600
  if (!isD1Alchemy) scripts["db:studio"] = "prisma studio";
600
601
  } else if (orm === "drizzle") {
601
- scripts["db:push"] = "drizzle-kit push";
602
+ if (dbSupport.hasDbPush) scripts["db:push"] = "drizzle-kit push";
602
603
  scripts["db:generate"] = "drizzle-kit generate";
603
604
  if (!isD1Alchemy) {
604
605
  scripts["db:studio"] = "drizzle-kit studio";
@@ -2835,7 +2836,7 @@ function processReadme(vfs, config) {
2835
2836
  vfs.writeFile("README.md", content);
2836
2837
  }
2837
2838
  function generateReadmeContent(options) {
2838
- const { projectName, packageManager, database, auth, addons = [], orm = "drizzle", runtime = "bun", frontend = ["tanstack-router"], backend = "hono", api = "trpc", webDeploy, serverDeploy } = options;
2839
+ const { projectName, packageManager, database, auth, addons = [], orm = "drizzle", runtime = "bun", frontend = ["tanstack-router"], backend = "hono", api = "trpc", dbSetup, webDeploy, serverDeploy } = options;
2839
2840
  const isConvex = backend === "convex";
2840
2841
  const hasReactRouter = frontend.includes("react-router");
2841
2842
  const hasTanStackRouter = frontend.includes("tanstack-router");
@@ -2857,7 +2858,7 @@ This project was created with [Better-T-Stack](https://github.com/AmanVarshney01
2857
2858
 
2858
2859
  ## Features
2859
2860
 
2860
- ${generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api)}
2861
+ ${generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api, dbSetup)}
2861
2862
 
2862
2863
  ## Getting Started
2863
2864
 
@@ -3031,7 +3032,7 @@ function generateProjectStructure(config) {
3031
3032
  }
3032
3033
  return structure.join("\n");
3033
3034
  }
3034
- function generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api) {
3035
+ function generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api, dbSetup) {
3035
3036
  const isConvex = backend === "convex";
3036
3037
  const hasNative = hasNativeFrontend(frontend);
3037
3038
  const hasAppWebFrontend = hasWebFrontend(frontend);
@@ -3074,16 +3075,20 @@ function generateFeaturesList(database, auth, addons, orm, runtime, frontend, ba
3074
3075
  const runtimeName = runtime === "bun" ? "Bun" : runtime === "node" ? "Node.js" : runtime;
3075
3076
  features.push(`- **${runtimeName}** - Runtime environment`);
3076
3077
  }
3077
- if (database !== "none" && !isConvex) features.push(`- **${{
3078
- drizzle: "Drizzle",
3079
- prisma: "Prisma",
3080
- mongoose: "Mongoose"
3081
- }[orm] || "ORM"}** - TypeScript-first ORM`, `- **${{
3082
- sqlite: "SQLite/Turso",
3083
- postgres: "PostgreSQL",
3084
- mysql: "MySQL",
3085
- mongodb: "MongoDB"
3086
- }[database] || "Database"}** - Database engine`);
3078
+ if (database !== "none" && !isConvex) {
3079
+ const ormNames = {
3080
+ drizzle: "Drizzle",
3081
+ prisma: "Prisma",
3082
+ mongoose: "Mongoose"
3083
+ };
3084
+ const dbNames = {
3085
+ sqlite: dbSetup === "d1" ? "Cloudflare D1" : "SQLite/Turso",
3086
+ postgres: "PostgreSQL",
3087
+ mysql: "MySQL",
3088
+ mongodb: "MongoDB"
3089
+ };
3090
+ features.push(`- **${ormNames[orm] || "ORM"}** - TypeScript-first ORM`, `- **${dbNames[database] || "Database"}** - Database engine`);
3091
+ }
3087
3092
  if (auth !== "none") {
3088
3093
  const authLabel = auth === "clerk" ? "Clerk" : "Better-Auth";
3089
3094
  features.push(`- **Authentication** - ${authLabel}`);
@@ -3114,7 +3119,27 @@ function generateDatabaseSetup(config, packageManagerRunCmd) {
3114
3119
  none: "ORM"
3115
3120
  }[orm] || orm}`;
3116
3121
  const dbSupport = getDbScriptSupport(config);
3122
+ const isD1Alchemy = dbSupport.isD1Alchemy;
3117
3123
  let setup = "## Database Setup\n\n";
3124
+ if (isD1Alchemy) {
3125
+ const steps = [];
3126
+ if (dbSupport.hasDbGenerate) steps.push(`${steps.length + 1}. ${orm === "prisma" ? "Generate the Prisma client" : "Generate migration files"}:
3127
+ \`\`\`bash
3128
+ ${packageManagerRunCmd} db:generate
3129
+ \`\`\``);
3130
+ if (dbSupport.hasDbMigrate) steps.push(`${steps.length + 1}. Create and apply Prisma migrations locally:
3131
+ \`\`\`bash
3132
+ ${packageManagerRunCmd} db:migrate
3133
+ \`\`\``);
3134
+ return `${setup}This project uses Cloudflare D1 (SQLite)${ormDesc}.
3135
+
3136
+ Runtime database access uses the Cloudflare \`DB\` binding from \`packages/infra/alchemy.run.ts\`. If a local \`DATABASE_URL\` is present, it is only for database tooling.
3137
+
3138
+ Alchemy provisions the D1 database and applies migrations during \`dev\` and \`deploy\`.
3139
+
3140
+ ${steps.join("\n\n")}
3141
+ `;
3142
+ }
3118
3143
  const dbDescriptions = {
3119
3144
  sqlite: `This project uses SQLite${ormDesc}.
3120
3145
 
@@ -3170,7 +3195,7 @@ function generateScriptsList(packageManagerRunCmd, config, hasNative) {
3170
3195
  scripts += `\n- \`${packageManagerRunCmd} check-types\`: Check TypeScript types across all apps`;
3171
3196
  if (hasNative) scripts += `\n- \`${packageManagerRunCmd} dev:native\`: Start the React Native/Expo development server`;
3172
3197
  if (dbSupport.hasDbScripts) {
3173
- scripts += `\n- \`${packageManagerRunCmd} db:push\`: Push schema changes to database`;
3198
+ if (dbSupport.hasDbPush) scripts += `\n- \`${packageManagerRunCmd} db:push\`: Push schema changes to database`;
3174
3199
  if (dbSupport.hasDbGenerate) scripts += `\n- \`${packageManagerRunCmd} db:generate\`: Generate database client/types`;
3175
3200
  if (dbSupport.hasDbMigrate) scripts += `\n- \`${packageManagerRunCmd} db:migrate\`: Run database migrations`;
3176
3201
  if (dbSupport.hasDbStudio) scripts += `\n- \`${packageManagerRunCmd} db:studio\`: Open database studio UI`;
@@ -3282,7 +3307,7 @@ function generateTurboConfig(config) {
3282
3307
  }
3283
3308
  function getBaseTasks(frontend) {
3284
3309
  const buildOutputs = ["dist/**"];
3285
- if (frontend.includes("next")) buildOutputs.push(".next/**");
3310
+ if (frontend.includes("next")) buildOutputs.push(".next/**", "!.next/cache/**");
3286
3311
  if (frontend.includes("nuxt")) buildOutputs.push(".nuxt/**", ".output/**");
3287
3312
  if (frontend.includes("svelte")) buildOutputs.push(".svelte-kit/**", "build/**");
3288
3313
  if (frontend.includes("astro")) buildOutputs.push(".astro/**");