Skip to content

Conversation

@kraenhansen
Copy link
Collaborator

Merging this PR will:

With this change, we can start pushing multiple tags to the React Native fork, to enable multiple React Native versions, ultimately fixing #157.

@kraenhansen kraenhansen self-assigned this Jul 7, 2025
@kraenhansen kraenhansen added enhancement New feature or request Host 🏡 Our `react-native-node-api-modules` package labels Jul 7, 2025
@changeset-bot
Copy link

changeset-bot bot commented Jul 7, 2025

🦋 Changeset detected

Latest commit: 2b82046

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
react-native-node-api Minor
cmake-rn Patch
ferric-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kraenhansen kraenhansen requested a review from Copilot July 7, 2025 18:45
);
console.log(hermesPath);
} catch (error) {
process.exitCode = 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out this didn't result in a failure.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the hardcoded Hermes git tag with a version derived from the .hermesversion file in the React Native package and adjusts the clone logic and error handling accordingly.

  • Remove static HERMES_GIT_TAG and derive patchedTag from .hermesversion
  • Read and log the Hermes version from React Native’s SDK folder
  • Update the git clone command to use the dynamic tag and add better error handling
  • Add a changeset entry for the new behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/host/src/node/cli/hermes.ts Read .hermesversion, compute patchedTag, update clone command, and refine error handling
.changeset/upset-paws-follow.md Add a changeset to document deriving the fork tag from .hermesversion
Comments suppressed due to low confidence (1)

packages/host/src/node/cli/hermes.ts:63

  • [nitpick] Add unit tests covering the new logic that reads .hermesversion and constructs patchedTag, ensuring the correct tag string is produced for different version inputs.
        const patchedTag = `node-api-${hermesVersion}`;

"sdks",
".hermesversion"
);
const hermesVersion = fs.readFileSync(hermesVersionPath, "utf8").trim();
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap the .hermesversion read in a try/catch to surface a clear error if the file is missing or unreadable, e.g., ‘Failed to read Hermes version from .hermesversion: ’.

Suggested change
const hermesVersion = fs.readFileSync(hermesVersionPath, "utf8").trim();
let hermesVersion: string;
try {
hermesVersion = fs.readFileSync(hermesVersionPath, "utf8").trim();
} catch (error) {
throw new Error(`Failed to read Hermes version from ${hermesVersionPath}: ${error.message}`);
}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very unlikely to happen. If I were to do this, I would call a function instead of using a mutable var.

Comment on lines +93 to +96
console.error(
`\n🛑 React Native uses the ${hermesVersion} tag and cloning our fork failed.`,
`Please see the Node-API package's peer dependency on "react-native" for supported versions.`
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we would match on the output of the command, but that isn't yet supported by bufout (see kraenhansen/bufout#2)

@kraenhansen kraenhansen added Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) labels Jul 7, 2025
@kraenhansen kraenhansen merged commit bd733b8 into main Jul 12, 2025
15 of 18 checks passed
@kraenhansen kraenhansen deleted the kh/derive-hermes-tag branch July 12, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) enhancement New feature or request Host 🏡 Our `react-native-node-api-modules` package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants