tasks/Makefile

154 lines
4.4 KiB
Makefile
Raw Normal View History

# 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 20:33:26 +00:00
# @copyright 2018 Raimund Schlüßler <raimund.schluessler@mailbox.org>
2016-03-14 16:20:22 +00:00
2017-10-15 11:41:00 +00:00
# Generic Makefile for building and packaging a Nextcloud app which uses npm and
# 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 11:41:00 +00:00
# * npm: for building and testing everything JS
#
2017-10-15 11:41:00 +00:00
# The npm command by launches the npm build script:
#
2017-10-15 11:41:00 +00:00
# npm run build
#
2017-10-15 11:41:00 +00:00
# The npm test command launches the npm test script:
#
2017-10-15 11:41:00 +00:00
# npm run test
#
2016-03-14 16:20:22 +00:00
app_name=$(notdir $(CURDIR))
2018-08-19 20:18:53 +00:00
build_directory=$(CURDIR)/build
appstore_build_directory=$(CURDIR)/build/appstore/$(app_name)
appstore_artifact_directory=$(CURDIR)/build/artifacts/appstore
appstore_package_name=$(appstore_artifact_directory)/$(app_name)
2017-10-15 11:41:00 +00:00
npm=$(shell which npm 2> /dev/null)
gcp=$(shell which gcp 2> /dev/null)
ifeq (, $(gcp))
copy_command=cp
else
copy_command=gcp
endif
# 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 20:18:53 +00:00
ifneq ("$(wildcard $(private_key))","") #(,$(wildcard $(private_key)))
ifneq ("$(wildcard $(certificate))","")#(,$(wildcard $(certificate)))
ifneq ("$(wildcard $(occ))","")#(,$(wildcard $(occ)))
CAN_SIGN=true
endif
endif
endif
all: build
# Fetches the PHP and JS dependencies and compiles the JS. If no composer.json
# is present, the composer step is skipped, if no package.json or js/package.json
2017-10-15 11:41:00 +00:00
# is present, the npm step is skipped
.PHONY: build
build:
$(npm) run build
2018-08-19 20:18:53 +00:00
# Sets up the development environment
.PHONY: development
development:
$(npm) install
$(npm) update
2018-08-30 21:23:11 +00:00
$(npm) run dev
2018-08-19 20:18:53 +00:00
# Removes the build directory and the compiled files
.PHONY: clean
2016-03-14 16:20:22 +00:00
clean:
2018-08-19 20:18:53 +00:00
rm -f ./css/src/sprites.scss
rm -f ./img/sprites.svg
2018-08-30 21:23:11 +00:00
rm -f ./js/tasks.js
rm -f ./js/tasks.js.map
2018-08-19 20:18:53 +00:00
rm -rf $(build_directory)
2017-10-15 11:41:00 +00:00
# Same as clean but also removes dependencies installed by npm
.PHONY: distclean
distclean: clean
rm -rf node_modules
2018-08-19 20:18:53 +00:00
# Watches the js and scss files
.PHONY: watch
watch:
$(npm) run watch
2018-01-27 22:08:15 +00:00
2018-08-19 20:18:53 +00:00
# Builds the source package for the app store
.PHONY: appstore
2018-08-19 20:18:53 +00:00
appstore: clean build
mkdir -p $(appstore_build_directory) $(appstore_artifact_directory)
rsync -av . $(appstore_build_directory) \
--exclude=/.git \
2018-08-19 20:18:53 +00:00
--exclude=/.babelrc \
--exclude=/.editorconfig \
2018-08-30 21:23:11 +00:00
--exclude=/.eslintrc.js \
--exclude=/.gitattributes \
--exclude=/.gitignore \
2018-08-19 20:18:53 +00:00
--exclude=/.gitlab-ci.yml \
2018-08-30 21:23:11 +00:00
--exclude=/.prettierrc.js \
--exclude=/.scrutinizer.yml \
2018-08-19 20:18:53 +00:00
--exclude=/.stylelintrc \
2018-08-30 21:23:11 +00:00
--exclude=/.travis.yml \
--exclude=/.tx \
2018-08-19 20:18:53 +00:00
--exclude=/.v8flags*.json \
2018-08-30 21:23:11 +00:00
--exclude=/build.xml \
--exclude=/CONTRIBUTING.md \
--exclude=/issue_template.md \
2018-08-19 20:18:53 +00:00
--exclude=/gulpfile.js \
--exclude=/Makefile \
2018-08-19 20:18:53 +00:00
--exclude=/package-lock.json \
--exclude=/package.json \
--exclude=/README.md \
2018-08-19 20:18:53 +00:00
--exclude=/webpack.common.js \
--exclude=/webpack.prod.js \
2018-08-30 21:23:11 +00:00
--exclude=/webpack.dev.js \
--exclude=/build \
2018-08-19 20:18:53 +00:00
--exclude=/coverage \
2017-10-15 17:47:54 +00:00
--exclude=/img/src \
2018-08-30 21:23:11 +00:00
--exclude=/src \
2018-08-19 20:18:53 +00:00
--exclude=/node_modules \
--exclude=/screenshots/ \
--exclude=/test
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 20:18:53 +00:00
# create hash
ifdef CAN_SIGN
openssl dgst -sha512 -sign $(private_key) $(appstore_package_name).tar.gz | openssl base64 -out $(appstore_artifact_directory)/$(app_name).sha512
2018-08-19 20:18:53 +00:00
else
@echo "Skipping hashing, no key found in $(private_key)."
endif
2018-08-19 20:18:53 +00:00
# Command for running VUE tests
.PHONY: test
test:
2018-08-19 20:18:53 +00:00
$(npm) run test