@@ -276,11 +276,7 @@ function run(
276276 } )
277277 . then ( packageName => {
278278 checkNodeVersion ( packageName ) ;
279-
280- // Since react-scripts has been installed with --save
281- // we need to move it into devDependencies and rewrite package.json
282- // also ensure react dependencies have caret version range
283- fixDependencies ( packageName ) ;
279+ setCaretRangeForRuntimeDeps ( packageName ) ;
284280
285281 const scriptsPath = path . resolve (
286282 process . cwd ( ) ,
@@ -497,16 +493,14 @@ function checkAppName(appName) {
497493 }
498494
499495 // TODO: there should be a single place that holds the dependencies
500- const dependencies = [ 'react' , 'react-dom' ] ;
501- const devDependencies = [ 'react-scripts' ] ;
502- const allDependencies = dependencies . concat ( devDependencies ) . sort ( ) ;
503- if ( allDependencies . indexOf ( appName ) >= 0 ) {
496+ const dependencies = [ 'react' , 'react-dom' , 'react-scripts' ] . sort ( ) ;
497+ if ( dependencies . indexOf ( appName ) >= 0 ) {
504498 console . error (
505499 chalk . red (
506500 `We cannot create a project called ${ chalk . green ( appName ) } because a dependency with the same name exists.\n` +
507501 `Due to the way npm works, the following names are not allowed:\n\n`
508502 ) +
509- chalk . cyan ( allDependencies . map ( depName => ` ${ depName } ` ) . join ( '\n' ) ) +
503+ chalk . cyan ( dependencies . map ( depName => ` ${ depName } ` ) . join ( '\n' ) ) +
510504 chalk . red ( '\n\nPlease choose a different project name.' )
511505 ) ;
512506 process . exit ( 1 ) ;
@@ -533,7 +527,7 @@ function makeCaretRange(dependencies, name) {
533527 dependencies [ name ] = patchedVersion ;
534528}
535529
536- function fixDependencies ( packageName ) {
530+ function setCaretRangeForRuntimeDeps ( packageName ) {
537531 const packagePath = path . join ( process . cwd ( ) , 'package.json' ) ;
538532 const packageJson = require ( packagePath ) ;
539533
@@ -543,16 +537,11 @@ function fixDependencies(packageName) {
543537 }
544538
545539 const packageVersion = packageJson . dependencies [ packageName ] ;
546-
547540 if ( typeof packageVersion === 'undefined' ) {
548541 console . error ( chalk . red ( `Unable to find ${ packageName } in package.json` ) ) ;
549542 process . exit ( 1 ) ;
550543 }
551544
552- packageJson . devDependencies = packageJson . devDependencies || { } ;
553- packageJson . devDependencies [ packageName ] = packageVersion ;
554- delete packageJson . dependencies [ packageName ] ;
555-
556545 makeCaretRange ( packageJson . dependencies , 'react' ) ;
557546 makeCaretRange ( packageJson . dependencies , 'react-dom' ) ;
558547
0 commit comments