@reliverse/rse-sdk
Version:
@reliverse/rse-sdk without cli. @reliverse/rse-sdk allows you to create new plugins for @reliverse/rse CLI, interact with reliverse.org, and even extend your own CLI functionality (you may also try @reliverse/dler-sdk for this case).
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;
}