@@ -6,10 +6,9 @@ import { createStart } from "./create-start";
66import {
77 getTemplatesList ,
88 GIT_IGNORE ,
9+ isValidTemplate ,
910 PROJECT_TYPES ,
1011 ProjectType ,
11- StartTemplate ,
12- VanillaTemplate ,
1312} from "./utils/constants" ;
1413import { detectPackageManager } from "@solid-cli/utils/package-manager" ;
1514import { existsSync , writeFileSync } from "node:fs" ;
@@ -111,25 +110,29 @@ export const createSolid = (version: string) =>
111110
112111 // Need to transpile if the user wants Jabascript, but their selected template isn't Javascript
113112 const transpileToJS = useJS && ! template . startsWith ( "js" ) ;
114- if ( projectType === "start" ) {
113+ if ( projectType === "start" && isValidTemplate ( "start" , template ) ) {
115114 await spinnerify ( {
116115 startText : "Creating project" ,
117116 finishText : "Project created 🎉" ,
118- fn : ( ) => createStart ( { template : template as StartTemplate , destination : projectName } , transpileToJS ) ,
117+ fn : ( ) => createStart ( { template, destination : projectName } , transpileToJS ) ,
119118 } ) ;
120- } else if ( projectType === "library" ) {
119+ } else if ( projectType === "library" && isValidTemplate ( "library" , template ) ) {
121120 await spinnerify ( {
122121 startText : "Creating project" ,
123122 finishText : "Project created 🎉" ,
124123 fn : ( ) => createLibrary ( { destination : projectName } ) ,
125124 } ) ;
126- } else {
125+ } else if ( projectType === "vanilla" && isValidTemplate ( projectType , template ) ) {
127126 await spinnerify ( {
128127 startText : "Creating project" ,
129128 finishText : "Project created 🎉" ,
130- fn : ( ) => createVanilla ( { template : template as VanillaTemplate , destination : projectName } , transpileToJS ) ,
129+ fn : ( ) => createVanilla ( { template, destination : projectName } , transpileToJS ) ,
131130 } ) ;
132131 }
132+ else {
133+ p . log . error ( `Template ${ template } is not valid for project type ${ projectType } ` ) ;
134+ process . exit ( 0 ) ;
135+ }
133136 // Add .gitignore
134137 writeFileSync ( join ( projectName , ".gitignore" ) , GIT_IGNORE ) ;
135138 // Add "Created with Solid CLI" text to bottom of README
0 commit comments