Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359213
D7056.id23663.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D7056.id23663.diff
View Options
diff --git a/native/.gitignore b/native/.gitignore
--- a/native/.gitignore
+++ b/native/.gitignore
@@ -58,7 +58,6 @@
android/app/.cxx/
codegen/dist
-facts/network.json
facts/alchemy.json
# Expo
diff --git a/native/app.config.js b/native/app.config.js
--- a/native/app.config.js
+++ b/native/app.config.js
@@ -15,7 +15,21 @@
if (COMM_NAT_DEV_HOSTNAME) {
return COMM_NAT_DEV_HOSTNAME;
}
- return ip.v4.sync();
+ const autodetectedHostname = ip.v4.sync();
+
+ // we only want to show this warning once, but this expo config file is
+ // evaluated multiple times, so we use a flag to make sure it's only shown
+ // once
+ if (!autodetectedHostname && !process.env._HOSTNAME_WARNING_SHOWN) {
+ console.warn(
+ 'Failed to autodetect `natDevHostname`. Please provide it manually ' +
+ 'by setting the `COMM_NAT_DEV_HOSTNAME` environment variable: ' +
+ '`COMM_NAT_DEV_HOSTNAME=${hostname} yarn dev`',
+ );
+ process.env._HOSTNAME_WARNING_SHOWN = true;
+ }
+
+ return autodetectedHostname;
}
export default {
diff --git a/native/utils/dev-hostname.js b/native/utils/dev-hostname.js
--- a/native/utils/dev-hostname.js
+++ b/native/utils/dev-hostname.js
@@ -13,35 +13,19 @@
return detectedHostname;
}
-function readHostnameFromNetworkJson(): string {
- try {
- // this is your machine's hostname in the local network
- // usually it looks like this: 192.168.1.x
- // to find it you may want to use `ifconfig | grep '192.168'`
- // command in the terminal
- // example of native/facts/network.json:
- // { "natDevHostname": "192.168.1.x" }
- // $FlowExpectedError: It's a conditional require so the file may not exist
- const hostname: string = require('../facts/network.json').natDevHostname;
- warnNatDevHostnameUndefined = false;
- return hostname;
- } catch (e) {
- return defaultNatDevHostname;
- }
-}
-
-const natDevHostname: string =
- readHostnameFromExpoConfig() ?? readHostnameFromNetworkJson();
-
function checkForMissingNatDevHostname() {
if (!warnNatDevHostnameUndefined) {
return;
}
console.warn(
- 'Failed to autodetect natDevHostname. ' +
- 'Please specify it manually in native/facts/network.json',
+ 'Failed to read `natDevHostname` from Expo config. ' +
+ 'Please provide it manually by setting the `COMM_NAT_DEV_HOSTNAME` ' +
+ 'environment variable: `COMM_NAT_DEV_HOSTNAME=${hostname} yarn dev`',
);
warnNatDevHostnameUndefined = false;
}
+const natDevHostname: string =
+ readHostnameFromExpoConfig() || defaultNatDevHostname;
+
export { natDevHostname, checkForMissingNatDevHostname };
diff --git a/patches/@expo+cli+0.4.10.patch b/patches/@expo+cli+0.4.10.patch
--- a/patches/@expo+cli+0.4.10.patch
+++ b/patches/@expo+cli+0.4.10.patch
@@ -1,5 +1,5 @@
diff --git a/node_modules/@expo/cli/build/src/start/interface/interactiveActions.js b/node_modules/@expo/cli/build/src/start/interface/interactiveActions.js
-index 9ab8961..ab012c0 100644
+index 9ab8961..27b9cc2 100644
--- a/node_modules/@expo/cli/build/src/start/interface/interactiveActions.js
+++ b/node_modules/@expo/cli/build/src/start/interface/interactiveActions.js
@@ -45,12 +45,17 @@ class DevServerManagerActions {
@@ -21,10 +21,10 @@
// TODO: if development build, change this message!
Log.log((0, _commandsTable).printItem("Scan the QR code above with Expo Go (Android) or the Camera app (iOS)"));
diff --git a/node_modules/@expo/cli/build/src/start/server/BundlerDevServer.js b/node_modules/@expo/cli/build/src/start/server/BundlerDevServer.js
-index 0a601bd..2c0a210 100644
+index 0a601bd..c4dbd20 100644
--- a/node_modules/@expo/cli/build/src/start/server/BundlerDevServer.js
+++ b/node_modules/@expo/cli/build/src/start/server/BundlerDevServer.js
-@@ -255,6 +255,23 @@ class BundlerDevServer {
+@@ -255,6 +255,16 @@ class BundlerDevServer {
return `${location.protocol}://localhost:${location.port}`;
}
var _url;
@@ -36,14 +36,7 @@
+ return `${location.protocol}://${ip}:${location.port}`;
+ }
+ } catch(e) {}
-+ // fall back to facts/network.json
-+ try {
-+ const { natDevHostname } = require('../../../../../../../native/facts/network.json');
-+ if (natDevHostname != null) {
-+ return `${location.protocol}://${natDevHostname}:${location.port}`;
-+ }
-+ } catch(e) {}
-+ // if everithing else fails, fall back to localhost
++ // if the above fails, fall back to localhost
+ }
return (_url = location.url) != null ? _url : null;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 7:53 AM (20 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578659
Default Alt Text
D7056.id23663.diff (4 KB)
Attached To
Mode
D7056: [native] Remove network.json fallbacks
Attached
Detach File
Event Timeline
Log In to Comment