create-better-t-stack 2.39.0 → 2.40.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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createBtsCli } from "./src-DV2p8gsC.js";
2
+ import { createBtsCli } from "./src-DCgC3MR2.js";
3
3
 
4
4
  //#region src/cli.ts
5
5
  createBtsCli().run();
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { builder, createBtsCli, docs, init, router, sponsors } from "./src-DV2p8gsC.js";
2
+ import { builder, createBtsCli, docs, init, router, sponsors } from "./src-DCgC3MR2.js";
3
3
 
4
4
  export { builder, createBtsCli, docs, init, router, sponsors };
@@ -1233,23 +1233,6 @@ async function gatherConfig(flags, projectName, projectDir, relativePath) {
1233
1233
  packageManager: () => getPackageManagerChoice(flags.packageManager),
1234
1234
  install: () => getinstallChoice(flags.install)
1235
1235
  }, { onCancel: () => exitCancelled("Operation cancelled") });
1236
- if (result.backend === "convex") {
1237
- result.runtime = "none";
1238
- result.database = "none";
1239
- result.orm = "none";
1240
- result.api = "none";
1241
- result.dbSetup = "none";
1242
- result.examples = ["todo"];
1243
- }
1244
- if (result.backend === "none") {
1245
- result.runtime = "none";
1246
- result.database = "none";
1247
- result.orm = "none";
1248
- result.api = "none";
1249
- result.auth = "none";
1250
- result.dbSetup = "none";
1251
- result.examples = [];
1252
- }
1253
1236
  return {
1254
1237
  projectName,
1255
1238
  projectDir,
@@ -1694,6 +1677,30 @@ function validateDatabaseSetup(config, providedFlags) {
1694
1677
  }
1695
1678
  }
1696
1679
  }
1680
+ function validateConvexConstraints(config, providedFlags) {
1681
+ const { backend } = config;
1682
+ if (backend !== "convex") return;
1683
+ const has = (k) => providedFlags.has(k);
1684
+ if (has("runtime") && config.runtime !== "none") exitWithError("Convex backend requires '--runtime none'. Please remove the --runtime flag or set it to 'none'.");
1685
+ if (has("database") && config.database !== "none") exitWithError("Convex backend requires '--database none'. Please remove the --database flag or set it to 'none'.");
1686
+ if (has("orm") && config.orm !== "none") exitWithError("Convex backend requires '--orm none'. Please remove the --orm flag or set it to 'none'.");
1687
+ if (has("api") && config.api !== "none") exitWithError("Convex backend requires '--api none'. Please remove the --api flag or set it to 'none'.");
1688
+ if (has("dbSetup") && config.dbSetup !== "none") exitWithError("Convex backend requires '--db-setup none'. Please remove the --db-setup flag or set it to 'none'.");
1689
+ if (has("serverDeploy") && config.serverDeploy !== "none") exitWithError("Convex backend requires '--server-deploy none'. Please remove the --server-deploy flag or set it to 'none'.");
1690
+ if (has("auth") && config.auth === "better-auth") exitWithError("Better-Auth is not compatible with Convex backend. Please use '--auth clerk' or '--auth none'.");
1691
+ }
1692
+ function validateBackendNoneConstraints(config, providedFlags) {
1693
+ const { backend } = config;
1694
+ if (backend !== "none") return;
1695
+ const has = (k) => providedFlags.has(k);
1696
+ if (has("runtime") && config.runtime !== "none") exitWithError("Backend 'none' requires '--runtime none'. Please remove the --runtime flag or set it to 'none'.");
1697
+ if (has("database") && config.database !== "none") exitWithError("Backend 'none' requires '--database none'. Please remove the --database flag or set it to 'none'.");
1698
+ if (has("orm") && config.orm !== "none") exitWithError("Backend 'none' requires '--orm none'. Please remove the --orm flag or set it to 'none'.");
1699
+ if (has("api") && config.api !== "none") exitWithError("Backend 'none' requires '--api none'. Please remove the --api flag or set it to 'none'.");
1700
+ if (has("auth") && config.auth !== "none") exitWithError("Backend 'none' requires '--auth none'. Please remove the --auth flag or set it to 'none'.");
1701
+ if (has("dbSetup") && config.dbSetup !== "none") exitWithError("Backend 'none' requires '--db-setup none'. Please remove the --db-setup flag or set it to 'none'.");
1702
+ if (has("serverDeploy") && config.serverDeploy !== "none") exitWithError("Backend 'none' requires '--server-deploy none'. Please remove the --server-deploy flag or set it to 'none'.");
1703
+ }
1697
1704
  function validateBackendConstraints(config, providedFlags, options) {
1698
1705
  const { backend } = config;
1699
1706
  if (config.auth === "clerk" && backend !== "convex") exitWithError("Clerk authentication is only supported with the Convex backend. Please use '--backend convex' or choose a different auth provider.");
@@ -1705,7 +1712,6 @@ function validateBackendConstraints(config, providedFlags, options) {
1705
1712
  ].includes(f));
1706
1713
  if (incompatibleFrontends.length > 0) exitWithError(`Clerk authentication is not compatible with the following frontends: ${incompatibleFrontends.join(", ")}. Please choose a different frontend or auth provider.`);
1707
1714
  }
1708
- if (backend === "convex" && config.auth === "better-auth" && providedFlags.has("auth")) exitWithError("Better-Auth is not compatible with the Convex backend. Please use '--auth clerk' or '--auth none'.");
1709
1715
  if (providedFlags.has("backend") && backend && backend !== "convex" && backend !== "none") {
1710
1716
  if (providedFlags.has("runtime") && options.runtime === "none") exitWithError("'--runtime none' is only supported with '--backend convex' or '--backend none'. Please choose 'bun', 'node', or remove the --runtime flag.");
1711
1717
  }
@@ -1731,6 +1737,8 @@ function validateApiConstraints(config, options) {
1731
1737
  function validateFullConfig(config, providedFlags, options) {
1732
1738
  validateDatabaseOrmAuth(config, providedFlags);
1733
1739
  validateDatabaseSetup(config, providedFlags);
1740
+ validateConvexConstraints(config, providedFlags);
1741
+ validateBackendNoneConstraints(config, providedFlags);
1734
1742
  validateBackendConstraints(config, providedFlags, options);
1735
1743
  validateFrontendConstraints(config, providedFlags);
1736
1744
  validateApiConstraints(config, options);
@@ -4697,25 +4705,61 @@ async function setupNeonPostgres(config) {
4697
4705
 
4698
4706
  //#endregion
4699
4707
  //#region src/helpers/database-providers/prisma-postgres-setup.ts
4708
+ const AVAILABLE_REGIONS = [
4709
+ {
4710
+ value: "ap-southeast-1",
4711
+ label: "Asia Pacific (Singapore)"
4712
+ },
4713
+ {
4714
+ value: "ap-northeast-1",
4715
+ label: "Asia Pacific (Tokyo)"
4716
+ },
4717
+ {
4718
+ value: "eu-central-1",
4719
+ label: "Europe (Frankfurt)"
4720
+ },
4721
+ {
4722
+ value: "eu-west-3",
4723
+ label: "Europe (Paris)"
4724
+ },
4725
+ {
4726
+ value: "us-east-1",
4727
+ label: "US East (N. Virginia)"
4728
+ },
4729
+ {
4730
+ value: "us-west-1",
4731
+ label: "US West (N. California)"
4732
+ }
4733
+ ];
4700
4734
  async function setupWithCreateDb(serverDir, packageManager, orm) {
4701
4735
  try {
4702
- log.info("Starting Prisma Postgres setup. Please follow the instructions below:");
4703
- const createDbCommand = getPackageExecutionCommand(packageManager, "create-db@latest -i");
4704
- await execa(createDbCommand, {
4736
+ log.info("Starting Prisma Postgres setup with create-db. Please follow the instructions below:");
4737
+ const selectedRegion = await select({
4738
+ message: "Select your preferred region:",
4739
+ options: AVAILABLE_REGIONS,
4740
+ initialValue: "ap-southeast-1"
4741
+ });
4742
+ if (isCancel(selectedRegion)) return null;
4743
+ const createDbCommand = getPackageExecutionCommand(packageManager, `create-db@latest --json --region ${selectedRegion}`);
4744
+ const s = spinner();
4745
+ s.start("Creating Prisma Postgres database...");
4746
+ const { stdout } = await execa(createDbCommand, {
4705
4747
  cwd: serverDir,
4706
- stdio: "inherit",
4707
4748
  shell: true
4708
4749
  });
4709
- log.info(orm === "drizzle" ? pc.yellow("Please copy the database URL from the output above and append ?sslmode=require for Drizzle.") : pc.yellow("Please copy the Prisma Postgres URL from the output above."));
4710
- const databaseUrl = await text({
4711
- message: orm === "drizzle" ? "Paste your database URL (append ?sslmode=require for Drizzle):" : "Paste your Prisma Postgres database URL:",
4712
- validate(value) {
4713
- if (!value) return "Please enter a database URL";
4714
- if (orm === "drizzle" && !value.includes("?sslmode=require")) return "Please append ?sslmode=require to your database URL when using Drizzle";
4715
- }
4716
- });
4717
- if (isCancel(databaseUrl)) return null;
4718
- return { databaseUrl };
4750
+ s.stop("Database created successfully!");
4751
+ let createDbResponse;
4752
+ try {
4753
+ createDbResponse = JSON.parse(stdout);
4754
+ } catch {
4755
+ consola$1.error("Failed to parse create-db response");
4756
+ return null;
4757
+ }
4758
+ const databaseUrl = orm === "drizzle" ? createDbResponse.directConnectionString : createDbResponse.connectionString;
4759
+ return {
4760
+ databaseUrl,
4761
+ claimUrl: createDbResponse.claimUrl
4762
+ };
4719
4763
  } catch (error) {
4720
4764
  if (error instanceof Error) consola$1.error(error.message);
4721
4765
  return null;
@@ -4755,6 +4799,11 @@ async function writeEnvFile$1(projectDir, config) {
4755
4799
  value: config?.databaseUrl ?? "postgresql://postgres:postgres@localhost:5432/mydb?schema=public",
4756
4800
  condition: true
4757
4801
  }];
4802
+ if (config?.claimUrl) variables.push({
4803
+ key: "CLAIM_URL",
4804
+ value: config.claimUrl,
4805
+ condition: true
4806
+ });
4758
4807
  await addEnvVariablesToFile(envPath, variables);
4759
4808
  } catch (_error) {
4760
4809
  consola$1.error("Failed to update environment configuration");
@@ -4841,7 +4890,9 @@ async function setupPrismaPostgres(config) {
4841
4890
  await addDotenvImportToPrismaConfig(projectDir);
4842
4891
  await addPrismaAccelerateExtension(serverDir);
4843
4892
  }
4844
- log.success(pc.green("Prisma Postgres database configured successfully!"));
4893
+ const connectionType = orm === "drizzle" ? "direct connection" : "Prisma Accelerate";
4894
+ log.success(pc.green(`Prisma Postgres database configured successfully with ${connectionType}!`));
4895
+ if (prismaConfig.claimUrl) log.info(pc.blue(`Claim URL saved to .env: ${prismaConfig.claimUrl}`));
4845
4896
  } else {
4846
4897
  await writeEnvFile$1(projectDir);
4847
4898
  displayManualSetupInstructions$1();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "2.39.0",
3
+ "version": "2.40.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",