@@ -11084,45 +11084,25 @@ async function main4(deps) {
1108411084 answers . projectName = projectNameFromArg ;
1108511085 M2 . info ( `Using project name from argument: ${ projectNameFromArg } ` ) ;
1108611086 }
11087- const group = await Ce (
11088- {
11089- ...! projectNameFromArg && {
11090- projectName : ( ) => he ( {
11091- message : "Project name:" ,
11092- placeholder : "my-awesome-project" ,
11093- validate : ( value ) => {
11094- if ( ! value ) return "Please enter a project name." ;
11095- }
11096- } )
11097- } ,
11098- template : async ( ) => ve ( {
11099- message : "Select a project template:" ,
11100- options : ( await getTemplates ( ) ) . map ( ( t ) => ( { value : t , label : t } ) )
11101- } )
11102- } ,
11103- {
11104- onCancel : ( ) => {
11105- xe ( "Operation cancelled." ) ;
11106- process . exit ( 0 ) ;
11107- }
11108- }
11109- ) ;
11110- Object . assign ( answers , group ) ;
11111- if ( answers . template === "discord-bot" ) {
11112- const discordGroup = await Ce (
11087+ const answersArg = args . find ( ( arg ) => arg . startsWith ( "--answers=" ) ) ;
11088+ if ( answersArg ) {
11089+ const answersJSON = answersArg . split ( "=" ) [ 1 ] ;
11090+ Object . assign ( answers , JSON . parse ( answersJSON ) ) ;
11091+ } else {
11092+ const group = await Ce (
1111311093 {
11114- discordFeatures : ( ) => fe ( {
11115- message : "Select Discord bot features:" ,
11116- options : [
11117- { value : "welcome" , label : "Include welcome messages for new users" } ,
11118- { value : "logging" , label : "Include message logging" } ,
11119- { value : "moderation" , label : "Include moderation commands (kick/ban)" }
11120- ] ,
11121- required : false
11122- } ) ,
11123- discordRPC : ( ) => ye ( {
11124- message : "Include Discord RPC (activity status)? " ,
11125- initialValue : false
11094+ ... ! projectNameFromArg && {
11095+ projectName : ( ) => he ( {
11096+ message : "Project name:" ,
11097+ placeholder : "my-awesome-project" ,
11098+ validate : ( value ) => {
11099+ if ( ! value ) return "Please enter a project name." ;
11100+ }
11101+ } )
11102+ } ,
11103+ template : async ( ) => ve ( {
11104+ message : "Select a project template: " ,
11105+ options : ( await getTemplates ( ) ) . map ( ( t ) => ( { value : t , label : t } ) )
1112611106 } )
1112711107 } ,
1112811108 {
@@ -11132,29 +11112,127 @@ async function main4(deps) {
1113211112 }
1113311113 }
1113411114 ) ;
11135- Object . assign ( answers , discordGroup ) ;
11136- }
11137- if ( answers . template === "vue-wizard" ) {
11138- const vueWizardGroup = await Ce (
11115+ Object . assign ( answers , group ) ;
11116+ if ( answers . template === "discord-bot" ) {
11117+ const discordGroup = await Ce (
11118+ {
11119+ discordFeatures : ( ) => fe ( {
11120+ message : "Select Discord bot features:" ,
11121+ options : [
11122+ { value : "welcome" , label : "Include welcome messages for new users" } ,
11123+ { value : "logging" , label : "Include message logging" } ,
11124+ { value : "moderation" , label : "Include moderation commands (kick/ban)" }
11125+ ] ,
11126+ required : false
11127+ } ) ,
11128+ discordRPC : ( ) => ye ( {
11129+ message : "Include Discord RPC (activity status)?" ,
11130+ initialValue : false
11131+ } )
11132+ } ,
11133+ {
11134+ onCancel : ( ) => {
11135+ xe ( "Operation cancelled." ) ;
11136+ process . exit ( 0 ) ;
11137+ }
11138+ }
11139+ ) ;
11140+ Object . assign ( answers , discordGroup ) ;
11141+ }
11142+ if ( answers . template === "vue-wizard" ) {
11143+ const vueWizardGroup = await Ce (
11144+ {
11145+ isPublic : ( ) => ye ( {
11146+ message : "Make the repository public?" ,
11147+ initialValue : true
11148+ } ) ,
11149+ addLicense : ( ) => ye ( {
11150+ message : "Add a LICENSE file?" ,
11151+ initialValue : true
11152+ } ) ,
11153+ addFunding : ( ) => ye ( {
11154+ message : "Add a FUNDING.yml file?" ,
11155+ initialValue : false
11156+ } ) ,
11157+ addDocs : ( ) => ye ( {
11158+ message : "Set up a docs/ directory?" ,
11159+ initialValue : false
11160+ } ) ,
11161+ useGhPages : ( ) => ye ( {
11162+ message : "Set up a GitHub Pages deployment workflow?" ,
11163+ initialValue : false
11164+ } )
11165+ } ,
11166+ {
11167+ onCancel : ( ) => {
11168+ xe ( "Operation cancelled." ) ;
11169+ process . exit ( 0 ) ;
11170+ }
11171+ }
11172+ ) ;
11173+ Object . assign ( answers , vueWizardGroup ) ;
11174+ }
11175+ const customizationGroup = await Ce (
1113911176 {
11140- isPublic : ( ) => ye ( {
11141- message : "Make the repository public?" ,
11177+ ...! answers . template . startsWith ( "vue-wizard" ) && {
11178+ dependencies : ( ) => fe ( {
11179+ message : "Which packages should be installed?" ,
11180+ options : [
11181+ { value : { name : "express" , version : "^4.18.2" } , label : "express" } ,
11182+ { value : { name : "discord.js" , version : "^14.14.1" } , label : "discord.js" } ,
11183+ { value : { name : "axios" , version : "^1.6.2" } , label : "axios" } ,
11184+ { value : { name : "eslint" , version : "^8.56.0" } , label : "eslint" } ,
11185+ { value : { name : "dotenv" , version : "^16.3.1" } , label : "dotenv" }
11186+ ] ,
11187+ required : false
11188+ } )
11189+ } ,
11190+ initGit : ( ) => ye ( {
11191+ message : "Initialize a Git repository?" ,
1114211192 initialValue : true
1114311193 } ) ,
11144- addLicense : ( ) => ye ( {
11145- message : "Add a LICENSE file?" ,
11146- initialValue : true
11194+ includeTestFramework : ( ) => ye ( {
11195+ message : "Include a testing framework?" ,
11196+ initialValue : false
11197+ } ) ,
11198+ testFramework : ( { results } ) => {
11199+ if ( results . includeTestFramework ) {
11200+ return ve ( {
11201+ message : "Which testing framework?" ,
11202+ options : [
11203+ { value : "Jest" , label : "Jest" } ,
11204+ { value : "Vitest" , label : "Vitest" } ,
11205+ { value : "Mocha/Chai" , label : "Mocha/Chai" }
11206+ ]
11207+ } ) ;
11208+ }
11209+ } ,
11210+ includeTypeScript : ( ) => ye ( {
11211+ message : "Include TypeScript?" ,
11212+ initialValue : false
1114711213 } ) ,
11148- addFunding : ( ) => ye ( {
11149- message : "Add a FUNDING.yml file ?" ,
11214+ includeEslint : ( ) => ye ( {
11215+ message : "Include ESLint for linting ?" ,
1115011216 initialValue : false
1115111217 } ) ,
11152- addDocs : ( ) => ye ( {
11153- message : "Set up a docs/ directory ?" ,
11218+ includePrettier : ( ) => ye ( {
11219+ message : "Include Prettier for code formatting ?" ,
1115411220 initialValue : false
1115511221 } ) ,
11156- useGhPages : ( ) => ye ( {
11157- message : "Set up a GitHub Pages deployment workflow?" ,
11222+ includeDocker : ( ) => ye ( {
11223+ message : "Include Docker support?" ,
11224+ initialValue : false
11225+ } ) ,
11226+ includeGithubActions : ( ) => ye ( {
11227+ message : "Include GitHub Actions workflow?" ,
11228+ initialValue : false
11229+ } ) ,
11230+ includeGitlabCi : ( ) => ye ( {
11231+ message : "Include GitLab CI/CD pipeline?" ,
11232+ initialValue : false
11233+ } ) ,
11234+ includeDebugConfig : ( ) => ye ( {
11235+ message : "Include VS Code debug configuration?" ,
1115811236 initialValue : false
1115911237 } )
1116011238 } ,
@@ -11165,80 +11243,8 @@ async function main4(deps) {
1116511243 }
1116611244 }
1116711245 ) ;
11168- Object . assign ( answers , vueWizardGroup ) ;
11246+ Object . assign ( answers , customizationGroup ) ;
1116911247 }
11170- const customizationGroup = await Ce (
11171- {
11172- ...! answers . template . startsWith ( "vue-wizard" ) && {
11173- dependencies : ( ) => fe ( {
11174- message : "Which packages should be installed?" ,
11175- options : [
11176- { value : { name : "express" , version : "^4.18.2" } , label : "express" } ,
11177- { value : { name : "discord.js" , version : "^14.14.1" } , label : "discord.js" } ,
11178- { value : { name : "axios" , version : "^1.6.2" } , label : "axios" } ,
11179- { value : { name : "eslint" , version : "^8.56.0" } , label : "eslint" } ,
11180- { value : { name : "dotenv" , version : "^16.3.1" } , label : "dotenv" }
11181- ] ,
11182- required : false
11183- } )
11184- } ,
11185- initGit : ( ) => ye ( {
11186- message : "Initialize a Git repository?" ,
11187- initialValue : true
11188- } ) ,
11189- includeTestFramework : ( ) => ye ( {
11190- message : "Include a testing framework?" ,
11191- initialValue : false
11192- } ) ,
11193- testFramework : ( { results } ) => {
11194- if ( results . includeTestFramework ) {
11195- return ve ( {
11196- message : "Which testing framework?" ,
11197- options : [
11198- { value : "Jest" , label : "Jest" } ,
11199- { value : "Vitest" , label : "Vitest" } ,
11200- { value : "Mocha/Chai" , label : "Mocha/Chai" }
11201- ]
11202- } ) ;
11203- }
11204- } ,
11205- includeTypeScript : ( ) => ye ( {
11206- message : "Include TypeScript?" ,
11207- initialValue : false
11208- } ) ,
11209- includeEslint : ( ) => ye ( {
11210- message : "Include ESLint for linting?" ,
11211- initialValue : false
11212- } ) ,
11213- includePrettier : ( ) => ye ( {
11214- message : "Include Prettier for code formatting?" ,
11215- initialValue : false
11216- } ) ,
11217- includeDocker : ( ) => ye ( {
11218- message : "Include Docker support?" ,
11219- initialValue : false
11220- } ) ,
11221- includeGithubActions : ( ) => ye ( {
11222- message : "Include GitHub Actions workflow?" ,
11223- initialValue : false
11224- } ) ,
11225- includeGitlabCi : ( ) => ye ( {
11226- message : "Include GitLab CI/CD pipeline?" ,
11227- initialValue : false
11228- } ) ,
11229- includeDebugConfig : ( ) => ye ( {
11230- message : "Include VS Code debug configuration?" ,
11231- initialValue : false
11232- } )
11233- } ,
11234- {
11235- onCancel : ( ) => {
11236- xe ( "Operation cancelled." ) ;
11237- process . exit ( 0 ) ;
11238- }
11239- }
11240- ) ;
11241- Object . assign ( answers , customizationGroup ) ;
1124211248 const projectDir = join4 ( process . cwd ( ) , answers . projectName ) ;
1124311249 if ( fs2 . existsSync ( projectDir ) ) {
1124411250 xe ( "Error: Project folder already exists." ) ;
@@ -11275,6 +11281,9 @@ async function main4(deps) {
1127511281 }
1127611282 const packageJsonPath = join4 ( projectDir , "package.json" ) ;
1127711283 let packageJson2 = JSON . parse ( fs2 . readFileSync ( packageJsonPath , "utf-8" ) ) ;
11284+ if ( ! answers . dependencies ) {
11285+ answers . dependencies = [ ] ;
11286+ }
1127811287 const userDependencies = answers . dependencies . reduce ( ( acc , dep ) => {
1127911288 acc [ dep . name ] = dep . version ;
1128011289 return acc ;
0 commit comments