Граф коммитов

9 Коммитов

Автор SHA1 Сообщение Дата
Max Thirouin c9e4d34885 - Support fnm when detecting node binary (#32890)
Summary:
Since 0.64, local code in `Bundle React Native code and images` step for iOS is not enough anymore.
This add support for [fnm](https://github.com/Schniz/fnm) that is widely used this days.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Added] - Support fnm when detecting node binary

Pull Request resolved: https://github.com/facebook/react-native/pull/32890

Test Plan: I use fnm & it's working. Tested this code via patch-package.

Reviewed By: christophpurrer

Differential Revision: D33766842

Pulled By: cortinico

fbshipit-source-id: 77bbda2c7742de9ec64e6faa9a3526d3997bb4aa
2022-01-26 07:52:45 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Ian Grayson 35bcf934b1 fix: find-node.sh now respects .nvmrc (#32712)
Summary:
React-native Xcode build steps (such as "Build JS Bundle") rely on `find.node-sh` to find the correct node binary, using nvm if present. We do this because Xcode may run build steps in a fresh shell environment, presumably for repeatable builds.

This PR fixes `find-node.sh`, to respect any `.nvmrc` file that may be present in the build environment.

Today: `find-node.sh` will set the shell environment to the system node version, and ignores any `.nvmrc` the project may provide to pin node for repeatable builds. By ignoring `.nvmrc`, node versions may differ depending on system environment — between developer laptops, or between developer and CI environments. 😞

This problem has been been noticed before in https://github.com/facebook/react-native/issues/8887

### Should this fix happen upstream?

Unfortunately this nvm behavior [is intended](https://github.com/nvm-sh/nvm/issues/2053),  for backwards compatibility

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - find-node.sh now respects .nvmrc

Pull Request resolved: https://github.com/facebook/react-native/pull/32712

Test Plan:
Before:
```bash
# nvm isn't loaded
$ which nvm

# we're on default system node
$ which node && node --version
/usr/local/bin/node
v17.0.1

$ echo v16.13.0 > .nvmrc
$ source ./scripts/find-node.sh

# Expected: v16.13.0
$ node --version
v17.0.1
```

After:
```bash
# we're on default system node
$ which node && node --version
/usr/local/bin/node
v17.0.1

$ echo v16.13.0 > .nvmrc
$ source ./scripts/find-node.sh

# Expected: v16.13.0
$ node --version
v16.13.0
```

After (no .nvmrc, should preserve previous behavior):
```bash
# we're on default system node
$ which node && node --version
/usr/local/bin/node
v17.0.1

$ source ./scripts/find-node.sh

$  nvm ls|grep default
default -> v14.17.1

# Expected: v14.17.1
$ node --version
v14.17.1
```

Reviewed By: sota000

Differential Revision: D32889629

Pulled By: ShikaSD

fbshipit-source-id: 527384055e303a87bad43413fb66a7fd117d1a63
2021-12-06 14:03:54 -08:00
Liam Jones 765844055b Add volta support to find-node.sh (#32611)
Summary:
This PR add [volta](https://volta.sh/) support to find-node.sh for use by `scripts/react-native-xcode.sh`, `scripts/generate-specs.sh`, etc.

## Changelog

[iOS] [Added] - add volta support to find-node.sh

Pull Request resolved: https://github.com/facebook/react-native/pull/32611

Test Plan:
Manually tested with volta installed node (and [relevant change](https://docs.volta.sh/guide/understanding#managing-your-project) added to the project's package.json). Without this patch, the `Bundle React Native code and images` Build Phase fails, with it, it succeeds.

Tested with both `curl https://get.volta.sh | bash` installed and `brew install volta`. One check works for both because the `node` shim will always be installed to the same location (and the required environment variable exports are the same also)

Wasn't sure if you'd want the package.json change applied to rn-tester? Shouldn't affect people who don't use volta. Shout if you want me to add it to this PR.

Reviewed By: cortinico

Differential Revision: D32498267

Pulled By: yungsters

fbshipit-source-id: 93ee187bd2178bfcd8f9009a1a0668c6f5583aa3
2021-11-19 05:27:57 -08:00
Michael Neeley 6334ac35ac Fixes Global Node Prefix Error (#31740)
Summary:
Some users have `node` installed globally which sets a `PREFIX` by default (so it knows where to put pkgs). We are looking for the "right" node on the next step anyway and if the user is using `nvm`, `PREFIX` breaks it.

closes https://github.com/facebook/react-native/issues/31181

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - Ignores global npm prefix

Pull Request resolved: https://github.com/facebook/react-native/pull/31740

Test Plan:
`yarn ios` now works, even if there's a `usr/local/bin/npm`

<img width="493" alt="Screen Shot 2021-06-17 at 10 14 08 AM" src="https://user-images.githubusercontent.com/2659478/122413946-c2f57200-cf54-11eb-817c-bd3c07ac50bf.png">

Reviewed By: yungsters

Differential Revision: D31237363

Pulled By: charlesbdudley

fbshipit-source-id: 4ee9c04f8b8ab4e815bafbe2d02e589d621577b4
2021-09-30 15:02:27 -07:00
PastLeo 3e7c310b1d add asdf-vm support in react-native-xcode.sh (#30111)
Summary:
About asdf-vm: https://asdf-vm.com/

This PR add [asdf-vm](https://asdf-vm.com/) support to `find-node.sh` for `scripts/react-native-xcode.sh` in `Bundle React Native code and images` build phrase and potentially other scripts using `find-node.sh` to get executable nodejs

## Changelog

[iOS] [Added] - add asdf-vm support in find-node.sh

Pull Request resolved: https://github.com/facebook/react-native/pull/30111

Test Plan: Xcode is able to complete `Bundle React Native code and images` build phrase without errors when node is installed by asdf-vm

Reviewed By: yungsters

Differential Revision: D31064080

Pulled By: charlesbdudley

fbshipit-source-id: aa73620fc39027c58c9cdfbb554cd5698b917850
2021-09-28 10:55:09 -07:00
Danilo Bürger 4d40b53c12 Find node on m1 via homebrew node managers (#31678)
Summary:
Adds homebrew on m1 to path before evaluating `command -v brew` to support nvm on m1 via homebrew.

## Changelog

[General] [Changed] - Find node on m1 via homebrew node managers

Pull Request resolved: https://github.com/facebook/react-native/pull/31678

Test Plan:
On M1, use nvm via homebrew. Create a RN project and it'll fail to build iOS app. Apply the patch, and build will succeed.

cc: dulmandakh as discussed in https://github.com/facebook/react-native/pull/31622

Reviewed By: ShikaSD

Differential Revision: D28967386

Pulled By: PeteTheHeat

fbshipit-source-id: 3d4a41dd3cc25fbf77778b16468a236b141d1259
2021-06-08 11:20:10 -07:00
Dulmandakh 502b819049 find-node.sh supports Homebrew on M1 (#31622)
Summary:
Homebrew on M1 installs executable binaries in **/opt/homebrew/bin** (See https://brew.sh/2021/02/05/homebrew-3.0.0/), and FBReactNativeSpec.build is failing because it couldn't find node. This PR changes find-node.sh script to add /opt/homebrew/bin into $PATH.

The way **react.gradle** trying to execute node is not using user environment variables, but system defaults, so it couldn't find it. I removed node execution, and hard coded cli path in parity with iOS d1ab03235c/scripts/react-native-xcode.sh (L106)

Fixes https://github.com/facebook/react-native/issues/31621 https://github.com/facebook/react-native/issues/31592

## Changelog

[General] [Changed] - find-node.sh supports Homebrew on M1

Pull Request resolved: https://github.com/facebook/react-native/pull/31622

Test Plan: On M1, create a RN project and it'll fail to build iOS app. Apply the patch, and build will succeed.

Reviewed By: ShikaSD

Differential Revision: D28808206

Pulled By: hramos

fbshipit-source-id: 8b313b6685462a15e67d99c61a0202d17fece1ec
2021-06-02 15:32:08 -07:00
Héctor Ramos 322e8f70cf Re-use Node path resolution script
Summary:
This fix is ported from 0.64-stable. It moves the Node resolution script from react-native-xcode.sh to find-node.sh for re-use in the codegen.

Changelog: [Codegen][Internal]

Reviewed By: fkgozali

Differential Revision: D27437216

fbshipit-source-id: ecb8a7a30411a709c095a0a34115b6dc48b99f1e
2021-04-02 13:56:52 -07:00