DEV Community

Kunwarvir
Kunwarvir

Posted on

Releasing and publishing through npm

Over the past couple of weeks, I've been working on cli-ssg, which is a command line tool to generate a website using .txt/.md files. A lot of changes had accumulated, and this was the perfect time to create an official release 1.0.0.

Tagging the release

Firstly, as cli-ssg was sitting at v0.1, I used npm-version to bump it up:

npm version major
Enter fullscreen mode Exit fullscreen mode

This changed the version in package.json and package-lock.json to:

"version": "1.0.1"
Enter fullscreen mode Exit fullscreen mode

Then, I updated the README.md and proceeded to create a git tag using:

git tag -a v1.0.0 -m "Release 1.0"
Enter fullscreen mode Exit fullscreen mode

At this point, I pushed my changes to GitHub but to my surprise the tags would not show up. After some digging, I realized that tags need to be pushed explicitly, so I used:

git push --tags origin
Enter fullscreen mode Exit fullscreen mode

This fixed the problem, and I was finally able to create a release:
Image description

Publishing to npm

Before one can publish a package to npm, you need to create an account and sign into npm using

npm adduser
Enter fullscreen mode Exit fullscreen mode

Since I already had this setup, I proceeded to publish my package using npm-publish:

npm publish
Enter fullscreen mode Exit fullscreen mode

This published cli-ssg to the public registry and I could now view it on npm:
https://www.npmjs.com/package/cli-ssg

Image description

Installing and testing through npm

While, everything looked great online, I wanted to ensure that users could install it through npm and the functionality worked as expected. And after some testing, as expected, everything works!

To use the package, users can now simply type:

npm i cli-ssg
Enter fullscreen mode Exit fullscreen mode

Once npm installs it, the users can use all the features, for example:

cli-ssg -i "sample_input_file.md"
Enter fullscreen mode Exit fullscreen mode

More examples can be found in our docs!

References

GitHub: https://github.com/dhillonks/cli-ssg
npm: https://www.npmjs.com/package/cli-ssg

Top comments (0)