Skip to content

Commit 1961e58

Browse files
cipolleschifabriziocucci
authored andcommitted
Fix release scripts to check npm packages (#49788)
Summary: Pull Request resolved: #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
1 parent c593bf8 commit 1961e58

File tree

6 files changed

+22
-12
lines changed

6 files changed

+22
-12
lines changed

.github/workflow-scripts/__tests__/publishTemplate-test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ jest.mock('../utils.js', () => ({
2222
log: silence,
2323
run: mockRun,
2424
sleep: mockSleep,
25-
verifyPublishedPackage: mockVerifyPublishedPackage,
2625
getNpmPackageInfo: mockGetNpmPackageInfo,
2726
}));
2827

28+
jest.mock('../verifyPublishedPackage.js', () => ({
29+
verifyPublishedPackage: mockVerifyPublishedPackage,
30+
}));
31+
2932
const getMockGithub = () => ({
3033
rest: {
3134
actions: {

.github/workflow-scripts/__tests__/verifyReleaseOnNpm-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const mockVerifyPublishedPackage = jest.fn();
1313
const silence = () => {};
1414

1515
jest.mock('../utils.js', () => ({
16+
log: silence,
17+
sleep: silence,
18+
}));
19+
20+
jest.mock('../verifyPublishedPackage.js', () => ({
1621
verifyPublishedPackage: mockVerifyPublishedPackage,
1722
}));
1823

.github/workflow-scripts/publishTemplate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* @format
88
*/
99

10-
const {run, sleep, log, verifyPublishedPackage} = require('./utils.js');
10+
const {run, sleep, log} = require('./utils.js');
11+
const {verifyPublishedPackage} = require('./verifyPublishedPackage.js');
1112

1213
const TAG_AS_LATEST_REGEX = /#publish-packages-to-npm&latest/;
1314

.github/workflow-scripts/utils.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99

1010
const {execSync} = require('child_process');
1111

12-
function run(cmd) {
13-
return execSync(cmd, 'utf8').toString().trim();
14-
}
15-
16-
async function sleep(seconds) {
17-
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
18-
}
12+
const log = (...args) => console.log(...args);
1913

2014
async function getNpmPackageInfo(pkg, versionOrTag) {
2115
return fetch(`https://registry.npmjs.org/${pkg}/${versionOrTag}`).then(resp =>
2216
resp.json(),
2317
);
2418
}
2519

26-
const log = (...args) => console.log(...args);
20+
async function sleep(seconds) {
21+
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
22+
}
23+
24+
function run(cmd) {
25+
return execSync(cmd, 'utf8').toString().trim();
26+
}
2727

2828
module.exports = {
2929
log,

.github/workflow-scripts/verifyPublishedPackage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function verifyPublishedPackage(
4242
}
4343

4444
log(
45-
`🐌 ${packageName}@${tag}${pkg.version} on npm and not ${version} as expected, retrying...`,
45+
`🐌 ${packageName}@${tag}${json.version} on npm and not ${version} as expected, retrying...`,
4646
);
4747
} catch (e) {
4848
log(`Nope, fetch failed: ${e.message}`);

.github/workflow-scripts/verifyReleaseOnNpm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* @format
88
*/
99

10-
const {run, sleep, log, verifyPublishedPackage} = require('./utils.js');
10+
const {run, sleep, log} = require('./utils.js');
11+
const {verifyPublishedPackage} = require('./verifyPublishedPackage.js');
1112
const REACT_NATIVE_NPM_PKG = 'react-native';
1213
const MAX_RETRIES = 3 * 6; // 18 attempts. Waiting between attempt: 10 s. Total time: 3 mins.
1314
/**

0 commit comments

Comments
 (0)