DEV Community

Cover image for How Do You Automate Your Boilerplate?
Marc Nevin
Marc Nevin

Posted on

How Do You Automate Your Boilerplate?

My team is reviewing how we start-up our projects, a large time sink for us is the initial set-up for running a prototype or Proof of Concept. We end up repeating similar repo and language/framework boilerplate over and over.

This boilerplating that we do for our projects is ripe for automation; we're looking at GitHub's templates for doing some of the heavy lifting around repo creation and we're looking for ways to automate adding GitHub Actions.

When it comes to generating project-specific boilerplate we're looking at language-specific tools but this in early stages.

This has led us to wonder what everyone else does, so, how do you automate your boilerplate for projects?

Is it templates, scripts or interns?


No interns were forced to do repetitive tasks in the making of this post, cover photo from pexels.

Latest comments (38)

Collapse
 
richardeschloss profile image
Richard Schloss

I actually have two boilerplate repos: 1) is an app template (but now not always needed because of nuxt-create-app, which I think does a great job at starting me up, but I go faster when I don't have to npm install stuff all over again), and 2) a "component design studio". The latter is my favorite where I can focus more on tiny and specific components that can be re-used in multiple projects. I guess someday I'll give bit a try.

Collapse
 
dtinth profile image
Thai Pangsakulyanont

From my experience, most templates that I use or create are doomed to be outdated someday, as we as a community uncover ways to improve how we build software. Having a template also means having to keep it in sync with how the template is actually used, or it is doomed to become out-of-sync. It created a lot of overhead and friction for me.

Nowadays in my projects, I try to write code that is easy to delete, so that when I create a new project, I can take the latest project, or one of the older projects, delete all the project-specific code, and develop based off that.

From time to time I noticed patterns many of my projects. That is when I create reusable stuffs such as tkt, xprs, vuetoy, or tailwindtinth. Now I usually avoid creating reusable stuff, until I am very sure that it is indeed reusable.

Collapse
 
jessekphillips profile image
Jesse Phillips

Being QA the boilerplate is around test structure for xunit. I looked into some Visual Studio templates, but I do not like the management or distribution process for them.

Our devs would say that they fork a repo. Original it was a dotnet template. I disagree that it is a template and have been pushing that it is a product implementation and that conceptually we are in fact forking for each new client. Client work should contribute and take this baseline. Several developers are now pushing for the same thing.

Collapse
 
gabe_ragland profile image
Gabe Ragland

I've been working on a web-based tool that lets you quickly create a Node/React codebase with everything they need: divjoy.com. Would love to hear your thoughts!

Collapse
 
jhermann profile image
Jürgen Hermann

Project scaffolding is the good kind of programmer laziness, thus Springerle, my collection of cookiecutters (Python).

Collapse
 
sobolevn profile image
Nikita Sobolev

We use templates for projects that we often use:

We use cookiecutter for python, and vue-cli for, well, vue!

Collapse
 
m_nevin profile image
Marc Nevin

Cookiecutter looks like it'll be a solid shout for some of our python scaffolding, it's something we always fall back to using!

Thanks for sharing your templates though, definitely going to take a look at them

Collapse
 
seanconnolly profile image
Sean Connolly

Hygen.io

It's more powerful than GH templates and pretty easy to setup and maintain.

Collapse
 
m_nevin profile image
Marc Nevin

Hmm okay, more and more advocates for Hygen.io!

What do you think makes it easier to maintain?

Collapse
 
seanconnolly profile image
Sean Connolly

You can update your templates and then test right there in the CLI. With GH templates you need to go through the process of creating a new repo.

Also hygen.io supports scripts. E.g. you can run npm install after generating your project.

GH templates don't even support variable substitution.

Thread Thread
 
m_nevin profile image
Marc Nevin

Ohh the scripting and substitution do sound like they'd win out on top of GH templates,

Variations depending on individual templates seem the most time consuming forking the template to make a template etc, guess that gets around all of that!

Collapse
 
jankapunkt profile image
Jan Küster 🔥

I use a boilerplate for my npm packages that include the tools I am used to work with: Babel 7, mocha, chai, standard, jsdoc
While this is very opinionated it perfectly fits my routine, so I can hands on immediately

Collapse
 
m_nevin profile image
Marc Nevin

How do you implement the boilerplate for these? Just a standard repo you clone and change?

And mocha and chai and fantastic

Collapse
 
jankapunkt profile image
Jan Küster 🔥 • Edited

Sorry, I forgot to add this information. It's a template repository: github.com/jankapunkt/npm-package-...

You can create new repositories, based on templates: help.github.com/en/github/creating...

Thread Thread
 
m_nevin profile image
Marc Nevin

Ohhh nice I'll take a look at your template!

Collapse
 
yougotwill profile image
Will G

I create my own templates/boilerplate and then use github.com/Rich-Harris/degit. However you can run degit on any github repo so essentially you have access to a ton of templates. I have no idea about automatically adding GitHub actions but I'm also curious.

Collapse
 
m_nevin profile image
Marc Nevin

Ohh interesting, never heard of this but being able to lift templates from what we've done in the past could lead to some pretty quick velocity on getting us started!

In the brief look, I've had, if registered, it should be just adding them to the repo but I think you might be able to add them to a GH template,

Collapse
 
yougotwill profile image
Will G

Awesome thanks for letting me know!

Collapse
 
dnnrly profile image
Pascal Dennerly

I have a repo with boilerplate in Github that I use for CLI tools. We've used a similar technique for miceoservices at work too.

Both use a simple shell script to rename file and packages etc.

Take a look at github.com/dnnrly/goclitem

Collapse
 
m_nevin profile image
Marc Nevin

Ahh thanks for the link will take a look and see what we can gleam from it!