Skip to content

Pre-release version fix #12148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-art/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prop-types": "^15.6.0"
},
"peerDependencies": {
"react": "^16.0.0"
"react": "^16.0.0 || 16.3.0-alpha.0"
},
"files": [
"LICENSE",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-call-return/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"object-assign": "^4.1.1"
},
"peerDependencies": {
"react": "^16.0.0"
"react": "^16.0.0 || 16.3.0-alpha.0"
}
}
2 changes: 1 addition & 1 deletion packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"prop-types": "^15.6.0"
},
"peerDependencies": {
"react": "^16.0.0"
"react": "^16.0.0 || 16.3.0-alpha.0"
},
"files": [
"LICENSE",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"node": ">=0.10.0"
},
"peerDependencies": {
"react": "^16.0.0"
"react": "^16.0.0 || 16.3.0-alpha.0"
},
"dependencies": {
"fbjs": "^0.8.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-test-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"prop-types": "^15.6.0"
},
"peerDependencies": {
"react": "^16.0.0"
"react": "^16.0.0 || 16.3.0-alpha.0"
},
"files": [
"LICENSE",
Expand Down
25 changes: 22 additions & 3 deletions scripts/release/build-commands/update-package-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,49 @@ const update = async ({cwd, dry, packages, version}) => {
const updateProjectPackage = async project => {
const path = join(cwd, 'packages', project, 'package.json');
const json = await readJson(path);
const prerelease = semver.prerelease(version);

// Unstable packages (eg version < 1.0) are treated specially:
// Rather than use the release version (eg 16.1.0)-
// We just auto-increment the minor version (eg 0.1.0 -> 0.2.0).
// If we're doing a prerelease, we also append the suffix (eg 0.2.0-beta).
if (semver.lt(json.version, '1.0.0')) {
const prerelease = semver.prerelease(version);
let suffix = '';
if (prerelease) {
suffix = `-${prerelease.join('.')}`;
}

json.version = `0.${semver.minor(json.version) + 1}.0${suffix}`;
// If this is a new pre-release, increment the minor.
// Else just increment (or remove) the pre-release suffix.
// This way our minor version isn't incremented unnecessarily with each prerelease.
const minor = semver.prerelease(json.version)
? semver.minor(json.version)
: semver.minor(json.version) + 1;

json.version = `0.${minor}.0${suffix}`;
} else {
json.version = version;
}

if (project !== 'react') {
const peerVersion = json.peerDependencies.react.replace('^', '');
let peerVersion = json.peerDependencies.react.replace('^', '');
if (peerVersion.includes(' || ')) {
peerVersion = peerVersion.split(' || ')[0];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes no one manually edits them (e.g. to reorder). It's probably a fine assumption to make but would be nice to leave a comment with expected format. Or assert it.

}

// Release engineers can manually update minor and bugfix versions,
// But we should ensure that major versions always match.
if (semver.major(version) !== semver.major(peerVersion)) {
json.peerDependencies.react = `^${semver.major(version)}.0.0`;
} else {
json.peerDependencies.react = `^${peerVersion}`;
}

// If this is a prerelease, update the react dependency as well.
// A dependency on a major version won't satisfy a prerelease version.
// So rather than eg "^16.0.0" we need "^16.0.0 || 16.3.0-alpha.0"
if (prerelease) {
json.peerDependencies.react += ` || ${version}`;
}
}

Expand Down