11#!/usr/bin/env node
2- const path = require ( "path" ) ,
3- fs = require ( "fs" ) ,
4- { execSync } = require ( "child_process" ) ,
5- colors = require ( "colors" ) ;
2+ const path = require ( "path" ) ;
3+ const fs = require ( "fs" ) ;
4+ const { execSync } = require ( "child_process" ) ;
65
7- let projectName = process . argv [ 2 ] ,
8- projectType = process . argv [ 3 ] ;
6+ require ( "colors" ) ;
7+
8+ const projectName = process . argv [ 2 ] ;
9+ const projectType = process . argv [ 3 ] ;
910
1011const currentPath = process . cwd ( ) ,
1112 projectPath = path . join ( currentPath , projectName ) ;
1213
1314const basicRepo =
14- "https://github.com/rescript-lang/rescript-project-template.git" ,
15- defaultRepo = "https://github.com/mahezsh/rescript-template-default.git" ,
16- nextJsRepo = "https://github.com/ryyppy/rescript-nextjs-template.git" ,
17- graphqlRepo = "https://github.com/mahezsh/rescript-template-graphql.git" ,
18- sbRepo = "https://github.com/mahezsh/rescript-template-storybook.git" ;
15+ "https://github.com/rescript-lang/rescript-project-template.git" ;
16+ const defaultRepo = "https://github.com/mahezsh/rescript-template-default.git" ;
17+ const nextJsRepo = "https://github.com/ryyppy/rescript-nextjs-template.git" ;
18+ const graphqlRepo = "https://github.com/mahezsh/rescript-template-graphql.git" ;
19+ const sbRepo = "https://github.com/mahezsh/rescript-template-storybook.git" ;
1920
2021try {
2122 fs . mkdirSync ( projectPath ) ;
@@ -32,33 +33,40 @@ try {
3233 process . exit ( 1 ) ;
3334}
3435
35- async function main ( ) {
36+ function main ( ) {
3637 try {
37- let repoUrl = defaultRepo ,
38- templateName = "default" ;
38+ let repoUrl ;
39+ let templateName ;
3940
4041 switch ( projectType ) {
41- case "-b" || "--basic" :
42+ case "-b" :
43+ case "--basic" :
4244 repoUrl = basicRepo ;
4345 templateName = "basic" ;
4446 break ;
45- case "-d" || "--default" || undefined :
46- repoUrl = defaultRepo ;
47- templateName = "default" ;
48- break ;
49- case "-nx" || "--nextjs" :
47+ case "-nx" :
48+ case "--nextjs" :
5049 repoUrl = nextJsRepo ;
5150 templateName = "nextJS" ;
5251 break ;
53- case "-gql" || "--graphql" :
52+ case "-gql" :
53+ case "--graphql" :
5454 repoUrl = graphqlRepo ;
5555 templateName = "graphQL" ;
5656 break ;
57- case "-sb" || "--storybook" :
57+ case "-sb" :
58+ case "--storybook" :
5859 repoUrl = sbRepo ;
5960 templateName = "storybook" ;
6061 break ;
62+ case "-d" :
63+ case "--default" :
64+ default :
65+ repoUrl = defaultRepo ;
66+ templateName = "default" ;
67+ break ;
6168 }
69+
6270 console . log (
6371 `\nCreating a new Rescript app in` ,
6472 `${ projectPath } ` . green ,
@@ -78,7 +86,7 @@ async function main() {
7886 }
7987}
8088
81- async function houseKeeping ( ) {
89+ function houseKeeping ( ) {
8290 console . log ( "\nInstalling packages. This might take a couple of seconds." ) ;
8391
8492 execSync ( "npm install" ) ;
0 commit comments