summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-os/build-ecomportal-fe.sh
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2017-05-04 07:48:42 -0400
committerst782s <statta@research.att.com>2017-05-04 12:28:17 -0400
commitb54df0ddd0c6a0372327c5aa3668e5a6458fcd64 (patch)
treee69cfa9b314a801bd187cf0145d1d4306436229c /ecomp-portal-FE-os/build-ecomportal-fe.sh
parent39d1e62c84041831bfc52cca73b5ed5efaf57d27 (diff)
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: I9a24a338665c7cd058978e8636bc412d9e2fdce8 Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-FE-os/build-ecomportal-fe.sh')
-rw-r--r--ecomp-portal-FE-os/build-ecomportal-fe.sh181
1 files changed, 181 insertions, 0 deletions
diff --git a/ecomp-portal-FE-os/build-ecomportal-fe.sh b/ecomp-portal-FE-os/build-ecomportal-fe.sh
new file mode 100644
index 00000000..8fc199d5
--- /dev/null
+++ b/ecomp-portal-FE-os/build-ecomportal-fe.sh
@@ -0,0 +1,181 @@
+#!/bin/sh
+
+# Script name : build_ecompportal_fe.sh
+# Script purpose : To have an easy way to build the front-end part of the eComp portal
+# Pre requisites :
+# 1. Your home directory must reside at /home
+# 2. Your server must have a 'Node' installation
+#----------------------------------------------------------------------------------------
+
+
+################################################
+### Functions
+################################################
+function log_message() {
+msgType=$1
+message=$2
+
+if [ ${msgType} == "I" ]; then
+printf "\033[32m %s \n\033[0m" "INF - ${message}"
+elif [ ${msgType} == "E" ]; then
+printf "\033[31m %s \n\033[0m" "ERR - ${message}"
+else
+echo "${msgType} - ${message}";
+fi
+}
+
+
+
+function exit_with_error() {
+
+log_message "E" ""
+log_message "E" "$1"
+log_message "E" ""
+
+exit 1
+}
+
+
+
+################################################
+### Hard coded information.
+################################################
+NVM_DIR="/home/${USER}/.nvm"
+NODE_VERSION=v0.12.4
+SCRIPT_USAGE="USAGE: $0 [ dev | ci | integ | qa ]"
+
+
+
+################################################
+### Verify arguments
+################################################
+log_message "I" "Checking command line arguments."
+if [ $# == 1 ]; then
+if [ $1 == "ci" -o $1 == "integ" -o $1 == "dev" -o $1 == "qa" ]; then
+BUILD_BY_ENV=$1
+else
+exit_with_error "The environment '$1' is invalid."
+fi
+else
+log_message "E" ""
+log_message "E" "$SCRIPT_USAGE"
+log_message "E" ""
+exit 1
+fi
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Set the node environment.
+################################################
+log_message "I" "Set the node environment."
+if [ -s "$NVM_DIR/nvm.sh" ]; then
+# This loads nvm
+. "$NVM_DIR/nvm.sh"
+if [ $? != 0 ]; then
+exit_with_error "Cannot load the NODE env."
+fi
+else
+exit_with_error "The nvm.sh script does not exist."
+fi
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Set the node version manager version.
+################################################
+log_message "I" "Set the node version manager version."
+nvm use v0.12.4
+TOOLS_ROOT_FOLDER=${NVM_DIR}/versions/node/${NODE_VERSION}/bin
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Set the proxy servers.
+################################################
+log_message "I" "Set the proxy servers."
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Install bower, if neeeded.
+################################################
+log_message "I" "Install bower, if neeeded."
+if [ ! -e ${TOOLS_ROOT_FOLDER}/bower ]; then
+npm install -g bower
+if [ $? != 0 ]; then
+exit_with_error "Cannot install bower."
+fi
+fi
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Install grunt, if neeeded.
+################################################
+log_message "I" "Install grunt, if neeeded."
+if [ ! -e ${TOOLS_ROOT_FOLDER}/grunt ]; then
+npm config set ca ""
+npm install -g grunt-cli
+
+if [ $? != 0 ]; then
+exit_with_error "Cannot install grunt."
+fi
+fi
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Run the Node package manager (NPM).
+################################################
+log_message "I" "Run the Node package manager (npm install)."
+npm install
+if [ $? != 0 ]; then
+exit_with_error "Cannot run 'npm install'."
+fi
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Install the Bower components.
+################################################
+log_message "I" "Install the Bower components."
+bower install
+if [ $? != 0 ]; then
+exit_with_error "Cannot run 'npm install'."
+fi
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+################################################
+### Build the application.
+################################################
+log_message "I" "Build the application."
+grunt build --env=${BUILD_BY_ENV}
+if [ $? != 0 ]; then
+exit_with_error "Cannot run 'grunt build --env=${BUILD_BY_ENV}'."
+fi
+log_message "I" "OK."
+log_message "I" ""
+
+
+
+log_message "I" ""
+log_message "I" "Done."
+log_message "I" "" \ No newline at end of file