File dev-helper/update.sh

Last commit: Thu Apr 24 00:13:35 2025 +0200	Jan Dankert	New: OpenAPI with REST interface for all actions and methods
1 #!/bin/bash 2 3 cd "$(dirname "$0")" 4 5 # Calling the template compiler if a template or a component was modified. 6 # 7 # Need for: 8 # - inotify-tools 9 # - curl 10 # - getopt 11 # 12 # On Ubuntu/Debian install them with 'apt-get install inotify-tools curl'. 13 # 14 15 16 usage() { 17 echo "Usage: $0 [-t <theme>] [-w] [-x <type>] [-u <host/path>]" 1>&2; 18 exit 1; 19 } 20 21 url="http://localhost:8000/" 22 watch= 23 type= 24 theme="default" 25 26 while getopts "wt:x:hu:" o; do 27 case "${o}" in 28 t) 29 theme=${OPTARG} 30 ;; 31 w) 32 watch=true 33 ;; 34 h) 35 usage; exit 1; 36 ;; 37 u) 38 url=${OPTARG} 39 ;; 40 x) 41 type=${OPTARG} 42 ;; 43 *) 44 usage 45 ;; 46 esac 47 done 48 shift $((OPTIND-1)) 49 50 if [ -z "${type}" ]; then 51 echo "Select a type" 52 select type in "tpl" "xsd" "css" "js" "lang" "api" "all"; do 53 break; 54 done 55 fi 56 57 if [ "${type}" == "all" ]; then 58 types=(tpl xsd css js lang api) 59 else 60 types=($type) 61 fi 62 63 function update { 64 url=$1 65 type=$2 66 echo "update started at $(date)" 67 curl --fail -X POST -d "type=$type" $url/dev-helper/update.php 68 retVal=$? 69 if [ $retVal -ne 0 ]; then 70 echo "An error occured! Returncode was $retVal" 71 exit 4; 72 else 73 echo "Sucessful update." 74 fi 75 echo "update ended at $(date)" 76 } 77 78 function make_writable { 79 type=$1 80 theme=$2 81 case $type in 82 lang ) chmod -v a+w ../modules/language ../modules/language/Language_*.php ../modules/language/Messages*;; 83 xsd ) chmod -v a+w ../modules/template_engine/components/template.xsd ../modules/template_engine/components/components.ini;; 84 css ) find ../modules/cms/ui/themes/$theme/style/ -type f -name "*.css" -exec chmod -v a+w {} \; ; find ../modules/template_engine/components/html/ -type f -name "*.css" -exec chmod -v a+w {} \; ;; 85 js ) find ../modules/cms/ui/themes/$theme/script/ -type f -name "*.min.js" -exec chmod -v a+w {} \; ; find ../modules/template_engine/components/html/ -type f -name "*.min.js" -exec chmod -v a+w {} \; ;; 86 tpl ) find ../modules/cms/ui/themes/$theme/html/views/ -type f -name "*.php" -exec chmod -v a+w {} \; ;; 87 api ) chmod -v a+w ../openapi.*;; 88 * ) echo "unknown type";exit;; 89 esac 90 } 91 92 93 function get_file_to_watch { 94 type=$1 95 theme=$2 96 case $type in 97 lang ) 98 watchfiles+=' ../modules/language/';; 99 xsd ) 100 watchfiles+=' ../modules/template_engine/components/html';; 101 css ) 102 watchfiles+=" ../modules/cms/ui/themes/$theme/style";; 103 js ) 104 watchfiles+=" ../modules/cms/ui/themes/$theme/script";; 105 tpl ) 106 watchfiles+=" ../modules/template_engine/components/html ../modules/cms/ui/themes/$theme/html/views";; 107 api ) 108 watchfiles+=" ../modules/cms/action";; 109 110 * ) echo "unknown type";exit;; 111 esac 112 } 113 114 115 for type in ${types[*]}; do 116 make_writable $type $theme 117 done 118 119 while true; do 120 121 # Calling update first 122 for type in ${types[*]}; do 123 update $url $type 124 done 125 126 127 if [ -z "${watch}" ]; then 128 echo "not watching, exiting." 129 exit 0; # Exit, because watching is not enabled 130 fi; 131 132 watchfiles= 133 for type in ${types[*]}; do 134 get_file_to_watch $type $theme 135 done 136 137 echo "Watching for files in $watchfiles" 138 inotifywait --event modify -r $watchfiles & 139 140 echo "Watching ..." 141 wait 142 echo "File change detected, updating ..." 143 done 144 145
Download dev-helper/update.sh
History Thu, 24 Apr 2025 00:13:35 +0200 Jan Dankert New: OpenAPI with REST interface for all actions and methods Sun, 13 Oct 2024 13:17:32 +0200 Jan Dankert New Minifier for CSS and JS: Leave JS Linebreaks as they are (for better debugging); Exploded CSS files (instead of a combined one), LESS is necessary but should be avoided in the future. Sat, 28 Jan 2023 19:10:47 +0100 Jan Dankert New: Templates may be rendered as Mustache, Script and Script template. Sat, 18 Dec 2021 03:47:23 +0100 dankert New: Every ES6-Module should have a minified version for performance reasons. Bad: The Minifier "Jsqueeze" is unable to minify ES6-modules, so we had to implement a simple JS-Minifier which strips out all comments. Sat, 24 Oct 2020 00:22:18 +0200 Jan Dankert Refactoring: Language files as classes Tue, 20 Oct 2020 00:34:04 +0200 Jan Dankert New: update.sh is now able to accept the type 'all'. The script watch-all.sh is not necessary any more. Sun, 18 Oct 2020 01:30:49 +0200 Jan Dankert New component "fieldset" for better form layout. Sat, 17 Oct 2020 01:10:24 +0200 Jan Dankert New: A helper script for setting up all watches for frontend development. Thu, 10 Sep 2020 17:47:47 +0200 Jan Dankert Language Compiler is generating a Messages class which contains all language keys. Applicaton code should use this constants where possible. Sat, 22 Aug 2020 02:38:58 +0200 Jan Dankert Documentation is a good thing. Sat, 22 Aug 2020 02:27:48 +0200 Jan Dankert Recatoring: New script 'update.sh' for a more comfortable way to update the internal ui elements.