Skip to content

Commit 27630d3

Browse files
cortinicofacebook-github-bot
authored andcommitted
Remove unused --otp property from release infrastructure (#53779)
Summary: The `--otp` flag is completely unused now, therefore it can be removed. We don't pass the `NPM_CONFIG_OTP` env variable either as this was done back in the days of CircleCI so I'm cleaning this up. ## Changelog: [INTERNAL] - Remove unused --otp property from release infrastructure Pull Request resolved: #53779 Test Plan: CI Reviewed By: lunaleaps Differential Revision: D82453539 Pulled By: cortinico fbshipit-source-id: 84a6b82a037c754165c21e17976dc534d9a7ba4c
1 parent 96c33a8 commit 27630d3

File tree

5 files changed

+18
-43
lines changed

5 files changed

+18
-43
lines changed

scripts/releases-ci/__tests__/publish-npm-test.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,6 @@ describe('publish-npm', () => {
282282
code: 0,
283283
}));
284284

285-
process.env.NPM_CONFIG_OTP = 'otp';
286-
287285
await publishNpm('release');
288286

289287
expect(setVersionMock).not.toBeCalled();
@@ -303,7 +301,7 @@ describe('publish-npm', () => {
303301
expect(publishPackageMock.mock.calls).toEqual([
304302
[
305303
path.join(REPO_ROOT, 'packages', 'react-native'),
306-
{otp: process.env.NPM_CONFIG_OTP, tags: ['0.81-stable']},
304+
{tags: ['0.81-stable']},
307305
],
308306
]);
309307

@@ -322,8 +320,6 @@ describe('publish-npm', () => {
322320
code: 0,
323321
}));
324322

325-
process.env.NPM_CONFIG_OTP = 'otp';
326-
327323
await publishNpm('release');
328324

329325
expect(updateReactNativeArtifactsMock).not.toBeCalled();
@@ -341,10 +337,7 @@ describe('publish-npm', () => {
341337
);
342338

343339
expect(publishPackageMock.mock.calls).toEqual([
344-
[
345-
path.join(REPO_ROOT, 'packages', 'react-native'),
346-
{otp: process.env.NPM_CONFIG_OTP, tags: ['latest']},
347-
],
340+
[path.join(REPO_ROOT, 'packages', 'react-native'), {tags: ['latest']}],
348341
]);
349342

350343
expect(consoleLogMock.mock.calls).toEqual([
@@ -365,8 +358,6 @@ describe('publish-npm', () => {
365358
execMock.mockReturnValueOnce({code: 1});
366359
isTaggedLatestMock.mockReturnValueOnce(true);
367360

368-
process.env.NPM_CONFIG_OTP = 'otp';
369-
370361
await expect(async () => {
371362
await publishNpm('release');
372363
}).rejects.toThrow(
@@ -388,10 +379,7 @@ describe('publish-npm', () => {
388379
);
389380

390381
expect(publishPackageMock.mock.calls).toEqual([
391-
[
392-
path.join(REPO_ROOT, 'packages', 'react-native'),
393-
{otp: process.env.NPM_CONFIG_OTP, tags: ['latest']},
394-
],
382+
[path.join(REPO_ROOT, 'packages', 'react-native'), {tags: ['latest']}],
395383
]);
396384
expect(consoleLogMock).not.toHaveBeenCalled();
397385
});
@@ -406,8 +394,6 @@ describe('publish-npm', () => {
406394
code: 0,
407395
}));
408396

409-
process.env.NPM_CONFIG_OTP = 'otp';
410-
411397
await publishNpm('release');
412398

413399
expect(setVersionMock).not.toBeCalled();
@@ -425,10 +411,7 @@ describe('publish-npm', () => {
425411
);
426412

427413
expect(publishPackageMock.mock.calls).toEqual([
428-
[
429-
path.join(REPO_ROOT, 'packages', 'react-native'),
430-
{otp: process.env.NPM_CONFIG_OTP, tags: ['next']},
431-
],
414+
[path.join(REPO_ROOT, 'packages', 'react-native'), {tags: ['next']}],
432415
]);
433416
expect(consoleLogMock.mock.calls).toEqual([
434417
[`Published react-native@${expectedVersion} to npm`],

scripts/releases-ci/publish-npm.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ async function publishMonorepoPackages(tag /*: ?string */) {
7676
console.log(`Publishing ${packageInfo.name}...`);
7777
const result = publishPackage(packageInfo.path, {
7878
tags: [tag],
79-
otp: process.env.NPM_CONFIG_OTP,
8079
access: 'public',
8180
});
8281

@@ -122,7 +121,6 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise<void> */ {
122121
const packagePath = path.join(REPO_ROOT, 'packages', 'react-native');
123122
const result = publishPackage(packagePath, {
124123
tags: [tag],
125-
otp: process.env.NPM_CONFIG_OTP,
126124
});
127125

128126
if (result.code) {

scripts/releases-ci/publish-updated-packages.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const {execSync} = require('child_process');
1414
const {parseArgs} = require('util');
1515

1616
const PUBLISH_PACKAGES_TAG = '#publish-packages-to-npm';
17-
const NPM_CONFIG_OTP = process.env.NPM_CONFIG_OTP;
1817

1918
const config = {
2019
options: {
@@ -139,7 +138,6 @@ function runPublish(
139138
) {
140139
const result = publishPackage(packagePath, {
141140
tags,
142-
otp: NPM_CONFIG_OTP,
143141
});
144142

145143
if (result.code !== 0) {

scripts/releases/utils/__tests__/npm-utils-test.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,35 @@ describe('npm-utils', () => {
3333
it('should run publish command', () => {
3434
publishPackage(
3535
'path/to/my-package',
36-
{tags: ['latest'], otp: 'otp'},
36+
{tags: ['latest']},
3737
{silent: true, cwd: 'i/expect/this/to/be/overriden'},
3838
);
39-
expect(execMock).toHaveBeenCalledWith(
40-
'npm publish --tag latest --otp otp',
41-
{silent: true, cwd: 'path/to/my-package'},
42-
);
39+
expect(execMock).toHaveBeenCalledWith('npm publish --tag latest', {
40+
silent: true,
41+
cwd: 'path/to/my-package',
42+
});
4343
});
4444

4545
it('should run publish command when no execOptions', () => {
46-
publishPackage('path/to/my-package', {tags: ['latest'], otp: 'otp'});
47-
expect(execMock).toHaveBeenCalledWith(
48-
'npm publish --tag latest --otp otp',
49-
{cwd: 'path/to/my-package'},
50-
);
46+
publishPackage('path/to/my-package', {tags: ['latest']});
47+
expect(execMock).toHaveBeenCalledWith('npm publish --tag latest', {
48+
cwd: 'path/to/my-package',
49+
});
5150
});
5251

5352
it('should handle multiple tags', () => {
5453
publishPackage('path/to/my-package', {
5554
tags: ['next', '0.72-stable'],
56-
otp: 'otp',
5755
});
5856
expect(execMock).toHaveBeenCalledWith(
59-
'npm publish --tag next --tag 0.72-stable --otp otp',
57+
'npm publish --tag next --tag 0.72-stable',
6058
{cwd: 'path/to/my-package'},
6159
);
6260
});
6361

6462
it('should handle -no-tag', () => {
65-
publishPackage('path/to/my-package', {tags: ['--no-tag'], otp: 'otp'});
66-
expect(execMock).toHaveBeenCalledWith('npm publish --no-tag --otp otp', {
63+
publishPackage('path/to/my-package', {tags: ['--no-tag']});
64+
expect(execMock).toHaveBeenCalledWith('npm publish --no-tag', {
6765
cwd: 'path/to/my-package',
6866
});
6967
});

scripts/releases/utils/npm-utils.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type PackageJSON = {
3535
}
3636
type NpmPackageOptions = {
3737
tags: ?Array<string> | ?Array<?string>,
38-
otp: ?string,
3938
access?: ?('public' | 'restricted')
4039
}
4140
*/
@@ -130,7 +129,7 @@ function publishPackage(
130129
packageOptions /*: NpmPackageOptions */,
131130
execOptions /*: ?ExecOptsSync */,
132131
) /*: ShellString */ {
133-
const {otp, tags, access} = packageOptions;
132+
const {tags, access} = packageOptions;
134133

135134
let tagsFlag = '';
136135
if (tags != null) {
@@ -142,13 +141,12 @@ function publishPackage(
142141
.join('');
143142
}
144143

145-
const otpFlag = otp != null ? ` --otp ${otp}` : '';
146144
const accessFlag = access != null ? ` --access ${access}` : '';
147145
const options /*: ExecOptsSync */ = execOptions
148146
? {...execOptions, cwd: packagePath}
149147
: {cwd: packagePath};
150148

151-
return exec(`npm publish${tagsFlag}${otpFlag}${accessFlag}`, options);
149+
return exec(`npm publish${tagsFlag}${accessFlag}`, options);
152150
}
153151

154152
/**

0 commit comments

Comments
 (0)