fix(cli): remove alchemy option when next, react router or hono is selected in prompts

This commit is contained in:
Aman Varshney
2025-08-21 10:43:11 +05:30
parent 32caaba615
commit 234a10896d
3 changed files with 35 additions and 12 deletions

View File

@@ -307,6 +307,7 @@ export async function addAddonsHandler(input: AddInput) {
const serverDeploymentPrompt = await getServerDeploymentToAdd(
detectedConfig.runtime,
detectedConfig.serverDeploy,
detectedConfig.backend,
);
if (serverDeploymentPrompt !== "none") {

View File

@@ -43,6 +43,10 @@ export async function getServerDeploymentChoice(
return "none";
}
if (backend !== "hono") {
return "none";
}
const options: DeploymentOption[] = [];
if (runtime === "workers") {
@@ -77,7 +81,12 @@ export async function getServerDeploymentChoice(
export async function getServerDeploymentToAdd(
runtime?: Runtime,
existingDeployment?: ServerDeploy,
backend?: Backend,
): Promise<ServerDeploy> {
if (backend !== "hono") {
return "none";
}
const options: DeploymentOption[] = [];
if (runtime === "workers") {

View File

@@ -47,21 +47,28 @@ export async function getDeploymentChoice(
return "none";
}
const options: DeploymentOption[] = ["wrangler", "alchemy", "none"].map(
(deploy) => {
const { label, hint } = getDeploymentDisplay(deploy as WebDeploy);
return {
value: deploy as WebDeploy,
label,
hint,
};
},
const hasIncompatibleFrontend = frontend.some(
(f) => f === "next" || f === "react-router",
);
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>({
message: "Select web deployment",
options,
initialValue: DEFAULT_CONFIG.webDeploy,
initialValue: hasIncompatibleFrontend
? "wrangler"
: DEFAULT_CONFIG.webDeploy,
});
if (isCancel(response)) return exitCancelled("Operation cancelled");
@@ -77,6 +84,10 @@ export async function getDeploymentToAdd(
return "none";
}
const hasIncompatibleFrontend = frontend.some(
(f) => f === "next" || f === "react-router",
);
const options: DeploymentOption[] = [];
if (existingDeployment !== "wrangler") {
@@ -88,7 +99,7 @@ export async function getDeploymentToAdd(
});
}
if (existingDeployment !== "alchemy") {
if (existingDeployment !== "alchemy" && !hasIncompatibleFrontend) {
const { label, hint } = getDeploymentDisplay("alchemy");
options.push({
value: "alchemy",
@@ -116,7 +127,9 @@ export async function getDeploymentToAdd(
const response = await select<WebDeploy>({
message: "Select web deployment",
options,
initialValue: DEFAULT_CONFIG.webDeploy,
initialValue: hasIncompatibleFrontend
? "wrangler"
: DEFAULT_CONFIG.webDeploy,
});
if (isCancel(response)) return exitCancelled("Operation cancelled");