2017-01-16 01:26:04 +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 2017
|
|
|
|
# @author Georg Ehrke <oc.list@georgehrke.com>
|
|
|
|
# @copyright Georg Ehrke 2017
|
|
|
|
# @author Raimund Schlüßler
|
2018-08-19 23:33:26 +03:00
|
|
|
# @copyright 2018 Raimund Schlüßler <raimund.schluessler@mailbox.org>
|
2016-03-14 19:20:22 +03:00
|
|
|
|
2017-10-15 14:41:00 +03:00
|
|
|
# Generic Makefile for building and packaging a Nextcloud app which uses npm and
|
2017-01-16 01:26:04 +03:00
|
|
|
# Composer.
|
|
|
|
#
|
|
|
|
# Dependencies:
|
|
|
|
# * make
|
|
|
|
# * which
|
|
|
|
# * curl: used if phpunit and composer are not installed to fetch them from the web
|
|
|
|
# * tar: for building the archive
|
2017-10-15 14:41:00 +03:00
|
|
|
# * npm: for building and testing everything JS
|
2017-01-16 01:26:04 +03:00
|
|
|
#
|
2017-10-15 14:41:00 +03:00
|
|
|
# The npm command by launches the npm build script:
|
2017-01-16 01:26:04 +03:00
|
|
|
#
|
2017-10-15 14:41:00 +03:00
|
|
|
# npm run build
|
2017-01-16 01:26:04 +03:00
|
|
|
#
|
2017-10-15 14:41:00 +03:00
|
|
|
# The npm test command launches the npm test script:
|
2017-01-16 01:26:04 +03:00
|
|
|
#
|
2017-10-15 14:41:00 +03:00
|
|
|
# npm run test
|
2017-01-16 01:26:04 +03:00
|
|
|
#
|
2016-03-14 19:20:22 +03:00
|
|
|
|
2017-01-16 01:26:04 +03:00
|
|
|
app_name=$(notdir $(CURDIR))
|
2018-08-19 23:18:53 +03:00
|
|
|
build_directory=$(CURDIR)/build
|
|
|
|
appstore_build_directory=$(CURDIR)/build/appstore/$(app_name)
|
2017-01-16 01:26:04 +03:00
|
|
|
appstore_artifact_directory=$(CURDIR)/build/artifacts/appstore
|
|
|
|
appstore_package_name=$(appstore_artifact_directory)/$(app_name)
|
|
|
|
|
|
|
|
# code signing
|
|
|
|
# assumes the following:
|
|
|
|
# * the app is inside the nextcloud/apps folder
|
|
|
|
# * the private key is located in ~/.nextcloud/tasks.key
|
|
|
|
# * the certificate is located in ~/.nextcloud/tasks.crt
|
|
|
|
occ=$(CURDIR)/../../occ
|
|
|
|
configdir=$(CURDIR)/../../config
|
|
|
|
private_key=$(HOME)/.nextcloud/$(app_name).key
|
|
|
|
certificate=$(HOME)/.nextcloud/$(app_name).crt
|
|
|
|
sign=php -f $(occ) integrity:sign-app --privateKey="$(private_key)" --certificate="$(certificate)"
|
|
|
|
sign_skip_msg="Skipping signing, either no key and certificate found in $(private_key) and $(certificate) or occ can not be found at $(occ)"
|
2018-08-19 23:18:53 +03:00
|
|
|
ifneq ("$(wildcard $(private_key))","") #(,$(wildcard $(private_key)))
|
|
|
|
ifneq ("$(wildcard $(certificate))","")#(,$(wildcard $(certificate)))
|
|
|
|
ifneq ("$(wildcard $(occ))","")#(,$(wildcard $(occ)))
|
|
|
|
CAN_SIGN=true
|
|
|
|
endif
|
|
|
|
endif
|
2017-01-16 01:26:04 +03:00
|
|
|
endif
|
|
|
|
|
2019-05-23 11:22:25 +03:00
|
|
|
.PHONY: all
|
2021-05-02 10:28:38 +03:00
|
|
|
all: dev-setup build-js-production
|
2017-01-16 01:26:04 +03:00
|
|
|
|
2024-03-01 14:09:39 +03:00
|
|
|
# cleanup and generate a clean development setup
|
2019-05-23 11:22:25 +03:00
|
|
|
dev-setup: clean clean-dev npm-init
|
2017-01-16 01:26:04 +03:00
|
|
|
|
2019-05-23 11:22:25 +03:00
|
|
|
npm-init:
|
|
|
|
npm install
|
|
|
|
|
|
|
|
npm-update:
|
|
|
|
npm update
|
2019-01-27 00:05:11 +03:00
|
|
|
|
|
|
|
# Runs the development build
|
2019-05-23 11:22:25 +03:00
|
|
|
build-js:
|
|
|
|
npm run dev
|
|
|
|
|
|
|
|
# Runs the production build
|
|
|
|
build-js-production:
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
# Runs the development build and keep watching
|
|
|
|
watch-js:
|
|
|
|
npm run watch
|
|
|
|
|
2020-04-10 14:18:30 +03:00
|
|
|
composer.phar:
|
|
|
|
curl -sS https://getcomposer.org/installer | php
|
|
|
|
|
|
|
|
install-composer-deps-dev: composer.phar
|
|
|
|
php composer.phar install -o
|
|
|
|
|
|
|
|
update-composer: composer.phar
|
|
|
|
rm -f composer.lock
|
|
|
|
php composer.phar install --prefer-dist
|
|
|
|
|
2018-08-19 23:18:53 +03:00
|
|
|
# Removes the build directory and the compiled files
|
2017-01-16 01:26:04 +03:00
|
|
|
.PHONY: clean
|
2016-03-14 19:20:22 +03:00
|
|
|
clean:
|
2023-08-21 23:50:41 +03:00
|
|
|
rm -rf ./js/*
|
|
|
|
ls -d ./css/* | grep -P '^((?!tasks-icon.css).)*$$' | xargs -r -d'\n' rm
|
2018-08-19 23:18:53 +03:00
|
|
|
rm -rf $(build_directory)
|
2017-01-16 01:26:04 +03:00
|
|
|
|
2017-10-15 14:41:00 +03:00
|
|
|
# Same as clean but also removes dependencies installed by npm
|
2019-05-23 11:22:25 +03:00
|
|
|
.PHONY: clean-dev
|
|
|
|
clean-dev:
|
2017-01-16 01:26:04 +03:00
|
|
|
rm -rf node_modules
|
|
|
|
|
2018-08-19 23:18:53 +03:00
|
|
|
# Builds the source package for the app store
|
2017-01-16 01:26:04 +03:00
|
|
|
.PHONY: appstore
|
2021-05-02 10:28:38 +03:00
|
|
|
appstore: clean build-js-production
|
2017-01-16 01:26:04 +03:00
|
|
|
mkdir -p $(appstore_build_directory) $(appstore_artifact_directory)
|
|
|
|
rsync -av . $(appstore_build_directory) \
|
|
|
|
--exclude=/.git \
|
2020-03-08 00:42:23 +03:00
|
|
|
--exclude=/.github \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/.babelrc \
|
2018-12-11 11:48:25 +03:00
|
|
|
--exclude=/.babelrc.js \
|
2019-08-07 22:20:13 +03:00
|
|
|
--exclude=/.codecov.yml \
|
2017-01-16 01:26:04 +03:00
|
|
|
--exclude=/.editorconfig \
|
2023-08-21 23:50:41 +03:00
|
|
|
--exclude=/.eslintrc.cjs \
|
2018-08-31 00:23:11 +03:00
|
|
|
--exclude=/.gitattributes \
|
2017-01-16 01:26:04 +03:00
|
|
|
--exclude=/.gitignore \
|
2019-08-07 22:20:13 +03:00
|
|
|
--exclude=/.phpunit.result.cache \
|
2022-10-19 17:09:28 +03:00
|
|
|
--exclude=/.php-cs-fixer.dist.php.cache \
|
|
|
|
--exclude=/.php-cs-fixer.dist.php \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/.gitlab-ci.yml \
|
2018-08-31 00:23:11 +03:00
|
|
|
--exclude=/.prettierrc.js \
|
|
|
|
--exclude=/.scrutinizer.yml \
|
2020-10-20 16:54:10 +03:00
|
|
|
--exclude=/.stylelintignore \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/.stylelintrc \
|
2018-08-31 00:23:11 +03:00
|
|
|
--exclude=/.travis.yml \
|
|
|
|
--exclude=/.tx \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/.v8flags*.json \
|
2023-08-21 23:50:41 +03:00
|
|
|
--exclude=/babel.config.cjs \
|
2018-08-31 00:23:11 +03:00
|
|
|
--exclude=/build.xml \
|
2021-06-20 22:21:19 +03:00
|
|
|
--exclude=/clover.integration.xml \
|
|
|
|
--exclude=/clover.unit.xml \
|
2020-03-08 00:42:23 +03:00
|
|
|
--exclude=/composer.json \
|
2020-04-27 21:56:17 +03:00
|
|
|
--exclude=/composer.lock \
|
|
|
|
--exclude=/composer.phar \
|
2017-01-16 01:26:04 +03:00
|
|
|
--exclude=/CONTRIBUTING.md \
|
|
|
|
--exclude=/issue_template.md \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/gulpfile.js \
|
2017-01-16 01:26:04 +03:00
|
|
|
--exclude=/Makefile \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/package-lock.json \
|
|
|
|
--exclude=/package.json \
|
2019-08-07 22:20:13 +03:00
|
|
|
--exclude=/phpunit.xml \
|
|
|
|
--exclude=/phpunit.integration.xml \
|
2017-01-16 01:26:04 +03:00
|
|
|
--exclude=/README.md \
|
2021-06-20 22:21:19 +03:00
|
|
|
--exclude=/stylelint.config.js \
|
2023-08-21 23:50:41 +03:00
|
|
|
--exclude=/vite.config.mjs \
|
2017-01-16 01:26:04 +03:00
|
|
|
--exclude=/build \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/coverage \
|
2017-10-15 20:47:54 +03:00
|
|
|
--exclude=/img/src \
|
2018-08-31 00:23:11 +03:00
|
|
|
--exclude=/src \
|
2018-08-19 23:18:53 +03:00
|
|
|
--exclude=/node_modules \
|
|
|
|
--exclude=/screenshots/ \
|
2018-12-11 11:48:25 +03:00
|
|
|
--exclude=/test \
|
2020-04-27 21:56:17 +03:00
|
|
|
--exclude=/tests \
|
|
|
|
--exclude=/vendor
|
2017-01-16 01:26:04 +03:00
|
|
|
ifdef CAN_SIGN
|
|
|
|
mv $(configdir)/config.php $(configdir)/config-2.php
|
|
|
|
$(sign) --path="$(appstore_build_directory)"
|
|
|
|
mv $(configdir)/config-2.php $(configdir)/config.php
|
|
|
|
else
|
|
|
|
@echo $(sign_skip_msg)
|
|
|
|
endif
|
|
|
|
cd $(appstore_build_directory)/../; \
|
|
|
|
zip -r $(appstore_package_name).zip $(app_name)
|
|
|
|
tar -czf $(appstore_package_name).tar.gz -C $(appstore_build_directory)/../ $(app_name)
|
2018-08-19 23:18:53 +03:00
|
|
|
# create hash
|
2018-01-28 01:08:04 +03:00
|
|
|
ifdef CAN_SIGN
|
2017-01-16 01:26:04 +03:00
|
|
|
openssl dgst -sha512 -sign $(private_key) $(appstore_package_name).tar.gz | openssl base64 -out $(appstore_artifact_directory)/$(app_name).sha512
|
2018-08-19 23:18:53 +03:00
|
|
|
else
|
|
|
|
@echo "Skipping hashing, no key found in $(private_key)."
|
2018-01-28 01:08:04 +03:00
|
|
|
endif
|
2016-07-27 00:36:15 +03:00
|
|
|
|
2018-08-19 23:18:53 +03:00
|
|
|
# Command for running VUE tests
|
2017-01-16 01:26:04 +03:00
|
|
|
.PHONY: test
|
|
|
|
test:
|
2021-04-04 19:53:13 +03:00
|
|
|
npm run test
|
2019-06-12 22:27:23 +03:00
|
|
|
|
|
|
|
test-php:
|
|
|
|
phpunit -c phpunit.xml
|
|
|
|
phpunit -c phpunit.integration.xml
|
|
|
|
|
|
|
|
test-php-coverage:
|
2021-05-15 21:01:49 +03:00
|
|
|
phpunit -c phpunit.xml
|
|
|
|
phpunit -c phpunit.integration.xml
|
2020-04-10 14:18:30 +03:00
|
|
|
|
|
|
|
lint-php:
|
|
|
|
php composer.phar run-script cs:check
|