Skip to content

Commit 88ab262

Browse files
author
Adam Gleitman
committed
Adjust error handling slightly
1 parent 5c49cdb commit 88ab262

2 files changed

Lines changed: 7 additions & 17 deletions

File tree

packages/react-native/sdks/hermes-engine/hermes-engine.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ end
2121

2222
# package.json
2323
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
24-
version = findMatchingHermesVersion(package) || package['version'] # [macOS] Prefer special logic in findMatchingHermesVersion
24+
version = findMatchingHermesVersion(package) # [macOS] Use special logic instead of just package['version']
2525

2626
source_type = hermes_source_type(version, react_native_path)
2727
source = podspec_source(source_type, version, react_native_path)
2828

2929
Pod::Spec.new do |spec|
3030
spec.name = "hermes-engine"
31-
spec.version = version
31+
spec.version = version || package['version'] # [macOS] If version is nil, fall back to package version so CocoaPods doesn't fail
3232
spec.summary = "Hermes is a small and lightweight JavaScript engine optimized for running React Native."
3333
spec.description = "Hermes is a JavaScript engine optimized for fast start-up of React Native apps. It features ahead-of-time static optimization and compact bytecode."
3434
spec.homepage = "https://hermesengine.dev"

packages/react-native/sdks/hermes-engine/hermes-utils.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -296,30 +296,20 @@ def resolve_url_redirects(url)
296296
return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
297297
end
298298

299-
# [macOS react-native-macos does not publish macos specific hermes artifacts
300-
# so we attempt to find the latest patch version of the iOS artifacts and use that
299+
# [macOS
300+
# Tries to find a suitable Hermes version for a given react-native-macos package.
301+
# For stable branches, we prefer this to be specified as a peer dependency.
301302
def findMatchingHermesVersion(package)
302303
if package['version'] == "1000.0.0"
303-
# The main branch builds from source, so skip the artifact check
304+
# The main branch builds from source, so skip this check
304305
return nil
305306
end
306307

307-
# This assumes that whatever peer dependency we specify has an artifact
308308
if packages['peerDependencies']
309309
return package['peerDependencies']['react-native']
310310
end
311311

312-
# See https://central.sonatype.org/search/rest-api-guide/ for details on query params
313-
versionWithoutPatch = "#{version.match(/^(\d+\.\d+)/)}"
314-
res, = Open3.capture3("curl -s https://search.maven.org/solrsearch/select?q=g:com.facebook.react+AND+a:react-native-artifacts+AND+v:#{versionWithoutPatch}.*&core=gav&rows=1&wt=json")
315-
begin
316-
wt = JSON.parse(res)
317-
rescue
318-
hermes_log("Failed to parse JSON from Maven search response:\n#{res}", :warning)
319-
return nil
320-
end
321-
response = wt['response']
322-
return response['docs'][0]['v'] unless response['numFound'] == 0
312+
hermes_log("No matching Hermes version found. Defaulting to main branch, which may be unreliable.")
323313
end
324314
# macOS]
325315

0 commit comments

Comments
 (0)