-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.sh
More file actions
executable file
·62 lines (57 loc) · 1.61 KB
/
Copy pathdocs.sh
File metadata and controls
executable file
·62 lines (57 loc) · 1.61 KB
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
#!/usr/bin/env bash
set -euo pipefail
log_error() { echo -e "\033[0m\033[1;91m${*}\033[0m"; }
log_info() { echo -e "\033[0m\033[1;94m${*}\033[0m"; }
function browse() {
declare docs_url="http://localhost:8080/workspace/diagrams#starterstack"
log_info "will open browser at ${docs_url:?} when docs are available"
while true; do
if curl --fail \
"${docs_url:?}" &>/dev/null; then
break
fi
sleep 2
done
if command -v xdg-open &>/dev/null; then
xdg-open "${docs_url:?}"
elif command -v explorer &>/dev/null; then
explorer "${docs_url:?}"
else
open "${docs_url:?}"
fi
}
function docs() {
declare -r structurizr_version="2024.01.02"
declare -r structurizr=".structurizr-${structurizr_version:?}.war"
if command -v java &>/dev/null; then
if [[ ! -f "${structurizr:?}" ]]; then
log_info "downloading structurizr ${structurizr_version:?}"
curl \
--fail \
-L \
-o "/tmp/${structurizr:?}" \
https://github.com/structurizr/lite/releases/download/${structurizr_version:?}/structurizr-lite.war
mv /tmp/"${structurizr:?}" "${structurizr:?}"
fi
browse &
java \
-Djdk.util.jar.enableMultiRelease=false \
-Dserver.port=8080 \
-jar "${structurizr:?}" \
docs/structurizr
else
if ! docker stats --no-stream &>/dev/null; then
log_error "You need docker or java to run structurizr"
exit 1
fi
browse &
docker \
run \
-it \
--rm \
-p 8080:8080 \
-v "$(pwd)"/docs/structurizr:/usr/local/structurizr \
structurizr/lite:${structurizr_version:?}
fi
}
docs