@@ -3,12 +3,21 @@ import { createVanilla } from "./create-vanilla";
33import * as p from "@clack/prompts" ;
44import { cancelable , spinnerify } from "@solid-cli/utils/ui" ;
55import { createStart } from "./create-start" ;
6- import { getTemplatesList , GIT_IGNORE , StartTemplate , VanillaTemplate } from "./utils/constants" ;
6+ import {
7+ getTemplatesList ,
8+ GIT_IGNORE ,
9+ PROJECT_TYPES ,
10+ ProjectType ,
11+ StartTemplate ,
12+ VanillaTemplate ,
13+ } from "./utils/constants" ;
714import { detectPackageManager } from "@solid-cli/utils/package-manager" ;
815import { insertAtEnd } from "@solid-cli/utils/fs" ;
916import { existsSync , writeFileSync } from "node:fs" ;
1017import { join } from "node:path" ;
18+ import { createLibrary } from "./create-library" ;
1119export { createVanilla , createStart } ;
20+
1221export const createSolid = ( version : string ) =>
1322 defineCommand ( {
1423 meta : {
@@ -46,12 +55,21 @@ export const createSolid = (version: string) =>
4655 // Show prompts for any unknown arguments
4756 let projectName : string = projectNamePositional ?? projectNameOptional ;
4857 let template : string = templatePositional ;
49- let isStart : boolean = solidstart ;
58+ let projectType : ProjectType | undefined = solidstart ? "start" : undefined ;
5059 projectName ??= await cancelable (
5160 p . text ( { message : "Project Name" , placeholder : "solid-project" , defaultValue : "solid-project" } ) ,
5261 ) ;
53- isStart ??= await cancelable ( p . confirm ( { message : "Is this a SolidStart project?" } ) ) ;
54- const template_opts = await getTemplatesList ( isStart ) ;
62+ projectType ??= await cancelable (
63+ p . select ( {
64+ message : "What type of project would you like to create?" ,
65+ initialValue : "start" ,
66+ options : PROJECT_TYPES . map ( ( t ) => ( {
67+ value : t ,
68+ label : t === "start" ? "SolidStart" : t === "vanilla" ? "SolidJS + Vite" : "Library" ,
69+ } ) ) ,
70+ } ) ,
71+ ) ;
72+ const template_opts = getTemplatesList ( projectType ) ;
5573 template ??= await cancelable (
5674 p . select ( {
5775 message : "Which template would you like to use?" ,
@@ -61,14 +79,25 @@ export const createSolid = (version: string) =>
6179 ) ;
6280
6381 // Don't transpile project if it's already javascript!
64- const transpileToJS = template . startsWith ( "js" ) ? false : ! ( await cancelable ( p . confirm ( { message : "Use Typescript?" } ) ) ) ;
82+ const transpileToJS =
83+ projectType === "library"
84+ ? false
85+ : template . startsWith ( "js" )
86+ ? false
87+ : ! ( await cancelable ( p . confirm ( { message : "Use Typescript?" } ) ) ) ;
6588
66- if ( isStart ) {
89+ if ( projectType === "start" ) {
6790 await spinnerify ( {
6891 startText : "Creating project" ,
6992 finishText : "Project created 🎉" ,
7093 fn : ( ) => createStart ( { template : template as StartTemplate , destination : projectName } , transpileToJS ) ,
7194 } ) ;
95+ } else if ( projectType === "library" ) {
96+ await spinnerify ( {
97+ startText : "Creating project" ,
98+ finishText : "Project created 🎉" ,
99+ fn : ( ) => createLibrary ( { destination : projectName } ) ,
100+ } ) ;
72101 } else {
73102 await spinnerify ( {
74103 startText : "Creating project" ,
0 commit comments