copier icon indicating copy to clipboard operation
copier copied to clipboard

Monorepo support?

Open projetmbc opened this issue 4 months ago • 5 comments

Actual Situation

It seems that copier does not allow to work with projects that each have their own template, but are parts of a monorepo with its own "single" .git.

Desired Situation

Am I wrong? If this is not the case, it might be good to have this type of configuration supported regarding the so useful copier update feature.

Proposed solution

The analysed .git should be that of the monorepo, not that of one of the projects.

projetmbc avatar Aug 26 '25 23:08 projetmbc

IIUC, you'd like to colocate a Copier template and a project generated from that template in the same Git repository. Is this correct? If so, Copier supports a local template path. For example:

copier copy ./template ./project

If your project uses Git tags to mark releases, then this might interfere with Copier's template update detection which relies on Git tags that follow PEP 440 to determine the latest template release. If you need to update to the latest commit, you can pass --vcs-ref HEAD (and similarly any valid Git revision). The appropriate flags and values depend a bit on your specific use case. Could you sketch it in more detail?

sisp avatar Aug 27 '25 09:08 sisp

The structure of my monorepo is as follows (simplified version).

.git
aboutmeta
multimd
src2prod

The projects aboutmeta, multimd, and src2prod use the same template named cb-py-dev. I have no problem creating them, but updating via copier update does not work because .git is above the project folders, and not inside each project folder.

projetmbc avatar Aug 27 '25 10:08 projetmbc

Is your copier.yml file inside cb-py-dev? If so, it currently needs to be in the repo root. You can still keep your template content in the cb-py-dev directory by setting _subdirectory: cb-py-dev in copier.yml. Would this help?

sisp avatar Aug 27 '25 13:08 sisp

This is a first step giving a friendly error message "Cannot update because cannot obtain old template references from .copier-answers.yml.". I think that it just remains to git tagthe template.

On the other, I can use copier copy -a .copier-answers.yml ./copier-templates/cb-py-dev ./coding/bc-tools/for-dev/my-project

projetmbc avatar Aug 27 '25 18:08 projetmbc

For your information, here are the two monorepos used, with, for the moment, just the aboutmeta project created via a copy template.

  1. https://github.com/bc-tools/for-dev/tree/aboutmeta
  2. https://github.com/projetmbc/copier-templates

projetmbc avatar Aug 28 '25 22:08 projetmbc