generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
165 lines (138 loc) · 4.77 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
##############################################################################
# Run:
# make
# make start
#
# Go to:
#
# http://localhost:3000
#
# Cypress:
#
# make cypress-open
#
##############################################################################
# SETUP MAKE
#
## Defensive settings for make: https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
# for Makefile debugging purposes add -x to the .SHELLFLAGS
.SHELLFLAGS:=-eu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
# Colors
# OK=Green, warn=yellow, error=red
ifeq ($(TERM),)
# no colors if not in terminal
MARK_COLOR=
OK_COLOR=
WARN_COLOR=
ERROR_COLOR=
NO_COLOR=
else
MARK_COLOR=`tput setaf 6`
OK_COLOR=`tput setaf 2`
WARN_COLOR=`tput setaf 3`
ERROR_COLOR=`tput setaf 1`
NO_COLOR=`tput sgr0`
endif
##############################################################################
# SETTINGS AND VARIABLE
DIR=$(shell basename $$(pwd))
NODE_MODULES?="../../../node_modules"
PLONE_VERSION?=6
VOLTO_VERSION?=17
ADDON_PATH="${DIR}"
ADDON_NAME="@eeacms/${ADDON_PATH}"
DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose
RAZZLE_INTERNAL_API_PATH?="http://localhost:8080/Plone"
RAZZLE_DEV_PROXY_API_PATH?="${RAZZLE_INTERNAL_API_PATH}"
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}"
# Top-level targets
.PHONY: all
all: clean install
.PHONY: clean
clean: ## Cleanup development environment
${DOCKER_COMPOSE} down --volumes --remove-orphans
.PHONY: install
install: ## Build and install development environment
echo "Running: ${DOCKER_COMPOSE} build"
${DOCKER_COMPOSE} pull
${DOCKER_COMPOSE} build
.PHONY: start
start: ## Start development environment
echo "Running: ${DOCKER_COMPOSE} up"
${DOCKER_COMPOSE} up
.PHONY: shell
shell: ## Start a shell in the frontend container
echo "Running: ${DOCKER_COMPOSE} run frontend bash"
${DOCKER_COMPOSE} run --entrypoint=bash frontend
.PHONY: cypress-open
cypress-open: ## Open cypress integration tests
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open
.PHONY: cypress-run
cypress-run: ## Run cypress integration tests
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run
.PHONY: test
test: ## Run jest tests
${DOCKER_COMPOSE} run -e CI=1 frontend test
.PHONY: test-update
test-update: ## Update jest tests snapshots
${DOCKER_COMPOSE} run -e CI=1 frontend test -u
.PHONY: stylelint
stylelint: ## Stylelint
$(NODE_MODULES)/.bin/stylelint --allow-empty-input 'src/**/*.{css,less}'
.PHONY: stylelint-overrides
stylelint-overrides:
$(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'
.PHONY: stylelint-fix
stylelint-fix: ## Fix stylelint
$(NODE_MODULES)/.bin/stylelint --allow-empty-input 'src/**/*.{css,less}' --fix
$(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix
.PHONY: prettier
prettier: ## Prettier
$(NODE_MODULES)/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'
.PHONY: prettier-fix
prettier-fix: ## Fix prettier
$(NODE_MODULES)/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'
.PHONY: lint
lint: ## ES Lint
$(NODE_MODULES)/.bin/eslint --max-warnings=0 'src/**/*.{js,jsx}'
.PHONY: lint-fix
lint-fix: ## Fix ES Lint
$(NODE_MODULES)/.bin/eslint --fix 'src/**/*.{js,jsx}'
.PHONY: i18n
i18n: ## i18n
rm -rf build/messages
NODE_ENV=development $(NODE_MODULES)/.bin/i18n --addon
.PHONY: help
help: ## Show this help.
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
head -n 14 Makefile
.PHONY: ci-fix
ci-fix:
echo "Running lint-fix"
make lint-fix
echo "Running prettier-fix"
make prettier-fix
echo "Running stylelint-fix"
make stylelint-fix
.PHONY: test-ci
test-ci:
cd /app
RAZZLE_JEST_CONFIG=src/addons/${ADDON_PATH}/jest-addon.config.js CI=true yarn test src/addons/${ADDON_PATH}/src --watchAll=false --reporters=default --reporters=jest-junit --collectCoverage --coverageReporters lcov cobertura text
.PHONY: start-ci
start-ci:
cp .coverage.babel.config.js /app/babel.config.js
cd ../..
yarn start
.PHONY: check-ci
check-ci:
$(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000
.PHONY: cypress-ci
cypress-ci:
$(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium