forked from sitegeist/sitegeist-neos-base-distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
200 lines (163 loc) · 7.08 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
###############################################################################
###############################################################################
## ##
## Sitegeist Neos Base Distribution ##
## ##
###############################################################################
###############################################################################
#
# @author Wilhelm Behncke <[email protected]>
#
###############################################################################
# VARIABLES #
###############################################################################
SHELL=/bin/bash
COMPOSE_EXEC_ROOT=docker-compose exec -T --user root php-fpm
export TS_NODE_PROJECT=./tsconfig.json
export HOST_USER=$(shell id -u)
export HOST_GROUP=$(shell id -g)
export PATH := ./node_modules/.bin:./bin:$(PATH)
COMPOSE_EXEC=docker-compose exec -T --user $(HOST_USER) php-fpm ssh-agent
-include ./Build/config.makefile
-include $(DIR_CONFIG_GLOBAL)/before.makefile
-include $(DIR_CONFIG_LOCAL)/before.makefile
###############################################################################
# README #
###############################################################################
.DEFAULT:
readme::
@printf "\n"
@printf "\t\t\t\033[0;1mSitegeist Neos Base Distribution\033[0m\n"
@printf "\n"
@printf " Available Targets\n"
@printf " --------------------------------------------------------------------\n"
@printf "\033[0;1m install \033[0m \t Install the project\n"
@printf "\033[0;1m cleanup \033[0m \t Cleanup all files and make a fresh install\n"
@printf "\033[0;1m lint \033[0m \t\t Lint all sources\n"
@printf "\033[0;1m build \033[0m \t Build Frontend\n"
@printf "\033[0;1m watch \033[0m \t Build Frontend (Watch Mode)\n"
@printf "\n"
###############################################################################
# INSTALL & CLEANUP #
###############################################################################
environment::
@docker --version
@docker-compose --version
@echo Node $$(node --version)
@echo Yarn $$(yarn --version)
@install-githooks::
@if [ -z $${CI+x} ]; then $(MAKE) environment; fi
@if [ -z $${CI+x} ]; then cp ./.git/hooks/pre-commit.sample ./.git/hooks/pre-commit && \
echo "make lint" >> ./.git/hooks/pre-commit; fi
@install-composer::
@$(COMPOSE_EXEC) composer install
@install-yarn::
@yarn install
@ln -sf ../node/bin/node ./node_modules/.bin/node
install::
@time $(MAKE) -s up
@time $(MAKE) -s -j 3 @install-githooks @install-composer @install-yarn
@time $(MAKE) -s -j 2 build flush
flush::
@$(COMPOSE_EXEC) ./flow flow:cache:flush --force
@$(COMPOSE_EXEC) ./flow flow:cache:warmup
@$(COMPOSE_EXEC) ./flow flow:package:rescan
@$(COMPOSE_EXEC) ./flow doctrine:migrate
@$(COMPOSE_EXEC) ./flow resource:publish
cleanup::
@rm -rf ./Data/Temporary/*
@rm -rf ./Packages/*
@rm -rf ./bin/*
@rm -rf node_modules/
@$(MAKE) install
###############################################################################
# LINTING & QA #
###############################################################################
lint-distribution::
@echo "Lint Distribution"
@./flow guidelines:validateDistribution && ./flow guidelines:validatePackages
lint-editorconfig::
@echo "Lint .editorconfig"
@editorconfig-checker -d -e 'Public|Sites.xml|.*.css.fusion|.*.css.json|.*.js.fusion' ./DistributionPackages/*
lint-php::
@echo "Lint PHP Sources"
@for package in DistributionPackages/*; do \
if [ -d "$$package/Classes" ]; \
then phpcs --standard=PSR2 $$package/Classes || exit 1; fi \
done
lint-css::
@echo "Lint CSS Sources"
@stylelint DistributionPackages/*/Resources/Private/**/*.css
lint-js::
@echo "Lint JavaScript Sources"
@eslint DistributionPackages/*/Resources/Private/**/*.js
lint::
@$(MAKE) -s lint-distribution
@$(MAKE) -s lint-editorconfig
@$(MAKE) -s lint-php
@$(MAKE) -s lint-css
@$(MAKE) -s lint-js
test-e2e::
@docker-compose exec testcafe /opt/testcafe/docker/testcafe-docker.sh 'chromium --no-sandbox' /tests/*.ts
test-component-semantics::
jest --verbose -t '#semantics'
###############################################################################
# FRONTEND BUILD #
###############################################################################
.PHONY: build
build::
@time webpack -p --hide-modules --mode production --optimize-dedupe --progress
watch::
@webpack --mode development -w
###############################################################################
# Docker #
###############################################################################
up::
@docker-compose up --force-recreate -d
@$(COMPOSE_EXEC_ROOT) mkdir -p /var/mail
@$(COMPOSE_EXEC_ROOT) mkdir -p /home/hostuser
@$(COMPOSE_EXEC_ROOT) useradd -u $(HOST_USER) hostuser
@$(COMPOSE_EXEC_ROOT) chown hostuser /home/hostuser
@$(COMPOSE_EXEC_ROOT) chmod -R 0777 /data
down::
@docker-compose down --remove-orphans
prune::
@docker-compose down --remove-orphans --volumes
restart::
$(MAKE) down
$(MAKE) up
logs::
@docker-compose logs -f
flow::
@docker-compose exec -T --user $(HOST_USER) php-fpm ssh-agent /project/flow $(FLOW_ARGS)
###############################################################################
# SSH #
###############################################################################
ssh::
docker-compose exec --user $(HOST_USER) php-fpm ssh-agent $(SHELL)
ssh-root::
docker-compose exec --user root php-fpm ssh-agent $(SHELL)
ssh-mariadb::
docker-compose exec mariadb $(SHELL) -c "mysql -uroot -p$(CRED_MYSQL_ROOT_PASSWORD) $(CRED_MYSQL_DATABASE)"
ssh-webserver::
docker-compose exec -w /etc/nginx webserver sh
###############################################################################
# CLONE #
###############################################################################
clone::
@docker-compose exec --user $(HOST_USER) php-fpm ssh-agent /bin/bash -c "\
./flow clone:list; \
./flow clone:preset $(preset) --yes"
###############################################################################
# DEPLOYMENT #
###############################################################################
deploy-develop::
@bin/dep deploy develop -vv --revision="develop"
deploy-staging::
@echo "ERROR: There's no stage deployment configured yet"
@exit 1
deploy-live::
@echo "ERROR: There's no live deployment configured yet"
@exit 1
-include $(DIR_CONFIG_GLOBAL)/after.makefile
-include $(DIR_CONFIG_LOCAL)/after.makefile