Skip to content

Maintaining the CLI

This page describes how to set up, test and release the All Contributors CLI. Maintainers use it to publish new versions, and contributors can follow the same workflows when they fix a bug in the code. If you only want to use the CLI in your own project, start with Install the CLI and the quick start instead.

The CLI is built with Node.js and npm. You need:

  • Node.js (see the .nvmrc for the exact version to use)
  • pnpm (the project uses pnpm which produces a pnpm-lock.yaml)

These are the npm scripts in package.json:

Command Description
pnpm install Install dependencies
pnpm build Build the CLI (output in dist/)
pnpm dev Run the CLI from source without building
pnpm start Run the built CLI (dist/cli.js)
pnpm format Fix format issues
pnpm lint Check for lint issues
pnpm lint --fix Fix lint issues
pnpm test Run the test suite (no coverage)
pnpm test:coverage Run tests with coverage and generate reports
pnpm commit Commit changes using a commitizen-compatible interface
pnpm knip Find unused files, dependencies, and exports
pnpm add-contributor Add a contributor (runs kcd-scripts contributors add)

After you install dependencies, or when you use pnpm dev, these subcommands are available:

Command What it does
all-contributors init Prepare a project to use the CLI
all-contributors add Add or update a contributor
all-contributors check Compare commits with .all-contributorsrc
all-contributors generate Regenerate the contributor list

This project uses Vitest for testing. To run the suite:

Terminal window
pnpm test

This runs all tests without coverage. For coverage (thresholds and reports), use pnpm test:coverage (see below).

If you use VS Code, the Vitest extension will discover those tests and allow you to run them from the IDE.

Test configuration lives in vitest.config.ts.

The Vitest config requires this minimum coverage:

Coverage type Percentage
Branches 50%
Functions 40%
Lines 50%
Statements 50%

If a pull request drops coverage below these thresholds, the coverage run in continuous integration fails.

Run pnpm test:coverage to generate coverage reports in the coverage/ directory:

  • coverage/lcov-report/index.html — Interactive HTML report (open in a browser)
  • coverage/lcov.info — LCOV format (used by Codecov)

The HTML report shows which files the tests cover.

The project uses Codecov to track coverage over time and on pull requests.

  • The workflow .github/workflows/ci.yml runs tests with coverage and uploads coverage/lcov.info using the Codecov action.
  • Coverage will appear in PR comments.

Codecov is configured in .codecov.yml:

  • Patch coverage is tracked (coverage of changed code in PRs)
  • Project-level status checks are disabled
  • PR comments are disabled

You don’t need a Codecov account to view coverage locally. Run pnpm test:coverage and open the HTML report. Codecov is mainly for tracking trends and enforcement in CI.

The project has several forms of static analysis.

We use Oxfmt for formatting. Use the format script to reformat.

Terminal window
pnpm format

We use ESLint as our primary linter. You can check for violations with:

Terminal window
pnpm lint

To automatically address what ESLint can fix for you, run:

Terminal window
pnpm lint --fix

This will fix many issues (e.g. Vitest aliases, unused eslint-disable directives). Some problems still need manual fixes (e.g. unused variables, tests without assertions).

simple-git-hooks runs a pre-commit hook that reformats staged files before each commit.

On git commit, simple-git-hooks runs the pre-commit hook. The hook runs lint-staged, which runs Oxfmt on all staged files.

Configuration:

  • The hook is configured on simple-git-hooks in the package.json.
  • lint-staged is configured in package.json under the lint-staged field.
  • Linting uses eslint.config.ts.

You can build the package by running:

Output goes to `dist/`. To run the built CLI locally without publishing, use
`pnpm start` (runs `dist/cli.js`) or `pnpm link` from the repo root and then run
`all-contributors` in another directory.
## Release process
Merged pull requests use
[conventional commits](https://www.conventionalcommits.org/).
[Release Please](https://github.com/googleapis/release-please) opens a
release pull request after commits land on `main`. That pull request
keeps a changelog and the next version, based on
[semantic versioning](https://semver.org/).
Release Please needs a GitHub token to open pull requests. This
repository uses the secret `CLI_RELEASE_PLEASE_TOKEN`. The workflow is
`.github/workflows/release-please.yml`.
### Create a release
When a pull request is merged, Release Please updates the changelog and
chooses the next version bump. That work stays in the release pull
request until a maintainer merges it.
When the release pull request is merged:
- The version in `package.json` is updated on `main`
- A Git tag and GitHub release are created, formatted as `vX.X.X`
### Publish to npm
After a GitHub release is published, the package is published to npm with
[trusted publishing](https://docs.npmjs.com/trusted-publishers) and a
provenance statement.
The publish job uses the GitHub environment `npm-publish`, so a
maintainer can approve before the package goes out.