# task-graph-protocol

> A task graph runner and a protocol for task runner communication that enables very efficient watch pipelines.

Latest version **1.1.1** (published 2022-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install task-graph-protocol
pnpm add task-graph-protocol
yarn add task-graph-protocol
bun add task-graph-protocol
```

Provides the commands `tgp`, `tgp-tsc`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-12-15 |
| First published | 2022-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 13 |
| Unpacked size | 15.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Patrik Stutz |
| Maintainers | patrik.stutz |

## Links

- npm: https://www.npmjs.com/package/task-graph-protocol
- npm.io page: https://npm.io/package/task-graph-protocol

## Dependencies (13)

- [zod](https://npm.io/package/zod.md) ^3.19.1
- [jest](https://npm.io/package/jest.md) ^29.3.1
- [cmd-ts](https://npm.io/package/cmd-ts.md) ^0.11.0
- [remeda](https://npm.io/package/remeda.md) ^1.3.0
- [split2](https://npm.io/package/split2.md) ^4.1.0
- [ts-node](https://npm.io/package/ts-node.md) ^10.9.1
- [testtriple](https://npm.io/package/testtriple.md) ^2.2.3
- [typescript](https://npm.io/package/typescript.md) ^4.9.4
- [@types/jest](https://npm.io/package/@types/jest.md) ^29.2.4
- [@types/node](https://npm.io/package/@types/node.md) ^18.11.13
- [@types/split2](https://npm.io/package/@types/split2.md) ^3.2.1
- [typed-signals](https://npm.io/package/typed-signals.md) ^2.5.0
- [jest-light-runner](https://npm.io/package/jest-light-runner.md) ^0.4.1

## Recent versions

- 1.1.1 (latest) — 2022-12-15
- 1.0.1 — 2022-12-13
- 1.0.0 — 2022-12-13

## README

# task-graph-protocol

A task graph runner and a protocol for task <-> runner communication that enables very efficient watch pipelines.

## taskfiles

Your tasks are declared in so-called "taskfiles". A taskfile can contain multiple tasks and you can also have as many taskfiles as you wish.
Tasks can depend on tasks from other taskfiles.

Example:

```json
// frontend/taskfile.json
{
  "build": {
    "command": "tsc",
    "dependencies": [{ "path": "../lib", "name": "build" }]
  }
}

// backend/taskfile.json
{
  "build": {
    "command": "tsc",
    "dependencies": [{ "path": "../lib", "name": "build" }]
  }
}

// lib/taskfile.json
{
  "build": {
    "command": "tsc"
  }
}
```

Running `tgp build:frontend build:backend` will then first build the project `lib` and then the projects `frontend` and `backend` in parallel.
If the task `build` of `lib` fails, then it won't attempt building `frontend` or `backend`.

## protocol

The main goal of this project is coordinating multiple watch processes. These are processes that don't exit after a build, but instead continue to rebuild as soon as file-changes are detected. The problem with such processes is that they cannot coordinate themselves with each other. So if both `lib` and `app` detect filechanges at the same time, both processes will immediately start re-building. This is a problem, because re-building `app` only makes sense _after_ `lib` is built successfully.

So what I came up with to solve this problem is a protocol for such processes to communicate with the task coordinator or task runner.
With this protocol, a watch process can notify the runner abount changes, and the runner can notify the process when it's time to re-start the task. Additionally, the task can tell the runner if it was successful or not.

For this all to work, watch-processes of course have to implement this protocol. But don't worry, this library provides some helpers to make this very easy.

## license

MIT

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