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

fix: fix @react-native-community/cli-platform-* packages not being found in monorepos #47308

Closed
wants to merge 2 commits into from

Conversation

tido64
Copy link
Collaborator

@tido64 tido64 commented Oct 30, 2024

Summary:

Fix @react-native-community/cli-platform-* packages not being found in monorepos.

Note that we are making the assumption that process.cwd() returns the project root. This is the same assumption that @react-native-community/cli makes. Specifically, findProjectRoot() has an optional argument that defaults to process.cwd():

As far as I can see, the project root argument is only ever used in tests.

Changelog:

[GENERAL] [FIXED] - Fix @react-native-community/cli-platform-* packages not being found in monorepos

Test Plan:

  1. Clone/check out this branch: chore: bump react-native to 0.76 microsoft/rnx-kit#3409
  2. Cherry-pick fix: fix @react-native-community/cli not being found in monorepos #47304
  3. Cherry-pick fix: fix @react-native-community/cli-platform-* packages not being found in monorepos #47308
  4. Run react-native config inside packages/test-app
  5. Verify that projects is populated

Before:

  "healthChecks": [],
  "platforms": {},
  "assets": [],
  "project": {}
}

After:

  "healthChecks": [],
  "platforms": {
    "ios": {},
    "android": {}
  },
  "assets": [],
  "project": {
    "ios": {
      "sourceDir": "/~/packages/test-app/ios",
      "xcodeProject": {
        "name": "SampleCrossApp.xcworkspace",
        "path": ".",
        "isWorkspace": true
      },
      "automaticPodsInstallation": false,
      "assets": []
    },
    "android": {
      "sourceDir": "/~/packages/test-app/android",
      "appName": "app",
      "packageName": "com.msft.identity.client.sample.local",
      "applicationId": "com.msft.identity.client.sample.local",
      "mainActivity": "com.microsoft.reacttestapp.MainActivity",
      "assets": []
    }
  }
}

@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: Microsoft Partner: Microsoft Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Oct 30, 2024
@tido64 tido64 requested review from blakef and cortinico October 30, 2024 15:17
@cortinico cortinico requested a review from robhogan October 30, 2024 22:51
@tido64 tido64 changed the title fix: fix @react-native-community/cli-platform-* packages not being found in pnpm setups fix: fix @react-native-community/cli-platform-* packages not being found in monorepos Nov 1, 2024
@tido64 tido64 force-pushed the tido/fix-rncli-pnpm-2 branch from 9d3672a to 01e7c20 Compare November 1, 2024 12:22
@tido64 tido64 force-pushed the tido/fix-rncli-pnpm-2 branch from 01e7c20 to 3e56095 Compare November 5, 2024 08:53
@robhogan
Copy link
Contributor

Note that we're assuming that the current working directory is the project root. This is also what @react-native-community/cli assumes (see https://github.com/react-native-community/cli/blob/14.x/packages/cli-tools/src/findProjectRoot.ts).

Thanks for adding that comment - I don't love this assumption, but on the basis that the CLI is already making it, I'm OK building on it and calling this non-breaking.

I think we should investigate using an optional peer dependency here though - the sticking point might be the number of non-CLI users on Yarn classic.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 12, 2025
@facebook-github-bot
Copy link
Contributor

@robhogan merged this pull request in 7926d65.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @tido64 in 7926d65

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

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: Microsoft Partner: Microsoft 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