The Command-Line Interface, or otherwise referred to as CLI, is a common way for developers to interact with different processes. CLI tools are often used in software development, DevOps, or even application structure. Overall, the command-line provides a more streamlined developer experience as well as automation tools for routine maintenance.
NPM, on the other hand, is the world’s largest software registry. The registry contains over one million code packages, supporting open-source developers in their mission to not only share software, but provide an accessible playing field for the management of private development projects.
With NPM supporting command-line tools, developers are given the opportunity to expedite collaboration amongst teammates.
In William Kimak’s Lightning Talk session, we will be uncovering the primary strategies for Publishing A Command-Line Tool To NPM:
- Popular Libraries
- Building Complex Packages
- Live Demonstrations
- Closing Thoughts
Yargs and Commander.js are two of the most popular libraries used for parsing user input. While both have their own collection of pros and cons per developer style, the primary difference between them is:
- Uses types to check for invalid user inputs
- Routes commands to functions, in order to clean up code
With Yargs and Commander.js leading the charge, there are a number of sub-libraries that provide interactive user-experiences to your application.
- Provides real-time error feedback
- Prompts user identity verification questions and validates the answers
- Manages hierarchical prompts
- Based on inquirer
- Supports mixed mode, in which a user doesn’t need a direct prompt for all navigation options
- Changes color of terminal output
- Intuitively bolds, dims, and underlines text
- Creates reusable style code
- Provides a variety of spinners
A jasmine-spec-builder is a command-line tool to build and update jasmine spec files. It allows you to build a spec folder from scratch and/or update an existing file’s providers. It provides developers the option to utilize a MasterServiceStub to initialize service stubs before each unit test. Overall, giving the developer the opportunity to automate tests for both synchronous and asynchronous code.
jasmine-spec-builder has a number of features, including:
- Speed and low overhead with no external dependencies
- An all inclusive library that offers everything needed to test code pre-development
- Availability for both Node and browser
- Use with other languages like Python and Ruby
- Does not require the DOM
- Providing a clean and easy to understand syntax and a rich, straightforward API
- Using natural language to describe the tests and the expected results
Building Complex Packages
The common requirements for developers looking to run more complex tests with the command-line for their NPM packages are:
- Running tests before every publish
- Consistently updating versions using semantic versioning
- Creating a git tag using semantic versioning
- Pushing the package to Github or NPM
- Creating manual release notes for the update
You’ve unpacked quite a few introductory principles to the publishing of command-line tools to NPM…But the best way to learn is through practical and tangible demonstration.
William Kimak has crafted an intuitive demonstration to help guide you through these principles in practicum:
Be sure to follow Kimak’s entire Lightning Talk to view this impressive demonstration in real time.
Publishing Command-Line Tools To NPM has given developers the ability to expedite their team’s backend processes. Overall, bringing more power and innovation to your “coder’s toolbox!” The properties explored above are the primary stepping stones to experimenting with the primary knowledge needed to test how publishing command-line tools to NPM can help streamline processes for your current (or future!) development portfolio. Be sure to explore, have fun, and match up the components that work best for your project!
To learn more about Publishing Command-Line Tools To NPM, along with some live test samples, and to experience William Kimak’s full Lightning Talk session, watch here.