Skip to content

Commit

Permalink
build: use react-native-config over original dotenv approach
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh committed Jan 11, 2022
1 parent 31e27fb commit eb6cbb9
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 162 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
UPLOAD_KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_PASSWORD }}
UPLOAD_KEYSTORE_KEY_ALIAS: ${{ secrets.UPLOAD_KEYSTORE_KEY_ALIAS }}
UPLOAD_KEYSTORE_KEY_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_KEY_PASSWORD }}
ENVFILE: config/.env.next

jobs:
prepare:
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source 'https://rubygems.org'

gem 'fastlane', '~> 2.199.0'
gem 'dotenv', '~> 2.1', '>= 2.1.1'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
dotenv (~> 2.1, >= 2.1.1)
fastlane (~> 2.199.0)
fastlane-plugin-appicon
fastlane-plugin-badge
Expand Down
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
plugins: [ 'transform-remove-console' ],
},
test: {
plugins: [ 'transform-remove-console' ],
plugins: [ 'react-native-config-node/transform', 'transform-remove-console' ],
},
},
}
2 changes: 1 addition & 1 deletion config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This app follows the [12 factor app](https://12factor.net/config) approach to co

_Currently, build configuration in [`fastlane/`](../fastlane) is not configurable through these files._

Specific dotenv files can be loaded by Fastlane by supplying `app_env:name` as an option to any commands. For example, `fastlane ios build app_env:next` would load the variables from `config/.env.next` and make these available to the app.
Specific dotenv files can be loaded by supplying an `ENVFILE` environment variable to any command. For example, `ENVFILE=config/.env.next fastlane ios build` would load the variables from `config/.env.next` and make these available to the app.

## Environments

Expand Down
1 change: 0 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './utils.rb'
import './load_env.rb'
import './Fastfile.ios'
import './Fastfile.android'
11 changes: 0 additions & 11 deletions fastlane/load_env.rb

This file was deleted.

8 changes: 8 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ PODS:
- React-jsinspector (0.66.3)
- React-logger (0.66.3):
- glog
- react-native-config (1.4.5):
- react-native-config/App (= 1.4.5)
- react-native-config/App (1.4.5):
- React-Core
- react-native-safe-area-context (3.3.2):
- React-Core
- React-perflogger (0.66.3)
Expand Down Expand Up @@ -447,6 +451,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- react-native-config (from `../node_modules/react-native-config`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
Expand Down Expand Up @@ -524,6 +529,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
react-native-config:
:path: "../node_modules/react-native-config"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
React-perflogger:
Expand Down Expand Up @@ -600,6 +607,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 433a691aee158533a6a6ee9c86cb4a1684fa2853
React-jsinspector: d9c8eb0b53f0da206fed56612b289fec84991157
React-logger: e522e76fa3e9ec3e7d7115b49485cc065cf4ae06
react-native-config: 6502b1879f97ed5ac570a029961fc35ea606cd14
react-native-safe-area-context: 584dc04881deb49474363f3be89e4ca0e854c057
React-perflogger: 73732888d37d4f5065198727b167846743232882
React-RCTActionSheet: 96c6d774fa89b1f7c59fc460adc3245ba2d7fd79
Expand Down
181 changes: 39 additions & 142 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"scripts": {
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --color",
"test:types": "tsc --pretty",
"test:unit": "dotenv -e ./config/.env.local jest --color",
"test:unit": "ENVFILE=config/.env.local jest --color",
"test": "run-p -l test:*",
"emulator:android": "dotenv -e ./config/.env.local react-native run-android",
"emulator:ios": "dotenv -e ./config/.env.local react-native run-ios --simulator='iPhone 8'",
"emulator:android": "ENVFILE=config/.env.local react-native run-android",
"emulator:ios": "ENVFILE=config/.env.local react-native run-ios --simulator='iPhone 8'",
"start:android": "run-p -l emulator:android \"test:* -- --watch\"",
"start:ios": "run-p -l emulator:ios \"test:* -- --watch\"",
"build:android": "bundle exec fastlane android build",
Expand Down Expand Up @@ -40,6 +40,7 @@
"react": "^17.0.2",
"react-i18next": "^11.14.3",
"react-native": "^0.66.3",
"react-native-config": "^1.4.5",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.2.4",
"react-native-safe-area-context": "^3.3.2",
Expand All @@ -64,7 +65,6 @@
"@typescript-eslint/parser": "^5.4.0",
"babel-jest": "^27.4.2",
"babel-plugin-transform-remove-console": "^6.9.4",
"dotenv-cli": "^4.1.1",
"eslint": "^8.3.0",
"eslint-config-airbnb": "^19.0.1",
"eslint-config-airbnb-typescript": "^16.0.0",
Expand All @@ -86,6 +86,7 @@
"npm-run-all": "^4.1.5",
"pod-install": "^0.1.29",
"prettier": "2.5.0",
"react-native-config-node": "^0.0.3",
"react-test-renderer": "^17.0.2",
"typescript": "^4.5.2"
}
Expand Down

0 comments on commit eb6cbb9

Please sign in to comment.