diff --git a/CHANGELOG.md b/CHANGELOG.md index 866c292..58fb7d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,36 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +### [0.1.26](https://github.com/eea/volto-forest-policy/compare/0.1.25...0.1.26) - 22 November 2023 + +#### :rocket: New Features + +- feat: use Sources from volto-embed [Miu Razvan - [`866e3bf`](https://github.com/eea/volto-forest-policy/commit/866e3bf12ab9c0cb05efde6e25baf4a9badf5fbf)] + +#### :bug: Bug Fixes + +- fix: sonarqube issues [Claudia Ifrim - [`e988d2e`](https://github.com/eea/volto-forest-policy/commit/e988d2eef9e2abe399b5431fc5b288a5e85cd79b)] +- fix: update tests [Claudia Ifrim - [`aca51b4`](https://github.com/eea/volto-forest-policy/commit/aca51b4d4d1c7ba4aa1231a7465a13f939cfb801)] +- fix: pretty package.json [Claudia Ifrim - [`f389495`](https://github.com/eea/volto-forest-policy/commit/f3894950f70095d0efaaba6d290f11e5b7ea2b17)] + +#### :house: Internal changes + +- chore: Cleanup tpl files [Alin Voinea - [`927b4e5`](https://github.com/eea/volto-forest-policy/commit/927b4e55a32939eb866335500dc44e0f8030373c)] +- style: Automated code fix [eea-jenkins - [`0a5a555`](https://github.com/eea/volto-forest-policy/commit/0a5a55514b526d2198c34449f60d3154708c61be)] +- chore: [JENKINS] Refactor automated testing [valentinab25 - [`6b470b3`](https://github.com/eea/volto-forest-policy/commit/6b470b301f73f3de4c3fa6f5594528b2ed1fa72d)] +- chore: husky, lint-staged use fixed versions [valentinab25 - [`0b61630`](https://github.com/eea/volto-forest-policy/commit/0b61630a0c69c57c5d3b504121a45ec64eb48286)] +- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`078dbc4`](https://github.com/eea/volto-forest-policy/commit/078dbc4545043a9181b13c5e44203c373ad216e1)] + +#### :hammer_and_wrench: Others + +- fix sonarqube [Miu Razvan - [`8e3f3b6`](https://github.com/eea/volto-forest-policy/commit/8e3f3b6279e211436522515708c9be37811ca874)] +- update test [Claudia Ifrim - [`33a3ef1`](https://github.com/eea/volto-forest-policy/commit/33a3ef1a80e2cf37a94e20c99b62e112a569ac3e)] +- Pin d3-array to 2.12.1 - refs #251399 [Claudia Ifrim - [`0048bbd`](https://github.com/eea/volto-forest-policy/commit/0048bbd71da25c364ecf6e2e91043067234c57cd)] +- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`e920388`](https://github.com/eea/volto-forest-policy/commit/e9203886bfe8307f7b74876e44a6f154adeab88c)] +- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`7a26d73`](https://github.com/eea/volto-forest-policy/commit/7a26d7343494edd15752f664831b0a552496a225)] +- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`58a48d2`](https://github.com/eea/volto-forest-policy/commit/58a48d2a2486d777ff0d40b7ccbf62f5b8329f67)] +- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`a85d8cb`](https://github.com/eea/volto-forest-policy/commit/a85d8cb9f3e8c2e6a9ba10d5f9553d4b938bd9ea)] +- test: [JENKINS] Improve cypress time [valentinab25 - [`a222cf9`](https://github.com/eea/volto-forest-policy/commit/a222cf981a928312fb2f05ae22870ce502741096)] ### [0.1.25](https://github.com/eea/volto-forest-policy/compare/0.1.24...0.1.25) - 19 September 2023 #### :hammer_and_wrench: Others diff --git a/DEVELOP.md b/DEVELOP.md index 52b161c..366482c 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -1,4 +1,4 @@ -# volto-addon-template +# volto-forest-policy ## Develop @@ -16,12 +16,14 @@ 1. Go to http://localhost:3000 -1. Happy hacking! +1. Initialize git hooks ```Bash - cd src/addons/volto-forest-policy/ + yarn prepare ``` +1. Happy hacking! + ### Or add @eeacms/volto-forest-policy to your Volto project Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/) @@ -32,15 +34,15 @@ Before starting make sure your development environment is properly set. See [Vol 1. Create new volto app - yo @plone/volto my-volto-project --addon @eeacms/volto-addon-template --skip-install + yo @plone/volto my-volto-project --addon @eeacms/volto-forest-policy --skip-install cd my-volto-project 1. Add the following to `mrs.developer.json`: { - "volto-addon-template": { - "url": "https://github.com/eea/volto-addon-template.git", - "package": "@eeacms/volto-addon-template", + "volto-forest-policy": { + "url": "https://github.com/eea/volto-forest-policy.git", + "package": "@eeacms/volto-forest-policy", "branch": "develop", "path": "src" } @@ -48,18 +50,15 @@ Before starting make sure your development environment is properly set. See [Vol 1. Install - yarn develop + make develop yarn 1. Start backend - docker pull plone - docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone + docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend ...wait for backend to setup and start - `Ready to handle requests`: - docker logs -f plone - ...you can also check http://localhost:8080/Plone 1. Start frontend @@ -70,7 +69,7 @@ Before starting make sure your development environment is properly set. See [Vol 1. Happy hacking! - cd src/addons/volto-addon-template/ + cd src/addons/volto-forest-policy/ ## Cypress @@ -105,3 +104,5 @@ Or run it: ```Bash make cypress-run ``` + + ``` diff --git a/DEVELOP.md.tpl b/DEVELOP.md.tpl deleted file mode 100644 index cf7da06..0000000 --- a/DEVELOP.md.tpl +++ /dev/null @@ -1,51 +0,0 @@ -# <%= name %> - -## Develop - -Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/) - -1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer` - - npm install -g yo @plone/generator-volto mrs-developer - -1. Create new volto app - - yo @plone/volto my-volto-project --addon <%= addonName %> --skip-install - cd my-volto-project - -1. Add the following to `mrs.developer.json`: - - { - "<%= name %>": { - "url": "https://github.com/eea/<%= name %>.git", - "package": "<%= addonName %>", - "branch": "develop", - "path": "src" - } - } - -1. Install - - yarn develop - yarn - -1. Start backend - - docker pull plone - docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone - - ...wait for backend to setup and start - `Ready to handle requests`: - - docker logs -f plone - - ...you can also check http://localhost:8080/Plone - -1. Start frontend - - yarn start - -1. Go to http://localhost:3000 - -1. Happy hacking! - - cd src/addons/<%= name %>/ diff --git a/Dockerfile b/Dockerfile index bd8e10d..b1ce603 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 ARG VOLTO_VERSION -FROM plone/frontend-builder:${VOLTO_VERSION} +FROM eeacms/frontend-builder:${VOLTO_VERSION} ARG ADDON_NAME ARG ADDON_PATH diff --git a/Jenkinsfile b/Jenkinsfile index bbc38d7..20854b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,23 @@ pipeline { - agent any + tools { + jdk 'Java17' + } + agent { + node { label 'docker-host' } + } environment { - GIT_NAME = "volto-forest-policy" - NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu" - DEPENDENCIES = "" - VOLTO = "" - } + GIT_NAME = "volto-forest-policy" + NAMESPACE = "@eeacms" + SONARQUBE_TAGS = "volto.eea.europa.eu" + DEPENDENCIES = "" + BACKEND_PROFILES = "eea.kitkat:testing" + BACKEND_ADDONS = "" + VOLTO = "16" + IMAGE_NAME = BUILD_TAG.toLowerCase() + } stages { - stage('Release') { when { allOf { @@ -20,52 +27,41 @@ pipeline { } steps { node(label: 'docker') { - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow''' + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'), string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { + sh '''docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow''' } } } } - stage('Code') { + stage('Check if testing needed') { when { allOf { - environment name: 'CHANGE_ID', value: '' - not { changelog '.*^Automated release [0-9\\.]+$' } not { branch 'master' } + not { branch 'develop' } + environment name: 'CHANGE_ID', value: '' } } steps { - parallel( + script { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + check_result = sh script: '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-check" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /check_if_testing_needed.sh''', returnStatus: true - "ES lint": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci eslint''' - } - }, - - "Style lint": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci stylelint''' - } - }, - - "Prettier": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci prettier''' + if (check_result == 0) { + env.SKIP_TESTS = 'yes' + } } - } - ) + } } } - stage('Tests') { + stage('Testing') { when { anyOf { allOf { not { environment name: 'CHANGE_ID', value: '' } environment name: 'CHANGE_TARGET', value: 'develop' + environment name: 'SKIP_TESTS', value: '' } allOf { environment name: 'CHANGE_ID', value: '' @@ -73,26 +69,76 @@ pipeline { not { changelog '.*^Automated release [0-9\\.]+$' } branch 'master' } + environment name: 'SKIP_TESTS', value: '' } } } - steps { - parallel( + stages { + stage('Build test image') { + steps { + checkout scm + sh '''docker build --pull --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend''' + } + } + + stage('Fix code') { + when { + environment name: 'CHANGE_ID', value: '' + not { branch 'master' } + } + steps { + script { + fix_result = sh(script: '''docker run --name="$IMAGE_NAME-fix" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend ci-fix''', returnStatus: true) + sh '''docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .''' + sh '''docker rm -v $IMAGE_NAME-fix''' + FOUND_FIX = sh(script: '''git diff | wc -l''', returnStdout: true).trim() - "Volto": { - node(label: 'docker') { - script { - try { - sh '''docker pull plone/volto-addon-ci''' - sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci''' - sh '''rm -rf xunit-reports''' - sh '''mkdir -p xunit-reports''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/''' - stash name: "xunit-reports", includes: "xunit-reports/**" - archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true - publishHTML (target : [ + if (FOUND_FIX != '0') { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config''' + } + sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH''' + sh '''git checkout $GIT_BRANCH''' + sh '''git add src/''' + sh '''git commit -m "style: Automated code fix" ''' + sh '''git push --set-upstream origin $GIT_BRANCH''' + sh '''exit 1''' + } + } + } + } + + stage('ES lint') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint''' + } + } + + stage('Style lint') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint''' + } + } + + stage('Prettier') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier''' + } + } + + stage('Coverage Tests') { + parallel { + + stage('Unit tests') { + steps { + script { + try { + sh '''docker run --name="$IMAGE_NAME-volto" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend test-ci''' + sh '''rm -rf xunit-reports''' + sh '''mkdir -p xunit-reports''' + sh '''docker cp $IMAGE_NAME-volto:/app/coverage xunit-reports/''' + sh '''docker cp $IMAGE_NAME-volto:/app/junit.xml xunit-reports/''' + publishHTML(target : [ allowMissing: false, alwaysLinkToLastBuild: true, keepAll: true, @@ -105,77 +151,69 @@ pipeline { catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true } - sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true + sh script: '''docker rm -v $IMAGE_NAME-volto''', returnStatus: true + } } } } - } - ) - } - } - - // stage('Integration tests') { - // when { - // anyOf { - // allOf { - // not { environment name: 'CHANGE_ID', value: '' } - // environment name: 'CHANGE_TARGET', value: 'develop' - // } - // allOf { - // environment name: 'CHANGE_ID', value: '' - // anyOf { - // not { changelog '.*^Automated release [0-9\\.]+$' } - // branch 'master' - // } - // } - // } - // } - // steps { - // parallel( + + stage('Integration tests') { + steps { + script { + try { + sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend''' + sh '''docker run -d --shm-size=3g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci''' + sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci''' + } finally { + try { + sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots''' + sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots''' + videos = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''', returnStatus: true + sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/reports cypress-results/''' + screenshots = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots''', returnStatus: true - // "Cypress": { - // node(label: 'docker') { - // script { - // try { - // sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend''' - // sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO=$VOLTO plone/volto-addon-ci cypress''' - // } finally { - // try { - // sh '''rm -rf cypress-reports cypress-results cypress-coverage''' - // sh '''mkdir -p cypress-reports cypress-results cypress-coverage''' - // sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/''' - // sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/''' - // coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true - // if ( coverage == 0 ) { - // publishHTML (target : [allowMissing: false, - // alwaysLinkToLastBuild: true, - // keepAll: true, - // reportDir: 'cypress-coverage/coverage/lcov-report', - // reportFiles: 'index.html', - // reportName: 'CypressCoverage', - // reportTitles: 'Integration Tests Code Coverage']) - // } - // sh '''touch empty_file; for ok_test in $(grep -E 'file=.*failures="0"' $(grep 'testsuites .*failures="0"' $(find cypress-results -name *.xml) empty_file | awk -F: '{print $1}') empty_file | sed 's/.* file="\\(.*\\)" time.*/\\1/' | sed 's#^cypress/integration/##g' | sed 's#^../../../node_modules/@eeacms/##g'); do rm -f cypress-reports/videos/$ok_test.mp4; rm -f cypress-reports/$ok_test.mp4; done''' - // archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true - // stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true - // } - // finally { - // catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { - // junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true - // } - // sh script: "docker stop $BUILD_TAG-plone", returnStatus: true - // sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true - // sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true + archiveArtifacts artifacts: 'cypress-screenshots/**', fingerprint: true, allowEmptyArchive: true - // } - // } - // } - // } - // } + coverage = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/coverage cypress-coverage''', returnStatus: true - // ) - // } - // } + if ( coverage == 0 ) { + publishHTML(target : [allowMissing: false, + alwaysLinkToLastBuild: true, + keepAll: true, + reportDir: 'cypress-coverage/coverage/lcov-report', + reportFiles: 'index.html', + reportName: 'CypressCoverage', + reportTitles: 'Integration Tests Code Coverage']) + } + if ( videos == 0 ) { + sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done''' + archiveArtifacts artifacts: 'cypress-videos/**/*.mp4', fingerprint: true, allowEmptyArchive: true + } + } finally { + catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true + } + catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + sh '''docker logs $IMAGE_NAME-cypress''' + } + sh script: "docker stop $IMAGE_NAME-cypress", returnStatus: true + sh script: "docker stop $IMAGE_NAME-plone", returnStatus: true + sh script: "docker rm -v $IMAGE_NAME-plone", returnStatus: true + sh script: "docker rm -v $IMAGE_NAME-cypress", returnStatus: true + } + } + } + } + } + } + } + } + post { + always { + sh script: "docker rmi $IMAGE_NAME-frontend", returnStatus: true + } + } + } stage('Report to SonarQube') { when { @@ -197,20 +235,14 @@ pipeline { } } steps { - node(label: 'swarm') { - script{ - checkout scm - unstash "xunit-reports" - // unstash "cypress-coverage" - def scannerHome = tool 'SonarQubeScanner'; - def nodeJS = tool 'NodeJS'; - withSonarQubeEnv('Sonarqube') { - sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - // sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" - sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" - sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done''' - } + script { + def scannerHome = tool 'SonarQubeScanner' + def nodeJS = tool 'NodeJS' + withSonarQubeEnv('Sonarqube') { + sh '''sed -i "s#/app/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' + sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' + sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" + sh '''try=5; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 15; try=\$(( \$try - 1 )); fi; done''' } } } @@ -231,18 +263,15 @@ pipeline { } } steps { - node(label: 'docker') { - script { - sh '''docker pull eeacms/gitflow''' - sh '''echo "Error" > checkresult.txt''' - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - 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''' - } - - 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", - text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}", - detailsURL: "${env.BUILD_URL}display/redirect" + script { + sh '''echo "Error" > checkresult.txt''' + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + sh '''set -o pipefail; docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt''' } + + 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', + text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}", + detailsURL: "${env.BUILD_URL}display/redirect" } } } @@ -255,20 +284,16 @@ pipeline { environment name: 'CHANGE_TARGET', value: 'master' } steps { - node(label: 'docker') { - script { - if ( env.CHANGE_BRANCH != "develop" ) { - error "Pipeline aborted due to PR not made from develop branch" - } - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow''' - } + script { + if (env.CHANGE_BRANCH != 'develop') { + error 'Pipeline aborted due to PR not made from develop branch' + } + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + sh '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow''' } } } } - } post { diff --git a/Jenkinsfile.tpl b/Jenkinsfile.tpl deleted file mode 100644 index 6de295e..0000000 --- a/Jenkinsfile.tpl +++ /dev/null @@ -1,242 +0,0 @@ -pipeline { - agent any - - environment { - GIT_NAME = "<%= name %>" - NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu" - DEPENDENCIES = "" - VOLTO = "alpha" - } - - stages { - - stage('Release') { - when { - allOf { - environment name: 'CHANGE_ID', value: '' - branch 'master' - } - } - steps { - node(label: 'docker') { - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow''' - } - } - } - } - - stage('Code') { - when { - allOf { - environment name: 'CHANGE_ID', value: '' - not { changelog '.*^Automated release [0-9\\.]+$' } - not { branch 'master' } - } - } - steps { - parallel( - - "ES lint": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha eslint''' - } - }, - - "Style lint": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha stylelint''' - } - }, - - "Prettier": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha prettier''' - } - } - ) - } - } - - stage('Tests') { - when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - not { changelog '.*^Automated release [0-9\\.]+$' } - branch 'master' - } - } - } - steps { - parallel( - - "Volto": { - node(label: 'docker') { - script { - try { - sh '''docker pull plone/volto-addon-ci:alpha''' - sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha''' - sh '''rm -rf xunit-reports''' - sh '''mkdir -p xunit-reports''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/''' - stash name: "xunit-reports", includes: "xunit-reports/**" - archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true - publishHTML (target : [ - allowMissing: false, - alwaysLinkToLastBuild: true, - keepAll: true, - reportDir: 'xunit-reports/coverage/lcov-report', - reportFiles: 'index.html', - reportName: 'UTCoverage', - reportTitles: 'Unit Tests Code Coverage' - ]) - } finally { - catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { - junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true - } - sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true - } - } - } - } - ) - } - } - - stage('Integration tests') { - when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - not { changelog '.*^Automated release [0-9\\.]+$' } - branch 'master' - } - } - } - steps { - parallel( - - "Cypress": { - node(label: 'docker') { - script { - try { - sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend''' - sh '''docker pull plone/volto-addon-ci:alpha; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha cypress''' - } finally { - try { - sh '''rm -rf cypress-reports cypress-results cypress-coverage''' - sh '''mkdir -p cypress-reports cypress-results cypress-coverage''' - sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/''' - sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/''' - coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true - if ( coverage == 0 ) { - publishHTML (target : [allowMissing: false, - alwaysLinkToLastBuild: true, - keepAll: true, - reportDir: 'cypress-coverage/coverage/lcov-report', - reportFiles: 'index.html', - reportName: 'CypressCoverage', - reportTitles: 'Integration Tests Code Coverage']) - } - sh '''touch empty_file; for ok_test in $(grep -E 'file=.*failures="0"' $(grep 'testsuites .*failures="0"' $(find cypress-results -name *.xml) empty_file | awk -F: '{print $1}') empty_file | sed 's/.* file="\\(.*\\)" time.*/\\1/' | sed 's#^cypress/integration/##g' | sed 's#^../../../node_modules/@eeacms/##g'); do rm -f cypress-reports/videos/$ok_test.mp4; rm -f cypress-reports/$ok_test.mp4; done''' - archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true - stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true - } - finally { - catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { - junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true - } - sh script: "docker stop $BUILD_TAG-plone", returnStatus: true - sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true - sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true - - } - } - } - } - } - - ) - } - } - - stage('Report to SonarQube') { - when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - branch 'master' - allOf { - branch 'develop' - not { changelog '.*^Automated release [0-9\\.]+$' } - } - } - } - } - steps { - node(label: 'swarm') { - script{ - checkout scm - unstash "xunit-reports" - unstash "cypress-coverage" - def scannerHome = tool 'SonarQubeScanner'; - def nodeJS = tool 'NodeJS'; - withSonarQubeEnv('Sonarqube') { - sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" - sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done''' - } - } - } - } - } - - stage('Pull Request') { - when { - not { - environment name: 'CHANGE_ID', value: '' - } - environment name: 'CHANGE_TARGET', value: 'master' - } - steps { - node(label: 'docker') { - script { - if ( env.CHANGE_BRANCH != "develop" ) { - error "Pipeline aborted due to PR not made from develop branch" - } - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow''' - } - } - } - } - } - - } - - post { - always { - cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) - } - changed { - script { - def details = """

${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${currentBuild.currentResult}

-

Check console output at ${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}

- """ - emailext( - subject: '$DEFAULT_SUBJECT', - body: details, - attachLog: true, - compressLog: true, - recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'CulpritsRecipientProvider']] - ) - } - } - } -} diff --git a/Makefile b/Makefile index 4a5cbed..cec7c10 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,11 @@ VOLTO_VERSION?=16 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 @@ -77,11 +82,11 @@ shell: ## Start a shell in the frontend container .PHONY: cypress-open cypress-open: ## Open cypress integration tests - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open + 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 - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run + CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium .PHONY: test test: ## Run jest tests @@ -97,12 +102,12 @@ stylelint: ## Stylelint .PHONY: stylelint-overrides stylelint-overrides: - $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' + $(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' .PHONY: stylelint-fix stylelint-fix: ## Fix stylelint $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix - $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix + $(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix .PHONY: prettier prettier: ## Prettier @@ -129,3 +134,30 @@ i18n: ## i18n 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: cypress-ci +cypress-ci: + $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000 + NODE_ENV=development make cypress-run + + diff --git a/Makefile.tpl b/Makefile.tpl deleted file mode 100644 index b256914..0000000 --- a/Makefile.tpl +++ /dev/null @@ -1,97 +0,0 @@ -SHELL=/bin/bash - -DIR=$(shell basename $$(pwd)) -ADDON ?= "<%= addonName %>" - -# 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` - -ifeq ($(wildcard ./project),) - NODE_MODULES = "../../../node_modules" -else - NODE_MODULES = "./project/node_modules" -endif - -project: - npm install -g yo - npm install -g @plone/generator-volto - npm install -g mrs-developer - yo @plone/volto project --addon ${ADDON} --workspace "src/addons/${DIR}" --no-interactive - ln -sf $$(pwd) project/src/addons/ - cp .project.eslintrc.js .eslintrc.js - cd project && yarn - @echo "-------------------" - @echo "$(GREEN)Volto project is ready!$(RESET)" - @echo "$(RED)Now run: cd project && yarn start$(RESET)" - -all: project - -.PHONY: start-test-backend -start-test-backend: ## Start Test Plone Backend - @echo "$(GREEN)==> Start Test Plone Backend$(RESET)" - 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 - -.PHONY: start-backend-docker -start-backend-docker: ## Starts a Docker-based backend - @echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)" - docker run -it --rm --name=plone -p 8080:8080 -e SITE=Plone -e ADDONS="kitconcept.volto" -e ZCML="kitconcept.volto.cors" plone - -.PHONY: test -test: ## Run jest tests - docker pull plone/volto-addon-ci:alpha - 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 - -.PHONY: test-update -test-update: ## Update jest tests snapshots - docker pull plone/volto-addon-ci:alpha - 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 - -.PHONY: stylelint -stylelint: ## Stylelint - $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' - -.PHONY: stylelint-overrides -stylelint-overrides: - $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' - -.PHONY: stylelint-fix -stylelint-fix: ## Fix stylelint - $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix - $(NODE_MODULES)/.bin/stylelint --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)/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}' - -.PHONY: lint-fix -lint-fix: ## Fix ES Lint - $(NODE_MODULES)/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}' - -.PHONY: i18n -i18n: ## i18n - rm -rf build/messages - NODE_ENV=development $(NODE_MODULES)/.bin/i18n --addon - -.PHONY: cypress-run -cypress-run: ## Run cypress integration tests - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run - -.PHONY: cypress-open -cypress-open: ## Open cypress integration tests - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open - -.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 :)" diff --git a/README.md.tpl b/README.md.tpl deleted file mode 100644 index 12e4b8f..0000000 --- a/README.md.tpl +++ /dev/null @@ -1,80 +0,0 @@ -# <%= name %> - -[![Releases](https://img.shields.io/github/v/release/eea/<%= name %>)](https://github.com/eea/<%= name %>/releases) - -[![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2F<%= name %>%2Fmaster&subject=master)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/<%= name %>/job/master/display/redirect) -[![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-master&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-master) -[![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-master&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-master) -[![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-master&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-master) -[![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-master&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-master) - -[![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2F<%= name %>%2Fdevelop&subject=develop)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/<%= name %>/job/develop/display/redirect) -[![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-develop&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-develop) -[![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-develop&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-develop) -[![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-develop) -[![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=<%= name %>-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=<%= name %>-develop) - - -[Volto](https://github.com/plone/volto) add-on - -## Features - -Demo GIF - -## Getting started - -### Add <%= name %> to your Volto project - -1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone - -1. Start Volto frontend - -* If you already have a volto project, just update `package.json`: - - ```JSON - "addons": [ - "<%= addonName %>" - ], - - "dependencies": { - "<%= addonName %>": "*" - } - ``` - -* If not, create one: - - ``` - npm install -g yo @plone/generator-volto - yo @plone/volto my-volto-project --canary --addon <%= addonName %> - cd my-volto-project - ``` - -1. Install new add-ons and restart Volto: - - ``` - yarn - yarn start - ``` - -1. Go to http://localhost:3000 - -1. Happy editing! - -## Release - -See [RELEASE.md](https://github.com/eea/<%= name %>/blob/master/RELEASE.md). - -## How to contribute - -See [DEVELOP.md](https://github.com/eea/<%= name %>/blob/master/DEVELOP.md). - -## Copyright and license - -The Initial Owner of the Original Code is European Environment Agency (EEA). -All Rights Reserved. - -See [LICENSE.md](https://github.com/eea/<%= name %>/blob/master/LICENSE.md) for details. - -## Funding - -[European Environment Agency (EU)](http://eea.europa.eu) diff --git a/RELEASE.md b/RELEASE.md index 24f98ee..4e311a0 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -20,9 +20,9 @@ You need to first install the [release-it](https://github.com/release-it/release ``` npm install -g release-it ``` - + Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository. - + Release-it is a tool that automates 4 important steps in the release process: 1. Version increase in `package.json` ( increased from the current version in `package.json`) @@ -30,45 +30,45 @@ Release-it is a tool that automates 4 important steps in the release process: 3. GitHub release on the commit with the changelog and package.json modification on the develop branch 4. NPM release ( by default it's disabled, but can be enabled in the configuration file ) -To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens) +To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens) ``` export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX ``` - + To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN : - + ``` echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc ``` #### Using release-it tool - + There are 3 yarn scripts that can be run to do the release ##### yarn release-beta -Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input). +Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input). ``` -? Select increment (next version): -❯ prepatch (0.1.1-beta.0) - preminor (0.2.0-beta.0) - premajor (1.0.0-beta.0) - Other, please specify... +? Select increment (next version): +❯ prepatch (0.1.1-beta.0) + preminor (0.2.0-beta.0) + premajor (1.0.0-beta.0) + Other, please specify... ``` ##### yarn release-major-beta Same as `yarn release-beta`, but with premajor version pre-selected. - + ##### yarn release Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other. #### Important notes -> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST. +> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST. > Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version). diff --git a/cypress.config.js b/cypress.config.js index 0755d54..7a9e0be 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,12 +2,12 @@ const { defineConfig } = require('cypress'); module.exports = defineConfig({ viewportWidth: 1280, - defaultCommandTimeout: 5000, + defaultCommandTimeout: 8888, chromeWebSecurity: false, reporter: 'junit', - video: true, + video: false, retries: { - runMode: 1, + runMode: 2, openMode: 0, }, reporterOptions: { @@ -19,7 +19,6 @@ module.exports = defineConfig({ setupNodeEvents(on, config) { // e2e testing node events setup code require('@cypress/code-coverage/task')(on, config); - require('cypress-fail-fast/plugin')(on, config); return config; }, baseUrl: 'http://localhost:3000', diff --git a/cypress/e2e/01-block-basics.cy.js b/cypress/e2e/01-block-basics.cy.js index 089c7b3..b3d6ad9 100644 --- a/cypress/e2e/01-block-basics.cy.js +++ b/cypress/e2e/01-block-basics.cy.js @@ -25,5 +25,11 @@ describe('Blocks Tests', () => { // then the page view should contain our changes cy.contains('My Add-on Page'); cy.get('.block.image'); + + cy.get('#toolbar-more').click(); + cy.get('.state-select .react-select-container') + .click() + .contains('Publish') + .click({ force: true }); }); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index f269a7f..6f813fd 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -71,7 +71,8 @@ Cypress.Commands.add( id: contentId, title: contentTitle, image: { - data: 'iVBORw0KGgoAAAANSUhEUgAAANcAAAA4CAMAAABZsZ3QAAAAM1BMVEX29fK42OU+oMvn7u9drtIPisHI4OhstdWZyt4fkcXX5+sAg74umMhNp86p0eJ7vNiKw9v/UV4wAAAAAXRSTlMAQObYZgAABBxJREFUeF7tmuty4yAMhZG4X2zn/Z92J5tsBJwWXG/i3XR6frW2Y/SBLIRAfaQUDNt8E5tLUt9BycfcKfq3R6Mlfyimtx4rzp+K3dtibXkor99zsEqLYZltblTecciogoh+TXfY1Ve4dn07rCDGG9dHSEEOg/GmXl0U1XDxTKxNK5De7BxsyyBr6gGm2/vPxKJ8F6f7BXKfRMp1xIWK9A+5ks25alSb353dWnDJN1k35EL5f8dVGifTf/4tjUuuFq7u4srmXC60yAmldLXIWbg65RKU87lcGxJCFqUPv0IacW0PmSivOZFLE908inPToMmii/roG+MRV/O8FU88i8tFsxV3a06MFUw0Qu7RmAtdV5/HVVaOVMTWNOWSwMljLhzhcB6XIS7OK5V6AvRDNN7t5VJWQs1J40UmalbK56usBG/CuCHSYuc+rkUGeMCViNRARPrzW52N3oQLe6WifNliSuuGaH3czbVNudI9s7ZLUCLHVwWlyES522o1t14uvmbblmVTKqFjaZYJFSTPP4dLL1kU1z7p0lzdbRulmEWLxoQX+z9ce7A8GqEEucllLxePuZwdJl1Lezu0hoswvTPt61DrFcRuujV/2cmlxaGBC7Aw6cpovGANwRiSdOAWJ5AGy4gLL64dl0QhUEAuEUNws+XxV+OKGPdw/hESGYF9XEGaFC7sNLMSXWJjHsnanYi87VK428N2uxpOjOFANcagLM5l+7mSycM8KknZpKLcGi6jmzWGr/vLurZ/0g4u9AZuAoeb5r1ceQhyiTPY1E4wUR6u/F3H2ojSpXMMriBPT9cezTto8Cx+MsglHL4fv1Rxrb1LVw9yvyQpJ3AhFnLZfuRLH2QsOG3FGGD20X/th/u5bFAt16Bt308KjF+MNOXgl/SquIEySX3GhaZvc67KZbDxcCDORz2N8yCWPaY5lyQZO7lQ29fnZbt3Xu6qoge4+DjXl/MocySPOp9rlvdyznahRyHEYd77v3LhugOXDv4J65QXfl803BDAdaWBEDhfVx7nKofjoVCgxnUAqw/UAUDPn788BDvQuG4TDtdtUPvzjSlXAB8DvaDOhhrmhwbywylXAm8CvaouikJTL93gs3y7Yy4VYbIxOHrcMizPqWOjqO9l3Uz52kibQy4xxOgqhJvD+w5rvokOcAlGvNCfeqCv1ste1stzLm0f71Iq3ZfTrPfuE5nhPtF+LvQE2lffQC7pYtQy3tdzdrKvd5TLVVzDetScS3nEKmmwDyt1Cev1kX3YfbvzNK4fzrlw+cB6vm+uiUgf2zdXI62241LawCb7Pi5FXFPF8KpzDoF/Sw2lg+GrHNbno1mhPu+VCF/vfMnw06PnUl6j48dVHD3jHNHPua+fc3o/5yp/zsGi0vYtzi3Pz5mHd4T6BWMIlewacd63AAAAAElFTkSuQmCC', + data: + 'iVBORw0KGgoAAAANSUhEUgAAANcAAAA4CAMAAABZsZ3QAAAAM1BMVEX29fK42OU+oMvn7u9drtIPisHI4OhstdWZyt4fkcXX5+sAg74umMhNp86p0eJ7vNiKw9v/UV4wAAAAAXRSTlMAQObYZgAABBxJREFUeF7tmuty4yAMhZG4X2zn/Z92J5tsBJwWXG/i3XR6frW2Y/SBLIRAfaQUDNt8E5tLUt9BycfcKfq3R6Mlfyimtx4rzp+K3dtibXkor99zsEqLYZltblTecciogoh+TXfY1Ve4dn07rCDGG9dHSEEOg/GmXl0U1XDxTKxNK5De7BxsyyBr6gGm2/vPxKJ8F6f7BXKfRMp1xIWK9A+5ks25alSb353dWnDJN1k35EL5f8dVGifTf/4tjUuuFq7u4srmXC60yAmldLXIWbg65RKU87lcGxJCFqUPv0IacW0PmSivOZFLE908inPToMmii/roG+MRV/O8FU88i8tFsxV3a06MFUw0Qu7RmAtdV5/HVVaOVMTWNOWSwMljLhzhcB6XIS7OK5V6AvRDNN7t5VJWQs1J40UmalbK56usBG/CuCHSYuc+rkUGeMCViNRARPrzW52N3oQLe6WifNliSuuGaH3czbVNudI9s7ZLUCLHVwWlyES522o1t14uvmbblmVTKqFjaZYJFSTPP4dLL1kU1z7p0lzdbRulmEWLxoQX+z9ce7A8GqEEucllLxePuZwdJl1Lezu0hoswvTPt61DrFcRuujV/2cmlxaGBC7Aw6cpovGANwRiSdOAWJ5AGy4gLL64dl0QhUEAuEUNws+XxV+OKGPdw/hESGYF9XEGaFC7sNLMSXWJjHsnanYi87VK428N2uxpOjOFANcagLM5l+7mSycM8KknZpKLcGi6jmzWGr/vLurZ/0g4u9AZuAoeb5r1ceQhyiTPY1E4wUR6u/F3H2ojSpXMMriBPT9cezTto8Cx+MsglHL4fv1Rxrb1LVw9yvyQpJ3AhFnLZfuRLH2QsOG3FGGD20X/th/u5bFAt16Bt308KjF+MNOXgl/SquIEySX3GhaZvc67KZbDxcCDORz2N8yCWPaY5lyQZO7lQ29fnZbt3Xu6qoge4+DjXl/MocySPOp9rlvdyznahRyHEYd77v3LhugOXDv4J65QXfl803BDAdaWBEDhfVx7nKofjoVCgxnUAqw/UAUDPn788BDvQuG4TDtdtUPvzjSlXAB8DvaDOhhrmhwbywylXAm8CvaouikJTL93gs3y7Yy4VYbIxOHrcMizPqWOjqO9l3Uz52kibQy4xxOgqhJvD+w5rvokOcAlGvNCfeqCv1ste1stzLm0f71Iq3ZfTrPfuE5nhPtF+LvQE2lffQC7pYtQy3tdzdrKvd5TLVVzDetScS3nEKmmwDyt1Cev1kX3YfbvzNK4fzrlw+cB6vm+uiUgf2zdXI62241LawCb7Pi5FXFPF8KpzDoF/Sw2lg+GrHNbno1mhPu+VCF/vfMnw06PnUl6j48dVHD3jHNHPua+fc3o/5yp/zsGi0vYtzi3Pz5mHd4T6BWMIlewacd63AAAAAElFTkSuQmCC', encoding: 'base64', filename: 'image.png', 'content-type': 'image/png', @@ -124,7 +125,7 @@ Cypress.Commands.add( }) .then(() => console.log(`${contentType} created`)); } - } + }, ); // --- Add DX Content-Type ---------------------------------------------------------- @@ -217,7 +218,7 @@ Cypress.Commands.add('removeSlateJSONField', (type, name) => { body: {}, }) .then(() => - console.log(`${name} SlateJSONField field removed from ${type}`) + console.log(`${name} SlateJSONField field removed from ${type}`), ); }); @@ -251,7 +252,7 @@ Cypress.Commands.add('typeInSlate', { prevSubject: true }, (subject, text) => { new InputEvent('beforeinput', { inputType: 'insertText', data: text, - }) + }), ); return subject; }) @@ -267,7 +268,7 @@ Cypress.Commands.add('lineBreakInSlate', { prevSubject: true }, (subject) => { .wrap(subject) .then((subject) => { subject[0].dispatchEvent( - new InputEvent('beforeinput', { inputType: 'insertLineBreak' }) + new InputEvent('beforeinput', { inputType: 'insertLineBreak' }), ); return subject; }) @@ -315,7 +316,7 @@ Cypress.Commands.add( include_children: include_children, }, }); - } + }, ); // --- waitForResourceToLoad ---------------------------------------------------------- @@ -375,7 +376,7 @@ Cypress.Commands.add( setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset); } }); - } + }, ); Cypress.Commands.add('getSlate', ({ createNewSlate = true } = {}) => { @@ -390,7 +391,7 @@ Cypress.Commands.add('getSlate', ({ createNewSlate = true } = {}) => { cy.get('.block.inner').last().type('{moveToEnd}{enter}'); } slate = cy.get(SLATE_SELECTOR, { timeout: 10000 }).last(); - } + }, ); return slate; }); @@ -470,7 +471,7 @@ Cypress.Commands.add( }); // Depending on what you're testing, you may need to chain a `.click()` here to ensure // further commands are picked up by whatever you're testing (this was required for Slate, for example). - } + }, ); Cypress.Commands.add( @@ -478,7 +479,7 @@ Cypress.Commands.add( { prevSubject: true }, (subject, query) => { cy.wrap(subject).setCursor(query, true); - } + }, ); Cypress.Commands.add( @@ -486,7 +487,7 @@ Cypress.Commands.add( { prevSubject: true }, (subject, query) => { cy.wrap(subject).setCursor(query); - } + }, ); // Helper functions @@ -532,5 +533,5 @@ Cypress.Commands.add( failAction(); } }); - } + }, ); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index b7c02f2..e77df61 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -21,9 +21,6 @@ import './commands'; //Generate code-coverage import '@cypress/code-coverage/support'; -// Fail Fast -import "cypress-fail-fast"; - export const slateBeforeEach = (contentType = 'Document') => { cy.autologin(); cy.createContent({ @@ -32,14 +29,14 @@ export const slateBeforeEach = (contentType = 'Document') => { contentTitle: 'Cypress', }); cy.createContent({ - contentType: contentType, + contentType: 'Document', contentId: 'my-page', contentTitle: 'My Page', path: 'cypress', }); cy.visit('/cypress/my-page'); cy.waitForResourceToLoad('@navigation'); - cy.waitForResourceToLoad('@breadcrumbs'); + // cy.waitForResourceToLoad('@breadcrumbs'); cy.waitForResourceToLoad('@actions'); cy.waitForResourceToLoad('@types'); cy.waitForResourceToLoad('my-page'); diff --git a/package.json b/package.json index a515dd0..3263d99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-forest-policy", - "version": "0.1.25", + "version": "0.1.26", "description": "@eeacms/volto-forest-policy: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", @@ -16,10 +16,15 @@ "type": "git", "url": "git@github.com:eea/volto-forest-policy.git" }, + "resolutions": { + "react-countup/countup.js": "2.5.0", + "d3-array": "^2.12.1" + }, "addons": [ "@eeacms/volto-eea-map", "@eeacms/volto-plotlycharts", "@eeacms/volto-datablocks", + "@eeacms/volto-embed", "@eeacms/volto-openlayers-map", "@eeacms/volto-matomo", "@eeacms/volto-eea-design-system", @@ -32,12 +37,14 @@ "@eeacms/volto-eea-design-system": "*", "@eeacms/volto-eea-map": "*", "@eeacms/volto-eea-website-theme": "*", + "@eeacms/volto-embed": "*", "@eeacms/volto-globalsearch": "*", "@eeacms/volto-matomo": "*", "@eeacms/volto-openlayers-map": "0.1.4", "@eeacms/volto-plotlycharts": "*", "@eeacms/volto-searchlib": "*", "@sentry/browser": "7.17.3", + "d3-array": "^2.12.1", "dompurify": "^2.0.12", "draft-js-alignment-plugin": "^2.0.6", "draft-js-focus-plugin": "^3.0.1", @@ -64,10 +71,10 @@ "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", "cypress-fail-fast": "^5.0.1", + "husky": "^8.0.3", + "lint-staged": "^14.0.1", "md5": "^2.3.0", - "postcss-less": "6.0.0", - "husky": "*", - "lint-staged": "*" + "postcss-less": "6.0.0" }, "lint-staged": { "src/**/*.{js,jsx,ts,tsx,json}": [ diff --git a/package.json.tpl b/package.json.tpl deleted file mode 100644 index a486aa7..0000000 --- a/package.json.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "<%= addonName %>", - "version": "0.1.0", - "description": "<%= addonName %>: Volto add-on", - "main": "src/index.js", - "author": "European Environment Agency: IDM2 A-Team", - "license": "MIT", - "homepage": "https://github.com/eea/<%= name %>", - "keywords": [ - "volto-addon", - "volto", - "plone", - "react" - ], - "repository": { - "type": "git", - "url": "git@github.com:eea/<%= name %>.git" - }, - "dependencies": {}, - "devDependencies": { - "@plone/scripts": "*", - "@cypress/code-coverage": "^3.10.0", - "cypress-fail-fast": "^5.0.1", - "babel-plugin-transform-class-properties": "^6.24.1", - "md5": "^2.3.0" - }, - "scripts": { - "release": "release-it", - "release-major-beta": "release-it major --preRelease=beta", - "release-beta": "release-it --preRelease=beta", - "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap", - "test": "make test", - "test:fix": "make test-update", - "pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix", - "stylelint": "make stylelint", - "stylelint:overrides": "make stylelint-overrides", - "stylelint:fix": "make stylelint-fix", - "prettier": "make prettier", - "prettier:fix": "make prettier-fix", - "lint": "make lint", - "lint:fix": "make lint-fix", - "i18n": "make i18n", - "cypress:run": "make cypress-run", - "cypress:open": "make cypress-open" - } -} diff --git a/src/components/manage/Blocks/DiscodataConnectorBlock/v1/View.jsx b/src/components/manage/Blocks/DiscodataConnectorBlock/v1/View.jsx index 565b31b..6b348a9 100644 --- a/src/components/manage/Blocks/DiscodataConnectorBlock/v1/View.jsx +++ b/src/components/manage/Blocks/DiscodataConnectorBlock/v1/View.jsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import { compose } from 'redux'; import { connectToMultipleProviders } from '@eeacms/volto-datablocks/hocs'; import { DataConnectedValue } from '@eeacms/volto-datablocks/Utils'; -import { Sources } from '@eeacms/volto-datablocks/Utils'; +import { Sources } from '@eeacms/volto-embed/Toolbar'; const providerView = (dataProviderKey, dataProvider, editMode) => { return ( diff --git a/src/components/manage/Blocks/DiscodataConnectorBlock/v2/View.jsx b/src/components/manage/Blocks/DiscodataConnectorBlock/v2/View.jsx index b0f1d11..e97c75e 100644 --- a/src/components/manage/Blocks/DiscodataConnectorBlock/v2/View.jsx +++ b/src/components/manage/Blocks/DiscodataConnectorBlock/v2/View.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { compose } from 'redux'; import { connectToMultipleProviders } from '@eeacms/volto-datablocks/hocs'; import { DataConnectedValue } from '@eeacms/volto-datablocks/Utils'; -import { Sources } from '@eeacms/volto-datablocks/Utils'; +import { Sources } from '@eeacms/volto-embed/Toolbar'; const ProviderView = ({ provider }) => { if (!provider) return ''; diff --git a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx index eabd135..235c277 100644 --- a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx +++ b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx @@ -26,10 +26,9 @@ class Edit extends Component { if (!provider_data) return schema; - const choices = Array.from(Object.keys(provider_data).sort()).map((n) => [ - n, - n, - ]); + const choices = Array.from( + Object.keys(provider_data).sort((a, b) => a.localeCompare(b)), + ).map((n) => [n, n]); schema.properties.columns.schema.properties.column.choices = choices; schema.properties.columns.schema.properties.column_link.choices = choices; @@ -52,11 +51,15 @@ class Edit extends Component { : ''; const mapChoices = map_provider_data - ? Array.from(Object.keys(map_provider_data).sort()).map((n) => [n, n]) + ? Array.from( + Object.keys(map_provider_data).sort((a, b) => a.localeCompare(b)), + ).map((n) => [n, n]) : []; const tableChoices = table_provider_data - ? Array.from(Object.keys(table_provider_data).sort()).map((n) => [n, n]) + ? Array.from( + Object.keys(table_provider_data).sort((a, b) => a.localeCompare(b)), + ).map((n) => [n, n]) : []; schema.properties.popup_data_query.choices = choices; diff --git a/src/components/manage/Widgets/Object.jsx b/src/components/manage/Widgets/ObjectItem.jsx similarity index 87% rename from src/components/manage/Widgets/Object.jsx rename to src/components/manage/Widgets/ObjectItem.jsx index 7ad9fb9..5364b5f 100644 --- a/src/components/manage/Widgets/Object.jsx +++ b/src/components/manage/Widgets/ObjectItem.jsx @@ -3,7 +3,7 @@ import { Field } from '@plone/volto/components'; // TODO: handle more then the default schema? -const Object = ({ schema, value, onChange, errors = {} }) => { +const ObjectItem = ({ schema, value, onChange, errors = {} }) => { return ( <> {schema.fieldsets[0].fields.map((field, index) => { @@ -25,4 +25,4 @@ const Object = ({ schema, value, onChange, errors = {} }) => { ); }; -export default Object; +export default ObjectItem; diff --git a/src/components/manage/Widgets/ObjectList.jsx b/src/components/manage/Widgets/ObjectList.jsx index f5ae2c1..029f18c 100644 --- a/src/components/manage/Widgets/ObjectList.jsx +++ b/src/components/manage/Widgets/ObjectList.jsx @@ -15,7 +15,7 @@ import { Icon as VoltoIcon } from '@plone/volto/components'; import deleteSVG from '@plone/volto/icons/delete.svg'; import penSVG from '@plone/volto/icons/pen.svg'; -import ObjectWidget from './Object'; +import ObjectWidget from './ObjectItem'; export const FlatObjectList = ({ id, value = [], schema, onChange }) => { return (