From 920a8f01ca03cd72a04f17d6807a80ea99989266 Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Thu, 1 May 2025 11:08:59 +0530 Subject: [PATCH] fix: enforce Convex backend when --api none is specified --- .changeset/chilly-wings-shake.md | 5 +++++ apps/cli/src/index.ts | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .changeset/chilly-wings-shake.md diff --git a/.changeset/chilly-wings-shake.md b/.changeset/chilly-wings-shake.md new file mode 100644 index 0000000..1513d1e --- /dev/null +++ b/.changeset/chilly-wings-shake.md @@ -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. diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts index b0713e8..3a23e9a 100644 --- a/apps/cli/src/index.ts +++ b/apps/cli/src/index.ts @@ -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; }