Files
react-native/.github/workflow-scripts/verifyPublishedPackage.js
T
Rob Hogan 47a21740cd Scripts: remove checked-in debugger; statements (#49289)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49289

These snuck in, presumably accidentally, via https://github.com/facebook/react-native/pull/49164.

This interferes with running test suites with a debugger connected (e.g, when debugging Jest itself).

(Aside: we should probably enable [`eslint/no-debugger`](https://eslint.org/docs/latest/rules/no-debugger) to catch these)

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D69377992

fbshipit-source-id: 5d51d18be76f9b01852b2e5b7297b95452f36d55
2025-02-10 00:52:43 -08:00

64 lines
1.6 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
const {log, getNpmPackageInfo, sleep} = require('./utils');
const SLEEP_S = 10;
const MAX_RETRIES = 3 * 6; // 18 attempts. Waiting between attempt: 10 s. Total time: 3 mins.
async function verifyPublishedPackage(
packageName,
version,
tag = null,
retries = MAX_RETRIES,
) {
log(`🔍 Is ${packageName}@${version} on npm?`);
let count = retries;
while (count-- > 0) {
try {
const json = await getNpmPackageInfo(packageName, tag ? tag : version);
log(`🎉 Found ${packageName}@${version} on npm`);
if (!tag) {
return;
}
// check for next tag
if (tag === 'next' && json.version === version) {
log(`🎉 ${packageName}@next → ${version} on npm`);
return;
}
// Check for latest tag
if (tag === 'latest' && json.version === version) {
log(`🎉 ${packageName}@latest → ${version} on npm`);
return;
}
log(
`🐌 ${packageName}@${tag}${pkg.version} on npm and not ${version} as expected, retrying...`,
);
} catch (e) {
log(`Nope, fetch failed: ${e.message}`);
}
await sleep(SLEEP_S);
}
let msg = `🚨 Timed out when trying to verify ${packageName}@${version} on npm`;
if (tag) {
msg += ` and ${tag} tag points to this version.`;
}
log(msg);
process.exit(1);
}
module.exports = {
verifyPublishedPackage,
};