@hyperfrontend/project-scope/tech/monorepo

monorepo

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

§function

detectMonorepoTools(workspacePath: string, packageJson?: PackageJson): MonorepoDetection[]

Detect all monorepo tools in project.

Parameters

NameTypeDescription
§workspacePath
string
Workspace directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

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, ... }
// ]
§function

lernaDetector(workspacePath: string, packageJson?: PackageJson): MonorepoDetection

Detect Lerna in project.

Parameters

NameTypeDescription
§workspacePath
string
Workspace directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

MonorepoDetection
Detection 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' }]
// }
§function

npmWorkspacesDetector(workspacePath: string, packageJson?: PackageJson): MonorepoDetection

Detect npm workspaces in project.

Parameters

NameTypeDescription
§workspacePath
string
Workspace directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

MonorepoDetection
Detection 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' }
//   ]
// }
§function

nxDetector(workspacePath: string, packageJson?: PackageJson): MonorepoDetection

Detect NX in project.

Parameters

NameTypeDescription
§workspacePath
string
Workspace directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

MonorepoDetection
Detection 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/' }
//   ]
// }
§function

pnpmWorkspacesDetector(workspacePath: string): MonorepoDetection

Detect pnpm workspaces in project.

Parameters

NameTypeDescription
§workspacePath
string
Workspace directory path

Returns

MonorepoDetection
Detection 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' }
//   ]
// }
§function

rushDetector(workspacePath: string, packageJson?: PackageJson): MonorepoDetection

Detect Rush in project.

Parameters

NameTypeDescription
§workspacePath
string
Workspace directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

MonorepoDetection
Detection 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' }]
// }
§function

turborepoDetector(workspacePath: string, packageJson?: PackageJson): MonorepoDetection

Detect Turborepo in project.

Parameters

NameTypeDescription
§workspacePath
string
Workspace directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

MonorepoDetection
Detection 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

NameTypeDescription
§workspacePath
string
Workspace directory path
§packageJson?
PackageJson
Optional pre-loaded package.json

Returns

MonorepoDetection
Detection 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

§interface

DetectionSource

Detection source information.

Properties

§field?:string
Field or path identifier
§path?:string
File path
§type:"package.json" | "config-file" | "lockfile" | "directory"
Source type
§interface

MonorepoDetection

Monorepo detection result.

Properties

§confidence:number
Detection confidence (0-100)
§configPath?:string
Config file path
§detectedFrom:DetectionSource[]
Detection sources
§id:string
Tool identifier
§name:string
Human-readable name
§projects?:string[]
Detected project paths
§version?:string
Detected version
§workspaceLayout?:{ appsDir: string; libsDir: string }
Workspace layout
§interface

MonorepoDetector

Monorepo detector interface.

Properties

§id:string
Tool identifier
§name:string
Human-readable name

Variables

§type

monorepoDetectors

All monorepo detectors