Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (122 loc) · 4.4 KB
/
Copy pathMakefile
File metadata and controls
146 lines (122 loc) · 4.4 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
FRONTEND_SOURCES := $(shell find frontend/src frontend/css -type f)
all: src/fava/static/app.js
# Compile the frontend.
src/fava/static/app.js: $(FRONTEND_SOURCES) frontend/build.ts frontend/node_modules
cd frontend; npm run build
# Install the frontend node_modules dependencies.
frontend/node_modules: frontend/package-lock.json
cd frontend; npm install --no-progress
touch -m frontend/node_modules
# Create and sync a dev environment.
.PHONY: dev
dev: .venv
.venv: uv.lock pyproject.toml
uv sync
uv run pre-commit install
touch -m .venv
# Remove the generated frontend and translations in addition to mostlyclean (see below).
.PHONY: clean
clean: mostlyclean
find src/fava/static ! -name 'favicon.ico' -type f -exec rm -f {} +
find src/fava/translations -name '*.mo' -delete
# Remove node_modules, caches, .tox, etc.
.PHONY: mostlyclean
mostlyclean:
rm -rf .*cache
rm -rf .eggs
rm -rf .tox
rm -rf .venv
rm -rf build
rm -rf dist
rm -rf htmlcov
rm -rf frontend/node_modules
find . -type f -name '*.py[c0]' -delete
find . -type d -name "__pycache__" -delete
# Run linters.
.PHONY: lint
lint: frontend/node_modules mypy
uv run pre-commit run -a
cd frontend; npm exec tsc
cd frontend; npm exec svelte-check
# Run mypy for Python type-checking.
.PHONY: mypy
mypy:
uv run --no-dev --group mypy mypy
# Run tests.
.PHONY: test test-js test-py test-py-old-deps
test: test-js test-py
test-js: frontend/node_modules
cd frontend; npm run test
test-py:
uv run --no-dev --group test pytest --cov=fava --cov-report=term-missing:skip-covered --cov-report=html --cov-fail-under=100
test-py-old-deps:
uv run --no-project --isolated --with-editable=. --with-requirements=constraints-old.txt pytest --snapshot-ignore
# Update the snapshot files generated by the snapshot tests.
.PHONY: update-snapshots
update-snapshots:
uv run pytest --snapshot-update --snapshot-clean
uv run pytest
# Update the constraints file for Python dependencies
.PHONY: update-constraints
update-constraints:
uv lock --upgrade
uv pip compile --quiet --extra excel --group old-deps --resolution=lowest --python-version 3.10 --upgrade --output-file constraints-old.txt pyproject.toml
# Update the frontend dependencies.
.PHONY: update-frontend-deps
update-frontend-deps:
-cd frontend; npm outdated
cd frontend; npm update
cd frontend; npm run sync-pre-commit
touch -m frontend/node_modules
# Update pre-commit hooks
.PHONY: update-precommit
update-precommit:
uv run pre-commit autoupdate
# Update github actions action versions.
.PHONY: update-github-actions
update-github-actions:
cd frontend; npm run sync-github-actions
# Update frontend deps, Python deps and pre-commit
.PHONY: update
update: update-constraints update-frontend-deps update-precommit update-github-actions
# Build the website
.PHONY: docs
docs:
uv run --no-dev --group docs docs/generate.py
uv run --no-dev --group docs sphinx-build -b html docs build/docs
# Run fava for the example files.
.PHONY: run-example
run-example:
@xdg-open http://localhost:3333
BEANCOUNT_FILE= fava -p 3333 --debug tests/data/*.beancount
# Generate the bql-grammar json file used by the frontend.
.PHONY: bql-grammar
bql-grammar: .venv contrib/scripts.py
uv run --group scripts contrib/scripts.py generate-bql-grammar-json
-uv run pre-commit run prettier --files frontend/src/codemirror/bql-grammar.ts
# Build the distribution (sdist and wheel).
.PHONY: dist
dist:
rm -f dist/*{.tar.gz,.whl}
uv build
# Build the bql-grammar and update translations with POEditor.com
.PHONY: before-release
before-release: bql-grammar translations-push translations-fetch
# Extract translation strings.
.PHONY: translations-extract
translations-extract: .venv
uv run pybabel extract -F src/fava/translations/babel.conf -o src/fava/translations/messages.pot .
# Extract translation strings and upload them to POEditor.com.
# Requires the environment variable POEDITOR_TOKEN to be set to an API token
# for POEditor.
.PHONY: translations-push
translations-push: .venv translations-extract
uv run --group scripts contrib/scripts.py upload-translations
# Download translations from POEditor.com. (also requires POEDITOR_TOKEN)
.PHONY: translations-fetch
translations-fetch: .venv
uv run --group scripts contrib/scripts.py download-translations
# Create a binary using pyinstaller
dist/fava: src/fava/static/app.js
uv run --no-project --isolated --with=. --with=pyinstaller pyinstaller --clean --noconfirm contrib/pyinstaller_spec.spec
dist/fava --version