Makefile 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. .PHONY: all coverage coverage-js coverage-php doc doc-js doc-php increment sign test test-js test-php help
  2. CURRENT_VERSION = 2.0.3
  3. VERSION ?= 2.0.3
  4. VERSION_FILES = README.md SECURITY.md doc/Installation.md js/package.json lib/Controller.php Makefile
  5. REGEX_CURRENT_VERSION := $(shell echo $(CURRENT_VERSION) | sed "s/\./\\\./g")
  6. REGEX_VERSION := $(shell echo $(VERSION) | sed "s/\./\\\./g")
  7. all: coverage doc ## Equivalent to running `make coverage doc`.
  8. composer: ## Update composer dependencies (only production ones, optimize the autoloader)
  9. composer update --no-dev --optimize-autoloader
  10. coverage: coverage-js coverage-php ## Run all unit tests and generate code coverage reports.
  11. coverage-js: ## Run JS unit tests and generate code coverage reports.
  12. cd js && nyc mocha
  13. coverage-php: ## Run PHP unit tests and generate code coverage reports.
  14. cd tst && XDEBUG_MODE=coverage phpunit 2> /dev/null
  15. cd tst/log/php-coverage-report && sed -i "s#$(CURDIR)/##g" *.html */*.html
  16. doc: doc-js doc-php ## Generate all code documentation.
  17. doc-js: ## Generate JS code documentation.
  18. jsdoc -p -d doc/jsdoc js/privatebin.js js/legacy.js
  19. doc-php: ## Generate JS code documentation.
  20. phpdoc --visibility=public,protected,private --target=doc/phpdoc --directory=lib/
  21. increment: ## Increment and commit new version number, set target version using `make increment VERSION=1.2.3`.
  22. for F in `grep -l -R $(REGEX_CURRENT_VERSION) $(VERSION_FILES)`; \
  23. do \
  24. sed -i "s/$(REGEX_CURRENT_VERSION)/$(REGEX_VERSION)/g" $$F; \
  25. done
  26. git add $(VERSION_FILES) CHANGELOG.md
  27. git commit -m "incrementing version"
  28. sign: ## Sign a release.
  29. git tag --sign --message "Release v$(VERSION)" $(VERSION)
  30. git push origin $(VERSION)
  31. signrelease.sh
  32. test: test-js test-php ## Run all unit tests.
  33. test-js: ## Run JS unit tests.
  34. cd js && mocha
  35. test-php: ## Run PHP unit tests.
  36. cd tst && phpunit --no-coverage
  37. help: ## Displays these usage instructions.
  38. @echo "Usage: make <target(s)>"
  39. @echo
  40. @echo "Specify one or multiple of the following targets and they will be processed in the given order:"
  41. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "%-16s%s\n", $$1, $$2}' $(MAKEFILE_LIST)