Skip to content

Commit

Permalink
create addon package using bobtemplates.plone
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Oct 15, 2022
1 parent 81c6fc2 commit 219d768
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
43 changes: 35 additions & 8 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ def prepare_frontend(volto_version: str, description: str):
"frontend",
],
[
f"Generate frontend application with @plone/volto {_info(volto_version)}",
f"yo @plone/volto frontend --description '{description}' {addons} "
f"--skip-install --no-interactive --volto={volto_version}{canary}",
(
"Generate frontend application with @plone/volto"
f" {_info(volto_version)}"
),
(
f"yo @plone/volto frontend --description '{description}'"
f" {addons} --skip-install --no-interactive"
f" --volto={volto_version}{canary}"
),
True,
"frontend",
],
Expand All @@ -113,15 +119,35 @@ def prepare_frontend(volto_version: str, description: str):
with open(cfg, "r") as fh:
data = fh.read()
with open(cfg, "w") as fh:
new_data = re.sub("\n \/\/ Add here your project.*\n", VOLTO_CONFIG, data)
new_data = re.sub(
"\n \/\/ Add here your project.*\n", VOLTO_CONFIG, data
)
fh.write(new_data)


def prepare_backend():
"""Apply black and isort to the generated codebase."""
def prepare_backend(python_package_name: str):
"""Run plonecli/bobtemplates to create the package.
Apply black and isort to the generated codebase."""
print("Backend codebase")
steps = [
["Format generated code in the backend", ["make", "format"], False, "backend"]
[
"Create python package using bobtemplates/plonecli",
[
(
"mrbob --config src/.mrbob.ini -O"
f" src/{python_package_name}.addon"
" bobtemplates.plone:addon"
),
],
True,
"backend",
],
[
"Format generated code in the backend",
["make", "format"],
False,
"backend",
],
]
for step in steps:
msg, command, shell, cwd = step
Expand All @@ -133,13 +159,14 @@ def prepare_backend():

volto_version = "{{ cookiecutter.volto_version }}"
description = "{{ cookiecutter.description }}"
python_package_name = "{{ cookiecutter.python_package_name }}"


def main():
"""Final fixes."""
prepare_frontend(volto_version=volto_version, description=description)
print("")
prepare_backend()
prepare_backend(python_package_name=python_package_name)
print(f"{MSG_DELIMITER}")
msg = dedent(
f"""
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ isort
pytest
pytest-cookies
wheel
bobtemplates.plone>=6.0b1
13 changes: 13 additions & 0 deletions {{ cookiecutter.project_slug }}/backend/src/.mrbob.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[mr.bob]
verbose = True

[variables]
author.name = {{ cookiecutter.author }}
author.email = {{ cookiecutter.email }}
author.github.user = {{ cookiecutter.github_organization }}
package.description = {{ cookiecutter.description }}
package.git.init = n

plone.version = {{ cookiecutter.plone_version }}
python.version = 3.10
vscode_support = n

0 comments on commit 219d768

Please sign in to comment.