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
- has linting
- has unit tests
- publishes new NPM version using semantic-release
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
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 | mkdir new-foo && cd new-foo |
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.
- the commit format is simple-commit-message
1 | major(scope): breaking change in API |
- 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
andhttps://github.com/bahmutov/bar
list these GitHub repositories
1 | { |
- every closed issue will get a comment when a new version closing this issue is published to NPM registry (using github-post-release plugin)
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.