Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@plone/registry as ESM module, move to TS, complete documentation #6399

Merged
merged 95 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
70559c1
WIP Update README for @plone/registry, added utilities registry
sneridagh Oct 12, 2024
db99028
First implementation of moving addon registry to TS and ESM.
sneridagh Oct 13, 2024
cfe41b7
Removing dangling pnpmlock
sneridagh Oct 13, 2024
944d6c1
Fix path
sneridagh Oct 13, 2024
62b4766
Fixes
sneridagh Oct 13, 2024
b80f9d5
Fix missing fake node_modules in fixtures
sneridagh Oct 13, 2024
d608239
Changelog
sneridagh Oct 13, 2024
6d82dfd
Fix tests
sneridagh Oct 13, 2024
fa9e675
Fix i18n to match the new ESM in @plone/registry
sneridagh Oct 13, 2024
9aeaf6a
Fix @plone/scripts
sneridagh Oct 13, 2024
6f26edf
Build all again for linting
sneridagh Oct 13, 2024
ef4c08f
Introduce new get() method in the addon registry
sneridagh Oct 13, 2024
f415b34
Refactor to TS other scripts. More polishments. Better tests
sneridagh Oct 13, 2024
1d37256
Create .readthedocs.yml
stevepiercy Oct 14, 2024
5251665
Fix tests
sneridagh Oct 14, 2024
2b34e98
Apply suggestions from code review
sneridagh Oct 14, 2024
c266a70
Update packages/registry/news/6399.breaking
sneridagh Oct 14, 2024
0ec33cd
Update packages/scripts/news/6399.feature
sneridagh Oct 14, 2024
2bf09b4
Fix storybook config
sneridagh Oct 14, 2024
e3b98b7
Fix storybook build for main
sneridagh Oct 14, 2024
e80b94c
Docs in @plone/registry
sneridagh Oct 14, 2024
c76b1b1
Requirements for docs in RTD
sneridagh Oct 14, 2024
67b700f
Requirements for docs in RTD 2
sneridagh Oct 14, 2024
51f09bb
Try to build with a custom command
sneridagh Oct 14, 2024
ddd0701
Try 3
sneridagh Oct 14, 2024
5c458df
Use post_install and don't use default sphinx builder.
stevepiercy Oct 14, 2024
304b042
Fix path to requirements-docs.txt
stevepiercy Oct 14, 2024
2881958
Revert to repo root for python install requirements
stevepiercy Oct 14, 2024
a36c126
Consolidate commands in Makefile
stevepiercy Oct 14, 2024
645a265
cd into registry
stevepiercy Oct 14, 2024
57a5244
Combine commands
stevepiercy Oct 14, 2024
6668e4b
Fix path to requirements
stevepiercy Oct 14, 2024
121e84a
Use commands instead of jobs to override the build process
stevepiercy Oct 14, 2024
8df4552
Fix lint
sneridagh Oct 14, 2024
9a9bf60
Fix prettier
sneridagh Oct 14, 2024
0fb7b77
Apply suggestions from code review
sneridagh Oct 14, 2024
4485e16
remove cruft
sneridagh Oct 14, 2024
30857cb
Fix storybook file reference
sneridagh Oct 14, 2024
47b105c
Fix references to plone-registry URL
sneridagh Oct 14, 2024
5255a97
WIP more docs
sneridagh Oct 14, 2024
3646e35
WIP
sneridagh Oct 14, 2024
c409647
Merge branch 'main' into registryesmandts
sneridagh Oct 18, 2024
f3e7e80
Fix code
sneridagh Oct 18, 2024
76b01ad
Fix other typo
sneridagh Oct 18, 2024
a174fa6
Merge branch 'main' into registryesmandts
sneridagh Oct 20, 2024
a09affa
lock
sneridagh Oct 20, 2024
75dec4d
More docs and add `registry.config.js` to the game
sneridagh Oct 20, 2024
e250d7b
new package in the fixture
sneridagh Oct 20, 2024
02ec019
Update glob version
sneridagh Oct 20, 2024
d449abc
New API for instantiating the Add-on Registry
sneridagh Oct 21, 2024
308eaf8
Apply suggestions from code review
sneridagh Oct 21, 2024
0c0cd8a
Fix i18n script
sneridagh Oct 21, 2024
624f7fb
How to instantiate the registry
sneridagh Oct 21, 2024
ea8ec70
More docs, polishments, move all to named exports
sneridagh Oct 21, 2024
2238307
Introduce plone-registry Vite plugin
sneridagh Oct 21, 2024
ca98c21
Apply suggestions from code review
sneridagh Oct 22, 2024
4d4bc76
Update packages/registry/src/addon-registry/addon-registry.ts
sneridagh Oct 22, 2024
dcbd645
Update docs/source/upgrade-guide/index.md
sneridagh Oct 22, 2024
f21434f
Apply suggestions from code review
sneridagh Oct 23, 2024
0ff5e5e
Impreove/complete some missing parts
sneridagh Oct 23, 2024
6be3887
Initialization
sneridagh Oct 23, 2024
c48d6a0
Add specific test for an app folder (non-Volto), add bare customizati…
sneridagh Oct 23, 2024
cdc28af
Changelog
sneridagh Oct 23, 2024
7222b43
Merge branch 'main' into registryesmandts
sneridagh Oct 23, 2024
1f813ad
remove only
sneridagh Oct 24, 2024
03fc1f0
Merge branch 'main' into registryesmandts
sneridagh Oct 24, 2024
0af08a5
Apply suggestions from code review
sneridagh Oct 25, 2024
8efb25f
David Suggestions
sneridagh Oct 25, 2024
afb0f3a
Changelog
sneridagh Oct 25, 2024
4cc244e
Apply suggestions from code review
sneridagh Oct 26, 2024
ad758d4
Explain better why do we want to use a configuration file
sneridagh Oct 26, 2024
3cd99ad
Clarify that you can use an string too, fix the example
sneridagh Oct 26, 2024
58ba93d
Added a warning for updating your shadowed components at the same tim…
sneridagh Oct 26, 2024
5a94bb4
Purge README
sneridagh Oct 26, 2024
2edb35b
Merge branch 'main' into registryesmandts
sneridagh Oct 26, 2024
301b610
Merge branch 'main' into registryesmandts
stevepiercy Oct 26, 2024
ba272ea
Add-on Registry is not a brand, but just a thing.
stevepiercy Oct 26, 2024
be685d1
Grammar on news item
stevepiercy Oct 26, 2024
87b0a78
Add-on Registry is not a brand, but just a thing.
stevepiercy Oct 26, 2024
5f75190
Complete sentence
stevepiercy Oct 26, 2024
7825088
Remove unused assets
stevepiercy Oct 27, 2024
f5791da
Add robots.txt with correct link to sitemap.xml
stevepiercy Oct 27, 2024
df038ab
Volto Foundation?
stevepiercy Oct 27, 2024
15f0292
Restore needed static files
stevepiercy Oct 27, 2024
bc0a175
Remove unneeded configuration.
stevepiercy Oct 27, 2024
bfe3b64
Move explanation docs into a Conceptual Guides section
stevepiercy Oct 27, 2024
cd14d36
Minor tweaks for grammar
stevepiercy Oct 27, 2024
3d4b45d
Move explanation of component and utility registry from index.
stevepiercy Oct 27, 2024
00dd707
Refactor and rename files to avoid repetition
stevepiercy Oct 27, 2024
c595d88
Clean up page titles
stevepiercy Oct 27, 2024
d08b27e
Clean up all how-to guides
stevepiercy Oct 27, 2024
5eb2898
Add html_meta stuff
stevepiercy Oct 27, 2024
79575b8
Add tree to shadow components docs, move it in the ToC to the last
sneridagh Oct 27, 2024
12f3910
Experiment with RTD preview builds
stevepiercy Oct 27, 2024
f603dd2
Add http://localhost:8080 to the whitelist in CI link check
sneridagh Oct 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ packages/volto
packages/volto-guillotina
!.*
dist
packages/registry/lib
packages/registry/docs
3 changes: 3 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ jobs:
- name: Install yalc
run: npm -g install yalc

- name: Build dependencies
run: make build-deps

- name: Install a yalc'ed version of the current Volto in the project - publish
run: |
yalc publish packages/types
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
styles/rules/*
node_modules
packages/volto/types/*
packages/registry/docs/*
storybook-static
apps/vite-ssr/src/routeTree.gen.ts
apps/vite/src/routeTree.gen.ts
2 changes: 0 additions & 2 deletions apps/remix/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
"paths": {
"~/*": ["./app/*"]
},

// Vite takes care of building everything, not tsc.
"noEmit": true
}
}
2 changes: 2 additions & 0 deletions apps/remix/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { vitePlugin as remix } from '@remix-run/dev';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import { PloneRegistryVitePlugin } from '@plone/registry/vite-plugin';

export default defineConfig({
plugins: [
Expand All @@ -12,6 +13,7 @@ export default defineConfig({
},
}),
tsconfigPaths(),
PloneRegistryVitePlugin(),
],
server: {
port: 3000,
Expand Down
57 changes: 57 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,63 @@ The `react/jsx-key` rule has been enabled in ESlint for catching missing `key` i
You might catch some violations in your project or add-on code after running ESlint.
Adding the missing `key` property whenever the violation is reported will fix it.

### `@plone/registry` moved to ESM

The `@plone/registry` package has been moved to ESM.
The add-on registry scripts have also been refactored to TypeScript.
For maximum compatibility with CommonJS builds, the default exports have been moved to named exports.
davisagli marked this conversation as resolved.
Show resolved Hide resolved
The modules affected are now built, and the import paths have changed, too.
These changes force some import path changes that you should patch in your Plone project or add-on boilerplates.

```{note}
As always, when something changes in the boilerplate, you may regenerate one from Cookieplone and move your code into it, instead of fiddling with it.
```

For example, in your project's {file}`.eslintrc.js`:

```diff
const fs = require('fs');
const projectRootPath = __dirname;
-const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');
+const { AddonRegistry } = require('@plone/registry/addon-registry');

let voltoPath = './node_modules/@plone/volto';

@@ -17,15 +17,15 @@ if (configFile) {
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}

-const reg = new AddonConfigurationRegistry(__dirname);
+const { registry } = AddonRegistry.init(__dirname);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
-const addonAliases = Object.keys(reg.packages).map((o) => [
+const addonAliases = Object.keys(registry.packages).map((o) => [
o,
- reg.packages[o].modulePath,
+ registry.packages[o].modulePath,
]);

-const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
+const addonExtenders = registry.getEslintExtenders().map((m) => require(m));
```

Also in the Storybook configuration {file}`.storybook/main.js`.

```diff
- const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');
+ const { AddonRegistry } = require('@plone/registry/addon-registry');

- const registry = new AddonConfigurationRegistry(projectRootPath);
+ const { registry } = AddonRegistry.init(projectRootPath);
```

```{versionadded} Volto 18.0.0-alpha.47
```

```{versionadded} @plone/registry 3.0.0-alpha.0
```

### Deprecation notices for Volto 18

#### `@plone/generator-volto`
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"overrides": {
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
"react-refresh": "0.14.0"
},
"patchedDependencies": {
"jest-resolve@26.6.2": "patches/jest-resolve@26.6.2.patch"
}
}
}
10 changes: 5 additions & 5 deletions packages/generator-volto/generators/app/templates/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const projectRootPath = __dirname;
const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');
const { AddonRegistry } = require('@plone/registry/addon-registry');

let voltoPath = './node_modules/@plone/volto';

Expand All @@ -17,15 +17,15 @@ if (configFile) {
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}

const reg = new AddonConfigurationRegistry(__dirname);
const { registry } = AddonRegistry.init(__dirname);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonAliases = Object.keys(reg.packages).map((o) => [
const addonAliases = Object.keys(registry.packages).map((o) => [
o,
reg.packages[o].modulePath,
registry.packages[o].modulePath,
]);

const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
const addonExtenders = registry.getEslintExtenders().map((m) => require(m));

const defaultConfig = {
extends: `${voltoPath}/.eslintrc`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ module.exports = {
[],
defaultRazzleOptions,
);
const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');
const { AddonRegistry } = require('@plone/registry/addon-registry');

const registry = new AddonConfigurationRegistry(projectRootPath);
const { registry } = AddonRegistry.init(projectRootPath);

config = lessPlugin({ registry }).modifyWebpackConfig({
env: { target: 'web', dev: 'dev' },
Expand Down
2 changes: 2 additions & 0 deletions packages/generator-volto/news/6399.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Breaking changes in `.eslintrc.js` and `.storybook/main.js` because of #6399. @sneridagh
Please see the [Upgrade Guide](https://6.docs.plone.org/volto/upgrade-guide/index.html).
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module.exports = {
// Base config
extends: ['eslint:recommended'],

ignorePatterns: ['docs/_static/searchtools.js'],

overrides: [
// React
{
Expand Down Expand Up @@ -61,7 +63,11 @@ module.exports = {

// Node
{
files: ['.eslintrc.js', 'src/*.js'],
files: [
'.eslintrc.cjs',
'src/addon-registry/**/*.{js,ts}',
'__tests__/**/*.{js,ts}',
],
env: {
node: true,
es6: true,
Expand Down
7 changes: 4 additions & 3 deletions packages/registry/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.parcel-cache/
dist
/bin
/lib
/include

# yarn 3
.pnp.*
.yarn/*
docs/_build/
34 changes: 34 additions & 0 deletions packages/registry/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"
commands:
- cd ./packages/registry && make docs-rtd-registry

# Build documentation in the "docs/" directory with Sphinx
#sphinx:
# configuration: packages/registry/docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
#python:
# install:
# - requirements: requirements-docs.txt
90 changes: 90 additions & 0 deletions packages/registry/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-eu -o pipefail -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules

# Sphinx variables
# You can set these variables from the command line.
SPHINXOPTS ?=
VALEOPTS ?=
# Internal variables.
SPHINXBUILD = "$(realpath bin/sphinx-build)"
SPHINXAUTOBUILD = "$(realpath bin/sphinx-autobuild)"
DOCS_DIR = ./docs/
BUILDDIR = ./_build/
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) .
VALEFILES := $(shell find $(DOCS_DIR) -type f -name "*.md" -print)

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

## Docs

bin/python: ## Create a Python virtual environment with the latest pip, and install documentation requirements
python3 -m venv . || virtualenv --clear --python=python3 .
bin/python -m pip install --upgrade pip
@echo "Python environment created."
bin/pip install -r ../../requirements-docs.txt
@echo "Requirements installed."

.PHONY: docs-clean
docs-clean: ## Clean current and legacy docs build directories, and Python virtual environment
rm -rf bin include lib
rm -rf docs/_build
cd $(DOCS_DIR) && rm -rf $(BUILDDIR)/

.PHONY: docs-html
docs-html: bin/python ## Build html
cd $(DOCS_DIR) && $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

.PHONY: docs-livehtml
docs-livehtml: bin/python ## Rebuild Sphinx documentation on changes, with live-reload in the browser
cd "$(DOCS_DIR)" && ${SPHINXAUTOBUILD} \
--ignore "*.swp" \
-b html . "$(BUILDDIR)/html" $(SPHINXOPTS)

.PHONY: docs-linkcheck
docs-linkcheck: bin/python ## Run linkcheck
cd $(DOCS_DIR) && $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/ ."

.PHONY: docs-linkcheckbroken
docs-linkcheckbroken: bin/python ## Run linkcheck and show only broken links
cd $(DOCS_DIR) && $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck | GREP_COLORS='0;31' grep -wi "broken\|redirect" --color=always | GREP_COLORS='0;31' grep -vi "https://github.com/plone/volto/issues/" --color=always && if test $$? -eq 0; then exit 1; fi || test $$? -ne 0

.PHONY: docs-vale
docs-vale: bin/python ## Install (once) and run Vale style, grammar, and spell checks
bin/vale sync
bin/vale --no-wrap $(VALEOPTS) $(VALEFILES)
@echo
@echo "Vale is finished; look for any errors in the above output."

.PHONY: docs-rtd-pr-preview
docs-rtd-pr-preview: ## Build previews of pull requests that have documentation changes on Read the Docs via CI
pip install -r requirements-docs.txt
cd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/

.PHONY: docs-rtd-registry
docs-rtd-registry: ## Build Plone Registry docs on RTD
pip install -r ../../requirements-docs.txt && cd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/

## Build

.PHONY: rename-to-cjs
rename-to-cjs: ## Rename the built files js -> cjs
mv dist/cjs/addon-registry.js dist/cjs/addon-registry.cjs
mv dist/cjs/create-addons-loader.js dist/cjs/create-addons-loader.cjs
mv dist/cjs/create-theme-loader.js dist/cjs/create-theme-loader.cjs
Loading
Loading