Use TypeScript and CircleCI v2 Workflows for NPM packages

November 5th, 2017 350 Words

If you love software workflows as much as I do, you should check out my basics for deploying NPM packages using TypeScript, CircleCI v2, and GitHub Releases.

You can find an example project on GitHub configured with all of following features. Use this guide as documentation for the project and make sure to check out the sources!

GitHub and The Basics

Just work with GitHub as you are used to: Work in branches, create Pull requests, ensure an always building master branch, and think about why you might be using git wrong.

GitHub PullRequest

CircleCI v2 Workflows

The recent major release v2 of CircleCI introduced new features for Jobs and Workflows. You can split up the build process of your projects into smaller jobs that can be organized in workflows.

Each step for the NPM package is separated in single jobs, so tasks for running the tests and linting the source files can be run in parallel.

CircleCI 2.0 Workflow

With the basic GitHow flow, this works perfectly: Every commit on a branch and new Pull requests trigger the following NPM tasks:

  • lint - Check the sources
  • test - Run all tests
  • build - Ensure the project can be build
  • coverage - Post coverage report to Coveralls.io

Per default lint and test are executed at the same time in parallel. After both tasks finished successfully, CircleCI triggers the jobs for build and coverage, in parallel of course.

Publish to NPM

On top of the basics for every branch and PullRequest, CircleCI is configured to run the deploy task for every GitHub Release after building the project was successful.

GitHub Release

With this workflow, you will always have tests, linting, and compile checks for every branch and PR. You can manage your changelog with GitHub Releases and don’t have to care about how to publish your project to NPM.

GitHub Release Overview

Just configure CircleCI with your NPM token, and for every release a new NPM package with that version is published:

NPM Package

You can find all sources on GitHub, of course. Just clone the repository and start writing your NPM modules using TypeScript and say goodbye to plain JavaScript 👋 😘


View on GitHub Source code is published using the MIT License.
  • Use SequelPro with OpenPGP cards like a YubiKey

    November 8th, 2017 182 Words

    The YubiKey is a great OpenGPG smart card compatible hardware device. I use my YubiKey to store my private GnuPG key and for authenticating SSH connections. A few applications, however, don’t work with the OpenGPG card and require a file containing the key per default; Sequel Pro is one of them.

  • AWS Lambda with MaxMind GeoLite2 IP database

    November 3rd, 2017 172 Words

    The MaxMind GeoLite2 database is basically the standard solution when you need to get the geo information for an IP address. Together with the mmdb-reader NPM package you can easily deploy your own serverless API to AWS Lambda to lookup locations for IP addresses.

  • Serverless Analytics with Amazon Kinesis and AWS Lambda

    August 23rd, 2017 591 Words

    AWS Lambda functions together with an Amazon Kinesis Stream offer a great way to process continuous information. I created an example project called Serverless Analytics to demonstrate this. You can use this as the starting point to create your very own Google Analytics clone and run it serverless and hopefully maintenance-free on Amazon.

  • Serverless DynamoDB Auto Scaling with CloudFormation

    July 19th, 2017 151 Words

    Since a few days, Amazon provides a native way to enable Auto Scaling for DynamoDB tables! Luckily the settings can be configured using CloudFormation templates, and so I wrote a plugin for serverless to easily configure Auto Scaling without having to write the whole CloudFormation configuration.

  • Process Serverless CloudFormation Stack Output

    July 1st, 2017 260 Words

    When you use a serverless environment for your service (and you should!), chances are high you might be using the Serverless framework and may end up in a situation like me with the need to process the AWS CloudFormation Stack Output after deploying the service.

  • Serverless Amazon SQS Worker with AWS Lambda

    April 1st, 2017 1071 Words

    Have you ever wondered how to process messages from SQS without maintaining infrastructure? Amazon Web Services perfectly support SNS as a trigger for AWS Lambda functions, but with SQS you have to find a custom solution. This tutorial will show an experimental setup using Serverless to read messages from an SQS queue and build auto-scaling worker processes.

  • Serverless Alexa skill for Amazon Echo with AWS Lambda

    March 30th, 2017 1667 Words

    If you read my first article about Amazon Alexa and AWS Lambda, you already know how to deploy a custom Alexa skill using Apex. With this article, you will learn how to use the Serverless framework to deploy a function to AWS Lambda and invoke it with your Amazon Echo using voice commands.