-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
146 lines (127 loc) · 3.74 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
.DEFAULT_GOAL := help
USER = $(shell id -u):$(shell id -g)
DOCKER_COMPOSE = docker compose -f docker/development/docker-compose.yml
ifdef NO_DOCKER
PHP = php
COMPOSER = composer
NPM = npm
CLI = php cli
else
PHP = ./docker/bin/php
COMPOSER = ./docker/bin/composer
NPM = ./docker/bin/npm
CLI = ./docker/bin/cli
endif
.PHONY: docker-start
docker-start: PORT ?= 8000
docker-start: .env ## Start a development server (can take a PORT argument)
@echo "Running webserver on http://localhost:$(PORT)"
$(DOCKER_COMPOSE) up
.PHONY: docker-build
docker-build: ## Rebuild the Docker images
$(DOCKER_COMPOSE) build --pull
.PHONY: docker-pull
docker-pull: ## Pull the Docker images from the Docker Hub
$(DOCKER_COMPOSE) pull --ignore-buildable
.PHONY: docker-clean
docker-clean: ## Clean the Docker stuff
$(DOCKER_COMPOSE) down -v
.PHONY: install
install: INSTALLER ?= all
install: ## Install the dependencies (can take an INSTALLER argument)
ifeq ($(INSTALLER), $(filter $(INSTALLER), all composer))
$(COMPOSER) install
endif
ifeq ($(INSTALLER), $(filter $(INSTALLER), all npm))
$(NPM) install
endif
.PHONY: db-setup
db-setup: .env ## Setup and migrate the application system
$(CLI) migrations setup --seed
.PHONY: db-rollback
db-rollback: ## Reverse the last migration (can take a STEPS argument)
ifdef STEPS
$(CLI) migrations rollback --steps=$(STEPS)
else
$(CLI) migrations rollback
endif
.PHONY: db-reset
db-reset: ## Reset the database (take a FORCE argument)
ifndef FORCE
$(error Please run the operation with FORCE=true)
endif
ifndef NO_DOCKER
$(DOCKER_COMPOSE) stop job_worker
endif
$(CLI) migrations reset --force --seed
ifndef NO_DOCKER
$(DOCKER_COMPOSE) start job_worker
endif
.PHONY: icons
icons: ## Build the icons asset
$(NPM) run build:icons
.PHONY: test
test: FILE ?= ./tests
ifdef FILTER
test: override FILTER := --filter=$(FILTER)
endif
test: COVERAGE ?= --coverage-html ./coverage
test: ## Run the test suite (can take FILE, FILTER and COVERAGE arguments)
$(PHP) ./vendor/bin/phpunit \
-c .phpunit.xml \
$(COVERAGE) \
$(FILTER) \
$(FILE)
.PHONY: lint
lint: LINTER ?= all
lint: ## Execute the linters (can take a LINTER argument)
ifeq ($(LINTER), $(filter $(LINTER), all phpstan))
$(PHP) vendor/bin/phpstan analyse --memory-limit 1G -c .phpstan.neon
endif
ifeq ($(LINTER), $(filter $(LINTER), all rector))
$(PHP) vendor/bin/rector process --dry-run --config .rector.php
endif
ifeq ($(LINTER), $(filter $(LINTER), all phpcs))
$(PHP) vendor/bin/phpcs
endif
ifeq ($(LINTER), $(filter $(LINTER), all js))
$(NPM) run lint-js
endif
ifeq ($(LINTER), $(filter $(LINTER), all css))
$(NPM) run lint-css
endif
.PHONY: lint-fix
lint-fix: LINTER ?= all
lint-fix: ## Fix the errors detected by the linters (can take a LINTER argument)
ifeq ($(LINTER), $(filter $(LINTER), all rector))
$(PHP) vendor/bin/rector process --config .rector.php
endif
ifeq ($(LINTER), $(filter $(LINTER), all phpcs))
$(PHP) vendor/bin/phpcbf
endif
ifeq ($(LINTER), $(filter $(LINTER), all js))
$(NPM) run lint-js-fix
endif
ifeq ($(LINTER), $(filter $(LINTER), all css))
$(NPM) run lint-css-fix
endif
.PHONY: release
release: ## Release a new version (take a VERSION argument)
ifndef VERSION
$(error You need to provide a "VERSION" argument)
endif
echo $(VERSION) > VERSION.txt
rm -rf public/assets/*
$(NPM) run build
$(EDITOR) CHANGELOG.md
git add .
git commit -m "release: Publish version v$(VERSION)"
git tag -a v$(VERSION) -m "Release version v$(VERSION)"
.PHONY: tree
tree: ## Display the structure of the application
tree -I 'Minz|vendor|node_modules|coverage|cache|dev_assets|media' --dirsfirst -CA
.PHONY: help
help:
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.env:
@cp env.sample .env