File tree Expand file tree Collapse file tree 5 files changed +40
-12
lines changed Expand file tree Collapse file tree 5 files changed +40
-12
lines changed Original file line number Diff line number Diff line change 2
2
3
3
"use strict" ;
4
4
5
- console . log ( "\x1b[36m" , "Bayon Cli" , "\x1b[0m" ) ;
6
- console . log ( `\t\t🚀 Version: ${ require ( "./package.json" ) . version } \n` ) ;
5
+ const program = require ( "commander" ) ;
6
+
7
+ console . log ( "\x1b[36mCreate React Dependency" , "\x1b[0m" ) ;
8
+ console . log ( `🚀 Version: ${ require ( "./package.json" ) . version } \n` ) ;
9
+
10
+ let projectName ;
11
+
12
+ program
13
+ . version ( require ( "./package.json" ) . version , "-v --version" , "Version number" )
14
+ . helpOption ( "-h --help" , "For more information" ) ;
15
+
16
+ program
17
+ . name ( `${ require ( "./package.json" ) . name } new` )
18
+ . command ( "new <name-project>" )
19
+ . description ( "Create a new project" )
20
+ . action ( name => ( projectName = name ) ) ;
21
+
22
+ program . parse ( process . argv ) ;
23
+
24
+ if ( typeof projectName === "undefined" ) {
25
+ console . error ( "\x1b[31mSpecify the name project." , "\x1b[0m" ) ;
26
+ console . log ( ` For example: ${ program . name ( ) } my-dependencie` ) ;
27
+ console . log ( ` Run ${ program . name ( ) } --help for more information\n` ) ;
28
+
29
+ process . exit ( 1 ) ;
30
+ } else {
31
+ console . log ( "sucess" ) ;
32
+ }
Original file line number Diff line number Diff line change 18
18
"repository" : {
19
19
"type" : " git" ,
20
20
"url" : " git+https://github.com/andrelmlins/create-react-dependency.git"
21
+ },
22
+ "dependencies" : {
23
+ "commander" : " ^4.0.0"
21
24
}
22
25
}
Original file line number Diff line number Diff line change @@ -8,20 +8,14 @@ const args = process.argv.slice(2);
8
8
const scripts = [ "start" , "build" , "test" ] ;
9
9
10
10
if ( args . length === 0 ) {
11
- console . log ( "Empty script." ) ;
11
+ console . log ( "\x1b[31mEmpty script." ) ;
12
12
process . exit ( 1 ) ;
13
13
}
14
14
15
15
const script = args [ 0 ] ;
16
16
17
- process . on ( "unhandledRejection" , err => {
18
- throw err ;
19
- } ) ;
20
-
21
- console . log ( "\x1b[36m" , `\nReact Library Scripts\n` , "\x1b[0m" ) ;
22
- console . log (
23
- `🚀 Version: ${ require ( "./package.json" ) . version } / ⚙️ Script: ${ script } \n`
24
- ) ;
17
+ console . log ( `\x1b[36m\nReact Dependency Scripts (${ script } )` , "\x1b[0m" ) ;
18
+ console . log ( `🚀 Version: ${ require ( "./package.json" ) . version } \n` ) ;
25
19
26
20
if ( scripts . includes ( script ) ) {
27
21
const result = spawnSync (
@@ -31,7 +25,7 @@ if (scripts.includes(script)) {
31
25
) ;
32
26
process . exit ( result . status ) ;
33
27
} else {
34
- console . log ( `Unknown script ${ script } .` ) ;
28
+ console . log ( `\x1b[31mUnknown script ${ script } .` ) ;
35
29
console . log ( "See: http://github.com/andrelmlins/create-react-library" ) ;
36
30
process . exit ( 1 ) ;
37
31
}
Original file line number Diff line number Diff line change @@ -3097,6 +3097,11 @@ commander@^2.20.0, commander@~2.20.3:
3097
3097
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
3098
3098
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
3099
3099
3100
+ commander@^4.0.0 :
3101
+ version "4.0.0"
3102
+ resolved "https://registry.yarnpkg.com/commander/-/commander-4.0.0.tgz#e782b6afe6a0f1b1408be59429919e1305160e3f"
3103
+ integrity sha512-SEa2abMBTZuEjLVYpNrAFoRgxPwG4rXP3+SGY6CM/HZGeDzIA7Pzp+7H3AHDukKEpyy2SoSGGPShKqqfH9T9AQ==
3104
+
3100
3105
commander@~2.19.0 :
3101
3106
version "2.19.0"
3102
3107
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
You can’t perform that action at this time.
0 commit comments