Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: check for expanded templates when a template is selected from the cli init flow. (#4107)
Jaya Krishna Namburu41ef20fe43ee
diff --git a/packages/cli/src/build-utils.ts b/packages/cli/src/build-utils.tsnew file mode 100644index 0000000000..ae3342d84a--- /dev/null+++ b/packages/cli/src/build-utils.ts@@ -0,0 +1,24 @@+import { PROJECT_TEMPLATES, INTERNAL_TEMPLATES } from "./config";++export const mapToTemplatesFromOptions = (values: string[]) => {+ const templates: string[] = [];+ for (const value of values) {+ const template =+ PROJECT_TEMPLATES.find((item) => item.value === value) ??+ INTERNAL_TEMPLATES.find((item) => item.value === value);++ if (template == null) {+ templates.push(value);+ continue;+ }++ if ("expand" in template && template.expand != null) {+ templates.push(...template.expand);+ continue;+ }++ templates.push(value);+ }++ return templates;+};diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.tsindex 55999b081c..3a1d0cdf01 100644--- a/packages/cli/src/commands/build.ts+++ b/packages/cli/src/commands/build.ts@@ -2,15 +2,12 @@ import { access } from "node:fs/promises";import { exit } from "node:process";import { log } from "@clack/prompts";import { prebuild } from "../prebuild";-import {- INTERNAL_TEMPLATES,- LOCAL_DATA_FILE,- PROJECT_TEMPLATES,-} from "../config";+import { LOCAL_DATA_FILE, PROJECT_TEMPLATES } from "../config";import type {CommonYargsArgv,StrictYargsOptionsToInterface,} from "./yargs-types";+import { mapToTemplatesFromOptions } from "../build-utils";export const buildOptions = (yargs: CommonYargsArgv) =>yargs@@ -29,28 +26,7 @@ export const buildOptions = (yargs: CommonYargsArgv) =>string: true,default: [] as string[],- coerce: (values: string[]) => {- const templates = [];- for (const value of values) {- const template =- PROJECT_TEMPLATES.find((item) => item.value === value) ??- INTERNAL_TEMPLATES.find((item) => item.value === value);-- if (template == null) {- templates.push(value);- continue;- }-- if ("expand" in template && template.expand != null) {- templates.push(...template.expand);- continue;- }-- templates.push(value);- }-- return templates;- },+ coerce: mapToTemplatesFromOptions,describe: `Template to use for the build [choices: ${PROJECT_TEMPLATES.map((item) => item.valuediff --git a/packages/cli/src/commands/init-flow.ts b/packages/cli/src/commands/init-flow.tsindex 30767ffd28..22d8ac22da 100644--- a/packages/cli/src/commands/init-flow.ts+++ b/packages/cli/src/commands/init-flow.ts@@ -17,6 +17,7 @@ import { link, validateShareLink } from "./link";import { sync } from "./sync";import { build, buildOptions } from "./build";import type { StrictYargsOptionsToInterface } from "./yargs-types";+import { mapToTemplatesFromOptions } from "../build-utils";type ProjectTemplates = (typeof PROJECT_TEMPLATES)[number]["value"];@@ -103,7 +104,9 @@ export const initFlow = async (await build({...options,- ...(projectTemplate && { template: [projectTemplate] }),+ ...(projectTemplate && {+ template: mapToTemplatesFromOptions([projectTemplate]),+ }),});if (shouldInstallDeps === true) {