Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. .DEFAULT_GOAL := help
  2. ifndef TAG
  3. TAG=alpine
  4. endif
  5. PORT ?= 8080
  6. NETWORK ?= freshrss-network
  7. ifdef NO_DOCKER
  8. PHP = $(shell which php)
  9. else
  10. PHP = docker run \
  11. --rm \
  12. --volume $(shell pwd):/var/www/FreshRSS:z \
  13. --env FRESHRSS_ENV=development \
  14. --name freshrss-php-cli \
  15. freshrss/freshrss:$(TAG) \
  16. php
  17. endif
  18. ifeq ($(findstring alpine,$(TAG)),alpine)
  19. DOCKERFILE=Dockerfile-Alpine
  20. else ifeq ($(findstring arm,$(TAG)),arm)
  21. DOCKERFILE=Dockerfile-QEMU-ARM
  22. else
  23. DOCKERFILE=Dockerfile
  24. endif
  25. ############
  26. ## Docker ##
  27. ############
  28. .PHONY: build
  29. build: ## Build a Docker image
  30. docker build \
  31. --pull \
  32. --tag freshrss/freshrss:$(TAG) \
  33. --file Docker/$(DOCKERFILE) .
  34. .PHONY: start
  35. start: ## Start the development environment (use Docker)
  36. docker network create --driver bridge $(NETWORK) || true
  37. $(foreach extension,$(extensions),$(eval volumes=$(volumes) --volume $(extension):/var/www/FreshRSS/extensions/$(notdir $(extension)):z))
  38. docker run \
  39. --rm \
  40. --volume $(shell pwd):/var/www/FreshRSS:z \
  41. $(volumes) \
  42. --publish $(PORT):80 \
  43. --env FRESHRSS_ENV=development \
  44. --name freshrss-dev \
  45. --network $(NETWORK) \
  46. freshrss/freshrss:$(TAG)
  47. .PHONY: stop
  48. stop: ## Stop FreshRSS container if any
  49. docker stop freshrss-dev || true
  50. docker network rm $(NETWORK) || true
  51. ######################
  52. ## Tests and linter ##
  53. ######################
  54. .PHONY: test
  55. test: vendor/bin/phpunit ## Run the test suite
  56. $(PHP) vendor/bin/phpunit --bootstrap ./tests/bootstrap.php ./tests
  57. .PHONY: lint
  58. lint: vendor/bin/phpcs ## Run the linter on the PHP files
  59. $(PHP) vendor/bin/phpcs . -p -s
  60. .PHONY: lint-fix
  61. lint-fix: vendor/bin/phpcbf ## Fix the errors detected by the linter
  62. $(PHP) vendor/bin/phpcbf . -p -s
  63. bin/composer:
  64. mkdir -p bin/
  65. wget 'https://raw.githubusercontent.com/composer/getcomposer.org/b5dbe5ebdec95ce71b3128b359bd5a85cb0a722d/web/installer' -O - -q | php -- --quiet --install-dir='./bin/' --filename='composer'
  66. vendor/bin/phpunit: bin/composer
  67. bin/composer install --prefer-dist --no-progress
  68. ln -s ../vendor/bin/phpunit bin/phpunit
  69. vendor/bin/phpcs: bin/composer
  70. bin/composer install --prefer-dist --no-progress
  71. ln -s ../vendor/bin/phpcs bin/phpcs
  72. vendor/bin/phpcbf: bin/composer
  73. bin/composer install --prefer-dist --no-progress
  74. ln -s ../vendor/bin/phpcbf bin/phpcbf
  75. bin/typos:
  76. mkdir -p bin/
  77. cd bin ; \
  78. wget -q 'https://github.com/crate-ci/typos/releases/download/v1.13.6/typos-v1.13.6-x86_64-unknown-linux-musl.tar.gz' && \
  79. tar -xvf *.tar.gz './typos' && \
  80. chmod +x typos && \
  81. rm *.tar.gz ; \
  82. cd ..
  83. node_modules/.bin/eslint:
  84. npm install
  85. node_modules/.bin/rtlcss:
  86. npm install
  87. vendor/bin/phpstan: bin/composer
  88. bin/composer install --prefer-dist --no-progress
  89. ##########
  90. ## I18N ##
  91. ##########
  92. .PHONY: i18n-format
  93. i18n-format: ## Format I18N files
  94. @$(PHP) ./cli/manipulate.translation.php -a format
  95. @echo Files formatted.
  96. .PHONY: i18n-add-language
  97. i18n-add-language: ## Add a new supported language
  98. ifndef lang
  99. $(error To add a new language, you need to provide one in the "lang" variable)
  100. endif
  101. $(PHP) ./cli/manipulate.translation.php -a add -l $(lang) -o $(ref)
  102. @echo Language added.
  103. .PHONY: i18n-add-key
  104. i18n-add-key: ## Add a translation key to all supported languages
  105. ifndef key
  106. $(error To add a key, you need to provide one in the "key" variable)
  107. endif
  108. ifndef value
  109. $(error To add a key, you need to provide its value in the "value" variable)
  110. endif
  111. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  112. @echo Key added.
  113. .PHONY: i18n-remove-key
  114. i18n-remove-key: ## Remove a translation key from all supported languages
  115. ifndef key
  116. $(error To remove a key, you need to provide one in the "key" variable)
  117. endif
  118. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  119. @echo Key removed.
  120. .PHONY: i18n-update-key
  121. i18n-update-key: ## Update a translation key in all supported languages
  122. ifndef key
  123. $(error To update a key, you need to provide one in the "key" variable)
  124. endif
  125. ifndef value
  126. $(error To update a key, you need to provide its value in the "value" variable)
  127. endif
  128. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)" -l en
  129. @echo Key updated.
  130. .PHONY: i18n-ignore-key
  131. i18n-ignore-key: ## Ignore a translation key for the selected language
  132. ifndef lang
  133. $(error To ignore a key, you need to provide a language in the "lang" variable)
  134. endif
  135. ifndef key
  136. $(error To ignore a key, you need to provide one in the "key" variable)
  137. endif
  138. @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang)
  139. @echo Key ignored.
  140. .PHONY: i18n-ignore-unmodified-keys
  141. i18n-ignore-unmodified-keys: ## Ignore all unmodified translation keys for the selected language
  142. ifndef lang
  143. $(error To ignore unmodified keys, you need to provide a language in the "lang" variable)
  144. endif
  145. @$(PHP) ./cli/manipulate.translation.php -a ignore_unmodified -l $(lang)
  146. @echo Unmodified keys ignored.
  147. .PHONY: i18n-key-exists
  148. i18n-key-exists: ## Check if a translation key exists
  149. ifndef key
  150. $(error To check if a key exists, you need to provide one in the "key" variable)
  151. endif
  152. @$(PHP) ./cli/manipulate.translation.php -a exist -k $(key)
  153. ###########
  154. ## TOOLS ##
  155. ###########
  156. .PHONY: rtl
  157. rtl: node_modules/.bin/rtlcss ## Generate RTL CSS files
  158. npm run-script rtlcss
  159. .PHONY: pot
  160. pot: ## Generate POT templates for docs
  161. cd docs && ../cli/translation-update.sh
  162. .PHONY: refresh
  163. refresh: ## Refresh feeds by fetching new messages
  164. @$(PHP) ./app/actualize_script.php
  165. ###############################
  166. ## New commands aligned on CI #
  167. ## Work in progress #
  168. ###############################
  169. # TODO: Add composer install
  170. .PHONY: composer-test
  171. composer-test: vendor/bin/phpstan
  172. bin/composer run-script test
  173. .PHONY: composer-fix
  174. composer-fix:
  175. bin/composer run-script fix
  176. .PHONY: npm-test
  177. npm-test: node_modules/.bin/eslint
  178. npm test
  179. .PHONY: npm-fix
  180. npm-fix: node_modules/.bin/eslint
  181. npm run fix
  182. .PHONY: typos-test
  183. typos-test: bin/typos
  184. bin/typos
  185. # TODO: Add shellcheck, shfmt, hadolint
  186. .PHONY: test-all
  187. test-all: composer-test npm-test typos-test
  188. .PHONY: fix-all
  189. fix-all: composer-fix npm-fix
  190. ##########
  191. ## HELP ##
  192. ##########
  193. .PHONY: help
  194. help:
  195. @grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'