Publishing my first npm package | DevsDay.ru

IT-блоги Publishing my first npm package

dev.to 26 ноября 2021 г.


The Project

Eleven weeks ago when I started in Open Source Development 600 at Seneca I never thought I would get to the point of actually releasing something into the wild. Over the term we have been working on our individual static site generators. The purpose of these tools is to take a text file or Markdown file and parse it into a valid HTML document.

It can include a variety of features depending on the student, but some of the options for my own textToHTML include stylesheets, using a config file instead of the command line, and having an output option to specify a folder to put the HTML documents into.

The Journey

Throughout the weeks, we have been contributing to Open Source projects on GitHub and making pull requests. Included in this is the idea of contributing to each other's SSG's. Collaborating with classmates has truly opened my eyes about new ways of doing things and best practices of development. All of my classmates such as Kevan Yang have been instrumental in getting the tool ready for npm deployment.

We added linting, style guides, testing, continuous integration, among many other things throughout the semester. Each time, finding a better approach and refactoring.

How does npm deploying work?

First of all, you will need to go to the npm website and create an account. This is where your packages will be stored. Then, make sure you have npm installed on your computer. You can check using npm -v in the terminal.

Next you will need to run npm login command and enter your credentials for the account you created. From the root directory of your project, run npm publish.

Important you may get an error about a package with the same name existing. You may either create a scoped package or change the name to something else. The name is found in the package.json file of your application.

That's it!!! Your package should show up on your npm account. However, if you want to tell people how to use your application you should create a README.md with usage instructions, and then run npm version patch and npm publish again to release a new version. In order to do this your Git commit history must be clean.

How to try my tool (if you want)

As mentioned, I published a package as part of the course and the way to install it is via terminal. My tool is called textToHTML. You may type npx texttohtmlv2 in your command line. It will prompt you to install the package (say yes). Then, to see if it's working you can try the help command by typing npx texttohtmlv2 -h in the terminal. It should display a list of other things to try out.

Final thoughts (for the final lab)

This has been such an amazing journey in my 5th semester at Seneca. I have had the opportunity to contribute to things I never dreamed of having a hand in working on like the jasmine testing framework, and also learned how to persevere when things aren't going right and to keep trying different approaches. I have also learned things that will serve me in my career such as Continuous Integration, end-to-end testing, Linting.

Last, and certainly not least I learned about using Git. At first it was terrifying because all of the commands were foreign. Throughout the term we have been forced to adopt Git and learn to use commits, branches, merges, and pull requests to organize our work which has been an amazing learning experience.

I know this article wasn't all about publishing, but I hope my experience inspires someone else to build a project even if it starts small.

Thanks for reading!

Andre Willomitzer

Источник: dev.to

Наш сайт является информационным посредником. Сообщить о нарушении авторских прав.

opensource webdev npm