File tree Expand file tree Collapse file tree 5 files changed +88
-0
lines changed Expand file tree Collapse file tree 5 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+ .cache
2
+
3
+ dist
4
+
5
+ build
6
+
7
+ node_modules
Original file line number Diff line number Diff line change
1
+ # create-rescript-app
2
+
3
+ Create ReScript apps with no build configuration.
4
+
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < body >
3
+ < div > create-rescript-app</ div >
4
+ < script src ="index.js "> </ script >
5
+ </ body >
6
+ </ html >
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+ const path = require ( "path" ) ;
3
+ let fs = require ( "fs" ) ;
4
+ const { execSync } = require ( "child_process" ) ;
5
+ let colors = require ( "colors" ) ;
6
+
7
+ let projectName = process . argv [ 2 ] ;
8
+ const currentPath = process . cwd ( ) ;
9
+ const projectPath = path . join ( currentPath , projectName ) ;
10
+ const git_repo =
11
+ "https://github.com/rescript-lang/rescript-project-template.git" ;
12
+
13
+ try {
14
+ fs . mkdirSync ( projectPath ) ;
15
+ } catch ( err ) {
16
+ if ( err . code === "EEXIST" ) {
17
+ console . log (
18
+ `The folder` ,
19
+ `${ projectName } ` . red ,
20
+ `already exist in the current directory, please give it another name.`
21
+ ) ;
22
+ } else {
23
+ console . log ( error ) ;
24
+ }
25
+ process . exit ( 1 ) ;
26
+ }
27
+
28
+ async function main ( ) {
29
+ try {
30
+ console . log ( `Creating a new Rescript app in` , `${ projectPath } \n` . green ) ;
31
+ execSync ( `git clone --depth 1 ${ git_repo } ${ projectPath } ` ) ;
32
+ process . chdir ( projectPath ) ;
33
+ console . log ( "\nInstalling packages. This might take a couple of seconds." ) ;
34
+ execSync ( "npm install" ) ;
35
+ execSync ( `find . | grep "\.git/" | xargs rm -rf` ) ;
36
+ execSync ( "git init" ) ;
37
+ console . log ( `\nInitialized a git repository.` ) ;
38
+ console . log (
39
+ `\nSuccess!` . green ,
40
+ `Created ${ projectName } at ` ,
41
+ `${ projectPath } ` . green
42
+ ) ;
43
+ console . log ( `\nHappy hacking!\n` ) ;
44
+ } catch ( error ) {
45
+ console . log ( error ) ;
46
+ }
47
+ }
48
+ main ( ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " create-rescript-app" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Create ReScript apps with no build configuration." ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "start" : " parcel index.html" ,
8
+ "build" : " parcel build index.js" ,
9
+ "test" : " echo \" Error: no test specified\" && exit 1"
10
+ },
11
+ "author" : " " ,
12
+ "license" : " ISC" ,
13
+ "dependencies" : {
14
+ "colors" : " ^1.4.0" ,
15
+ "shelljs" : " ^0.8.4"
16
+ },
17
+ "devDependencies" : {
18
+ "parcel-bundler" : " ^1.12.5"
19
+ },
20
+ "bin" : {
21
+ "create-rescript-app" : " index.js"
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments