diff --git a/native/app.config.js b/native/app.config.js index f72b2d133..23a8c1e1c 100644 --- a/native/app.config.js +++ b/native/app.config.js @@ -1,10 +1,26 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import ip from 'internal-ip'; +// Finds this machine's hostname in the local network. This is useful for +// debugging on a real device. The `COMM_DEV` environment variable must be set +// or this function will return `null`. The `COMM_NAT_DEV_HOSTNAME` environment +// variable can be used to override the autodetected hostname. +function getDevHostname() { + const { COMM_DEV: isDev, COMM_NAT_DEV_HOSTNAME } = process.env; + + if (!isDev) { + return null; + } + if (COMM_NAT_DEV_HOSTNAME) { + return COMM_NAT_DEV_HOSTNAME; + } + return ip.v4.sync(); +} + export default { extra: { // developer machine's hostname in the local network - natDevHostname: ip.v4.sync(), + natDevHostname: getDevHostname(), }, }; diff --git a/native/package.json b/native/package.json index 133b482e5..0c057239e 100644 --- a/native/package.json +++ b/native/package.json @@ -1,127 +1,127 @@ { "name": "native", "version": "0.0.1", "private": true, "license": "BSD-3-Clause", "scripts": { "clean": "yarn clean-commoncpp && yarn clean-android && yarn clean-ios && rm -rf node_modules/ && rm -f ios/.xcode.env.local && (yarn clean-rust || true)", "clean-commoncpp": "rm -rf cpp/CommonCpp/build && rm -rf cpp/CommonCpp/CryptoTools/build && rm -rf cpp/CommonCpp/DatabaseManagers/build && rm -rf cpp/CommonCpp/NativeModules/build && rm -rf cpp/CommonCpp/Tools/build", "clean-rust": "cargo clean --manifest-path native_rust_library/Cargo.toml", "clean-android": "rm -rf android/build android/app/build android/app/.cxx", "clean-ios": "rm -rf ios/Pods/", "clean-all": "yarn clean && rm -rf ~/Library/Developer/Xcode/DerivedData/Comm-*; cd android && (./gradlew clean || true)", "postinstall": "bash ./postinstall.sh", - "start": "yarn expo start --dev-client", + "start": "COMM_DEV=1 yarn expo start --dev-client", "dev": "yarn start", "test": "yarn jest", "logfirebase": "adb shell logcat | grep -E -i 'FIRMessagingModule|firebase'", "redux-devtools": "redux-devtools --port=8043 --open", "codegen-jsi": "flow && babel codegen/src/ -d codegen/dist/ && node codegen/dist", "react-native": "PATH=/usr/bin:\"$PATH\" react-native" }, "devDependencies": { "@babel/cli": "^7.8.4", "@babel/core": "^7.13.14", "@babel/node": "^7.8.7", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8", "@babel/plugin-proposal-optional-chaining": "^7.13.12", "@babel/preset-flow": "^7.9.0", "@redux-devtools/cli": "^1.0.7", "babel-jest": "^26.6.3", "babel-plugin-transform-remove-console": "^6.9.4", "babel-plugin-transform-remove-strict-mode": "0.0.2", "flow-bin": "^0.182.0", "flow-mono-cli": "^1.5.0", "flow-typed": "^3.2.1", "fs-extra": "^8.1.0", "googleapis": "^89.0.0", "internal-ip": "4.3.0", "jest": "^26.6.3", "jetifier": "^1.6.4", "jsonwebtoken": "^8.5.1", "metro-react-native-babel-preset": "^0.72.3", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.0.0", "react-devtools": "^4.27.0", "react-native-codegen": "^0.70.6", "react-test-renderer": "18.1.0", "remote-redux-devtools": "git+https://git@github.com/zalmoxisus/remote-redux-devtools.git", "remotedev": "git+https://git@github.com/zalmoxisus/remotedev.git" }, "dependencies": { "@commapp/android-lifecycle": "0.0.1", "@commapp/sqlcipher-amalgamation": "^4.4.3-a", "@expo/react-native-action-sheet": "^3.14.0", "@expo/vector-icons": "^13.0.0", "@gorhom/bottom-sheet": "^4.4.5", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-clipboard/clipboard": "^1.11.1", "@react-native-community/art": "^1.2.0", "@react-native-community/netinfo": "^9.3.7", "@react-native-masked-view/masked-view": "^0.2.8", "@react-navigation/bottom-tabs": "^6.4.0", "@react-navigation/devtools": "^6.0.10", "@react-navigation/drawer": "^6.5.0", "@react-navigation/elements": "^1.3.6", "@react-navigation/material-top-tabs": "^6.3.0", "@react-navigation/native": "^6.0.13", "@react-navigation/stack": "^6.3.2", "base-64": "^0.1.0", "expo": "47.0.8", "expo-dev-client": "~2.0.1", "expo-font": "~11.0.1", "expo-haptics": "~12.0.1", "expo-image-manipulator": "~11.0.0", "expo-image-picker": "~14.0.2", "expo-media-library": "~15.0.0", "expo-secure-store": "~12.0.0", "expo-splash-screen": "~0.17.4", "find-root": "^1.1.0", "invariant": "^2.2.4", "lib": "0.0.1", "lodash": "^4.17.21", "lottie-react-native": "^5.1.4", "md5": "^2.2.1", "olm": "git+https://gitlab.matrix.org/matrix-org/olm.git#v3.2.4", "react": "18.1.0", "react-native": "^0.70.6", "react-native-background-upload": "^6.6.0", "react-native-camera": "^3.31.0", "react-native-device-info": "^10.3.0", "react-native-exit-app": "^1.1.0", "react-native-fast-image": "^8.3.0", "react-native-ffmpeg": "^0.4.4", "react-native-figma-squircle": "^0.1.2", "react-native-firebase": "^5.6.0", "react-native-floating-action": "^1.22.0", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "^2.8.0", "react-native-in-app-message": "^1.0.2", "react-native-keyboard-input": "6.0.1", "react-native-keychain": "^8.0.0", "react-native-notifications": "git+https://git@github.com/ashoat/react-native-notifications.git", "react-native-orientation-locker": "^1.5.0", "react-native-pager-view": "^6.0.1", "react-native-progress": "^4.1.2", "react-native-reanimated": "^2.12.0", "react-native-safe-area-context": "^4.4.1", "react-native-screens": "^3.18.2", "react-native-svg": "^12.3.0", "react-native-tab-view": "^3.3.0", "react-native-video": "^5.2.1", "react-native-webview": "^11.23.0", "react-redux": "^7.1.1", "reactotron-react-native": "^5.0.3", "reactotron-redux": "^3.1.3", "redux": "^4.0.4", "redux-persist": "^6.0.0", "redux-thunk": "^2.2.0", "reselect": "^4.0.0", "shallowequal": "^1.0.2", "simple-markdown": "^0.7.2", "tinycolor2": "^1.4.1" }, "jest": { "preset": "react-native" } }