Skip to content

Commit 2f00257

Browse files
authored
feat: Add Volto 17 support - refs #264527
1 parent a76cf1a commit 2f00257

22 files changed

+718
-332
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Jest configuration variables
2+
# - possible values: ON, OFF
3+
JEST_USE_SETUP=OFF

.eslintrc.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const projectRootPath = fs.realpathSync(__dirname + '/../../../');
4+
5+
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
6+
let configFile;
7+
if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
8+
configFile = `${projectRootPath}/tsconfig.json`;
9+
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
10+
configFile = `${projectRootPath}/jsconfig.json`;
11+
12+
if (configFile) {
13+
const jsConfig = require(configFile).compilerOptions;
14+
const pathsConfig = jsConfig.paths;
15+
if (pathsConfig['@plone/volto'])
16+
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
17+
}
18+
19+
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20+
const reg = new AddonConfigurationRegistry(projectRootPath);
21+
22+
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23+
const addonAliases = Object.keys(reg.packages).map((o) => [
24+
o,
25+
reg.packages[o].modulePath,
26+
]);
27+
28+
const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
29+
30+
const defaultConfig = {
31+
extends: `${voltoPath}/.eslintrc`,
32+
settings: {
33+
'import/resolver': {
34+
alias: {
35+
map: [
36+
['@plone/volto', '@plone/volto/src'],
37+
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
38+
...addonAliases,
39+
['@package', `${__dirname}/src`],
40+
['@root', `${__dirname}/src`],
41+
['~', `${__dirname}/src`],
42+
],
43+
extensions: ['.js', '.jsx', '.json'],
44+
},
45+
'babel-plugin-root-import': {
46+
rootPathSuffix: 'src',
47+
},
48+
},
49+
},
50+
rules: {
51+
'react/jsx-no-target-blank': [
52+
'error',
53+
{
54+
allowReferrer: true,
55+
},
56+
],
57+
}
58+
};
59+
60+
const config = addonExtenders.reduce(
61+
(acc, extender) => extender.modify(acc),
62+
defaultConfig,
63+
);
64+
65+
module.exports = config;

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.vscode/
22
.history
3-
.eslintrc.js
43
.nyc_output
54
project
65
coverage

.project.eslintrc.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22
ARG VOLTO_VERSION
3-
FROM plone/frontend-builder:${VOLTO_VERSION}
3+
FROM eeacms/frontend-builder:${VOLTO_VERSION}
44

55
ARG ADDON_NAME
66
ARG ADDON_PATH

0 commit comments

Comments
 (0)