Fat Codes

Software engineering related ramblings by fat

Useful Npm Scripts for Nodejs Microservices

When a man without a package.json meets a man with a package.json, the man without a package.json wants one.

That’s what clint eastwood would say if only he knew about the power of these files!

This is not properly a blog post, rather a collection of package.json scripts I’ve been using in the last 3–5 years. Please note that these are microservice oriented scripts, so if you are building / maintainging npm packages such as libraries or frameworks, some of these scripts won’t matter to you.

I will do my best to keep this list up to date with my scripts, and please if you have cool package.json scripts, post it in the comment section!


Running the application

I extensively use docker-compose for single-host deployment and for spinning up the expected environment for our microservices.


Running tests

The first command is the one used by pre-commit hooks and by yourself when you want to make sure you didn’t screw things up.

The second is used by your favorite CI/CD pipeline/tool (in my case the dear gitlab-runner)

The third and the fourth are used by you (or your IDE/Editor) while you are working on a specific portion of code.


From build to release

This sections uses a bit of tooling:

  • ESLint does not need introductions. We all need it very badly.
  • The commit command uses commitzen, check it out
  • conventional-changelog creates/updates the changelog from your project’s commit history
  • release.sh is a scripts that heavily depends on your project, a good point to start is the one from request/request. If you are using a git-based deployment flow, you can control deployments too from the release.sh script.
comments powered by Disqus