From da4a87f6380d813664e95ef3d77e18df0295bca8 Mon Sep 17 00:00:00 2001 From: Mikhail Osher Date: Fri, 27 Apr 2018 15:45:18 +0300 Subject: [PATCH] Support package distribution tags (#4350) * Support package distribution tags (#4348) * Remove redundand variable check in `getInstallPackage` * Simplify react-scripts version using `--scripts-version=@tagname` notation * Add dist-tag tests to e2e-installs --- packages/create-react-app/createReactApp.js | 19 ++++++++++++------- tasks/e2e-installs.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index cbe9699e2c3..957501c8e17 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -84,6 +84,7 @@ const program = new commander.Command(packageJson.name) ` A custom ${chalk.cyan('--scripts-version')} can be one of:` ); console.log(` - a specific npm version: ${chalk.green('0.8.2')}`); + console.log(` - a specific npm tag: ${chalk.green('@next')}`); console.log( ` - a custom fork published on npm: ${chalk.green( 'my-react-scripts' @@ -394,14 +395,18 @@ function getInstallPackage(version, originalDirectory) { const validSemver = semver.valid(version); if (validSemver) { packageToInstall += `@${validSemver}`; - } else if (version && version.match(/^file:/)) { - packageToInstall = `file:${path.resolve( - originalDirectory, - version.match(/^file:(.*)?$/)[1] - )}`; } else if (version) { - // for tar.gz or alternative paths - packageToInstall = version; + if (version[0] === '@') { + packageToInstall += version; + } else if (version.match(/^file:/)) { + packageToInstall = `file:${path.resolve( + originalDirectory, + version.match(/^file:(.*)?$/)[1] + )}`; + } else { + // for tar.gz or alternative paths + packageToInstall = version; + } } return packageToInstall; } diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index ed014c58f35..6caf114c572 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -101,6 +101,18 @@ npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_reg git clean -df ./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest +# ****************************************************************************** +# Test --scripts-version with a distribution tag +# ****************************************************************************** + +cd "$temp_app_path" +npx create-react-app --scripts-version=@latest test-app-dist-tag +cd test-app-dist-tag + +# Check corresponding scripts version is installed. +exists node_modules/react-scripts +checkDependencies + # ****************************************************************************** # Test --scripts-version with a version number # ******************************************************************************