Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

spence-s/spence-s-starter-template

Repository files navigation

spence-s-starter-template

Node.js CI

A bleeding edge, prod ready starter template for creating and publishing Node.js libraries to npm.

Features Include:

Getting starting

Installation

This is a github template and is best used by using the github UI to start a new project.

Once you've cloned the template for a new repository, the first thing you want to do is to make sure all the deps are up to date!

  1. Run npm install to get the immediately needed deps
  2. run npm run update to have npm-check-updates run an interactive program to update all the other deps.
  3. run npm run test to ensure updates haven't broken anything themselves (this typically shouldn't happen).

Run the hello world

This starter-template is already set up to run typescript code out of the box node native type stripping and node native watch mode.

npm run dev

Building the project

npm run build will build the project to the dist directory (which is already gitignored).

Developing

npm run dev will build the project with tsc --watch execute the script with the new nodejs watch flag.

Testing

npm run test run the tests once with node native type stripping. npm run test:coverage run the tests once with native type stripping node experimental test coverage flags. npm run test:watch run the tests in native watch mode with native type stripping.

Updating dependencies

npm run update will use ncu -i to update all dependencies to their latest versions, interactively

Releasing

To encourage best practices for publishing an open source package on npm, np is installed by default.

npm run release

Scripts

{
  "scripts": {
    "build": "rimraf dist && tsc -p tsconfig.build.json",
    "check": "tsc -p tsconfig.json",
    "dev": "node --watch src/index.ts",
    "lint": "npm run check && xo",
    "prepare": "husky",
    "release": "np",
    "start": "node dist/src/index.js",
    "test": "npm run lint && node --test",
    "test:coverage": "node --test --experimental-test-coverage",
    "test:watch": "node --test --watch",
    "update": "ncu -i"
  }
}

build: Builds the project into a dist directory for releasing to npm as js files complete with type defintions and source maps. check: Check the types without building the project. dev: Run the program in watch mode. lint: Run the linter and type checker. prepare: Run the husky prepare script so husky is installed with deps. release: Use np to release the package to npm. start: Run the build js files from the build script. test: Run tests with node native test runner. test:watch: Run tests in watch mode. update: Update deps interactively to their latest versions.

TypeScript

The tsconfig included in this template is set up for Node.JS native type stripping and includes the erasableSyntaxOnly option, so not all TypeScript features are supported.This decision was made to encourage adoption of cutting edge Node.JS features which improve DX. We continue to maintain a build and release option for packaging only JavaScript files, as node native type stripping will not strip imports from node_modules folders.

Learn More:

About

An opinionated ESM + typescript starter template for new node.js project.

Resources

License

Stars

Watchers

Forks

Packages

No packages published