Fakultas Ilmu Komputer UI

Commit 01cb9410 authored by Wulan Mantiri's avatar Wulan Mantiri
Browse files

Setup environment variables

parent 5f3f58fc
# localhost
API_BASE_URL=http://localhost:8000/
GOOGLE_CLIENT_ID=813112248680-ulv0amtocut652j31qbpvubtclbd2c7o.apps.googleusercontent.com
# staging
API_BASE_URL=https://dietela-backend.herokuapp.com/
GOOGLE_CLIENT_ID=
# production
API_BASE_URL=
GOOGLE_CLIENT_ID=
...@@ -65,3 +65,6 @@ buck-out/ ...@@ -65,3 +65,6 @@ buck-out/
coverage/ coverage/
.husky .husky
.eslintcache .eslintcache
# environment
.env
before_script:
- >
if [[ "${CI_COMMIT_REF_NAME}" == "master" ]];
then
ENV=PRODUCTION
else
ENV=STAGING
fi
- API_BASE_URL=${ENV}_API_BASE_URL
- GOOGLE_CLIENT_ID=${ENV}_GOOGLE_CLIENT_ID
- echo -e "API_BASE_URL=${!API_BASE_URL}\n" >> .env
- echo -e "GOOGLE_CLIENT_ID=${!GOOGLE_CLIENT_ID}\n" >> .env
cache: cache:
key: ${CI_COMMIT_REF_SLUG} key: ${CI_COMMIT_REF_SLUG}
paths: paths:
...@@ -8,7 +21,6 @@ cache: ...@@ -8,7 +21,6 @@ cache:
stages: stages:
- lint - lint
- test - test
- pbi-sonar-scanner
- sonar-scanner - sonar-scanner
- build - build
...@@ -23,9 +35,8 @@ lint: ...@@ -23,9 +35,8 @@ lint:
test: test:
image: node:slim image: node:slim
stage: test stage: test
before_script:
- yarn install
script: script:
- yarn install
- yarn test --silent - yarn test --silent
artifacts: artifacts:
paths: paths:
...@@ -35,7 +46,9 @@ pbi-sonar-scanner: ...@@ -35,7 +46,9 @@ pbi-sonar-scanner:
image: image:
name: sonarsource/sonar-scanner-cli:latest name: sonarsource/sonar-scanner-cli:latest
entrypoint: [''] entrypoint: ['']
stage: pbi-sonar-scanner stage: sonar-scanner
before_script:
- ''
script: script:
- sonar-scanner - sonar-scanner
-Dsonar.host.url=$SONARQUBE_URL -Dsonar.host.url=$SONARQUBE_URL
...@@ -52,6 +65,8 @@ sonar-scanner: ...@@ -52,6 +65,8 @@ sonar-scanner:
name: sonarsource/sonar-scanner-cli:latest name: sonarsource/sonar-scanner-cli:latest
entrypoint: [''] entrypoint: ['']
stage: sonar-scanner stage: sonar-scanner
before_script:
- ''
script: script:
- sonar-scanner - sonar-scanner
-Dsonar.host.url=$SONARQUBE_URL -Dsonar.host.url=$SONARQUBE_URL
...@@ -65,10 +80,9 @@ sonar-scanner: ...@@ -65,10 +80,9 @@ sonar-scanner:
android: android:
image: reactnativecommunity/react-native-android image: reactnativecommunity/react-native-android
stage: build stage: build
before_script: script:
- yarn install - yarn install
- export ANDROID_SDK_ROOT=/usr/lib/android-sdk - export ANDROID_SDK_ROOT=/usr/lib/android-sdk
script:
- cd android - cd android
- chmod +x gradlew && ./gradlew assembleRelease - chmod +x gradlew && ./gradlew assembleRelease
- cd .. && cp android/app/build/outputs/apk/release/app-release.apk $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME.apk - cd .. && cp android/app/build/outputs/apk/release/app-release.apk $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME.apk
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## About Dietela ## About Dietela
Dietela is an Android-based application that provides personalised diet and online nutritionist consultation services. Dietela is an Android-based application that provides personalised diet and online nutritionist consultation services.
Check out Dietela app by downloading the latest artifact [here](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/DD/pt-gizi-sehat-dietela/dietela-mobile/-/pipelines?page=1&scope=all&ref=staging)! Check out Dietela app by downloading the APK file [here](https://drive.google.com/drive/folders/1Irc2aiSuvhysRSDDd6pwAAfbgUkkobmk?usp=sharing)!
## Installation Manual ## Installation Manual
...@@ -16,9 +16,9 @@ Check out Dietela app by downloading the latest artifact [here](https://gitlab.c ...@@ -16,9 +16,9 @@ Check out Dietela app by downloading the latest artifact [here](https://gitlab.c
* Clone the repository. * Clone the repository.
* Enter the project directory with `cd dietela-mobile`. * Enter the project directory with `cd dietela-mobile`.
* Build the dependencies with `yarn install`. * Build the dependencies with `yarn install`.
* Run the app in development node with `yarn start`. * Create `.env` file based on `.env.example`.
* On another terminal or cmd, build the app by running `yarn android`. * Run and build the app in development node by running `yarn android`.
* View it in your physical device or Android emulator. * View it in your Android emulator or physical device.
## Current Features ## Current Features
...@@ -34,6 +34,26 @@ Check out Dietela app by downloading the latest artifact [here](https://gitlab.c ...@@ -34,6 +34,26 @@ Check out Dietela app by downloading the latest artifact [here](https://gitlab.c
Clients can continue by choosing recommended diet program that is suitable for their needs Clients can continue by choosing recommended diet program that is suitable for their needs
- PBI 4: Registration
Clients can register an account to access Dietela's authenticated-only features
- PBI 5: Login
Clients can do authentication using a registered account to access Dietela's authenticated-only features
- PBI 6: Logout
Clients can sign out from the Dietela app
- PBI 7: Checkout
Clients can choose a diet program and a nutritionist then proceed to do the payment
- PBI 8: Payment Integration
Clients can perform payment using a third party payment gateway (Midtrans)
## Developers ## Developers
Team **we fall in love with PPL we cant have** Team **we fall in love with PPL we cant have**
......
...@@ -11,5 +11,16 @@ module.exports = { ...@@ -11,5 +11,16 @@ module.exports = {
}, },
}, },
], ],
[
'module:react-native-dotenv',
{
moduleName: 'env',
path: '.env',
blacklist: null,
whitelist: null,
safe: true,
allowUndefined: false,
},
],
], ],
}; };
declare module 'env' {
const API_BASE_URL: string;
const GOOGLE_CLIENT_ID: string;
}
import React, { FC, useEffect } from 'react'; import React, { FC, useEffect } from 'react';
import { UserContext, useUserContext } from './UserContext';
import { GoogleSignin } from '@react-native-google-signin/google-signin'; import { GoogleSignin } from '@react-native-google-signin/google-signin';
import { GOOGLE_CLIENT_ID } from 'env';
import { set401Callback } from 'services/api'; import { set401Callback } from 'services/api';
import { UserContext, useUserContext } from './UserContext';
const ContextProvider: FC = ({ children }) => { const ContextProvider: FC = ({ children }) => {
const { getUser, logout, ...user } = useUserContext(); const { getUser, logout, ...user } = useUserContext();
useEffect(() => { useEffect(() => {
// TODO: save to .env
GoogleSignin.configure({ GoogleSignin.configure({
webClientId: webClientId: GOOGLE_CLIENT_ID,
'813112248680-ulv0amtocut652j31qbpvubtclbd2c7o.apps.googleusercontent.com',
}); });
getUser(); getUser();
......
import axios, { AxiosRequestConfig } from 'axios'; import axios, { AxiosRequestConfig } from 'axios';
import { API_BASE_URL } from 'env';
export enum RequestMethod { export enum RequestMethod {
GET = 'GET', GET = 'GET',
...@@ -16,7 +17,7 @@ export interface Response<T> { ...@@ -16,7 +17,7 @@ export interface Response<T> {
export type ApiResponse<T> = Promise<Response<T>>; export type ApiResponse<T> = Promise<Response<T>>;
const apiInstance = axios.create({ const apiInstance = axios.create({
baseURL: 'https://dietela-backend.herokuapp.com/', baseURL: API_BASE_URL,
}); });
export async function api<T>( export async function api<T>(
......
...@@ -2654,6 +2654,11 @@ domexception@^1.0.1: ...@@ -2654,6 +2654,11 @@ domexception@^1.0.1:
dependencies: dependencies:
webidl-conversions "^4.0.2" webidl-conversions "^4.0.2"
dotenv@^8.0.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
ecc-jsbn@~0.1.1: ecc-jsbn@~0.1.1:
version "0.1.2" version "0.1.2"
resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz" resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz"
...@@ -6077,6 +6082,13 @@ react-is@^17.0.1: ...@@ -6077,6 +6082,13 @@ react-is@^17.0.1:
resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz" resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
react-native-dotenv@^2.5.5:
version "2.5.5"
resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-2.5.5.tgz#5450fe79859f8553e893129d9fccc855cd38ecd9"
integrity sha512-ODaFNUX52ZYfBLJ8WSEm87nv+HrwxeEoZchuwsPyEWwsC4ARRhklfsKTf1dg09UpPS31zx5IUV431fLvcepCsA==
dependencies:
dotenv "^8.0.0"
react-native-elements@^3.3.2: react-native-elements@^3.3.2:
version "3.3.2" version "3.3.2"
resolved "https://registry.npmjs.org/react-native-elements/-/react-native-elements-3.3.2.tgz" resolved "https://registry.npmjs.org/react-native-elements/-/react-native-elements-3.3.2.tgz"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment