From e3e69a88e6109679d14bdebda6477a19973a77eb Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Tue, 22 Aug 2023 23:11:50 +0200 Subject: [PATCH] reinstated vue mode switch --- build.php | 1 + build.sh | 21 +++++++++++++++++++++ vuemode.sh | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100755 vuemode.sh diff --git a/build.php b/build.php index 39115f9..1b893ad 100644 --- a/build.php +++ b/build.php @@ -10,6 +10,7 @@ $exclude_paths = [ "build", // dir for build zip files "build/*", "build.*", + "vuemode.sh", "amd/src", "amd/src/*", ".git", diff --git a/build.sh b/build.sh index b12fd54..9f52a0a 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,30 @@ #!/bin/bash SCRIPTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) WD=`pwd` +# get the current vuejs mode +VUEMODE=`$SCRIPTDIR/vuemode.sh query` +if [[ $? -eq 1 ]]; then + exit 1 +fi + +# switch vuejs to prod mode +$SCRIPTDIR/vuemode.sh prod + +# run the grunt script in the scripts working directory +# so we can be sure all javascript is properly built from the most recent source +cd $SCRIPTDIR +grunt amd # run the build php script php ${SCRIPTDIR}/build.php $@ +if [[ "$VUEMODE" == "dev" ]]; then + # switch vuejs vack to original mode + $SCRIPTDIR/vuemode.sh $VUEMODE + + # re-do the grunt compiling + grunt amd +fi + # return to the working directory cd $WD \ No newline at end of file diff --git a/vuemode.sh b/vuemode.sh new file mode 100755 index 0000000..01ecedf --- /dev/null +++ b/vuemode.sh @@ -0,0 +1,38 @@ +#!/bin/bash +SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +VUESRC="$SCRIPTPATH/amd/src/vue" +VUEBUILD="$SCRIPTPATH/amd/build/vue" +VUEPROD="$SCRIPTPATH/amd/src/vue/prod" +VUEDEV="$SCRIPTPATH/amd/src/vue/dev" + +VUEJS_MD5=($(md5sum $VUESRC/vue.js)) +VUEPROD_MD5=($(md5sum $VUEPROD/vue.js)) +VUEDEV_MD5=($(md5sum $VUEDEV/vue.js)) + +if [[ "$VUEJS_MD5" == "$VUEDEV_MD5" ]]; then + MODE="dev" +elif [[ "$VUEJS_MD5" == "$VUEPROD_MD5" ]]; then + MODE="prod" +elif [[ "$2" != "-f" && "$1" != "query" ]]; then + echo "ERROR: $VUELINK is not a a copy of either ../vue/vue-dev.js or ../vue/vue-prod.js" + echo "Maybe you manually changed it? Use -f to force overwrite in this case" + exit 1 +fi + +# SINCE the production version of vue.js s already minified, we may get away with simply copying it +# to the build directory +if [ "$1" == "dev" ]; then + cp $VUEDEV/vue.js $VUEBUILD/vue.min.js + cp $VUEDEV/vue.js $VUESRC/vue.js + rm $VUEBUILD/vue.min.js.map 2>/dev/null +elif [ "$1" == "prod" ]; then + cp $VUEPROD/vue.js $VUEBUILD/vue.min.js + cp $VUEPROD/vue.js $VUESRC/vue.js + rm $VUEBUILD/vue.min.js.map 2>/dev/null +elif [ "$1" == "query" ]; then + echo $MODE +else + echo "Switch VueJS between development and production mode" + echo "Usage:" + echo "$SCRIPTNAME [-f]" +fi