Gauge · package quality
monorepo-gauge
Hygiene checks for npm, yarn and pnpm workspaces: circular internal deps, mismatched shared deps, version drift and missing fields.
npm i -D @mrlouiswright/monorepo-gaugePublished to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).
What it checks
- Workspace discovery
package.jsonworkspaces(array or{ packages }),pnpm-workspace.yamlandlerna.json, with*, `and!exclusions. The package manager is detected from the lockfile,.yarnrc.ymlandpackageManager`. - Internal graphcycles through
dependencies/peerDependencies/optionalDependencies(high) and throughdevDependencies(low), each reported once asa → b → c → a… - Shared dependency driftthe same external dependency with different majors (medium) or different ranges in the same major (low) across packages and the root, listing who uses what.
- Package fields, delegated to pkg-field-gaugeevery workspace runs through pkg-field-gauge's
checkPackage(entry points,exports, types,bin,files, licence, repository, description… workspace:protocolmixedworkspace:^/workspace:~/workspace:*/workspace:<range>styles are flagged (workspace-protocol-inconsistent, majority wins or setworkspaceProtocolStyle), andworkspace:under npm or yarn classic…- Version groups (syncpack-style)
versionGroupsassign dependencies × packages to a policy:pin(exactpinVersion),sameRange,bannedorignored. Unmatched dependencies use the default "highest range wins" drift check. --fixrewritespackage.jsonfiles in place (keeping indentation): internal ranges,workspace:protocol and style, fixed-mode versions, same-major range drift,pingroups andrepository.directory…- Outputtext, JSON, SARIF 2.1.0 and Markdown;
--fail-on; exit codes 0/1/2; allowlist entries with expiry dates.
Quick usage
CLI
npx monorepo-gauge # run at the monorepo root
npx monorepo-gauge --fail-on medium
npx monorepo-gauge --versioning fixed # all publishable packages share one version
npx monorepo-gauge --ignore-packages "playground-*,examples/**"
API
import { check, applyFixes, satisfies, findCycles } from 'monorepo-gauge';
const report = check('.', { versioning: 'fixed' });
check('.', { fix: true, fixDryRun: true }).fixed; // [{ rule, file, path, from, to }]
for (const p of report.info.packages) console.log(p.name, p.internalDeps);
satisfies('2.0.0', '^1.0.0'); // false
Every option is documented in the monorepo-gauge docs.
CI / GitHub Action
permissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
monorepo-gauge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with: { persist-credentials: false }
- uses: MrLouisWright/monorepo-gauge@v1
with:
fail-on: high
sarif: monorepo-gauge.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: monorepo-gauge.sarif }