-
-
Notifications
You must be signed in to change notification settings - Fork 227
/
Makefile
137 lines (113 loc) · 4.36 KB
/
Makefile
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
.DEFAULT_GOAL := help
.PHONY: install
install: ## Install the dependencies
python3 -m pip install --upgrade pip
python3 -m pip install -e .
.PHONY: develop
develop: ## Install the test and dev dependencies
python3 -m pip install -e .[test,dev,sync]
playwright install
.PHONY: format
format: ## Format the code and templates files
-djlint umap/templates --reformat
-isort --profile black umap/
-ruff format --target-version=py310 umap/
.PHONY: lint
lint: ## Lint the code and template files
npx eslint umap/static/umap/js/
djlint umap/templates --lint
isort --check --profile black umap/
ruff format --check --target-version=py310 umap/
vermin --no-tips --violations -t=3.10- umap/
docs: ## Compile the docs
mkdocs build
.PHONY: version
version: ## Display the current version
@hatch version
.PHONY: patch
patch: ## Bump the current version to a new patch one
@hatch version fix
.PHONY: minor
minor: ## Bump the current version to a new minor one
@hatch version minor
.PHONY: docker
docker: ## Create a new Docker image and publish it
$(eval VERSION=$(shell hatch version))
@echo "Version to build: ${VERSION}"
docker build -t umap/umap:${VERSION} .
docker push umap/umap:${VERSION}
.PHONY: build
build: ## Build the Python package before release
@hatch build --clean
.PHONY: publish
publish: ## Publish the Python package to Pypi
@hatch publish
make clean
test: testpy testjs
testpy:
pytest -vv umap/tests/ --dist=loadgroup --reruns 1
test-integration:
pytest -xv umap/tests/integration/ --dist=loadgroup
clean:
rm -f dist/*
rm -rf build/*
compilemessages:
umap compilemessages
umap generate_js_locale
messages:
cd umap && umap makemessages -l en
node node_modules/leaflet-i18n/bin/i18n.js --dir_path=umap/static/umap/js/ --dir_path=umap/static/umap/vendors/measurable/ --locale_dir_path=umap/static/umap/locale/ --locale_codes=en --mode=json --clean --default_values --expressions=_,translate
vendors:
npm run vendors
installjs:
npm install
testjs: node_modules
node_modules/mocha/bin/mocha.js umap/static/umap/unittests/
tx_push:
tx push -s
tx_pull:
tx pull
changelog:
$(eval VERSION=$(shell hatch version))
@# Bearer token is readonly
@printf $(shell curl -sL -X POST -H "Authorization: Bearer ${GITHUB_TOKEN}" https://api.github.com/repos/umap-project/umap/releases/generate-notes -d '{"target_commitish":"master","previous_tag_name":"", "tag_name": "${VERSION}"}' | jq .body | sed 's/https:\/\/github.com\/umap-project\/umap\/pull\//#/g')
jsdir = umap/static/umap/js/
filepath = "${jsdir}*.js"
.PHONY: pretty
pretty: ## Apply Biome to all JS files (or specified `jsdir`)
./node_modules/@biomejs/biome/bin/biome check --write ${jsdir}
.PHONY: lebab
lebab: ## Convert JS `filepath` to modern syntax with Lebab, then prettify
./node_modules/lebab/bin/index.js --replace ${filepath} --transform arrow,arrow-return
./node_modules/lebab/bin/index.js --replace ${filepath} --transform let
./node_modules/lebab/bin/index.js --replace ${filepath} --transform template
$(MAKE) pretty filepath=${filepath}
.PHONY: lebab-all
lebab-all: $(jsdir)* ## Convert all JS files to modern syntax with Lebab + prettify
for file in $^ ; do $(MAKE) lebab filepath=$${file}; done
icons:
scour -i umap/static/umap/img/source/24.svg -o umap/static/umap/img/24.svg --strip-xml-prolog --enable-comment-stripping
scour -i umap/static/umap/img/source/24-white.svg -o umap/static/umap/img/24-white.svg --strip-xml-prolog --enable-comment-stripping
scour -i umap/static/umap/img/source/16.svg -o umap/static/umap/img/16.svg --strip-xml-prolog --enable-comment-stripping
scour -i umap/static/umap/img/source/16-white.svg -o umap/static/umap/img/16-white.svg --strip-xml-prolog --enable-comment-stripping
.PHONY: help
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
# See https://daniel.feldroy.com/posts/autodocumenting-makefiles
define PRINT_HELP_PYSCRIPT # start of Python section
import re, sys
output = []
# Loop through the lines in this file
for line in sys.stdin:
# if the line has a command and a comment start with
# two pound signs, add it to the output
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
output.append("\033[36m%-20s\033[0m %s" % (target, help))
# Sort the output in alphanumeric order
output.sort()
# Print the help result
print('\n'.join(output))
endef
export PRINT_HELP_PYSCRIPT # End of python section