Skip to content

Commit

Permalink
Support package distribution tags (#4350)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Mikhail Osher authored and Timer committed Apr 27, 2018
1 parent cc36849 commit da4a87f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ******************************************************************************
Expand Down

0 comments on commit da4a87f

Please sign in to comment.