Makefile 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 . -p -s
  56. .PHONY: lint-fix
  57. lint-fix: bin/phpcbf ## Fix the errors detected by the linter
  58. $(PHP) ./bin/phpcbf . -p -s
  59. bin/phpunit:
  60. mkdir -p bin/
  61. wget -O bin/phpunit https://phar.phpunit.de/phpunit-9.5.2.phar
  62. echo 'bcf913565bc60dfb5356cf67cbbccec1d8888dbd595b0fbb8343a5019342c67c 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. bin/typos:
  72. mkdir -p bin/
  73. cd bin ; \
  74. wget -q 'https://github.com/crate-ci/typos/releases/download/v1.3.3/typos-v1.3.3-x86_64-unknown-linux-musl.tar.gz' && \
  75. tar -xvf *.tar.gz './typos' && \
  76. chmod +x typos && \
  77. rm *.tar.gz ; \
  78. cd ..
  79. ##########
  80. ## I18N ##
  81. ##########
  82. .PHONY: i18n-format
  83. i18n-format: ## Format I18N files
  84. @$(PHP) ./cli/manipulate.translation.php -a format
  85. @echo Files formatted.
  86. .PHONY: i18n-add-language
  87. i18n-add-language: ## Add a new supported language
  88. ifndef lang
  89. $(error To add a new language, you need to provide one in the "lang" variable)
  90. endif
  91. $(PHP) ./cli/manipulate.translation.php -a add -l $(lang) -o $(ref)
  92. @echo Language added.
  93. .PHONY: i18n-add-key
  94. i18n-add-key: ## Add a translation key to all supported languages
  95. ifndef key
  96. $(error To add a key, you need to provide one in the "key" variable)
  97. endif
  98. ifndef value
  99. $(error To add a key, you need to provide its value in the "value" variable)
  100. endif
  101. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  102. @echo Key added.
  103. .PHONY: i18n-remove-key
  104. i18n-remove-key: ## Remove a translation key from all supported languages
  105. ifndef key
  106. $(error To remove a key, you need to provide one in the "key" variable)
  107. endif
  108. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  109. @echo Key removed.
  110. .PHONY: i18n-update-key
  111. i18n-update-key: ## Update a translation key in all supported languages
  112. ifndef key
  113. $(error To update a key, you need to provide one in the "key" variable)
  114. endif
  115. ifndef value
  116. $(error To update a key, you need to provide its value in the "value" variable)
  117. endif
  118. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)" -l en
  119. @echo Key updated.
  120. .PHONY: i18n-ignore-key
  121. i18n-ignore-key: ## Ignore a translation key for the selected language
  122. ifndef lang
  123. $(error To ignore a key, you need to provide a language in the "lang" variable)
  124. endif
  125. ifndef key
  126. $(error To ignore a key, you need to provide one in the "key" variable)
  127. endif
  128. @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang)
  129. @echo Key ignored.
  130. .PHONY: i18n-ignore-unmodified-keys
  131. i18n-ignore-unmodified-keys: ## Ignore all unmodified translation keys for the selected language
  132. ifndef lang
  133. $(error To ignore unmodified keys, you need to provide a language in the "lang" variable)
  134. endif
  135. @$(PHP) ./cli/manipulate.translation.php -a ignore_unmodified -l $(lang)
  136. @echo Unmodified keys ignored.
  137. .PHONY: i18n-key-exists
  138. i18n-key-exists: ## Check if a translation key exists
  139. ifndef key
  140. $(error To check if a key exists, you need to provide one in the "key" variable)
  141. endif
  142. @$(PHP) ./cli/manipulate.translation.php -a exist -k $(key)
  143. ###########
  144. ## TOOLS ##
  145. ###########
  146. .PHONY: rtl
  147. rtl: ## Generate RTL CSS files
  148. rtlcss -d p/themes/ && find p/themes/ -type f -name '*.rtl.rtl.css' -delete
  149. .PHONY: pot
  150. pot: ## Generate POT templates for docs
  151. cd docs && ../cli/translation-update.sh
  152. .PHONY: refresh
  153. refresh: ## Refresh feeds by fetching new messages
  154. @$(PHP) ./app/actualize_script.php
  155. ###############################
  156. ## New commands aligned on CI #
  157. ## Work in progress #
  158. ###############################
  159. # TODO: Add composer install
  160. .PHONY: composer-test
  161. composer-test:
  162. composer run-script test
  163. .PHONY: composer-fix
  164. composer-fix:
  165. composer run-script fix
  166. # TODO: Add npm install
  167. .PHONY: npm-test
  168. npm-test:
  169. npm test
  170. .PHONY: npm-fix
  171. npm-fix:
  172. npm run fix
  173. .PHONY: typos-test
  174. typos-test: bin/typos
  175. bin/typos
  176. # TODO: Add shellcheck, shfmt, hadolint
  177. .PHONY: test-all
  178. test-all: composer-test npm-test typos-test
  179. .PHONY: fix-all
  180. fix-all: composer-fix npm-fix
  181. ##########
  182. ## HELP ##
  183. ##########
  184. .PHONY: help
  185. help:
  186. @grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'