Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build codegen on postinstall #46227

Closed
wants to merge 1 commit into from

Conversation

okwasniewski
Copy link
Contributor

Summary:

This PR solves a small issue I've encountered when working with the repo.

When changing branches we often run yarn to reinstall dependencies (let's say we change from 0.74-stable to main).

There are lots of changes between those two versions in the react-native-codegen package. This causes an issue when we install pods in packages/rn-tester the old version of codegen is used (the one cached from 0.74-stable) leading to a big error that's hard to solve at first.

This PR solves this by building codegen on postinstall. I've seen many newcomers blocked by this issue (and rerunning yarn is the natural thing to do in this situation)

Changelog:

[INTERNAL] [ADDED] - Build codegen on postinstall when working with the monorepo

Test Plan:

Run yarn

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner labels Aug 27, 2024
@react-native-bot
Copy link
Collaborator

Warnings
⚠️ 🔒 package.json - Changes were made to package.json. This will require a manual import by a Facebook employee.

Generated by 🚫 dangerJS against 3918079

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 27, 2024
@facebook-github-bot
Copy link
Contributor

@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@huntie merged this pull request in 0cb97f0.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 27, 2024
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @okwasniewski in 0cb97f0

When will my fix make it into a release? | How to file a pick request?

Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Sep 10, 2024
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Sep 10, 2024
facebook-github-bot pushed a commit that referenced this pull request Sep 16, 2024
Summary:
This reverts commit 0cb97f0.

Revert this commit that adds a `post install` script for a couple of reasons:

1. (EDIT: This turns out to be unrelated) The `postinstall` script causes `yarn install` to fail on React Native macOS, where we use Yarn 4. I'm not entirely sure why, but I probably won't debug it for the rest of the reasons.
2. `postinstall` scripts (at least inside Microsoft) are viewed as a security risk. Any package in your dependency tree can get compromised, add the phase, and run arbitrary code. This has happened in the past with React Native past if I recall correctly. As such, we disable `postinstall` scripts in many of our repos (including `rnx-kit` and `react-native-test-app`).
3. The issue this is trying to solve is to help newcomers avoid a stale cache when they switch branches in the React Native monorepo and only run `yarn install`. I think it would be sufficient to add some documentation somewhere that it is expected one runs `yarn && yarn build` to use this repo locally? That's a fairly common practice in monorepos, at least ones inside Microsoft.

## Changelog:

[INTERNAL] [SECURITY] - Remove post install script phase in the React Native monorepo

Pull Request resolved: #46420

Test Plan: CI should pass

Reviewed By: christophpurrer, robhogan, cortinico, rshest

Differential Revision: D62755022

Pulled By: huntie

fbshipit-source-id: bf94ed33e3e451ea337ef7a6984f7ba964d0b212
blakef pushed a commit that referenced this pull request Sep 23, 2024
Summary:
This reverts commit 0cb97f0.

Revert this commit that adds a `post install` script for a couple of reasons:

1. (EDIT: This turns out to be unrelated) The `postinstall` script causes `yarn install` to fail on React Native macOS, where we use Yarn 4. I'm not entirely sure why, but I probably won't debug it for the rest of the reasons.
2. `postinstall` scripts (at least inside Microsoft) are viewed as a security risk. Any package in your dependency tree can get compromised, add the phase, and run arbitrary code. This has happened in the past with React Native past if I recall correctly. As such, we disable `postinstall` scripts in many of our repos (including `rnx-kit` and `react-native-test-app`).
3. The issue this is trying to solve is to help newcomers avoid a stale cache when they switch branches in the React Native monorepo and only run `yarn install`. I think it would be sufficient to add some documentation somewhere that it is expected one runs `yarn && yarn build` to use this repo locally? That's a fairly common practice in monorepos, at least ones inside Microsoft.

## Changelog:

[INTERNAL] [SECURITY] - Remove post install script phase in the React Native monorepo

Pull Request resolved: #46420

Test Plan: CI should pass

Reviewed By: christophpurrer, robhogan, cortinico, rshest

Differential Revision: D62755022

Pulled By: huntie

fbshipit-source-id: bf94ed33e3e451ea337ef7a6984f7ba964d0b212
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Oct 19, 2024
@blakef blakef mentioned this pull request Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants