mediamonks / seng-boilerplate

Boilerplate and example project for all Seng libraries
MIT License
7 stars 3 forks source link
boilerplate npm-package seng

seng-boilerplate

Add a description here...

Travis Code Climate Coveralls npm npm

Installation

yarn add seng-boilerplate
npm i -S seng-boilerplate

Basic Usage

import SengBoilerplate from 'seng-boilerplate';
// import SengBoilerplate from 'seng-boilerplate/lib/classname';

// do something with SengBoilerplate

Documentation

View the generated documentation.

Building

In order to build seng-boilerplate, ensure that you have Git and Node.js installed.

Clone a copy of the repo:

git clone https://github.com/mediamonks/seng-boilerplate.git

Change to the seng-boilerplate directory:

cd seng-boilerplate

Install dev dependencies:

yarn

Use one of the following main scripts:

yarn build            # build this project
yarn dev              # run compilers in watch mode, both for babel and typescript
yarn test             # run the unit tests incl coverage
yarn test:dev         # run the unit tests in watch mode
yarn lint             # run eslint and tslint on this project
yarn doc              # generate typedoc documentation

When installing this module, it adds a pre-commit hook, that runs lint and prettier commands before committing, so you can be sure that everything checks out.

Contribute

View CONTRIBUTING.md

Changelog

View CHANGELOG.md

Authors

View AUTHORS.md

LICENSE

MIT © MediaMonks

About this boilerplate

Remove this section when cloning this boilerplate to a real project!

Folders

This boilerplate contains the following folders:

Files

This boilerplate contains the following files:

Travis

This project uses Travis to build, test and publish its code to npm. Travis is free for public Github repositories.

It runs on all commits, shows the build status for pull requests, and publishes to npm when a new tag/release is created.

Travis only runs the npm test script, so have configured that script to run everything we want Travis to check. Besides the unit tests, we also run our validations and linters.

The travis configuration is placed in a .travis.yml file, consisting of multiple sections.

  1. Defines the node_js language, and tells travis on which node versions to run the process.
  2. Before running, it needs to install some global dependencies, and when it processes some coverage results.
  3. It can do a npm deploy, telling it to keep the generated artifacts and only publish when run on node 8 and when a tag was committed. It also contains the email address and api key of the npm user.
  4. Code Climate has a travis plugin that automatically uploads the code coverage results.

Because we want to keep the npm api key secret, we add the token to the Travis Repo settings where it will be stored secure: https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings

Before we can do this, we must make sure that the repository is added to Travis, because Travis needs the repository owner/name info to make sure the encrypted values only work for that repository.

  1. Then make sure you are logged in to your npm account with the adduser command:

    $ npm adduser

    To verify that you are logged in correctly you can check:

    $ npm whoami
  2. Now we need to create a new token:

    npm token create

    Copy the token value from the output to the Travis Environment Variable settings, and add it with the name NPM_TOKEN.