Booking Activities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

109 lines
2.4 KiB

#!/usr/bin/bash
NAME="booking-activities-silicon"
VERSION="1.7.20.20200307"
ZIPBASEDIR="$(basename $(dirname $(realpath $0)))"
ZIPNAME="${NAME}-${VERSION}.zip"
DEBUG="$(echo $@ | grep debug >/dev/null && echo debug)"
CSS_ONLY="$(echo $@ | grep css >/dev/null && echo css)"
JS_ONLY="$(echo $@ | grep js >/dev/null && echo js)"
ZIP_ONLY="$(echo $@ | grep zip >/dev/null && echo zip)"
JS_IGNORE="select2"
CSS_IGNORE="select2"
if [[ -z "${CSS_ONLY}" && -z "${JS_ONLY}" && -z "${ZIP_ONLY}" ]]; then
CSS_ONLY="css"
JS_ONLY="js"
fi
function js_uglify() {
INPUT_JS="${1}"
DEBUG="${2}"
if [[ -n "${DEBUG}" ]]; then
uglifyjs -c -m --source-map "${INPUT_JS}".map --source-map-include-sources -o ${jsfile%.js}.min.js ${jsfile}
else
uglifyjs -c -m -o ${jsfile%.js}.min.js ${jsfile}
fi
}
function js_dir() {
DIR="${1}"
pushd "${DIR}" >/dev/null
for jsfile in $(ls -p | grep -v / | grep -v js.map | grep -v min.js | grep -v "${JS_IGNORE}"); do
echo "${jsfile}"
js_uglify ${jsfile} ${DEBUG} 2>/dev/null
done
popd >/dev/null
}
function css_cssmin() {
INPUT_CSS="${1}"
DEBUG="${2}"
if [[ -n "${DEBUG}" ]]; then
cp ${INPUT_CSS} ${INPUT_CSS%.css}.min.css
else
cssmin-cli ${INPUT_CSS} > ${INPUT_CSS%.css}.min.css
fi
}
function css_dir() {
DIR="${1}"
pushd "${DIR}" >/dev/null
for cssfile in $(ls -p | grep -v / | grep -v min.css | grep -v "${CSS_IGNORE}"); do
echo "${cssfile}"
css_cssmin ${cssfile} ${DEBUG} 2>/dev/null
done
popd >/dev/null
}
if [[ -n "${DEBUG}" ]]; then
echo "Creating debug build ${NAME}-${VERSION}.zip from \"${ZIPBASEDIR}\""
else
echo "Creating ${NAME}-${VERSION}.zip from \"${ZIPBASEDIR}\""
fi
if [[ -n "${JS_ONLY}" && -z "${ZIP_ONLY}" ]]; then
echo "------------"
echo "Uglifyjs"
echo "----"
echo "Main Booking Activites"
js_dir js
echo "----"
echo "BA:Silicon"
js_dir silicon/js
fi
if [[ -n "${CSS_ONLY}" && -z "${ZIP_ONLY}" ]]; then
echo "------------"
echo "CSSmin"
echo "----"
echo "Main Booking Activities"
css_dir css
echo "----"
echo "BA:Silicon"
css_dir silicon/css
fi
echo "------------"
echo "Compress to zip"
pushd .. >/dev/null
if [[ -f ${ZIPNAME} ]] ; then
rm ${ZIPNAME}
fi
zip -q -r ${ZIPNAME} ./"${ZIPBASEDIR}"/* -x \*build.sh -x \*.git -x \*.sonarlint
popd >/dev/null
echo "============"
echo "Complete"