fix(cli): improve flags handling (#552)

This commit is contained in:
Aman Varshney
2025-08-29 10:24:00 +05:30
committed by GitHub
parent d7a3904b1e
commit ea32eb649d
8 changed files with 880 additions and 2142 deletions

View File

@@ -133,72 +133,6 @@ export function validateWorkersCompatibility(
}
}
export function coerceBackendPresets(config: Partial<ProjectConfig>) {
if (config.backend === "convex") {
config.database = "none";
config.orm = "none";
config.api = "none";
config.runtime = "none";
config.dbSetup = "none";
config.examples = ["todo"] as ProjectConfig["examples"];
}
if (config.backend === "none") {
config.auth = "none" as ProjectConfig["auth"];
config.database = "none";
config.orm = "none";
config.api = "none";
config.runtime = "none";
config.dbSetup = "none";
config.examples = [] as ProjectConfig["examples"];
}
}
export function incompatibleFlagsForBackend(
backend: ProjectConfig["backend"] | undefined,
providedFlags: Set<string>,
options: CLIInput,
): string[] {
const list: string[] = [];
if (backend === "convex") {
if (
providedFlags.has("auth") &&
options.auth &&
options.auth !== "none" &&
options.auth !== "clerk"
)
list.push(`--auth ${options.auth}`);
if (providedFlags.has("database") && options.database !== "none")
list.push(`--database ${options.database}`);
if (providedFlags.has("orm") && options.orm !== "none")
list.push(`--orm ${options.orm}`);
if (providedFlags.has("api") && options.api !== "none")
list.push(`--api ${options.api}`);
if (providedFlags.has("runtime") && options.runtime !== "none")
list.push(`--runtime ${options.runtime}`);
if (providedFlags.has("dbSetup") && options.dbSetup !== "none")
list.push(`--db-setup ${options.dbSetup}`);
}
if (backend === "none") {
if (providedFlags.has("auth") && options.auth && options.auth !== "none")
list.push(`--auth ${options.auth}`);
if (providedFlags.has("database") && options.database !== "none")
list.push(`--database ${options.database}`);
if (providedFlags.has("orm") && options.orm !== "none")
list.push(`--orm ${options.orm}`);
if (providedFlags.has("api") && options.api !== "none")
list.push(`--api ${options.api}`);
if (providedFlags.has("runtime") && options.runtime !== "none")
list.push(`--runtime ${options.runtime}`);
if (providedFlags.has("dbSetup") && options.dbSetup !== "none")
list.push(`--db-setup ${options.dbSetup}`);
if (providedFlags.has("examples") && options.examples) {
const hasNonNoneExamples = options.examples.some((ex) => ex !== "none");
if (hasNonNoneExamples) list.push("--examples");
}
}
return list;
}
export function validateApiFrontendCompatibility(
api: API | undefined,
frontends: Frontend[] = [],