polls/Makefile

115 строки
3.0 KiB
Makefile
Исходник Обычный вид История

2017-10-09 18:34:25 +03:00
# This file is licensed under the Affero General Public License version 3 or
# later. See the COPYING file.
# @author Bernhard Posselt <dev@bernhard-posselt.com>
# @copyright Bernhard Posselt 2016
# Dependencies:
# * make
# * which
2019-01-02 22:59:42 +03:00
# * npm
2017-10-09 18:34:25 +03:00
# * curl: used if phpunit and composer are not installed to fetch them from the web
# * tar: for building the archive
2019-01-03 02:29:30 +03:00
app_name=polls
project_dir=.
build_dir=./build
2019-01-02 22:59:42 +03:00
build_tools_dir=$(build_dir)/tools
build_source_dir=$(build_dir)/source
appstore_build_dir=$(build_dir)/artifacts/appstore
appstore_package_name=$(appstore_build_dir)/$(app_name)
nc_cert_dir=$(HOME)/.nextcloud/certificates
2017-10-09 18:34:25 +03:00
composer=$(shell which composer 2> /dev/null)
2019-01-04 07:46:47 +03:00
all: dev-setup appstore
2019-01-02 22:59:42 +03:00
# Dev environment setup
2019-01-04 07:46:47 +03:00
dev-setup: clean-dev npm-init composer
2019-01-02 22:59:42 +03:00
npm-init:
npm install
2017-10-09 18:34:25 +03:00
# a copy is fetched from the web
.PHONY: composer
composer:
ifeq (,$(composer))
2017-10-09 18:34:25 +03:00
@echo "No composer command available, downloading a copy from the web"
2019-01-02 22:59:42 +03:00
mkdir -p $(build_tools_dir)
2017-10-09 18:34:25 +03:00
curl -sS https://getcomposer.org/installer | php
2019-01-02 22:59:42 +03:00
mv composer.phar $(build_tools_dir)
php $(build_tools_dir)/composer.phar install --prefer-dist
php $(build_tools_dir)/composer.phar update --prefer-dist
2017-10-09 18:34:25 +03:00
else
composer install --prefer-dist
composer update --prefer-dist
endif
2019-01-02 22:59:42 +03:00
# Lint
lint:
npm run lint
lint-fix:
npm run lint:fix
# Removes the appstore build and compiled js files
2017-10-09 18:34:25 +03:00
.PHONY: clean
clean:
2019-01-02 22:59:42 +03:00
rm -rf $(build_dir)
2020-01-31 09:51:45 +03:00
rm -rf js/*
2020-01-19 13:31:52 +03:00
mkdir -p js
2019-01-04 07:46:47 +03:00
clean-dev: clean
2019-01-02 22:59:42 +03:00
rm -rf node_modules
2019-01-04 07:46:47 +03:00
rm -rf ./vendor
# Build js
# Installs and updates the composer dependencies. If composer is not installed
build-js-production:
npm run build
2019-01-02 22:59:42 +03:00
2017-10-09 18:34:25 +03:00
# Builds the source package for the app store, ignores php and js tests
.PHONY: appstore
2019-01-04 07:46:47 +03:00
appstore: clean lint build-js-production
2019-01-03 00:01:38 +03:00
mkdir -p $(build_source_dir)
mkdir -p $(appstore_build_dir)
2017-10-21 17:47:11 +03:00
rsync -a \
2019-01-02 22:59:42 +03:00
--exclude="ISSUE_TEMPLATE.md" \
2017-10-21 17:47:11 +03:00
--exclude="*.log" \
2018-09-14 20:04:42 +03:00
--exclude=".*" \
2019-01-03 00:12:12 +03:00
--exclude="_*" \
2019-01-02 22:59:42 +03:00
--exclude="build" \
2018-09-14 20:04:42 +03:00
--exclude="bower.json" \
2017-10-21 17:47:11 +03:00
--exclude="composer.*" \
2019-01-02 22:59:42 +03:00
--exclude="js/.*" \
2017-10-21 17:47:11 +03:00
--exclude="js/*.log" \
--exclude="js/bower.json" \
--exclude="js/karma.*" \
2019-01-02 22:59:42 +03:00
--exclude="js/node_modules" \
--exclude="js/package.json" \
2017-10-21 17:47:11 +03:00
--exclude="js/protractor.*" \
2019-01-02 22:59:42 +03:00
--exclude="js/test" \
--exclude="js/tests" \
--exclude="karma.*" \
2017-10-21 17:47:11 +03:00
--exclude="l10n/no-php" \
2019-01-02 22:59:42 +03:00
--exclude="Makefile" \
2018-09-14 20:04:42 +03:00
--exclude="node_modules" \
2019-01-02 22:59:42 +03:00
--exclude="package*" \
--exclude="phpunit*xml" \
--exclude="protractor.*" \
2018-09-14 20:04:42 +03:00
--exclude="screenshots" \
--exclude="src" \
--exclude="tests" \
--exclude="vendor" \
2019-01-03 00:12:12 +03:00
--exclude="webpack.*" \
2019-01-03 02:29:30 +03:00
$(project_dir)/ $(build_source_dir)/$(app_name)
tar -czf $(appstore_package_name).tar.gz \
2019-01-02 22:59:42 +03:00
--directory="$(build_source_dir)" $(app_name)
@if [ -f $(nc_cert_dir)/$(app_name).key ]; then \
2017-10-21 17:47:11 +03:00
echo "Signing package..."; \
2019-01-02 22:59:42 +03:00
openssl dgst -sha512 -sign $(nc_cert_dir)/$(app_name).key $(appstore_build_dir)/$(app_name).tar.gz | openssl base64; \
2017-10-21 17:47:11 +03:00
fi
2017-10-09 18:34:25 +03:00
.PHONY: test
test: composer
$(CURDIR)/vendor/phpunit/phpunit/phpunit --coverage-clover clover.xml -c phpunit.xml
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml