|
| 1 | +# Volto development |
| 2 | + |
| 3 | +### Defensive settings for make: |
| 4 | +# https://tech.davis-hansson.com/p/make/ |
| 5 | +SHELL:=bash |
| 6 | +.ONESHELL: |
| 7 | +.SHELLFLAGS:=-eu -o pipefail -c |
| 8 | +.SILENT: |
| 9 | +.DELETE_ON_ERROR: |
| 10 | +MAKEFLAGS+=--warn-undefined-variables |
| 11 | +MAKEFLAGS+=--no-builtin-rules |
| 12 | + |
| 13 | +# Project settings (read from repo root) |
| 14 | +include ../../variables.mk |
| 15 | + |
| 16 | +# Allow setting the language for backend-docker-start. Default is `en`. |
| 17 | +LANGUAGE ?=en |
| 18 | + |
| 19 | +# Recipe snippets for reuse |
| 20 | + |
| 21 | +CHECKOUT_BASENAME="$(shell basename $(shell realpath ./))" |
| 22 | +CHECKOUT_BRANCH=$(shell git branch --show-current) |
| 23 | +CHECKOUT_TMP=../$(CHECKOUT_BASENAME).tmp |
| 24 | +CHECKOUT_TMP_ABS="$(shell realpath $(CHECKOUT_TMP))" |
| 25 | + |
| 26 | +CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) |
| 27 | + |
| 28 | +# We like colors |
| 29 | +# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects |
| 30 | +RED=`tput setaf 1` |
| 31 | +GREEN=`tput setaf 2` |
| 32 | +RESET=`tput sgr0` |
| 33 | +YELLOW=`tput setaf 3` |
| 34 | + |
| 35 | + |
| 36 | +# Top-level targets |
| 37 | + |
| 38 | +.PHONY: all |
| 39 | +all: help |
| 40 | + |
| 41 | +# Add the following 'help' target to your Makefile |
| 42 | +# and add help text after each target name starting with ' ##' |
| 43 | +# to return a pretty list of targets and their descriptions. |
| 44 | +.PHONY: help |
| 45 | +help: ## This help message |
| 46 | + @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" |
| 47 | + |
| 48 | +.PHONY: start |
| 49 | +start: ## Starts Plone 7 in development mode |
| 50 | + pnpm start |
| 51 | + |
| 52 | +.PHONY: build |
| 53 | +build: ## Build a production bundle for distribution |
| 54 | + pnpm build |
| 55 | + |
| 56 | +.PHONY: test |
| 57 | +test: ## Run unit tests |
| 58 | + pnpm test |
| 59 | + |
| 60 | +.PHONY: clean |
| 61 | +clean: ## Clean development environment |
| 62 | + rm -rf node_modules |
| 63 | + |
| 64 | +##### Build |
| 65 | + |
| 66 | +.PHONY: cypress-install |
| 67 | +cypress-install: ## Install Cypress for acceptance tests |
| 68 | + $(NODEBIN)/cypress install |
| 69 | + |
| 70 | +../registry/dist: $(shell find ../registry/src -type f) |
| 71 | + (cd ../../ && pnpm build:registry) |
| 72 | + |
| 73 | +../components/dist: $(shell find ../components/src -type f) |
| 74 | + (cd ../../ && pnpm build:components) |
| 75 | + |
| 76 | +../client/dist: $(shell find ../client/src -type f) |
| 77 | + (cd ../../ && pnpm build:client) |
| 78 | + |
| 79 | +../providers/dist: $(shell find ../providers/src -type f) |
| 80 | + (cd ../../ && pnpm build:providers) |
| 81 | + |
| 82 | +../helpers/dist: $(shell find ../helpers/src -type f) |
| 83 | + (cd ../../ && pnpm build:helpers) |
| 84 | + |
| 85 | +../react-router/dist: $(shell find ../react-router/src -type f) |
| 86 | + (cd ../../ && pnpm build:react-router) |
| 87 | + |
| 88 | +.PHONY: build-deps |
| 89 | +build-deps: ../registry/dist ../components/dist ../client/dist ../providers/dist ../react-router/dist ../helpers/dist ## Build dependencies |
| 90 | + |
| 91 | +.PHONY: i18n |
| 92 | +i18n: ## Extract and compile translations |
| 93 | + pnpm i18n |
| 94 | + |
| 95 | +## Storybook |
| 96 | + |
| 97 | +.PHONY: storybook-start |
| 98 | +storybook-start: ## Start Storybook server on port 6006 |
| 99 | + @echo "$(GREEN)==> Start Storybook$(RESET)" |
| 100 | + pnpm run storybook |
| 101 | + |
| 102 | +.PHONY: storybook-build |
| 103 | +storybook-build: build-deps ## Build Storybook |
| 104 | + pnpm build-storybook -o ../../docs/_build/html/storybook |
| 105 | + |
| 106 | +##### Release (it runs the one inside) |
| 107 | + |
| 108 | +.PHONY: release-notes-copy-to-docs |
| 109 | +release-notes-copy-to-docs: ## Copy release notes into documentation |
| 110 | + cp CHANGELOG.md ../../docs/source/release-notes/index.md |
| 111 | + git add ../../docs/source/release-notes/index.md |
| 112 | + |
| 113 | +##### Docker containers |
| 114 | + |
| 115 | +.PHONY: backend-docker-start |
| 116 | +backend-docker-start: ## Starts a Docker-based backend for development |
| 117 | + docker run -it --rm --name=backend -p 8080:8080 -v volto-backend-data:/data -e SITE=Plone -e ADDONS='$(KGS)' -e LANGUAGE='$(LANGUAGE)' $(DOCKER_IMAGE) |
| 118 | + |
| 119 | +.PHONY: frontend-docker-start |
| 120 | +frontend-docker-start: ## Starts a Docker-based frontend for development |
| 121 | + docker run -it --rm --name=volto --link backend -p 3000:3000 -e RAZZLE_INTERNAL_API_PATH=http://backend:8080/Plone -e RAZZLE_DEV_PROXY_API_PATH=http://backend:8080/Plone plone/plone-frontend:latest |
| 122 | + |
| 123 | +##### Acceptance tests (Cypress) |
| 124 | +######### Dev mode Acceptance tests |
| 125 | + |
| 126 | +.PHONY: acceptance-frontend-dev-start |
| 127 | +acceptance-frontend-dev-start: ## Start acceptance frontend in development mode |
| 128 | + PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm start |
| 129 | + |
| 130 | +######### Core Acceptance tests |
| 131 | + |
| 132 | +.PHONY: acceptance-backend-start |
| 133 | +acceptance-backend-start: ## Start backend acceptance server |
| 134 | + # docker run -it --rm -p 55001:55001 $(DOCKER_IMAGE_ACCEPTANCE) |
| 135 | + docker run -it --rm -p 55001:55001 -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:default $(DOCKER_IMAGE_ACCEPTANCE) |
| 136 | + # Uncomment next line and comment line above to use a custom image with the acceptance server (in case you need to use an specific backend add-on or version) |
| 137 | + # docker run -it --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e ADDONS='$(KGS) $(TESTING_ADDONS)' -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:default -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,plone.volto,plone.volto.cors $(DOCKER_IMAGE) ./bin/robot-server plone.app.robotframework.testing.VOLTO_ROBOT_TESTING |
| 138 | + |
| 139 | +.PHONY: ci-acceptance-backend-start |
| 140 | +ci-acceptance-backend-start: ## Start backend acceptance server in headless mode for CI |
| 141 | + # docker run -i --rm -p 55001:55001 $(DOCKER_IMAGE_ACCEPTANCE) |
| 142 | + docker run -i --rm -p 55001:55001 -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:default $(DOCKER_IMAGE_ACCEPTANCE) |
| 143 | + # Uncomment next line and comment line above to use a custom image with the acceptance server (in case you need to use an specific backend add-on or version) |
| 144 | + # docker run -i --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e ADDONS='$(KGS) $(TESTING_ADDONS)' -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:default -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,plone.volto,plone.volto.cors $(DOCKER_IMAGE) ./bin/robot-server plone.app.robotframework.testing.VOLTO_ROBOT_TESTING |
| 145 | + |
| 146 | +.PHONY: acceptance-frontend-prod-start |
| 147 | +acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode |
| 148 | + pnpm build && PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm start:prod |
| 149 | + |
| 150 | +.PHONY: acceptance-test |
| 151 | +acceptance-test: ## Start Cypress in interactive mode |
| 152 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress open |
| 153 | + |
| 154 | +.PHONY: ci-acceptance-test |
| 155 | +ci-acceptance-test: ## Run cypress tests in headless mode for CI |
| 156 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress run --config specPattern='cypress/tests/core/**/*.{ts,tsx}' |
| 157 | + |
| 158 | +.PHONY: ci-acceptance-test-run-all |
| 159 | +ci-acceptance-test-run-all: ## With a single command, start both the acceptance frontend and backend acceptance server, and run Cypress tests in headless mode |
| 160 | + $(NODEBIN)/start-test "make ci-acceptance-backend-start" http-get://127.0.0.1:55001/plone "make acceptance-frontend-prod-start" http://127.0.0.1:3000 "make ci-acceptance-test" |
| 161 | + |
| 162 | +######### Deployment Core Acceptance tests |
| 163 | + |
| 164 | +.PHONY: deployment-acceptance-frontend-prod-start |
| 165 | +deployment-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for deployment |
| 166 | + pnpm build && pnpm start:prod |
| 167 | + |
| 168 | +.PHONY: deployment-acceptance-test |
| 169 | +deployment-acceptance-test: ## Start Cypress in interactive mode for tests in deployment |
| 170 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress open --config baseUrl='http://localhost' |
| 171 | + |
| 172 | +.PHONY: deployment-acceptance-web-server-start |
| 173 | +deployment-acceptance-web-server-start: ## Start the reverse proxy (Traefik) in port 80 for deployment |
| 174 | + cd cypress/docker && docker compose -f seamless.yml up |
| 175 | + |
| 176 | +.PHONY: deployment-ci-acceptance-test-run-all |
| 177 | +deployment-ci-acceptance-test-run-all: ## With a single command, run the backend, frontend, and the Cypress tests in headless mode for CI for deployment tests |
| 178 | + $(NODEBIN)/start-test "make acceptance-backend-start" http-get://127.0.0.1:55001/plone "make deployment-acceptance-frontend-prod-start" http://127.0.0.1:3000 "make ci-acceptance-test" |
| 179 | + |
| 180 | +######### Project Acceptance tests |
| 181 | + |
| 182 | +.PHONY: project-acceptance-frontend-prod-start |
| 183 | +project-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for project tests |
| 184 | + (cd ../../.. && pnpm build && PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm start:prod) |
| 185 | + |
| 186 | +######### Core Sandbox Acceptance tests |
| 187 | + |
| 188 | +.PHONY: coresandbox-acceptance-backend-start |
| 189 | +coresandbox-acceptance-backend-start: ## Start backend acceptance server for core sandbox tests |
| 190 | + docker run -i --rm -p 55001:55001 -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:default,plone.volto:coresandbox -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,plone.volto,plone.volto.cors,plone.volto.coresandbox $(DOCKER_IMAGE_ACCEPTANCE) |
| 191 | + |
| 192 | +.PHONY: coresandbox-acceptance-frontend-prod-start |
| 193 | +coresandbox-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for core sandbox tests |
| 194 | + ADDONS=@plone/volto-coresandbox PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod |
| 195 | + |
| 196 | +.PHONY: coresandbox-acceptance-frontend-dev-start |
| 197 | +coresandbox-acceptance-frontend-dev-start: build-deps ## Start acceptance frontend in development mode for core sandbox tests |
| 198 | + ADDONS=@plone/volto-coresandbox PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm start |
| 199 | + |
| 200 | +.PHONY: coresandbox-acceptance-test |
| 201 | +coresandbox-acceptance-test: ## Start Cypress in interactive mode for core sandbox tests |
| 202 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress open --config specPattern='cypress/tests/coresandbox/**/*.{js,jsx,ts,tsx}' |
| 203 | + |
| 204 | +.PHONY: coresandbox-ci-acceptance-test |
| 205 | +coresandbox-ci-acceptance-test: ## Run Cypress tests in headless mode for CI for core sandbox tests |
| 206 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress run --config specPattern='cypress/tests/coresandbox/**/*.{js,jsx,ts,tsx}' |
| 207 | + |
| 208 | +.PHONY: coresandbox-ci-acceptance-test-run-all |
| 209 | +coresandbox-ci-acceptance-test-run-all: ## With a single command, run the backend, frontend, and the Cypress tests in headless mode for CI for core sandbox tests |
| 210 | + $(NODEBIN)/start-test "make coresandbox-acceptance-backend-start" http-get://127.0.0.1:55001/plone "make coresandbox-acceptance-frontend-prod-start" http://127.0.0.1:3000 "make coresandbox-ci-acceptance-test" |
| 211 | + |
| 212 | +######### Multilingual Acceptance tests |
| 213 | + |
| 214 | +.PHONY: multilingual-acceptance-backend-start |
| 215 | +multilingual-acceptance-backend-start: ## Start backend acceptance server for multilingual tests |
| 216 | + docker run -i --rm -p 55001:55001 -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:multilingual $(DOCKER_IMAGE_ACCEPTANCE) |
| 217 | + |
| 218 | +.PHONY: multilingual-acceptance-frontend-prod-start |
| 219 | +multilingual-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for multilingual tests |
| 220 | + ADDONS=@plone/volto-coresandbox:multilingualFixture PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod |
| 221 | + |
| 222 | +.PHONY: multilingual-acceptance-test |
| 223 | +multilingual-acceptance-test: ## Start Cypress in interactive mode for multilingual tests |
| 224 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress open --config specPattern='cypress/tests/multilingual/**/*.{js,jsx,ts,tsx}' |
| 225 | + |
| 226 | +.PHONY: multilingual-ci-acceptance-test |
| 227 | +multilingual-ci-acceptance-test: ## Run Cypress tests in headless mode for CI for multilingual tests |
| 228 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress run --config specPattern='cypress/tests/multilingual/**/*.{js,jsx,ts,tsx}' |
| 229 | + |
| 230 | +.PHONY: multilingual-ci-acceptance-test-run-all |
| 231 | +multilingual-ci-acceptance-test-run-all: ## With a single command, run the backend, frontend, and the Cypress tests in headless mode for CI for multilingual tests |
| 232 | + $(NODEBIN)/start-test "make multilingual-acceptance-backend-start" http-get://127.0.0.1:55001/plone "make multilingual-acceptance-frontend-prod-start" http://127.0.0.1:3000 "make multilingual-ci-acceptance-test" |
| 233 | + |
| 234 | +######### Deployment Multilingual Acceptance tests |
| 235 | + |
| 236 | +.PHONY: deployment-multilingual-acceptance-backend-start |
| 237 | +deployment-multilingual-acceptance-backend-start: ## Start backend acceptance server for multilingual tests for deployment |
| 238 | + docker run -i --rm -p 55001:55001 -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:multilingual $(DOCKER_IMAGE_ACCEPTANCE) |
| 239 | + |
| 240 | +.PHONY: deployment-multilingual-acceptance-frontend-prod-start |
| 241 | +deployment-multilingual-acceptance-frontend-prod-start: build-deps ##Start acceptance frontend in production mode for multilingual tests for deployment |
| 242 | + ADDONS=@plone/volto-coresandbox:multilingualFixture pnpm build && pnpm start:prod |
| 243 | + |
| 244 | +.PHONY: deployment-multilingual-acceptance-test |
| 245 | +deployment-multilingual-acceptance-test: ## Start Cypress in interactive mode for multilingual tests for deployment |
| 246 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress open --config baseUrl='http://localhost',specPattern='cypress/tests/multilingual/**/*.{js,jsx,ts,tsx}' |
| 247 | + |
| 248 | +.PHONY: deployment-multilingual-ci-acceptance-test |
| 249 | +deployment-multilingual-ci-acceptance-test: ## Run Cypress tests in headless mode for CI for multilingual tests for deployment |
| 250 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress run --config specPattern='cypress/tests/multilingual/**/*.{js,jsx,ts,tsx}' |
| 251 | + |
| 252 | +.PHONY: deployment-multilingual-ci-acceptance-test-run-all |
| 253 | +deployment-multilingual-ci-acceptance-test-run-all: ## With a single command, run the backend, frontend, and the Cypress tests in headless mode for CI for multilingual tests for deployment |
| 254 | + $(NODEBIN)/start-test "make deployment-multilingual-acceptance-backend-start" http-get://127.0.0.1:55001/plone "make deployment-multilingual-acceptance-frontend-prod-start" http://127.0.0.1:3000 "make deployment-multilingual-ci-acceptance-test" |
| 255 | + |
| 256 | +######### Working Copy Acceptance tests |
| 257 | + |
| 258 | +.PHONY: working-copy-acceptance-backend-start |
| 259 | +working-copy-acceptance-backend-start: ## Start backend acceptance server for working copy tests |
| 260 | + docker run -i --rm -p 55001:55001 -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.app.iterate:default,plone.volto:default $(DOCKER_IMAGE_ACCEPTANCE) |
| 261 | + |
| 262 | +.PHONY: working-copy-acceptance-frontend-prod-start |
| 263 | +working-copy-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for working copy tests |
| 264 | + PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod |
| 265 | + |
| 266 | +.PHONY: working-copy-acceptance-test |
| 267 | +working-copy-acceptance-test: ## Start Cypress in interactive mode for working copy tests |
| 268 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress open --config specPattern='cypress/tests/workingCopy/**/*.{js,jsx,ts,tsx}' |
| 269 | + |
| 270 | +.PHONY: working-copy-ci-acceptance-test |
| 271 | +working-copy-ci-acceptance-test: ## Run Cypress tests in headless mode for CI for working copy tests |
| 272 | + NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress run --config specPattern='cypress/tests/workingCopy/**/*.{js,jsx,ts,tsx}' |
| 273 | + |
| 274 | +.PHONY: working-copy-ci-acceptance-test-run-all |
| 275 | +working-copy-ci-acceptance-test-run-all: ## With a single command, run the backend, frontend, and the Cypress tests in headless mode for CI for working copy tests |
| 276 | + $(NODEBIN)/start-test "make working-copy-acceptance-backend-start" http-get://127.0.0.1:55001/plone "make working-copy-acceptance-frontend-prod-start" http://127.0.0.1:3000 "make working-copy-ci-acceptance-test" |
0 commit comments