MCPcopy Create free account
hub / github.com/react/create-react-app / run

Function run

packages/create-react-app/createReactApp.js:396–545  ·  view source on GitHub ↗
(
  root,
  appName,
  version,
  verbose,
  originalDirectory,
  template,
  useYarn,
  usePnp
)

Source from the content-addressed store, hash-verified

394}
395
396function 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(

Callers 1

createAppFunction · 0.70

Calls 8

getInstallPackageFunction · 0.85
getPackageInfoFunction · 0.85
checkIfOnlineFunction · 0.85
installFunction · 0.85
checkNodeVersionFunction · 0.85
executeNodeScriptFunction · 0.70

Tested by

no test coverage detected