From d0fc823b5a6f1ae06ccb872a15d56cc5bd8118a3 Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Fri, 27 Dec 2019 20:07:29 +0100
Subject: [PATCH] [fix] Fix gulp file

---
 gulpfile.js              |   7 +-
 release.sh               | 205 ---------------------------------------
 scripts/build-android.sh |   9 +-
 scripts/env-global.sh    |  16 +++
 www/js/config.js         |   2 +-
 5 files changed, 27 insertions(+), 212 deletions(-)
 delete mode 100755 release.sh

diff --git a/gulpfile.js b/gulpfile.js
index 430f861c..b686b2f9 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -21,7 +21,6 @@ const gulp = require('gulp'),
   useref = require('gulp-useref'),
   filter = require('gulp-filter'),
   uglify = require('gulp-uglify'),
-  concat = require('gulp-concat'),
   csso = require('gulp-csso'),
   replace = require('gulp-replace'),
   rev = require('gulp-rev'),
@@ -637,9 +636,9 @@ gulp.task('build', [
   'plugin'
 ]);
 
-gulp.task('ionic:serve:before', ['build', 'watch']);
-gulp.task('sass', ['config', 'build']);
-gulp.task('default', ['config', 'build']);
+gulp.task('ionic:serve:before', ['build', 'watch'], done => done());
+gulp.task('sass', ['license', 'appSass', 'pluginSass'], done => done());
+gulp.task('default', ['config', 'build'], done => done());
 
 gulp.task('webClean', [], webClean);
 gulp.task('webCopyFiles', ['config', 'sass', 'webClean'], webCopyFiles);
diff --git a/release.sh b/release.sh
deleted file mode 100755
index f0c7c226..00000000
--- a/release.sh
+++ /dev/null
@@ -1,205 +0,0 @@
-#!/bin/bash
-
-DIRNAME=$(dirname "$0")
-cd $DIRNAME
-
-### Control that the script is run on `dev` branch
-branch=`git rev-parse --abbrev-ref HEAD`
-if [[ ! "$branch" = "master" ]];
-then
-  echo ">> This script must be run under \`master\` branch"
-  exit 1
-fi
-
-### Get current version (package.json)
-current=`grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?" package.json | grep -m 1 -oP "\d+.\d+.\d+((a|b)[0-9]+)?"`
-if [[ "_$current" == "_" ]]; then
-  echo "Unable to read the current version in 'package.json'. Please check version format is: x.y.z (x and y should be an integer)."
-  exit 1;
-fi
-echo "Current version: $current"
-
-### Get current version for Android
-currentAndroid=`grep -oP "android-versionCode=\"[0-9]+\"" config.xml | grep -oP "\d+"`
-if [[ "_$currentAndroid" == "_" ]]; then
-  echo "Unable to read the current Android version in 'config.xml'. Please check version format is an integer."
-  exit 1;
-fi
-echo "Current Android version: $currentAndroid"
-
-# Check version format
-if [[ ! $2 =~ ^[0-9]+.[0-9]+.[0-9]+((a|b)[0-9]+)?$ || ! $3 =~ ^[0-9]+$ ]]; then
-  echo "Wrong version format"
-  echo "Usage:"
-  echo " > ./release.sh [pre|rel] <version>  <android-version> <release_description>"
-  echo "with:"
-  echo " - pre: use for pre-release"
-  echo " - rel: for full release"
-  echo " - version: x.y.z"
-  echo " - android-version: nnn"
-  echo " - release_description: a comment on release"
-  exit 1
-fi
-
-echo "new build version: $2"
-echo "new build android version: $3"
-case "$1" in
-  rel|pre)
-    # Change the version in files: 'package.json' and 'config.xml'
-    sed -i "s/version\": \"$current\"/version\": \"$2\"/g" package.json
-    currentConfigXmlVersion=`grep -oP "version=\"\d+.\d+.\d+((a|b)[0-9]+)?\"" config.xml | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?"`
-    sed -i "s/ version=\"$currentConfigXmlVersion\"/ version=\"$2\"/g" config.xml
-    sed -i "s/ android-versionCode=\"$currentAndroid\"/ android-versionCode=\"$3\"/g" config.xml
-
-    # Change version in file: 'www/manifest.json'
-    currentManifestJsonVersion=`grep -oP "version\": \"\d+.\d+.\d+((a|b)[0-9]+)?\"" www/manifest.json | grep -oP "\d+.\d+.\d+((a|b)[0-9]+)?"`
-    sed -i "s/version\": \"$currentManifestJsonVersion\"/version\": \"$2\"/g" www/manifest.json
-
-    # Bump the install.sh
-    sed -i "s/echo \"v.*\" #lastest/echo \"v$2\" #lastest/g" install.sh
-    ;;
-  *)
-    echo "No task given"
-    exit 1
-    ;;
-esac
-
-# Load env.sh if exists
-if [[ -f "${DIRNAME}/.local/env.sh" ]]; then
-  echo "Loading .local/env.sh ..."
-  source "${DIRNAME}/.local/env.sh" $*
-fi
-
-# Check the Java version
-JAVA_VERSION=`java -version 2>&1 | egrep "(java|openjdk) version" | awk '{print $3}' | tr -d \"`
-if [[ $? -ne 0 ]]; then
-  echo "No Java JRE 1.8 found in machine. This is required for Android artifacts."
-  exit 1
-fi
-JAVA_MAJOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[1]}'`
-JAVA_MINOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[2]}'`
-if [[ ${JAVA_MAJOR_VERSION} -ne 1 ]] || [[ ${JAVA_MINOR_VERSION} -ne 8 ]]; then
-  echo "Require a Java JRE in version 1.8, but found ${JAVA_VERSION}. You can override your default JAVA_HOME in '.local/env.sh'."
-  exit 1
-fi
-echo "Java: $JAVA_VERSION"
-
-
-# force nodejs version to 6
-if [[ -d "$NVM_DIR" ]]; then
-  . $NVM_DIR/nvm.sh
-  nvm use 6
-  if [[ $? -ne 0 ]]; then
-    exit 1
-  fi
-else
-  echo "nvm (Node version manager) not found (directory $NVM_DIR not found). Please install, and retry"
-  exit 1
-fi
-
-# Update config file
-gulp config --env default_fr
-
-echo "----------------------------------"
-echo "- Compiling sources..."
-echo "----------------------------------"
-gulp
-
-echo "----------------------------------"
-echo "- Building Android artifact..."
-echo "----------------------------------"
-rm -rf platforms/android/build/outputs/release/*
-ionic build android --release
-if [[ $? -ne 0 ]]; then
-  exit 1
-fi
-
-
-echo "----------------------------------"
-echo "- Building web artifact..."
-echo "----------------------------------"
-
-# Update config file
-gulp config --env default
-gulp build:web --release
-if [[ $? -ne 0 ]]; then
-  exit 1
-fi
-
-echo "----------------------------------"
-echo "- Executing git push, with tag: v$2"
-echo "----------------------------------"
-
-# Commit
-cd ${DIRNAME}
-git reset HEAD
-git add package.json config.xml install.sh www/js/config.js www/manifest.json
-if [[ $? -ne 0 ]]; then
-  exit 1
-fi
-git commit -m "v$2" && git tag "v$2" && git push
-if [[ $? -ne 0 ]]; then
-  exit 1
-fi
-
-# Commit android project
-cd ${DIRNAME}/platforms/android
-git reset HEAD
-git add -A
-git commit -m "v$2" && git tag "v$2" && git push
-if [[ $? -ne 0 ]]; then
-  exit 1
-fi
-
-# Pause (wait propagation to from git.duniter.org to github)
-echo " Waiting 40s, for propagation to github..."
-sleep 40s
-
-description="$4"
-if [[ "_$description" == "_" ]]; then
-   description="Release v$2"
-fi
-
-echo "**********************************"
-echo "* Uploading artifacts to Github..."
-echo "**********************************"
-
-./github.sh $1 ''"$description"''
-if [[ $? -ne 0 ]]; then
-    exit 1
-fi
-
-echo "----------------------------------"
-echo "- Building desktop artifacts..."
-echo "----------------------------------"
-
-git submodule init && git submodule sync && git submodule update --remote --merge
-if [[ $? -ne 0 ]]; then
-  echo "Unable to sync git submodule. Could not build desktop version"
-  exit 1
-fi
-
-if [[ -d "${DIRNAME}/dist/desktop" ]]; then
-  cd "${DIRNAME}/dist/desktop"
-
-  # Fetch last updates
-  git fetch origin && git merge origin/master || exit 1
-
-  # Build desktop assets
-  ./release.sh $2
-  if [[ $? -ne 0 ]]; then
-      exit 1
-  fi
-else
-  echo "ERROR: dist/desktop not found -> Make sure git submodule has been init!"
-  exit 1
-fi;
-
-# back to nodejs version 6
-cd ${DIRNAME}
-nvm use 6
-
-echo "**********************************"
-echo "* Build release succeed !"
-echo "**********************************"
-
diff --git a/scripts/build-android.sh b/scripts/build-android.sh
index c5f10e83..491f9ed9 100755
--- a/scripts/build-android.sh
+++ b/scripts/build-android.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+
 # Get to the root project
 if [[ "_" == "_${PROJECT_DIR}" ]]; then
   SCRIPT_DIR=$(dirname $0)
@@ -15,6 +16,10 @@ fi
 cd ${PROJECT_DIR}
 
 # Run the build
-echo "Running cordova build..."
-ionic cordova build android --warning-mode=none --color
+echo "Cleaning previous android APK files..."
+rm -rf ${ANDROID_OUTPUT_APK_DEBUG}/*.apk
+rm -rf ${ANDROID_OUTPUT_APK_RELEASE}/*.apk
+
+echo "Running cordova build android..."
+ionic cordova build android --warning-mode=none --color $*
 #ionic cordova build android --warning-mode=none --color --verbose
diff --git a/scripts/env-global.sh b/scripts/env-global.sh
index 28e43597..4acb1a6e 100755
--- a/scripts/env-global.sh
+++ b/scripts/env-global.sh
@@ -21,6 +21,9 @@ ANDROID_SDK_VERSION=r29.0.0
 ANDROID_SDK_TOOLS_VERSION=4333796
 ANDROID_SDK_ROOT=/usr/lib/android-sdk
 ANDROID_SDK_TOOLS_ROOT=${ANDROID_SDK_ROOT}/build-tools
+ANDROID_OUTPUT_APK=platforms/android/build/outputs/apk
+ANDROID_OUTPUT_APK_DEBUG=${ANDROID_OUTPUT_APK}/debug
+ANDROID_OUTPUT_APK_RELEASE=${ANDROID_OUTPUT_APK}/release
 
 #JAVA_HOME=
 
@@ -45,6 +48,19 @@ if [[ "_" == "_${JAVA_HOME}" ]]; then
     echo "No Java installed. Please install java, or set env variable JAVA_HOME "
     exit 1
   fi
+
+  # Check the Java version
+  JAVA_VERSION=`java -version 2>&1 | egrep "(java|openjdk) version" | awk '{print $3}' | tr -d \"`
+  if [[ $? -ne 0 ]]; then
+    echo "No Java JRE 1.8 found in machine. This is required for Android artifacts."
+    exit 1
+  fi
+  JAVA_MAJOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[1]}'`
+  JAVA_MINOR_VERSION=`echo ${JAVA_VERSION} | awk '{split($0, array, ".")} END{print array[2]}'`
+  if [[ ${JAVA_MAJOR_VERSION} -ne 1 ]] || [[ ${JAVA_MINOR_VERSION} -ne 8 ]]; then
+    echo "Require a Java JRE in version 1.8, but found ${JAVA_VERSION}. You can override your default JAVA_HOME in '.local/env.sh'."
+    exit 1
+  fi
 fi
 
 # Checking Android SDK
diff --git a/www/js/config.js b/www/js/config.js
index 3c4a0db7..1b71f24e 100644
--- a/www/js/config.js
+++ b/www/js/config.js
@@ -94,7 +94,7 @@ angular.module("cesium.config", [])
 		}
 	},
 	"version": "1.4.15",
-	"build": "2019-12-27T18:57:30.124Z",
+	"build": "2019-12-27T19:07:17.137Z",
 	"newIssueUrl": "https://git.duniter.org/clients/cesium-grp/cesium/issues/new"
 })
 
-- 
GitLab