-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathJustfile
More file actions
166 lines (143 loc) · 4.47 KB
/
Justfile
File metadata and controls
166 lines (143 loc) · 4.47 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Copyright (c) Humanitarian OpenStreetMap Team
#
# This file is part of Drone-TM.
#
# Drone-TM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Drone-TM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Drone-TM. If not, see <https:#www.gnu.org/licenses/>.
#
set dotenv-load
mod build 'tasks/build'
mod start 'tasks/start'
mod config 'tasks/config'
mod test 'tasks/test'
mod process 'tasks/process'
# List available commands
[private]
default:
just help
# List available commands
help:
just --justfile {{justfile()}} --list
# Prep module from https://github.com/hotosm/justfiles
prep *args:
@curl -sS https://raw.githubusercontent.com/hotosm/justfiles/main/prep.just \
-o {{justfile_directory()}}/tasks/prep.just;
@just --justfile {{justfile_directory()}}/tasks/prep.just {{args}}
# Chart module from https://github.com/hotosm/justfiles
chart *args:
@curl -sS https://raw.githubusercontent.com/hotosm/justfiles/main/chart.just \
-o {{justfile_directory()}}/tasks/chart.just;
@just --justfile {{justfile_directory()}}/tasks/chart.just --set chart_name "drone-tm" {{args}}
# Run database migrations
migrate:
docker compose run --rm migrations alembic upgrade head
# Run pre-commit hooks
lint:
#!/usr/bin/env sh
cd {{justfile_directory()}}/src/backend
uv run pre-commit run --all-files
# Increment Drone-TM
bump:
#!/usr/bin/env sh
cd {{justfile_directory()}}/src/backend
uv run cz bump --check-consistency
# Increment drone-flightplan (doesn't work yet!)
bump-drone-flightplan:
#!/usr/bin/env sh
cd {{justfile_directory()}}/src/backend
uv --project packages/drone-flightplan --directory packages/drone-flightplan run cz bump --check-consistency
# Run docs website locally
docs:
#!/usr/bin/env sh
cd {{justfile_directory()}}/src/backend
uv sync --group docs
uv run mkdocs serve --config-file ../../mkdocs.yml --dev-addr 0.0.0.0:3000
# Install curl if missing
[private]
_install-curl:
#!/usr/bin/env bash
set -e
if ! command -v curl &> /dev/null; then
echo "📦 Installing curl..."
if command -v apt-get &> /dev/null; then
sudo apt-get update -qq && sudo apt-get install -y curl
elif command -v yum &> /dev/null; then
sudo yum install -y curl
elif command -v apk &> /dev/null; then
sudo apk add --no-cache curl
else
echo "❌ Error: curl is not installed and no package manager found"
echo " Please install curl manually"
exit 1
fi
echo "✓ curl installed"
fi
# Arrow-key selection menu. Draws on stderr, prints chosen item to stdout.
# Usage: chosen=$(just _select-menu "Pick one:" item1 item2 item3)
[no-cd]
_select-menu prompt +items:
#!/usr/bin/env bash
set -e
IFS=' ' read -ra opts <<< "{{ items }}"
count=${#opts[@]}
selected=0
# Print prompt
printf "\033[0;34m%s\033[0m\n" "{{ prompt }}" >&2
# Hide cursor, restore on exit
tput civis >&2 2>/dev/null
trap 'tput cnorm >&2 2>/dev/null' EXIT
draw_menu() {
for i in "${!opts[@]}"; do
tput el >&2 2>/dev/null
if [ "$i" -eq "$selected" ]; then
printf " \033[7m > %s \033[0m\n" "${opts[$i]}" >&2
else
printf " %s\n" "${opts[$i]}" >&2
fi
done
}
draw_menu
while true; do
read -rsn1 key
case "$key" in
$'\x1b')
read -rsn2 rest
case "$rest" in
'[A') ((selected > 0)) && ((selected--)) || true ;;
'[B') ((selected < count - 1)) && ((selected++)) || true ;;
esac
;;
'') # enter
break
;;
esac
printf "\033[%dA" "$count" >&2
draw_menu
done
printf "\n" >&2
echo "${opts[$selected]}"
# Echo to terminal with blue colour
[no-cd]
_echo-blue text:
#!/usr/bin/env sh
printf "\033[0;34m%s\033[0m\n" "{{ text }}"
# Echo to terminal with yellow colour
[no-cd]
_echo-yellow text:
#!/usr/bin/env sh
printf "\033[0;33m%s\033[0m\n" "{{ text }}"
# Echo to terminal with red colour
[no-cd]
_echo-red text:
#!/usr/bin/env sh
printf "\033[0;41m%s\033[0m\n" "{{ text }}"