@hyperfrontend/project-scope/tech/monorepomonorepo
Monorepo-tool detectors for the workspace orchestration tools used in JavaScript/TypeScript repos.
Covers Nx, Turborepo, Lerna, Rush, and the native workspace declarations from npm, Yarn, and pnpm. Each <tool>Detector follows the shared MonorepoDetector contract and reports a MonorepoDetection with confidence, evidence, and the DetectionSource (config file vs package.json field). detectMonorepoTools runs the full set against a project root and returns the aggregate.
API Reference
ƒ Functions
Detect all monorepo tools in project.
Parameters
Returns
MonorepoDetection[]Array of detected monorepo tools, sorted by confidence
Example
Detecting monorepo tools
const detections = detectMonorepoTools('/path/to/project')
// => [
// { id: 'nx', name: 'NX', confidence: 90, configPath: 'nx.json', detectedFrom: [...] },
// { id: 'npm-workspaces', name: 'npm Workspaces', confidence: 80, ... }
// ]Detect Lerna in project.
Parameters
Returns
MonorepoDetectionDetection result or null if not detected
Example
Detecting Lerna monorepo
// Project with lerna.json config file
const result = lernaDetector('/path/to/lerna-project')
// => {
// id: 'lerna',
// name: 'Lerna',
// confidence: 80,
// configPath: 'lerna.json',
// detectedFrom: [{ type: 'config-file', path: 'lerna.json' }]
// }Detect npm workspaces in project.
Parameters
Returns
MonorepoDetectionDetection result or null if not detected
Example
Detecting npm workspaces
// Project with workspaces in package.json and package-lock.json
const result = npmWorkspacesDetector('/path/to/npm-project')
// => {
// id: 'npm-workspaces',
// name: 'npm Workspaces',
// confidence: 90,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'package-lock.json' }
// ]
// }Detect NX in project.
Parameters
Returns
MonorepoDetectionDetection result or null if not detected
Example
Detecting NX workspace
// Project with nx.json and apps/libs directories
const result = nxDetector('/path/to/nx-workspace')
// => {
// id: 'nx',
// name: 'NX',
// confidence: 100,
// configPath: 'nx.json',
// version: '17.0.0',
// workspaceLayout: { appsDir: 'apps', libsDir: 'libs' },
// detectedFrom: [
// { type: 'config-file', path: 'nx.json' },
// { type: 'package.json', field: 'dependencies.nx' },
// { type: 'directory', path: 'apps/ or libs/' }
// ]
// }Detect pnpm workspaces in project.
Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
Returns
MonorepoDetectionDetection result or null if not detected
Example
Detecting pnpm workspaces
// Project with pnpm-workspace.yaml
const result = pnpmWorkspacesDetector('/path/to/pnpm-project')
// => {
// id: 'pnpm-workspaces',
// name: 'pnpm Workspaces',
// confidence: 100,
// configPath: 'pnpm-workspace.yaml',
// detectedFrom: [
// { type: 'config-file', path: 'pnpm-workspace.yaml' },
// { type: 'lockfile', path: 'pnpm-lock.yaml' }
// ]
// }Detect Rush in project.
Parameters
Returns
MonorepoDetectionDetection result or null if not detected
Example
Detecting Rush monorepo
// Project with rush.json config file
const result = rushDetector('/path/to/rush-project')
// => {
// id: 'rush',
// name: 'Rush',
// confidence: 90,
// configPath: 'rush.json',
// detectedFrom: [{ type: 'config-file', path: 'rush.json' }]
// }Detect Turborepo in project.
Parameters
Returns
MonorepoDetectionDetection result or null if not detected
Example
Detecting Turborepo monorepo
// Project with turbo.json and turbo dependency
const result = turborepoDetector('/path/to/turbo-project')
// => {
// id: 'turborepo',
// name: 'Turborepo',
// confidence: 95,
// configPath: 'turbo.json',
// version: '2.0.0',
// detectedFrom: [
// { type: 'config-file', path: 'turbo.json' },
// { type: 'package.json', field: 'dependencies.turbo' }
// ]
// }§function
yarnWorkspacesDetector(workspacePath: string, packageJson?: PackageJson): MonorepoDetection
Detect yarn workspaces in project.
Parameters
Returns
MonorepoDetectionDetection result or null if not detected
Example
Detecting yarn workspaces
// Project with workspaces in package.json and yarn.lock
const result = yarnWorkspacesDetector('/path/to/yarn-project')
// => {
// id: 'yarn-workspaces',
// name: 'Yarn Workspaces',
// confidence: 100,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'yarn.lock' },
// { type: 'config-file', path: '.yarnrc.yml' }
// ]
// }◈ Interfaces
Detection source information.
Monorepo detection result.
Properties
● Variables
All monorepo detectors