tmrts / boilr

:zap: boilerplate template manager that generates files or directories from template repositories
Apache License 2.0
1.73k stars 118 forks source link

Plan for updating projects when templates change? #4

Open sgoings opened 8 years ago

sgoings commented 8 years ago

I'm currently toying around with the makeup project and would love to see the makeup cli be fully ported to the boilr tool. However, I'm held up by what boilr's offerings for a "template update" feature might be.

Creating a project for the first time is a fairly automateable and understandable task, but having the ability to take a project from an initial creation and slowly add in advancements/features down the line is a trickier endeavor (think: when the templates add awesome functionality and people want that new functionality...). Have you thought about how you might accomplish this?

A common use case of boilr for me starts with the initial bootstrapping:

Somewhere down the road, I'm going to want to use boilr to move the repoA project from version 1 to version 2 (after adding some more makefile targets).

I have a few possible directions:

tmrts commented 8 years ago

Thank you for your detailed use case and feature request.

We can assume that any successful template will have new features and bug fixes. But, I didn't consider updating used templates when the boilr templates are updated since the aim at the moment is to provide a starter boilerplate for users.

However, I can see the benefit of adding a mechanism as a plugin command (boilr plugin X args) with some modifications.

I think using upgrade might be confusing to people since templates are saved locally and they might think it is for updating stored templates. Instead migrate might be a better name for this context.

In order to allow people to upgrade their used templates, the used template needs to be parsed but I'm not sure if that's the way to go. Instead, boilr can store the answers given to that particular template and then when asked boilr plugin migrate <path>, it can automatically use the same answers, but it might overwrite the changes so users either, need to be warned about this or as you suggested a read-only template mechanism can be implemented (e.g. boilr use --read-only <template-name> <target-dir>)

Cons of automatically using the answers:

Cons of read-only templates:

sgoings commented 8 years ago

I like this idea:

boilr can store the answers given to that particular template and then when asked boilr plugin migrate <path>

Where they'd potentially be asked more questions if the newer version needed to. I'm totally ok with this feature starting out as a plugin. That's what we did with helm.

jdoklovic commented 7 years ago

Personally, I think updating can be even simpler to begin with if a template could simply identify which files can be overwritten.

e.g. I create a project with boilr that creates a readme and a CI plan template. Then I add a bunch of code and update the readme. Then at some point the completely boilerplate CI template is updated. I should be able to run some sort of update that keeps all of my newly created files, does not overwrite the readme, but does overwrite the CI template.

tmrts commented 7 years ago

@jdoklovic since we have started using git as the back-end, implementation of this feature is simplified considerably.

What we want is basically a git-rebase:

  1. User renders the template
  2. User does some other modifications
  3. Updated template is downloaded
  4. A stash and rebase is performed on the previously executed & used template

There are some problems with this solution, such as rebase conflicts