Makefile 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. $(error To add a new language, you need to provide one in the "lang" variable)
  82. endif
  83. $(PHP) ./cli/manipulate.translation.php -a add -l $(lang) -o $(ref)
  84. @echo Language added.
  85. .PHONY: i18n-add-key
  86. i18n-add-key: ## Add a translation key to all supported languages
  87. ifndef key
  88. $(error To add a key, you need to provide one in the "key" variable)
  89. endif
  90. ifndef value
  91. $(error To add a key, you need to provide its value in the "value" variable)
  92. endif
  93. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  94. @echo Key added.
  95. .PHONY: i18n-remove-key
  96. i18n-remove-key: ## Remove a translation key from all supported languages
  97. ifndef key
  98. $(error To remove a key, you need to provide one in the "key" variable)
  99. endif
  100. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  101. @echo Key removed.
  102. .PHONY: i18n-update-key
  103. i18n-update-key: ## Update a translation key in all supported languages
  104. ifndef key
  105. $(error To update a key, you need to provide one in the "key" variable)
  106. endif
  107. ifndef value
  108. $(error To update a key, you need to provide its value in the "value" variable)
  109. endif
  110. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)" -l en
  111. @echo Key updated.
  112. .PHONY: i18n-ignore-key
  113. i18n-ignore-key: ## Ignore a translation key for the selected language
  114. ifndef lang
  115. $(error To ignore a key, you need to provide a language in the "lang" variable)
  116. endif
  117. ifndef key
  118. $(error To ignore a key, you need to provide one in the "key" variable)
  119. endif
  120. @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang)
  121. @echo Key ignored.
  122. .PHONY: i18n-ignore-unmodified-keys
  123. i18n-ignore-unmodified-keys: ## Ignore all unmodified translation keys for the selected language
  124. ifndef lang
  125. $(error To ignore unmodified keys, you need to provide a language in the "lang" variable)
  126. endif
  127. @$(PHP) ./cli/manipulate.translation.php -a ignore_unmodified -l $(lang)
  128. @echo Unmodified keys ignored.
  129. .PHONY: i18n-key-exists
  130. i18n-key-exists: ## Check if a translation key exists
  131. ifndef key
  132. $(error To check if a key exists, you need to provide one in the "key" variable)
  133. endif
  134. @$(PHP) ./cli/manipulate.translation.php -a exist -k $(key)
  135. ###########
  136. ## TOOLS ##
  137. ###########
  138. .PHONY: rtl
  139. rtl: ## Generate RTL CSS files
  140. rtlcss -d p/themes && find . -type f -name '*.rtl.rtl.css' -delete
  141. .PHONY: pot
  142. pot: ## Generate POT templates for docs
  143. cd docs && ../cli/translation-update.sh
  144. .PHONY: refresh
  145. refresh: ## Refresh feeds by fetching new messages
  146. @$(PHP) ./app/actualize_script.php
  147. ##########
  148. ## HELP ##
  149. ##########
  150. .PHONY: help
  151. help:
  152. @grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'