create-better-t-stack 2.46.3-canary.a2097c5b → 2.46.3-canary.f7f132c8

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-C8eRIOI8.js";
2
+ import { createBtsCli } from "./src-FqipJoqR.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-C8eRIOI8.js";
2
+ import { builder, createBtsCli, docs, init, router, sponsors } from "./src-FqipJoqR.js";
3
3
 
4
4
  export { builder, createBtsCli, docs, init, router, sponsors };
@@ -611,30 +611,30 @@ async function getApiChoice(Api, frontend, backend) {
611
611
  async function getAuthChoice(auth, hasDatabase, backend, frontend) {
612
612
  if (auth !== void 0) return auth;
613
613
  if (backend === "convex") {
614
- const unsupportedFrontends = frontend?.filter((f) => [
615
- "nuxt",
616
- "svelte",
617
- "solid",
618
- "native-nativewind",
619
- "native-unistyles"
614
+ const supportedBetterAuthFrontends = frontend?.some((f) => [
615
+ "tanstack-router",
616
+ "tanstack-start",
617
+ "next"
620
618
  ].includes(f));
621
- if (unsupportedFrontends && unsupportedFrontends.length > 0) return "none";
622
- const hasReactFrontends = frontend?.some((f) => [
619
+ const hasClerkCompatibleFrontends = frontend?.some((f) => [
623
620
  "react-router",
624
621
  "tanstack-router",
625
622
  "tanstack-start",
626
- "next"
623
+ "next",
624
+ "native-nativewind",
625
+ "native-unistyles"
627
626
  ].includes(f));
628
- const options = [{
629
- value: "clerk",
630
- label: "Clerk",
631
- hint: "More than auth, Complete User Management"
632
- }];
633
- if (hasReactFrontends) options.unshift({
627
+ const options = [];
628
+ if (supportedBetterAuthFrontends) options.push({
634
629
  value: "better-auth",
635
630
  label: "Better-Auth",
636
631
  hint: "comprehensive auth framework for TypeScript"
637
632
  });
633
+ if (hasClerkCompatibleFrontends) options.push({
634
+ value: "clerk",
635
+ label: "Clerk",
636
+ hint: "More than auth, Complete User Management"
637
+ });
638
638
  options.push({
639
639
  value: "none",
640
640
  label: "None",
@@ -1750,14 +1750,13 @@ function validateConvexConstraints(config, providedFlags) {
1750
1750
  if (has("dbSetup") && config.dbSetup !== "none") exitWithError("Convex backend requires '--db-setup none'. Please remove the --db-setup flag or set it to 'none'.");
1751
1751
  if (has("serverDeploy") && config.serverDeploy !== "none") exitWithError("Convex backend requires '--server-deploy none'. Please remove the --server-deploy flag or set it to 'none'.");
1752
1752
  if (has("auth") && config.auth === "better-auth") {
1753
- const hasUnsupportedFrontends = config.frontend?.some((f) => [
1754
- "nuxt",
1755
- "svelte",
1756
- "solid",
1757
- "native-nativewind",
1758
- "native-unistyles"
1759
- ].includes(f));
1760
- if (hasUnsupportedFrontends) exitWithError("Better-Auth with Convex backend is not supported for non-React frontends (nuxt, svelte, solid) or native frontends (native-nativewind, native-unistyles). Please use '--auth clerk' or '--auth none'.");
1753
+ const supportedFrontends = [
1754
+ "tanstack-router",
1755
+ "tanstack-start",
1756
+ "next"
1757
+ ];
1758
+ const hasSupportedFrontend = config.frontend?.some((f) => supportedFrontends.includes(f));
1759
+ if (!hasSupportedFrontend) exitWithError("Better-Auth with Convex backend is only supported with TanStack Router, TanStack Start, or Next.js frontends. Please use '--auth clerk' or '--auth none'.");
1761
1760
  }
1762
1761
  }
1763
1762
  function validateBackendNoneConstraints(config, providedFlags) {
@@ -4384,7 +4383,7 @@ async function addEnvVariablesToFile(filePath, variables) {
4384
4383
  let modified = false;
4385
4384
  let contentToAdd = "";
4386
4385
  const exampleVariables = [];
4387
- for (const { key, value, condition } of variables) if (condition) {
4386
+ for (const { key, value, condition, comment } of variables) if (condition) {
4388
4387
  const regex = new RegExp(`^${key}=.*$`, "m");
4389
4388
  const valueToWrite = value ?? "";
4390
4389
  exampleVariables.push(`${key}=`);
@@ -4395,6 +4394,7 @@ async function addEnvVariablesToFile(filePath, variables) {
4395
4394
  modified = true;
4396
4395
  }
4397
4396
  } else {
4397
+ if (comment) contentToAdd += `# ${comment}\n`;
4398
4398
  contentToAdd += `${key}=${valueToWrite}\n`;
4399
4399
  modified = true;
4400
4400
  }
@@ -4521,16 +4521,26 @@ async function setupEnvironmentVariables(config) {
4521
4521
  if (auth === "better-auth") {
4522
4522
  const convexBackendDir = path.join(projectDir, "packages/backend");
4523
4523
  if (await fs.pathExists(convexBackendDir)) {
4524
+ const envLocalPath = path.join(convexBackendDir, ".env.local");
4525
+ if (!await fs.pathExists(envLocalPath) || !(await fs.readFile(envLocalPath, "utf8")).includes("npx convex env set")) {
4526
+ const convexCommands = `# Set Convex environment variables
4527
+ npx convex env set BETTER_AUTH_SECRET=$(openssl rand -base64 32)
4528
+ npx convex env set SITE_URL http://localhost:3001
4529
+
4530
+ `;
4531
+ await fs.appendFile(envLocalPath, convexCommands);
4532
+ }
4524
4533
  const convexBackendVars = [{
4525
- key: hasTanStackStart ? "NEXT_PUBLIC_CONVEX_SITE_URL" : "VITE_CONVEX_SITE_URL",
4534
+ key: hasNextJs ? "NEXT_PUBLIC_CONVEX_SITE_URL" : "VITE_CONVEX_SITE_URL",
4526
4535
  value: "",
4527
- condition: true
4536
+ condition: true,
4537
+ comment: "Same as CONVEX_URL but ends in .site"
4528
4538
  }, {
4529
4539
  key: "SITE_URL",
4530
4540
  value: "http://localhost:3001",
4531
4541
  condition: true
4532
4542
  }];
4533
- await addEnvVariablesToFile(path.join(convexBackendDir, ".env.local"), convexBackendVars);
4543
+ await addEnvVariablesToFile(envLocalPath, convexBackendVars);
4534
4544
  }
4535
4545
  }
4536
4546
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "2.46.3-canary.a2097c5b",
3
+ "version": "2.46.3-canary.f7f132c8",
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",
@@ -1,5 +1,5 @@
1
1
  import { createClient, type GenericCtx } from "@convex-dev/better-auth";
2
- {{#if (or (eq frontend "tanstack-start") (eq frontend "next"))}}
2
+ {{#if (or (includes frontend "tanstack-start") (includes frontend "next"))}}
3
3
  import { convex } from "@convex-dev/better-auth/plugins";
4
4
  {{else}}
5
5
  import { convex, crossDomain } from "@convex-dev/better-auth/plugins";
@@ -21,7 +21,7 @@ export const createAuth = (
21
21
  logger: {
22
22
  disabled: optionsOnly,
23
23
  },
24
- {{#if (or (eq frontend "tanstack-start") (eq frontend "next"))}}
24
+ {{#if (or (includes frontend "tanstack-start") (includes frontend "next"))}}
25
25
  baseUrl: siteUrl,
26
26
  {{else}}
27
27
  trustedOrigins: [siteUrl],
@@ -32,7 +32,7 @@ export const createAuth = (
32
32
  requireEmailVerification: false,
33
33
  },
34
34
  plugins: [
35
- {{#unless (or (eq frontend "tanstack-start") (eq frontend "next"))}}
35
+ {{#unless (or (includes frontend "tanstack-start") (includes frontend "next"))}}
36
36
  crossDomain({ siteUrl }),
37
37
  {{/unless}}
38
38
  convex(),
@@ -3,7 +3,7 @@ import { authComponent, createAuth } from "./auth";
3
3
 
4
4
  const http = httpRouter();
5
5
 
6
- {{#if (or (eq frontend "tanstack-start") (eq frontend "next"))}}
6
+ {{#if (or (includes frontend "tanstack-start") (includes frontend "next"))}}
7
7
  authComponent.registerRoutes(http, createAuth);
8
8
  {{else}}
9
9
  authComponent.registerRoutes(http, createAuth, { cors: true });