(typeArg: (typeof POSSIBLE_TYPES)[number])
| 172 | } |
| 173 | |
| 174 | async 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 | |
| 198 | async function writeToFile(name: string, slug: string, template: Template, outDir: string) { |
| 199 | // Build the full output file path + name |
no test coverage detected
searching dependent graphs…