Skip to content

Commit 01571f4

Browse files
author
valentinab25
committed
docs: Cleanup Makefile, update DEVELOP documentation, i18n - refs #254894
1 parent ffb3476 commit 01571f4

File tree

11 files changed

+303
-77
lines changed

11 files changed

+303
-77
lines changed

.i18n.babel.config.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

DEVELOP.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22

33
## Develop
44

5+
1. Make sure you have `docker` and `docker compose` installed and running on your machine:
6+
7+
```Bash
8+
git clone https://github.com/eea/volto-widget-toggle.git
9+
cd volto-widget-toggle
10+
git checkout -b bugfix-123456 develop
11+
make
12+
make start
13+
```
14+
15+
1. Wait for `Volto started at 0.0.0.0:3000` meesage
16+
17+
1. Go to http://localhost:3000
18+
19+
1. Happy hacking!
20+
21+
```Bash
22+
cd src/addons/volto-widget-toggle/
23+
```
24+
25+
### Or add @eeacms/volto-widget-toggle to your Volto project
26+
527
Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)
628

729
1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer`
@@ -50,3 +72,37 @@ Before starting make sure your development environment is properly set. See [Vol
5072
1. Happy hacking!
5173

5274
$ cd src/addons/volto-widget-toggle/
75+
76+
## Cypress
77+
78+
To run cypress locally, first make sure you don't have any Volto/Plone running on ports `8080` and `3000`.
79+
80+
You don't have to be in a `clean-volto-project`, you can be in any Volto Frontend
81+
project where you added `volto-widget-toggle` to `mrs.developer.json`
82+
83+
Go to:
84+
85+
```BASH
86+
cd src/addons/volto-widget-toggle/
87+
```
88+
89+
Start:
90+
91+
```Bash
92+
make
93+
make start
94+
```
95+
96+
This will build and start with Docker a clean `Plone backend` and `Volto Frontend` with `volto-widget-toggle` block installed.
97+
98+
Open Cypress Interface:
99+
100+
```Bash
101+
make cypress-open
102+
```
103+
104+
Or run it:
105+
106+
```Bash
107+
make cypress-run
108+
```

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# syntax=docker/dockerfile:1
2+
ARG VOLTO_VERSION
3+
FROM plone/frontend-builder:${VOLTO_VERSION}
4+
5+
ARG ADDON_NAME
6+
ARG ADDON_PATH
7+
8+
COPY --chown=node:node ./ /app/src/addons/${ADDON_PATH}/
9+
10+
RUN /setupAddon
11+
RUN yarn install
12+
13+
ENTRYPOINT ["yarn"]
14+
CMD ["start"]

Jenkinsfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,31 @@ pipeline {
197197
}
198198
}
199199

200+
stage('SonarQube compare to master') {
201+
when {
202+
allOf {
203+
environment name: 'CHANGE_ID', value: ''
204+
branch 'develop'
205+
not { changelog '.*^Automated release [0-9\\.]+$' }
206+
}
207+
}
208+
steps {
209+
node(label: 'docker') {
210+
script {
211+
sh '''docker pull eeacms/gitflow'''
212+
sh '''echo "Error" > checkresult.txt'''
213+
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
214+
sh '''set -o pipefail; docker run -i --rm --name="$BUILD_TAG-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt'''
215+
}
216+
217+
publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: "Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed",
218+
text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}",
219+
detailsURL: "${env.BUILD_URL}display/redirect"
220+
}
221+
}
222+
}
223+
}
224+
200225
stage('Pull Request') {
201226
when {
202227
not {

Makefile

Lines changed: 92 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,126 @@
1-
SHELL=/bin/bash
1+
##############################################################################
2+
# Run:
3+
# make
4+
# make start
5+
#
6+
# Go to:
7+
#
8+
# http://localhost:3000
9+
#
10+
# Cypress:
11+
#
12+
# make cypress-open
13+
#
14+
##############################################################################
15+
# SETUP MAKE
16+
#
17+
## Defensive settings for make: https://tech.davis-hansson.com/p/make/
18+
SHELL:=bash
19+
.ONESHELL:
20+
# for Makefile debugging purposes add -x to the .SHELLFLAGS
21+
.SHELLFLAGS:=-eu -o pipefail -O inherit_errexit -c
22+
.SILENT:
23+
.DELETE_ON_ERROR:
24+
MAKEFLAGS+=--warn-undefined-variables
25+
MAKEFLAGS+=--no-builtin-rules
26+
27+
# Colors
28+
# OK=Green, warn=yellow, error=red
29+
ifeq ($(TERM),)
30+
# no colors if not in terminal
31+
MARK_COLOR=
32+
OK_COLOR=
33+
WARN_COLOR=
34+
ERROR_COLOR=
35+
NO_COLOR=
36+
else
37+
MARK_COLOR=`tput setaf 6`
38+
OK_COLOR=`tput setaf 2`
39+
WARN_COLOR=`tput setaf 3`
40+
ERROR_COLOR=`tput setaf 1`
41+
NO_COLOR=`tput sgr0`
42+
endif
243

44+
##############################################################################
45+
# SETTINGS AND VARIABLE
346
DIR=$(shell basename $$(pwd))
4-
ADDON ?= "@eeacms/volto-widget-toggle"
5-
6-
# We like colors
7-
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
8-
RED=`tput setaf 1`
9-
GREEN=`tput setaf 2`
10-
RESET=`tput sgr0`
11-
YELLOW=`tput setaf 3`
12-
13-
project:
14-
npm install -g yo
15-
npm install -g @plone/generator-volto
16-
npm install -g mrs-developer
17-
yo @plone/volto project --addon ${ADDON} --workspace "src/addons/${DIR}" --no-interactive
18-
ln -sf $$(pwd) project/src/addons/
19-
cp .project.eslintrc.js .eslintrc.js
20-
cd project && yarn
21-
@echo "-------------------"
22-
@echo "$(GREEN)Volto project is ready!$(RESET)"
23-
@echo "$(RED)Now run: cd project && yarn start$(RESET)"
24-
25-
all: project
26-
27-
.PHONY: start-test-backend
28-
start-test-backend: ## Start Test Plone Backend
29-
@echo "$(GREEN)==> Start Test Plone Backend$(RESET)"
30-
docker run -i --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e SITE=plone -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,kitconcept.volto:default-homepage -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,kitconcept.volto,kitconcept.volto.cors -e ADDONS='plone.app.robotframework plone.app.contenttypes plone.restapi kitconcept.volto' plone ./bin/robot-server plone.app.robotframework.testing.PLONE_ROBOT_TESTING
31-
32-
.PHONY: start-backend-docker
33-
start-backend-docker: ## Starts a Docker-based backend
34-
@echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)"
35-
docker run -it --rm --name=plone -p 8080:8080 -e SITE=Plone -e ADDONS="kitconcept.volto" -e ZCML="kitconcept.volto.cors" plone
47+
NODE_MODULES?="../../../node_modules"
48+
PLONE_VERSION?=6
49+
VOLTO_VERSION?=16
50+
ADDON_PATH="${DIR}"
51+
ADDON_NAME="@eeacms/${ADDON_PATH}"
52+
DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose
53+
54+
# Top-level targets
55+
.PHONY: all
56+
all: clean install
57+
58+
.PHONY: clean
59+
clean: ## Cleanup development environment
60+
${DOCKER_COMPOSE} down --volumes --remove-orphans
61+
62+
.PHONY: install
63+
install: ## Build and install development environment
64+
echo "Running: ${DOCKER_COMPOSE} build"
65+
${DOCKER_COMPOSE} pull
66+
${DOCKER_COMPOSE} build
67+
68+
.PHONY: start
69+
start: ## Start development environment
70+
echo "Running: ${DOCKER_COMPOSE} up"
71+
${DOCKER_COMPOSE} up
3672

37-
.PHONY: test
38-
test:
39-
docker pull plone/volto-addon-ci:alpha
40-
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha
41-
42-
.PHONY: test-update
43-
test-update:
44-
docker pull plone/volto-addon-ci:alpha
45-
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha yarn test src/addons/${DIR}/src --watchAll=false -u
73+
.PHONY: cypress-open
74+
cypress-open: ## Open cypress integration tests
75+
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open
4676

47-
.PHONY: help
48-
help: ## Show this help.
49-
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
77+
.PHONY: cypress-run
78+
cypress-run: ## Run cypress integration tests
79+
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run
5080

81+
.PHONY: test
82+
test: ## Run jest tests
83+
${DOCKER_COMPOSE} run -e CI=1 frontend test
5184

52-
ifeq ($(wildcard ./project),)
53-
NODE_MODULES = "../../../node_modules"
54-
else
55-
NODE_MODULES = "./project/node_modules"
56-
endif
85+
.PHONY: test-update
86+
test-update: ## Update jest tests snapshots
87+
${DOCKER_COMPOSE} run -e CI=1 frontend test -u
5788

5889
.PHONY: stylelint
59-
stylelint:
90+
stylelint: ## Stylelint
6091
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'
6192

6293
.PHONY: stylelint-overrides
6394
stylelint-overrides:
6495
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'
6596

6697
.PHONY: stylelint-fix
67-
stylelint-fix:
98+
stylelint-fix: ## Fix stylelint
6899
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix
69100
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix
70101

71102
.PHONY: prettier
72-
prettier:
103+
prettier: ## Prettier
73104
$(NODE_MODULES)/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'
74105

75106
.PHONY: prettier-fix
76-
prettier-fix:
107+
prettier-fix: ## Fix prettier
77108
$(NODE_MODULES)/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'
78109

79110
.PHONY: lint
80-
lint:
111+
lint: ## ES Lint
81112
$(NODE_MODULES)/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'
82113

83114
.PHONY: lint-fix
84-
lint-fix:
115+
lint-fix: ## Fix ES Lint
85116
$(NODE_MODULES)/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'
86117

87118
.PHONY: i18n
88-
i18n:
119+
i18n: ## i18n
89120
rm -rf build/messages
90121
NODE_ENV=development $(NODE_MODULES)/.bin/i18n --addon
91122

92-
.PHONY: cypress-run
93-
cypress-run:
94-
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run
95-
96-
.PHONY: cypress-open
97-
cypress-open:
98-
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open
123+
.PHONY: help
124+
help: ## Show this help.
125+
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
126+
head -n 14 Makefile

README.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,59 @@
1414
[![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-widget-toggle-develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-widget-toggle-develop)
1515
[![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-widget-toggle-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-widget-toggle-develop)
1616

17-
[Volto](https://github.com/plone/volto) add-on: Replace any checkbox with a nice toggle button within edit forms
17+
18+
[Volto](https://github.com/plone/volto) add-on
1819

1920
## Features
2021

21-
![Toogle Checkboxes](https://raw.githubusercontent.com/eea/volto-widget-toggle/docs/docs/volto-widget-toggle.gif)
22+
Demo GIF
2223

2324
## Getting started
2425

25-
1. Create new volto project if you don't already have one:
26+
### Try volto-widget-toggle with Docker
2627

27-
```
28-
$ npm install -g yo @plone/generator-volto
29-
$ yo @plone/volto my-volto-project --addon @eeacms/volto-widget-toggle
28+
git clone https://github.com/eea/volto-widget-toggle.git
29+
cd volto-widget-toggle
30+
make
31+
make start
32+
33+
Go to http://localhost:3000
34+
35+
### Add volto-widget-toggle to your Volto project
36+
37+
1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone
3038

31-
$ cd my-volto-project
32-
$ yarn add -W @eeacms/volto-widget-toggle
39+
```Bash
40+
docker compose up backend
3341
```
3442

35-
1. If you already have a volto project, just update `package.json`:
43+
1. Start Volto frontend
44+
45+
* If you already have a volto project, just update `package.json`:
3646

3747
```JSON
3848
"addons": [
3949
"@eeacms/volto-widget-toggle"
4050
],
4151

4252
"dependencies": {
43-
"@eeacms/volto-widget-toggle": "^2.0.0"
53+
"@eeacms/volto-widget-toggle": "*"
4454
}
4555
```
4656

57+
* If not, create one:
58+
59+
```
60+
npm install -g yo @plone/generator-volto
61+
yo @plone/volto my-volto-project --canary --addon @eeacms/volto-widget-toggle
62+
cd my-volto-project
63+
```
64+
4765
1. Install new add-ons and restart Volto:
4866

4967
```
50-
$ yarn
51-
$ yarn start
68+
yarn
69+
yarn start
5270
```
5371

5472
1. Go to http://localhost:3000

0 commit comments

Comments
 (0)