Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

TOP_LEVEL_TEMPLATES = add-ons/backend add-ons/frontend projects/monorepo projects/classic
SUB_TEMPLATES = sub/cache sub/frontend_project sub/project_settings
TOP_LEVEL_TEMPLATES = add-ons/backend add-ons/frontend add-ons/monorepo projects/monorepo projects/classic
SUB_TEMPLATES = ci/github sub/cache sub/frontend_project sub/addon_settings sub/classic_project_settings sub/project_settings sub/vscode

# Python checks
UV?=uv
Expand Down Expand Up @@ -88,3 +88,7 @@ report-keys-usage: $(VENV_FOLDER) ## Generate a report of usage of context keys
@echo "$(GREEN)==> Generate a report of usage of context keys$(RESET)"
@uv run .scripts/report_keys_usage.py

.PHONY: run
run: $(VENV_FOLDER) ## Run cookieplone
@echo "$(GREEN)==> Run cookieplone$(RESET)"
COOKIEPLONE_REPOSITORY=$(CURRENT_DIR) uv run cookieplone
38 changes: 34 additions & 4 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@
"project": {
"path": "./templates/projects/monorepo",
"title": "Volto Project",
"description": "Create a new Plone project that uses the Volto frontend",
"description": "Plone project that uses the Volto frontend",
"hidden": false
},
"classic_project": {
"path": "./templates/projects/classic",
"title": "Classic UI Project",
"description": "Create a new Plone project that uses Classic UI",
"description": "Plone project that uses Classic UI",
"hidden": false
},
"monorepo_addon": {
"path": "./templates/add-ons/monorepo",
"title": "Add-on for Plone (with backend and frontend)",
"description": "Codebase for a Plone add-on with backend and frontend parts",
"hidden": false
},
"backend_addon": {
"path": "./templates/add-ons/backend",
"title": "Backend Add-on for Plone",
"description": "Create a new Python package to be used with Plone",
"description": "Python package to be used with Plone",
"hidden": false
},
"frontend_addon": {
"path": "./templates/add-ons/frontend",
"title": "Frontend Add-on for Plone",
"description": "Create a new Node package to be used with Volto",
"description": "Node package to be used with Volto",
"hidden": false
},
"sub/cache": {
Expand All @@ -36,6 +42,12 @@
"description": "Subtemplate with configuration used in container images for frontend project.",
"hidden": true
},
"sub/addon_settings": {
"path": "./templates/sub/addon_settings",
"title": "Settings to be applied on top of a mono repo add-on codebase",
"description": "Subtemplate with configuration and settings for a mono repo add-on.",
"hidden": true
},
"sub/project_settings": {
"path": "./templates/sub/project_settings",
"title": "Project settings to be applied on top of a mono repo project",
Expand All @@ -48,11 +60,29 @@
"description": "Subtemplate with configuration and settings for a Classic UI project.",
"hidden": true
},
"sub/vscode": {
"path": "./templates/sub/vscode",
"title": "VSCode settings",
"description": "Subtemplate with configuration and settings for VSCode.",
"hidden": true
},
"documentation_starter": {
"path": "./templates/docs/starter",
"title": "Documentation scaffold for Plone projects",
"description": "Create a new documentation scaffold for Plone projects",
"hidden": false
},
"ci_github": {
"path": "./templates/ci/github",
"title": "GitHub CI configuration for Plone projects",
"description": "Create a new GitHub CI configuration for Plone projects",
"hidden": true
},
"devops_ansible": {
"path": "./templates/devops/ansible",
"title": "Ansible Playbooks for Plone",
"description": "Ansible setup to manage a Docker Swarm cluster for Plone hosting.",
"hidden": true
}
}
}
1 change: 1 addition & 0 deletions news/+monorepo-calver.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Project monorepo uses calendar versioning. @ericof
1 change: 1 addition & 0 deletions news/+monorepo-gha.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactored Github actions for monorepo projects. @ericof
1 change: 1 addition & 0 deletions news/+monorepo.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor monorepo project to use uv and repoplone. @ericof
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also mention the refactor of the CI pipeline

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a day or two from being done, but I will make sure to add the changelog entries for the CI and for the base Docker images

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ description = "Collection of templates for Plone integrators to use through Cook
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"cookieplone>=0.9.7",
"cookieplone>=0.9.10",
"gitpython>=3.1.43",
"pytest>=8.3.5",
"pytest-cookies>=0.7.0",
"pytest-jsonschema>=1.0.0b1",
"pytest-jsonschema>=1.0.0",
"pytest-md-report>=0.6.3",
"tomli>=2.0.1",
]
Expand Down
8 changes: 6 additions & 2 deletions templates/add-ons/backend/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"plone_version": "{{ cookiecutter.use_prerelease_versions | latest_plone }}",
"python_package_name": "{{ cookiecutter.github_organization|lower }}.{{ cookiecutter.title|replace(' ', '')|replace('-', '_')|replace('.', '')|lower }}",
"__year": "{% now 'local', '%Y' %}",
"initial_version": "1.0.0a0",
"configuration_version": "1000",
"feature_headless": ["1", "0"],
"initialize_documentation": ["1", "0"],
"__project_slug": "{{ cookiecutter.python_package_name }}",
Expand All @@ -28,8 +30,8 @@
"__gha_plone_version": "{{ cookiecutter.plone_version }}",
"__python_version_identifier": "{{ cookiecutter.__supported_versions_python[0] | replace('.', '') }}",
"__profile_language": "en",
"__version_package": "1.0.0a0",
"__profile_version": "1000",
"__version_package": "{{ cookiecutter.initial_version }}",
"__profile_version": "{{ cookiecutter.configuration_version }}",
"__backend_addon_git_initialize": "1",
"__backend_addon_format": "1",
"__prompts__": {
Expand All @@ -41,6 +43,8 @@
"python_package_name": "Python package name",
"author": "Author",
"email": "Author E-mail",
"initial_version": "Package version",
"configuration_version": "Configuration version",
"feature_headless": {
"__prompt__": "Support headless Plone?",
"1": "Yes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ var/
/reports/
/sources/
/venv/
.mxdev_cache
constraints*.txt
requirements*.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test = [
"plone.restapi[test]",
"pytest",
"pytest-cov",
"pytest-plone>=0.5.0",
"pytest-plone>=1.0.0a2",
]
release = [
"zest.releaser[recommended]",
Expand Down
8 changes: 6 additions & 2 deletions templates/add-ons/frontend/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
"__version_frontend_package": "1.0.0-alpha.0",
"__version_plone_volto": "{{ cookiecutter.volto_version }}",
"__version_mrs_developer": "^2.2.0",
"__version_pnpm": "9.1.1",
"__version_release_it": "^17.1.1",
"__version_pnpm": "{{ '10.20.0' if cookiecutter.volto_version >= '19' else '9.1.1' }}",
"__version_release_it": "^19.0.5",
"__version_testing_library_react": "^16.2.0",
"__version_typescript": "^5.7.3",
"__version_vitest": "^3.1.2",
"__node_version": "{{ cookiecutter.volto_version | node_version_for_volto }}",
"__gha_version_node": "{{ cookiecutter.__node_version }}",
"__gha_version_checkout": "v4",
Expand All @@ -27,6 +30,7 @@
"__gha_version_background_action": "v1",
"__gha_version_upload_artifact": "v4",
"__gha_version_pages_deploy": "v4",
"__test_framework": "{{ 'vitest' if cookiecutter.volto_version >= '19' else 'jest'}}",
"__prompts__": {
"frontend_addon_name": "Add-on (Short name of the addon)",
"title": "Add-on Title",
Expand Down
14 changes: 14 additions & 0 deletions templates/add-ons/frontend/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ def generate_docs_starter(context, output_dir):
files.remove_files(output_dir / folder_name, DOCUMENTATION_STARTER_REMOVE)


def remove_conditional_files(context, output_dir):
if context["__test_framework"] == "jest":
(
output_dir
/ "packages"
/ context["frontend_addon_name"]
/ "vitest.config.mjs"
).unlink()
else:
(output_dir / "jest-addon.config.js").unlink()


def main():
"""Final fixes."""

Expand All @@ -53,6 +65,8 @@ def main():
console.print(f" -> {title}")
func(new_context, output_dir)

remove_conditional_files(context, output_dir)

msg = """
[bold blue]{{ cookiecutter.frontend_addon_name }}[/bold blue]

Expand Down
1 change: 1 addition & 0 deletions templates/add-ons/frontend/hooks/pre_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"20",
"21",
"22",
"24",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ test: ## Run unit tests
.PHONY: ci-test
ci-test: ## Run unit tests in CI
# Unit Tests need the i18n to be built
VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto i18n
CI=1 RAZZLE_JEST_CONFIG=$(CURRENT_DIR)/jest-addon.config.js pnpm --filter @plone/volto test -- --passWithNoTests
VOLTOCONFIG=$(CURRENT_DIR)/volto.config.js pnpm --filter @plone/volto i18n
{%- if cookiecutter.__test_framework == 'jest' %}
CI=1 RAZZLE_JEST_CONFIG=$(CURRENT_DIR)/jest-addon.config.js pnpm run --filter @plone/volto test --passWithNoTests
{%- else %}
CI=1 pnpm run test --passWithNoTests
{%- endif %}

.PHONY: backend-docker-start
backend-docker-start: ## Starts a Docker-based backend for development
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Cypress {
export interface Chainable {
/**
* Custom command to select DOM element by data-cy attribute.
* @example cy.dataCy('greeting')
*/
navigate(value: string): Chainable<JQuery<HTMLElement>>;
getSlateEditorAndType(value: string): Chainable<JQuery<HTMLElement>>;
setSlateSelection(value: string): Chainable<JQuery<HTMLElement>>;
clickSlateButton(value: string): Chainable<JQuery<HTMLElement>>;
autologin(): Chainable<JQuery<HTMLElement>>;
createContent({
contentType,
contentId,
contentTitle,
path,
bodyModifier,
preview_image_link,
}: {
contentType: string;
contentId: string;
contentTitle: string;
path?: string;
bodyModifier?: (body: any) => any;
preview_image_link?: { '@id': string };
}): Chainable<JQuery<HTMLElement>>;
addNewBlock(value: string): Chainable<JQuery<HTMLElement>>;
matchImage(): Chainable<JQuery<HTMLElement>>;
injectAxe({
axeCorePath,
}: {
axeCorePath: string;
}): Chainable<JQuery<HTMLElement>>;
checkA11y(
context?: Object | string,
options?: Object,
violationCallback?: (violations: any[]) => void,
skipFailures?: boolean,
): Chainable<JQuery<HTMLElement>>;
checkAccessibility(): Chainable<JQuery<HTMLElement>>;
getSlate(): Chainable<JQuery<HTMLElement>>;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "@testing-library/cypress", "node"]
},
"include": ["**/*.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"build": "VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto build",
"build:deps": "pnpm --filter @plone/registry --filter @plone/components build",
"i18n": "pnpm --filter {{ cookiecutter.__npm_package_name }} i18n && VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto i18n",
{%- if cookiecutter.__test_framework == 'jest' %}
"test": "RAZZLE_JEST_CONFIG=$(pwd)/jest-addon.config.js pnpm --filter @plone/volto test -- --passWithNoTests",
{%- else %}
"test": "pnpm --filter {{ cookiecutter.__npm_package_name }} exec vitest",
{%- endif %}
"lint": "VOLTOCONFIG=$(pwd)/volto.config.js eslint --max-warnings=0 'packages/**/src/**/*.{js,jsx,ts,tsx}'",
"lint:fix": "VOLTOCONFIG=$(pwd)/volto.config.js eslint --fix 'packages/**/src/**/*.{js,jsx,ts,tsx}'",
"prettier": "prettier --check 'packages/**/src/**/*.{js,jsx,ts,tsx}'",
Expand All @@ -44,7 +48,21 @@
"overrides": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"react-refresh": "^0.14.2"
}
}{%- if cookiecutter.volto_version >= '19' %},
"ignoredBuiltDependencies": [
"@parcel/watcher"
],
"onlyBuiltDependencies": [
"core-js",
"core-js-pure",
"cypress",
"es5-ext",
"esbuild",
"full-icu",
"lightningcss-cli",
"unrs-resolver"
]
{%- endif %}
},
"packageManager": "pnpm@{{ cookiecutter.__version_pnpm }}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,22 @@
"addons": [],
"dependencies": {},
"peerDependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"@plone/registry": "workspace:*",
"@plone/types": "workspace:*"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@plone/registry": "workspace:*",
"@plone/scripts": "workspace:*",
"@plone/types": "workspace:*",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.1",
"typescript": "{{ cookiecutter.__version_typescript }}",
{%- if cookiecutter.__test_framework == 'jest' %}
"release-it": "{{ cookiecutter.__version_release_it }}"
{%- else %}
"@testing-library/react": "{{ cookiecutter.__version_testing_library_react }}",
"release-it": "{{ cookiecutter.__version_release_it }}",
"vitest": "{{ cookiecutter.__version_vitest }}"
{%- endif %}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'vitest/config';
import voltoVitestConfig from '@plone/volto/vitest.config.mjs';
import path from 'path';

export default defineConfig({
...voltoVitestConfig,
resolve: {
alias: {
'@plone/volto': path.resolve(__dirname, '../../core/packages/volto/src'), // Add paths accordingly
// 'promise-file-reader': require.resolve('promise-file-reader') // Add to identify dependency from package
},
},
});
1 change: 1 addition & 0 deletions templates/add-ons/monorepo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addon
Loading