Skip to content

Commit 636e322

Browse files
committed
[RN] Fix build for 0.83-RC.1
1 parent 5fa907f commit 636e322

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ describe('publish-npm', () => {
9696
beforeEach(() => {
9797
jest.mock('../../shared/monorepoUtils', () => ({
9898
...jest.requireActual('../../shared/monorepoUtils'),
99-
getWorkspaceRoot: jest.fn().mockResolvedValue({version: '1000.0.0'}),
99+
getReactNativePackage: jest
100+
.fn()
101+
.mockResolvedValue({version: '1000.0.0'}),
100102
}));
101103
});
102104

@@ -167,7 +169,7 @@ describe('publish-npm', () => {
167169
getBranchName.mockReturnValueOnce('0.83-stable');
168170
jest.mock('../../shared/monorepoUtils', () => ({
169171
...jest.requireActual('../../shared/monorepoUtils'),
170-
getWorkspaceRoot: jest
172+
getReactNativePackage: jest
171173
.fn()
172174
.mockResolvedValue({version: '0.83.0-rc.0'}),
173175
}));

scripts/releases-ci/publish-npm.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ const {
2727
publishExternalArtifactsToMaven,
2828
} = require('../releases/utils/release-utils');
2929
const {getBranchName} = require('../releases/utils/scm-utils');
30-
const {REPO_ROOT} = require('../shared/consts');
31-
const {getPackages, getWorkspaceRoot} = require('../shared/monorepoUtils');
32-
const path = require('path');
30+
const {REACT_NATIVE_PACKAGE_DIR} = require('../shared/consts');
31+
const {getPackages, getReactNativePackage} = require('../shared/monorepoUtils');
3332
const yargs = require('yargs');
3433

3534
/**
@@ -109,7 +108,7 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise<void> */ {
109108
// Before updating React Native artifacts versions for dry-run, we check if the version has already been set.
110109
// If it has, we don't need to update the artifacts at all (at this will revert them back to 1000.0.0)
111110
// If it hasn't, we can update the native artifacts accordingly.
112-
const projectInfo = await getWorkspaceRoot();
111+
const projectInfo = await getReactNativePackage();
113112

114113
if (projectInfo.version === '1000.0.0') {
115114
// Set hermes versions to latest available if not on a stable branch
@@ -134,8 +133,7 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise<void> */ {
134133
// NPM publishing is done just after.
135134
publishExternalArtifactsToMaven(version, buildType);
136135

137-
const packagePath = path.join(REPO_ROOT, 'packages', 'react-native');
138-
const result = publishPackage(packagePath, {
136+
const result = publishPackage(REACT_NATIVE_PACKAGE_DIR, {
139137
tags: [tag],
140138
});
141139

scripts/shared/monorepoUtils.js

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

11-
const {REPO_ROOT} = require('./consts');
11+
const {REACT_NATIVE_PACKAGE_DIR, REPO_ROOT} = require('./consts');
1212
const {promises: fs} = require('fs');
1313
const glob = require('glob');
1414
const path = require('path');
@@ -89,6 +89,16 @@ async function getWorkspaceRoot() /*: Promise<PackageInfo> */ {
8989
return packageInfo;
9090
}
9191

92+
/**
93+
* Get the parsed package metadata for the main react-native package.
94+
*/
95+
async function getReactNativePackage() /*: Promise<PackageInfo> */ {
96+
const [, packageInfo] = await parsePackageInfo(
97+
path.join(REACT_NATIVE_PACKAGE_DIR, 'package.json'),
98+
);
99+
return packageInfo;
100+
}
101+
92102
async function parsePackageInfo(
93103
packageJsonPath /*: string */,
94104
) /*: Promise<[string, PackageInfo]> */ {
@@ -158,4 +168,5 @@ module.exports = {
158168
getPackages,
159169
getWorkspaceRoot,
160170
updatePackageJson,
171+
getReactNativePackage,
161172
};

0 commit comments

Comments
 (0)