toolchains

Toolchains

Generate a command line interface for local scripts.

Review Version Downloads Size Quality Coverage

Motivation

Often projects have local scripts:

scripts
  └── lint.ts

This package generates a command line interface for them:

toolchains <command>

Commands:
toolchains lint Run linters

Options:
-p, --path Set the search path [default: "scripts"]
-i, --include Set the include pattern [default: "*.ts"]
-d, --debug Enable debug logging [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

The scripts can be written in TypeScript:

export default {
name: "lint",
description: "Run linters",
action: () => {
console.log("Running linters...");
},
};

Then the command line interface can be invoked:

toolchains lint
Running linters...

Installing

npm install toolchains

Documentation

Documentation and more detailed examples are hosted on Github Pages.

Usage

You can use named exports for the name, description and action:

export const name = "example";

export const description = "Does nothing";

export const action = () => {
console.log("Running");
};

You can also default export a function on its own:

export default function () {
console.log("Running");
}

Options

  • --path - Set the search path
  • --include - Set the include pattern

Design

Transpilation

Unfortunately ts-node does not allow you to consume the parsed module contents and dynamic imports won't accept typescript syntax without transpilation first. To parse TypeScript files while respecting any tsconfig.json options tscw-config is used and the transpilation is performed in a temporary directory.

Limitations

Libraries imported from the scripts aren't resolved by the TypeScript compiler.

Tooling

Dependencies

To install dependencies:

yarn install

Tests

To run tests:

yarn test

Documentation

To generate the documentation locally:

yarn docs

Linters

To run linters:

yarn lint

Formatters

To run formatters:

yarn format

Contributing

Please read this repository's Code of Conduct which outlines our collaboration standards and the Changelog for details on breaking changes that have been made.

This repository adheres to semantic versioning standards. For more information on semantic versioning visit SemVer.

Bump2version is used to version and tag changes. For example:

bump2version patch

Contributors

Remarks

Lots of love to the open source community!

Be kind to your mind Love each other It's ok to have a bad day