The "Javascript PR" CI checks were failing, because the jest tests would call an RNM-only JS function getPkgJsonVersion, which used some NodeJS built in modules like path and fs. Apparently, such modules need to be mocked out in jest. Rather than write the appropriate mocks (and further our diffs from upstream), let's instead retactor away the use of that extra JS function.
Upstream, the CircleCI publish job is triggered by a new tag getting pushed to the React Native repo. The tag would set the environment variable CIRCLE_TAG, and run the steps and scripts needed to publish a new React Native NPM package. The script publish-npm.js would reference this environment variable to find out the version to publish. In React Native macOS, because nothing set CIRCLE_TAG, we instead calculated the next version ourselves, wrote it to the package.json, and read it via the getPkgJsonVersion. This was done around https://github.com/microsoft/react-native-macos/pull/1777 timeframe.
Since we want to get rid of getPkgJsonVersion, and we already calculate the next version we want in our CI, let's just set that version to an environment variable in the CI job, and then pass that as the CIRCLE_TAG environment variable to the publish-npm.js. This is a trick we've done earlier, we also pass CIRCLE_BRANCH to prepare-package-for-release.js.
Test Plan:
The PR checks NPM Publish Dry Run and Javascript PR (Which tests publish-npm.js should both succeed, for this PR and the equivalent PR in 0.73-stable: #2022
Summary:
The "Javascript PR" CI checks were failing, because the jest tests would call an RNM-only JS function
getPkgJsonVersion
, which used some NodeJS built in modules likepath
andfs
. Apparently, such modules need to be mocked out injest
. Rather than write the appropriate mocks (and further our diffs from upstream), let's instead retactor away the use of that extra JS function.Upstream, the CircleCI publish job is triggered by a new tag getting pushed to the React Native repo. The tag would set the environment variable
CIRCLE_TAG
, and run the steps and scripts needed to publish a new React Native NPM package. The scriptpublish-npm.js
would reference this environment variable to find out the version to publish. In React Native macOS, because nothing setCIRCLE_TAG
, we instead calculated the next version ourselves, wrote it to thepackage.json
, and read it via thegetPkgJsonVersion
. This was done around https://github.com/microsoft/react-native-macos/pull/1777 timeframe.Since we want to get rid of
getPkgJsonVersion
, and we already calculate the next version we want in our CI, let's just set that version to an environment variable in the CI job, and then pass that as theCIRCLE_TAG
environment variable to thepublish-npm.js
. This is a trick we've done earlier, we also passCIRCLE_BRANCH
toprepare-package-for-release.js
.Test Plan:
The PR checks
NPM Publish Dry Run
andJavascript PR
(Which testspublish-npm.js
should both succeed, for this PR and the equivalent PR in0.73-stable
: #2022