@reliverse/rse
Version:
@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power
68 lines (67 loc) • 1.8 kB
JavaScript
import { re } from "@reliverse/relico";
import { cancel, isCancel, select } from "@reliverse/rempts";
export async function getDBSetupChoice(databaseType, dbSetup, orm, backend) {
if (backend === "convex") {
return "none";
}
if (dbSetup !== void 0) return dbSetup;
if (databaseType === "none") {
return "none";
}
if (databaseType === "sqlite" && orm === "prisma") {
return "none";
}
let options = [];
if (databaseType === "sqlite") {
options = [
{
value: "turso",
label: "Turso",
hint: "SQLite for Production. Powered by libSQL"
},
{ value: "none", label: "None", hint: "Manual setup" }
];
} else if (databaseType === "postgres") {
options = [
{
value: "neon",
label: "Neon Postgres",
hint: "Serverless Postgres with branching capability"
},
{
value: "supabase",
label: "Supabase",
hint: "Local Supabase stack (requires Docker)"
},
...orm === "prisma" ? [
{
value: "prisma-postgres",
label: "Prisma Postgres",
hint: "Instant Postgres for Global Applications"
}
] : [],
{ value: "none", label: "None", hint: "Manual setup" }
];
} else if (databaseType === "mongodb") {
options = [
{
value: "mongodb-atlas",
label: "MongoDB Atlas",
hint: "The most effective way to deploy MongoDB"
},
{ value: "none", label: "None", hint: "Manual setup" }
];
} else {
return "none";
}
const response = await select({
message: `Select ${databaseType} setup option`,
options,
initialValue: "none"
});
if (isCancel(response)) {
cancel(re.red("Operation cancelled"));
process.exit(0);
}
return response;
}