-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
175 lines (139 loc) · 5.65 KB
/
Copy pathMakefile
File metadata and controls
175 lines (139 loc) · 5.65 KB
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
166
167
168
169
170
171
172
173
174
175
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-eu -o pipefail -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Recipe snippets for reuse
# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`
PLONE_VERSION=6
DOCKER_IMAGE=plone/server-dev:${PLONE_VERSION}
DOCKER_IMAGE_ACCEPTANCE=plone/server-acceptance:${PLONE_VERSION}
ADDON_NAME='volto-hydra'
.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 :)"
# Dev Helpers
.PHONY: install
install: ## Installs the add-on in a development environment
pnpm dlx mrs-developer missdev --no-config --fetch-https
pnpm i
# lightningcss-cli ships a placeholder text file as its `lightningcss`
# binary; its postinstall.js is meant to replace that with the real native
# binary. With pnpm's non-hoisted layout the postinstall's
# `require.resolve('lightningcss-cli-<platform>')` can't resolve at the time
# pnpm runs it, so it silently leaves the placeholder and @plone/components'
# `build:css` (via `pnpm build:deps`) then dies with "This: command not
# found". `pnpm rebuild` doesn't retry it. Run the postinstall directly from
# the package dir (where the platform pkg IS resolvable) to land the binary.
PI="$$(node -e "console.log(require.resolve('lightningcss-cli/postinstall.js'))")"; \
(cd "$$(dirname "$$PI")" && node postinstall.js)
.PHONY: start
start: ## Starts Volto, allowing reloading of the add-on during development
pnpm start
.PHONY: build
build: ## Build a production bundle for distribution of the project with the add-on
pnpm build
.PHONY: i18n
i18n: ## Sync i18n
pnpm --filter $(ADDON_NAME) i18n
.PHONY: format
format: ## Format codebase
pnpm lint:fix
pnpm prettier:fix
pnpm stylelint:fix
.PHONY: lint
lint: ## Lint, or catch and remove problems, in code base
pnpm lint
pnpm prettier
pnpm stylelint
.PHONY: release
release: ## Release the add-on on npmjs.org
pnpm release
.PHONY: release-dry-run
release-dry-run: ## Dry-run the release of the add-on on npmjs.org
pnpm release
.PHONY: test
test: ## Run unit tests
pnpm test
.PHONY: test-ci
ci-test: ## Run unit tests in CI
CI=1 RAZZLE_JEST_CONFIG=$(CURRENT_DIR)/jest-addon.config.js pnpm --filter @plone/volto test -- --passWithNoTests
.PHONY: backend-docker-start
backend-docker-start: ## Starts a Docker-based backend for development
@echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)"
docker run -it --rm --name=backend -p 8080:8080 -e SITE=Plone -e CORS_ALLOW_ORIGIN='*' $(DOCKER_IMAGE)
## Storybook
.PHONY: storybook-start
storybook-start: ## Start Storybook server on port 6006
@echo "$(GREEN)==> Start Storybook$(RESET)"
pnpm run storybook
.PHONY: storybook-build
storybook-build: ## Build Storybook
@echo "$(GREEN)==> Build Storybook$(RESET)"
mkdir -p $(CURRENT_DIR)/.storybook-build
pnpm run build-storybook -o $(CURRENT_DIR)/.storybook-build
## Acceptance
.PHONY: acceptance-frontend-dev-start
acceptance-frontend-dev-start: ## Start acceptance frontend in development mode
RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm start
.PHONY: acceptance-frontend-prod-start
acceptance-frontend-prod-start: ## Start acceptance frontend in production mode
RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod
.PHONY: acceptance-backend-start
acceptance-backend-start: ## Start backend acceptance server
docker run -it --rm -p 55001:55001 $(DOCKER_IMAGE_ACCEPTANCE)
.PHONY: ci-acceptance-backend-start
ci-acceptance-backend-start: ## Start backend acceptance server in headless mode for CI
docker run -i --rm -p 55001:55001 $(DOCKER_IMAGE_ACCEPTANCE)
.PHONY: acceptance-test
acceptance-test: ## Start Cypress in interactive mode
pnpm --filter @plone/volto exec cypress open --config-file $(CURRENT_DIR)/cypress.config.js --config specPattern=$(CURRENT_DIR)'/cypress/tests/**/*.{js,jsx,ts,tsx}'
.PHONY: ci-acceptance-test
ci-acceptance-test: ## Run cypress tests in headless mode for CI
pnpm --filter @plone/volto exec cypress run --config-file $(CURRENT_DIR)/cypress.config.js --config specPattern=$(CURRENT_DIR)'/cypress/tests/**/*.{js,jsx,ts,tsx}'
################
### EXAMPLES ###
################
# Next.js
.PHONY: example-nextjs-admin
example-nextjs-admin: ## Starts Volto, allowing reloading of the add-on during development
RAZZLE_DEFAULT_IFRAME_URL=http://localhost:3002 pnpm start
.PHONY: example-nextjs-frontend
example-nextjs-frontend: ## Starts nextjs example frontend
pnpm example:nextjs
# Nuxt
.PHONY: example-nextjs-admin
example-nuxt-admin:
RAZZLE_DEFAULT_IFRAME_URL=http://localhost:3002 pnpm start
.PHONY: example-nuxt-frontend
example-nuxt-frontend: ## Starts nuxt example frontend
cd examples/nuxt-blog-starter && npm install && npm run dev
######################
### DOCUMENTATION ###
######################
.PHONY: docs-install
docs-install: ## Install documentation dependencies
@echo "$(GREEN)==> Installing documentation dependencies$(RESET)"
pip install -r docs/requirements.txt
.PHONY: docs
docs: ## Build HTML documentation
@echo "$(GREEN)==> Building documentation$(RESET)"
$(MAKE) -C docs html
.PHONY: docs-clean
docs-clean: ## Clean documentation build
@echo "$(GREEN)==> Cleaning documentation build$(RESET)"
$(MAKE) -C docs clean
.PHONY: docs-live
docs-live: ## Start live-reloading documentation server
@echo "$(GREEN)==> Starting live documentation server$(RESET)"
$(MAKE) -C docs livehtml