summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rwxr-xr-xactions109
1 files changed, 109 insertions, 0 deletions
diff --git a/actions b/actions
new file mode 100755
index 0000000..a18c9ff
--- /dev/null
+++ b/actions
@@ -0,0 +1,109 @@
+#!/usr/bin/env sh
+
+set -euC
+
+help_text=
+
+help_text="$help_text install\t[]\t\n"
+install () {
+ perl Makefile.PL
+ make
+ make test
+ make install
+}
+
+help_text="$help_text dist\t[]\tcreate a source distribution\n"
+dist () {
+ perl Makefile.PL
+ make
+ make test
+ make dist
+}
+
+help_text="$help_text run_tests\t[arg]\tpasses arg to the 'prove' tool\n"
+run_tests () {
+ eval "prove -l ${1-} t/"
+}
+
+help_text="$help_text start_dev\t[]\tstarts a hot reloading dev server\n"
+start_dev () {
+ morbo script/jwebmail
+}
+
+help_text="$help_text logrotate\t[mode]\tarchives the current log file\n"
+logrotate () {
+ mode=${1:-development}
+ mv -i "log/$mode.log" "log/${mode}_$(date --iso-8601=minutes).log"
+}
+
+help_text="$help_text linelength\t[files]\tchecks documentation files for overly long lines\n"
+linelength () {
+ files=${1:-'README.md CHANGES.md LICENSE'}
+ for file in $files
+ do
+ fold -s -w 85 "$file" | diff "$file" -
+ done
+}
+
+help_text="$help_text follow\t[mode]\tfollows the current log file\n"
+follow () {
+ mode=${1:-development}
+ tail -f "log/$mode.log"
+}
+
+help_text="$help_text check_manifest\t[]\tchecks if files in the MANIFEST actually exist\n"
+check_manifest () {
+ perl -nE 'chomp; say if $_ && !-e' MANIFEST
+}
+
+help_text="$help_text list_deps\t[module]\tlists all non core dependencies of a module (default=JWebmail)\n"
+list_deps () {
+ module=${1:-JWebmail}
+ core="$(corelist -v v5.34.1 | awk '{ print $1 }')"
+ deps="$(perl -wE "use lib 'lib'; use Module::Load::Conditional 'requires'; @res = requires '$module'; \$\" = qq(\n); say \$res[0] ? qq(@res) : ''")"
+
+ for dep in $deps
+ do
+ if ! echo "$core" | grep -qxF "$dep"
+ then echo "$dep"
+ fi
+ done
+}
+
+help_text="$help_text list_translations\t[raw]\tlists translatable snipptes on a best effort base (incomplete!!)\n"
+list_translations () {
+ raw=${1-}
+ if [ "$raw" ]
+ then
+ find lib -name '*.pm' -exec grep '\->l(' '{}' '+'
+ find templates -name '*.html.ep' -exec grep "l[ (][\"']" '{}' '+'
+ else
+ p1="$(find lib -name '*.pm' -exec grep '\->l(' '{}' '+' | sed 's/^\(\S*\):.*->l(\([^)]*\)).*$/\1: \2/')"
+ p2="$(find templates -name '*.html.ep' -exec grep "l[ (][\"']" '{}' '+' | sed "s/^\\(\\S*\\):.*l[ (][\"']\\([^\"']*\\)[\"'].*$/\\1: '\\2'/")"
+ echo "$(echo "$p1"; echo "$p2")" | sort | uniq
+ fi
+}
+
+help_text="$help_text rust_extract\t[]\tupdates and gets the rust extract binary\n"
+rust_extract () {
+ cd extract
+ cargo build --release --target=x86_64-unknown-linux-musl
+ cp target/x86_64-unknown-linux-musl/release/jwebmail-extract ../bin
+ cd ..
+}
+
+help () {
+ echo "The following actions are available:"
+ echo
+ printf "$help_text" | expand -t 22,33
+ echo
+}
+
+if [ $# -gt 0 ]
+then cmd=$1; shift
+else cmd=help
+fi
+if [ "$(command -v "$cmd")" = "$cmd" ]
+then eval "$cmd" "$@"
+else echo "unkown commad '$cmd'"; exit 1
+fi