Quick Solid NPM Module

Setting up a rock solid NPM module with semantic release in 30 seconds.

How important is automating one's workflow? I say it is extremely important! Kent C. Dodds in his An Argument for Automation says to "spend 1 hour to automate a 10 second task". While this might seem extreme, I subscribe to a similar idea

Spend time to automate painful and mundane tasks

For example, setting up a new NPM module with all bells and whistles is simple yet mindless list of tasks. I even compiled it into a checklist to go through it like a pilot

and so on.

This is not just my problem - even people very involved with Node itself do not have an official project starter than everyone is happy with. This Twitter thread is a good example

Good generator thread

Last year, I finally wrote a personal Yeoman generator called generator-node-bahmutov to implement most, if not all items on the npm-module-checklist. Whenever I start a new project, I can set up a very solid NPM module in 30 seconds.

First, create a new GitHub repository and a local folder. Then set the remote origin URL. My generator will form all urls based on the remote repo address so this is better be done first.

1
2
3
4
mkdir new-foo && cd new-foo
git init
git remote add origin ...
yo node-bahmutov && yo node-bahmutov:release

I think my generator has good default features and should work for most Node people right out of the box. This is why the initial scaffolding asks you only 3 (!) questions to confirm module's name, description and keywords. The rest is all setup silently.

The optional second command is yo node-bahmutov:release - I use semantic-release for ALL my modules to avoid even thinking about it. The process is customized a little via my plugin modules.

1
2
3
4
5
major(scope): breaking change in API
minor(something): this is a new feature
fix(login): an example fix message
chore(tests): writing more tests
WIP: work in progress, not ready yet
  • before publishing new version you can test downstream dependencies using dont-crack plugin. For example to test current module against https://github.com/bahmutov/foo and https://github.com/bahmutov/bar list these GitHub repositories
1
2
3
4
5
6
7
8
9
10
11
{
"release": {
"verifyRelease": {
"path": "dont-crack",
"test-against": [
"https://github.com/bahmutov/foo",
"https://github.com/bahmutov/bar"
]
}
}
}
  • every closed issue will get a comment when a new version closing this issue is published to NPM registry (using github-post-release plugin)

Example comment

Was it worth writing this generator? I did invest a few days of work, and keep spending time on small modifications, like adding prettier. I believe I already saved days setting up my projects after that and all my NPM modules lately are of higher quality. I now spend literally no overhead on factoring out a piece of code into a separate module.