Fix validation logic with --yes flag for addon compatibility

This commit is contained in:
Aman Varshney
2025-04-11 17:00:05 +05:30
parent e858f23afc
commit 5a15147960
2 changed files with 24 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"create-better-t-stack": patch
---
Fix validation logic with --yes flag for addon compatibility

View File

@@ -402,7 +402,16 @@ function processAndValidateFlags(
(f) => f === "tanstack-router" || f === "react-router",
);
if (hasWebSpecificAddons && !hasCompatibleWebFrontend) {
if (
hasWebSpecificAddons &&
!hasCompatibleWebFrontend &&
!(
options.yes &&
DEFAULT_CONFIG.frontend.some(
(f) => f === "tanstack-router" || f === "react-router",
)
)
) {
cancel(
pc.red(
"PWA and Tauri addons require tanstack-router or react-router. Cannot use these addons with your frontend selection.",
@@ -439,7 +448,8 @@ function processAndValidateFlags(
if (
options.examples.includes("ai") &&
(options.backend === "elysia" || config.backend === "elysia")
(options.backend === "elysia" || config.backend === "elysia") &&
!(options.yes && DEFAULT_CONFIG.backend !== "elysia")
) {
cancel(
pc.red(
@@ -459,7 +469,13 @@ function processAndValidateFlags(
(!options.frontend ||
!options.frontend.some((f) =>
["tanstack-router", "react-router", "tanstack-start"].includes(f),
))
)) &&
!(
options.yes &&
DEFAULT_CONFIG.frontend.some((f) =>
["tanstack-router", "react-router", "tanstack-start"].includes(f),
)
)
) {
cancel(
pc.red(
@@ -468,7 +484,6 @@ function processAndValidateFlags(
);
process.exit(1);
}
config.examples = options.examples.filter(
(ex): ex is ProjectExamples => ex === "todo" || ex === "ai",
);