Skip to content

Commit

Permalink
Cleanup and renaming (#5456)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Piercy <[email protected]>
  • Loading branch information
sneridagh and stevepiercy authored Nov 30, 2023
1 parent caa80a9 commit 1be7f4f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 142 deletions.
46 changes: 18 additions & 28 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,81 +21,71 @@ jobs:
run: pip install towncrier

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
volto:
- 'packages/volto/**'
registry:
- 'packages/registry/**'
generator:
- 'packages/generator-volto/**'
scripts:
- 'packages/scripts/**'
voltoSlate:
- 'packages/volto-slate/**'
id: filter
with:
filters: |
volto:
- 'packages/volto/**'
registry:
- 'packages/registry/**'
generator:
- 'packages/generator-volto/**'
scripts:
- 'packages/scripts/**'
voltoSlate:
- 'packages/volto-slate/**'
- name: Volto changelog check
if: steps.filter.outputs.volto == 'true'
working-directory: 'packages/volto'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin main
towncrier check --compare-with origin/main
towncrier check --compare-with origin/main --dir packages/volto
env:
BASE_BRANCH: ${{ github.base_ref }}
if: github.event_name == 'pull_request'

- name: Registry changelog check
if: steps.filter.outputs.volto == 'true'
working-directory: 'packages/registry'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin main
towncrier check --compare-with origin/main
towncrier check --compare-with origin/main --dir packages/registry
env:
BASE_BRANCH: ${{ github.base_ref }}
if: github.event_name == 'pull_request'

- name: Generator changelog check
if: steps.filter.outputs.generator == 'true'
working-directory: 'packages/generator-volto'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin main
towncrier check --compare-with origin/main
towncrier check --compare-with origin/main --dir packages/generator-volto
env:
BASE_BRANCH: ${{ github.base_ref }}
if: github.event_name == 'pull_request'

- name: scripts changelog check
if: steps.filter.outputs.scripts == 'true'
working-directory: 'packages/scripts'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin main
towncrier check --compare-with origin/main
towncrier check --compare-with origin/main --dir packages/scripts
env:
BASE_BRANCH: ${{ github.base_ref }}
if: github.event_name == 'pull_request'

- name: volto-slate changelog check
if: steps.filter.outputs.voltoSlate == 'true'
working-directory: 'packages/volto-slate'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin main
towncrier check --compare-with origin/main
towncrier check --compare-with origin/main --dir packages/volto-slate
env:
BASE_BRANCH: ${{ github.base_ref }}
if: github.event_name == 'pull_request'
32 changes: 0 additions & 32 deletions .github/workflows/towncrier.yml

This file was deleted.

8 changes: 4 additions & 4 deletions docs/source/contributing/volto-core-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
Volto has the concept of "core add-ons".
They are add-ons that are always installed in Volto.
They are located separately from the main code in the `packages` folder.
These add-ons can be released as standalone add-ons, and used in projects that are using versions of Volto that do not have them by default.
Another useful use case is the introduction of new or experimental features that need to be developed side-by-side with core Volto, but not enabled by default.
If Volto uses them directly, these add-ons must be released as stand-alone add-ons.
You can use these packages released as standalone add-ons installed in your old Volto projects to test them or to have a bleeding edge feature without having to upgrade to the latest Volto version.
You can add them to non-Volto projects to get parts of the Volto feature set outside of the main project.

## Enabling a core add-on

This is a feature that only spans in Volto core itself, so it does not apply to projects or add-ons.
The core add-ons are enabled in Volto's own `package.json`.
It uses the key `packagesFolderAddons`:
It uses the key `coreAddons`:

```json
"packagesFolderAddons": {
"coreAddons": {
"volto-slate": {
"package": "@plone/volto-slate"
}
Expand Down
1 change: 1 addition & 0 deletions packages/registry/news/5456.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cleaned up Registry and renamed `packagesFolderAddons` to `coreAddons`. @sneridagh
76 changes: 6 additions & 70 deletions packages/registry/src/addon-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ class AddonConfigurationRegistry {
? `${projectRootPath}`
: `${projectRootPath}/node_modules/@plone/volto`;

this.packagesFolderAddons =
this.coreAddons =
packageJson.name === '@plone/volto'
? packageJson.packagesFolderAddons || {}
? packageJson.coreAddons || {}
: require(`${getPackageBasePath(this.voltoPath)}/package.json`)
.packagesFolderAddons || {};
.coreAddons || {};

this.resultantMergedAddons = [
...(packageJson.addons || []),
Expand All @@ -148,8 +148,8 @@ class AddonConfigurationRegistry {

this.dependencyGraph = buildDependencyGraph(
[
...(Object.keys(this.packagesFolderAddons).map(
(key) => this.packagesFolderAddons[key].package,
...(Object.keys(this.coreAddons).map(
(key) => this.coreAddons[key].package,
) || []),
...this.resultantMergedAddons,
...(process.env.ADDONS ? process.env.ADDONS.split(';') : []),
Expand Down Expand Up @@ -210,43 +210,6 @@ class AddonConfigurationRegistry {
}
});
}
this.initPackagesFolder();
}

initPackagesFolder() {
// TODO: Monorepo => this can be spared, not needed anymore
const registerPackageFolder = (packageFolderName, packageInfo) => {
const packageName = packageInfo.package;
if (this.packages[packageName]) return;

const packagePath = path.normalize(
`${this.voltoPath}/packages/${packageFolderName}/src`,
);
const packageJsonPath = path.normalize(
`${this.voltoPath}/packages/${packageFolderName}/package.json`,
);

// some tests set the root in a location that doesn't have the packages
if (!fs.existsSync(packagePath)) return;

this.packages[packageName] = {
modulePath: packagePath,
packageJson: packageJsonPath,
version: require(packageJsonPath).version,
isPublishedPackage: false,
isRegisteredAddon: false,
name: packageName,
addons: [],
};
this.addonNames.push(packageName);
};

Object.keys(this.packagesFolderAddons).forEach((packageFolderName) => {
registerPackageFolder(
packageFolderName,
this.packagesFolderAddons[packageFolderName],
);
});
}

/**
Expand Down Expand Up @@ -295,35 +258,8 @@ class AddonConfigurationRegistry {
}

initAddonFromEnvVar(name) {
// TODO: Monorepo => this can be spared, not needed anymore
// First lookup in the packages folder, local to the root (either vanilla Volto or project)
const normalizedAddonName = name.split(':')[0];
const testingPackagePath = `${this.projectRootPath}/packages/${normalizedAddonName}/src`;
if (fs.existsSync(testingPackagePath)) {
const basePath = getPackageBasePath(testingPackagePath);
const packageJson = path.join(basePath, 'package.json');

if (!this.addonNames.includes(normalizedAddonName))
this.addonNames.push(normalizedAddonName);
const pkg = {
modulePath: testingPackagePath,
version: require(packageJson).version,
packageJson: packageJson,
isPublishedPackage: false,
isRegisteredAddon: this.addonNames.includes(name),
name: normalizedAddonName,
addons: require(packageJson).addons || [],
};

this.packages[normalizedAddonName] = Object.assign(
this.packages[normalizedAddonName] || {},
pkg,
);
} else {
// Fallback in case the addon is released (not in packages folder nor in development, but in node_modules)
const normalizedAddonName = name.split(':')[0];
this.initPublishedPackage(normalizedAddonName);
}
this.initPublishedPackage(normalizedAddonName);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/__tests__/addon-registry-project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('AddonConfigurationRegistry - Project', () => {
)}/node_modules/@plone/volto/package.json`,
() => ({
// TODO: mock the packages folder inside the mocked @plone/volto to work with resolves
packagesFolderAddons: {},
coreAddons: {},
}),
{ virtual: true },
);
Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/5464.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cleaned up Registry and renamed `packagesFolderAddons` to `coreAddons`. @sneridagh
2 changes: 1 addition & 1 deletion packages/volto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"plone",
"react"
],
"packagesFolderAddons": {
"coreAddons": {
"volto-slate": {
"package": "@plone/volto-slate"
}
Expand Down
5 changes: 0 additions & 5 deletions packages/volto/razzle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const fileLoaderFinder = makeLoaderFinder('file-loader');

const projectRootPath = path.resolve('.');
const languages = require('./src/constants/Languages');
// const { poToJson } = require('@plone/scripts/i18n.cjs');

const packageJson = require(path.join(projectRootPath, 'package.json'));

Expand Down Expand Up @@ -233,7 +232,6 @@ const defaultModify = ({
'load-volto-addons': addonsLoaderPath,
...registry.getResolveAliases(),
'@plone/volto': `${registry.voltoPath}/src`,
// '@plone/registry': `${registry.voltoPath}/packages/registry/src`,
// to be able to reference path uncustomized by webpack
'@plone/volto-original': `${registry.voltoPath}/src`,
// be able to reference current package from customized package
Expand Down Expand Up @@ -276,9 +274,6 @@ const defaultModify = ({
include.push(fs.realpathSync(`${registry.voltoPath}/src`));
}

// console.log(`${registry.voltoPath}../registry/src`);
// include.push(fs.realpathSync(`${registry.voltoPath}../registry/src`));

// Add babel support external (ie. node_modules npm published packages)
const packagesNames = Object.keys(registry.packages);
if (registry.packages && packagesNames.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/towncrier.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.towncrier]
filename = "CHANGELOG.md"
directory = "news"
directory = "./news"
title_format = "## {version} ({project_date})"
underlines = ["", "", ""]
template = "../scripts/templates/towncrier_template.jinja"
Expand Down

0 comments on commit 1be7f4f

Please sign in to comment.