Files
create-better-t-stack/apps/cli/src/prompts/orm.ts
2025-03-29 15:13:57 +05:30

37 lines
816 B
TypeScript

import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { ProjectOrm } from "../types";
export async function getORMChoice(
orm: ProjectOrm | undefined,
hasDatabase: boolean,
): Promise<ProjectOrm> {
if (!hasDatabase) return "none";
if (orm !== undefined) return orm;
const response = await select<ProjectOrm>({
message: "Which ORM would you like to use?",
options: [
{
value: "drizzle",
label: "Drizzle",
hint: "Type-safe, lightweight ORM",
},
{
value: "prisma",
label: "Prisma",
hint: "Powerful, feature-rich ORM",
},
],
initialValue: DEFAULT_CONFIG.orm,
});
if (isCancel(response)) {
cancel(pc.red("Operation cancelled"));
process.exit(0);
}
return response;
}