Skip to content

Instantly share code, notes, and snippets.

@rsp
Last active April 20, 2018 09:06
Show Gist options
  • Save rsp/74553657617f91f30fd8a8966a54c055 to your computer and use it in GitHub Desktop.
Save rsp/74553657617f91f30fd8a8966a54c055 to your computer and use it in GitHub Desktop.
Releasing Open Source Libraries for Node.js and Other Platforms

Releasing Open Source Libraries for Node.js and Other Platforms

My recommendation of releasing open source libraries - not only for Node.

This guide was written specifically for Node modules but it can be adapted to other languages and environments simply by changing "npm" to the main place where open source libraries are published for the given platform (e.g. CPAN for Perl, RubyGems for Ruby etc.)

It is divided into three main stages - a one-time Setup being the first thing to do and ongoing Development and Maintainance stages, plus some useful Tips and Services as a bonus.

See also Releasing Internal Libraries as Open Source for my recommendation on how to create open source libraries with functionality that was already implemented as a part of a client project.

Setup

One-time process:

  1. find a name not used on npm
  2. start a project on github
  3. register the name on npm
  4. decide git branching model before making any commits
  5. decide code style guide before writing any code
  6. configure the github project with protected branches and restricted merging
  7. add license to the project as a first commit
  8. add minimal readme to the project
  9. add minimal boilerplate for the library with no functionality yet
  10. add minimal tests for the project to verify if the library can be required
  11. add project metadata for package managers
  12. add test scripts to the package meta data
  13. add linter to the test pipeline to enforce the chosen code style guide
  14. configure CI (travis and/or circle) with multiple runtime versions
  15. add badges for CI build status, download count, license etc. to the readme
  16. explain style guide, branching model and contribution rules in the readme
  17. add tools to monitor outdated dependencies and vulnerabilities
  18. publish as a 0.0.0 version and proceed to the development stage

Development

Ongoing process:

  1. write the implementation and tests of the new features
  2. run the tests locally and on CI systems
  3. make sure that the new features work as expected
  4. document new changes in readme/docs
  5. bump the version according to the semver rules
  6. merge the code according to the branching style
  7. publish the new version on npm
  8. rinse, repeat

Maintenance

Periodically:

  • handle outstanding issues and pull requests
  • update CI pipeline with new runtime versions
  • test manually with different runtimes and preferably different operating systems

Tips

Some useful tips for easier testing:

  • you can run tests in Docker to quickly test on different Linux distros
  • you can run tests in Vagrant to test on multiple different operating systems

Services

Some useful services to help with the development and testing:

Flow and GitHub Setup

I recommend following the Strict Flow and GitHub Project Guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment