Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. $(foreach extension,$(extensions),$(eval volumes=$(volumes) --volume $(extension):/var/www/FreshRSS/extensions/$(notdir $(extension)):z))
  36. docker run \
  37. --rm \
  38. --volume $(shell pwd):/var/www/FreshRSS:z \
  39. $(volumes) \
  40. --publish $(PORT):80 \
  41. --env FRESHRSS_ENV=development \
  42. --name freshrss-dev \
  43. freshrss/freshrss:$(TAG)
  44. .PHONY: stop
  45. stop: ## Stop FreshRSS container if any
  46. docker stop freshrss-dev
  47. ######################
  48. ## Tests and linter ##
  49. ######################
  50. .PHONY: test
  51. test: bin/phpunit ## Run the test suite
  52. $(PHP) ./bin/phpunit --bootstrap ./tests/bootstrap.php ./tests
  53. .PHONY: lint
  54. lint: bin/phpcs ## Run the linter on the PHP files
  55. $(PHP) ./bin/phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
  56. .PHONY: lint-fix
  57. lint-fix: bin/phpcbf ## Fix the errors detected by the linter
  58. $(PHP) ./bin/phpcbf . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
  59. bin/phpunit:
  60. mkdir -p bin/
  61. wget -O bin/phpunit https://phar.phpunit.de/phpunit-7.5.9.phar
  62. echo '5404288061420c3921e53dd3a756bf044be546c825c5e3556dea4c51aa330f69 bin/phpunit' | sha256sum -c - || rm bin/phpunit
  63. bin/phpcs:
  64. mkdir -p bin/
  65. wget -O bin/phpcs https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.5/phpcs.phar
  66. echo '4a2f6aff1b1f760216bb00c0b3070431131e3ed91307436bb1bfb252281a804a bin/phpcs' | sha256sum -c - || rm bin/phpcs
  67. bin/phpcbf:
  68. mkdir -p bin/
  69. wget -O bin/phpcbf https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.5/phpcbf.phar
  70. echo '6f64fe00dee53fa7b256f63656dc0154f5964666fc7e535fac86d0078e7dea41 bin/phpcbf' | sha256sum -c - || rm bin/phpcbf
  71. ##########
  72. ## I18N ##
  73. ##########
  74. .PHONY: i18n-format
  75. i18n-format: ## Format I18N files
  76. @$(PHP) ./cli/manipulate.translation.php -a format
  77. @echo Files formatted.
  78. .PHONY: i18n-add-language
  79. i18n-add-language: ## Add a new supported language
  80. ifndef lang
  81. @echo To add a new language, you need to provide one in the "lang" variable.
  82. @exit 10
  83. endif
  84. $(PHP) ./cli/manipulate.translation.php -a add -l $(lang) -o $(ref)
  85. @echo Language added.
  86. .PHONY: i18n-add-key
  87. i18n-add-key: ## Add a translation key to all supported languages
  88. ifndef key
  89. @echo To add a key, you need to provide one in the "key" variable.
  90. @exit 10
  91. endif
  92. ifndef value
  93. @echo To add a key, you need to provide its value in the "value" variable.
  94. @exit 10
  95. endif
  96. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  97. @echo Key added.
  98. .PHONY: i18n-remove-key
  99. i18n-remove-key: ## Remove a translation key from all supported languages
  100. ifndef key
  101. @echo To remove a key, you need to provide one in the "key" variable.
  102. @exit 10
  103. endif
  104. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  105. @echo Key removed.
  106. .PHONY: i18n-update-key
  107. i18n-update-key: ## Update a translation key in all supported languages
  108. ifndef key
  109. @echo To update a key, you need to provide one in the "key" variable.
  110. @exit 10
  111. endif
  112. ifndef value
  113. @echo To update a key, you need to provide its value in the "value" variable.
  114. @exit 10
  115. endif
  116. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  117. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  118. @echo Key updated.
  119. .PHONY: i18n-ignore-key
  120. i18n-ignore-key: ## Ignore a translation key for the selected language
  121. ifndef lang
  122. @echo To ignore a key, you need to provide a language in the "lang" variable.
  123. @exit 10
  124. endif
  125. ifndef key
  126. @echo To ignore a key, you need to provide one in the "key" variable.
  127. @exit 10
  128. endif
  129. @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang)
  130. @echo Key ignored.
  131. .PHONY: i18n-key-exists
  132. i18n-key-exists: ## Check if a translation key exists
  133. ifndef key
  134. @echo To check if a key exists, you need to provide one in the "key" variable.
  135. @exit 10
  136. endif
  137. @$(PHP) ./cli/manipulate.translation.php -a exist -k $(key)
  138. ###########
  139. ## TOOLS ##
  140. ###########
  141. .PHONY: rtl
  142. rtl: ## Generate RTL CSS files
  143. rtlcss -d p/themes && find . -type f -name '*.rtl.rtl.css' -delete
  144. .PHONY: pot
  145. pot: ## Generate POT templates for docs
  146. cd docs && ../cli/translation-update.sh
  147. .PHONY: refresh
  148. refresh: ## Refresh feeds by fetching new messages
  149. @$(PHP) ./app/actualize_script.php
  150. ##########
  151. ## HELP ##
  152. ##########
  153. .PHONY: help
  154. help:
  155. @grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'