make backend optional

This commit is contained in:
Aman Varshney
2025-05-07 08:31:54 +05:30
parent af1e8efbdc
commit d09a284ce7
11 changed files with 116 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
import { cancel, isCancel, log, select } from "@clack/prompts";
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { ProjectApi, ProjectBackend, ProjectFrontend } from "../types";
@@ -8,7 +8,7 @@ export async function getApiChoice(
frontend?: ProjectFrontend[],
backend?: ProjectBackend,
): Promise<ProjectApi> {
if (backend === "convex") {
if (backend === "convex" || backend === "none") {
return "none";
}

View File

@@ -48,6 +48,13 @@ export async function getBackendFrameworkChoice(
});
}
// Add "None" option
backendOptions.push({
value: "none" as const,
label: "None",
hint: "No backend server (e.g., for a static site or client-only app)",
});
let initialValue = DEFAULT_CONFIG.backend;
if (hasIncompatibleFrontend && initialValue === "convex") {
initialValue = "hono";

View File

@@ -106,6 +106,16 @@ export async function gatherConfig(
result.dbSetup = "none";
}
if (result.backend === "none") {
result.runtime = "none";
result.database = "none";
result.orm = "none";
result.api = "none";
result.auth = false;
result.dbSetup = "none";
result.examples = [];
}
return {
projectName: projectName,
projectDir: projectDir,

View File

@@ -1,4 +1,4 @@
import { cancel, isCancel, log, select } from "@clack/prompts";
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { ProjectBackend, ProjectDatabase } from "../types";
@@ -7,7 +7,7 @@ export async function getDatabaseChoice(
database?: ProjectDatabase,
backend?: ProjectBackend,
): Promise<ProjectDatabase> {
if (backend === "convex") {
if (backend === "convex" || backend === "none") {
return "none";
}

View File

@@ -1,4 +1,4 @@
import { cancel, isCancel, log, multiselect } from "@clack/prompts";
import { cancel, isCancel, multiselect } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type {
@@ -20,6 +20,10 @@ export async function getExamplesChoice(
return ["todo"];
}
if (backend === "none") {
return [];
}
if (database === "none") return [];
const onlyNative =

View File

@@ -1,4 +1,4 @@
import { cancel, isCancel, log, select } from "@clack/prompts";
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { ProjectBackend, ProjectRuntime } from "../types";
@@ -7,7 +7,7 @@ export async function getRuntimeChoice(
runtime?: ProjectRuntime,
backend?: ProjectBackend,
): Promise<ProjectRuntime> {
if (backend === "convex") {
if (backend === "convex" || backend === "none") {
return "none";
}