-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (139 loc) · 4.97 KB
/
Makefile
File metadata and controls
153 lines (139 loc) · 4.97 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# SPDX-FileCopyrightText: Bernhard Posselt <dev@bernhard-posselt.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
app_directory_name=$(notdir $(CURDIR))
app_real_name=gdatavaas
build_tools_directory=$(CURDIR)/build/tools
source_build_directory=./build/artifacts/source
source_package_name=$(source_build_directory)/$(app_directory_name)
appstore_build_directory=$(CURDIR)/build/artifacts
appstore_package_name=$(appstore_build_directory)/$(app_real_name)
npm=$(shell which npm 2> /dev/null)
composer=$(shell which composer 2> /dev/null)
all: build
# Fetches dependencies and builds it
.PHONY: build
build: oc
ifneq (,$(wildcard $(CURDIR)/composer.json))
make composer
endif
ifneq (,$(wildcard $(CURDIR)/package.json))
make npm
endif
ifneq (,$(wildcard $(CURDIR)/js/package.json))
make npm
endif
# Clone Nextcloud server to know private OC namespace
.PHONY: oc
oc:
ifeq (,$(wildcard nextcloud-server))
./scripts/get-nc-server.sh
endif
# Installs and updates the composer dependencies. If composer is not installed
# a copy is fetched from the web
.PHONY: composer
composer: oc
ifeq (,$(composer))
@echo "No composer command available, downloading a copy from the web"
mkdir -p $(build_tools_directory)
curl -sS https://getcomposer.org/installer | php
mv composer.phar $(build_tools_directory)
php $(build_tools_directory)/composer.phar install --prefer-dist --no-dev
else
composer install --prefer-dist --no-dev
endif
# Installs npm dependencies and builds the js code
.PHONY: npm
npm:
ifeq (,$(wildcard $(CURDIR)/package.json))
ifeq (,$(wildcard $(CURDIR)/package-lock.json))
npm install --no-audit --progress=false
else
npm ci
endif
cd js && $(npm) run build
else
ifeq (,$(wildcard $(CURDIR)/package-lock.json))
npm install --no-audit --progress=false
else
npm ci
endif
npm run build
endif
# Removes the appstore build
.PHONY: clean
clean:
rm -rf ./build
# Run unit tests
.PHONY: unittests
unittests:
composer install
./vendor/bin/phpunit --bootstrap tests/unittests/bootstrap.php tests/unittests/ --testdox
# Run integration tests
.PHONY: integrationtests
integrationtests:
./scripts/run-app.sh "32.0.0" 1
composer install
./vendor/bin/phpunit -c tests/integration/phpunit.xml tests/integration/ --testdox
# Run bats tests
.PHONY: bats
bats:
./scripts/run-app.sh "32.0.0" 1
bats --verbose-run --timing --trace ./tests/bats
# Complete production like but static Nextcloud and app setup
.PHONY: prod
prod: oc
./scripts/run-app.sh "32.0.0" 1
# Same as clean but also removes dependencies and build related folders
.PHONY: distclean
distclean: clean
rm -rf vendor
rm -rf node_modules
rm -rf js/vendor
rm -rf js/node_modules
rm -rf build
rm -f composer.lock
# Builds the app in a Docker container and serves it on localhost:8080
.PHONY: local
local: build
docker compose kill || true
docker stop nextcloud-container || true
docker container rm nextcloud-container || true
docker run --rm -d -p 8080:80 --name nextcloud-container -e SERVER_BRANCH="v32.0.0" -v .:/var/www/html/apps-extra/gdatavaas ghcr.io/juliusknorr/nextcloud-dev-php84:latest
composer install
# Builds the app for production and prepares it for the appstore under ./build/artifacts
.PHONY: appstore
appstore: build
rm -rf $(appstore_build_directory)
mkdir -p $(appstore_build_directory)
php-scoper add-prefix --output-dir=$(source_build_directory) --force
composer dump-autoload --working-dir $(source_build_directory) --classmap-authoritative
tar czf $(appstore_package_name).tar.gz \
--transform s%$(source_build_directory)%$(app_real_name)% \
--exclude-vcs \
--exclude="$(source_build_directory)/.git" \
--exclude="$(source_build_directory)/.github" \
--exclude="$(source_build_directory)/nextcloud-server" \
--exclude="$(source_build_directory)/composer.json" \
--exclude="$(source_build_directory)/composer.json.license" \
--exclude="$(source_build_directory)/babel.config.js" \
--exclude="$(source_build_directory)/.editorconfig" \
--exclude="$(source_build_directory)/.gitignore" \
--exclude="$(source_build_directory)/.php-cs-fixer.dist.php" \
--exclude="$(source_build_directory)/.php-cs-fixer.cache" \
--exclude="$(source_build_directory)/Makefile" \
--exclude="$(source_build_directory)/package.json" \
--exclude="$(source_build_directory)/package-lock.json" \
--exclude="$(source_build_directory)/package-lock.json.license" \
--exclude="$(source_build_directory)/package.json.license" \
--exclude="$(source_build_directory)/psalm.xml" \
--exclude="$(source_build_directory)/webpack.config.json" \
--exclude="$(source_build_directory)/stylelint.config.json" \
--exclude="$(source_build_directory)/empty-skeleton.config.php" \
--exclude="$(source_build_directory)/scoper.inc.php" \
--exclude="$(source_build_directory)/renovate.json" \
--exclude="$(source_build_directory)/renovate.json.license" \
--exclude="$(source_build_directory)/scripts" \
--exclude="$(source_build_directory)/src" \
--exclude="$(source_build_directory)/docker-compose.yaml" \
--exclude="$(source_build_directory)/composer.lock" \
$(source_build_directory) \