Creating a Task

The Task is the core primitive in Checkup that allows you to execute arbitrary queries against a project. Tasks have a very basic structure, and are intended to be authored inside Plugins.

Creating a Task using Generators

Similar to Plugins, you can use Checkup's generators to create Tasks.

To generate a Task, run the following in a Checkup plugin root directory:

# generates the demo-task.ts, demo-task-result.ts, and demo-task-test.ts files
checkup generate task demo
# create src/tasks/demo-task.ts
# create __tests__/demo-task-test.ts
# conflict src/hooks/register-tasks.ts
#? Overwrite src/hooks/register-tasks.ts? overwrite
# force src/hooks/register-tasks.ts

Checkup will generate the correct files for you, and place them in the correct directories;

├── __tests__
│ └── demo-task-test.ts
├── jest.config.js
├── package.json
├── src
│ ├── hooks
│ │ └── register-tasks.ts
│ ├── index.ts
│ ├── tasks
│ │ └── demo-task.ts
│ └── types
│ └── index.ts
└── tsconfig.json

Writing your Task

Tasks are written by implementing the run method in the Task class. Tasks perform operations that gather data and return JSON in one of the predefined formats.

For examples, refer to some of the built-in tasks to see how they're implemented.