How to update project templates?

I have to templates for creating my new projects:

For coworkflow, I have about 10+ repositories based on it, in old of newer versions, which contains:

  • shadow-cljs.edn for ClojureScript compiler
  • package.json for npm scripts, which handles assets building
  • main.cljs for initializations of Respo and DOM
  • business code

So every time there’s updates in a configure file, I have 10+ projects to update. As time past, it becomes really tedious and time-costing work to maintain them all. For each project:

=>> git log --oneline | grep up
37b5859 upgrade sepal and recollect; release 0.3.3 on npm
4ccdcbf update workflow; upgrade respo; fix :package ; release 0.3.1 on npm
3e5cda5 upgrade sepal; release 0.3.0
db30f1e update shortcut link; add Consolas in leaf; upgrade npm deps; release 0.2.19 on npm
3d90607 update icon; release 0.2.15 on npm
6842d74 update guide texts; release 0.2.14 on npm
dfc6fae update README like stack-editor
12c2d3b upgrade shadow-cljs 2.0.3 to fix nodejs hmr
8e8bdd5 support editing expr in draft box
e299661 upgrade deps
ac31fee update respo; add comp-rename
0c74d8d upgrade respo 0.6.0-rc6
a6c0ee5 upgrade deps
673a512 upgrade deps
92a14c0 update push stack algorithm

Even through each project is a very simple page, updating the template is tedious.

For cumulo-workflow, contains more like main.cljs with a server.cljs, which means more code. I’m thinking about turning the code into side-effect functions, however it does no help to the build scripts…

What do you think can save us from such tedious works?

I agree being able to update project templates would be a useful feature.

It might be worth looking at how creat-react-app does this. It allows you to upgrade the scaffolding automatically, unless you’ve “ejected” the project, i.e. declared independence from the template.

In my case I always run in ejected mode to make sure each page has different paths and configs. Abstracting code into dependencies is less viable… I did quite some copy-paste(even diff patch by hand) last night trying to migrate one.

This is something that people ask about every so often for Chestnut. There’s no real good solution. In general I think pushing as much of the template into libraries is a good first step, those can more easily be upgraded. Some stuff you want to have in the actual template though.

Chestnut will initialize Git and generate a first commit with the generated code, and the commit message will show you which options you used. What I’ve advised people before is to re-run that command, and then diff the result with the first commit of your project.

If you’re feeling adventurous you can try to apply that diff to your current code, or you can go through it manually, or you could import the newly generated repo into your existing repo, then rebase everything but the initial commit on top of it. For some cases I can imagine this will work well, but for projects with a lot of history it’s probably not feasible, you’ll be fixing conflicts until the heat death of the universe.

1 Like