@eeacms/volto-slate-footnote 4.0.2 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,8 +4,27 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [4.0.5](https://github.com/eea/volto-slate-footnote/compare/4.0.4...4.0.5)
8
+
9
+ - Allow other block types to define footnotes - refs #148688 [`12f5920`](https://github.com/eea/volto-slate-footnote/commit/12f592019bbc37d71c14a64387ef9fbaf1828adc)
10
+
11
+ #### [4.0.4](https://github.com/eea/volto-slate-footnote/compare/4.0.3...4.0.4)
12
+
13
+ > 3 January 2022
14
+
15
+
16
+ #### [4.0.3](https://github.com/eea/volto-slate-footnote/compare/4.0.2...4.0.3)
17
+
18
+ > 18 December 2021
19
+
20
+ - Add SonarQube badges [`#29`](https://github.com/eea/volto-slate-footnote/pull/29)
21
+ - Refs #142010 - Optimize Volto-addons gitflow pipelines [`1081079`](https://github.com/eea/volto-slate-footnote/commit/1081079444f5ac806e9d56765c4ccf0b9e415a73)
22
+
7
23
  #### [4.0.2](https://github.com/eea/volto-slate-footnote/compare/4.0.1...4.0.2)
8
24
 
25
+ > 30 September 2021
26
+
27
+ - Make footnotes aware of Metadata / Metadata section block / Slate Table [`#27`](https://github.com/eea/volto-slate-footnote/pull/27)
9
28
  - Multiple citations [`#26`](https://github.com/eea/volto-slate-footnote/pull/26)
10
29
  - Remove :asDefault dependency from volto-slate [`13dad5e`](https://github.com/eea/volto-slate-footnote/commit/13dad5ed23043fa7a24682e1ac6addc86632bfe0)
11
30
 
package/Jenkinsfile CHANGED
@@ -4,13 +4,37 @@ pipeline {
4
4
  environment {
5
5
  GIT_NAME = "volto-slate-footnote"
6
6
  NAMESPACE = "@eeacms"
7
- SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu"
7
+ SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu"
8
8
  DEPENDENCIES = "volto-slate:asDefault"
9
9
  }
10
10
 
11
11
  stages {
12
12
 
13
+ stage('Release') {
14
+ when {
15
+ allOf {
16
+ environment name: 'CHANGE_ID', value: ''
17
+ branch 'master'
18
+ }
19
+ }
20
+ steps {
21
+ node(label: 'docker') {
22
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
23
+ sh '''docker pull eeacms/gitflow'''
24
+ 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'''
25
+ }
26
+ }
27
+ }
28
+ }
29
+
13
30
  stage('Code') {
31
+ when {
32
+ allOf {
33
+ environment name: 'CHANGE_ID', value: ''
34
+ not { changelog '.*^Automated release [0-9\\.]+$' }
35
+ not { branch 'master' }
36
+ }
37
+ }
14
38
  steps {
15
39
  parallel(
16
40
 
@@ -36,6 +60,15 @@ pipeline {
36
60
  }
37
61
 
38
62
  stage('Tests') {
63
+ when {
64
+ allOf {
65
+ environment name: 'CHANGE_ID', value: ''
66
+ anyOf {
67
+ not { changelog '.*^Automated release [0-9\\.]+$' }
68
+ branch 'master'
69
+ }
70
+ }
71
+ }
39
72
  steps {
40
73
  parallel(
41
74
 
@@ -75,6 +108,15 @@ pipeline {
75
108
  }
76
109
 
77
110
  stage('Integration tests') {
111
+ when {
112
+ allOf {
113
+ environment name: 'CHANGE_ID', value: ''
114
+ anyOf {
115
+ not { changelog '.*^Automated release [0-9\\.]+$' }
116
+ branch 'master'
117
+ }
118
+ }
119
+ }
78
120
  steps {
79
121
  parallel(
80
122
 
@@ -82,7 +124,7 @@ pipeline {
82
124
  node(label: 'docker') {
83
125
  script {
84
126
  try {
85
- sh '''docker pull plone; docker run -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg'''
127
+ sh '''docker pull plone; docker run -d --rm --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg'''
86
128
  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" plone/volto-addon-ci cypress'''
87
129
  } finally {
88
130
  try {
@@ -100,7 +142,8 @@ pipeline {
100
142
  reportName: 'CypressCoverage',
101
143
  reportTitles: 'Integration Tests Code Coverage'])
102
144
  }
103
- archiveArtifacts artifacts: 'cypress-reports/videos/*.mp4', fingerprint: true
145
+ 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'''
146
+ archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true
104
147
  stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true
105
148
  }
106
149
  finally {
@@ -122,10 +165,16 @@ pipeline {
122
165
  }
123
166
 
124
167
  stage('Report to SonarQube') {
125
- // Exclude Pull-Requests
126
168
  when {
127
169
  allOf {
128
170
  environment name: 'CHANGE_ID', value: ''
171
+ anyOf {
172
+ branch 'master'
173
+ allOf {
174
+ branch 'develop'
175
+ not { changelog '.*^Automated release [0-9\\.]+$' }
176
+ }
177
+ }
129
178
  }
130
179
  }
131
180
  steps {
@@ -135,10 +184,10 @@ pipeline {
135
184
  unstash "xunit-reports"
136
185
  unstash "cypress-coverage"
137
186
  def scannerHome = tool 'SonarQubeScanner';
138
- def nodeJS = tool 'NodeJS11';
187
+ def nodeJS = tool 'NodeJS';
139
188
  withSonarQubeEnv('Sonarqube') {
140
189
  sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
141
- sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; 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"
190
+ 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"
142
191
  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'''
143
192
  }
144
193
  }
@@ -156,8 +205,8 @@ pipeline {
156
205
  steps {
157
206
  node(label: 'docker') {
158
207
  script {
159
- if ( env.CHANGE_BRANCH != "develop" && !( env.CHANGE_BRANCH.startsWith("hotfix")) ) {
160
- error "Pipeline aborted due to PR not made from develop or hotfix branch"
208
+ if ( env.CHANGE_BRANCH != "develop" ) {
209
+ error "Pipeline aborted due to PR not made from develop branch"
161
210
  }
162
211
  withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
163
212
  sh '''docker pull eeacms/gitflow'''
@@ -168,23 +217,6 @@ pipeline {
168
217
  }
169
218
  }
170
219
 
171
- stage('Release') {
172
- when {
173
- allOf {
174
- environment name: 'CHANGE_ID', value: ''
175
- branch 'master'
176
- }
177
- }
178
- steps {
179
- node(label: 'docker') {
180
- withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
181
- sh '''docker pull eeacms/gitflow'''
182
- 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'''
183
- }
184
- }
185
- }
186
- }
187
-
188
220
  }
189
221
 
190
222
  post {
package/README.md CHANGED
@@ -1,7 +1,19 @@
1
1
  # volto-slate-footnote
2
+
2
3
  [![Releases](https://img.shields.io/github/v/release/eea/volto-slate-footnote)](https://github.com/eea/volto-slate-footnote/releases)
4
+
3
5
  [![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-slate-footnote%2Fmaster&subject=master)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-slate-footnote/job/master/display/redirect)
6
+ [![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-master&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-master)
7
+ [![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-master&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-master)
8
+ [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-master&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-master)
9
+ [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-master&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-master)
10
+
4
11
  [![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-slate-footnote%2Fdevelop&subject=develop)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-slate-footnote/job/develop/display/redirect)
12
+ [![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-develop&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-develop)
13
+ [![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-develop&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-develop)
14
+ [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-develop)
15
+ [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-slate-footnote-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-slate-footnote-develop)
16
+
5
17
 
6
18
  [Volto Slate](https://github.com/eea/volto-slate/tree/develop) Footnotes
7
19
 
@@ -75,6 +87,81 @@
75
87
 
76
88
  1. Happy editing!
77
89
 
90
+ ## Release
91
+
92
+ ### Automatic release using Jenkins
93
+
94
+ * The automatic release is started by creating a [Pull Request](../../compare/master...develop) from `develop` to `master`. The pull request status checks correlated to the branch and PR Jenkins jobs need to be processed successfully. 1 review from a github user with rights is mandatory.
95
+ * It runs on every commit on `master` branch, which is protected from direct commits, only allowing pull request merge commits.
96
+ * The automatic release is done by [Jenkins](https://ci.eionet.europa.eu). The status of the release job can be seen both in the Readme.md badges and the green check/red cross/yellow circle near the last commit information. If you click on the icon, you will have the list of checks that were run. The `continuous-integration/jenkins/branch` link goes to the Jenkins job execution webpage.
97
+ * Automated release scripts are located in the `eeacms/gitflow` docker image, specifically [js-release.sh](https://github.com/eea/eea.docker.gitflow/blob/master/src/js-release.sh) script. It uses the `release-it` tool.
98
+ * As long as a PR request is open from develop to master, the PR Jenkins job will automatically re-create the CHANGELOG.md and package.json files to be production-ready.
99
+ * The version format must be MAJOR.MINOR.PATCH. By default, next release is set to next minor version (with patch 0).
100
+ * You can manually change the version in `package.json`. The new version must not be already present in the tags/releases of the repository, otherwise it will be automatically increased by the script. Any changes to the version will trigger a `CHANGELOG.md` re-generation.
101
+ * Automated commits and commits with [JENKINS] or [YARN] in the commit log are excluded from `CHANGELOG.md` file.
102
+
103
+ ### Manual release from the develop branch ( beta release )
104
+
105
+ #### Installation and configuration of release-it
106
+
107
+ You need to first install the [release-it](https://github.com/release-it/release-it) client.
108
+
109
+ ```
110
+ npm install -g release-it
111
+ ```
112
+
113
+ Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.
114
+
115
+ Release-it is a tool that automates 4 important steps in the release process:
116
+
117
+ 1. Version increase in `package.json` ( increased from the current version in `package.json`)
118
+ 2. `CHANGELOG.md` automatic generation from commit messages ( grouped by releases )
119
+ 3. GitHub release on the commit with the changelog and package.json modification on the develop branch
120
+ 4. NPM release ( by default it's disabled, but can be enabled in the configuration file )
121
+
122
+ To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
123
+
124
+ ```
125
+ export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
126
+ ```
127
+
128
+ To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :
129
+
130
+ ```
131
+ echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
132
+ ```
133
+
134
+ #### Using release-it tool
135
+
136
+ There are 3 yarn scripts that can be run to do the release
137
+
138
+ ##### yarn release-beta
139
+
140
+ Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
141
+
142
+ ```
143
+ ? Select increment (next version):
144
+ ❯ prepatch (0.1.1-beta.0)
145
+ preminor (0.2.0-beta.0)
146
+ premajor (1.0.0-beta.0)
147
+ Other, please specify...
148
+ ```
149
+
150
+ ##### yarn release-major-beta
151
+
152
+ Same as `yarn release-beta`, but with premajor version pre-selected.
153
+
154
+ ##### yarn release
155
+
156
+ Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.
157
+
158
+ #### Important notes
159
+
160
+ > 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.
161
+
162
+ > 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).
163
+
164
+
78
165
  ## How to contribute
79
166
 
80
167
  See [DEVELOP.md](DEVELOP.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-slate-footnote",
3
- "version": "4.0.2",
3
+ "version": "4.0.5",
4
4
  "description": "volto-slate-footnote: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -30,6 +30,8 @@
30
30
  },
31
31
  "scripts": {
32
32
  "release": "release-it",
33
+ "release-major-beta": "release-it major --preRelease=beta",
34
+ "release-beta": "release-it --preRelease=beta",
33
35
  "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
34
36
  "test": "make test",
35
37
  "test:fix": "make test-update",
package/src/constants.js CHANGED
@@ -1 +1,2 @@
1
1
  export const FOOTNOTE = 'footnote';
2
+ export const SLATE = 'slate';
@@ -11,6 +11,7 @@ import { Node } from 'slate';
11
11
  import { useSelector } from 'react-redux';
12
12
  import { isEmpty } from 'lodash';
13
13
  import { getAllBlocksAndSlateFields } from '@eeacms/volto-slate-footnote/editor/utils';
14
+ import config from '@plone/volto/registry';
14
15
 
15
16
  const FootnoteEditor = (props) => {
16
17
  const {
@@ -66,7 +67,7 @@ const FootnoteEditor = (props) => {
66
67
  // add label and value for the multi search widget
67
68
  // flatten blocks to add all extra in the list
68
69
  flatAllBlocks
69
- .filter((b) => b['@type'] === 'slate')
70
+ .filter((b) => config.settings.blocksWithFootnotes.includes(b['@type']))
70
71
  .forEach(({ value }) => {
71
72
  if (!value) return;
72
73
 
@@ -118,7 +118,7 @@ export const makeFootnoteListOfUniqueItems = (blocks) => {
118
118
  let notesObjResult = {};
119
119
 
120
120
  blocks
121
- .filter((b) => b['@type'] === 'slate')
121
+ .filter((b) => config.settings.blocksWithFootnotes.includes(b['@type']))
122
122
  .forEach(({ value }) => {
123
123
  if (!value) return;
124
124
  // Node.elements(value[0]) returns an iterable generator of nodes
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ import codeSVG from '@plone/volto/icons/blog-entry.svg';
3
3
  import FootnotesBlockView from './Blocks/Footnote/FootnotesBlockView';
4
4
  import FootnotesBlockEdit from './Blocks/Footnote/FootnotesBlockEdit';
5
5
  import FootnotesBlockSchema from './Blocks/Footnote/FootnotesBlockSchema';
6
- import { FOOTNOTE } from './constants';
6
+ import { FOOTNOTE, SLATE } from './constants';
7
7
  import installFootnoteEditor from './editor';
8
8
  import SearchWidget from '@eeacms/volto-slate-footnote/editor/MultiSelectSearchWidget';
9
9
 
@@ -36,5 +36,10 @@ export default function install(config) {
36
36
  config.widgets.widget.searchInput = SearchWidget;
37
37
  config = installFootnoteEditor(config);
38
38
 
39
+ config.settings.blocksWithFootnotes = [
40
+ ...(config.settings.blocksWithFootnotes || []),
41
+ SLATE,
42
+ ];
43
+
39
44
  return config;
40
45
  }