From 8f2ea1518f792b1d670bd0020f997bb2bf6c8bd8 Mon Sep 17 00:00:00 2001 From: Sunim Acharya Date: Sun, 4 Mar 2018 12:05:34 +0545 Subject: [PATCH] Setup for env for Clarifai API --- .babelrc | 2 +- .env.dev | 1 + .gitignore | 6 ++++++ package-lock.json | 24 ++++++++++++++++++++++++ package.json | 1 + src/screens/Predict/index.js | 4 +++- 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .env.dev diff --git a/.babelrc b/.babelrc index a9ce136..7757a2a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["react-native"] + "presets": ["react-native", "react-native-dotenv"] } diff --git a/.env.dev b/.env.dev new file mode 100644 index 0000000..74467f1 --- /dev/null +++ b/.env.dev @@ -0,0 +1 @@ +CLARIFAY_KEY=api_key \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0826423..bee9a6c 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,10 @@ build/ local.properties *.iml +# env files +.env +.env.prod + # node.js # node_modules/ @@ -51,3 +55,5 @@ buck-out/ */fastlane/report.xml */fastlane/Preview.html */fastlane/screenshots + +.vscode/ diff --git a/package-lock.json b/package-lock.json index 99b8e25..1a4aab7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -551,6 +551,15 @@ "babel-runtime": "6.26.0" } }, + "babel-plugin-dotenv": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-dotenv/-/babel-plugin-dotenv-0.1.1.tgz", + "integrity": "sha1-nI+upnp8A0/n6UCZGHqy51c0ALw=", + "dev": true, + "requires": { + "dotenv": "2.0.0" + } + }, "babel-plugin-external-helpers": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-external-helpers/-/babel-plugin-external-helpers-6.22.0.tgz", @@ -1890,6 +1899,12 @@ "webidl-conversions": "4.0.2" } }, + "dotenv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-2.0.0.tgz", + "integrity": "sha1-vXWcNXqqcDZeAclrewvsCKbg2Uk=", + "dev": true + }, "duplexer2": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", @@ -6413,6 +6428,15 @@ "resolved": "https://registry.npmjs.org/react-native-dismiss-keyboard/-/react-native-dismiss-keyboard-1.0.0.tgz", "integrity": "sha1-MohiQrPyMX4SHzrrmwpYXiuHm0k=" }, + "react-native-dotenv": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-0.1.1.tgz", + "integrity": "sha1-lalD26uiTd9Q6VvYYeWgxKsDo40=", + "dev": true, + "requires": { + "babel-plugin-dotenv": "0.1.1" + } + }, "react-native-drawer-layout": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/react-native-drawer-layout/-/react-native-drawer-layout-1.3.2.tgz", diff --git a/package.json b/package.json index 3c849d8..6af41fd 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "babel-jest": "22.4.0", "babel-preset-react-native": "4.0.0", "jest": "22.4.0", + "react-native-dotenv": "^0.1.1", "react-test-renderer": "16.2.0" }, "jest": { diff --git a/src/screens/Predict/index.js b/src/screens/Predict/index.js index 9a8b0d7..99bc9fe 100644 --- a/src/screens/Predict/index.js +++ b/src/screens/Predict/index.js @@ -7,6 +7,8 @@ import { Button, Text } from "react-native-elements"; import Clarifai from "clarifai"; +import { CLARIFAY_KEY } from 'react-native-dotenv'; + import Notif from "../../components/Notif"; import styles from "./styles"; @@ -30,7 +32,7 @@ class Predict extends Component { componentDidMount() { const clarifai = new Clarifai.App({ - apiKey: "" //dummy + apiKey: CLARIFAY_KEY //dummy }); process.nextTick = setImmediate; // RN polyfill