@eeacms/volto-eea-kitkat 4.1.6 → 4.1.7

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,15 @@ 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.1.7](https://github.com/eea/volto-eea-kitkat/compare/4.1.6...4.1.7)
8
+
9
+ - Cleanup obsolte i18n script [`8d8896d`](https://github.com/eea/volto-eea-kitkat/commit/8d8896db6227ec14eb536cee4b632cdeeeed56aa)
10
+
7
11
  #### [4.1.6](https://github.com/eea/volto-eea-kitkat/compare/4.1.5...4.1.6)
8
12
 
13
+ > 24 November 2021
14
+
15
+ - Develop [`#19`](https://github.com/eea/volto-eea-kitkat/pull/19)
9
16
  - Cypress tests in child addons [`#18`](https://github.com/eea/volto-eea-kitkat/pull/18)
10
17
  - screenshotOnRunFailure: false [`de33099`](https://github.com/eea/volto-eea-kitkat/commit/de330994f12db6e0436ddfcfa0dc173ddeff3778)
11
18
  - cy: upload video on failure [`b3c2b46`](https://github.com/eea/volto-eea-kitkat/commit/b3c2b464b14baf5e2a972bc001f5872288faa0a8)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-kitkat",
3
- "version": "4.1.6",
3
+ "version": "4.1.7",
4
4
  "description": "@eeacms/volto-eea-kitkat: Volto Add-ons bundle - A known good set of Volto addons to be used within all EEA projects and beyond",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -106,14 +106,15 @@
106
106
  },
107
107
  "devDependencies": {
108
108
  "@cypress/code-coverage": "^3.9.5",
109
- "babel-plugin-transform-class-properties": "^6.24.1"
109
+ "babel-plugin-transform-class-properties": "^6.24.1",
110
+ "@plone/scripts": "*"
110
111
  },
111
112
  "scripts": {
112
113
  "release": "release-it",
113
114
  "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
114
115
  "test": "make test",
115
116
  "test:fix": "make test-update",
116
- "i18n": "rm -rf build/messages && NODE_ENV=production node src/i18n.js",
117
+ "i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
117
118
  "pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix",
118
119
  "stylelint": "if [ -d ./project ]; then ./project/node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'; else ../../../node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'; fi",
119
120
  "stylelint:overrides": "if [ -d ./project ]; then ./project/node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'; else ../../../node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'; fi",
package/src/i18n.js DELETED
@@ -1,180 +0,0 @@
1
- /* eslint no-console: 0 */
2
- /**
3
- * i18n script.
4
- * @module scripts/i18n
5
- */
6
-
7
- const { find, keys, map, concat, reduce } = require('lodash');
8
- const glob = require('glob').sync;
9
- const fs = require('fs');
10
- const Pofile = require('pofile');
11
- const babel = require('@babel/core');
12
-
13
- /**
14
- * Extract messages into separate JSON files
15
- * @function extractMessages
16
- * @return {undefined}
17
- */
18
- function extractMessages() {
19
- map(glob('src/**/*.js?(x)'), (filename) => {
20
- babel.transformFileSync(filename, {}, (err) => {
21
- if (err) {
22
- console.log(err);
23
- }
24
- });
25
- });
26
- }
27
-
28
- /**
29
- * Get messages from separate JSON files
30
- * @function getMessages
31
- * @return {Object} Object with messages
32
- */
33
- function getMessages() {
34
- return reduce(
35
- concat(
36
- {},
37
- ...map(
38
- // We ignore the existing customized shadowed components ones, since most
39
- // probably we won't be overriding them
40
- // If so, we should do it in the config object or somewhere else
41
- glob('build/messages/src/**/*.json', {
42
- ignore: 'build/messages/src/customizations/**',
43
- }),
44
- (filename) =>
45
- map(JSON.parse(fs.readFileSync(filename, 'utf8')), (message) => ({
46
- ...message,
47
- filename: filename.match(/build\/messages\/src\/(.*).json$/)[1],
48
- })),
49
- ),
50
- ),
51
- (current, value) => {
52
- let result = current;
53
- if (current.id) {
54
- result = {
55
- [current.id]: {
56
- defaultMessage: current.defaultMessage,
57
- filenames: [current.filename],
58
- },
59
- };
60
- }
61
-
62
- if (result[value.id]) {
63
- result[value.id].filenames.push(value.filename);
64
- } else {
65
- result[value.id] = {
66
- defaultMessage: value.defaultMessage,
67
- filenames: [value.filename],
68
- };
69
- }
70
- return result;
71
- },
72
- );
73
- }
74
-
75
- /**
76
- * Convert messages to pot format
77
- * @function messagesToPot
78
- * @param {Object} messages Messages
79
- * @return {string} Formatted pot string
80
- */
81
- function messagesToPot(messages) {
82
- return map(keys(messages).sort(), (key) =>
83
- [
84
- ...map(messages[key].filenames, (filename) => `#: ${filename}`),
85
- `# defaultMessage: ${messages[key].defaultMessage}`,
86
- `msgid "${key}"`,
87
- 'msgstr ""',
88
- ].join('\n'),
89
- ).join('\n\n');
90
- }
91
-
92
- /**
93
- * Pot header
94
- * @function potHeader
95
- * @return {string} Formatted pot header
96
- */
97
- function potHeader() {
98
- return `msgid ""
99
- msgstr ""
100
- "Project-Id-Version: Plone\\n"
101
- "POT-Creation-Date: ${new Date().toISOString()}\\n"
102
- "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"
103
- "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"
104
- "MIME-Version: 1.0\\n"
105
- "Content-Type: text/plain; charset=utf-8\\n"
106
- "Content-Transfer-Encoding: 8bit\\n"
107
- "Plural-Forms: nplurals=1; plural=0;\\n"
108
- "Language-Code: en\\n"
109
- "Language-Name: English\\n"
110
- "Preferred-Encodings: utf-8\\n"
111
- "Domain: volto\\n"
112
-
113
- `;
114
- }
115
-
116
- /**
117
- * Format header
118
- * @function formatHeader
119
- * @param {Array} comments Array of comments
120
- * @param {Object} headers Object of header items
121
- * @return {string} Formatted header
122
- */
123
- function formatHeader(comments, headers) {
124
- return [
125
- ...map(comments, (comment) => `# ${comment}`),
126
- 'msgid ""',
127
- 'msgstr ""',
128
- ...map(keys(headers), (key) => `"${key}: ${headers[key]}\\n"`),
129
- '',
130
- ].join('\n');
131
- }
132
-
133
- /**
134
- * Sync po by the pot file
135
- * @function syncPoByPot
136
- * @return {undefined}
137
- */
138
- function syncPoByPot() {
139
- const pot = Pofile.parse(fs.readFileSync('locales/volto.pot', 'utf8'));
140
-
141
- map(glob('locales/**/*.po'), (filename) => {
142
- const po = Pofile.parse(fs.readFileSync(filename, 'utf8'));
143
-
144
- fs.writeFileSync(
145
- filename,
146
- `${formatHeader(po.comments, po.headers)}
147
- ${map(pot.items, (item) => {
148
- const poItem = find(po.items, { msgid: item.msgid });
149
- return [
150
- `${map(item.references, (ref) => `#: ${ref}`).join('\n')}`,
151
- `msgid "${item.msgid}"`,
152
- `msgstr "${poItem ? poItem.msgstr : ''}"`,
153
- ].join('\n');
154
- }).join('\n\n')}\n`,
155
- );
156
- });
157
- }
158
-
159
- // Main tasks
160
- console.log('Extracting messages from source files...');
161
- extractMessages();
162
- console.log('Synchronizing messages to pot file...');
163
- // We only write the pot file if it's really different
164
- const newPot = `${potHeader()}${messagesToPot(getMessages())}\n`.replace(
165
- /"POT-Creation-Date:(.*)\\n"/,
166
- '',
167
- );
168
- const oldPot = fs
169
- .readFileSync('locales/volto.pot', 'utf8')
170
- .replace(/"POT-Creation-Date:(.*)\\n"/, '');
171
-
172
- if (newPot !== oldPot) {
173
- fs.writeFileSync(
174
- 'locales/volto.pot',
175
- `${potHeader()}${messagesToPot(getMessages())}\n`,
176
- );
177
- }
178
- console.log('Synchronizing messages to po files...');
179
- syncPoByPot();
180
- console.log('done!');