Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. .DEFAULT_GOAL := help
  2. ifndef TAG
  3. TAG=alpine
  4. endif
  5. PORT ?= 8080
  6. ifdef NO_DOCKER
  7. PHP = $(shell which php)
  8. else
  9. PHP = docker run \
  10. --rm \
  11. --volume $(shell pwd):/var/www/FreshRSS:z \
  12. --env FRESHRSS_ENV=development \
  13. --name freshrss-php-cli \
  14. freshrss/freshrss:$(TAG) \
  15. php
  16. endif
  17. ifeq ($(findstring alpine,$(TAG)),alpine)
  18. DOCKERFILE=Dockerfile-Alpine
  19. else ifeq ($(findstring arm,$(TAG)),arm)
  20. DOCKERFILE=Dockerfile-QEMU-ARM
  21. else
  22. DOCKERFILE=Dockerfile
  23. endif
  24. ############
  25. ## Docker ##
  26. ############
  27. .PHONY: build
  28. build: ## Build a Docker image
  29. docker build \
  30. --pull \
  31. --tag freshrss/freshrss:$(TAG) \
  32. --file Docker/$(DOCKERFILE) .
  33. .PHONY: start
  34. start: ## Start the development environment (use Docker)
  35. docker run \
  36. --rm \
  37. --volume $(shell pwd):/var/www/FreshRSS:z \
  38. --publish $(PORT):80 \
  39. --env FRESHRSS_ENV=development \
  40. --name freshrss-dev \
  41. freshrss/freshrss:$(TAG)
  42. .PHONY: stop
  43. stop: ## Stop FreshRSS container if any
  44. docker stop freshrss-dev
  45. ######################
  46. ## Tests and linter ##
  47. ######################
  48. .PHONY: test
  49. test: bin/phpunit ## Run the test suite
  50. $(PHP) ./bin/phpunit --bootstrap ./tests/bootstrap.php ./tests
  51. .PHONY: lint
  52. lint: bin/phpcs ## Run the linter on the PHP files
  53. $(PHP) ./bin/phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
  54. .PHONY: lint-fix
  55. lint-fix: bin/phpcbf ## Fix the errors detected by the linter
  56. $(PHP) ./bin/phpcbf . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
  57. bin/phpunit:
  58. mkdir -p bin/
  59. wget -O bin/phpunit https://phar.phpunit.de/phpunit-7.5.9.phar
  60. echo '5404288061420c3921e53dd3a756bf044be546c825c5e3556dea4c51aa330f69 bin/phpunit' | sha256sum -c - || rm bin/phpunit
  61. bin/phpcs:
  62. mkdir -p bin/
  63. wget -O bin/phpcs https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.5/phpcs.phar
  64. echo '4a2f6aff1b1f760216bb00c0b3070431131e3ed91307436bb1bfb252281a804a bin/phpcs' | sha256sum -c - || rm bin/phpcs
  65. bin/phpcbf:
  66. mkdir -p bin/
  67. wget -O bin/phpcbf https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.5/phpcbf.phar
  68. echo '6f64fe00dee53fa7b256f63656dc0154f5964666fc7e535fac86d0078e7dea41 bin/phpcbf' | sha256sum -c - || rm bin/phpcbf
  69. ##########
  70. ## I18N ##
  71. ##########
  72. .PHONY: i18n-format
  73. i18n-format: ## Format I18N files
  74. @$(PHP) ./cli/manipulate.translation.php -a format
  75. @echo Files formatted.
  76. .PHONY: i18n-add-language
  77. i18n-add-language: ## Add a new supported language
  78. ifndef lang
  79. @echo To add a new language, you need to provide one in the "lang" variable.
  80. @exit 10
  81. endif
  82. @$(PHP) ./cli/manipulate.translation.php -a add -l $(lang)
  83. @echo Language added.
  84. .PHONY: i18n-add-key
  85. i18n-add-key: ## Add a translation key to all supported languages
  86. ifndef key
  87. @echo To add a key, you need to provide one in the "key" variable.
  88. @exit 10
  89. endif
  90. ifndef value
  91. @echo To add a key, you need to provide its value in the "value" variable.
  92. @exit 10
  93. endif
  94. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  95. @echo Key added.
  96. .PHONY: i18n-remove-key
  97. i18n-remove-key: ## Remove a translation key from all supported languages
  98. ifndef key
  99. @echo To remove a key, you need to provide one in the "key" variable.
  100. @exit 10
  101. endif
  102. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  103. @echo Key removed.
  104. .PHONY: i18n-update-key
  105. i18n-update-key: ## Update a translation key in all supported languages
  106. ifndef key
  107. @echo To update a key, you need to provide one in the "key" variable.
  108. @exit 10
  109. endif
  110. ifndef value
  111. @echo To update a key, you need to provide its value in the "value" variable.
  112. @exit 10
  113. endif
  114. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  115. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  116. @echo Key updated.
  117. .PHONY: i18n-ignore-key
  118. i18n-ignore-key: ## Ignore a translation key for the selected language
  119. ifndef lang
  120. @echo To ignore a key, you need to provide a language in the "lang" variable.
  121. @exit 10
  122. endif
  123. ifndef key
  124. @echo To ignore a key, you need to provide one in the "key" variable.
  125. @exit 10
  126. endif
  127. @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang)
  128. @echo Key ignored.
  129. ###########
  130. ## TOOLS ##
  131. ###########
  132. .PHONY: rtl
  133. rtl: ## Generate RTL CSS files
  134. rtlcss -d p/themes && find . -type f -name '*.rtl.rtl.css' -delete
  135. .PHONY: pot
  136. pot: ## Generate POT templates for docs
  137. cd docs && ../cli/translation-update.sh
  138. .PHONY: refresh
  139. refresh: ## Refresh feeds by fetching new messages
  140. @$(PHP) ./app/actualize_script.php
  141. ##########
  142. ## HELP ##
  143. ##########
  144. .PHONY: help
  145. help:
  146. @grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'