Skip to content

Installation

Install repopo with your package manager.

To run repopo in a repository, from scripts, Git hooks, or CI, install it as a dev dependency:

Terminal window
npm i -D repopo

With repopo installed, choose one repository convention to check. The walkthrough below uses a required license field.

Run these steps from the root of a Git repository that has a package.json. The commands use pnpm; if you installed with npm, use npx repopo instead of pnpm exec repopo.

Suppose each package.json must declare an MIT license. Create repopo.config.ts at the repository root:

repopo.config.ts
import { makePolicy, type RepopoConfig } from "repopo/api";
import { PackageJsonProperties } from "repopo/policies";
export default {
policies: [
makePolicy(PackageJsonProperties, {
config: { verbatim: { license: "MIT" } },
}),
],
} satisfies RepopoConfig;

If you already have a configuration, add this policy to its policies array instead of replacing the file.

This configuration enables only PackageJsonProperties. It checks each package.json in the Git file inventory, including tracked files and untracked files that Git does not ignore.

Terminal window
pnpm exec repopo check

If a package.json has no license field, or its value differs from "MIT", repopo reports Incorrect package.json field value for 'license'. The command exits with a non-zero status. If each matching file has the expected value, the check passes.

Review the violations before you apply fixes. This rule sets the license field to "MIT" in each matching file; use a value that reflects your project’s license.

Terminal window
pnpm exec repopo check --fix
pnpm exec repopo check

The fix adds or updates the license field and preserves the other package fields. Repopo reports the fixed findings. The second check passes with no violations if the files meet the rule.

After you install development dependencies in CI, run the same read-only command:

Terminal window
pnpm exec repopo check

A violation produces a non-zero exit status, so the CI job can fail the check without changing files. To add more rules or skip selected files, continue with Configuration. See CLI usage for checks on selected files and other commands.

To run policies from your own program with the programmatic API, or to publish policies for other repositories, install it as a regular dependency:

Terminal window
npm i repopo

You can also install repopo globally to use the repopo command in any repository:

Terminal window
npm install --global repopo
# or
pnpm add --global repopo

Each repository still needs its own repopo.config.ts, and that file must be able to import repopo.

The repopo check-native command uses a Rust binary, repopo-core. When you install repopo, a postinstall script downloads a prebuilt binary for Linux (x64, arm64), macOS (x64, arm64), or Windows (x64). If the download fails, installation still succeeds. Only check-native needs the binary; repopo check doesn’t.

  • Set REPOPO_SKIP_POSTINSTALL=1 to skip the download.
  • Point to your own build with --binary-path or the REPOPO_CORE_PATH environment variable.