From 06d6229b7b673d764aa8b0948aeab02b6ef75d6f Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 11 May 2026 12:55:12 -0700 Subject: [PATCH] Remove V0 nightly download path from ios-prebuild (#56759) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56759 The legacy Hermes V0 nightly dist-tag ('nightly') has been removed. This commit cleans up the ios-prebuild Hermes download logic: - Remove the 'nightly' sentinel string and getNightlyVersionFromNPM() - Remove DOWNLOAD_PREBUILT_NIGHTLY_TARBALL source type and downloadPrebuiltNightlyTarball() - Remove getNightlyTarballUrl() (was fetching from Maven Snapshots for V0 nightlies) - Rename getLatestV1VersionFromNPM -> getLatestHermesVersionFromNPM - Update prepare-app-utils.js to use 'latest-v1' instead of 'nightly' for HERMES_VERSION ## Changelog: [Internal] - Reviewed By: cortinico Differential Revision: D104649632 fbshipit-source-id: 91f7c67ee59a3ef835d78146e5ad5ecab25a17bf --- .../scripts/ios-prebuild/hermes.js | 89 ++++--------------- .../__tests__/prepare-app-utils-test.js | 16 ++-- .../scripts/swiftpm/prepare-app-utils.js | 4 +- 3 files changed, 29 insertions(+), 80 deletions(-) diff --git a/packages/react-native/scripts/ios-prebuild/hermes.js b/packages/react-native/scripts/ios-prebuild/hermes.js index 7e8a7600606..94f7883b49b 100644 --- a/packages/react-native/scripts/ios-prebuild/hermes.js +++ b/packages/react-native/scripts/ios-prebuild/hermes.js @@ -8,7 +8,7 @@ * @format */ -const {computeNightlyTarballURL, createLogger} = require('./utils'); +const {createLogger} = require('./utils'); const {execSync} = require('child_process'); const fs = require('fs'); const path = require('path'); @@ -23,10 +23,15 @@ import type {BuildFlavor, Destination, Platform} from './types'; */ /** - * Downloads hermes artifacts from the specified version and build type. If you want to specify a specific - * version of hermes, use the HERMES_VERSION environment variable. The path to the artifacts will be inside - * the .build/artifacts/hermes folder, but this can be overridden by setting the HERMES_ENGINE_TARBALL_PATH - * environment variable. If this varuable is set, the script will use the local tarball instead of downloading it. + * Downloads hermes artifacts from the specified version and build type. + * + * Version resolution (in order): + * 1. `HERMES_ENGINE_TARBALL_PATH` env var → use that local file directly + * 2. `HERMES_VERSION` env var: + * - `"latest-v1"` (default) → resolve latest version from npm's `latest-v1` dist-tag + * - any semver string → use that exact version from Maven Central + * The resolved version is downloaded from Maven Central (stable) or from a + * Maven snapshot repo as fallback. */ async function prepareHermesArtifactsAsync( reactNativeVersion /*:string*/, @@ -57,12 +62,9 @@ async function prepareHermesArtifactsAsync( let resolvedVersion = process.env.HERMES_VERSION ?? 'latest-v1'; if (resolvedVersion === 'latest-v1') { + // TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm hermesLog('Using latest-v1 tarball'); - const hermesVersion = await getLatestV1VersionFromNPM(); - resolvedVersion = hermesVersion; - } else if (resolvedVersion === 'nightly') { - hermesLog('Using latest nightly tarball'); - const hermesVersion = await getNightlyVersionFromNPM(); + const hermesVersion = await getLatestHermesVersionFromNPM(); resolvedVersion = hermesVersion; } @@ -106,7 +108,8 @@ async function prepareHermesArtifactsAsync( return artifactsPath; } -async function getLatestV1VersionFromNPM() /*: Promise */ { +async function getLatestHermesVersionFromNPM() /*: Promise */ { + // TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm const npmResponse /*: Response */ = await fetch( 'https://registry.npmjs.org/hermes-compiler/latest-v1', ); @@ -118,43 +121,23 @@ async function getLatestV1VersionFromNPM() /*: Promise */ { } const json = await npmResponse.json(); - const latestV1 = json.version; - hermesLog(`Using version ${latestV1}`); - return latestV1; -} - -async function getNightlyVersionFromNPM() /*: Promise */ { - const npmResponse /*: Response */ = await fetch( - 'https://registry.npmjs.org/hermes-compiler/nightly', - ); - - if (!npmResponse.ok) { - throw new Error( - `Couldn't get a response from NPM: ${npmResponse.status} ${npmResponse.statusText}`, - ); - } - - const json = await npmResponse.json(); - const latestNightly = json.version; - hermesLog(`Using version ${latestNightly}`); - return latestNightly; + const latestVersion = json.version; + hermesLog(`Using version ${latestVersion}`); + return latestVersion; } /*:: type HermesEngineSourceType = | 'local_prebuilt_tarball' | 'download_prebuild_tarball' - | 'download_prebuilt_nightly_tarball' */ const HermesEngineSourceTypes /*:{ +DOWNLOAD_PREBUILD_TARBALL: "download_prebuild_tarball", - +DOWNLOAD_PREBUILT_NIGHTLY_TARBALL: "download_prebuilt_nightly_tarball", +LOCAL_PREBUILT_TARBALL: "local_prebuilt_tarball" } */ = { LOCAL_PREBUILT_TARBALL: 'local_prebuilt_tarball', DOWNLOAD_PREBUILD_TARBALL: 'download_prebuild_tarball', - DOWNLOAD_PREBUILT_NIGHTLY_TARBALL: 'download_prebuilt_nightly_tarball', }; /** @@ -216,21 +199,6 @@ function getTarballUrl( return `${mavenRepoUrl}/${namespace}/hermes-ios/${version}/hermes-ios-${version}-hermes-ios-${buildType.toLowerCase()}.tar.gz`; } -async function getNightlyTarballUrl( - version /*: string */, - buildType /*: BuildFlavor */, -) /*: Promise */ { - const artifactCoordinate = 'hermes-ios'; - const artifactName = `hermes-ios-${buildType.toLowerCase()}.tar.gz`; - return await computeNightlyTarballURL( - version, - buildType, - 'hermes', - artifactCoordinate, - artifactName, - ); -} - /** * Checks if a Hermes artifact exists at the given URL using fetch instead of curl */ @@ -266,17 +234,10 @@ async function hermesSourceType( return HermesEngineSourceTypes.DOWNLOAD_PREBUILD_TARBALL; } - // For nightly tarball, we need to resolve redirects first - const nightlyUrl = await getNightlyTarballUrl(version, buildType); - if (await hermesArtifactExists(nightlyUrl)) { - hermesLog('Using download prebuild nightly tarball'); - return HermesEngineSourceTypes.DOWNLOAD_PREBUILT_NIGHTLY_TARBALL; - } - hermesLog( - 'Using download prebuild nightly tarball - this is a fallback and might not work.', + `No prebuilt tarball found for version ${version}. Falling back to DOWNLOAD_PREBUILD_TARBALL, which may fail.`, ); - return HermesEngineSourceTypes.DOWNLOAD_PREBUILT_NIGHTLY_TARBALL; + return HermesEngineSourceTypes.DOWNLOAD_PREBUILD_TARBALL; } async function resolveSourceFromSourceType( @@ -290,8 +251,6 @@ async function resolveSourceFromSourceType( return localPrebuiltTarball(); case HermesEngineSourceTypes.DOWNLOAD_PREBUILD_TARBALL: return downloadPrebuildTarball(version, buildType, artifactsPath); - case HermesEngineSourceTypes.DOWNLOAD_PREBUILT_NIGHTLY_TARBALL: - return downloadPrebuiltNightlyTarball(version, buildType, artifactsPath); default: abort( `[Hermes] Unsupported or invalid source type provided: ${sourceType}`, @@ -324,16 +283,6 @@ async function downloadPrebuildTarball( return downloadStableHermes(version, buildType, artifactsPath); } -async function downloadPrebuiltNightlyTarball( - version /*: string */, - buildType /*: BuildFlavor */, - artifactsPath /*: string*/, -) /*: Promise */ { - const url = await getNightlyTarballUrl(version, buildType); - hermesLog(`Using nightly tarball from URL: ${url}`); - return downloadHermesTarball(url, version, buildType, artifactsPath); -} - async function downloadStableHermes( version /*: string */, buildType /*: BuildFlavor */, diff --git a/packages/react-native/scripts/swiftpm/__tests__/prepare-app-utils-test.js b/packages/react-native/scripts/swiftpm/__tests__/prepare-app-utils-test.js index fa6059e1364..6519310d0a2 100644 --- a/packages/react-native/scripts/swiftpm/__tests__/prepare-app-utils-test.js +++ b/packages/react-native/scripts/swiftpm/__tests__/prepare-app-utils-test.js @@ -1093,7 +1093,7 @@ describe('runIosPrebuild', () => { process.env = originalProcessEnv; }); - it('should run iOS prebuild successfully with nightly versions', async () => { + it('should run iOS prebuild successfully with prebuilt versions', async () => { // Setup const reactNativePath = '/path/to/react-native'; @@ -1108,13 +1108,13 @@ describe('runIosPrebuild', () => { env: { ...originalProcessEnv, RN_DEP_VERSION: 'nightly', - HERMES_VERSION: 'nightly', + HERMES_VERSION: 'latest-v1', }, stdio: 'inherit', }); expect(mockExecSync).toHaveBeenCalledTimes(1); expect(mockConsoleLog).toHaveBeenCalledWith( - 'Running iOS prebuild with nightly versions...', + 'Running iOS prebuild with prebuilt versions...', ); expect(mockConsoleLog).toHaveBeenCalledWith('✓ iOS prebuild completed'); expect(mockConsoleLog).toHaveBeenCalledTimes(2); @@ -1135,7 +1135,7 @@ describe('runIosPrebuild', () => { env: { ...originalProcessEnv, RN_DEP_VERSION: 'nightly', - HERMES_VERSION: 'nightly', + HERMES_VERSION: 'latest-v1', }, stdio: 'inherit', }); @@ -1156,7 +1156,7 @@ describe('runIosPrebuild', () => { env: { ...originalProcessEnv, RN_DEP_VERSION: 'nightly', - HERMES_VERSION: 'nightly', + HERMES_VERSION: 'latest-v1', }, stdio: 'inherit', }); @@ -1181,12 +1181,12 @@ describe('runIosPrebuild', () => { env: { ...originalProcessEnv, RN_DEP_VERSION: 'nightly', - HERMES_VERSION: 'nightly', + HERMES_VERSION: 'latest-v1', }, stdio: 'inherit', }); expect(mockConsoleLog).toHaveBeenCalledWith( - 'Running iOS prebuild with nightly versions...', + 'Running iOS prebuild with prebuilt versions...', ); expect(mockConsoleLog).not.toHaveBeenCalledWith('✓ iOS prebuild completed'); }); @@ -1221,7 +1221,7 @@ describe('runIosPrebuild', () => { env: { ...originalProcessEnv, RN_DEP_VERSION: 'nightly', - HERMES_VERSION: 'nightly', + HERMES_VERSION: 'latest-v1', }, stdio: 'inherit', }); diff --git a/packages/react-native/scripts/swiftpm/prepare-app-utils.js b/packages/react-native/scripts/swiftpm/prepare-app-utils.js index 3632201c309..760f00ada89 100644 --- a/packages/react-native/scripts/swiftpm/prepare-app-utils.js +++ b/packages/react-native/scripts/swiftpm/prepare-app-utils.js @@ -73,12 +73,12 @@ async function runPodDeintegrate( async function runIosPrebuild( reactNativePath /*: string */, ) /*: Promise */ { - console.log('Running iOS prebuild with nightly versions...'); + console.log('Running iOS prebuild with prebuilt versions...'); const env = { ...process.env, RN_DEP_VERSION: 'nightly', - HERMES_VERSION: 'nightly', + HERMES_VERSION: 'latest-v1', }; try {