@darkobits/ts-unified
TypeScript boilerplate.
Last updated a month ago by darkobits .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @darkobits/ts-unified 
SYNC missed versions from official npm registry.

Boilerplate-as-a-package for TypeScript-based projects. To create a new repository based on ts-unified, check out the ts-unified template repository.

Features

  • Compilation with Babel.
  • Type-checking and declaration generation with TypeScript.
  • Unit testing with Jest.
  • Linting with ESLint.
  • Version and change log management with standard-version.
  • Package script management with NPS.

Usage

npm install --save-dev @darkobits/ts-unified

This repository provides most of the build and code quality tooling needed for modern TypeScript-based projects. It also provides several common package scripts for building, testing, and versioning a project. These scripts are provided via NPS. For more information, see the NPS section below.

Configuration Files

This section will walk you through setting up the configuration files required by the various tools that ts-unified provides support for. Each base configuration file is provided as a function that accepts an optional additional configuration object that will be merged with the default configuration, allowing projects to extend or modify the base configuration.

NPS

In your project root, create package-scripts.js. Then, export the NPS configuration from ts-unified, optionally providing your own configuration/scripts to merge with the defaults.

???? PROTIP: NPS does not provide a native extends feature, so configuration merging is achieved by passing an object containing your configuration to the function exported by package-scripts. If you do not need to provide any additional configuration, you still need to invoke this function to ensure the correct object is exported by your configuration file.

package-scripts.js

Using base configuration:

module.exports = require('@darkobits/ts-unified/dist/config/package-scripts')();

Providing additional configuration:

module.exports = require('@darkobits/ts-unified/dist/config/package-scripts')({
  scripts: {
    foo: {
      description: 'My awesome script.',
      script: 'foo --bar --baz'
    }
  }
});

Once you have created this file, you can get a list of all NPS scripts provided via ts-unified by running the following command:

npx nps --scripts

Jest

In your project root, create jest.config.js. Then, export the Jest configuration from ts-unified, optionally providing your own configuration to merge with the default.

???? PROTIP: Jest does not provide a native extends feature, so configuration merging is achieved by passing an object containing your configuration to the function exported by jest. If you do not need to provide any additional configuration, you still need to invoke this function to ensure the correct object is exported by your configuration file.

jest.config.js

Using base configuration:

module.exports = require('@darkobits/ts-unified/dist/config/jest')();

Providing additional configuration:

module.exports = require('@darkobits/ts-unified/dist/config/jest')({
  collectCoverageFrom: [
    '<rootDir>/my-custom-path'
  ]
});

TypeScript

In your project root, create tsconfig.json. Then, extend the TypeScript configuration from ts-unified, optionally providing your own configuration. It is recommended that you at least set baseUrl, outDir, and paths; these cannot be set by ts-unified because TypeScript computes them relative to the tsconfig.json file from which they were declared.

tsconfig.json

Using base configuration:

{
  "extends": "./node_modules/@darkobits/ts-unified/dist/config/tsconfig.json",
  // You should specify at least the following configuration options, as
  // TypeScript resolves these directories relative to the tsconfig.json file
  // where they were defined.
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "dist",
    "paths": {
      "*": ["*", "src/*"]
    }
  }
}

ESLint

In your project root, create .eslintrc.js. Then, extend the ESLint configuration from ts-unified, optionally providing your own additional configuration.

.eslintrc.js

module.exports = {
 extends: [
    require.resolve('@darkobits/ts-unified/dist/config/eslint')
  ]
}

React Rules

If you're working in a React project, ts-unified provides a React variant of its ESLint rules. To use these rules, extend eslint-react:

.eslintrc.js

module.exports = {
 extends: [
    require.resolve('@darkobits/ts-unified/dist/config/eslint-react')
  ]
}

Running Scripts

For a list of all scripts provided by ts-unified, make sure you have created a package-scripts.js file in your project root per the instructions above. Then, you may run:

npx nps --scripts

Building

To build your project, assuming its source is located at src and build artifacts are to be written to dist, you may run:

npx nps build

or add the following to your package.json:

"scripts": {
  "build": "nps build"
}

and run:

npm run build

To continuously build the project in watch mode:

npx nps build.watch

or:

"scripts": {
  "build:watch": "nps build.watch"
}
npm run build:watch

Testing

To run unit tests for your project, assuming your test files end in .spec.ts, you may run:

npx nps test

or, add the following to your package.json:

"scripts": {
  "test": "nps test"
}

and run:

npm test

To continuously run tests in watch mode:

npx nps test.watch

or:

"scripts": {
  "test:watch": "nps test.watch"
}
npm run build:watch

To run unit tests and generate a coverage report:

npx nps test.coverage

or:

"scripts": {
  "test:coverage": "nps test.coverage"
}
npm run test:coverage

Versioning

To generate (or update) a CHANGELOG.md and bump the project's version, assuming you use Conventional Commits, you may run:

npx nps bump

or, add the following to your package.json:

"scripts": {
  "bump": "nps bump"
}

and run:

npm run bump

Alternatively, if you need to create a beta tag:

npx nps bump.beta

or:

"scripts": {
  "bump:beta": "nps bump.beta"
}
npm run bump:beta

NPM Life Cycles

ts-unified also provides a prepare script that will build and test the project. If you wish to use this script, add a prepare script to your project's package.json:

"scripts": {
  "prepare": "nps prepare"
}

This script will then be run after every npm install and as part of every npm publish command.

Current Tags

  • 5.0.0-beta.22                                ...           beta (3 months ago)
  • 5.2.1                                ...           latest (a month ago)

68 Versions

  • 5.2.1                                ...           a month ago
  • 5.2.0                                ...           2 months ago
  • 5.1.4                                ...           3 months ago
  • 5.1.3                                ...           3 months ago
  • 5.1.2                                ...           3 months ago
  • 5.1.1                                ...           3 months ago
  • 5.1.0                                ...           3 months ago
  • 5.0.0                                ...           3 months ago
  • 5.0.0-beta.22                                ...           3 months ago
  • 5.0.0-beta.21                                ...           3 months ago
  • 5.0.0-beta.20                                ...           3 months ago
  • 5.0.0-beta.19                                ...           3 months ago
  • 5.0.0-beta.18                                ...           4 months ago
  • 5.0.0-beta.17                                ...           4 months ago
  • 5.0.0-beta.16                                ...           4 months ago
  • 5.0.0-beta.15                                ...           4 months ago
  • 5.0.0-beta.14                                ...           4 months ago
  • 5.0.0-beta.13                                ...           4 months ago
  • 5.0.0-beta.12                                ...           4 months ago
  • 5.0.0-beta.11                                ...           4 months ago
  • 5.0.0-beta.10                                ...           4 months ago
  • 5.0.0-beta.9                                ...           4 months ago
  • 5.0.0-beta.8                                ...           4 months ago
  • 5.0.0-beta.7                                ...           4 months ago
  • 5.0.0-beta.6                                ...           4 months ago
  • 5.0.0-beta.5                                ...           4 months ago
  • 5.0.0-beta.4                                ...           4 months ago
  • 5.0.0-beta.3                                ...           4 months ago
  • 5.0.0-beta.2                                ...           5 months ago
  • 5.0.0-beta.1                                ...           5 months ago
  • 5.0.0-beta.0                                ...           5 months ago
  • 4.0.0                                ...           5 months ago
  • 4.0.0-beta.2                                ...           8 months ago
  • 4.0.0-beta.1                                ...           8 months ago
  • 4.0.0-beta.0                                ...           8 months ago
  • 3.3.0                                ...           9 months ago
  • 3.2.4                                ...           10 months ago
  • 3.3.0-beta.0                                ...           10 months ago
  • 3.2.3                                ...           a year ago
  • 3.2.2                                ...           a year ago
  • 3.2.1                                ...           a year ago
  • 3.2.0                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.6                                ...           a year ago
  • 3.0.5                                ...           a year ago
  • 3.0.4                                ...           a year ago
  • 3.0.3                                ...           a year ago
  • 3.0.2                                ...           a year ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.1.5                                ...           a year ago
  • 2.1.4                                ...           a year ago
  • 2.1.3                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.6.0                                ...           a year ago
  • 1.5.0                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.1                                ...           2 years ago
  • 1.1.5                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 72
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |