Skip to content

Commit f8a6dcb

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Automate fetching of the latest nightly
Summary: This change simplify testing building React Native core using SwiftPM. It let you use the HERMES_VERSION env var to automatically fetch the latest nightly. To do so, just call: ``` HERMES_VERSION=nightly node script/ios-prebuild ``` ## Changelog: [Internal] - Handle the `HERMES_VERSION=nightly` case for iOS prebuilds Differential Revision: D75146936
1 parent f5eaaf7 commit f8a6dcb

File tree

1 file changed

+24
-1
lines changed
  • packages/react-native/scripts/ios-prebuild

1 file changed

+24
-1
lines changed

packages/react-native/scripts/ios-prebuild/hermes.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ async function prepareHermesArtifactsAsync(
4747
// Only check if the artifacts folder exists if we are not using a local tarball
4848
if (!localPath) {
4949
// Resolve the version from the environment variable or use the default version
50-
const resolvedVersion = process.env.HERMES_VERSION ?? version;
50+
let resolvedVersion = process.env.HERMES_VERSION ?? version;
51+
52+
if (resolvedVersion === 'nightly') {
53+
hermesLog('Using latest nightly tarball');
54+
const hermesVersion = await getNightlyVersionFromNPM();
55+
resolvedVersion = hermesVersion;
56+
}
5157

5258
// Check if the Hermes artifacts are already downloaded
5359
if (
@@ -89,6 +95,23 @@ async function prepareHermesArtifactsAsync(
8995
return artifactsPath;
9096
}
9197

98+
async function getNightlyVersionFromNPM() /*: Promise<string> */ {
99+
const npmResponse /*: Response */ = await fetch(
100+
'https://registry.npmjs.org/react-native/nightly',
101+
);
102+
103+
if (!npmResponse.ok) {
104+
throw new Error(
105+
`Couldn't get an answer from NPM: ${npmResponse.status} ${npmResponse.statusText}`,
106+
);
107+
}
108+
109+
const json = await npmResponse.json();
110+
const latestNightly = json.version;
111+
hermesLog(`Using version ${latestNightly}`);
112+
return latestNightly;
113+
}
114+
92115
/*::
93116
type HermesEngineSourceType =
94117
| 'local_prebuilt_tarball'

0 commit comments

Comments
 (0)