Makefile 4.4 KB

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