Publishing package to npm registry, tagging and doing a release, and beyond...
Tags: webdev, javascript, opensource, programming
Published: 2023-11-21 01:32:46

## Release
You can find my [release here](https://www.npmjs.com/package/node-tilify).

## Release tool and package registry used
[npm](https://www.npmjs.com/)

## Installing the package
Installation instructions for node-tilify package can be [found here](https://www.npmjs.com/package/node-tilify#how-to-install).

## Process of creating a release
I watched a couple of videos, read the documentation and a blog before I was able to successfully release the tool on npm. Videos watched include [Creating Node.js modules](https://www.youtube.com/watch?v=3I78ELjTzlQ&list=PLQso55XhxkgBMeiYmFEHzz1axDUBjTLC6&index=11) & [Publishing npm packages](https://www.youtube.com/watch?v=BkotrAFtBM0&list=PLQso55XhxkgBMeiYmFEHzz1axDUBjTLC6&index=11) from [npm's youtube channel](https://www.youtube.com/@npminc) and [How To Create And Publish Your First NPM Package](https://www.youtube.com/watch?v=J4b_T-qH3BY) from [Web Dev Simplified's youtube channel](https://www.youtube.com/@WebDevSimplified). Reading documentation included [npm's very own documentation](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry) and blog includes [Publishing a Node.js CLI tool to npm in less than 15 minutes](https://hackernoon.com/publishing-a-nodejs-cli-tool-to-npm-in-less-than-15-minutes). The steps I performed are below:

1. Ran `npm run adduser` to create a user account on npm and link that user account locally to my machine. Ran `npm version patch` to upgrade the semver, followed by `npm publish —access public` to publish the package. Package was released with `v1.0.0`. Tested by running `npm i node-tilify` followed by `node-tilify -h` and it didn't work.

2. I assumed the location of the index.js was incorrect so I moved it from `/src` dir to `/` root dir part of commit [b832ef9e](https://github.com/sdthaker/Node-TILify/commit/b832ef9eefb0173b1d8ef88774f801b452372195). Ran `npm version patch` to upgrade the semver, followed by `npm publish —access public` to publish the package. Package was released with patch release `v1.0.1`. Tested by running `npm i node-tilify` followed by `node-tilify -h` and it didn't work.

3. I assumed the code within `/index.js` was exposed out in the open without being invoked by a function so I edited the code by putting all of the code into a function and then invoking that function at the bottom of `/index.js` part of commit [6597c56a](https://github.com/sdthaker/Node-TILify/commit/6597c56ab514432707e3ddeb128846630c620194). Ran `npm version patch` to upgrade the semver, followed by `npm publish —access public` to publish the package. Package was released with patch release `v1.0.2`. Tested by running `npm i node-tilify` followed by `node-tilify -h` and it didn't work.

4. According to the blog that I read, it suggested adding a shebang line `#!/usr/bin/env node` at the top of `index.js` file so that systems like Unix can understand what executable to use to run the script, which in this case is node. Also added a property `"bin": "./index.js"` within `/package.json` file so that npm can install the package globally, refer to the bin entry and link the package name with the index.js file as specified in the `./package.json` configuration parth of commit [1583e704](https://github.com/sdthaker/Node-TILify/commit/1583e704825b7a8d30d5858d060cf5aa0580b188). Ran `npm version patch` to upgrade the semver, followed by `npm publish —access public` to publish the package. Package was released with patch release `v1.0.3`. Tested by running `npm i node-tilify` followed by `node-tilify -h` and it didn't work.

5. I missed one step from the blog, running `npm link`. `npm link` is a command-line tool for symlinking a local package as a dependency during development. It is commonly used for testing packages before publishing them. Ran `npm link` to link the package locally, followed by `npm version patch` to upgrade the semver, followed by `npm publish —access public` to publish the package. Package was released with patch release `v1.0.4`. Tested by running `npm i node-tilify` followed by `node-tilify -h` and _it finally started working_.

6. It was then time to update the documentation with latest information on how to install the package from npm. I pushed the commit [e8eb1820](https://github.com/sdthaker/Node-TILify/commit/e8eb182058d7bae3c14e050db01181434e2691dd). Ran `npm version patch` to upgrade the semver, followed by `npm publish —access public` to publish the package. Package was released with patch release `v1.0.5`. Tested by running `npm i node-tilify` followed by `node-tilify -h` and it worked fine.

7. Finally it was time to push all the tags to Github, ran `git push --follow-tags` command and then performed a release manually from GitHub to release `v1.0.6` to the public.

## User Testing
Manual user testing went quite well, which was unexpected. My tool only has 1 step to get it installed on another user's computer and they are ready to go to use the software. They did however point out a thing to fix on my documentation. The readme.md file mentioned the incorrect way to use the tool. It mentioned invoking the tool using `node src/index.js -h` which was now changed to `node-tilify -h`. Besides, they mentioned moving all the information regarding developer contributions like cloning a repo, installing the packages and running the repo code from the command line to contributing.md for better clarity. Also, they got stuck figuring out what passing a directory meant for input and output flags, so I explained it to them and they were able to get going after that point. Moreover, initially, they were reluctant to use `toml` configuration from the command line but then figured it out after reading the documentation a couple of times. Based on the feedback received the documentation was updated accordingly.

## Learning Outcomes
This was a fantastic exercise for me considering I've never published packages to npm and releasing software to the public. I learnt how to test the software before publishing or releasing, publish a package on a registry, add git tags being part of the release, release the software on GitHub and perform user testing to gain valuable feedback from them to improve the documentation which in turn increases user adoption helping to capture wider audience who'd use the software.