mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
Add database setup scripts and fix navigation
This commit is contained in:
@@ -127,6 +127,22 @@ ${options.orm === "prisma" ? 'DATABASE_URL="file:./dev.db"' : ""}
|
||||
);
|
||||
await fs.writeFile(prismaAuthPath, authContent);
|
||||
}
|
||||
|
||||
const packageJsonPath = path.join(projectDir, "package.json");
|
||||
if (await fs.pathExists(packageJsonPath)) {
|
||||
const packageJson = await fs.readJson(packageJsonPath);
|
||||
|
||||
packageJson.scripts["prisma:generate"] =
|
||||
"cd packages/server && npx prisma generate";
|
||||
packageJson.scripts["prisma:push"] =
|
||||
"cd packages/server && npx prisma db push";
|
||||
packageJson.scripts["prisma:studio"] =
|
||||
"cd packages/server && npx prisma studio";
|
||||
packageJson.scripts["db:setup"] =
|
||||
"npm run auth:generate && npm run prisma:generate && npm run prisma:push";
|
||||
|
||||
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
||||
}
|
||||
} else if (options.orm === "drizzle") {
|
||||
const drizzleAuthPath = path.join(serverDir, "src/lib/auth.ts");
|
||||
const defaultDrizzleAuthPath = path.join(
|
||||
@@ -141,6 +157,18 @@ ${options.orm === "prisma" ? 'DATABASE_URL="file:./dev.db"' : ""}
|
||||
await fs.ensureDir(path.dirname(drizzleAuthPath));
|
||||
await fs.copy(defaultDrizzleAuthPath, drizzleAuthPath);
|
||||
}
|
||||
|
||||
const packageJsonPath = path.join(projectDir, "package.json");
|
||||
if (await fs.pathExists(packageJsonPath)) {
|
||||
const packageJson = await fs.readJson(packageJsonPath);
|
||||
|
||||
packageJson.scripts["db:push"] =
|
||||
"cd packages/server && npx @better-auth/cli migrate";
|
||||
packageJson.scripts["db:setup"] =
|
||||
"npm run auth:generate && npm run db:push";
|
||||
|
||||
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -151,11 +151,11 @@ ${packageManagerRunCmd} auth:generate
|
||||
? `Generate the Prisma client and push the schema:
|
||||
\`\`\`bash
|
||||
${packageManagerRunCmd} prisma:generate
|
||||
${packageManagerRunCmd} prisma:push
|
||||
${packageManagerRunCmd} db:push
|
||||
\`\`\``
|
||||
: `Apply the Drizzle migrations:
|
||||
\`\`\`bash
|
||||
${packageManagerRunCmd} drizzle:migrate
|
||||
${packageManagerRunCmd} db:push
|
||||
\`\`\``
|
||||
}
|
||||
`;
|
||||
@@ -183,7 +183,7 @@ function generateScriptsList(
|
||||
if (orm === "prisma") {
|
||||
scripts += `
|
||||
- \`${packageManagerRunCmd} prisma:generate\`: Generate Prisma client
|
||||
- \`${packageManagerRunCmd} prisma:push\`: Push schema changes to database
|
||||
- \`${packageManagerRunCmd} db:push\`: Push schema changes to database
|
||||
- \`${packageManagerRunCmd} prisma:studio\`: Open Prisma Studio`;
|
||||
} else if (orm === "drizzle") {
|
||||
scripts += `
|
||||
|
||||
@@ -19,21 +19,18 @@ export function displayPostInstallInstructions(
|
||||
}
|
||||
|
||||
if (hasAuth && database !== "none") {
|
||||
steps.push(`${pc.yellow("Authentication Setup:")}`);
|
||||
steps.push(
|
||||
`${pc.cyan("1.")} Generate auth schema: ${pc.green(`${runCmd} auth:generate`)}`,
|
||||
);
|
||||
steps.push(`${pc.yellow("Database Setup:")}`);
|
||||
|
||||
if (orm === "prisma") {
|
||||
steps.push(
|
||||
`${pc.cyan("2.")} Generate Prisma client: ${pc.green(`${runCmd} prisma:generate`)}`,
|
||||
`${pc.cyan("1.")} Generate Prisma client: ${pc.green(`${runCmd} prisma:generate`)}`,
|
||||
);
|
||||
steps.push(
|
||||
`${pc.cyan("3.")} Push schema to database: ${pc.green(`${runCmd} prisma:push`)}`,
|
||||
`${pc.cyan("2.")} Push schema to database: ${pc.green(`${runCmd} prisma:push`)}`,
|
||||
);
|
||||
} else if (orm === "drizzle") {
|
||||
steps.push(
|
||||
`${pc.cyan("2.")} Apply migrations: ${pc.green(`${runCmd} drizzle:migrate`)}`,
|
||||
`${pc.cyan("1.")} Apply migrations: ${pc.green(`${runCmd} db:push`)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function UserMenu() {
|
||||
className="w-full"
|
||||
onClick={() => {
|
||||
navigate({
|
||||
to: "/sign-in",
|
||||
to: "/",
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user