Node.js Starter Project for Advent of Code
Tags: adventofcode, node, javascript, typescript
Published: 2020-11-24 01:09:05

## Hello!

It's getting to be that time of year when the annual [Advent of Code](https://adventofcode.com) kicks off. I've taken a swing at it the last couple of years but always fell off after a few days. One of the biggest reasons was having to setup a new 'project' every day. Having to take the time to copy things over and tweak the config was often _just_ enough to keep me from keeping on.

## Solution

So this year I've put together a [package](https://github.com/thedavefulton/create-node-cli) to install a starter project with minimal effort and I've made it available to everyone through [NPM](https://www.npmjs.com/package/@thedavefulton/create-node-cli). Now I'm not going to claim that this is the _best_ in the world. In fact it's still a _bit_ rough.

BUT.

I'll be [dogfooding](https://en.wikipedia.org/wiki/Eating_your_own_dog_food) it for the rest of the month while I work through some of the previous years puzzles. Anything I find that makes getting up and running with the least possible effort will be added to the package.

I'm also hoping that some folks may find it useful enough to make some suggestions to improve it 🙏

## Usage

The [README.md](https://github.com/thedavefulton/create-node-cli/blob/main/README.md) should give a pretty clear idea of how to use the package. Of special note: I've made sure you can run it using the `npx` command. For those who might not be familiar, `npx` allows you to run an `npm` command without actually installing it. It's pretty slick 🙌

For example, you can just run
```
npx @thedavefulton/create-node-cli
```
and the package will work it's magic without any extra work on your part. It really is one of my favorite things about the Node ecosystem!

Sorry to gush 😊

I've also added a flag for all of the options so that you can setup an alias in your terminal's configuration. So rather than typing it all out every day or going through the wizard, you could just setup something like
```
alias newcli='npx @thedavefulton/create-node-cli ts --name "Dave Fulton" --project '
```
and then everyday you just type
```
newcli my-new-project-name
```
and you're off 🚀

## Features

So you're still not convinced that this is the _one thing_ that could make 2020 not a _complete_ dumpster fire?

Well, you're probably right 😢

But there are a few other things that I think make this pretty useful. I've included a few packages that will make your life a little easier and hopefully help you focus on solving the various daily challenges.

There's [Lodash](https://lodash.com/docs/4.17.15), a really great utility library. I know some of you may frown on it, and there is certainly a lot more that can be done in vanilla JavaScript now. But _I_ still find a bunch of their functions to be helpful ¯\_(ツ)_/¯

I've also included a basic testing setup using [Jest](https://jestjs.io/docs/en/using-matchers). I really like having this around for AoC. They usually offer a bunch of examples for their problems and writing a couple of simple unit tests using their data can really clarify my thinking 🤔

[Prettier](https://prettier.io/docs/en/index.html) is there because I like to not worry about how my code is formatted and styled and whatnot

[Chalk](https://github.com/chalk/chalk/blob/master/readme.md) is there because I like to worry about how my output is formatted and styled and whatnot.

I'm also keeping an eye on adding utility functions when they seem appropriate. For instance, there's a function now that will read a file and give you back an array of lines. Nothing fancy, but I hate having to write that stuff over and over.

## In Closing

I'm really excited to get started on the Advent of Code this year. If you are too and you're planning to use JavaScript or TypeScript I hope you'll consider checking out my project. If you're newish (or lazyish 😈) I think you'll find it can really take out a lot of the boilerplate busywork and let you focus on the challenges you _actually_ care about 🏋️

I'd also love you hear your [thoughts](https://github.com/thedavefulton/create-node-cli/issues) and [suggestions](https://github.com/thedavefulton/create-node-cli/pulls) for improving it! I'm sure there are a bunch of things I haven't thought of that could make your life easier. But more importantly: they could also make _my_ life easier 😃

Be well 🖖