Skip to content

ProfessorManhattan/template-npm-cli

Repository files navigation

NPM CLI Boilerplate

An NPM CLI maintained by Megabyte Labs



A boilerplate / starting template for NPM CLI packages (using Nest Commander)


Table of Contents

Overview

This repository houses the starting template / boilerplate with the format that all Megabyte Labs NPM CLIs should use. It bundles together NestJS, Nest Commander, and a few other recommended dependencies. It also includes Jest for Test-Driven Development (TDD).

Requirements

If you are simply including this library in your project, all you need is a recent version of Node.js. Node.js >14.18.0 is sometimes required and is the only version range we actively support. Albeit, it is highly probable that lower versions will work as well depending on the requirements that this project imports.

Developer Requirements

The following versions of Node.js and Python are required for development:

Other versions may work, but only the above versions are supported. Most development dependencies are installed automatically by our Taskfile.yml set-up (even Node.js and Python). Run bash start.sh to install Bodega (an improved fork of go-task) and run the initialization sequence. The taskfiles will automatically install dependencies as they are needed, based on what development tasks you are running. For more information, check out the CONTRIBUTING.md or simply run:

npm run help

npm run help will ensure Bodega is installed and then open an interactive dialog where you can explore and learn about various developer commands.

NPM CLI Requirements

All of the NPM CLIs in the Megabyte Labs eco-system should use the same format and core dependencies. They should all be written in TypeScript. Because we use Angular as a first-class choice, NestJS was an easy choice for us to adopt because of the similarities. The fact that NestJS is wildly popular on GitHub does not hurt as well. And because we use NestJS, we decided to use Nest Commander for our NPM CLIs.

Test-Driven Development

Testing CLIs can be cumbersome without the right tools. We have found that the best way of testing a Nest Commander CLI app is to utilize Test-Driven Development principles. Instead of manually compiling the app each time you make a change to test the CLI, we can create Jest tests while we are developing the CLI and then use Nodemon to automatically run the tests everytime we make a change to any file.

We encourage you to adopt these principles and develop your tests while you code.

Development Tools

You are probably already familiar with npm run test and npm run build. We take things a step further and provide a plethora of build tools that are housed in our Taskfile.yml and the accompanying files it includes. We encourage you to attempt to make use of task npm:test:inspect which will watch the files as you code, run the Jest tests whenever a change is made, and open a Chrome DevTools instance for advanced debugging via ndb.

To make sense of all the build tools we include in all of our projects, you can run bash start.sh (to make sure our task runner called Bodega is installed) and then task --menu to show a sweet TUI that will help you navigate through the available commands. It integrates documentation right into the menu too!

Documentation

A link to the Nest Commander documentation can be found here.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page. If you would like to contribute, please take a look at the contributing guide.

Sponsorship

Dear Awesome Person,

I create open source projects out of love. Although I have a job, shelter, and as much fast food as I can handle, it would still be pretty cool to be appreciated by the community for something I have spent a lot of time and money on. Please consider sponsoring me! Who knows? Maybe I will be able to quit my job and publish open source full time.

Sincerely,

Brian Zalewski

Open Collective sponsors GitHub sponsors Patreon

Affiliates

Below you will find a list of services we leverage that offer special incentives for signing up for their services through our special links:

MailChimp DigitalOcean Referral Badge

License

Copyright © 2020-2021 Megabyte LLC. This project is MIT licensed.