-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
123 lines (103 loc) · 3.51 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
.DEFAULT_GOAL := help
MODULE_NAME := DubasShortUrl
.PHONY: requirements
requirements: ## Install requirements
@if [ ! -d "vendor" ]; then composer install --quiet; fi
@if [ ! -d "node_modules" ]; then npm ci --silent --no-update-notifier; fi
@if [ -f "src/files/custom/Espo/Modules/${MODULE_NAME}/composer.json" ] && \
[ ! -d "src/files/custom/Espo/Modules/${MODULE_NAME}/vendor" ]; \
then cd "src/files/custom/Espo/Modules/${MODULE_NAME}" && composer install --quiet; \
fi
.PHONY: up
up: ## Start environment
@docker compose pull --quiet
@docker compose up --detach --remove-orphans
.PHONY: full
full: requirements up ## Build full environment
@echo "Building full environment..."
@if [ ! -f config.php ]; then cp config.dist.php config.php; fi
@docker compose exec --user devilbox php node build --all
@$(MAKE) import --no-print-directory
@echo "Done."
@echo "Open http://localhost:$(shell docker compose port httpd 80 | awk -F: '{print $$2}') in your browser."
.PHONY: package
package: requirements ## Build extension package
@node build --extension
.PHONY: copy
copy: requirements ## Copy extension
@echo "Copying extension..."
@node build --copy
.PHONY: cc
cc: copy ## Copy extension and clear cache
@echo "Clearing cache..."
@docker compose exec --user devilbox php sh -c ' \
cd site; php clear_cache.php \
'
@echo "Done."
.PHONY: cr
cr: copy ## Copy extension and rebuild
@echo "Rebuilding..."
@docker compose exec --user devilbox php sh -c ' \
cd site; php rebuild.php; \
'
@echo "Done."
.PHONY: config
config: ## Merge config files
@echo "Merging config files..."
@if [ ! -f config.php ]; then cp config.dist.php config.php; fi
@docker compose exec --user devilbox php sh -c ' \
cd php_scripts; php merge_configs.php; \
'
@echo "Done."
.PHONY: import
import: ## Import test data
@docker compose exec --user devilbox php sh -c ' \
cd php_scripts; php import.php; \
'
.PHONY: before-install
before-install: ## Run before install
@docker compose exec --user devilbox php sh -c ' \
cd php_scripts; php before_install.php; \
'
.PHONY: after-install
after-install: ## Run after install
@docker compose exec --user devilbox php sh -c ' \
cd php_scripts; php after_install.php; \
'
.PHONY: before-uninstall
before-uninstall: ## Run before uninstall
@docker compose exec --user devilbox php sh -c ' \
cd php_scripts; php before_uninstall.php; \
'
.PHONY: ecs
ecs: requirements ## Fix PHP code style
@vendor/bin/ecs check --clear-cache --fix
.PHONY: phpstan
phpstan: requirements ## Run PHPStan
@vendor/bin/phpstan
.PHONY: prepare-tests
prepare-tests: ## Prepare test environment
@docker compose exec --user devilbox php sh -c ' \
cd site && npm ci && npx grunt test; \
'
.PHONY: test
test: ## Run unit tests
@docker compose exec --user devilbox php sh -c ' \
$(MAKE) copy --no-print-directory; \
cd site; vendor/bin/phpunit tests/unit/Espo/Modules/$(MODULE_NAME) ; \
'
.PHONY: test-integration
test-integration: ## Run integration tests
@docker compose exec --user devilbox php sh -c ' \
$(MAKE) copy --no-print-directory; \
cd site && vendor/bin/phpunit tests/integration/Espo/Modules/$(MODULE_NAME); \
'
.PHONY: clean
clean: ## Clean up
@echo "Stop, remove containers and volumes, and clean up..."
@docker compose down --volumes --remove-orphans
@rm --recursive --force site
@if [ -d .git ]; then git clean -fdX; fi
@echo "Done."
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'