File: Makefile

package info (click to toggle)
fava 1.30.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,856 kB
  • sloc: javascript: 45,789; python: 11,087; makefile: 112; sh: 25
file content (134 lines) | stat: -rw-r--r-- 3,972 bytes parent folder | download
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
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: constraints.txt requirements.txt pyproject.toml
	uv venv --allow-existing
	uv pip sync requirements.txt
	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
	pre-commit run -a
	cd frontend; npm exec tsc
	cd frontend; npm exec svelte-check
	tox -e lint

# Run tests.
.PHONY: test
test: frontend/node_modules
	cd frontend; npm run test
	tox -e py

# Update the snapshot files generated by the snapshot tests.
.PHONY: update-snapshots
update-snapshots:
	find . -name "__snapshots__" -type d -prune -exec rm -r "{}" +
	-SNAPSHOT_UPDATE=1 tox -e py
	tox -e py

# Update the constraints file for Python dependencies
.PHONY: update-constraints
update-constraints:
	uv pip compile --quiet --extra excel --extra dev --python-version 3.9 --upgrade --output-file constraints.txt pyproject.toml
	uv pip compile --quiet --extra excel --extra old_deps_pins --resolution=lowest --python-version 3.9 --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:
	pre-commit autoupdate

# Update frontend deps, Python deps and pre-commit
.PHONY: update
update: update-constraints update-frontend-deps update-precommit

# Build the website
.PHONY: docs
docs:
	tox -e 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 constraints.txt
	uv run --no-sync python contrib/scripts.py generate-bql-grammar-json
	-pre-commit run prettier --files frontend/src/codemirror/bql-grammar.ts

# Build the distribution (sdist and wheel).
.PHONY: dist
dist:
	rm -rf dist/*.tar.gz
	rm -rf dist/*.whl
	python -m build
	twine check dist/*

# 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 --no-sync 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 --no-sync python contrib/scripts.py upload-translations

# Download translations from POEditor.com. (also requires POEDITOR_TOKEN)
.PHONY: translations-fetch
translations-fetch: .venv
	uv run --no-sync python contrib/scripts.py download-translations

# Create a binary using pyinstaller
dist/fava: src/fava/static/app.js
	tox -e pyinstaller