1.1.8 • Published 6 years ago

@tradie/node-package-scripts v1.1.8

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

@tradie/node-package-scripts

An opinionated set of scripts for creating and maintaining node packages.

Feel like you spend more time setting up and updating the tools to build, test and maintain your project? @tradie/node-package-scripts lets you focus on writing code and spend less time setting up and updating the tools to build, test and maintain your project. It provides you with a way to keep tooling consistent across multiple packages with minimal effort.

Usage

Create a new folder for your project:

mkdir my-package && cd my-package

Create the files for your project:

npx --package @tradie/node-package-scripts tradie create

Files

  coverage/
  examples/
  lib/
  src/
  test/
  .flowconfig
  .gitignore
  package.json

coverage/

This folder contains the coverage report generated by tradie test --coverage. This folder should be added to your .gitignore file. This folder is removed by tradie clean.

examples/

This folder contains scripts that demonstrate the functionality of your package. These scripts can be run using the tradie example <module> command.

lib/

This folder contains the transpiled sources generated by tradie build. This folder should be added to your .gitignore file. This folder is removed by tradie clean.

src/

This folder contains the source code and the unit tests for your package.

test/

This folder contains other tests e.g. integration etc

.flowconfig

This file contains your config for flowtype. Typings are optional.

.gitignore

This file excludes files from your version control system. It should at least exclude the generated files and folders. For example:

lib
coverage
node_modules

package.json

This is your package manifest. You should specify your package's main script and which files will should be included in the package.

{
  "main": "lib/index.js",
  "files": ["lib", ".flowconfig"]
}

Commands

tradie clean

Remove generated files and folders.

tradie clean

tradie lint

Lint sources, tests and examples.

tradie lint [--watch]

This command doesn't enforce any stylistic rules. Use prettier instead.

tradie build

Transpile sources and export their types.

tradie build [--watch]

tradie test

Run tests.

tradie test [--watch] [--coverage]

tradie example

Run examples.

tradie example [module]

FAQ*

*Questions that I think will be frequently asked.

Can I use the latest language features?

Yes. The following Babel presets and plugins are configured:

  • babel-preset-env
  • babel-plugin-transform-class-properties
  • babel-plugin-transform-object-rest-spread
  • babel-plugin-transform-dynamic-import-node

What versions of node will my package support?

By default your sources will be transpiled to support Node >=4. You can change the target Node version by using the engines key in your package.json. For example:

{
  "engines": {
    "node": "v8"
  }
}

Can I use types?

Yes! Create a .flowconfig and add // @flow comments to the top of your files. Type information will be exported to ./lib.

You should ignore the ./lib directory. For example:

.flowconfig:

[ignore]
<PROJECT_ROOT>/lib