fix: enforce Convex backend when --api none is specified

This commit is contained in:
Aman Varshney
2025-05-01 11:08:59 +05:30
parent 3e5483a9eb
commit 920a8f01ca
2 changed files with 18 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"create-better-t-stack": patch
---
Fixed an issue where the CLI would still allow selecting non-Convex backends after specifying `--api none` flag.

View File

@@ -244,6 +244,19 @@ function processAndValidateFlags(
Object.keys(options).filter((key) => key !== "_" && key !== "$0"),
);
if (options.api) {
config.api = options.api as ProjectApi;
if (options.api === "none") {
if (options.backend && options.backend !== "convex") {
consola.fatal(
`'--api none' is only supported with '--backend convex'. Please choose a different API setting or use '--backend convex'.`,
);
process.exit(1);
}
config.backend = "convex";
}
}
if (options.backend) {
config.backend = options.backend as ProjectBackend;
}
@@ -285,9 +298,6 @@ function processAndValidateFlags(
if (options.runtime) {
config.runtime = options.runtime as ProjectRuntime;
}
if (options.api) {
config.api = options.api as ProjectApi;
}
if (options.dbSetup) {
config.dbSetup = options.dbSetup as ProjectDBSetup;
}