mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat: add mysql database
This commit is contained in:
@@ -45,27 +45,6 @@ type PromptGroupResults = {
|
||||
export async function gatherConfig(
|
||||
flags: Partial<ProjectConfig>,
|
||||
): Promise<ProjectConfig> {
|
||||
if (flags.dbSetup) {
|
||||
if (flags.dbSetup === "turso") {
|
||||
flags.database = "sqlite";
|
||||
|
||||
if (flags.orm === "prisma") {
|
||||
log.warn(
|
||||
pc.yellow(
|
||||
"Turso is not compatible with Prisma - switching to Drizzle",
|
||||
),
|
||||
);
|
||||
flags.orm = "drizzle";
|
||||
}
|
||||
} else if (flags.dbSetup === "prisma-postgres") {
|
||||
flags.database = "postgres";
|
||||
flags.orm = "prisma";
|
||||
} else if (flags.dbSetup === "mongodb-atlas") {
|
||||
flags.database = "mongodb";
|
||||
flags.orm = "prisma";
|
||||
}
|
||||
}
|
||||
|
||||
const result = await group<PromptGroupResults>(
|
||||
{
|
||||
projectName: async () => {
|
||||
@@ -84,7 +63,11 @@ export async function gatherConfig(
|
||||
results.frontend,
|
||||
),
|
||||
dbSetup: ({ results }) =>
|
||||
getDBSetupChoice(results.database ?? "none", flags.dbSetup),
|
||||
getDBSetupChoice(
|
||||
results.database ?? "none",
|
||||
flags.dbSetup,
|
||||
results.orm,
|
||||
),
|
||||
addons: ({ results }) => getAddonsChoice(flags.addons, results.frontend),
|
||||
examples: ({ results }) =>
|
||||
getExamplesChoice(
|
||||
|
||||
@@ -26,6 +26,11 @@ export async function getDatabaseChoice(
|
||||
label: "PostgreSQL",
|
||||
hint: "powerful, open source object-relational database system",
|
||||
},
|
||||
{
|
||||
value: "mysql",
|
||||
label: "MySQL",
|
||||
hint: "popular open-source relational database system",
|
||||
},
|
||||
{
|
||||
value: "mongodb",
|
||||
label: "MongoDB",
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import { cancel, isCancel, select } from "@clack/prompts";
|
||||
import pc from "picocolors";
|
||||
import type { ProjectDBSetup } from "../types";
|
||||
import type { ProjectDBSetup, ProjectOrm } from "../types";
|
||||
|
||||
export async function getDBSetupChoice(
|
||||
databaseType: string,
|
||||
dbSetup: ProjectDBSetup | undefined,
|
||||
orm?: ProjectOrm,
|
||||
): Promise<ProjectDBSetup> {
|
||||
if (dbSetup !== undefined) return dbSetup as ProjectDBSetup;
|
||||
|
||||
if (databaseType === "sqlite" && orm === "prisma") {
|
||||
return "none";
|
||||
}
|
||||
|
||||
let options: Array<{ value: ProjectDBSetup; label: string; hint: string }> =
|
||||
[];
|
||||
|
||||
@@ -16,7 +21,7 @@ export async function getDBSetupChoice(
|
||||
{
|
||||
value: "turso" as const,
|
||||
label: "Turso",
|
||||
hint: "SQLite for Production. Powered by libSQL.",
|
||||
hint: "SQLite for Production. Powered by libSQL",
|
||||
},
|
||||
{ value: "none" as const, label: "None", hint: "Manual setup" },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user