Skip to content

Commit da4a87f

Browse files
Mikhail OsherTimer
Mikhail Osher
authored andcommitted
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
1 parent cc36849 commit da4a87f

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

packages/create-react-app/createReactApp.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const program = new commander.Command(packageJson.name)
8484
` A custom ${chalk.cyan('--scripts-version')} can be one of:`
8585
);
8686
console.log(` - a specific npm version: ${chalk.green('0.8.2')}`);
87+
console.log(` - a specific npm tag: ${chalk.green('@next')}`);
8788
console.log(
8889
` - a custom fork published on npm: ${chalk.green(
8990
'my-react-scripts'
@@ -394,14 +395,18 @@ function getInstallPackage(version, originalDirectory) {
394395
const validSemver = semver.valid(version);
395396
if (validSemver) {
396397
packageToInstall += `@${validSemver}`;
397-
} else if (version && version.match(/^file:/)) {
398-
packageToInstall = `file:${path.resolve(
399-
originalDirectory,
400-
version.match(/^file:(.*)?$/)[1]
401-
)}`;
402398
} else if (version) {
403-
// for tar.gz or alternative paths
404-
packageToInstall = version;
399+
if (version[0] === '@') {
400+
packageToInstall += version;
401+
} else if (version.match(/^file:/)) {
402+
packageToInstall = `file:${path.resolve(
403+
originalDirectory,
404+
version.match(/^file:(.*)?$/)[1]
405+
)}`;
406+
} else {
407+
// for tar.gz or alternative paths
408+
packageToInstall = version;
409+
}
405410
}
406411
return packageToInstall;
407412
}

tasks/e2e-installs.sh

+12
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ npx [email protected] -u user -p password -e [email protected] -r "$custom_reg
101101
git clean -df
102102
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
103103

104+
# ******************************************************************************
105+
# Test --scripts-version with a distribution tag
106+
# ******************************************************************************
107+
108+
cd "$temp_app_path"
109+
npx create-react-app --scripts-version=@latest test-app-dist-tag
110+
cd test-app-dist-tag
111+
112+
# Check corresponding scripts version is installed.
113+
exists node_modules/react-scripts
114+
checkDependencies
115+
104116
# ******************************************************************************
105117
# Test --scripts-version with a version number
106118
# ******************************************************************************

0 commit comments

Comments
 (0)