-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
168 lines (132 loc) · 4 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
#
# Optionally include a .env to provide secrets and local config options.
#
-include .env
#
# You can choose to use Docker for local development by specifying the USE_DOCKER=1 environment variable in
# your project .env file.
#
USE_DOCKER ?= 0
#
# Ensure the local environment has the right binaries installed.
#
REQUIRED_BINS := composer npm node php yarn
$(foreach bin,$(REQUIRED_BINS),\
$(if $(shell command -v $(bin) 2> /dev/null),,$(error Please install `$(bin)`)))
#
# Default is what happens if you only type make.
#
default: install build start
#
# Bring in the external project dependencies.
#
install:
composer install
yarn
#
# Start the local development server.
#
start:
ifeq ("${USE_DOCKER}","1")
@echo Bringing docker containers up
docker-compose up -d
docker-compose ps
else
./node_modules/.bin/concurrently \
-n "webpack,drupal" \
-c "yellow,cyan" \
--kill-others \
--handle-input \
"./node_modules/.bin/webpack -wd" \
"./vendor/bin/drush runserver"
endif
stop:
ifeq ("${USE_DOCKER}","1")
docker-compose down --remove-orphans
endif
restart: stop start
#
# Build stages: Setup and configure the application for the environment.
#
build: install-drupal
install-drupal:
ifeq ("${USE_DOCKER}","1")
mv src/backend/settings/99-installation.settings.inc.hide src/backend/settings/99-installation.settings.inc
./drush.wrapper @docker si contenta_jsonapi --yes
mv src/backend/settings/99-installation.settings.inc src/backend/settings/99-installation.settings.inc.hide
./drush.wrapper @docker cim --yes
else
mv src/backend/settings/99-installation.settings.inc.hide src/backend/settings/99-installation.settings.inc
./vendor/bin/drush si contenta_jsonapi --yes --db-url=sqlite://../local.sqlite
mv src/backend/settings/99-installation.settings.inc src/backend/settings/99-installation.settings.inc.hide
./vendor/bin/drush cim --yes
endif
#
# Linting / testing / formatting.
#
lint:
./node_modules/.bin/tsc && ./node_modules/.bin/eslint --ext .js,.jsx,.ts,.tsx ./src/frontend/
test:
./node_modules/.bin/jest ./src/frontend
format:
./node_modules/.bin/prettier ./src/frontend/**/*.{ts,tsx,js,jsx} --write
#
# Delete all non version controlled files to reset the project.
#
clean: clean--reset-installation-file
rm -rf docroot vendor node_modules dist
clean--reset-installation-file:
ifneq (,$(wildcard ${PWD}/src/settings/99-installation.settings.inc))
mv src/settings/99-installation.settings.inc src/settings/99-installation.settings.inc.hide
endif
#
# Generate project symlinks and other disposable assets and wiring.
#
.persist/public:
ifeq ("${USE_DOCKER}","1")
mkdir -p .persist/public
endif
.persist/private:
ifeq ("${USE_DOCKER}","1")
mkdir -p .persist/private
endif
docroot/sites/default/files/:
ifeq ("${USE_DOCKER}","1")
ln -s ../../../.persist/public docroot/sites/default/files
endif
docroot/sites/default/files/tmp/:
mkdir -p docroot/sites/default/files/tmp/
docroot/sites/default/settings.php:
ln -s ../../../src/backend/settings/settings.php docroot/sites/default/settings.php
docroot/modules/custom:
ln -s ../../src/backend/modules $@
docroot/themes/custom:
ln -s ../../src/backend/themes $@
docroot/profiles/custom:
ln -s ../../src/backend/profiles $@
#
# Commands which get run from composer.json scripts section.
#
composer--post-install-cmd: composer--post-update-cmd
composer--post-update-cmd: .persist/public \
.persist/private \
docroot/sites/default/files/tmp/ \
docroot/sites/default/settings.php \
docroot/modules/custom \
docroot/profiles/custom \
docroot/themes/custom;
#
# Helper CLI commands.
#
sql-cli:
ifeq ("${USE_DOCKER}","1")
@docker-compose exec ${DB_HOST} mysql -u${DB_USER} -p${DB_PASSWORD} ${DB_NAME}
else
@echo "You need to use whatever sqlite uses..."
endif
logs:
ifeq ("${USE_DOCKER}","1")
docker-compose logs -f
else
@echo "You need to use whatever sqlite uses..."
endif