Skip to content

Commit fadcf7b

Browse files
lunaleapsfacebook-github-bot
authored andcommitted
set to public access by default
Summary: Changelog: [Internal] - Specify `access` flag in publishing nightlies Reviewed By: cipolleschi Differential Revision: D54230208 fbshipit-source-id: 7711eee62e8e01a12d6604831754d36a5cd5dc13
1 parent 3eaf965 commit fadcf7b

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

scripts/npm-utils.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ type PackageJSON = {
3434
...
3535
}
3636
type NpmPackageOptions = {
37-
tags: ?Array<string>,
37+
tags: ?Array<string> | ?Array<?string>,
3838
otp: ?string,
39+
access?: ?('public' | 'restricted')
3940
}
4041
*/
4142

@@ -131,14 +132,21 @@ function publishPackage(
131132
packageOptions /*: NpmPackageOptions */,
132133
execOptions /*: ?ExecOptsSync */,
133134
) /*: ShellString */ {
134-
const {otp, tags} = packageOptions;
135-
const tagsFlag = tags != null ? tags.map(t => ` --tag ${t}`).join('') : '';
135+
const {otp, tags, access} = packageOptions;
136+
const tagsFlag =
137+
tags != null
138+
? tags
139+
.filter(Boolean)
140+
.map(t => ` --tag ${t}`)
141+
.join('')
142+
: '';
136143
const otpFlag = otp != null ? ` --otp ${otp}` : '';
144+
const accessFlag = access != null ? ` --access ${access}` : '';
137145
const options = execOptions
138146
? {...execOptions, cwd: packagePath}
139147
: {cwd: packagePath};
140148

141-
return exec(`npm publish${tagsFlag}${otpFlag}`, options);
149+
return exec(`npm publish${tagsFlag}${otpFlag}${accessFlag}`, options);
142150
}
143151

144152
function diffPackages(

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ describe('publish-npm', () => {
160160
expect(setVersionMock).toBeCalledWith(expectedVersion);
161161
expect(generateAndroidArtifactsMock).toHaveBeenCalled();
162162
expect(publishPackageMock.mock.calls).toEqual([
163-
['path/to/monorepo/pkg-a', {otp: undefined, tags: ['nightly']}],
164-
['path/to/monorepo/pkg-b', {otp: undefined, tags: ['nightly']}],
163+
[
164+
'path/to/monorepo/pkg-a',
165+
{otp: undefined, tags: ['nightly'], access: 'public'},
166+
],
167+
[
168+
'path/to/monorepo/pkg-b',
169+
{otp: undefined, tags: ['nightly'], access: 'public'},
170+
],
165171
[
166172
path.join(REPO_ROOT, 'packages', 'react-native'),
167173
{otp: undefined, tags: ['nightly']},
@@ -249,8 +255,14 @@ describe('publish-npm', () => {
249255

250256
// Note that we don't call `publishPackage` for react-native, or monorepo/pkg-c
251257
expect(publishPackageMock.mock.calls).toEqual([
252-
['path/to/monorepo/pkg-a', {otp: undefined, tags: ['nightly']}],
253-
['path/to/monorepo/pkg-b', {otp: undefined, tags: ['nightly']}],
258+
[
259+
'path/to/monorepo/pkg-a',
260+
{otp: undefined, tags: ['nightly'], access: 'public'},
261+
],
262+
[
263+
'path/to/monorepo/pkg-b',
264+
{otp: undefined, tags: ['nightly'], access: 'public'},
265+
],
254266
]);
255267

256268
expect(consoleLogMock.mock.calls).toEqual([

scripts/releases-ci/publish-npm.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ async function publishMonorepoPackages(tag /*: ?string */) {
7575
for (const packageInfo of Object.values(projectInfo)) {
7676
console.log(`Publishing ${packageInfo.name}...`);
7777
const result = publishPackage(packageInfo.path, {
78-
// $FlowFixMe[incompatible-call]
7978
tags: [tag],
8079
otp: process.env.NPM_CONFIG_OTP,
80+
access: 'public',
8181
});
8282

8383
const spec = `${packageInfo.name}@${packageInfo.packageJson.version}`;
@@ -122,7 +122,6 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise<void> */ {
122122

123123
const packagePath = path.join(REPO_ROOT, 'packages', 'react-native');
124124
const result = publishPackage(packagePath, {
125-
// $FlowFixMe[incompatible-call]
126125
tags: [tag],
127126
otp: process.env.NPM_CONFIG_OTP,
128127
});

0 commit comments

Comments
 (0)