github.com/greenpau/go-authcrunch@v1.1.4/assets/scripts/update_ui_apps.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  printf "Updating UI apps\n"
     5  
     6  SCRIPT_DIR=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
     7  ASSETS_DIR=$(dirname -- "$SCRIPT_DIR")
     8  ROOT_DIR=$(dirname -- "$ASSETS_DIR")
     9  
    10  echo $SCRIPT_DIR
    11  echo $ROOT_DIR
    12  
    13  
    14  UI_FILE=pkg/authn/ui/apps.go
    15  
    16  declare -a _APPS
    17  _APPS[${#_APPS[@]}]="profile"
    18  
    19  cat << 'EOF' > ${UI_FILE}
    20  package ui
    21  
    22  import (
    23  	"embed"
    24  )
    25  
    26  var (
    27      //go:embed profile
    28      embedFileSystem embed.FS
    29      embedPages = map[string]string{
    30  EOF
    31  
    32  for APP_ID in "${!_APPS[@]}"; do
    33      cd $ROOT_DIR
    34      APP_NAME=${_APPS[$APP_ID]};
    35      echo "Updating ${APP_NAME} app";
    36      APP_DIR=../../authcrunch/authcrunch-ui/frontend/${APP_NAME}/build
    37      if [ -d ${APP_DIR} ]; then
    38          echo "App directory ${APP_DIR} exists."
    39      else
    40          echo "ERROR: App directory ${APP_DIR} does not exist."
    41          exit 1
    42      fi
    43      rm -rf pkg/authn/ui/${APP_NAME}
    44      cp -R ../../authcrunch/authcrunch-ui/frontend/${APP_NAME}/build pkg/authn/ui/${APP_NAME}
    45      echo "\"${APP_NAME}/\": \"${APP_NAME}/index.html\"," >> ${UI_FILE}
    46  
    47      cd pkg/authn/ui
    48      for APP_UI_FILE in `find ${APP_NAME} -type f`; do
    49          echo "\"${APP_UI_FILE}\": \"${APP_UI_FILE}\"," >> apps.go
    50      done
    51      cd $ROOT_DIR
    52  done
    53  
    54  
    55  cat << 'EOF' >> ${UI_FILE}
    56      }
    57  )
    58  EOF
    59  go fmt ${UI_FILE}