At Sniptt, most of our experience has been writing TypeScript and JavaScript for Node, so we made the decision to use the same technologies to build o

Building a Node.js CLI with TypeScript, packaged and distributed via Homebrew

submited by
Style Pass
2021-06-22 14:30:16

At Sniptt, most of our experience has been writing TypeScript and JavaScript for Node, so we made the decision to use the same technologies to build out the first few versions of the Snip CLI. Our initial testing has shown, however, that distributing security software exclusively over npm would not sit right with many of our users. While our long-term goal is to port the Snip CLI to Golang, we decided to take a pragmatic approach until then and package our JavaScript code as stand-alone executable binaries for both macOS and Linux.

In this t utorial, we’ll show you how to build a simple Node.js CLI with TypeScript, and then package and distribute it via Homebrew.

TLDR; To view a completed setup including workflow automation, take a look at how we’ve done this with our official CLI at https://github.com/sniptt-official/snip-cli 😎.

Let’s start by initialising a new Node.js project called hello via npm init. This will create a package.json file where we’ll keep track of our dependencies and scripts.

Leave a Comment