# typescript-tooling

> This package helps keep TypeScript configuration and tooling synced up between seperate projects.

Latest version **4.1.0** (published 2018-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install typescript-tooling
pnpm add typescript-tooling
yarn add typescript-tooling
bun add typescript-tooling
```

Provides the command `tst`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2018-10-15 |
| First published | 2018-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 107.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | cruhl |
| Maintainers | cruhl |
| Keywords | typescript, tslint, prettier, tooling |

## Links

- npm: https://www.npmjs.com/package/typescript-tooling
- Repository: https://github.com/cruhl/typescript-tooling
- Homepage: https://github.com/cruhl/typescript-tooling#readme
- Issues: https://github.com/cruhl/typescript-tooling/issues
- npm.io page: https://npm.io/package/typescript-tooling

## Dependencies (6)

- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.2
- [caporal](https://npm.io/package/caporal.md) ^0.10.0
- [copy-dir](https://npm.io/package/copy-dir.md) ^0.4.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 4.1.0 (latest) — 2018-10-15
- 4.0.4-alpha.20 (canary) — 2018-10-15
- 4.0.4-alpha.19 — 2018-10-15
- 4.1.0-alpha.01ab903 — 2018-10-11
- 4.1.0-alpha.97e980c — 2018-10-03
- 4.0.3 — 2018-10-03
- 4.1.0-alpha.a505ec8 — 2018-10-03
- 4.1.0-alpha.fae767f — 2018-10-03
- 4.0.3-alpha.2 — 2018-08-29
- 4.0.3-alpha.1 — 2018-08-27
- 4.0.3-alpha.0 — 2018-08-27
- 4.0.2 — 2018-08-26
- 4.0.1 — 2018-08-26
- 4.0.0 — 2018-08-24
- 4.0.1-alpha.9 — 2018-08-24
- … 26 more at https://npm.io/package/typescript-tooling/versions

## README

# Typescript Tooling // `tst`

> A tool for creating and managing TypeScript projects with minimal configuration.

<p align="center">
  <image src="https://github.com/cruhl/typescript-tooling/blob/master/packages/typescript-tooling/images/logo.png" alt="Logo">
</p>

## Features

TypeScript Tooling...

- 🛠️ Provides reasonable defaults for [TypeScript](https://github.com/Microsoft/TypeScript), [TSLint](https://github.com/palantir/tslint), [Jest](https://github.com/facebook/jest), and [Nodemon](https://github.com/remy/nodemon)
- 🐉 Uses a monorepo project structure with help from [Lerna](https://github.com/lerna/lerna)
- 📦 Bundles packages into ready-to-use JavaScript with [Parcel](https://parceljs.org/)
- 🏗️ Installs and saves the `devDependencies` you need to get up and running
- 📝 Generates useful NPM scripts for your packages (`test`, `test:watch`, `dev`, and `build`)

## Getting Started

1. Install and save `tst`... _ignore warnings for missing `peerDependencies`_

```
npm install --save-dev typescript-tooling
```

2. Run the `init` command...

```
npx tst init
```

3. _**That's it!**_ Here's a few scripts you can use with the example package...

```
npm run example:test
```

```
npm run example:dev
```

```
npm run example:build
```

## Usage

```
npx tst help
```

![Usage](https://github.com/cruhl/typescript-tooling/blob/master/packages/typescript-tooling/images/usage.jpg)

## How does TST work?

Running `tst init` copies config files for various tools into a new `.tst`
directory in the root of your project. Under the hood, TST's CLI executes normal
commands which use those defaults. For example, `tst test <package-name>` runs
the command `npx jest packages/<package-name>` (which is also echo'ed out for
reference). This works since TST creates a `jest.config.js` at the root of your
project which extends `.tst/jest.config.js`. Settings and commands for other
tools operate the same way.

_Nothing special is happening here!_ TST is just a bunch of config files and
shortcuts for writing long CLI commands which can always be executed directly
without using TST. Since no magic is involved, it's easy to stop using this
tool, just move config files from `.tst` into the project root and add the
commands TST generates to the `scripts` section of your `package.json`. For
example...

```
// `package.json`

{
  "scripts": {
    "<package-name>:build": "tst build <package-name>"
  }
}
```

...would become...

```
// `package.json`

{
  "scripts": {
    "<package-name>:build": "parcel build packages/<package-name>/src/index.ts --out-dir packages/<package-name>/dist --target node"
  }
}
```

## What's in the defaults?

If you're interested in seeing TST's defaults for TypeScript, Lerna, Nodemon,
and Jest, check out the
[`configs` folder](https://github.com/cruhl/typescript-tooling/tree/master/packages/typescript-tooling/configs); these files are copied into `.tst` during a
`tst init`.

### Overriding TypeScript and TSLint Settings

TST creates or modifies `<tsconfig|tslint>.json` in your project root to extend
the defaults in the `.tst` directory...

```
// `<tsconfig|tslint>.json`

{
  // TST adds this line if it isn't already set
  "extends": "./.tst/<tsconfig|tslint>.json"
}
```

If you want to add or modify any settings, `<tsconfig|tslint>.json` behaves just
as you'd expect, just modify the file...

```
// `tslint.json`

{
  "extends": "./.tst/tslint.json",
  "rules": {
    // Allow `console.log`s across all packages
    "no-console": false
  }
}
```

It's easy to change settings for individual packages too. Imagine you want to
enable TypeScript's DOM library for a `ui` package, you would just need to
create `packages/ui/tsconfig.json`...

```
// `packages/ui/tsconfig.json`

{
  // Extend the base configuration in your project root
  "extends": "../../tsconfig.json",

  // Change the setting we're interested in...
  "compilerOptions": {
    "lib": ["es2018", "dom"]
  }
}
```

You can do the same thing for TSLint settings.

### Overriding Jest Settings

TST exports a Jest configuration object from `.tst/jest.config.js` which can be
modified and re-exported from your project's `jest.config.js`...

```js
// `jest.config.js`

module.exports = {
  ...require(".tst/jest.config.js"),

  verbose: true,
  bail: true
};
```

## Working with a Monorepo

TypeScript Tooling is built to be used with
[Lerna](https://github.com/lerna/lerna), which means it's easy to separate
code into multiple packages within the same project. Want to have independently
versioned/deployed `types`, `api`, and `ui` packages? No problem!

### Creating a New Package

1. First, make a new folder at `packages/<package-name>`
2. Create `packages/<package-name>/package.json` and make sure its `name` field
   matches `<package-name>`. For packages only used within your project, make
   sure to set `"private": true`. _Private packages only require the `name` and
   `private` fields._

3. TST looks for `packages/<package-name>/src/index.ts` as the entry point. You
   can generate NPM scripts (`test`, `test:watch`, `dev`, and `build`) by
   running...

```
npm run tst:scripts
```

...or...

```
npx tst scripts
```

### Delegating NPM Scripts to Packages

It's useful to keep all NPM scripts available from the project root so you
aren't constantly bouncing around with `cd`. However, an overly complicated set
of NPM scripts in one gigantic `package.json` isn't so great.

Luckily, [Lerna](https://github.com/lerna/lerna) allows you to execute NPM
Scripts from any package without leaving the project root. Let's say you want to
use [Parcel](https://parceljs.org/) to build deployable bundles for a `ui`
package; you could add the build script in `packages/ui/package.json`...

```json
// `packages/ui/package.json`

{
  "scripts": {
    "build": "parcel build public/index.html"
  }
}
```

To enable `npm run ui:build` from the root, we need to modify the NPM script in
the base `package.json`...

```
// `package.json`

{
  "scripts": {
    // Use Lerna to execute the NPM script defined in `packages/ui/package.json`
    "ui:build": "lerna run build --stream --scope ui"
  }
}
```

It's important to note `npx tst scripts` or `npm run tst:scripts` won't override
scripts you've defined.

## Notes

- Test files are expected to live next to the code they cover are named
  `<module-name>.spec.<ts|tsx>`, i.e. `Dog.ts` would be tested by `Dog.spec.ts`

- Run `npx tst init` after upgrading TST or cloning down a project with TST to
  ensure `.tst` is up-to-date

- You can upgrade dependencies TST relies on, but know that there is no
  guarentee everything will still work together (normally you can bump
  major TypeScript versions without problems)

## Disclaimer

_**This is my first usable open-source tool!**_ Any help making TST more
"professional" would be greatly appreciated. Please open an issue if you have
any comments, suggestions, or feedback...

## License

MIT

---
_Source: https://npm.io/package/typescript-tooling · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
