MCPcopy
hub / github.com/QwikDev/qwik / selectTemplate

Function selectTemplate

packages/qwik/src/cli/new/run-new-command.ts:174–196  ·  view source on GitHub ↗
(typeArg: (typeof POSSIBLE_TYPES)[number])

Source from the content-addressed store, hash-verified

172}
173
174async function selectTemplate(typeArg: (typeof POSSIBLE_TYPES)[number]) {
175 const allTemplates = await loadTemplates();
176
177 const templates = allTemplates.filter((i) => i[typeArg] && i[typeArg].length);
178
179 if (!templates.length) {
180 log.error(`No templates found for type "${typeArg}"`);
181 bye();
182 }
183 if (templates.length === 1) {
184 return templates[0][typeArg][0];
185 }
186 const templateAnswer = await select({
187 message: 'Which template would you like to use?',
188 options: templates.map((t) => ({ value: t[typeArg][0], label: t.id })),
189 });
190
191 if (isCancel(templateAnswer)) {
192 bye();
193 }
194
195 return templateAnswer as Template;
196}
197
198async function writeToFile(name: string, slug: string, template: Template, outDir: string) {
199 // Build the full output file path + name

Callers 1

runNewCommandFunction · 0.85

Calls 2

loadTemplatesFunction · 0.90
byeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…