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.
Prerequisites
Section titled “Prerequisites”The CLI is built with Node.js and npm. You need:
- Node.js (see the
.nvmrcfor the exact version to use) - pnpm (the project uses pnpm which produces a
pnpm-lock.yaml)
Development commands
Section titled “Development commands”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) |
CLI commands
Section titled “CLI commands”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 |
Testing and code coverage
Section titled “Testing and code coverage”Run tests
Section titled “Run tests”This project uses Vitest for testing. To run the suite:
pnpm testThis 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
Section titled “Test configuration”Test configuration lives in vitest.config.ts.
Coverage thresholds
Section titled “Coverage thresholds”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.
Coverage reports
Section titled “Coverage reports”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.
Codecov
Section titled “Codecov”The project uses Codecov to track coverage over time and on pull requests.
CI integration
Section titled “CI integration”- The workflow
.github/workflows/ci.ymlruns tests with coverage and uploadscoverage/lcov.infousing the Codecov action. - Coverage will appear in PR comments.
Configuration
Section titled “Configuration”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
Local usage
Section titled “Local usage”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.
Static Checks
Section titled “Static Checks”The project has several forms of static analysis.
Format
Section titled “Format”We use Oxfmt for formatting.
Use the format script to reformat.
pnpm formatWe use ESLint as our primary linter. You can check for violations with:
pnpm lintTo automatically address what ESLint can fix for you, run:
pnpm lint --fixThis 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).
Pre-commit hooks
Section titled “Pre-commit hooks”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-hooksin thepackage.json. lint-stagedis configured inpackage.jsonunder thelint-stagedfield.- 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 arelease pull request after commits land on `main`. That pull requestkeeps a changelog and the next version, based on[semantic versioning](https://semver.org/).
Release Please needs a GitHub token to open pull requests. Thisrepository 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 andchooses the next version bump. That work stays in the release pullrequest 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 aprovenance statement.
The publish job uses the GitHub environment `npm-publish`, so amaintainer can approve before the package goes out.