@@ -42,8 +42,13 @@ var chalk = require('chalk');
42
42
43
43
var currentNodeVersion = process . versions . node
44
44
if ( currentNodeVersion . split ( '.' ) [ 0 ] < 4 ) {
45
- console . error ( chalk . red ( 'You are currently running Node v' + currentNodeVersion +
46
- ' but create-react-app requires >=4. Please use a supported version of Node.\n' ) ) ;
45
+ console . error (
46
+ chalk . red (
47
+ 'You are running Node ' + currentNodeVersion + '.\n' +
48
+ 'Create React App requires Node 4 or higher. \n' +
49
+ 'Please update your version of Node.'
50
+ )
51
+ ) ;
47
52
process . exit ( 1 ) ;
48
53
}
49
54
@@ -58,23 +63,36 @@ var projectName;
58
63
59
64
var program = require ( 'commander' )
60
65
. version ( require ( './package.json' ) . version )
61
- . arguments ( '<name>' )
66
+ . arguments ( '<project-directory>' )
67
+ . usage ( chalk . green ( '<project-directory>' ) + ' [options]' )
62
68
. action ( function ( name ) {
63
69
projectName = name ;
64
70
} )
65
- . option ( '-v, -- verbose' , 'print logs while init ' )
66
- . option ( '-s, -- scripts-version <alternative package>' , 'select a react script variant ' )
71
+ . option ( '-- verbose' , 'print additional logs ' )
72
+ . option ( '-- scripts-version <alternative- package>' , 'use a non-standard version of react-scripts ' )
67
73
. on ( '--help' , function ( ) {
68
- console . log ( 'Example of valid script version values:' )
69
- console . log ( ' - a specific npm version: "0.22.0-rc1"' )
70
- console . log ( ' - a .tgz archive from any npm repo: "https://registry.npmjs.org/react-scripts/-/react-scripts-0.20.0.tgz"' )
71
- console . log ( ' - a package prepared with `tasks/clean_pack.sh`: "/Users/home/vjeux/create-react-app/react-scripts-0.22.0.tgz"' )
74
+ console . log ( ' Only ' + chalk . green ( '<project-directory>' ) + ' is required.' ) ;
75
+ console . log ( ) ;
76
+ console . log ( ' A custom ' + chalk . cyan ( '--scripts-version' ) + ' can be one of:' ) ;
77
+ console . log ( ' - a specific npm version: ' + chalk . green ( '0.8.2' ) ) ;
78
+ console . log ( ' - a custom fork published on npm: ' + chalk . green ( 'my-react-scripts' ) ) ;
79
+ console . log ( ' - a .tgz archive: ' + chalk . green ( 'https://mysite.com/my-react-scripts-0.8.2.tgz' ) ) ;
80
+ console . log ( ' It is not needed unless you specifically want to use a fork.' ) ;
81
+ console . log ( ) ;
82
+ console . log ( ' If you have any problems, do not hesitate to file an issue:' ) ;
83
+ console . log ( ' ' + chalk . cyan ( 'https://github.com/facebookincubator/create-react-app/issues/new' ) ) ;
84
+ console . log ( ) ;
72
85
} )
73
86
. parse ( process . argv )
74
87
75
88
if ( typeof projectName === 'undefined' ) {
76
- console . error ( 'Error: no name given!' ) ;
77
- console . log ( 'Usage: ' + program . name ( ) + ' ' + program . usage ( ) ) ;
89
+ console . error ( 'Please specify the project directory:' ) ;
90
+ console . log ( ' ' + chalk . cyan ( program . name ( ) ) + chalk . green ( ' <project-directory>' ) ) ;
91
+ console . log ( ) ;
92
+ console . log ( 'For example:' ) ;
93
+ console . log ( ' ' + chalk . cyan ( program . name ( ) ) + chalk . green ( ' my-react-app' ) ) ;
94
+ console . log ( ) ;
95
+ console . log ( 'Run ' + chalk . cyan ( program . name ( ) + ' --help' ) + ' to see all options.' ) ;
78
96
process . exit ( 1 ) ;
79
97
}
80
98
@@ -89,12 +107,13 @@ function createApp(name, verbose, version) {
89
107
if ( ! pathExists . sync ( name ) ) {
90
108
fs . mkdirSync ( root ) ;
91
109
} else if ( ! isSafeToCreateProjectIn ( root ) ) {
92
- console . log ( 'The directory `' + name + '` contains file(s) that could conflict. Aborting.' ) ;
110
+ console . log ( 'The directory ' + chalk . green ( name ) + ' contains files that could conflict.' ) ;
111
+ console . log ( 'Try using a new directory name.' ) ;
93
112
process . exit ( 1 ) ;
94
113
}
95
114
96
115
console . log (
97
- 'Creating a new React app in ' + root + '.'
116
+ 'Creating a new React app in ' + chalk . green ( root ) + '.'
98
117
) ;
99
118
console . log ( ) ;
100
119
@@ -111,7 +130,7 @@ function createApp(name, verbose, version) {
111
130
process . chdir ( root ) ;
112
131
113
132
console . log ( 'Installing packages. This might take a couple minutes.' ) ;
114
- console . log ( 'Installing react-scripts...' ) ;
133
+ console . log ( 'Installing ' + chalk . cyan ( ' react-scripts' ) + ' ...') ;
115
134
console . log ( ) ;
116
135
117
136
run ( root , appName , version , verbose , originalDirectory ) ;
@@ -153,7 +172,7 @@ function run(root, appName, version, verbose, originalDirectory) {
153
172
154
173
install ( packageToInstall , verbose , function ( code , command , args ) {
155
174
if ( code !== 0 ) {
156
- console . error ( '`' + command + ' ' + args . join ( ' ' ) + '` failed' ) ;
175
+ console . error ( chalk . cyan ( command + ' ' + args . join ( ' ' ) ) + ' failed' ) ;
157
176
process . exit ( 1 ) ;
158
177
}
159
178
@@ -187,7 +206,7 @@ function getInstallPackage(version) {
187
206
function getPackageName ( installPackage ) {
188
207
if ( installPackage . indexOf ( '.tgz' ) > - 1 ) {
189
208
// The package name could be with or without semver version, e.g. react-scripts-0.2.0-alpha.1.tgz
190
- // However, this function returns package name only wihout semver version.
209
+ // However, this function returns package name only without semver version.
191
210
return installPackage . match ( / ^ .+ \/ ( .+ ?) (?: - \d + .+ ) ? \. t g z $ / ) [ 1 ] ;
192
211
} else if ( installPackage . indexOf ( '@' ) > 0 ) {
193
212
// Do not match @scope / when stripping off @version or @tag
@@ -211,8 +230,9 @@ function checkNodeVersion(packageName) {
211
230
if ( ! semver . satisfies ( process . version , packageJson . engines . node ) ) {
212
231
console . error (
213
232
chalk . red (
214
- 'You are currently running Node %s but create-react-app requires %s.' +
215
- ' Please use a supported version of Node.\n'
233
+ 'You are running Node %s.\n' +
234
+ 'Create React App requires Node %s or higher. \n' +
235
+ 'Please update your version of Node.'
216
236
) ,
217
237
process . version ,
218
238
packageJson . engines . node
@@ -230,7 +250,7 @@ function checkAppName(appName) {
230
250
if ( allDependencies . indexOf ( appName ) >= 0 ) {
231
251
console . error (
232
252
chalk . red (
233
- 'We cannot create a project called ` ' + appName + '` because a dependency with the same name exists.\n' +
253
+ 'We cannot create a project called ' + chalk . green ( appName ) + ' because a dependency with the same name exists.\n' +
234
254
'Due to the way npm works, the following names are not allowed:\n\n'
235
255
) +
236
256
chalk . cyan (
0 commit comments