-
Notifications
You must be signed in to change notification settings - Fork 58
/
Makefile
109 lines (90 loc) · 2.79 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
VERSION = $(shell cat composer.json | sed -n 's/.*"version": "\([^"]*\)"/\1/p')
SHELL = /usr/bin/env bash
XDSWI := $(shell command -v xd_swi 2> /dev/null)
XDSWI_STATUS:=$(shell command xd_swi stat 2> /dev/null)
CURRENT_FOLDER:=$(shell command pwd 2> /dev/null)
HAS_PHPMD := $(shell command -v phpmd 2> /dev/null)
HAS_CSFIXER:= $(shell command -v php-cs-fixer 2> /dev/null)
HAS_PSALM:=$(shell command -v psalm stat 2> /dev/null)
HAS_PHPCPD:=$(shell command -v phpcpd 2> /dev/null)
YELLOW=\033[0;33m
RED=\033[0;31m
WHITE=\033[1m
RESET=\033[0m
GREEN=\u001B[32m
ifneq ($(g),)
groups=-g
endif
ifeq ($(target),)
target=src
endif
default: clean
.PHONY: version install test tag start csfixer
version:
@echo $(VERSION)
install:
composer install --no-dev
test:
@if [[ "$(XDSWI)" != "" ]]; then \
echo -e "$(WHITE)XDebug state is$(RESET) $(XDSWI_STATUS)" ;\
fi ;\
xd_swi off ;\
php vendor/bin/codecept run unit $(test) $(groups) $(g) --debug ;\
echo seting XDebug to initial state $(XDSWI_STATUS) ;\
xd_swi $(XDSWI_STATUS)
test_coverage:
@if [[ "$(XDSWI)" != "" ]]; then \
echo -e "$(WHITE)XDebug state is$(RESET) $(XDSWI_STATUS)" ;\
fi ;\
xd_swi on ;\
php vendor/bin/codecept run unit $(test) --coverage-html ;\
echo seting XDebug to initial state $(XDSWI_STATUS) ;\
xd_swi $(XDSWI_STATUS)
update_version:
@echo "Current version is " ${VERSION}
@echo "Next version is " $(v)
@sed -i s/'"$(VERSION)"'/'"$(v)"'/ composer.json
@sed -i s/'"$(VERSION)"'/'"$(v)"'/ README.md
composer update nothing --lock --root-reqs
tag_and_push:
git add --all
git commit -a -m "Tag v $(v) $(m)"
git tag v$(v)
git push
git push --tags
tag: test update_version csfixer tag_and_push
delete_tag:
git tag -d $(v)
git push origin :refs/tags/$(v)
start:
php -S localhost:8000 -t Examples
runcsfixer:
@if [[ "$(HAS_CSFIXER)" == "" ]]; then \
echo -e "$(GREEN)php-cs-fixer$(WHITE) is $(RED)NOT$(WHITE) installed. " ;\
echo -e "Install it with $(GREEN)phive install php-cs-fixer$(WHITE)" ;\
else \
php-cs-fixer --verbose fix --using-cache no;\
fi
csfixer:
@if [[ "$(XDSWI)" == "" ]]; then \
${MAKE} runcsfixer --no-print-directory ;\
else \
xd_swi off ;\
${MAKE} runcsfixer --no-print-directory ;\
xd_swi $(XDSWI_STATUS) ;\
fi
phpmd:
@if [ "$(HAS_PHPMD)" == "" ]; then \
echo -e "$(GREEN)phpmd$(WHITE) is $(RED)NOT$(WHITE) installed. " ;\
echo -e "Install it with $(GREEN)phive install phpmd$(WHITE)" ;\
else \
phpmd src text .phpmd.xml | sed "s/.*\///" ;\
fi ;\
echo ""
phpcpd:
@if ["$(HAS_PHPCPD)" == "" ]; then \
echo -e "$(GREEN)phpcpd$(WHITE) is $(RED)NOT$(WHITE) installed. Install it with $(GREEN)phive install phpcpd$(WHITE)" ;\
else \
phpcpd --fuzzy --ansi --log-pmd=.pmd.log $(target) ;\
fi ;\
echo ""