add cloudflare workers support (#326)

This commit is contained in:
Aman Varshney
2025-06-16 22:55:26 +05:30
committed by GitHub
parent 5fc1ba164e
commit b34e94a09e
34 changed files with 556 additions and 538 deletions

View File

@@ -1,11 +1,12 @@
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { Backend, Database } from "../types";
import type { Backend, Database, Runtime } from "../types";
export async function getDatabaseChoice(
database?: Database,
backend?: Backend,
runtime?: Runtime,
): Promise<Database> {
if (backend === "convex" || backend === "none") {
return "none";
@@ -13,35 +14,44 @@ export async function getDatabaseChoice(
if (database !== undefined) return database;
const databaseOptions: Array<{
value: Database;
label: string;
hint: string;
}> = [
{
value: "none",
label: "None",
hint: "No database setup",
},
{
value: "sqlite",
label: "SQLite",
hint: "lightweight, server-less, embedded relational database",
},
{
value: "postgres",
label: "PostgreSQL",
hint: "powerful, open source object-relational database system",
},
{
value: "mysql",
label: "MySQL",
hint: "popular open-source relational database system",
},
];
if (runtime !== "workers") {
databaseOptions.push({
value: "mongodb",
label: "MongoDB",
hint: "open-source NoSQL database that stores data in JSON-like documents called BSON",
});
}
const response = await select<Database>({
message: "Select database",
options: [
{
value: "none",
label: "None",
hint: "No database setup",
},
{
value: "sqlite",
label: "SQLite",
hint: "lightweight, server-less, embedded relational database",
},
{
value: "postgres",
label: "PostgreSQL",
hint: "powerful, open source object-relational database system",
},
{
value: "mysql",
label: "MySQL",
hint: "popular open-source relational database system",
},
{
value: "mongodb",
label: "MongoDB",
hint: "open-source NoSQL database that stores data in JSON-like documents called BSON",
},
],
options: databaseOptions,
initialValue: DEFAULT_CONFIG.database,
});