mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
Add setup warnings and handle no-ORM auth
This commit is contained in:
5
.changeset/stupid-cloths-pay.md
Normal file
5
.changeset/stupid-cloths-pay.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add setup warnings and handle no-ORM auth
|
||||||
@@ -43,6 +43,16 @@ export function displayPostInstallInstructions(
|
|||||||
const starlightInstructions = addons?.includes("starlight")
|
const starlightInstructions = addons?.includes("starlight")
|
||||||
? getStarlightInstructions(runCmd)
|
? getStarlightInstructions(runCmd)
|
||||||
: "";
|
: "";
|
||||||
|
const hasWeb = frontend?.some((f) =>
|
||||||
|
["tanstack-router", "react-router", "next", "tanstack-start"].includes(f),
|
||||||
|
);
|
||||||
|
const hasNative = frontend?.includes("native");
|
||||||
|
const bunWebNativeWarning =
|
||||||
|
packageManager === "bun" && hasNative && hasWeb
|
||||||
|
? getBunWebNativeWarning()
|
||||||
|
: "";
|
||||||
|
const noOrmWarning =
|
||||||
|
database !== "none" && orm === "none" ? getNoOrmWarning() : "";
|
||||||
|
|
||||||
const hasTanstackRouter = frontend?.includes("tanstack-router");
|
const hasTanstackRouter = frontend?.includes("tanstack-router");
|
||||||
const hasTanstackStart = frontend?.includes("tanstack-start");
|
const hasTanstackStart = frontend?.includes("tanstack-start");
|
||||||
@@ -83,7 +93,7 @@ ${
|
|||||||
lintingInstructions ? `\n${lintingInstructions.trim()}` : ""
|
lintingInstructions ? `\n${lintingInstructions.trim()}` : ""
|
||||||
}${pwaInstructions ? `\n${pwaInstructions.trim()}` : ""}${
|
}${pwaInstructions ? `\n${pwaInstructions.trim()}` : ""}${
|
||||||
starlightInstructions ? `\n${starlightInstructions.trim()}` : ""
|
starlightInstructions ? `\n${starlightInstructions.trim()}` : ""
|
||||||
}
|
}${noOrmWarning ? `\n${noOrmWarning.trim()}` : ""}${bunWebNativeWarning ? `\n${bunWebNativeWarning.trim()}` : ""}
|
||||||
|
|
||||||
${pc.bold("Update all dependencies:\n")}${pc.cyan(tazeCommand)}
|
${pc.bold("Update all dependencies:\n")}${pc.cyan(tazeCommand)}
|
||||||
|
|
||||||
@@ -165,3 +175,11 @@ function getStarlightInstructions(runCmd?: string): string {
|
|||||||
"•",
|
"•",
|
||||||
)} Build docs site: ${`cd apps/docs && ${runCmd} build`}\n`;
|
)} Build docs site: ${`cd apps/docs && ${runCmd} build`}\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNoOrmWarning(): string {
|
||||||
|
return `\n${pc.yellow("WARNING:")} Database selected without an ORM. Features requiring database access (e.g., examples, auth) need manual setup.\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBunWebNativeWarning(): string {
|
||||||
|
return `\n${pc.yellow("WARNING:")} 'bun' might cause issues with web + native apps in a monorepo. Use 'pnpm' if problems arise.\n`;
|
||||||
|
}
|
||||||
|
|||||||
@@ -519,14 +519,23 @@ export async function handleExtras(
|
|||||||
context: ProjectConfig,
|
context: ProjectConfig,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (context.packageManager === "pnpm") {
|
if (context.packageManager === "pnpm") {
|
||||||
const src = path.join(PKG_ROOT, "templates/extras/pnpm-workspace.yaml");
|
const pnpmWorkspaceSrc = path.join(
|
||||||
const dest = path.join(projectDir, "pnpm-workspace.yaml");
|
PKG_ROOT,
|
||||||
if (await fs.pathExists(src)) {
|
"templates/extras/pnpm-workspace.yaml",
|
||||||
await fs.copy(src, dest);
|
);
|
||||||
|
const pnpmWorkspaceDest = path.join(projectDir, "pnpm-workspace.yaml");
|
||||||
|
if (await fs.pathExists(pnpmWorkspaceSrc)) {
|
||||||
|
await fs.copy(pnpmWorkspaceSrc, pnpmWorkspaceDest);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.frontend.includes("native")) {
|
||||||
|
const npmrcSrc = path.join(PKG_ROOT, "templates/extras/.npmrc");
|
||||||
|
const npmrcDest = path.join(projectDir, ".npmrc");
|
||||||
|
if (await fs.pathExists(npmrcSrc)) {
|
||||||
|
await fs.copy(npmrcSrc, npmrcDest);
|
||||||
} else {
|
} else {
|
||||||
consola.warn(
|
|
||||||
pc.yellow("Warning: pnpm-workspace.yaml template not found."),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
import { betterAuth } from "better-auth";
|
|
||||||
|
|
||||||
{{#if (eq orm "prisma")}}
|
{{#if (eq orm "prisma")}}
|
||||||
|
import { betterAuth } from "better-auth";
|
||||||
import { prismaAdapter } from "better-auth/adapters/prisma";
|
import { prismaAdapter } from "better-auth/adapters/prisma";
|
||||||
import prisma from "../../prisma";
|
import prisma from "../../prisma";
|
||||||
|
|
||||||
export const auth = betterAuth({
|
export const auth = betterAuth({
|
||||||
database: prismaAdapter(prisma, {
|
database: prismaAdapter(prisma, {
|
||||||
provider: "{{database}}"
|
{{#if (eq database "postgres")}}provider: "postgresql"{{/if}}
|
||||||
|
{{#if (eq database "sqlite")}}provider: "sqlite"{{/if}}
|
||||||
|
{{#if (eq database "mysql")}}provider: "mysql"{{/if}}
|
||||||
}),
|
}),
|
||||||
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
||||||
emailAndPassword: { enabled: true }
|
emailAndPassword: { enabled: true }
|
||||||
});
|
});
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{else if (eq orm "drizzle")}}
|
{{#if (eq orm "drizzle")}}
|
||||||
|
import { betterAuth } from "better-auth";
|
||||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import * as schema from "../db/schema/auth";
|
import * as schema from "../db/schema/auth";
|
||||||
|
|
||||||
export const auth = betterAuth({
|
export const auth = betterAuth({
|
||||||
database: drizzleAdapter(db, {
|
database: drizzleAdapter(db, {
|
||||||
{{#if (eq database "postgresql")}}provider: "pg",{{/if}}
|
{{#if (eq database "postgres")}}provider: "pg",{{/if}}
|
||||||
{{#if (eq database "sqlite")}}provider: "sqlite",{{/if}}
|
{{#if (eq database "sqlite")}}provider: "sqlite",{{/if}}
|
||||||
{{#if (eq database "mysql")}}provider: "mysql",{{/if}}
|
{{#if (eq database "mysql")}}provider: "mysql",{{/if}}
|
||||||
schema: schema
|
schema: schema
|
||||||
@@ -28,3 +31,13 @@ export const auth = betterAuth({
|
|||||||
emailAndPassword: { enabled: true }
|
emailAndPassword: { enabled: true }
|
||||||
});
|
});
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (eq orm "none")}}
|
||||||
|
import { betterAuth } from "better-auth";
|
||||||
|
|
||||||
|
export const auth = betterAuth({
|
||||||
|
database: "",
|
||||||
|
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
||||||
|
emailAndPassword: { enabled: true }
|
||||||
|
});
|
||||||
|
{{/if}}
|
||||||
|
|||||||
Reference in New Issue
Block a user