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

Enable cookieplone add-ons via mrs.developer in pnpm-workspace.yaml #109

Open
Fosten opened this issue Nov 20, 2024 · 6 comments
Open

Enable cookieplone add-ons via mrs.developer in pnpm-workspace.yaml #109

Fosten opened this issue Nov 20, 2024 · 6 comments

Comments

@Fosten
Copy link
Contributor

Fosten commented Nov 20, 2024

This line works within cookieplone add-ons

But for a project's pnpm-workspace file, this only supports generator-volto add-ons

As seen in kitconcept.volto-lite-theme
https://github.com/kitconcept/volto-light-theme/blob/18c9fba394c41fafbf303dce877ae946735823ca/pnpm-workspace.yaml#L4-L6
This supports cookieplone addons within a cookieplone project

'packages/**/packages/*'

This also worked for me.

'packages/*/packages/*'

Additionally, if the project's pnpm-workspace.yaml is customized for any reason, the user will need to add this to the frontend Dockerfile

COPY --chown=node pnpm-workspace.yaml /app/
@davisagli
Copy link
Member

@Fosten I'm not sure I understand the situation you're reporting. Could you provide steps to reproduce the problem starting from a fresh cookieplone project?

@Fosten
Copy link
Contributor Author

Fosten commented Nov 21, 2024

Ah yes, sorry, I see that I left out a key detail. This is for cookieplone add-ons fetched via mrs.developer.

Steps to reproduce:

  1. Add any cookieplone addon to mrs.developer.json
  2. Enable add-on in volto.config.js
  3. make install = ERR_PNPM_WORKSPACE_PKG_NOT_FOUND  In packages/volto-addon: "volto-addon@workspace:*" is in the dependencies but no package named "volto-addon" is present in the workspace

This is because it clones the entire repo including the "-dev" outer package where there is already declaration for "dependencies": { "volto-addon": "workspace:*"}.

In your cookieplone root project pnpm-workspace.yaml, you can add
packages/volto-addon/packages/*

Or add a catch-all like
packages/*/packages/*

Or simply change
packages/*
to recursive
packages/**

And then for the Dockerfile additionally copy in your pnpm-workspace.yaml (Which should be done anyway to allow future user-customization of this file).

Perhaps there is a better way? Only clone the inner packages/src? Or change mrs.developer add-on path "output": "packages"? Or use hoist settings in .npmrc https://pnpm.io/npmrc ? However, the above solutions worked fine.

This ticket is related to issue #108.

@Fosten Fosten changed the title Enable cookieplone add-ons in project pnpm-workspace.yaml Enable cookieplone add-ons via mrs.developer in pnpm-workspace.yaml Nov 21, 2024
@ichim-david
Copy link
Member

ichim-david commented Jan 26, 2025

@davisagli I think my issue is somewhat similar or perhaps the same and I would love your feedback.

I created a new project using:
pipx run cookieplone project
I created a project and I also added a volto-datatable-tutorial in the wizard for addons to create

I then tried to create it with: pipx run cookieplone frontend_addon
in that case the structure is different and there is no add-on added to volto.config.js
https://gist.github.com/ichim-david/42304649171ef262c699e73f0b4a077b

When we had the yo generator you could run from the project root
yo @plone/volto:addon

and get the addon created in src/addons and integrated with mrs.developer and tsconfig.json

here if you use:
pipx run cookieplone frontend_addon
in the project root you simply create a new folder in the project where you ran the code.

How do we then replicate the behavior of the generator with the cookieplone templates?

EDIT:
I would of expected for volto.config to be updated with the new add-on name and the
add-on to be created within packages/volto-add-on with the same structure as found from
volto-datatable-tutorial which was the add-on name I gave when I created the project

EDIT 2:
My main idea is to update the Volto Add-ons training and although I guess I can get the
add-on created as I need it when I bootstrap the project, we had as a separate step how to
create a new add-on to add to the newly created project.
Trying to create then a new add-on using the frontend_addon cookieplone template
to be integrated into my already-created project is not
as straightforward as it is when using the yo generate addon command.

@stevepiercy
Copy link
Contributor

When a PR is created, let's ensure that related docs are updated in a separate PR. The relevant area is in https://6.docs.plone.org/volto/development/add-ons/index.html, which we published on Nov 5, 2024.

@davisagli
Copy link
Member

The original issue here is about using mrs.developer to check out an add-on which is developed in a separate repository. @Fosten There is existing documentation in https://6.docs.plone.org/volto/development/add-ons/install-an-add-on-dev-18.html which mentions the need to update pnpm-workspace.yaml

@Fosten gave 2 suggestions which make sense to me:

  1. Include packages/**/packages/* in the default pnpm-workspace.yaml generated by the project template
  2. Make sure that customizations to pnpm-workspace.yaml are copied into the Docker image.

@ichim-david If I understood correctly, you're talking about a different scenario where you already have a project and want to create a new frontend addon in the same repository. Did I get that right?

Currently the frontend_addon template supports 2 use cases:

  1. Generating a new frontend addon in its own repository
  2. Generating a new frontend addon as part of a new project (in this case the project template calls the frontend_addon template as a subtemplate, then deletes some things like github actions config that only make sense at the top level of a repository)

Your use case would be nice to support as well. It sounds like we would need to:

  1. Somehow detect that it's being run inside an existing project
  2. Adjust the output folder to frontend/packages/[name] instead of just [name].
  3. Add code to the post_gen_project hook to update project-level config files

@davisagli
Copy link
Member

2 suggestions which make sense to me:

  • Include packages/**/packages/* in the default pnpm-workspace.yaml generated by the project template
  • Make sure that customizations to pnpm-workspace.yaml are copied into the Docker image.

These were taken care of in #112

@ichim-david I'd like to close this issue since the original issue was resolved, and create a new one for supporting your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants