( root, appName, version, verbose, originalDirectory, template, useYarn, usePnp )
| 394 | } |
| 395 | |
| 396 | function run( |
| 397 | root, |
| 398 | appName, |
| 399 | version, |
| 400 | verbose, |
| 401 | originalDirectory, |
| 402 | template, |
| 403 | useYarn, |
| 404 | usePnp |
| 405 | ) { |
| 406 | Promise.all([ |
| 407 | getInstallPackage(version, originalDirectory), |
| 408 | getTemplateInstallPackage(template, originalDirectory), |
| 409 | ]).then(([packageToInstall, templateToInstall]) => { |
| 410 | const allDependencies = ['react', 'react-dom', packageToInstall]; |
| 411 | |
| 412 | console.log('Installing packages. This might take a couple of minutes.'); |
| 413 | |
| 414 | Promise.all([ |
| 415 | getPackageInfo(packageToInstall), |
| 416 | getPackageInfo(templateToInstall), |
| 417 | ]) |
| 418 | .then(([packageInfo, templateInfo]) => |
| 419 | checkIfOnline(useYarn).then(isOnline => ({ |
| 420 | isOnline, |
| 421 | packageInfo, |
| 422 | templateInfo, |
| 423 | })) |
| 424 | ) |
| 425 | .then(({ isOnline, packageInfo, templateInfo }) => { |
| 426 | let packageVersion = semver.coerce(packageInfo.version); |
| 427 | |
| 428 | const templatesVersionMinimum = '3.3.0'; |
| 429 | |
| 430 | // Assume compatibility if we can't test the version. |
| 431 | if (!semver.valid(packageVersion)) { |
| 432 | packageVersion = templatesVersionMinimum; |
| 433 | } |
| 434 | |
| 435 | // Only support templates when used alongside new react-scripts versions. |
| 436 | const supportsTemplates = semver.gte( |
| 437 | packageVersion, |
| 438 | templatesVersionMinimum |
| 439 | ); |
| 440 | if (supportsTemplates) { |
| 441 | allDependencies.push(templateToInstall); |
| 442 | } else if (template) { |
| 443 | console.log(''); |
| 444 | console.log( |
| 445 | `The ${chalk.cyan(packageInfo.name)} version you're using ${ |
| 446 | packageInfo.name === 'react-scripts' ? 'is not' : 'may not be' |
| 447 | } compatible with the ${chalk.cyan('--template')} option.` |
| 448 | ); |
| 449 | console.log(''); |
| 450 | } |
| 451 | |
| 452 | console.log( |
| 453 | `Installing ${chalk.cyan('react')}, ${chalk.cyan( |
no test coverage detected