@@ -3,13 +3,18 @@ import path from 'path';
33import commander from 'commander' ;
44import inquirer from 'inquirer' ;
55
6+ import { replaceMaskFile } from '../utils/replaceMask' ;
67import copyFolder from '../utils/copyFolder' ;
78import createPackageJson from '../stages/CreatePackageJson' ;
89import installDependencies from '../stages/InstallDependencies' ;
910import initializeGit from '../stages/InitializeGit' ;
1011import Log from '../Log' ;
1112
12- const createProject = ( projectName : string , packageManager : 'yarn' | 'npm' ) => {
13+ const createProject = (
14+ projectName : string ,
15+ packageManager : 'yarn' | 'npm' ,
16+ httpFramework : 'koa' | 'express' | 'hapi'
17+ ) => {
1318 Log . Instance . infoHeap ( `Creating the project` ) ;
1419
1520 const source = path . join ( __dirname , '/../../templates/project' ) ;
@@ -24,8 +29,12 @@ const createProject = (projectName: string, packageManager: 'yarn' | 'npm') => {
2429 path . join ( target , 'gitignore' ) ,
2530 path . join ( target , '.gitignore' )
2631 ) ;
32+ replaceMaskFile ( path . join ( target , 'config/app.ts' ) , {
33+ projectName,
34+ httpFramework
35+ } ) ;
2736
28- createPackageJson ( target , projectName ) ;
37+ createPackageJson ( target , projectName , httpFramework ) ;
2938 installDependencies ( target , packageManager ) ;
3039 initializeGit ( projectName ) ;
3140
@@ -51,22 +60,33 @@ const createProjectWithOptions = () => {
5160 type : 'list' ,
5261 default : 'npm' ,
5362 choices : [ 'npm' , 'yarn' ]
63+ } ,
64+ {
65+ name : 'httpFramework' ,
66+ message : 'Http Framework:' ,
67+ type : 'list' ,
68+ default : 'koa' ,
69+ choices : [ 'koa' , 'express' , 'hapi' ]
5470 }
5571 ] )
5672 . then ( ( answers : any ) => {
5773 Log . Instance . jump ( ) ;
58- createProject ( answers . projectName , answers . packageManager ) ;
74+ createProject (
75+ answers . projectName ,
76+ answers . packageManager ,
77+ answers . httpFramework
78+ ) ;
5979 } ) ;
6080} ;
6181
6282commander
6383 . name ( `recife-cli project` )
6484 . arguments ( '[project-name]' )
65- . option ( '-p, --package-manager <packageManager>' , 'Package Manager' )
85+ . option ( '-p, --package-manager <packageManager>' , 'Package Manager' , 'npm' )
86+ . option ( '-h, --http-framework <httpFramework>' , 'Http Framework' , 'koa' )
6687 . action ( ( name , cmd ) => {
67- console . log ( cmd ) ;
6888 if ( name ) {
69- createProject ( name , cmd . packageManager || 'npm' ) ;
89+ createProject ( name , cmd . packageManager , cmd . httpFramework ) ;
7090 } else {
7191 createProjectWithOptions ( ) ;
7292 }
0 commit comments