-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (111 loc) · 4.71 KB
/
Makefile
File metadata and controls
131 lines (111 loc) · 4.71 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
MAIN=cli
APP=things-cli
SRC_CORE=things_cli
SRC_TEST=tests
PYTHON=python3
PYDOC=pydoc3
PIP=pip3
PIPENV=pipenv
DATE:=$(shell date +"%Y-%m-%d")
VERSION=$(shell $(PYTHON) -c 'import things_cli; print(things_cli.__version__)')
SHELL := /usr/bin/env bash -euo pipefail -c
help: ## Print help for each target
$(info Things low-level Python CLI.)
$(info ============================)
$(info )
$(info Available commands:)
$(info )
@grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'
run: ## Run the code
@$(PYTHON) -m $(SRC_CORE).$(MAIN)
install: ## Install the code
@$(PYTHON) setup.py install
uninstall: ## Uninstall the code
@$(PIP) uninstall -y things-cli
test: ## Test the code
@type coverage >/dev/null 2>&1 || (echo "Run '$(PIP) install coverage' first." >&2 ; exit 1)
@coverage erase
@coverage run -a -m $(SRC_TEST).test_things_cli
@coverage report
@coverage html
.PHONY: doc
doc: ## Document the code
@$(PYDOC) $(SRC_CORE).cli
.PHONY: clean
clean: ## Cleanup
@rm -f $(DEST)
@find . -name \*.pyc -delete
@find . -name __pycache__ -delete
@rm -rf htmlcov
@rm -rf build dist *.egg-info .eggs
@rm -rf $(SRC_CORE)/.mypy_cache $(SRC_TEST)/.mypy_cache .mypy_cache
@rm -f .coverage
auto-style: ## Style the code
@echo "isort..."
@if type isort >/dev/null 2>&1 ; then isort . ; \
else echo "SKIPPED. Run '$(PIP) install isort' first." >&2 ; fi
@echo "autoflake..."
@if type autoflake >/dev/null 2>&1 ; then autoflake -r --in-place --remove-unused-variables . ; \
else echo "SKIPPED. Run '$(PIP) install isort' first." >&2 ; fi
@echo "black..."
@if type black >/dev/null 2>&1 ; then black $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install black' first." >&2 ; fi
code-style: ## Test the code style
@echo Pycodestyle...
@if type pycodestyle >/dev/null 2>&1 ; then pycodestyle $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install pycodestyle' first." >&2 ; fi
@echo Pydocstyle...
@if type pydocstyle >/dev/null 2>&1 ; then pydocstyle $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install pydocstyle' first." >&2 ; fi
code-count: ## Count the code
@if type cloc >/dev/null 2>&1 ; then cloc $(SRC_CORE) ; \
else echo "SKIPPED. Run 'brew install cloc' first." >&2 ; fi
code-lint: ## Lint the code
@echo Ruff...
@if type ruff >/dev/null 2>&1 ; then ruff $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install ruff' first." >&2 ; fi
@echo Pylama...
@if type pylama >/dev/null 2>&1 ; then pylama $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install pylama' first." >&2 ; fi
@echo Pylint...
@if type pylint >/dev/null 2>&1 ; then pylint -sn $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install pylint' first." >&2 ; fi
@echo Flake...
@if type flake8 >/dev/null 2>&1 ; then flake8 $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install flake8' first." >&2 ; fi
@echo Pyright...
@if type pyright >/dev/null 2>&1 ; then PYRIGHT_PYTHON_FORCE_VERSION=latest pyright $(SRC_CORE) ; \
else echo "SKIPPED. Run 'npm install -f pyright' first." >&2 ; fi
@echo MyPy...
@if type mypy >/dev/null 2>&1 ; then mypy --ignore-missing-imports $(SRC_CORE) ; \
else echo "SKIPPED. Run '$(PIP) install mypy' first." >&2 ; fi
lint: code-style code-lint ## Lint everything
deps-install: ## Install the dependencies
@#type $(PIPENV) >/dev/null 2>&1 || (echo "Run '$(PIP) install pipenv' first." >&2 ; exit 1)
@#$(PIPENV) install
@$(PIP) install -r requirements.txt
feedback: ## Give feedback
@open https://github.com/thingsapi/things-cli/issues
release: build ## Create a new release
@type gh >/dev/null 2>&1 || (echo "Run e.g. 'brew install gh' first." >&2 ; exit 1)
@echo "Checking for not committed changes..."
@git diff --exit-code && git diff --cached --exit-code
@echo "########################"
@echo Making release for version "$(VERSION)". Press ENTER to continue...
@echo "########################"
@read
@gh release create "v$(VERSION)" -t "Release $(VERSION) ($(DATE))" 'dist/$(APP)-$(VERSION).tar.gz'
build: clean ## Build the code
@$(PYTHON) setup.py sdist bdist_wheel
upload: build ## Upload the code
@type twine >/dev/null 2>&1 || (echo "Run e.g. 'pip install twine' first." >&2 ; exit 1)
@echo "########################"
@echo "Using ~/.pypirc or environment variables TWINE_USERNAME and TWINE_PASSWORD"
@echo "See: https://packaging.python.org/specifications/pypirc/#using-a-pypi-token"
@echo "########################"
@twine upload dist/$(APP)*
db-to-things:
@cp tests/main.sqlite* ~/Library/Group\ Containers/JLMPQHK86H.com.culturedcode.ThingsMac/ThingsData-*/Things\ Database.thingsdatabase/
db-from-things:
@cp ~/Library/Group\ Containers/JLMPQHK86H.com.culturedcode.ThingsMac/ThingsData-*/Things\ Database.thingsdatabase/main.sqlite* tests