Fix release scripts to check npm packages (#49788)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49788

Release of 0.78 was successful but it failed to verify the package of NPM because of some error in the JS files.

Preparing for 0.79, I discovered some other issues in the NPM checking scripts.

This change should fix them.

## Changelog:
[Internal] - Fix publishing scripts

Reviewed By: fabriziocucci

Differential Revision: D70489717

fbshipit-source-id: 02a37d9a86fe108c7f7d2d634b8c0727dabb153d
This commit is contained in:
Riccardo Cipolleschi
2025-03-03 06:54:54 -08:00
committed by Facebook GitHub Bot
parent cee63397bf
commit 70c3b2dcff
6 changed files with 22 additions and 12 deletions
@@ -22,10 +22,13 @@ jest.mock('../utils.js', () => ({
log: silence,
run: mockRun,
sleep: mockSleep,
verifyPublishedPackage: mockVerifyPublishedPackage,
getNpmPackageInfo: mockGetNpmPackageInfo,
}));
jest.mock('../verifyPublishedPackage.js', () => ({
verifyPublishedPackage: mockVerifyPublishedPackage,
}));
const getMockGithub = () => ({
rest: {
actions: {
@@ -13,6 +13,11 @@ const mockVerifyPublishedPackage = jest.fn();
const silence = () => {};
jest.mock('../utils.js', () => ({
log: silence,
sleep: silence,
}));
jest.mock('../verifyPublishedPackage.js', () => ({
verifyPublishedPackage: mockVerifyPublishedPackage,
}));
+2 -1
View File
@@ -7,7 +7,8 @@
* @format
*/
const {run, sleep, log, verifyPublishedPackage} = require('./utils.js');
const {run, sleep, log} = require('./utils.js');
const {verifyPublishedPackage} = require('./verifyPublishedPackage.js');
const TAG_AS_LATEST_REGEX = /#publish-packages-to-npm&latest/;
+8 -8
View File
@@ -9,13 +9,7 @@
const {execSync} = require('child_process');
function run(cmd) {
return execSync(cmd, 'utf8').toString().trim();
}
async function sleep(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
const log = (...args) => console.log(...args);
async function getNpmPackageInfo(pkg, versionOrTag) {
return fetch(`https://registry.npmjs.org/${pkg}/${versionOrTag}`).then(resp =>
@@ -23,7 +17,13 @@ async function getNpmPackageInfo(pkg, versionOrTag) {
);
}
const log = (...args) => console.log(...args);
async function sleep(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
function run(cmd) {
return execSync(cmd, 'utf8').toString().trim();
}
module.exports = {
log,
@@ -42,7 +42,7 @@ async function verifyPublishedPackage(
}
log(
`🐌 ${packageName}@${tag} → ${pkg.version} on npm and not ${version} as expected, retrying...`,
`🐌 ${packageName}@${tag} → ${json.version} on npm and not ${version} as expected, retrying...`,
);
} catch (e) {
log(`Nope, fetch failed: ${e.message}`);
@@ -7,7 +7,8 @@
* @format
*/
const {run, sleep, log, verifyPublishedPackage} = require('./utils.js');
const {run, sleep, log} = require('./utils.js');
const {verifyPublishedPackage} = require('./verifyPublishedPackage.js');
const REACT_NATIVE_NPM_PKG = 'react-native';
const MAX_RETRIES = 3 * 6; // 18 attempts. Waiting between attempt: 10 s. Total time: 3 mins.
/**