HomePhabricator
Diffusion Comm eea14efeddd3

[native] Patch @expo/cli to display dev-server IP

Description

[native] Patch @expo/cli to display dev-server IP

Summary:
Related: https://linear.app/comm/issue/ENG-2705/expo-cli-qr-code-doesnt-use-the-right-lan-ip-address

Because we run expo start with the --dev-client flag, but we don't have defined a custom Linking URL Scheme, Expo CLI defaults to localhost.

This diff patches @expo/cli and overrides this behavior.

  • Try to autodetect the IP using some utility from the package
  • If failed, try to read the IP from native/facts/network.json
  • If we fail again (require fails or natDevHostname doesn't exist), leave "localhost"

On the other hand, maybe it's worth stopping relying on network.json, as stated in https://linear.app/comm/issue/ENG-2707/replace-nativefactsnetworkjson-with-code-that-detects-lan-ip-address

Test Plan:

cd native
yarn dev

The IP should display instead of http://localhost:8081 and QR code should be scannable (it should open some Expo/Metro-specific JSON in the browser)

Screenshot 2023-01-12 at 22.48.15.png (964×1 px, 86 KB)

Reviewers: ashoat

Reviewed By: ashoat

Subscribers: tomek, atul

Differential Revision: https://phab.comm.dev/D6257

Details

Provenance
bartekAuthored on Jan 12 2023, 1:51 PM
Reviewer
ashoat
Differential Revision
D6257: [native] Patch @expo/cli to display dev-server IP
Parents
rCOMMf1e39f51bffd: [web] Conditionally display `ConnectButton` once `nonce` received from…
Branches
Unknown
Tags
Unknown