From e87c749f39779675e3efacf0fb1bdaa5a0648ce8 Mon Sep 17 00:00:00 2001
From: Eric Bremner <ebremner@uwaterloo.ca>
Date: Fri, 20 May 2022 13:13:41 -0400
Subject: [PATCH] ISTWCMS-5509: updating build ohana for non theme development

---
 build_ohana.sh | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/build_ohana.sh b/build_ohana.sh
index 2ee70823..87170157 100755
--- a/build_ohana.sh
+++ b/build_ohana.sh
@@ -47,11 +47,9 @@ echo "Done installing correct npm version."
 if [[ $build_option == 1 || $build_option == 3 ]]; then
   echo "**************************************************************************************"
   echo "Setting up theming ..."
-  if [[ $build_option == 1 || $build_option == 3 ]]; then
-    ln -s "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/ohana/dist "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/dist
-    rm -rf src/patterns
-    ln -s ../../src/patterns src/patterns
-  fi
+  ln -s "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/ohana/dist "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/dist
+  rm -rf src/patterns
+  ln -s ../../src/patterns src/patterns
   echo "**************************************************************************************"
   echo "Done setting up theming."
 fi
@@ -71,14 +69,25 @@ npm run build
 echo "**************************************************************************************"
 echo "Done running npm run build."
 
-if [[ $build_option != 1 && $build_option != 3 ]]; then
+if [[ $build_option == 2 || $build_option == 4 ]]; then
   echo "**************************************************************************************"
   echo "Setting up css/js and removing ohana ..."
-  mv "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/ohana/dist "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/
-  cd "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/ohana/dist/css
-  rm !("all.min.css")
-  cd "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/ohana/dist/js
-  rm !("all.min.js")
+  cd ..
+  if [[ ! -d ohana ]]; then
+    mkdir dist
+  fi
+  cp -r ohana/dist/* dist
+  cd dist/css
+  find . -type f -not -name 'all.min.css' -delete
+  cd ../js
+  find . -type f -not -name 'all.min.js' -delete
+  cd ..
+  if [[ -d vendor ]]; then
+    rm -rf vendor
+  fi
+  if [[ -d dist ]]; then
+    rm -rf dist
+  fi
   cd "$DRUPAL_PATH"/web/profiles/uw_base_profile/modules/custom/uw_wcms_ohana/
   rm -rf ohana
   echo "**************************************************************************************"
-- 
GitLab