Creating a Plugin

Checkup plugins allow you to extend the core functionality with tasks of your own. Plugins encapsulate groups of tasks that can be run as part of Checkup's other health checks, complimenting the built-in tasks with ones that are tailored to your needs.

Creating a Plugin Using Generators

Checkup includes a few generators to make the process of creating Plugins and Tasks easier.

To generate a plugin, run the following in the directory you want to create the plugin in:

# generates the checkup-plugin-demo plugin directory and file structure
checkup generate plugin demo

By default, Checkup will name your plugin using a predictable format: checkup-plugin-*. This format will be familiar to you if you've created plugins in other tools, such as eslint, before.

  • if a directory in the format checkup-plugin- exists within the directory you execute Checkup in, the files will be generated in that directory

  • if a directory does not exist, Checkup will create that directory and generate the files within it

By default, the following structure is created:

checkup-plugin-demo
├── README.md
├── __tests__
├── jest.config.js
├── package.json
├── src
│ ├── hooks
│ │ └── register-tasks.ts
│ ├── index.ts
│ ├── tasks
│ └── types
│ └── index.ts
└── tsconfig.json

Developing your Plugin

The generated plugin will include the following package scripts:

To build:

yarn build

To lint:

yarn lint

To test:

yarn test

Configuring Your Plugin to Run in Checkup

In order to use your plugin in the Checkup CLI, you need to configure it in the target project you want to run checkup in. You project needs to have a .checkuprc file in its root - one can be generated by running checkup generate config.

Once the target project has a configuration file, you can configure your plugin by adding the plugin name to the plugins array.

Using our checkup-plugin-demo plugin above, you can configuring it either by using the fully qualified name (the name with checkup-plugin- preceding it), or the short name (the name without a preceding checkup-plugin-):

{
"plugins": ["checkup-plugin-demo"],
"tasks": {}
}

or

{
"plugins": ["demo"],
"tasks": {}
}

When run, Checkup will find and load your plugin's tasks, and they'll be executed with the built-in tasks.