-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·101 lines (86 loc) · 2.97 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
set -euo pipefail
#set -x
self_path=$(realpath "$0")
repository=github.com/husio/lith
version=$(git rev-parse --short HEAD)
function task:build-lith {
# Build the lith application binary.
mkdir -p bin
CGO_ENABLED=1 go build -ldflags="-X 'main.sourceHash=${version}'" -o "bin/lith" "$repository/cmd/lith"
}
function task:build-translations-collect {
# Build the translations collector application binary.
mkdir -p bin
CGO_ENABLED=0 go build -ldflags="-X 'main.sourceHash=${version}'" -o "bin/translations-collect" "$repository/cmd/translations-collect"
}
function task:vendor {
# Ensure all application dependencies are vendored.
go mod tidy
go mod vendor
go mod verify
}
function task:docker-image {
# Build docker image for the lith application.
docker build -t "lith:${version}" -t "lith:latest" .
}
function task:test {
# Run all tests.
go test -race -test.timeout 4m "$repository/..."
}
function task:translations-collect {
# Collect all translation files.
bin/translations-collect -dir app/lith -o app/lith/po/en.pot
find app/lith/po/ -name '*.po' -exec msgmerge --no-wrap --add-location --sort-output --update {} app/lith/po/en.pot \;
}
function task:translations-edit {
# Edit translation files.
poedit .
}
function task:run-lith {
# In order to run with live reload, install cespare/reflex from https://github.com/cespare/reflex
reflex -s -- sh -c "go run \"$repository/cmd/lith\" -conf examples/lith.conf serve"
}
function task:run-monitor-queue {
# Run a task queue monitoring tool.
printf "Running Task Queue Info server on http://localhost:8085\n"
go run github.com/husio/lith/cmd/lith -conf examples/lith.conf taskqueueinfo
}
function task:run-test-mailserver {
# Run a mailhog test mail server.
printf "\n"
printf "\n"
printf "Running UI on http://localhost:8025\n"
printf "Running SMTP server on localhost:11025\n"
printf "\n"
printf "\n"
docker run -p 11025:1025 -p 8025:8025 mailhog/mailhog
}
function task:run-demo {
# Run a complete demo setup of the application.
task:build-lith
bin/lith -conf examples/lith.conf useradd -email [email protected] -password "admin" -groups=1,2 -allow-insecure 2>/dev/null || true
printf "\n"
printf "\n"
printf "Running public UI on http://localhost:8000/login/\n"
printf "Running admin panel on http://localhost:8001\n"
printf "Emails are written to /tmp/lith_outgoing_emails/\n"
printf "\n"
printf "Admin credentials are\n"
printf " email: [email protected]\n"
printf " password: admin\n"
printf "\n"
printf "\n"
printf "Press Ctrl+c to stop the application.\n"
bin/lith -conf examples/lith.conf serve
}
function task:help {
# Print this script help.
printf "%s <task> [args]\n\nTasks:\n" "${0}\n"
tasks=$(compgen -A function | sed -En 's/task:(.*)/\1/p')
for task in ${tasks}; do
desc=$(grep "function task:$task" "$self_path" -A 1 | sed -En 's/.*# (.*)/\1/p')
printf " %-26s\t%s\n" "$task" "$desc"
done
}
"task:${@:-help}"