Compare commits

...
Author SHA1 Message Date
Nicola Corti 07da3f16a0 Remove unused --otp property from release infrastructure 2025-09-15 16:32:41 +01:00
5 changed files with 18 additions and 43 deletions
@@ -282,8 +282,6 @@ describe('publish-npm', () => {
code: 0,
}));
process.env.NPM_CONFIG_OTP = 'otp';
await publishNpm('release');
expect(setVersionMock).not.toBeCalled();
@@ -303,7 +301,7 @@ describe('publish-npm', () => {
expect(publishPackageMock.mock.calls).toEqual([
[
path.join(REPO_ROOT, 'packages', 'react-native'),
{otp: process.env.NPM_CONFIG_OTP, tags: ['0.81-stable']},
{tags: ['0.81-stable']},
],
]);
@@ -322,8 +320,6 @@ describe('publish-npm', () => {
code: 0,
}));
process.env.NPM_CONFIG_OTP = 'otp';
await publishNpm('release');
expect(updateReactNativeArtifactsMock).not.toBeCalled();
@@ -341,10 +337,7 @@ describe('publish-npm', () => {
);
expect(publishPackageMock.mock.calls).toEqual([
[
path.join(REPO_ROOT, 'packages', 'react-native'),
{otp: process.env.NPM_CONFIG_OTP, tags: ['latest']},
],
[path.join(REPO_ROOT, 'packages', 'react-native'), {tags: ['latest']}],
]);
expect(consoleLogMock.mock.calls).toEqual([
@@ -365,8 +358,6 @@ describe('publish-npm', () => {
execMock.mockReturnValueOnce({code: 1});
isTaggedLatestMock.mockReturnValueOnce(true);
process.env.NPM_CONFIG_OTP = 'otp';
await expect(async () => {
await publishNpm('release');
}).rejects.toThrow(
@@ -388,10 +379,7 @@ describe('publish-npm', () => {
);
expect(publishPackageMock.mock.calls).toEqual([
[
path.join(REPO_ROOT, 'packages', 'react-native'),
{otp: process.env.NPM_CONFIG_OTP, tags: ['latest']},
],
[path.join(REPO_ROOT, 'packages', 'react-native'), {tags: ['latest']}],
]);
expect(consoleLogMock).not.toHaveBeenCalled();
});
@@ -406,8 +394,6 @@ describe('publish-npm', () => {
code: 0,
}));
process.env.NPM_CONFIG_OTP = 'otp';
await publishNpm('release');
expect(setVersionMock).not.toBeCalled();
@@ -425,10 +411,7 @@ describe('publish-npm', () => {
);
expect(publishPackageMock.mock.calls).toEqual([
[
path.join(REPO_ROOT, 'packages', 'react-native'),
{otp: process.env.NPM_CONFIG_OTP, tags: ['next']},
],
[path.join(REPO_ROOT, 'packages', 'react-native'), {tags: ['next']}],
]);
expect(consoleLogMock.mock.calls).toEqual([
[`Published react-native@${expectedVersion} to npm`],
-2
View File
@@ -76,7 +76,6 @@ async function publishMonorepoPackages(tag /*: ?string */) {
console.log(`Publishing ${packageInfo.name}...`);
const result = publishPackage(packageInfo.path, {
tags: [tag],
otp: process.env.NPM_CONFIG_OTP,
access: 'public',
});
@@ -122,7 +121,6 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise<void> */ {
const packagePath = path.join(REPO_ROOT, 'packages', 'react-native');
const result = publishPackage(packagePath, {
tags: [tag],
otp: process.env.NPM_CONFIG_OTP,
});
if (result.code) {
@@ -14,7 +14,6 @@ const {execSync} = require('child_process');
const {parseArgs} = require('util');
const PUBLISH_PACKAGES_TAG = '#publish-packages-to-npm';
const NPM_CONFIG_OTP = process.env.NPM_CONFIG_OTP;
const config = {
options: {
@@ -139,7 +138,6 @@ function runPublish(
) {
const result = publishPackage(packagePath, {
tags,
otp: NPM_CONFIG_OTP,
});
if (result.code !== 0) {
@@ -33,37 +33,35 @@ describe('npm-utils', () => {
it('should run publish command', () => {
publishPackage(
'path/to/my-package',
{tags: ['latest'], otp: 'otp'},
{tags: ['latest']},
{silent: true, cwd: 'i/expect/this/to/be/overriden'},
);
expect(execMock).toHaveBeenCalledWith(
'npm publish --tag latest --otp otp',
{silent: true, cwd: 'path/to/my-package'},
);
expect(execMock).toHaveBeenCalledWith('npm publish --tag latest', {
silent: true,
cwd: 'path/to/my-package',
});
});
it('should run publish command when no execOptions', () => {
publishPackage('path/to/my-package', {tags: ['latest'], otp: 'otp'});
expect(execMock).toHaveBeenCalledWith(
'npm publish --tag latest --otp otp',
{cwd: 'path/to/my-package'},
);
publishPackage('path/to/my-package', {tags: ['latest']});
expect(execMock).toHaveBeenCalledWith('npm publish --tag latest', {
cwd: 'path/to/my-package',
});
});
it('should handle multiple tags', () => {
publishPackage('path/to/my-package', {
tags: ['next', '0.72-stable'],
otp: 'otp',
});
expect(execMock).toHaveBeenCalledWith(
'npm publish --tag next --tag 0.72-stable --otp otp',
'npm publish --tag next --tag 0.72-stable',
{cwd: 'path/to/my-package'},
);
});
it('should handle -no-tag', () => {
publishPackage('path/to/my-package', {tags: ['--no-tag'], otp: 'otp'});
expect(execMock).toHaveBeenCalledWith('npm publish --no-tag --otp otp', {
publishPackage('path/to/my-package', {tags: ['--no-tag']});
expect(execMock).toHaveBeenCalledWith('npm publish --no-tag', {
cwd: 'path/to/my-package',
});
});
+2 -4
View File
@@ -35,7 +35,6 @@ type PackageJSON = {
}
type NpmPackageOptions = {
tags: ?Array<string> | ?Array<?string>,
otp: ?string,
access?: ?('public' | 'restricted')
}
*/
@@ -130,7 +129,7 @@ function publishPackage(
packageOptions /*: NpmPackageOptions */,
execOptions /*: ?ExecOptsSync */,
) /*: ShellString */ {
const {otp, tags, access} = packageOptions;
const {tags, access} = packageOptions;
let tagsFlag = '';
if (tags != null) {
@@ -142,13 +141,12 @@ function publishPackage(
.join('');
}
const otpFlag = otp != null ? ` --otp ${otp}` : '';
const accessFlag = access != null ? ` --access ${access}` : '';
const options /*: ExecOptsSync */ = execOptions
? {...execOptions, cwd: packagePath}
: {cwd: packagePath};
return exec(`npm publish${tagsFlag}${otpFlag}${accessFlag}`, options);
return exec(`npm publish${tagsFlag}${accessFlag}`, options);
}
/**