mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
fix(cli): remove alchemy option when next, react router or hono is selected in prompts
This commit is contained in:
@@ -307,6 +307,7 @@ export async function addAddonsHandler(input: AddInput) {
|
|||||||
const serverDeploymentPrompt = await getServerDeploymentToAdd(
|
const serverDeploymentPrompt = await getServerDeploymentToAdd(
|
||||||
detectedConfig.runtime,
|
detectedConfig.runtime,
|
||||||
detectedConfig.serverDeploy,
|
detectedConfig.serverDeploy,
|
||||||
|
detectedConfig.backend,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (serverDeploymentPrompt !== "none") {
|
if (serverDeploymentPrompt !== "none") {
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ export async function getServerDeploymentChoice(
|
|||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (backend !== "hono") {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
|
||||||
const options: DeploymentOption[] = [];
|
const options: DeploymentOption[] = [];
|
||||||
|
|
||||||
if (runtime === "workers") {
|
if (runtime === "workers") {
|
||||||
@@ -77,7 +81,12 @@ export async function getServerDeploymentChoice(
|
|||||||
export async function getServerDeploymentToAdd(
|
export async function getServerDeploymentToAdd(
|
||||||
runtime?: Runtime,
|
runtime?: Runtime,
|
||||||
existingDeployment?: ServerDeploy,
|
existingDeployment?: ServerDeploy,
|
||||||
|
backend?: Backend,
|
||||||
): Promise<ServerDeploy> {
|
): Promise<ServerDeploy> {
|
||||||
|
if (backend !== "hono") {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
|
||||||
const options: DeploymentOption[] = [];
|
const options: DeploymentOption[] = [];
|
||||||
|
|
||||||
if (runtime === "workers") {
|
if (runtime === "workers") {
|
||||||
|
|||||||
@@ -47,21 +47,28 @@ export async function getDeploymentChoice(
|
|||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: DeploymentOption[] = ["wrangler", "alchemy", "none"].map(
|
const hasIncompatibleFrontend = frontend.some(
|
||||||
(deploy) => {
|
(f) => f === "next" || f === "react-router",
|
||||||
const { label, hint } = getDeploymentDisplay(deploy as WebDeploy);
|
|
||||||
return {
|
|
||||||
value: deploy as WebDeploy,
|
|
||||||
label,
|
|
||||||
hint,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
const availableDeployments = hasIncompatibleFrontend
|
||||||
|
? ["wrangler", "none"]
|
||||||
|
: ["wrangler", "alchemy", "none"];
|
||||||
|
|
||||||
|
const options: DeploymentOption[] = availableDeployments.map((deploy) => {
|
||||||
|
const { label, hint } = getDeploymentDisplay(deploy as WebDeploy);
|
||||||
|
return {
|
||||||
|
value: deploy as WebDeploy,
|
||||||
|
label,
|
||||||
|
hint,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const response = await select<WebDeploy>({
|
const response = await select<WebDeploy>({
|
||||||
message: "Select web deployment",
|
message: "Select web deployment",
|
||||||
options,
|
options,
|
||||||
initialValue: DEFAULT_CONFIG.webDeploy,
|
initialValue: hasIncompatibleFrontend
|
||||||
|
? "wrangler"
|
||||||
|
: DEFAULT_CONFIG.webDeploy,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isCancel(response)) return exitCancelled("Operation cancelled");
|
if (isCancel(response)) return exitCancelled("Operation cancelled");
|
||||||
@@ -77,6 +84,10 @@ export async function getDeploymentToAdd(
|
|||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasIncompatibleFrontend = frontend.some(
|
||||||
|
(f) => f === "next" || f === "react-router",
|
||||||
|
);
|
||||||
|
|
||||||
const options: DeploymentOption[] = [];
|
const options: DeploymentOption[] = [];
|
||||||
|
|
||||||
if (existingDeployment !== "wrangler") {
|
if (existingDeployment !== "wrangler") {
|
||||||
@@ -88,7 +99,7 @@ export async function getDeploymentToAdd(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingDeployment !== "alchemy") {
|
if (existingDeployment !== "alchemy" && !hasIncompatibleFrontend) {
|
||||||
const { label, hint } = getDeploymentDisplay("alchemy");
|
const { label, hint } = getDeploymentDisplay("alchemy");
|
||||||
options.push({
|
options.push({
|
||||||
value: "alchemy",
|
value: "alchemy",
|
||||||
@@ -116,7 +127,9 @@ export async function getDeploymentToAdd(
|
|||||||
const response = await select<WebDeploy>({
|
const response = await select<WebDeploy>({
|
||||||
message: "Select web deployment",
|
message: "Select web deployment",
|
||||||
options,
|
options,
|
||||||
initialValue: DEFAULT_CONFIG.webDeploy,
|
initialValue: hasIncompatibleFrontend
|
||||||
|
? "wrangler"
|
||||||
|
: DEFAULT_CONFIG.webDeploy,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isCancel(response)) return exitCancelled("Operation cancelled");
|
if (isCancel(response)) return exitCancelled("Operation cancelled");
|
||||||
|
|||||||
Reference in New Issue
Block a user