Use this template + Cookiecutter

I was looking how other template github projects function and here a template-janitor job is triggered to replace the placeholder variables after the user clicks on “Create a new repository” from the “Use this template” combobox in the template repo page.
This functionality would also be very convenient for our exemplar project to have. The implementation above does not use cookiecutter and does the replacement “manually”, but I was wondering if we can have a template-janitor job in the exemplar as well to run the cookiecutter when new repositories are created from this template. That way we wouldn’t need to keep all files twice in the root and the cookiecutter folder. The whole repo could just be the cookiecutter folder!
The difficulty I see is on how to pass all the necessary information from cookiecutter,json to the janitor job at the time of new repo creation.
Any thoughts on that @ednolan ?

1 Like

What a find! I would love to implement this in exemplar. That would totally solve the problem of the complicated workflow users currently need to perform after clicking “Use this template” for exemplar.

That way we wouldn’t need to keep all files twice in the root and the cookiecutter folder. The whole repo could just be the cookiecutter folder!

I would be more open to this after we’d made that change, but I’m still a little bit skeptical– it would change the repo from being an “exemplar” to just being a “template.” One of the advantages of the current setup is that you can look at the exemplar repo to see what your new library would more or less look like without needing to actually stamp out the cookiecutter template first.

Well, we can think in more detail about that once we have a template-janitor job, but I think you are right. Checking all the placeholder variables we currently have in the cookiecutter.json file the only one that would make the template non-functional (thus non-exemplar) is the “cpp_build_version”, the rest of them are strings that will (just) look strange to someone who doesn’t know that exemplar is also a template.
The main problem I see is how to extract all the information we currently need for the cookiecutter at the time of the template creation. From the github’s create project page we can only get the “project_name”, "owner“ and “description” and I cannot find any way to extend this since Github doesn’t cooperate well with cookiecutter templates. This means that we might have to leave the “cpp_build_version”, “paper”, and ““godbolt_link” outside of the template-janitor job, or somehow trigger a second step after we get that piece of information.