mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat(cli): prisma + workers, prisma + turso, planetscale (postgres/mysql) support (#567)
This commit is contained in:
@@ -5,7 +5,7 @@ import { exitCancelled } from "../utils/errors";
|
||||
export async function getDBSetupChoice(
|
||||
databaseType: string,
|
||||
dbSetup: DatabaseSetup | undefined,
|
||||
orm?: ORM,
|
||||
_orm?: ORM,
|
||||
backend?: Backend,
|
||||
runtime?: Runtime,
|
||||
): Promise<DatabaseSetup> {
|
||||
@@ -19,10 +19,6 @@ export async function getDBSetupChoice(
|
||||
return "none";
|
||||
}
|
||||
|
||||
if (databaseType === "sqlite" && orm === "prisma") {
|
||||
return "none";
|
||||
}
|
||||
|
||||
let options: Array<{ value: DatabaseSetup; label: string; hint: string }> =
|
||||
[];
|
||||
|
||||
@@ -51,6 +47,11 @@ export async function getDBSetupChoice(
|
||||
label: "Neon Postgres",
|
||||
hint: "Serverless Postgres with branching capability",
|
||||
},
|
||||
{
|
||||
value: "planetscale" as const,
|
||||
label: "PlanetScale",
|
||||
hint: "Serverless MySQL platform with branching (Postgres compatible)",
|
||||
},
|
||||
{
|
||||
value: "supabase" as const,
|
||||
label: "Supabase",
|
||||
@@ -70,6 +71,11 @@ export async function getDBSetupChoice(
|
||||
];
|
||||
} else if (databaseType === "mysql") {
|
||||
options = [
|
||||
{
|
||||
value: "planetscale" as const,
|
||||
label: "PlanetScale",
|
||||
hint: "Serverless MySQL platform with branching",
|
||||
},
|
||||
{
|
||||
value: "docker" as const,
|
||||
label: "Docker",
|
||||
|
||||
@@ -35,10 +35,6 @@ export async function getORMChoice(
|
||||
if (!hasDatabase) return "none";
|
||||
if (orm !== undefined) return orm;
|
||||
|
||||
if (runtime === "workers") {
|
||||
return "drizzle";
|
||||
}
|
||||
|
||||
const options = [
|
||||
...(database === "mongodb"
|
||||
? [ormOptions.prisma, ormOptions.mongoose]
|
||||
@@ -48,7 +44,12 @@ export async function getORMChoice(
|
||||
const response = await select<ORM>({
|
||||
message: "Select ORM",
|
||||
options,
|
||||
initialValue: database === "mongodb" ? "prisma" : DEFAULT_CONFIG.orm,
|
||||
initialValue:
|
||||
database === "mongodb"
|
||||
? "prisma"
|
||||
: runtime === "workers"
|
||||
? "drizzle"
|
||||
: DEFAULT_CONFIG.orm,
|
||||
});
|
||||
|
||||
if (isCancel(response)) return exitCancelled("Operation cancelled");
|
||||
|
||||
@@ -47,10 +47,7 @@ export async function getDeploymentChoice(
|
||||
return "none";
|
||||
}
|
||||
|
||||
const hasIncompatibleFrontend = frontend.some((f) => f === "next");
|
||||
const availableDeployments = hasIncompatibleFrontend
|
||||
? ["wrangler", "none"]
|
||||
: ["wrangler", "alchemy", "none"];
|
||||
const availableDeployments = ["wrangler", "alchemy", "none"];
|
||||
|
||||
const options: DeploymentOption[] = availableDeployments.map((deploy) => {
|
||||
const { label, hint } = getDeploymentDisplay(deploy as WebDeploy);
|
||||
@@ -64,9 +61,7 @@ export async function getDeploymentChoice(
|
||||
const response = await select<WebDeploy>({
|
||||
message: "Select web deployment",
|
||||
options,
|
||||
initialValue: hasIncompatibleFrontend
|
||||
? "wrangler"
|
||||
: DEFAULT_CONFIG.webDeploy,
|
||||
initialValue: DEFAULT_CONFIG.webDeploy,
|
||||
});
|
||||
|
||||
if (isCancel(response)) return exitCancelled("Operation cancelled");
|
||||
@@ -82,8 +77,6 @@ export async function getDeploymentToAdd(
|
||||
return "none";
|
||||
}
|
||||
|
||||
const hasIncompatibleFrontend = frontend.some((f) => f === "next");
|
||||
|
||||
const options: DeploymentOption[] = [];
|
||||
|
||||
if (existingDeployment !== "wrangler") {
|
||||
@@ -95,7 +88,7 @@ export async function getDeploymentToAdd(
|
||||
});
|
||||
}
|
||||
|
||||
if (existingDeployment !== "alchemy" && !hasIncompatibleFrontend) {
|
||||
if (existingDeployment !== "alchemy") {
|
||||
const { label, hint } = getDeploymentDisplay("alchemy");
|
||||
options.push({
|
||||
value: "alchemy",
|
||||
@@ -123,9 +116,7 @@ export async function getDeploymentToAdd(
|
||||
const response = await select<WebDeploy>({
|
||||
message: "Select web deployment",
|
||||
options,
|
||||
initialValue: hasIncompatibleFrontend
|
||||
? "wrangler"
|
||||
: DEFAULT_CONFIG.webDeploy,
|
||||
initialValue: DEFAULT_CONFIG.webDeploy,
|
||||
});
|
||||
|
||||
if (isCancel(response)) return exitCancelled("Operation cancelled");
|
||||
|
||||
Reference in New Issue
Block a user