@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
44 lines (43 loc) • 1.17 kB
JavaScript
import { re } from "@reliverse/relico";
import { cancel, isCancel, select } from "@reliverse/rempts";
import { DEFAULT_CONFIG } from "../constants.js";
const ormOptions = {
prisma: {
value: "prisma",
label: "Prisma",
hint: "Powerful, feature-rich ORM"
},
mongoose: {
value: "mongoose",
label: "Mongoose",
hint: "Elegant object modeling tool"
},
drizzle: {
value: "drizzle",
label: "Drizzle",
hint: "Lightweight and performant TypeScript ORM"
}
};
export async function getORMChoice(orm, hasDatabase, database, backend, runtime) {
if (backend === "convex") {
return "none";
}
if (!hasDatabase) return "none";
if (orm !== void 0) return orm;
if (runtime === "workers") {
return "drizzle";
}
const options = [
...database === "mongodb" ? [ormOptions.prisma, ormOptions.mongoose] : [ormOptions.drizzle, ormOptions.prisma]
];
const response = await select({
message: "Select ORM",
options,
initialValue: database === "mongodb" ? "prisma" : DEFAULT_CONFIG.orm
});
if (isCancel(response)) {
cancel(re.red("Operation cancelled"));
process.exit(0);
}
return response;
}