2019-12-07 21:37:30 +11:00
|
|
|
#
|
|
|
|
# Makefile that handles all the static file compilation and
|
|
|
|
# adds some helper tools for daily development.
|
|
|
|
#
|
|
|
|
|
|
|
|
SHELL=/bin/bash -eu -o pipefail
|
|
|
|
|
|
|
|
define N # newline
|
|
|
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test: ## Run Django tests
|
2019-12-23 17:54:21 +11:00
|
|
|
rm -f .coverage
|
|
|
|
docker-compose run --rm app monkeytype run /usr/local/bin/pytest dpaste/
|
2019-12-07 21:37:30 +11:00
|
|
|
|
|
|
|
.PHONY: code-cleanup
|
|
|
|
code-cleanup: ## Black and isort the Python codebase
|
2019-12-08 22:47:39 +11:00
|
|
|
autoflake --remove-all-unused-imports --ignore-init-module-imports --remove-unused-variables \
|
2019-12-09 05:44:07 +11:00
|
|
|
--in-place --exclude "**/migrations/*,dpaste/settings/local.py" -r dpaste
|
2019-12-07 21:37:30 +11:00
|
|
|
isort -rc dpaste
|
|
|
|
black --line-length=80 --exclude='/(migrations)/' dpaste
|
|
|
|
|
2019-12-08 22:47:39 +11:00
|
|
|
.PHONY: docs
|
|
|
|
docs: ## Compile the documentation
|
|
|
|
docker-compose run --rm app sphinx-build docs docs/_build/html
|
|
|
|
|
|
|
|
.PHONY: watch-docs
|
|
|
|
docs-watch: ## Compile the documentation and watch for changes
|
2019-12-09 04:21:42 +11:00
|
|
|
docker-compose run -p 8000:8000 --rm app sphinx-autobuild -H 0 -p 8000 docs docs/_build/html
|
2019-12-07 21:37:30 +11:00
|
|
|
|
|
|
|
.PHONY: css
|
|
|
|
css: ## Compile SCSS files
|
|
|
|
npx sass --no-source-map --style=compressed client/scss/dpaste.scss:dpaste/static/dpaste.css
|
|
|
|
|
|
|
|
.PHONY: css-watch
|
|
|
|
css-watch: ## Compile JS files
|
2019-12-09 08:57:00 +11:00
|
|
|
npx sass --watch client/scss/dpaste.scss:dpaste/static/dpaste.css
|
2019-12-07 21:37:30 +11:00
|
|
|
|
|
|
|
.PHONY: js
|
|
|
|
js: ## Compile JS files
|
|
|
|
npx uglifyjs --compress="drop_console=true,ecma=6" --mangle="toplevel" --output=dpaste/static/dpaste.js client/js/dpaste.js
|
|
|
|
|
2019-12-08 20:29:33 +11:00
|
|
|
.PHONY: release-docker
|
|
|
|
release-docker:
|
|
|
|
set -ex
|
2019-12-19 03:47:42 +11:00
|
|
|
rm -f .coverage
|
2019-12-19 03:46:31 +11:00
|
|
|
pip-compile --dry-run setup.py
|
2019-12-08 20:29:33 +11:00
|
|
|
docker build --build-arg BUILD_EXTRAS=production -t barttc/dpaste:latest .
|
2019-12-19 03:55:08 +11:00
|
|
|
docker run --rm barttc/dpaste:latest pytest dpaste/
|
2019-12-08 20:29:33 +11:00
|
|
|
@echo -e "\n\n💫 All fine. Now do: docker push barttc/dpaste:latest"
|
|
|
|
|
2019-12-08 22:47:39 +11:00
|
|
|
.PHONY: release-pypi
|
|
|
|
release-pypi:
|
|
|
|
set -ex
|
2019-12-19 03:47:42 +11:00
|
|
|
rm -f .coverage
|
2019-12-19 03:46:31 +11:00
|
|
|
pip-compile --dry-run setup.py
|
|
|
|
docker-compose build
|
2019-12-08 22:47:39 +11:00
|
|
|
docker-compose run --rm app pytest dpaste/
|
|
|
|
rm -rf ./node_modules
|
|
|
|
npm ci
|
|
|
|
make css
|
|
|
|
make js
|
|
|
|
python setup.py sdist && python setup.py bdist_wheel --universal
|
|
|
|
@echo -e "\n\n💫 All fine. Now do: twine upload dist/* --sign"
|
|
|
|
|
2019-12-07 21:37:30 +11:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@echo -e "Available make commands:"
|
|
|
|
@echo -e ""
|
|
|
|
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sort | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := start
|