identify-monorepo-root
v1.1.0
Published
Find the root directory of a monorepo from anywhere inside it.
Downloads
3,295
Maintainers
Readme
identify-monorepo-root 🌱
Find the root directory of a monorepo from anywhere inside it.
The package works as a small CLI and as a library. It detects common monorepo root markers such as package-lock.json, yarn.lock, pnpm-lock.yaml, workspaces, and packageManager.
Installation
npm install identify-monorepo-rootYou can also run it without a global install:
npx identify-monorepo-rootCLI usage
Run the command from any nested directory inside the repository:
identify-monorepo-rootThe CLI prints the detected root path and exits with status code 1 when no root can be identified.
Library usage
import { identifyMonorepoRoot } from "identify-monorepo-root";
const monorepoRoot = identifyMonorepoRoot();You may also pass a starting directory explicitly:
const monorepoRoot = identifyMonorepoRoot("/path/inside/repository");Development
This repository uses npm, not Yarn or pnpm.
Useful commands:
npm test
npm run build
npm run verifyCommits are expected to use conventional commit messages. Local raw git commit is blocked by Husky on purpose; use the interactive helper instead:
npm run commitThat helper is intentionally a small local script instead of commitizen to avoid extra transitive maintenance and vulnerability surface.
Release workflow
Releases are automated with semantic-release in GitHub Actions.
- CI runs
npm ciandnpm run verify. - Releases run on pushes to
mainormaster, plus manual workflow dispatch. - The workflow is designed for protected branches and does not rely on pushing version or changelog commits back to git.
- Git tags, npm releases, and GitHub Releases are the release source of truth.
- Because of that, the
package.jsonversion committed onmaincan lag behind the latest published version. - The release workflow is set up for npm Trusted Publishing via GitHub Actions OIDC. No long-lived
NPM_TOKENshould be required once the npm package is configured for trusted publishing.
You can preview the release process locally with:
npm run release:dry-run