mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
organize code
This commit is contained in:
38
apps/cli/src/prompts/database.ts
Normal file
38
apps/cli/src/prompts/database.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user