#!/bin/sh

echo start installing required native and 3rd party plugins

echo to update angular -> npm install -g @angular/cli
echo to update ionic  -> npm install -g ionic

echo add browser, android , ios platforms commit non required
echo to add browser -> call ionic cordova platform add browser
echo to add ios     -> call ionic cordova platform add ios

ionic cordova platform add android
 
echo copying android FCM google servcie file
 cp ./google-services.json  ./platforms/android/

 npm i @angular/animations 
 npm i @swimlane/ngx-charts --save

echo primeng framework [angular] 

 npm install primeng --save
 npm install primeicons --save

echo  add css links for primeng in global.scss 
echo  @import "../node_modules/primeng/resources/themes/nova-light/theme.css";
echo  @import "../node_modules/primeng/resources/primeng.min.css";
echo  @import "../node_modules/primeicons/primeicons.css";

echo install chartjs as dependency for primeng chartjs
npm install chart.js --save
# echo add reference in [angular.json] in [scripts] array add (node_modules/chart.js/dist/Chart.js)


echo calendar  https://mattlewis92.github.io/angular-calendar/#/kitchen-sink
 npm install --save @ng-bootstrap/ng-bootstrap
 npm install --save angular-calendar date-fns

echo install android support gradle release because of barcode scanner  to install missing android attributes
ionic cordova plugin add cordova-android-support-gradle-release --fetch


echo push notifications
ionic cordova plugin add phonegap-plugin-push  --variable GOOGLE_PLAY_SERVICES_VERSION="16.0.0" --variable FCM_VERSION="15.0.0"
npm install @ionic-native/push


echo sqlite storage
 ionic cordova plugin add cordova-sqlite-storage
 npm install @ionic-native/sqlite


echo native storage
 ionic cordova plugin add cordova-plugin-nativestorage
 npm install @ionic-native/native-storage


echo bluetooth ble centeral //check interface assets/js/bletooth.js
 ionic cordova plugin add cordova-plugin-ble-central
 npm install @ionic-native/ble

 
echo launch navigator
echo warning : for now we stick with launch navigator 3 since 5 has issue
#  call ionic cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable GOOGLE_API_KEY_FOR_ANDROID="AIzaSyC-XbzwGMyAVCnspof0cqiO4iLfKmeEYVA"
 ionic cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator@3
 npm install @ionic-native/launch-navigator

 echo themeablebrowser

 ionic cordova plugin add cordova-plugin-themeablebrowser
 npm install @ionic-native/themeable-browser

echo in app browser
ionic cordova plugin add cordova-plugin-inappbrowser
npm install @ionic-native/in-app-browser


echo globalization

 ionic cordova plugin add cordova-plugin-globalization
 npm install @ionic-native/globalization


echo android permissions plugin
 ionic cordova plugin add cordova-plugin-android-permissions
 npm install @ionic-native/android-permissions

echo sms reader  https://www.npmjs.com/package/cordova-plugin-sms-receive
 npm i cordova-plugin-sms-receive
 cordova plugin add cordova-plugin-sms-receive

echo device information§
 ionic cordova plugin add cordova-plugin-device
 npm install @ionic-native/device

echo local notifications
 ionic cordova plugin add cordova-plugin-local-notification
 npm install @ionic-native/local-notifications

echo call phone number
 ionic cordova plugin add call-number
 npm install @ionic-native/call-number

echo badge
 ionic cordova plugin add cordova-plugin-badge
 npm install @ionic-native/badge


echo biometric features 
 ionic cordova plugin add cordova-plugin-fingerprint-aio --variable FACEID_USAGE_DESCRIPTION="User Authentication"
 npm install @ionic-native/fingerprint-aio

echo install diagnostic 
 ionic cordova plugin add cordova.plugins.diagnostic
 npm install @ionic-native/diagnostic

echo install background-geolocation
 ionic cordova plugin add cordova-plugin-mauron85-background-geolocation@alpha --variable GOOGLE_PLAY_SERVICES_VERSION="16.0.0"
 npm install @ionic-native/background-geolocation

echo install barcode plugin
 ionic cordova plugin add phonegap-plugin-barcodescanner
 npm install @ionic-native/barcode-scanner

echo install camera plugin
 ionic cordova plugin add cordova-plugin-camera
 npm install @ionic-native/camera

echo install keyboard plugin
 ionic cordova plugin add cordova-plugin-ionic-keyboard
 npm install @ionic-native/keyboard

echo install opentok required permissions
ionic cordova plugin add cordova-opentok-android-permissions

echo install health plugin
ionic cordova plugin add cordova-plugin-health --variable HEALTH_READ_PERMISSION="App needs read access to read heart rate"  --variable HEALTH_WRITE_PERMISSION="App needs write access for heart rate" --variable GMS_VERSION="16.0.1"
npm install @ionic-native/health

echo install App Availability Plugin
ionic cordova plugin add cordova-plugin-appavailability
npm install @ionic-native/app-availability

echo install rate plugin
ionic cordova plugin add cordova-plugin-apprate
npm install @ionic-native/app-rate


echo reinitializing git repository
echo git init
echo git remote add  origin https://enas_yaghi@hmg.git.cloudforge.com/patientappionic.git
echo git push -f origin master


echo update project from package.js change if necessary 
echo to install all dependencies in package.json

echo npm cache clean --force
echo exact version -> npm install --save --save-exact react
echo latest versions based on package.json rules  -> npm install

echo to build or serve for (( production ))
echo export NODE_OPTIONS=--max-old-space-size=4096
echo ionic serve --prod  -> for serving in production
echo ionic cordova build android  --release --aot --minifyjs --optimizejs --minifycss  
echo ionic cordova build ios  --release --aot --minifyjs --optimizejs --minifycss  
