mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
Use different .env files for staging and production (#332)
* Add different env files to gitignore; update react-native-config * Set different staging and production .env files in Android * Add different envfiles to podfile * Use podfile to check for .env.production and .env.staging files * Update README * Point production to .env instead of .env.production
This commit is contained in:
committed by
GitHub
parent
705152a9ca
commit
236904e0a1
2
.gitignore
vendored
2
.gitignore
vendored
@@ -60,7 +60,7 @@ buck-out/
|
||||
/coverage/
|
||||
|
||||
# Secrets file
|
||||
.env
|
||||
.env*
|
||||
|
||||
# Fastlane files
|
||||
*.zip
|
||||
|
||||
10
README.md
10
README.md
@@ -8,8 +8,8 @@
|
||||
## Install packages and pods
|
||||
|
||||
1. Run `npm install`
|
||||
1. Run `npx pod-install ios` or `cd ios && pod install` from the root directory
|
||||
1. `cp env.example .env` and fill in appropriate values. This is not part of the code repo (contains secrets, such as OAuth client ID).
|
||||
1. Run `npx pod-install` or `cd ios && pod install` from the root directory
|
||||
1. `cp env.example .env.staging` for staging and `cp env.example .env` for production and fill in appropriate values. This is not part of the code repo (contains secrets, such as OAuth client ID).
|
||||
1. To run on Android, do this `cp android/example-keystore.properties android/keystore.properties`. Fill in the relevant values. If you are a member of iNat staff, get them from another member of iNat Staff.
|
||||
|
||||
## Set up pre-commit hooks
|
||||
@@ -59,7 +59,7 @@ Run `npm run e2e:build:android && npm run e2e:test:android` to build the .apk fo
|
||||
|
||||
## Running with Staging Environment
|
||||
|
||||
1. Override `API_URL` to a staging API domain - either using a local `.env` file, or overriding the environment variable when calling `npm start` - e.g. `API_URL=http://example.com npm start -- --reset-cache`
|
||||
1. Override `API_URL` to a staging API domain - either using local `.env.staging` file, or overriding the environment variable when calling `npm start` - e.g. `API_URL=http://example.com npm start -- --reset-cache`
|
||||
|
||||
## Translations
|
||||
|
||||
@@ -109,7 +109,7 @@ We're using Nativewind, a styling system for React Native based on Tailwind CSS.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
1. Run `react-native clean-project`. This will give you options to clean caches, clean builds, reinstall pods, and reinstall node_modules. Using this eliminates a lot of hard-to-diagnose build issues.
|
||||
1. Run `npx react-native clean-project`. This will give you options to clean caches, clean builds, reinstall pods, and reinstall node_modules. Using this eliminates a lot of hard-to-diagnose build issues.
|
||||
1. If you're running on an M series chip, you may need to install a specific version of NDK to the app to build for Android. See `android/build.gradle`
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ We use [fastlane](https://docs.fastlane.tools/) to help automate parts of the de
|
||||
|
||||
### Setting up fastlane
|
||||
|
||||
1. Make a [Github personal access token](https://github.com/settings/tokens/) with repo access in the `GITHUB_TOKEN` environmental variable.
|
||||
1. Make a [Github personal access token](https://github.com/settings/tokens/) with repo access in the `GITHUB_API_TOKEN` environmental variable.
|
||||
1. `cp android/example-keystore.properties android/keystore.properties` and fill in the relevant values provided by another member of iNat staff.
|
||||
1. `cp fastlane/example-Appfile fastlane/Appfile` and fill in the relevant values provided by another member of iNat staff.
|
||||
1. Work with iNat staff to either get a new Apple ID or associate an existing one with the iNat Apple development team
|
||||
|
||||
@@ -78,6 +78,16 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||
* ]
|
||||
*/
|
||||
|
||||
// set up different .env files so fastlane will automatically build using .env
|
||||
// and dev builds will use .env.staging
|
||||
// https://github.com/luggit/react-native-config#android-1
|
||||
project.ext.envConfigFiles = [
|
||||
debug: ".env.staging",
|
||||
release: ".env"
|
||||
]
|
||||
|
||||
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
|
||||
|
||||
project.ext.react = [
|
||||
enableHermes: true, // clean and rebuild if changing
|
||||
]
|
||||
@@ -345,7 +355,6 @@ task copyDownloadableDepsToLibs(type: Copy) {
|
||||
}
|
||||
|
||||
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
||||
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
|
||||
|
||||
def isNewArchitectureEnabled() {
|
||||
// To opt-in for the New Architecture, you can either:
|
||||
|
||||
17
ios/Podfile
17
ios/Podfile
@@ -35,8 +35,23 @@ target 'iNaturalistReactNative' do
|
||||
|
||||
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
|
||||
|
||||
# code below appears to be necessary for building pods with XCode 14: https://github.com/facebook/react-native/issues/34673#issuecomment-1252114414
|
||||
ENVFILES = {
|
||||
'Debug' => '$(PODS_ROOT)/../../.env.staging',
|
||||
'Release' => '$(PODS_ROOT)/../../.env',
|
||||
}
|
||||
|
||||
post_install do |installer|
|
||||
# use different .env files for staging and production
|
||||
# https://github.com/luggit/react-native-config#ios-1
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
if target.name == 'react-native-config'
|
||||
config.build_settings['ENVFILE'] = ENVFILES[config.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# code below appears to be necessary for building pods with XCode 14: https://github.com/facebook/react-native/issues/34673#issuecomment-1252114414
|
||||
react_native_post_install(
|
||||
installer,
|
||||
# Set `mac_catalyst_enabled` to `true` in order to apply patches
|
||||
|
||||
@@ -678,6 +678,6 @@ SPEC CHECKSUMS:
|
||||
VisionCamera: 4cfd685b1e671fea4aa0400905ab397f0e972210
|
||||
Yoga: 1f02ef4ce4469aefc36167138441b27d988282b1
|
||||
|
||||
PODFILE CHECKSUM: 82e6d2d7955b95f3c10ea43e9c64be85443373d5
|
||||
PODFILE CHECKSUM: 04aff709868ecadb8756484c5de8760be202ad25
|
||||
|
||||
COCOAPODS: 1.11.3
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -48,7 +48,7 @@
|
||||
"react-i18next": "^11.16.1",
|
||||
"react-native": "0.70.4",
|
||||
"react-native-audio-recorder-player": "^3.5.1",
|
||||
"react-native-config": "^1.4.5",
|
||||
"react-native-config": "^1.4.11",
|
||||
"react-native-device-info": "^8.5.1",
|
||||
"react-native-dropdown-picker": "^5.3.0",
|
||||
"react-native-exif-reader": "github:inaturalist/react-native-exif-reader",
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
"react-i18next": "^11.16.1",
|
||||
"react-native": "0.70.4",
|
||||
"react-native-audio-recorder-player": "^3.5.1",
|
||||
"react-native-config": "^1.4.5",
|
||||
"react-native-config": "^1.4.11",
|
||||
"react-native-device-info": "^8.5.1",
|
||||
"react-native-dropdown-picker": "^5.3.0",
|
||||
"react-native-exif-reader": "github:inaturalist/react-native-exif-reader",
|
||||
|
||||
Reference in New Issue
Block a user