-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathMakefile
More file actions
219 lines (167 loc) · 6.82 KB
/
Makefile
File metadata and controls
219 lines (167 loc) · 6.82 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
217
218
219
# Needed because we have folders called "docs" and "test" that confuse `make`.
.PHONY: docs test py-venv-check clean deploy
# Setup commands
# ===============================================
# Install the repository from scratch.
# This command does NOT install data dependencies.
install:
./scripts/install_from_scratch.sh
# Install frontend dependencies and build CSS and JS assets.
install-frontend:
npm install
make css-prod js-prod
# Install Python dependencies.
install-python:
uv sync
# Fetch and build all i18n files.
install-i18n:
uv run python -m ambuda.scripts.fetch_i18n_files
# Force a build with `-f`. Transifex files have a `fuzzy` annotation, so if
# we build without this flag, then all of the files will be skipped with:
#
# "catalog <file>.po" is marked as fuzzy, skipping"
#
# There's probably a nicer workaround for this, but `-f` works and unblocks
# this command for now.
uv run pybabel compile -d ambuda/translations -f
# Upgrade an existing setup.
upgrade:
make install-frontend install-python
uv run make install-i18n
uv run alembic upgrade head
uv run python -m ambuda.seed.lookup
# Seed the database with a minimal dataset for CI. We fetch data only if it is
# hosted on GitHub. Other resources are less predictable.
db-seed-ci:
uv run python -m ambuda.seed.lookup
uv run python -m ambuda.seed.texts.gretil
uv run python -m ambuda.seed.dcs
# Seed the database with just enough data for the devserver to be interesting.
db-seed-basic:
uv run python -m ambuda.seed.lookup
uv run python -m ambuda.seed.texts.gretil
uv run python -m ambuda.seed.dcs
uv run python -m ambuda.seed.dictionaries.monier
# Seed the database with all of the text, parse, and dictionary data we serve
# in production.
db-seed-all:
uv run python -m ambuda.seed.lookup.role
uv run python -m ambuda.seed.lookup.page_status
uv run python -m ambuda.seed.texts.gretil
uv run python -m ambuda.seed.texts.ramayana
uv run python -m ambuda.seed.texts.mahabharata
uv run python -m ambuda.seed.dcs
uv run python -m ambuda.seed.dictionaries.amarakosha
uv run python -m ambuda.seed.dictionaries.apte
uv run python -m ambuda.seed.dictionaries.apte_sanskrit_hindi
uv run python -m ambuda.seed.dictionaries.monier
uv run python -m ambuda.seed.dictionaries.shabdakalpadruma
uv run python -m ambuda.seed.dictionaries.shabdartha_kaustubha
uv run python -m ambuda.seed.dictionaries.shabdasagara
uv run python -m ambuda.seed.dictionaries.vacaspatyam
# Local run commands
# ===============================================
.PHONY: devserver celery
# For Docker try `make mode=dev docker-start`
devserver:
./node_modules/.bin/concurrently "uv run flask run -h 0.0.0.0 -p 5000" "npx tailwindcss -i ambuda/static/css/style.css -o ambuda/static/gen/style.css --watch" "npx esbuild ambuda/static/js/main.js ambuda/static/js/proofing.js --outdir=ambuda/static/gen --bundle --watch"
# Run a local Celery instance for background tasks.
celery:
uv run celery -A ambuda.tasks worker --loglevel=INFO
deploy:
uv run fab deploy
# Docker commands
# ===============================================
# Start all development services (web, celery, redis) with hot-reloading
ambuda-dev:
@echo "🚀 Starting Ambuda development environment in Docker..."
@echo " This will start: web server, Celery workers, and Redis"
@mkdir -p data/database data/file-uploads data/vidyut
@touch .env.docker.local
docker compose -f docker-compose.dev.yml up
# Build the Docker image. You can also run this if you encounter any build issues.
ambuda-dev-build:
docker compose -f docker-compose.dev.yml build
# Start a shell inside the docker image. (Useful for CLI commands.)
ambuda-dev-shell:
docker compose -f docker-compose.dev.yml exec web /bin/bash
# Run database migrations in Docker
ambuda-dev-migrate:
docker compose -f docker-compose.dev.yml exec web uv run alembic upgrade head
# Seed the database with basic data
ambuda-dev-seed-basic:
docker compose -f docker-compose.dev.yml exec web uv run python -m ambuda.seed.lookup
docker compose -f docker-compose.dev.yml exec web uv run python -m ambuda.seed.texts.gretil
docker compose -f docker-compose.dev.yml exec web uv run python -m ambuda.seed.dcs
docker compose -f docker-compose.dev.yml exec web uv run python -m ambuda.seed.dictionaries.monier
# Lint commands
# ===============================================
# Link checks on Python code
py-lint:
uv run ruff format .
# Lint our Python and JavaScript code. Fail on any issues.
lint-check: js-lint
uv run ruff format . --check
# Test, coverage and documentation commands
# ===============================================
# Run all Python unit tests.
test:
uv run pytest .
# Run all Python unit tests with a coverage report.
# After the command completes, open "htmlcov/index.html".
coverage:
uv run pytest --cov=ambuda --cov-report=html test/
coverage-report: coverage
coverage report --fail-under=80
# Generate Ambuda's technical documentation.
# After the command completes, open "docs/_build/index.html".
docs:
cd docs && make html
# CSS commands
# ===============================================
# Run Tailwind to build our CSS, and rebuild our CSS every time a relevant file
# changes.
css-dev:
npx tailwindcss -i ./ambuda/static/css/style.css -o ./ambuda/static/gen/style.css --watch
# Build CSS for production.
css-prod:
npx tailwindcss -i ./ambuda/static/css/style.css -o ./ambuda/static/gen/style.css --minify
# JavaScript commands
# ===============================================
# Run esbuild to build our JavaScript, and rebuild our JavaScript every time a
# relevant file changes.
js-dev:
npx esbuild ambuda/static/js/main.js ambuda/static/js/proofing.js --outdir=ambuda/static/gen --bundle --watch
# Build JS for production.
js-prod:
npx esbuild ambuda/static/js/main.js ambuda/static/js/proofing.js --outdir=ambuda/static/gen --bundle --minify
js-test:
npx jest
js-coverage:
npx jest --coverage
# Lint our JavaScript code.
js-lint:
npx eslint --fix ambuda/static/js/* --ext .js,.ts
# Check our JavaScript code for type consistency.
js-check-types:
npx tsc ambuda/static/js/*.ts -noEmit
# i18n and l10n commands
# ===============================================
# Extract all translatable text from the application and save it in `messages.pot`.
babel-extract:
uv run pybabel extract --mapping babel.cfg --keywords _l --output-file messages.pot .
# Create a new translation file from `messages.pot`.
babel-init:
uv run pybabel init -i messages.pot -d ambuda/translations --locale $(locale)
# Update all translation files with new text from `messages.pot`
babel-update:
uv run pybabel update -i messages.pot -d ambuda/translations
# Compile all translation files.
# NOTE: you probably want `make install-i18n` instead.
babel-compile:
uv run pybabel compile -d ambuda/translations
# Clean up
# ===============================================
clean:
@rm -rf data/
@rm -rf ambuda/translations/*