organize code

This commit is contained in:
Aman Varshney
2025-02-20 19:14:28 +05:30
parent 9032a598d0
commit f804a9efda
16 changed files with 451 additions and 282 deletions

View File

@@ -0,0 +1,38 @@
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import type { ProjectDatabase } from "../types";
export async function getDatabaseChoice(
database?: ProjectDatabase,
): Promise<ProjectDatabase> {
if (database !== undefined) return database;
const response = await select<ProjectDatabase>({
message: "Which database would you like to use?",
options: [
{
value: "none",
label: "None",
hint: "No database setup",
},
{
value: "sqlite",
label: "SQLite",
hint: "by Turso (recommended)",
},
{
value: "postgres",
label: "PostgreSQL",
hint: "Traditional relational database",
},
],
initialValue: "sqlite",
});
if (isCancel(response)) {
cancel(pc.red("Operation cancelled"));
process.exit(0);
}
return response;
}