-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
executable file
·130 lines (105 loc) · 3.23 KB
/
Makefile
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
# This file is licensed under the Affero General Public License version 3 or
# later. See the COPYING file.
VERSION?=$(shell sed -ne 's/^\s*<version>\(.*\)<\/version>/\1/p' appinfo/info.xml)
composer=$(shell which composer 2> /dev/null)
# Internal variables
APP_NAME:=$(notdir $(CURDIR))
PROJECT_DIR:=$(CURDIR)/../$(APP_NAME)
BIN_DIR:=$(CURDIR)/bin
BUILD_DIR:=$(CURDIR)/build
BUILD_TOOLS_DIR:=$(BUILD_DIR)/tools
RELEASE_DIR:=$(BUILD_DIR)/release
CERT_DIR:=$(HOME)/.keys
OCC?=php ../../occ
all: dev-setup lint build-js-production test
# Dev env management
dev-setup: clean clean-dev composer npm-init
build-docs:
composer install --ignore-platform-reqs \
&& php "$(BIN_DIR)/generate_docs.php" \
&& composer install --ignore-platform-reqs --no-dev
# Installs and updates the composer dependencies. If composer is not installed
# a copy is fetched from the web
composer:
ifeq (, $(composer))
@echo "No composer command available, downloading a copy from the web"
mkdir -p $(BUILD_TOOLS_DIR)
curl -sS https://getcomposer.org/installer | php
mv composer.phar $(BUILD_TOOLS_DIR)
php $(BUILD_TOOLS_DIR)/composer.phar install --prefer-dist --ignore-platform-reqs --no-dev
else
composer install --prefer-dist --ignore-platform-reqs --no-dev
endif
npm-init:
npm ci
npm-update:
npm update
# Building
build-js:
npm run dev
build-js-production:
npm run build
watch-js:
npm run watch
serve-js:
npm run serve
# Linting
lint:
npm run lint
lint-fix:
npm run lint:fix
# Style linting
stylelint:
npm run stylelint
stylelint-fix:
npm run stylelint:fix
# Cleaning
clean:
rm -rf js/*
clean-dev:
rm -rf node_modules
# Tests
test:
./vendor/phpunit/phpunit/phpunit -c phpunit.xml
./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
test-php-integration:
$(CURDIR)/vendor/bin/behat --config=tests/integration/config/behat.yml
prepare-build:
mkdir -p $(RELEASE_DIR)
rsync -a --delete --delete-excluded --verbose\
--exclude=".[a-z]*" \
--exclude="Makefile" \
--exclude="Dockerfile" \
--exclude /$(APP_NAME)/build \
--exclude /$(APP_NAME)/docs \
--exclude /$(APP_NAME)/screenshots \
--exclude /$(APP_NAME)/bin \
--exclude /$(APP_NAME)/src \
--exclude /$(APP_NAME)/node_modules \
--exclude /$(APP_NAME)/tests \
--exclude="composer.*" \
--exclude="package*.json" \
--exclude="*config.js" \
--exclude="*config.json" \
$(PROJECT_DIR) $(RELEASE_DIR)/ \
&& chmod -R 777 $(RELEASE_DIR)/
# Signs the build files
sign-build:
echo "Signing app files…"; \
sudo -u \#33 -- $(OCC) integrity:sign-app --privateKey="$(CERT_DIR)/$(APP_NAME).key" \
--certificate="$(CERT_DIR)/$(APP_NAME).crt" \
--path="$(RELEASE_DIR)/$(APP_NAME)";
# Packages the build into a release tarball, then signs the tarball.
package-build:
tar -czf $(RELEASE_DIR)/$(APP_NAME)-$(VERSION).tar.gz \
-C $(RELEASE_DIR) $(APP_NAME)
# Sign the release tarball
sign-tar:
echo "Signing release tarball…"; \
openssl dgst -sha512 -sign $(CERT_DIR)/$(APP_NAME).key \
$(RELEASE_DIR)/$(APP_NAME)-$(VERSION).tar.gz | openssl base64;
# Deletes any unnecessary files after the build is completed
clean-up-build:
rm -rf $(RELEASE_DIR)/$(APP_NAME)
# Build a release package
build: npm-init build-js-production composer prepare-build sign-build package-build sign-tar clean-up-build