Skip to content

Commit 389e307

Browse files
Skip the platform question if there is only one option
1 parent 9dd929c commit 389e307

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

packages/create-cloudflare/src/templates.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,30 +467,43 @@ export const createContext = async (
467467
}
468468

469469
if ("platformVariants" in frameworkConfig) {
470+
const availableVariants = Object.entries(
471+
frameworkConfig.platformVariants,
472+
).filter(([, config]) => !config.hidden) as [
473+
keyof typeof frameworkConfig.platformVariants,
474+
TemplateConfig,
475+
][];
476+
477+
if (availableVariants.length === 1) {
478+
args.platform ??= availableVariants[0][0];
479+
}
480+
470481
const platform = await processArgument(args, "platform", {
471482
type: "select",
472483
label: "platform",
473484
question: "Select your deployment platform",
474485
options: [
475-
...(frameworkConfig.platformVariants.workers.hidden
476-
? []
477-
: [
486+
...(args.platform === "workers" ||
487+
!frameworkConfig.platformVariants.workers.hidden
488+
? [
478489
{
479490
label: "Workers with Assets",
480491
value: "workers",
481492
description:
482493
"Take advantage of the full Developer Platform, including R2, Queues, Durable Objects and more.",
483494
},
484-
]),
485-
...(frameworkConfig.platformVariants.pages.hidden
486-
? []
487-
: [
495+
]
496+
: []),
497+
...(args.platform === "pages" ||
498+
!frameworkConfig.platformVariants.pages.hidden
499+
? [
488500
{
489501
label: "Pages",
490502
value: "pages",
491503
description: "Great for simple websites and applications.",
492504
},
493-
]),
505+
]
506+
: []),
494507
backOption,
495508
],
496509
defaultValue: "workers",

0 commit comments

Comments
 (0)