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
|
|
|
|
|
|
|
|
app_name=$(notdir $(CURDIR))
|
2019-01-02 22:59:42 +03:00
|
|
|
build_dir=$(CURDIR)/build
|
|
|
|
build_tools_dir=$(build_dir)/tools
|
|
|
|
build_source_dir=$(build_dir)/source
|
|
|
|
appstore_build_dir=$(build_dir)/artifacts/appstore
|
|
|
|
sign_dir=$(build_dir)/sign
|
|
|
|
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-02 22:59:42 +03:00
|
|
|
all: dev-setup lint build-js-production test
|
|
|
|
|
|
|
|
# Dev environment setup
|
|
|
|
dev-setup: clean clean-dev npm-init composer
|
|
|
|
|
|
|
|
npm-init:
|
|
|
|
npm install
|
|
|
|
|
|
|
|
# Build js
|
|
|
|
build-js-production:
|
|
|
|
npm run build
|
2017-10-09 18:34:25 +03:00
|
|
|
|
|
|
|
# Installs and updates the composer dependencies. If composer is not installed
|
|
|
|
# a copy is fetched from the web
|
|
|
|
.PHONY: composer
|
|
|
|
composer:
|
2017-10-21 16:18:45 +03:00
|
|
|
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)
|
|
|
|
rm -f js/polls.js
|
|
|
|
rm -f js/polls.js.map
|
|
|
|
|
|
|
|
clean-dev:
|
|
|
|
rm -rf node_modules
|
|
|
|
|
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-02 22:59:42 +03:00
|
|
|
appstore: dev-setup lint build-js-production composer
|
|
|
|
mkdir -p $(sign_dir)
|
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-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-02 22:59:42 +03:00
|
|
|
./ $(build_source_dir)/$(app_name)
|
2017-10-21 17:47:11 +03:00
|
|
|
|
2019-01-02 22:59:42 +03:00
|
|
|
tar cvzf $(appstore_package_name).tar.gz \
|
|
|
|
--directory="$(build_source_dir)" $(app_name)
|
2017-10-21 17:47:11 +03:00
|
|
|
|
2019-01-02 22:59:42 +03:00
|
|
|
@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-21 16:18:45 +03:00
|
|
|
|
2017-10-09 18:34:25 +03:00
|
|
|
.PHONY: test
|
2017-10-09 19:34:48 +03:00
|
|
|
test: composer
|
2017-11-07 17:43:45 +03:00
|
|
|
$(CURDIR)/vendor/phpunit/phpunit/phpunit --coverage-clover clover.xml -c phpunit.xml
|
2017-10-09 19:34:48 +03:00
|
|
|
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
|