This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
133 lines (98 loc) · 2.92 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
# Tutorial: http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
# Docs: https://www.gnu.org/software/make/
# Help
.PHONY: help
help:
$(info Run `make setup` to configure the Git Hooks and install the dependencies`)
$(info Run `make install` to install the dependencies)
$(info Run `make install-prod` to install the dependencies in production mode)
$(info - Run `make composer-install` to only install Composer dependencies)
$(info - Run `make composer-install-prod` to only install Composer dependencies in production mode)
$(info - Run `make npm-install` to only install Node dependencies)
$(info - Run `make npm-install-prod` to only install Node dependencies in production mode)
$(info Run `make tests` to run all tests)
$(info - Run `make jest` to run only Jest tests)
$(info - Run `make phpunit` to run only PhpUnit tests)
$(info Run `make dev` to bundle WebPack modules in development mode)
$(info Run `make prod` to bundle WebPack modules in production mode)
# Setup
.PHONY: setup githooks
setup:: githooks
setup:: install
githooks:
ifdef CI
$(info Skipping Git Hooks in CI)
else ifdef OS
cp .githooks/* .git/hooks/
$(info Looks like you are on Windows... files copied.)
else
@find .git/hooks -type l -exec rm {} \;
@find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
$(info Git Hooks installed)
endif
# Install
.PHONY: install
install: composer-install
install: npm-install
install-prod: composer-install-prod
install-prod: npm-install-prod
# Build
.PHONY: dev prod
dev prod: npm-install
@npm run build:$@
$(info WebPack modules bundled)
# Tests
.PHONY: tests
tests:: jest
tests:: phpunit
# Git Hooks
.PHONY: precommit
precommit:: validate-composer
precommit:: validate-npm
precommit:: dupes
precommit:: compatibility
# precommit
.PHONY: dupes compatibility validate-composer validate-npm
dupes: composer-install
./.make/check-duplicates.sh
compatibility: composer-install
./.make/check-compatibility.sh
validate-composer: composer-install
./.make/check-composer.sh
validate-npm: npm-install
./.make/check-npm.sh
# Dependency managers
## Composer
.PHONY: composer-install
composer.lock: composer-install
@touch $@
vendor/autoload.php: composer-install
@touch $@
composer-install:
$(info Installing Composer dependencies)
@composer install
composer-install-prod:
$(info Installing Composer dependencies)
@composer --no-dev install
## NPM
.PHONY: npm-install
package.json: npm-install
@touch $@
package-lock.json: npm-install
@touch $@
npm-install:
$(info Installing Node dependencies)
@npm install
npm-install-prod:
$(info Installing Node dependencies)
@npm --prod install
# Tests
.PHONY: jest phpunit
jest: npm-install
$(info Running Jest)
@npm run test
phpunit: composer-install
$(info Running PhpUnit)
@vendor/bin/phpunit --fail-on-warning
# Use the following if the phpunit.xml is on a different location
# @vendor/bin/phpunit --fail-on-warning --configuration tests/phpunit/phpunit.xml