mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 22:14:29 +09:00
fixes #4105 ## Description This issue fixes picking the default vanilla template in the cli init-flow. Right now, when a template is selected from the `PROJECT_TEMPLATES` we are directly sending the value to `build`. But we need to check for the `expanded` value of the template in order to pick all the series of templates needed for the build. ## Steps for reproduction - create a project in the editor. - Now, create a share-link for the project and copy it. - Run `webstudio` in your local terminal and then the cli prompts for the URL, parse the url from the above step. - Now, pick `Vanilla` as a template from the list of the templates. - The project should build a vanilla template without any errors. ## Code Review - [ ] hi @istarkov , I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [x] made a self-review - [x] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [x] tested locally and on preview environment (preview dev login: 5de6)
25 lines
606 B
TypeScript
25 lines
606 B
TypeScript
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;
|
|
};
|