From ac9c033af852cbe3d30cae98dc003d8732f5ce81 Mon Sep 17 00:00:00 2001
From: Jan Mach <jan.mach@cesnet.cz>
Date: Wed, 27 Sep 2017 12:46:56 +0200
Subject: [PATCH] Updated grunt tasks to enable building and packaging Hawat
 interface in our automated build system.

(Redmine issue: #3387)
---
 Gruntfile.js | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/Gruntfile.js b/Gruntfile.js
index 9ccfba0c4..3d5a6954b 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -70,11 +70,27 @@ module.exports = function(grunt) {
         // ---------------------------------------------------------------------
         // Running shell commands.
         shell: {
-            // Update NodeJS packages (Grunt and grunt plugins)
+            // Update NodeJS packages (Grunt and grunt plugins).
             npm_update: {
                 command: 'npm update'
             },
-            // Calculate directory size, willbe used in DEB package metadata.
+            // Install Yarn managed packages (web interface frontend packages).
+            yarn_install: {
+                command: 'yarn install'
+            },
+            // Upgrade Yarn managed packages (web interface frontend packages).
+            yarn_upgrade: {
+                command: 'yarn upgrade'
+            },
+            // Clean precompiled Python modules.
+            pyclean: {
+                command: 'find lib/ -name *.pyc -delete'
+            },
+            // Compile language dictionaries.
+            pybabel: {
+                command: 'pybabel-python3 compile -d lib/hawat/translations'
+            },
+            // Calculate directory size, will be used in DEB package metadata.
             dir_size: {
                 command: '/usr/bin/du -k -s <%= project_paths.package_dir %> | /usr/bin/cut -f 1',
                 options: {
@@ -166,9 +182,9 @@ module.exports = function(grunt) {
                     // ----- Copy libraries to appropriate package location.
                     {
                         expand: true,
-                        cwd: 'lib/mentat/',
+                        cwd: 'lib/',
                         src: './**',
-                        dest: '<%= project_paths.package_dir %><%= paths_deb.lib_dir %>mentat/'
+                        dest: '<%= project_paths.package_dir %><%= paths_deb.lib_dir %>'
                     },
                     // ----- Copy Debian package meta files to appropriate package location.
                     {
@@ -319,11 +335,11 @@ module.exports = function(grunt) {
 
     grunt.registerTask('deb-build',
                        '(RUN) Build Debian packages for Mentat-ng system.',
-                       ['check-version', 'clean:build', 'shell:deb_archive', 'copy:deb', 'chmod', 'shell:dir_size', 'template:deb-control', 'shell:deb_build', 'clean:build']
+                       ['check-version', 'shell:pyclean', 'clean:build', 'shell:deb_archive', 'webui', 'copy:deb', 'chmod', 'shell:dir_size', 'template:deb-control', 'shell:deb_build', 'clean:build']
         );
     grunt.registerTask('deb-buildbot',
                        '(RUN) Build Debian packages for Mentat-ng system by Buildbot automation system.',
-                       ['check-version', 'clean:build', 'shell:deb_archive', 'copy:deb', 'chmod', 'shell:dir_size', 'template:deb-control', 'shell:deb_build', 'clean:build']
+                       ['check-version', 'shell:pyclean', 'clean:build', 'shell:deb_archive', 'webui', 'copy:deb', 'chmod', 'shell:dir_size', 'template:deb-control', 'shell:deb_build', 'clean:build']
         );
     grunt.registerTask('deb-scp-upload',
                        '(RUN) Upload latest Debian packages to repository server, development server and demo server.',
@@ -351,11 +367,11 @@ module.exports = function(grunt) {
         );
     grunt.registerTask('update',
                        '(RUN) Update internal NPM packages for build suite.',
-                       ['shell:npm_update']
+                       ['shell:npm_update', 'shell:yarn_install']
         );
     grunt.registerTask('webui',
                        '(RUN) Build and install web user interface dependencies.',
-                       ['clean:webui', 'copy:webui']
+                       ['shell:yarn_install', 'shell:pybabel', 'clean:webui', 'copy:webui']
         );
     grunt.registerTask('default',
                        '(RUN) Alias for deb-build, only build Debian packages.',
-- 
GitLab