~cypheon/nextcloud-chores-app

ref: d19a6603c01e63c7545582e5ff313ef4aec0bf9f nextcloud-chores-app/Makefile -rw-r--r-- 3.1 KiB
d19a6603 — Johann Rudloff Make overdue sidebar badge dynamic, switch badges to `CounterBubble` component 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# This file is licensed under the Affero General Public License version 3 or
# later. See the COPYING file.
# @author Johann Rudloff <johann@sinyax.net>
# @copyright Johann Rudloff 2021
# original file:
# @author Bernhard Posselt <dev@bernhard-posselt.com>
# @copyright Bernhard Posselt 2016

# Dependencies:
# * make
# * tar: for building the archive
# * npm: for building and testing everything JS
#
# The npm command by launches the npm build script:
#
#    npm run build
#

app_name=chores
build_tools_directory=$(CURDIR)/build/tools
source_build_directory=$(CURDIR)/build/artifacts/source
source_package_name=$(source_build_directory)/$(app_name)
appstore_build_directory=$(CURDIR)/build/artifacts/appstore
appstore_package_name=$(appstore_build_directory)/$(app_name)
npm=$(shell command -v npm 2> /dev/null)
composer=$(shell command -v composer 2> /dev/null)

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
# is present, the npm step is skipped
.PHONY: build
build: composer npm

# Installs and updates the composer dependencies. If composer is not installed
# a copy is fetched from the web
.PHONY: composer
composer:
	composer install --prefer-dist

# Build frontend
.PHONY: npm
npm:
	npm run build

# Removes the appstore build
.PHONY: clean
clean:
	rm -rf ./build ./dist

.PHONY: check-appinfo
check-appinfo:
	mkdir -p build
	test -f build/info.xsd || wget -O build/info.xsd https://apps.nextcloud.com/schema/apps/info.xsd
	xmllint --schema build/info.xsd --noout appinfo/info.xml

# Same as clean but also removes dependencies installed by composer, bower and
# npm
.PHONY: distclean
distclean: clean
	rm -rf vendor
	rm -rf node_modules

# Builds the source and appstore package
.PHONY: dist
dist:
	make source
	make appstore

# Builds the source package
.PHONY: source
source:
	rm -rf $(source_build_directory)
	mkdir -p $(source_build_directory)
	tar cvzf $(source_package_name).tar.gz $(shell git ls-tree --name-only -r HEAD)

# Builds the source package for the app store, ignores php and js tests
.PHONY: appstore
appstore:
	rm -rf $(appstore_build_directory)
	mkdir -p $(appstore_build_directory)/$(app_name)
	mkdir -p $(appstore_build_directory)/$(app_name)/css
	cp -av dist/css/app.css $(appstore_build_directory)/$(app_name)/css
	mkdir -p $(appstore_build_directory)/$(app_name)/img
	cp -av img/app.svg $(appstore_build_directory)/$(app_name)/img
	mkdir -p $(appstore_build_directory)/$(app_name)/js
	cp -av dist/js/{app,chunk-vendors}.js $(appstore_build_directory)/$(app_name)/js
	cp -av {appinfo,lib,templates} $(appstore_build_directory)/$(app_name)/
	find $(appstore_build_directory)/$(app_name) -iname \*.swp -delete
	tar cvzf $(appstore_package_name).tar.gz -C $(appstore_build_directory) $(app_name)
	rm -rf $(appstore_build_directory)/$(app_name)

.PHONY: lint-php
lint-php: composer
	$(CURDIR)/vendor/bin/psalm --no-cache

.PHONY: lint
lint: check-appinfo lint-php

.PHONY: test
test: composer
	$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.xml
	$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml