Skip to content

Commit

Permalink
Transfer all knowledge from #6050
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Dec 16, 2024
1 parent 086f950 commit 64fb418
Show file tree
Hide file tree
Showing 120 changed files with 1,767 additions and 808 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { FormattedMessage } from 'react-intl';
import isEmpty from 'lodash/isEmpty';

import voltoPackageJson from '@plone/volto/../package.json';
import projectPackageJson from '@root/../package.json';

import { defineMessages, useIntl } from 'react-intl';
import config from '@plone/volto/registry';

const messages = defineMessages({
no_addons: {
id: 'No addons found',
defaultMessage: 'No addons found',
},
});

const voltoVersion = voltoPackageJson.version;

const VersionOverview = ({
cmf_version,
debug_mode,
pil_version,
plone_version,
plone_restapi_version,
python_version,
zope_version,
}) => {
const intl = useIntl();
const { addonsInfo } = config.settings;
const isProject = voltoPackageJson.name !== projectPackageJson.name;

return (
<>
<h2>
This is a customized Route Component from @plone/volto-coresandbox
</h2>
<ul
style={{
fontSize: '16px',
fontFamily: 'Monospace',
paddingLeft: '1rem',
}}
>
{isProject ? (
<li>
{projectPackageJson.name} {projectPackageJson.version}
</li>
) : null}
{voltoVersion && <li>Volto {voltoVersion}</li>}
<li>Plone {plone_version}</li>
<li>plone.restapi {plone_restapi_version}</li>
<li>CMF {cmf_version}</li>
<li>Zope {zope_version}</li>
<li>Python {python_version}</li>
<li>PIL {pil_version}</li>
</ul>
<h3>Add-ons</h3>
{isEmpty(addonsInfo) ? (
<p>{intl.formatMessage(messages.no_addons)}</p>
) : (
<ul style={{ fontSize: '16px', fontFamily: 'Monospace' }}>
{addonsInfo.map((addon) => (
<li key={addon.name}>{`${addon.name} ${addon.version || ''}`}</li>
))}
</ul>
)}
{debug_mode !== 'No' && (
<p>
<FormattedMessage
id="Warning Regarding debug mode"
defaultMessage="You are running in 'debug mode'. This mode is intended for sites that are under development. This allows many configuration changes to be immediately visible, but will make your site run more slowly. To turn off debug mode, stop the server, set 'debug-mode=off' in your buildout.cfg, re-run bin/buildout and then restart the server process."
/>
</p>
)}
</>
);
};

export default VersionOverview;
5 changes: 4 additions & 1 deletion packages/registry/src/addon-registry/addon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,10 @@ class AddonRegistry {
options[item][0].replace(/\/\*$/, ''),
);

aliases[name] = value;
// We don't want to alias Volto itself, since that's fixed
if (name !== '@plone/volto') {
aliases[name] = value;
}
});

return aliases;
Expand Down
4 changes: 4 additions & 0 deletions packages/volto-slate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
"is-url": "1.2.4",
"jsdom": "^16.6.0",
"lodash": "4.17.21",
"lodash-es": "^4.17.21",
"promise-file-reader": "1.0.2",
"prop-types": "15.7.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-dropzone": "11.1.0",
"react-intersection-observer": "9.1.0",
"react-intl": "3.12.1",
"react-redux": "8.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/volto-slate/src/blocks/Table/Cell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Cell extends Component {

render() {
return (
__CLIENT__ && (
!import.meta.env.SSR && (
<SlateEditor
tabIndex={0}
onChange={this.onChange}
Expand Down
2 changes: 1 addition & 1 deletion packages/volto-slate/src/blocks/Text/PluginSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const PluginSidebar = ({ children, selected }) => {
return (
<>
{selected &&
__CLIENT__ &&
!import.meta.env.SSR &&
createPortal(
<>{children}</>,
document.getElementById('slate-plugin-sidebar'),
Expand Down
2 changes: 1 addition & 1 deletion packages/volto-slate/src/editor/SlateEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,6 @@ SlateEditor.defaultProps = {
};

// May be needed to wrap in React.memo(), it used to be wrapped in connect()
export default __CLIENT__ && window?.Cypress
export default !import.meta.env.SSR && window?.Cypress
? withTestingFeatures(SlateEditor)
: SlateEditor;
1 change: 1 addition & 0 deletions packages/volto/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ eslint.xml
yarn-error.log
build
.changelog.draft
dist

# yarn 3
.pnp.*
Expand Down
18 changes: 9 additions & 9 deletions packages/volto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ start: ## Starts Volto, allowing reloading of the add-on during development

.PHONY: build
build: ## Build a production bundle for distribution
pnpm i && RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build
pnpm i && PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build

.PHONY: test
test: ## Run unit tests
Expand Down Expand Up @@ -118,7 +118,7 @@ frontend-docker-start: ## Starts a Docker-based frontend for development

.PHONY: acceptance-frontend-dev-start
acceptance-frontend-dev-start: ## Start acceptance frontend in development mode
RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm start
PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm start

######### Core Acceptance tests

Expand All @@ -136,7 +136,7 @@ ci-acceptance-backend-start: ## Start backend acceptance server in headless mode

.PHONY: acceptance-frontend-prod-start
acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode
RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod
PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod

.PHONY: acceptance-test
acceptance-test: ## Start Cypress in interactive mode
Expand Down Expand Up @@ -172,7 +172,7 @@ deployment-ci-acceptance-test-run-all: ## With a single command, run the backend

.PHONY: project-acceptance-frontend-prod-start
project-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for project tests
(cd ../../my-volto-app && RAZZLE_API_PATH=http://127.0.0.1:55001/plone yarn build && yarn start:prod)
(cd ../../my-volto-app && PLONE_API_PATH=http://127.0.0.1:55001/plone yarn build && yarn start:prod)

######### Core Sandbox Acceptance tests

Expand All @@ -182,11 +182,11 @@ coresandbox-acceptance-backend-start: ## Start backend acceptance server for cor

.PHONY: coresandbox-acceptance-frontend-prod-start
coresandbox-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for core sandbox tests
ADDONS=@plone/volto-coresandbox RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod
ADDONS=@plone/volto-coresandbox PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod

.PHONY: coresandbox-acceptance-frontend-dev-start
coresandbox-acceptance-frontend-dev-start: build-deps ## Start acceptance frontend in development mode for core sandbox tests
ADDONS=@plone/volto-coresandbox RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm start
ADDONS=@plone/volto-coresandbox PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm start

.PHONY: coresandbox-acceptance-test
coresandbox-acceptance-test: ## Start Cypress in interactive mode for core sandbox tests
Expand All @@ -208,7 +208,7 @@ multilingual-acceptance-backend-start: ## Start backend acceptance server for mu

.PHONY: multilingual-acceptance-frontend-prod-start
multilingual-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for multilingual tests
ADDONS=@plone/volto-coresandbox:multilingualFixture RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod
ADDONS=@plone/volto-coresandbox:multilingualFixture PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod

.PHONY: multilingual-acceptance-test
multilingual-acceptance-test: ## Start Cypress in interactive mode for multilingual tests
Expand Down Expand Up @@ -252,7 +252,7 @@ working-copy-acceptance-backend-start: ## Start backend acceptance server for wo

.PHONY: working-copy-acceptance-frontend-prod-start
working-copy-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for working copy tests
ADDONS=@plone/volto-coresandbox:workingCopyFixture RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod
ADDONS=@plone/volto-coresandbox:workingCopyFixture PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod

.PHONY: working-copy-acceptance-test
working-copy-acceptance-test: ## Start Cypress in interactive mode for working copy tests
Expand All @@ -274,7 +274,7 @@ guillotina-acceptance-backend-start: ## Start backend acceptance server for Guil

.PHONY: guillotina-acceptance-frontend-prod-start
guillotina-acceptance-frontend-prod-start: ## Start acceptance frontend in production mode for Guillotina tests
ADDONS=volto-guillotina RAZZLE_API_PATH=http://127.0.0.1:8081/db/web RAZZLE_LEGACY_TRAVERSE=true pnpm build && pnpm start:prod
ADDONS=volto-guillotina PLONE_API_PATH=http://127.0.0.1:8081/db/web RAZZLE_LEGACY_TRAVERSE=true pnpm build && pnpm start:prod

.PHONY: guillotina-acceptance-test
guillotina-acceptance-test: ## Start Cypress in interactive mode for Guillotina tests
Expand Down
1 change: 0 additions & 1 deletion packages/volto/babel.js → packages/volto/babel.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module.exports = function (api) {
messagesDir: './build/messages/',
},
],
'@loadable/babel-plugin', // Required by the @loadable plugin
];

return {
Expand Down
1 change: 1 addition & 0 deletions packages/volto/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./babel.cjs');
1 change: 0 additions & 1 deletion packages/volto/babel.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/volto/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { defineConfig } = require('cypress');
import { defineConfig } from 'cypress';

module.exports = defineConfig({
export default defineConfig({
viewportWidth: 1280,
chromeWebSecurity: false,
projectId: 'hvviu4',
Expand Down
14 changes: 14 additions & 0 deletions packages/volto/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- This file is only being used by the "vite build" command as it takes the "module" script entries -->
<!-- and transpile them. The actual dev/prod build is not using it at all -->
<!-- Remove when copleting the migration to RR7 -->
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<div role="navigation" aria-label="Toolbar" id="toolbar"></div>
<div id="main"></div>
<div role="complementary" aria-label="Sidebar" id="sidebar"></div>
<script type="module" src="/src/entry-client.tsx"></script>
</body>
</html>
30 changes: 22 additions & 8 deletions packages/volto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
"package": "@plone/volto-slate"
}
},
"type": "module",
"main": "src/index.js",
"types": "types/index.d.ts",
"scripts": {
"analyze": "BUNDLE_ANALYZE=true razzle build",
"start": "make build-deps && razzle start",
"start:coresandbox": "make build-deps && ADDONS=coresandbox razzle start",
"build": "make build-deps && razzle build --noninteractive",
"build": "make build-deps && pnpm run build:client && pnpm run build:server",
"build:types": "tsc --project tsconfig.declarations.json",
"test": "razzle test --maxWorkers=50%",
"test:ci": "CI=true NODE_ICU_DATA=node_modules/full-icu razzle test",
Expand All @@ -62,7 +63,14 @@
"release-major-alpha": "release-it major --preRelease=alpha",
"release-alpha": "release-it --preRelease=alpha",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
"build-storybook": "storybook build",
"dev": "vite",
"dev:server": "node server.js",
"dev:server:debug": "NODE_INSPECT_RESUME_ON_START=1 node inspect src/vite-server.js",
"build:client": "vite build --ssrManifest --outDir dist/client",
"build:server": "vite build --ssr src/entry-server.tsx --outDir dist/server",
"start:prod": "NODE_ENV=production node server.js",
"start:prod:debug": "NODE_INSPECT_RESUME_ON_START=1 NODE_ENV=production node --inspect-brk server.js"
},
"bundlewatch": {
"files": [
Expand Down Expand Up @@ -177,8 +185,6 @@
"node": "^20 || ^22"
},
"dependencies": {
"@loadable/component": "5.14.1",
"@loadable/server": "5.14.0",
"@plone/registry": "workspace:*",
"@plone/scripts": "workspace:*",
"@plone/volto-slate": "workspace:*",
Expand All @@ -188,7 +194,7 @@
"debug": "4.3.2",
"decorate-component-with-props": "1.2.1",
"dependency-graph": "0.10.0",
"detect-browser": "5.1.0",
"detect-browser": "5.3.0",
"diff": "3.5.0",
"express": "4.19.2",
"filesize": "6",
Expand Down Expand Up @@ -268,7 +274,8 @@
"universal-cookie-express": "4.0.3",
"url": "^0.11.3",
"use-deep-compare-effect": "1.8.1",
"uuid": "^8.3.2"
"uuid": "^8.3.2",
"vite-plugin-node-polyfills": "0.17.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
Expand All @@ -281,13 +288,12 @@
"@babel/plugin-syntax-export-namespace-from": "7.8.3",
"@babel/runtime": "7.20.6",
"@babel/types": "7.20.5",
"@builder.io/react-hydration-overlay": "^0.1.0",
"@dnd-kit/core": "6.0.8",
"@dnd-kit/sortable": "7.0.2",
"@dnd-kit/utilities": "3.2.2",
"@fiverr/afterbuild-webpack-plugin": "^1.0.0",
"@jest/globals": "^29.7.0",
"@loadable/babel-plugin": "5.13.2",
"@loadable/webpack-plugin": "5.15.2",
"@plone/types": "workspace:*",
"@plone/volto-coresandbox": "workspace:*",
"@sinonjs/fake-timers": "^6.0.1",
Expand All @@ -304,6 +310,7 @@
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.2.0",
"@testing-library/react-hooks": "8.0.1",
"@types/express": "^4.17.21",
"@types/history": "^4.7.11",
"@types/jest": "^29.5.8",
"@types/loadable__component": "^5.13.9",
Expand All @@ -315,6 +322,7 @@
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "10.4.8",
"axe-core": "4.4.2",
"babel-loader": "9.1.0",
Expand All @@ -325,11 +333,13 @@
"babel-preset-razzle": "4.2.18",
"bundlewatch": "0.3.3",
"circular-dependency-plugin": "5.2.2",
"compression": "^1.7.4",
"css-loader": "5.2.7",
"cypress": "13.13.2",
"cypress-axe": "1.5.0",
"cypress-file-upload": "5.0.8",
"deep-freeze": "0.0.1",
"esbuild-plugin-react-virtualized": "^1.0.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
Expand All @@ -342,6 +352,7 @@
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"full-icu": "1.4.0",
"get-port": "^7.0.0",
"html-webpack-plugin": "5.5.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.3",
Expand Down Expand Up @@ -370,20 +381,23 @@
"react-is": "^18.2.0",
"release-it": "^17.1.1",
"semver": "^7.5.4",
"sirv": "^2.0.4",
"start-server-and-test": "1.14.0",
"storybook": "^8.0.4",
"style-loader": "3.3.1",
"stylelint": "^16.3.1",
"stylelint-config-idiomatic-order": "10.0.0",
"stylelint-prettier": "5.0.0",
"svg-loader": "0.0.2",
"svgo": "^2.8.0",
"svgo-loader": "3.0.3",
"terser-webpack-plugin": "5.3.6",
"tmp": "0.2.1",
"ts-jest": "^26.4.2",
"ts-loader": "9.4.4",
"typescript": "^5.6.3",
"use-trace-update": "1.3.2",
"vite": "^5.4.5",
"wait-on": "6.0.0",
"webpack": "5.90.1",
"webpack-bundle-analyzer": "4.10.1",
Expand Down
Loading

0 comments on commit 64fb418

Please sign in to comment.