Skip to content
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

Prepare semver (@latest) releases in CI #21615

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Changes from all 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
36 changes: 31 additions & 5 deletions scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,29 @@ function processStable(buildDir) {
updatePackageVersions(
buildDir + '/node_modules',
versionsMap,
defaultVersionIfNotFound
defaultVersionIfNotFound,
true
);
fs.renameSync(buildDir + '/node_modules', buildDir + '/oss-stable');

// Identical to `oss-stable` but with real, semver versions. This is what
// will get published to @latest.
spawnSync('cp', [
'-r',
buildDir + '/oss-stable',
buildDir + '/oss-stable-semver',
]);
const semverVersionsMap = new Map();
for (const moduleName in stablePackages) {
const version = stablePackages[moduleName];
semverVersionsMap.set(moduleName, version);
}
updatePackageVersions(
buildDir + '/oss-stable-semver',
semverVersionsMap,
defaultVersionIfNotFound,
false
);
}

if (fs.existsSync(buildDir + '/facebook-www')) {
Expand Down Expand Up @@ -131,7 +151,8 @@ function processExperimental(buildDir, version) {
updatePackageVersions(
buildDir + '/node_modules',
versionsMap,
defaultVersionIfNotFound
defaultVersionIfNotFound,
true
);
fs.renameSync(buildDir + '/node_modules', buildDir + '/oss-experimental');
}
Expand Down Expand Up @@ -179,7 +200,8 @@ function crossDeviceRenameSync(source, destination) {
function updatePackageVersions(
modulesDir,
versionsMap,
defaultVersionIfNotFound
defaultVersionIfNotFound,
pinToExactVersion
) {
for (const moduleName of fs.readdirSync(modulesDir)) {
let version = versionsMap.get(moduleName);
Expand All @@ -199,14 +221,18 @@ function updatePackageVersions(
if (packageInfo.dependencies) {
for (const dep of Object.keys(packageInfo.dependencies)) {
if (versionsMap.has(dep)) {
packageInfo.dependencies[dep] = version;
packageInfo.dependencies[dep] = pinToExactVersion
? version
: '^' + version;
}
}
}
if (packageInfo.peerDependencies) {
for (const dep of Object.keys(packageInfo.peerDependencies)) {
if (versionsMap.has(dep)) {
packageInfo.peerDependencies[dep] = version;
packageInfo.peerDependencies[dep] = pinToExactVersion
? version
: '^' + version;
}
}
}
Expand Down