This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git


The following commit(s) were added to refs/heads/master by this push:
     new 2129074  footer: show Primate version
2129074 is described below

commit 2129074d528e41f0fc3a0f410c2b359789b68a47
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
AuthorDate: Tue Jun 16 22:06:33 2020 +0530

    footer: show Primate version
    
    Show Primate version in footer based on package.json
    
    Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>
---
 packaging/package.sh                 | 9 +++++----
 src/components/page/GlobalFooter.vue | 4 +++-
 src/store/getters.js                 | 1 +
 src/store/modules/app.js             | 1 +
 vue.config.js                        | 9 ++++++++-
 5 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/packaging/package.sh b/packaging/package.sh
index 2ae2729..1160de4 100644
--- a/packaging/package.sh
+++ b/packaging/package.sh
@@ -22,8 +22,6 @@ set -x
 ROOT=$PWD
 
 function package_deb() {
-    VERSION=$(cd ../; grep --color=none \"version\" package.json | cut -d '"' 
-f4)
-    DATE=$(date +"%Y%m%d")
     sed -i "s/VERSION/$VERSION-$DATE/g" debian/changelog
     dpkg-buildpackage -uc -us
     $(cd ../; tar czf cloudstack-primate-$VERSION-$DATE.tar.gz dist 
--transform s/dist/primate/)
@@ -33,10 +31,9 @@ function package_rpm() {
     CWD=`pwd`
     RPMDIR=$CWD/../build
 
-    VERSION=$(cd ../; grep --color=none \"version\" package.json | cut -d '"' 
-f4)
     REALVER=`echo $VERSION`
     DEFVER="-D_ver $REALVER"
-    DEFREL="-D_rel $(date +"%Y%m%d")"
+    DEFREL="-D_rel $DATE"
 
     echo Preparing to package CloudStack Primate ${VERSION}
 
@@ -63,6 +60,10 @@ function package_rpm() {
     fi
 }
 
+DATE=$(date +"%Y%m%d")
+VERSION=$(grep -Po '"version": "\K[^"]*' ../package.json)
+sed -i "s/\"version\":.*/\"version\": \"$VERSION$DATE\",/g" ../package.json
+
 case "$1" in
   deb ) package_deb
       ;;
diff --git a/src/components/page/GlobalFooter.vue 
b/src/components/page/GlobalFooter.vue
index 9438494..1df96d4 100644
--- a/src/components/page/GlobalFooter.vue
+++ b/src/components/page/GlobalFooter.vue
@@ -18,7 +18,9 @@
 <template>
   <div class="footer">
     <div class="links">
-      CloudStack Server {{ $store.getters.features.cloudstackversion }}
+      CloudStack {{ $store.getters.features.cloudstackversion }}
+      <a-divider type="vertical" />
+      Primate {{ $store.getters.version }}
       <a-divider type="vertical" />
       <a href="https://github.com/apache/cloudstack-primate/issues/new/choose"; 
target="_blank">
         <a-icon type="github"/>
diff --git a/src/store/getters.js b/src/store/getters.js
index fba66a8..97103b4 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -17,6 +17,7 @@
 
 const getters = {
   device: state => state.app.device,
+  version: state => state.app.version,
   theme: state => state.app.theme,
   color: state => state.app.color,
   token: state => state.user.token,
diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index b71b772..c954ff6 100644
--- a/src/store/modules/app.js
+++ b/src/store/modules/app.js
@@ -31,6 +31,7 @@ import {
 
 const app = {
   state: {
+    version: process.env.PACKAGE_VERSION || 'master',
     sidebar: true,
     device: 'desktop',
     theme: '',
diff --git a/vue.config.js b/vue.config.js
index 3bb6d87..4421a02 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -18,6 +18,8 @@
 const path = require('path')
 const webpack = require('webpack')
 const fs = require('fs')
+const packageJson = fs.readFileSync('./package.json')
+const version = JSON.parse(packageJson).version || 'master'
 
 function resolve (dir) {
   return path.join(__dirname, dir)
@@ -43,7 +45,12 @@ module.exports = {
   configureWebpack: {
     plugins: [
       // Ignore all locale files of moment.js
-      new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
+      new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
+      new webpack.DefinePlugin({
+        'process.env': {
+          PACKAGE_VERSION: '"' + version + '"'
+        }
+      })
     ]
   },
 

Reply via email to