diff --git a/.gitignore b/.gitignore index dbc4e6d1..a5f81fb5 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ project-todo android/release-keystore.properties android/.bundle android/vendor +.env diff --git a/babel.config.js b/babel.config.js index ec692eec..34da8382 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,5 +1,5 @@ module.exports = { - presets: ['module:metro-react-native-babel-preset'], + presets: ['module:metro-react-native-babel-preset', 'module:react-native-dotenv'], plugins: [ [ 'module-resolver', diff --git a/package.json b/package.json index 654d38a3..771568f8 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "native-base": "^2.13.12", "react": "16.11.0", "react-native": "0.62.2", + "react-native-dotenv": "^0.2.0", "react-redux": "^7.2.0", "redux": "^4.0.5" }, @@ -35,6 +36,7 @@ "@types/jest": "^25.2.1", "@types/react": "^16.9.34", "@types/react-native": "^0.62.2", + "@types/react-native-dotenv": "^0.2.0", "@types/react-redux": "^7.1.7", "@types/react-test-renderer": "^16.9.2", "@typescript-eslint/eslint-plugin": "^2.27.0", diff --git a/src/configs/env.d.ts b/src/configs/env.d.ts new file mode 100644 index 00000000..37e24963 --- /dev/null +++ b/src/configs/env.d.ts @@ -0,0 +1,6 @@ +// Create module to deal with Typescript error when pulling env values using react-native-dotenv +// check https://github.com/zetachang/react-native-dotenv/issues/76#issuecomment-585171009 +declare module 'react-native-dotenv' { + export const BUILD_VERSION: 'development' | string; + export const API_KEY: string; +} diff --git a/yarn.lock b/yarn.lock index c278e0e5..119bb7b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1513,6 +1513,11 @@ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7" integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw== +"@types/react-native-dotenv@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@types/react-native-dotenv/-/react-native-dotenv-0.2.0.tgz#32c58422a422c1adf68acce363ed791314d5a8e7" + integrity sha512-ZxX+dU/yoQc0jTk+/NWttkiuXceJyN5FpOSqDl0WynN5GDzxwH7OMruQ47qcY8llo2RD3irjvzJ9BwC8gDiq0A== + "@types/react-native@^0.62.2": version "0.62.2" resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.62.2.tgz#f3e150f308c27089cefbcbfa3eb6cc14db279b2f" @@ -2000,6 +2005,13 @@ babel-jest@^25.3.0: chalk "^3.0.0" slash "^3.0.0" +babel-plugin-dotenv@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/babel-plugin-dotenv/-/babel-plugin-dotenv-0.1.1.tgz#9c8faea67a7c034fe7e94099187ab2e7573400bc" + integrity sha1-nI+upnp8A0/n6UCZGHqy51c0ALw= + dependencies: + dotenv "^2.0.0" + babel-plugin-dynamic-import-node@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz#f00f507bdaa3c3e3ff6e7e5e98d90a7acab96f7f" @@ -2925,6 +2937,11 @@ domexception@^1.0.1: dependencies: webidl-conversions "^4.0.2" +dotenv@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-2.0.0.tgz#bd759c357aaa70365e01c96b7b0bec08a6e0d949" + integrity sha1-vXWcNXqqcDZeAclrewvsCKbg2Uk= + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -6665,6 +6682,13 @@ react-is@^16.12.0, react-is@^16.13.0, react-is@^16.7.0, react-is@^16.8.1, react- resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== +react-native-dotenv@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-0.2.0.tgz#311551cb6a35a3dcfede648bded55c0e3ece579d" + integrity sha1-MRVRy2o1o9z+3mSL3tVcDj7OV50= + dependencies: + babel-plugin-dotenv "0.1.1" + react-native-drawer@2.5.1: version "2.5.1" resolved "https://registry.yarnpkg.com/react-native-drawer/-/react-native-drawer-2.5.1.tgz#08b9314184f48c724f1b467f8859797369798654"