@@ -12,8 +12,18 @@ import {
1212import { downloadTemplate } from 'giget'
1313import { getUserAgent } from 'package-manager-detector'
1414
15+ export const templateOptions = [
16+ { value : 'default' , label : 'Default' } ,
17+ { value : 'minimal' , label : 'Minimal' } ,
18+ { value : 'vue' , label : 'Vue' } ,
19+ { value : 'react' , label : 'React' } ,
20+ { value : 'solid' , label : 'Solid' } ,
21+ ] as const
22+
23+ type TemplateOption = ( typeof templateOptions ) [ number ] [ 'value' ]
24+
1525export interface Options {
16- template ?: 'default' | 'minimal' | 'vue' | 'react' | 'solid'
26+ template ?: TemplateOption
1727 path ?: string
1828}
1929
@@ -74,21 +84,16 @@ export async function resolveOptions(
7484
7585 let template : Options [ 'template' ] | symbol = options . template
7686 if ( template ) {
77- if ( ! [ 'default' , 'minimal' , 'vue' , 'react' , 'solid' ] . includes ( template ) ) {
87+ const templateOptionsValues = templateOptions . map ( ( option ) => option . value )
88+ if ( ! templateOptionsValues . includes ( template ) ) {
7889 throw new Error (
79- `Invalid template "${ template } ". Available templates: default, vue, react, solid ` ,
90+ `Invalid template "${ template } ". Available templates: ${ templateOptionsValues . join ( ', ' ) } ` ,
8091 )
8192 }
8293 } else {
8394 template = await select ( {
8495 message : 'Which template do you want to use?' ,
85- options : [
86- { value : 'default' , label : 'Default' } ,
87- { value : 'minimal' , label : 'Minimal' } ,
88- { value : 'vue' , label : 'Vue' } ,
89- { value : 'react' , label : 'React' } ,
90- { value : 'solid' , label : 'Solid' } ,
91- ] ,
96+ options : [ ...templateOptions ] ,
9297 initialValue : 'default' ,
9398 } )
9499
0 commit comments