@eeacms/volto-eea-versions 2.0.2 → 3.0.0

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,6 +4,12 @@ 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
+ ### [3.0.0](https://github.com/eea/volto-eea-versions/compare/2.0.2...3.0.0) - 20 November 2026
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: Volto 19 support - refs #297832 [Alin Voinea - [`13846ed`](https://github.com/eea/volto-eea-versions/commit/13846ed1ded3b4fba052bceee4b2cd5997472900)]
12
+
7
13
  ### [2.0.2](https://github.com/eea/volto-eea-versions/compare/2.0.1...2.0.2) - 27 July 2026
8
14
 
9
15
  #### :bug: Bug Fixes
@@ -11,10 +17,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
11
17
  - fix: Add edit property to LatestVersion and AllVersions - refs #305522 [dobri1408 - [`238b1c6`](https://github.com/eea/volto-eea-versions/commit/238b1c66804d1a2a64a7ef4841e079856af4c4c2)]
12
18
  - fix: Add betterleaks github action - refs #304517 [dobri1408 - [`f9765c4`](https://github.com/eea/volto-eea-versions/commit/f9765c438c6d84bca78a7b0cb80f877f34cdf203)]
13
19
 
14
- #### :house: Internal changes
15
-
16
- - chore: [JENKINSFILE] sanitize sonarqube command Refs #305084 [valentinab25 - [`7be20db`](https://github.com/eea/volto-eea-versions/commit/7be20db95a6ba843e4cd2c7a6f9624ff3330656b)]
17
-
18
20
  #### :hammer_and_wrench: Others
19
21
 
20
22
  - test: pin Chromium version 149 to work with Cypress [valentinab25 - [`5c70940`](https://github.com/eea/volto-eea-versions/commit/5c709402c1e036248016f9a30b461d203fb52bc8)]
@@ -30,11 +32,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
30
32
 
31
33
  - feat: Volto 18 support - refs #287700 [Alin Voinea - [`2e896cd`](https://github.com/eea/volto-eea-versions/commit/2e896cd9d1385fa50e0f77b66c035d210a61f5eb)]
32
34
 
33
- #### :house: Internal changes
34
-
35
- - chore: [JENKINSFILE] add package version in sonarqube [valentinab25 - [`2f4a62d`](https://github.com/eea/volto-eea-versions/commit/2f4a62d39d30b2e2bc44d367517121d39252b037)]
36
- - chore: [JENKINSFILE] use sonarqube branches [EEA Jenkins - [`75259dc`](https://github.com/eea/volto-eea-versions/commit/75259dcd39e2ae84ede23a47b50721654f7fe34f)]
37
-
38
35
  #### :hammer_and_wrench: Others
39
36
 
40
37
  - tests: Fix Sonar Qube tags - refs #297339 [Alin Voinea - [`ae18a8f`](https://github.com/eea/volto-eea-versions/commit/ae18a8ff1a05e9b6a53efe5e46b307e67084caf2)]
@@ -53,9 +50,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
53
50
  #### :hammer_and_wrench: Others
54
51
 
55
52
  - Release #4 from eea/develop [David Ichim - [`c649076`](https://github.com/eea/volto-eea-versions/commit/c64907618c948834331d98aa219809e3159289f4)]
56
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`68bb33d`](https://github.com/eea/volto-eea-versions/commit/68bb33d275e5484b022cf0aad5084f8da8f98de3)]
57
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`0abf06b`](https://github.com/eea/volto-eea-versions/commit/0abf06b6e67152960582e993d79e9c401e04cd1e)]
58
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`aaedb59`](https://github.com/eea/volto-eea-versions/commit/aaedb59a81591f6db124cf27ae3a074f05444a27)]
59
53
  ## [1.0.0](https://github.com/eea/volto-eea-versions/compare/0.2.0...1.0.0) - 18 December 2024
60
54
 
61
55
  #### :nail_care: Enhancements
@@ -92,6 +86,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
92
86
  - Removed next and previous versions components since we only need latest and all versions logic [David Ichim - [`4df102f`](https://github.com/eea/volto-eea-versions/commit/4df102f95744e7e95e26ccd386307973e9dcf90d)]
93
87
  - Started adding latest version and all version blocks while maintaining the previous logic for previous components [David Ichim - [`9f9d04b`](https://github.com/eea/volto-eea-versions/commit/9f9d04b4fda0b9606ffb038bdd4c53615ce54d3e)]
94
88
  - initial import of boilerplate code needed to have the 2 version blocks available [David Ichim - [`e631e27`](https://github.com/eea/volto-eea-versions/commit/e631e273ce4f7782f0d721815e6d8f0305fa7d32)]
95
- - Fixed error from package.json after error in yarn bootstrap [David Ichim - [`fb1810b`](https://github.com/eea/volto-eea-versions/commit/fb1810b0dfa3c2bbdfe09a18efa4836d2be2d2eb)]
96
- - yarn bootstrap [David Ichim - [`63d4d93`](https://github.com/eea/volto-eea-versions/commit/63d4d934aa14c5df966a0e443f648bb8eb7b2619)]
97
89
  - Initial commit [Alin Voinea - [`0c11208`](https://github.com/eea/volto-eea-versions/commit/0c11208f3fae44b66b185de3dd2994ebae91dc9b)]
package/README.md CHANGED
@@ -1,19 +1,8 @@
1
- # volto-eea-versions
1
+ # @eeacms/volto-eea-versions
2
2
 
3
3
  [![Releases](https://img.shields.io/github/v/release/eea/volto-eea-versions)](https://github.com/eea/volto-eea-versions/releases)
4
-
5
4
  [![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-eea-versions%2Fmaster&subject=master)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-eea-versions/job/master/display/redirect)
6
- [![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions)
7
5
  [![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions)
8
- [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions)
9
- [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions)
10
-
11
- [![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-eea-versions%2Fdevelop&subject=develop)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-eea-versions/job/develop/display/redirect)
12
- [![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&branch=develop&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions&branch=develop)
13
- [![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&branch=develop&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions&branch=develop)
14
- [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&branch=develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions&branch=develop)
15
- [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-eea-versions&branch=develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-versions&branch=develop)
16
-
17
6
 
18
7
  [Volto](https://github.com/plone/volto) add-on
19
8
 
@@ -21,23 +10,36 @@
21
10
 
22
11
  Demo GIF
23
12
 
24
- ## Getting started
13
+ ## Upgrade
14
+
15
+ ### Upgrading to 3.x
16
+
17
+ > This version requires `Volto 18` or `Volto 19` and Node.js 22.
25
18
 
26
- ### Try volto-eea-versions with Docker
19
+ No API or behaviour change: the control panel id and route, the exported components and the
20
+ settings keys are the same as 2.x. The release adds Volto 19 support and moves the repository to the
21
+ Volto 19 layout, where the published package lives in `packages/volto-eea-versions`.
27
22
 
28
- git clone https://github.com/eea/volto-eea-versions.git
29
- cd volto-eea-versions
30
- make
31
- make start
23
+ #### Breaking changes
32
24
 
33
- Go to http://localhost:3000
25
+ - **Node.js 22 or newer is required** (`engines.node >= 22`), 2.x declared no engine.
26
+ - **React 18 is required.** The package declares `react` and `react-dom` as `^18.2.0` peers, 2.x
27
+ declared no peers.
28
+ - **The package no longer ships the repository tooling.** The Cypress specs and the Jest setup are
29
+ gone and the unit tests moved to Vitest next to the add-on, so nothing a site imports was removed.
34
30
 
35
- `make start` now defaults to Volto 18. To run the same setup against Volto 17, use:
31
+ ## Requirements
36
32
 
37
- VOLTO_VERSION=17 make
38
- VOLTO_VERSION=17 make start
33
+ ### Backend
39
34
 
40
- ### Add volto-eea-versions to your Volto project
35
+ - [Plone](https://plone.org/download)
36
+ - [plone.restapi](https://pypi.org/project/plone.restapi/)
37
+
38
+ ### Frontend
39
+
40
+ - Node.js: `>=22.0.0`
41
+
42
+ ## Installation
41
43
 
42
44
  1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone
43
45
 
@@ -81,89 +83,14 @@ Go to http://localhost:3000
81
83
  make frontend-start
82
84
  ```
83
85
 
84
- For a legacy Volto 17 project, install the package with `yarn` and restart the frontend as usual.
85
-
86
86
  1. Go to http://localhost:3000
87
87
 
88
88
  1. Happy editing!
89
89
 
90
- ## Release
91
-
92
- See [RELEASE.md](https://github.com/eea/volto-eea-versions/blob/master/RELEASE.md).
93
-
94
- ## How to contribute
95
-
96
- See [DEVELOP.md](https://github.com/eea/volto-eea-versions/blob/master/DEVELOP.md).
97
-
98
- ## Secret Scanning
99
-
100
- This repository uses the Betterleaks GitHub Action to scan the current
101
- repository content on every push and pull request. The scan uses the rules in
102
- `.gitleaks.toml` and uploads a `betterleaks-report` artifact when a finding is
103
- detected.
104
-
105
- If the optional SMTP secrets are configured, failed scans also send an email to
106
- the last commit committer. The workflow expects these repository or
107
- organization secrets:
108
-
109
- - `SMTP_URL`
110
- - `SMTP_PORT` (optional, defaults to `25`)
111
- - `SMTP_EMAIL`
112
- - `SMTP_PASSWORD` (optional if the SMTP server does not require authentication)
113
-
114
- Port `465` is sent with direct TLS; other ports use the default SMTP handshake.
115
- The email includes a short finding summary from the redacted Betterleaks report,
116
- including the redacted matched line from each finding.
90
+ ## License
117
91
 
118
- There are three common outcomes:
119
-
120
- 1. **Everything is OK.** The `Betterleaks / Scan for secrets` check is green and
121
- no action is needed. Regular references to runtime values are OK, for example:
122
-
123
- ```js
124
- const tokenFromCookie = req.universalCookies.get('auth_token');
125
- ```
126
-
127
- 2. **A real secret was found.** The check is red and the workflow log asks you to
128
- download the `betterleaks-report` artifact. Open the artifact from the GitHub
129
- Actions run and check the reported file, line and rule. Remove the committed
130
- value, move it to the proper secret store, and rotate it if it was exposed.
131
- A report entry looks like this:
132
-
133
- ```json
134
- {
135
- "RuleID": "secret-literal-assignment",
136
- "File": "src/config.js",
137
- "StartLine": 12,
138
- "Secret": "[REDACTED]"
139
- }
140
- ```
141
-
142
- 3. **The finding is a false positive.** Keep the value only if it is clearly not
143
- sensitive, such as a test fixture, placeholder, or public example. Add
144
- `betterleaks:allow` on the same line and include a short explanation in the
145
- pull request.
146
-
147
- ```js
148
- const testPassword = 'admin'; //betterleaks:allow
149
- ```
150
-
151
- ```yaml
152
- password: "admin" #betterleaks:allow
153
- ```
154
-
155
- Do not add `betterleaks:allow` to real credentials.
156
-
157
- ## Copyright and license
158
-
159
- The Initial Owner of the Original Code is European Environment Agency (EEA).
160
- All Rights Reserved.
161
-
162
- See [LICENSE.md](https://github.com/eea/volto-eea-versions/blob/master/LICENSE.md) for details.
92
+ See [LICENSE.md](LICENSE.md) for details.
163
93
 
164
94
  ## Funding
165
95
 
166
96
  [European Environment Agency (EU)](http://eea.europa.eu)
167
- Funding
168
-
169
- [European Environment Agency (EU)](http://eea.europa.eu)
package/babel.config.js CHANGED
@@ -1,17 +1 @@
1
- module.exports = function (api) {
2
- api.cache(true);
3
- const presets = ['razzle'];
4
- const plugins = [
5
- [
6
- 'react-intl', // React Intl extractor, required for the whole i18n infrastructure to work
7
- {
8
- messagesDir: './build/messages/',
9
- },
10
- ],
11
- ];
12
-
13
- return {
14
- plugins,
15
- presets,
16
- };
17
- };
1
+ module.exports = require('@plone/volto/babel');
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-versions",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "@eeacms/volto-eea-versions: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
7
7
  "license": "MIT",
8
+ "packageManager": "pnpm@10.20.0",
9
+ "engines": {
10
+ "node": ">=22.0.0"
11
+ },
8
12
  "homepage": "https://github.com/eea/volto-eea-versions",
9
13
  "keywords": [
10
14
  "volto-addon",
@@ -18,13 +22,26 @@
18
22
  },
19
23
  "devDependencies": {
20
24
  "@cypress/code-coverage": "^3.10.0",
21
- "@plone/scripts": "*",
25
+ "@vitejs/plugin-react": "4.7.0",
26
+ "@vitest/coverage-istanbul": "3.2.7",
22
27
  "babel-plugin-transform-class-properties": "^6.24.1",
23
28
  "cypress": "13.1.0",
24
29
  "cypress-fail-fast": "^5.0.1",
30
+ "dotenv": "^16.3.2",
25
31
  "husky": "^8.0.3",
32
+ "jsdom": "23.0.0",
26
33
  "lint-staged": "^14.0.1",
27
- "md5": "^2.3.0"
34
+ "md5": "^2.3.0",
35
+ "vite": "6.4.3",
36
+ "vitest": "3.2.7",
37
+ "@testing-library/jest-dom": "6.9.1",
38
+ "@testing-library/react": "^16.3.2",
39
+ "@types/react": "^18.3.1",
40
+ "@types/react-dom": "^18.3.1",
41
+ "redux-mock-store": "1.5.4",
42
+ "redux-thunk": "^2.4.2",
43
+ "release-it": "^19.0.5",
44
+ "typescript": "^5.7.3"
28
45
  },
29
46
  "lint-staged": {
30
47
  "src/**/*.{js,jsx,ts,tsx,json}": [
@@ -48,23 +65,22 @@
48
65
  ]
49
66
  },
50
67
  "scripts": {
51
- "prepare": "husky install",
68
+ "prepare": "cd ../.. && husky install || true",
52
69
  "release": "release-it",
53
70
  "release-major-beta": "release-it major --preRelease=beta",
54
71
  "release-beta": "release-it --preRelease=beta",
55
- "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
56
- "test": "make test",
57
- "test:fix": "make test-update",
58
- "pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix",
59
- "stylelint": "make stylelint",
60
- "stylelint:overrides": "make stylelint-overrides",
61
- "stylelint:fix": "make stylelint-fix",
62
- "prettier": "make prettier",
63
- "prettier:fix": "make prettier-fix",
64
- "lint": "make lint",
65
- "lint:fix": "make lint-fix",
66
- "i18n": "make i18n",
67
- "cypress:run": "make cypress-run",
68
- "cypress:open": "make cypress-open"
72
+ "test": "vitest --config ./vitest.config.mjs run --passWithNoTests",
73
+ "test:fix": "vitest --config ./vitest.config.mjs run --passWithNoTests --update",
74
+ "i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
75
+ "dry-release": "release-it --dry-run",
76
+ "release-major-alpha": "release-it major --preRelease=alpha",
77
+ "release-alpha": "release-it --preRelease=alpha"
78
+ },
79
+ "publishConfig": {
80
+ "access": "public"
81
+ },
82
+ "peerDependencies": {
83
+ "react": "^18.2.0",
84
+ "react-dom": "^18.2.0"
69
85
  }
70
86
  }
package/tsconfig.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "skipLibCheck": true,
5
+ "target": "es2022",
6
+ "allowJs": true,
7
+ "resolveJsonModule": true,
8
+ "moduleDetection": "force",
9
+ "isolatedModules": true,
10
+ "verbatimModuleSyntax": true,
11
+ "module": "preserve",
12
+ "noEmit": true,
13
+ "lib": [
14
+ "es2022",
15
+ "dom",
16
+ "dom.iterable"
17
+ ],
18
+ "jsx": "react-jsx",
19
+ "paths": {
20
+ "@plone/volto/*": [
21
+ "../../core/packages/volto/src/*"
22
+ ],
23
+ "@eeacms/volto-eea-versions/*": [
24
+ "./src/*"
25
+ ]
26
+ }
27
+ },
28
+ "include": [
29
+ "**/*.ts",
30
+ "**/*.tsx",
31
+ "**/*.js",
32
+ "**/*.jsx"
33
+ ],
34
+ "exclude": [
35
+ "node_modules",
36
+ "build",
37
+ "public",
38
+ "coverage",
39
+ "**/*.test.{js,jsx,ts,tsx}",
40
+ "**/*.spec.{js,jsx,ts,tsx}",
41
+ "**/*.stories.{js,jsx,ts,tsx}"
42
+ ]
43
+ }
@@ -0,0 +1,279 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createRequire } from 'node:module';
4
+ import { fileURLToPath, pathToFileURL } from 'node:url';
5
+ import { defineConfig } from 'vitest/config';
6
+ import { transformWithEsbuild } from 'vite';
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
+ process.env.TZ = 'UTC';
10
+ // The nearest folder with a Volto checkout in `core/`: the add-on repository
11
+ // when developed standalone, or the frontend project when it is checked out
12
+ // in its `packages/` folder.
13
+ const findProjectRoot = (dir) => {
14
+ if (fs.existsSync(path.join(dir, 'core/packages/volto'))) return dir;
15
+ const parent = path.dirname(dir);
16
+ return parent === dir ? __dirname : findProjectRoot(parent);
17
+ };
18
+ const projectRoot = findProjectRoot(__dirname);
19
+ const voltoRoot = fs.existsSync(path.join(projectRoot, 'core/packages/volto'))
20
+ ? path.join(projectRoot, 'core/packages/volto')
21
+ : path.dirname(
22
+ fileURLToPath(
23
+ import.meta.resolve('@plone/volto/package.json'),
24
+ ),
25
+ );
26
+ const requireFromVolto = createRequire(path.join(voltoRoot, 'package.json'));
27
+ // The other core packages are dependencies of Volto, not of the add-on.
28
+ const resolveCorePackage = (name, folder) =>
29
+ fs.existsSync(path.join(projectRoot, 'core/packages', folder))
30
+ ? path.join(projectRoot, 'core/packages', folder)
31
+ : path.dirname(requireFromVolto.resolve(`${name}/package.json`));
32
+ const voltoSlateRoot = resolveCorePackage('@plone/volto-slate', 'volto-slate');
33
+ const componentsRoot = resolveCorePackage('@plone/components', 'components');
34
+ const registryRoot = resolveCorePackage('@plone/registry', 'registry');
35
+
36
+ const requireFromAddon = createRequire(path.join(__dirname, 'package.json'));
37
+ const voltoPackage = JSON.parse(
38
+ fs.readFileSync(path.join(voltoRoot, 'package.json'), 'utf8'),
39
+ );
40
+
41
+ const baseConfig = (
42
+ await import(pathToFileURL(path.join(voltoRoot, 'vitest.config.mjs')).href)
43
+ ).default;
44
+ const setupGlobals = fs.existsSync(
45
+ path.join(voltoRoot, 'test-setup-globals-vitest.js'),
46
+ )
47
+ ? path.join(voltoRoot, 'test-setup-globals-vitest.js')
48
+ : path.join(voltoRoot, 'test-setup-globals.js');
49
+ const addonsLoader = fs.existsSync(
50
+ path.join(voltoRoot, 'test-addons-loader.js'),
51
+ )
52
+ ? path.join(voltoRoot, 'test-addons-loader.js')
53
+ : path.join(voltoRoot, 'jest-addons-loader.js');
54
+ const setupFiles = [
55
+ setupGlobals,
56
+ path.join(voltoRoot, 'test-setup-config.jsx'),
57
+ ];
58
+ const setupAfterEnv = path.join(voltoRoot, 'jest-setup-afterenv.js');
59
+ if (fs.existsSync(setupAfterEnv)) setupFiles.push(setupAfterEnv);
60
+ setupFiles.push(addonsLoader);
61
+
62
+ const globalsFile = path.join(__dirname, 'vitest.globals.js');
63
+ if (fs.existsSync(globalsFile)) setupFiles.push(globalsFile);
64
+ const envFile = path.join(__dirname, '.env');
65
+ const useAddonSetup =
66
+ !fs.existsSync(envFile) ||
67
+ /^VITEST_USE_SETUP=ON(?:\s|$)/m.test(fs.readFileSync(envFile, 'utf8'));
68
+ const addonSetup = path.join(__dirname, 'vitest.setup.jsx');
69
+ if (useAddonSetup && fs.existsSync(addonSetup)) setupFiles.push(addonSetup);
70
+
71
+ function resolvePackageRoot(packageName) {
72
+ for (const packageRequire of [requireFromAddon, requireFromVolto]) {
73
+ try {
74
+ return path.dirname(packageRequire.resolve(`${packageName}/package.json`));
75
+ } catch {
76
+ try {
77
+ let current = path.dirname(packageRequire.resolve(packageName));
78
+ while (current !== path.dirname(current)) {
79
+ const manifest = path.join(current, 'package.json');
80
+ if (fs.existsSync(manifest)) {
81
+ const candidate = JSON.parse(fs.readFileSync(manifest, 'utf8'));
82
+ if (candidate.name === packageName) return current;
83
+ }
84
+ current = path.dirname(current);
85
+ }
86
+ } catch {
87
+ // Try the next package resolution context.
88
+ }
89
+ }
90
+ }
91
+ return null;
92
+ }
93
+
94
+ const addonPackage = JSON.parse(
95
+ fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'),
96
+ );
97
+ const aliases = {
98
+ ...(baseConfig.resolve?.alias ?? {}),
99
+ '@plone/volto': path.join(voltoRoot, 'src'),
100
+ '@plone/volto-slate': path.join(voltoSlateRoot, 'src'),
101
+ '@plone/components': path.join(componentsRoot, 'src'),
102
+ '@plone/registry': path.join(registryRoot, 'src'),
103
+ '@root': path.join(voltoRoot, 'src'),
104
+ '@package': path.join(__dirname, 'src'),
105
+ '~': path.join(voltoRoot, 'src'),
106
+ 'load-volto-addons': addonsLoader,
107
+ [addonPackage.name]: path.join(__dirname, 'src'),
108
+ };
109
+ function addSourceAlias(packageRoot) {
110
+ const manifestPath = path.join(packageRoot, 'package.json');
111
+ const sourceRoot = path.join(packageRoot, 'src');
112
+ if (!fs.existsSync(manifestPath) || !fs.existsSync(sourceRoot)) return;
113
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
114
+ if (manifest.name) aliases[manifest.name] = sourceRoot;
115
+ }
116
+
117
+ const workspacePackages = path.join(projectRoot, 'packages');
118
+ if (fs.existsSync(workspacePackages)) {
119
+ for (const packageDirectory of fs.readdirSync(workspacePackages)) {
120
+ const packageRoot = path.join(workspacePackages, packageDirectory);
121
+ addSourceAlias(packageRoot);
122
+ // In a frontend project each add-on repository keeps its add-on in its
123
+ // own `packages/` folder.
124
+ const nestedPackages = path.join(packageRoot, 'packages');
125
+ if (fs.existsSync(nestedPackages)) {
126
+ for (const nestedDirectory of fs.readdirSync(nestedPackages)) {
127
+ addSourceAlias(path.join(nestedPackages, nestedDirectory));
128
+ }
129
+ }
130
+ }
131
+ }
132
+ const pnpmStore = path.join(projectRoot, 'node_modules/.pnpm');
133
+ if (fs.existsSync(pnpmStore)) {
134
+ for (const storeDirectory of fs.readdirSync(pnpmStore)) {
135
+ for (const scope of ['@eeacms', '@plone-collective']) {
136
+ const scopeRoot = path.join(
137
+ pnpmStore,
138
+ storeDirectory,
139
+ 'node_modules',
140
+ scope,
141
+ );
142
+ if (!fs.existsSync(scopeRoot)) continue;
143
+ for (const packageDirectory of fs.readdirSync(scopeRoot)) {
144
+ addSourceAlias(path.join(scopeRoot, packageDirectory));
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+ const excludedVoltoAliases = [
151
+ 'vitest',
152
+ 'vite',
153
+ 'jsdom',
154
+ '@vitejs/plugin-react',
155
+ ];
156
+ for (const dependency of Object.keys({
157
+ ...(voltoPackage.dependencies ?? {}),
158
+ ...(voltoPackage.devDependencies ?? {}),
159
+ })) {
160
+ if (
161
+ dependency in aliases ||
162
+ excludedVoltoAliases.includes(dependency) ||
163
+ dependency.startsWith('@vitest/') ||
164
+ dependency.startsWith('@testing-library/')
165
+ ) {
166
+ continue;
167
+ }
168
+ const dependencyRoot = resolvePackageRoot(dependency);
169
+ if (dependencyRoot) aliases[dependency] = dependencyRoot;
170
+ }
171
+ const workspaceSearchlib = [
172
+ 'packages/volto-searchlib/searchlib',
173
+ 'packages/volto-searchlib/packages/volto-searchlib/searchlib',
174
+ ]
175
+ .map((searchlibFolder) => path.join(projectRoot, searchlibFolder))
176
+ .find((searchlibFolder) => fs.existsSync(searchlibFolder));
177
+ const installedSearchlib = resolvePackageRoot('@eeacms/volto-searchlib');
178
+ const searchlibPath = fs.existsSync(workspaceSearchlib)
179
+ ? workspaceSearchlib
180
+ : fs.existsSync(path.join(__dirname, 'searchlib'))
181
+ ? path.join(__dirname, 'searchlib')
182
+ : installedSearchlib
183
+ ? path.join(installedSearchlib, 'searchlib')
184
+ : '';
185
+ if (fs.existsSync(searchlibPath)) aliases['@eeacms/search'] = searchlibPath;
186
+ const subsitesMock = path.join(
187
+ __dirname,
188
+ 'src/__mocks__/volto-subsites-utils.js',
189
+ );
190
+ if (fs.existsSync(subsitesMock)) aliases['volto-subsites/utils'] = subsitesMock;
191
+ const localStorageMock = path.join(
192
+ __dirname,
193
+ 'src/__mocks__/redux-localstorage-simple-original.js',
194
+ );
195
+ if (fs.existsSync(localStorageMock)) {
196
+ aliases['redux-localstorage-simple-original'] = localStorageMock;
197
+ }
198
+ const uuidMock = path.join(__dirname, 'vitest.uuid.mock.js');
199
+ if (fs.existsSync(uuidMock)) aliases.uuid = uuidMock;
200
+ const jsxSourceRoots = Object.values(aliases).filter(
201
+ (aliasPath) => typeof aliasPath === 'string',
202
+ );
203
+
204
+ const jsxInJsPlugin = {
205
+ name: 'eea-addon-jsx-in-js',
206
+ enforce: 'pre',
207
+ transform(code, id) {
208
+ const filePath = id.split('?')[0];
209
+ if (
210
+ !filePath.endsWith('.js') ||
211
+ !jsxSourceRoots.some(
212
+ (sourceRoot) =>
213
+ filePath === sourceRoot ||
214
+ filePath.startsWith(`${sourceRoot}${path.sep}`),
215
+ )
216
+ ) {
217
+ return null;
218
+ }
219
+ return transformWithEsbuild(code, filePath, {
220
+ loader: 'jsx',
221
+ jsx: 'automatic',
222
+ });
223
+ },
224
+ };
225
+
226
+ export default defineConfig({
227
+ plugins: [jsxInJsPlugin, ...(baseConfig.plugins ?? [])],
228
+ define: {
229
+ __CLIENT__: true,
230
+ __DEVELOPMENT__: false,
231
+ __SERVER__: false,
232
+ __TEST__: true,
233
+ },
234
+ resolve: { alias: aliases },
235
+ server: {
236
+ fs: {
237
+ allow: [projectRoot, __dirname],
238
+ },
239
+ deps: {
240
+ inline: [/@eeacms/, /@plone/, /query-string/],
241
+ },
242
+ },
243
+ test: {
244
+ root: __dirname,
245
+ isolate: true,
246
+ globals: true,
247
+ environment: 'jsdom',
248
+ css: false,
249
+ setupFiles,
250
+ include: [
251
+ 'src/**/*.{test,spec}.{js,jsx,ts,tsx}',
252
+ 'searchlib/**/*.{test,spec}.{js,jsx,ts,tsx}',
253
+ ],
254
+ passWithNoTests: true,
255
+ snapshotFormat: baseConfig.test?.snapshotFormat ?? {
256
+ printBasicPrototype: false,
257
+ },
258
+ coverage: {
259
+ provider: 'istanbul',
260
+ reporter: ['text', 'lcov', 'html', 'cobertura'],
261
+ reportsDirectory: process.env.COVERAGE_DIR ?? 'coverage',
262
+ include: [
263
+ 'src/**/*.{js,jsx,ts,tsx}',
264
+ 'searchlib/**/*.{js,jsx,ts,tsx}',
265
+ ],
266
+ exclude: [
267
+ 'src/**/*.{test,spec}.{js,jsx,ts,tsx}',
268
+ 'src/**/__tests__/**',
269
+ 'src/**/__mocks__/**',
270
+ 'src/**/*.d.ts',
271
+ 'src/**/index.{js,jsx,ts,tsx}',
272
+ 'src/**/*config.{js,jsx,ts,tsx}',
273
+ 'src/**/*schema.{js,jsx,ts,tsx}',
274
+ ],
275
+ // No unit tests in this add-on yet; the 5% thresholds would always
276
+ // fail on an empty coverage report.
277
+ },
278
+ },
279
+ });