-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathdevsetup.sh
More file actions
executable file
·216 lines (171 loc) · 5.91 KB
/
Copy pathdevsetup.sh
File metadata and controls
executable file
·216 lines (171 loc) · 5.91 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
set -e
# macOS's System Integrity Protection purges the environment variables controlling
# `dyld` when launching protected processes (https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html#//apple_ref/doc/uid/TP40016462-CH3-SW1)
# This causes macOS to remove the DYLD_ env variables when running this script, so we have to set them again
if [ ! -z "${FRAGDENSTAAT_DYLD_LIBRARY_PATH:-}" ]; then
export LD_LIBRARY_PATH=${FRAGDENSTAAT_DYLD_LIBRARY_PATH:-}:${LD_LIBRARY_PATH:-}
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:${DYLD_LIBRARY_PATH:-}
fi
MAIN=fragdenstaat_de
REPOS=("froide" "froide-campaign" "froide-legalaction" "froide-food" "froide-payment" "froide-crowdfunding" "froide-govplan" "froide-fax" "froide-exam" "django-filingcabinet" "froide-evidencecollection" "froide-pressconference" "froide-election")
FRONTEND=("froide" "froide_food" "froide_exam" "froide_campaign" "froide_payment" "froide_legalaction" "@okfde/filingcabinet" "froide_pressconference")
FRONTEND_DIR=("froide" "froide-food" "froide-exam" "froide-campaign" "froide-payment" "froide-legalaction" "django-filingcabinet" "froide-pressconference")
FROIDE_PEERS=("froide-campaign" "froide-food") # these have peer-dependencies on froide
ALL=("$MAIN" "${REPOS[@]}")
export UV_PYTHON="3.13"
if [[ $(basename "$PWD") == "$MAIN" ]]; then
# make sure we're starting from the main project's parent dir,
# even when executed from main project
cd ..
fi
check_versions() {
if ! command -v uv > /dev/null 2>&1 || ! command -v pnpm > /dev/null 2>&1 ; then
echo "You need python, uv and pnpm 9 installed."
exit 1
fi
if [[ "$(pnpm --version)" != 9.* ]]; then
echo "You need to have pnpm v9 installed, but are using $(pnpm --version)."
exit 1
fi
}
pull() {
echo "Cloning / installing $MAIN"
if [ ! -d $MAIN ]; then
git clone [email protected]:okfde/$MAIN.git
else
pushd $MAIN
git pull origin --autostash "$(git branch --show-current)"
popd
fi
for name in "${REPOS[@]}"; do
if [ ! -d $name ]; then
git clone [email protected]:okfde/$name.git
else
pushd $name
git pull origin --autostash "$(git branch --show-current)"
popd
fi
done
}
dependencies() {
echo "Creating virtual environments and installing dependencies..."
if ! command -v prek > /dev/null 2>&1; then
echo "prek is not installed. Run \`uv tool install prek\` to fix this. Make sure \`$(uv tool dir)\` is in your \$PATH. If it is not, run \`uv tool update-shell\`."
exit 1
fi
for name in "${ALL[@]}"; do
pushd "$name"
uv sync --all-extras
source .venv/bin/activate
if [[ $name == "froide" ]]; then
uv pip install -e ../django-filingcabinet --no-deps
fi
if [[ $name == "$MAIN" ]]; then
for project in "${REPOS[@]}"; do
uv pip install -e "../$project" --config-setting editable_mode=compat --no-deps
done
fi
if [ -e ".pre-commit-config.yaml" ]; then
prek install
fi
deactivate
popd
done
}
upgrade_backend_repos() {
pushd $MAIN
uv sync ${REPOS[@]/#/--upgrade-package }
popd
}
frontend() {
pnpm_version=$(pnpm --version)
if [[ $pnpm_version != 9.15* ]]; then
echo "You need to have pnpm@^9.15 installed"
exit 1
fi
echo "Installing frontend dependencies..."
# we need to link globally since local linking adjusts the lockfile
# Install and link all frontend packages
for name in "${FRONTEND_DIR[@]}"; do
pushd "$name"
pnpm link --global
pnpm install
popd
done
# Link froide peer dependencies
for name in "${FROIDE_PEERS[@]}"; do
pushd "$name"
pnpm link --global "froide"
popd
done
# Setup main project and link dependencies
pushd "$MAIN"
pnpm install
for name in "${FRONTEND[@]}"; do
pnpm link --global "$name"
done
popd
}
upgrade_frontend_repos() {
pushd "$MAIN"
pnpm update "${FRONTEND[@]}"
popd
}
messages() {
source $MAIN/.venv/bin/activate
python $MAIN/manage.py compilemessages -l de -i node_modules
}
load_dump() {
pushd "$MAIN"
# special command to restore a light fragdenstaat dump for staff
docker compose -f compose-dev.yaml up -d db
docker compose -f compose-dev.yaml exec db dropdb -U fragdenstaat_de fragdenstaat_de
docker compose -f compose-dev.yaml exec db dropdb -U fragdenstaat_de froide || true
docker compose -f compose-dev.yaml exec db createdb -U fragdenstaat_de -O fragdenstaat_de fragdenstaat_de
curl http://10.9.0.201:9000/fragdenstaat_de_light.sql.gz --output - | gunzip | (docker compose -f compose-dev.yaml exec -T db psql -U fragdenstaat_de > /dev/null)
psql() {
docker compose -f compose-dev.yaml exec db psql -U fragdenstaat_de "$@"
}
# set sites to localhost
psql -c "UPDATE django_site SET domain = 'localhost:8000' WHERE domain = 'fragdenstaat.de';"
psql -c "UPDATE django_site SET domain = 'localhost:8001' WHERE domain = 'gegenrechtsschutz.de';"
psql -c "UPDATE django_site SET domain = 'localhost:8002' WHERE domain = 'ueberbrueckungsfonds.de';"
# create another database for froide testing
psql -c "CREATE USER froide WITH SUPERUSER PASSWORD 'froide';" || true
psql -c "CREATE DATABASE froide OWNER froide;"
echo "Restored database successfully! You might have to apply migrations."
read -p "Please enter your email address to set the account password (or press Ctrl+C to abort):" email
source .venv/bin/activate
python manage.py changepassword "$email"
deactivate
popd
}
forall() {
echo "Executing '$@' in all repos"
for name in "${ALL[@]}"; do
pushd $name
"$@"
popd
done
}
help() {
echo "Available commands:"
echo "setup: setup / update all repos"
echo "forall: run command in all repos"
}
if [ -z "$1" ]; then
check_versions
pull
dependencies
frontend
messages
echo "Done!"
else
if [[ $(type -t "$1") == function ]]; then
"$@"
else
help
exit 1
fi
fi