@reliverse/rse-sdk
Version:
@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).
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;
}