feat: add mysql database

This commit is contained in:
Aman Varshney
2025-04-09 11:54:01 +05:30
parent 3cd9f31e01
commit c9b7e25e1d
25 changed files with 607 additions and 518 deletions

View File

@@ -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(

View File

@@ -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",

View File

@@ -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" },
];