@hyperfrontend/versioning/workspace

workspace/

Workspace-level utilities for monorepo package discovery, dependency tracking, cascade versioning, and batch operations.

Overview

This module provides tools for working with multi-package workspaces (monorepos). It handles package discovery, builds dependency graphs, calculates cascade bumps when releasing, and performs batch updates across packages.

Configuration

Cascade Bumps

CascadeOptions:

OptionDefaultDescription
cascadeBumpType'patch'Bump type for cascaded dependents
includeDevDependenciesfalseCascade through dev dependencies
includePeerDependenciestrueCascade through peer dependencies
prereleaseId'alpha'Prerelease identifier for prerelease bumps

Batch Updates

BatchUpdateOptions:

OptionDefaultDescription
updateDependencyReferencestrueRewrite the version ranges other packages hold on the bumped ones

Validation

validateWorkspace takes no options: it runs every check below and returns a ValidationReport whose ValidationCheckResult entries name the check and the package it ran against. validateProject runs the per-package checks for one project.

Built-in Validation Checks:

CheckScopeDescription
workspace-has-projectsworkspaceAt least one project was discovered
no-circular-dependenciesworkspaceNo circular dependencies between internal packages
valid-versionpackageVersion must be valid semver
valid-namepackagePackage name must follow npm conventions
dependency-versionspackageInternal dependencies must name versions that exist

Usage Example

import {
  discoverPackages,
  buildDependencyGraph,
  createWorkspace,
  calculateCascadeBumps,
  applyBumps,
  validateWorkspace,
} from '@hyperfrontend/versioning'

// 1. Discover workspace
const projects = await discoverPackages('/path/to/monorepo')
const depGraph = buildDependencyGraph(projects)
const workspace = createWorkspace({
  root: '/path/to/monorepo',
  type: 'nx',
  projects,
  dependencyGraph: depGraph,
  reverseDependencyGraph: buildReverseDependencyGraph(depGraph),
})

// 2. Validate workspace
const report = validateWorkspace(workspace)
if (!report.isValid) {
  console.error(formatValidationReport(report))
  process.exit(1)
}

// 3. Calculate cascade bumps
const result = calculateCascadeBumps(workspace, [{ name: 'core', bumpType: 'minor' }])
console.log(summarizeCascadeBumps(result))
// Output: "3 package(s) affected (1 direct, 2 cascade)"

// 4. Apply bumps
const updateResult = applyBumps(workspace, result.bumps, {
  dryRun: true,
  updateChangelogs: true,
})
console.log(formatBatchResult(updateResult))

Dependencies

Uses @hyperfrontend/project-scope for file system operations and workspace detection. Uses @hyperfrontend/immutable-api-utils for immutable data structures.

See Also

API Reference§

ƒ Functions

§function

createWorkspaceFromDisk(options: DiscoveryOptions): Workspace

Creates a complete workspace object by discovering packages and building the dependency graph.
Parameters
NameTypeDescription
§options
DiscoveryOptionsDiscovery configuration options(default: {})
Returns
Workspace
Complete workspace object with projects and dependency graph
Example

Create a complete workspace object from disk

import { createWorkspaceFromDisk } from '@hyperfrontend/versioning'

const workspace = createWorkspaceFromDisk()

// Access projects
for (const project of workspace.projectList) {
  console.log(`${project.name}@${project.version}`)
}

// Get dependents of a package
const dependents = workspace.dependencyGraph.get('lib-utils')
§function

findChangelogsInTree(tree: Tree, packages: unknown): Map<string, string>

Finds changelog files for a list of packages using VFS tree. Returns a map of project path to changelog absolute path.
Parameters
NameTypeDescription
§tree
TreeVFS tree instance
§packages
unknownList of packages to find changelogs for
Returns
Map<string, string>
Map of project path to changelog path
Example

Find changelogs using VFS tree

import { findChangelogsInTree, discoverPackages } from '@hyperfrontend/versioning'

// Inside an Nx generator
export default function myGenerator(tree: Tree) {
  const { packages } = discoverPackages()
  const changelogs = findChangelogsInTree(tree, packages)

  for (const [projectPath, changelogPath] of changelogs) {
    console.log(`Found changelog at ${changelogPath}`)
  }
}
§function

findProjectChangelogInTree(tree: Tree, projectPath: string): string

Finds the changelog file for a single project using VFS tree. Checks for common changelog names in order of priority.
Parameters
NameTypeDescription
§tree
TreeVFS tree instance
§projectPath
stringPath to project directory
Returns
string
Absolute path to changelog or null if not found
Example

Find project changelog using VFS tree

import { findProjectChangelogInTree } from '@hyperfrontend/versioning'

// Inside an Nx generator
export default function myGenerator(tree: Tree) {
  const changelogPath = findProjectChangelogInTree(tree, 'libs/my-lib')
  if (changelogPath) {
    const content = tree.read(changelogPath, 'utf-8')
    // Process changelog content
  }
}
§function

updateDependencyReferencesInTree(tree: Tree, packageJsonPath: string, versionUpdates: Map<string, string>): void

Updates dependency version references in a package.json file using a VFS Tree.
Uses the changeFile() pattern for cleaner transformation. Silently skips if the file doesn't exist.
Parameters
NameTypeDescription
§tree
TreeVirtual file system tree
§packageJsonPath
stringRelative path to package.json
§versionUpdates
Map<string, string>Map of package name to new version
Example

Update dependency version references using VFS Tree

import { updateDependencyReferencesInTree } from '@hyperfrontend/versioning'

// Inside an Nx generator
export default function syncDeps(tree: Tree) {
  const updates = new Map([
    ['@myorg/utils', '2.0.0'],
    ['@myorg/core', '3.1.0'],
  ])

  updateDependencyReferencesInTree(tree, 'apps/my-app/package.json', updates)
}
§function

addDependent(project: Project, dependent: string): Project

Creates a copy of a project with an added internal dependent.
Parameters
NameTypeDescription
§project
ProjectThe project to update
§dependent
stringName of the dependent to add
Returns
Project
A new Project with the added dependent
Example

Add an internal dependent to a project

import { discoverProject, addDependent } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/utils')
if (project) {
  const updated = addDependent(project, '@myorg/new-app')
  console.log('Dependents now:', updated.internalDependents)
}
§function

applyBumps(tree: Tree, workspace: Workspace, bumps: unknown, options: BatchUpdateOptions): BatchUpdateResult

Applies planned bumps to the workspace using the VFS Tree. Updates package.json version fields for all affected packages.
Changes are buffered in the tree until commitChanges() is called, enabling atomic commits and rollback on failure.
Parameters
NameTypeDescription
§tree
TreeVirtual file system tree for buffered operations
§workspace
WorkspaceWorkspace containing projects to update
§bumps
unknownPlanned version bumps
§options
BatchUpdateOptionsUpdate options(default: {})
Returns
BatchUpdateResult
Batch update result
Example

Apply planned bumps to workspace using VFS Tree

import { createTree, commitChanges } from '@hyperfrontend/project-scope'
import { applyBumps, calculateCascadeBumps } from '@hyperfrontend/versioning'

const tree = createTree(workspaceRoot)
const cascadeResult = calculateCascadeBumps(workspace, directBumps)
const updateResult = applyBumps(tree, workspace, cascadeResult.bumps)

if (updateResult.success) {
  commitChanges(tree) // Atomic commit of all changes
  console.log(`Updated ${updateResult.updated.length} packages`)
} else {
  console.error('Some updates failed:', updateResult.failed)
  // No commitChanges() call - changes are discarded
}
§function

buildDependencyGraph(projects: unknown): DependencyGraphAnalysis

Builds a complete dependency graph from a list of projects.
Parameters
NameTypeDescription
§projects
unknownList of projects to analyze
Returns
DependencyGraphAnalysis
Dependency graph analysis result
Example

Build a complete dependency graph

import { buildDependencyGraph, discoverPackages } from '@hyperfrontend/versioning'

const { projects } = discoverPackages()
const analysis = buildDependencyGraph(projects)

// Get packages that depend on 'lib-utils'
const dependents = analysis.dependencyGraph.get('lib-utils') ?? []

// Get packages in topological order for building
const buildOrder = getTopologicalOrder(analysis)
§function

calculateCascadeBumps(workspace: Workspace, directBumps: unknown, options: CascadeBumpOptions): CascadeBumpResult

Calculates cascade bumps for a workspace given direct bumps.
When packages are directly bumped (e.g., due to commits), their dependents may also need version bumps. This function calculates all affected packages.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace containing projects and dependency graph
§directBumps
unknownPackages with direct changes
§options
CascadeBumpOptionsConfiguration for cascade bump calculation(default: {})
Returns
CascadeBumpResult
Cascade bump result
Example

Calculate cascade bumps for a workspace

import { calculateCascadeBumps } from '@hyperfrontend/versioning'

// If lib-utils is getting a minor bump
const result = calculateCascadeBumps(workspace, [
  { name: 'lib-utils', bumpType: 'minor' }
])

// result.bumps includes lib-utils and all packages that depend on it
for (const bump of result.bumps) {
  console.log(`${bump.name}: ${bump.currentVersion} -> ${bump.nextVersion}`)
}
§function

calculateCascadeBumpsFromPackage(workspace: Workspace, packageName: string, bumpType: BumpType, options: CascadeBumpOptions): CascadeBumpResult

Calculates cascade bumps starting from a single package.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace containing projects and dependency graph
§packageName
stringPackage with direct changes
§bumpType
BumpTypeType of bump for the direct change
§options
CascadeBumpOptionsConfiguration for cascade behavior(default: {})
Returns
CascadeBumpResult
Cascade bump result
Example

Calculate cascade bumps from a single package

import { discoverWorkspace, calculateCascadeBumpsFromPackage } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
const result = calculateCascadeBumpsFromPackage(workspace, '@myorg/utils', 'minor')

console.log(`${result.totalAffected} packages will be bumped`)
for (const bump of result.bumps) {
  console.log(`${bump.name}: ${bump.currentVersion} -> ${bump.nextVersion}`)
}
§function

createProject(options: CreateProjectOptions): Project

Creates a new Project object.
Parameters
NameTypeDescription
§options
CreateProjectOptionsProject properties
Returns
Project
A new Project object
Example

Create a new Project object

import { createProject, readPackageJson } from '@hyperfrontend/versioning'

const packageJson = readPackageJson('./libs/my-lib/package.json')
const project = createProject({
  name: '@myorg/my-lib',
  version: '1.0.0',
  path: './libs/my-lib',
  packageJsonPath: './libs/my-lib/package.json',
  packageJson,
  changelogPath: './libs/my-lib/CHANGELOG.md',
})
§function

createWorkspace(options: CreateWorkspaceOptions): Workspace

Creates a new workspace object.
Parameters
NameTypeDescription
§options
CreateWorkspaceOptionsWorkspace properties
Returns
Workspace
A new Workspace object
Example

Create a new workspace object

import { createWorkspace, createWorkspaceConfig, createProject } from '@hyperfrontend/versioning'

const projects = new Map([['@myorg/utils', createProject({ ... })]])
const workspace = createWorkspace({
  root: '/path/to/workspace',
  type: 'nx',
  projects,
  config: createWorkspaceConfig(),
  dependencyGraph: new Map(),
  reverseDependencyGraph: new Map(),
})
§function

createWorkspaceConfig(options?: Partial<WorkspaceConfig>): WorkspaceConfig

Creates a new workspace configuration by merging with defaults.
Parameters
NameTypeDescription
§options?
Partial<WorkspaceConfig>Partial configuration options
Returns
WorkspaceConfig
Complete workspace configuration
Example

Create a workspace configuration with defaults

import { createWorkspaceConfig } from '@hyperfrontend/versioning'

const config = createWorkspaceConfig({
  patterns: ['packages/*', 'libs/*'],
  exclude: ['node_modules', 'dist'],
})
§function

dependsOn(workspace: Workspace, projectA: string, projectB: string): boolean

Checks if projectA depends on projectB.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace containing the dependency graph
§projectA
stringName of the potentially dependent project
§projectB
stringName of the potential dependency
Returns
boolean
True if projectA depends on projectB
Example

Check if one project depends on another

import { discoverWorkspace, dependsOn } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
if (dependsOn(workspace, '@myorg/app', '@myorg/utils')) {
  console.log('@myorg/app directly depends on @myorg/utils')
}
§function

discoverAllChangelogs(workspaceRoot: string, patterns: unknown): unknown

Discovers all changelog files within a workspace.
Parameters
NameTypeDescription
§workspaceRoot
stringWorkspace root path
§patterns
unknownGlob patterns for finding changelogs (default: all CHANGELOGs)(default: ...)
Returns
unknown
Array of discovered changelog information
Example

Discover all changelog files within a workspace

import { discoverAllChangelogs } from '@hyperfrontend/versioning'

const changelogs = discoverAllChangelogs('/path/to/workspace')
for (const changelog of changelogs) {
  console.log(`${changelog.projectPath} -> ${changelog.path}`)
}
§function

discoverPackages(options: DiscoveryOptions): DiscoveryResult

Discovers all packages within a workspace. Finds package.json files, parses them, and optionally discovers changelogs and internal dependencies.
Parameters
NameTypeDescription
§options
DiscoveryOptionsDiscovery options(default: {})
Returns
DiscoveryResult
Discovery result with all found packages
Example

Discover all packages within a workspace

import { discoverPackages } from '@hyperfrontend/versioning'

// Discover all packages in current workspace
const result = discoverPackages()

// Discover with custom patterns
const result = discoverPackages({
  patterns: ['packages/*/package.json'],
  includeChangelogs: true
})

// Access discovered projects
for (const project of result.projects) {
  console.log(`${project.name}@${project.version}`)
}
§function

discoverProject(projectPath: string): Project

Discovers a single project by path.
Parameters
NameTypeDescription
§projectPath
stringPath to project directory or package.json
Returns
Project
The discovered project or null if not found
Example

Discover a single project by path

import { discoverProject } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/utils')
if (project) {
  console.log(`Found ${project.name}@${project.version}`)
}

// Also accepts direct package.json path
const project2 = discoverProject('./libs/utils/package.json')
§function

discoverProjectByName(projectName: string, options: DiscoveryOptions): Project

Discovers a project by name within a workspace.
Parameters
NameTypeDescription
§projectName
stringName of the project to find
§options
DiscoveryOptionsDiscovery options(default: {})
Returns
Project
The project or null if not found
Example

Discover a project by name within a workspace

import { discoverProjectByName } from '@hyperfrontend/versioning'

const project = discoverProjectByName('@myorg/utils')
if (project) {
  console.log(`Found at ${project.path}`)
}

// With custom workspace root
const project2 = discoverProjectByName('@myorg/core', { workspaceRoot: '/custom/path' })
§function

findChangelogs(workspaceRoot: string, packages: unknown): Map<string, string>

Finds changelog files for a list of packages. Returns a map of project path to changelog absolute path.
Parameters
NameTypeDescription
§workspaceRoot
stringWorkspace root path
§packages
unknownList of packages to find changelogs for
Returns
Map<string, string>
Map of project path to changelog path
Example

Find changelog files for all packages

import { findChangelogs, discoverPackages } from '@hyperfrontend/versioning'

const { packages } = discoverPackages()
const changelogs = findChangelogs('/workspace', packages)

for (const [projectPath, changelogPath] of changelogs) {
  console.log(`${projectPath} -> ${changelogPath}`)
}
§function

findInternalDependencies(packageJson: PackageJson, workspacePackageNames: Set<string>): string[]

Finds internal dependencies in a package.json. Returns names of workspace packages that this package depends on.
Parameters
NameTypeDescription
§packageJson
PackageJsonParsed package.json content
§workspacePackageNames
Set<string>Set of all package names in the workspace
Returns
string[]
Array of internal dependency names
Example

Find internal dependencies in a package

const internalDeps = findInternalDependencies(packageJson, allPackageNames)
// ['@scope/lib-a', '@scope/lib-b']
§function

findInternalDependenciesWithTypes(packageName: string, packageJson: PackageJson, workspacePackageNames: Set<string>): DependencyEdge[]

Finds internal dependencies with type information.
Parameters
NameTypeDescription
§packageName
stringName of the package being analyzed
§packageJson
PackageJsonParsed package.json content
§workspacePackageNames
Set<string>Set of all package names in the workspace
Returns
DependencyEdge[]
Array of dependency edges with type information
Example

Find internal dependencies with type information

import { findInternalDependenciesWithTypes, readPackageJson } from '@hyperfrontend/versioning'

const packageJson = readPackageJson('./libs/my-lib/package.json')
const workspacePackages = new Set(['@myorg/utils', '@myorg/core'])

const edges = findInternalDependenciesWithTypes('@myorg/my-lib', packageJson, workspacePackages)
for (const edge of edges) {
  console.log(`${edge.from} -> ${edge.to} (${edge.type})`)
}
§function

findProjectChangelog(projectPath: string): string

Finds the changelog file for a single project. Checks for common changelog names in order of priority.
Parameters
NameTypeDescription
§projectPath
stringPath to project directory
Returns
string
Absolute path to changelog or null if not found
Example

Find the changelog for a single project

import { findProjectChangelog } from '@hyperfrontend/versioning'

const changelogPath = findProjectChangelog('./libs/my-lib')
if (changelogPath) {
  console.log('Found changelog:', changelogPath)
}
§function

getDependencies(workspace: Workspace, projectName: string): unknown

Gets projects that the given project depends on.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace containing the dependency graph
§projectName
stringIdentifier of the project to look up
Returns
unknown
Array of dependency project names
Example

Get projects that the given project depends on

import { discoverWorkspace, getDependencies } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
const deps = getDependencies(workspace, '@myorg/app')
console.log(`@myorg/app depends on:`, deps)
§function

getDependencyCount(project: Project): number

Gets the dependency count (internal dependencies).
Parameters
NameTypeDescription
§project
ProjectProject instance to analyze
Returns
number
Number of internal dependencies
Example

Get the dependency count for a project

import { discoverProject, getDependencyCount } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/my-lib')
if (project) {
  console.log(`${project.name} depends on ${getDependencyCount(project)} internal packages`)
}
§function

getDependentCount(project: Project): number

Gets the dependent count (packages that depend on this one).
Parameters
NameTypeDescription
§project
ProjectProject instance to analyze
Returns
number
Number of internal dependents
Example

Get the dependent count for a project

import { discoverProject, getDependentCount } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/utils')
if (project) {
  console.log(`${project.name} is used by ${getDependentCount(project)} packages`)
}
§function

getDependents(workspace: Workspace, projectName: string): unknown

Gets projects that depend on the given project.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace containing the dependency graph
§projectName
stringName of the dependency
Returns
unknown
Array of dependent project names
Example

Get projects that depend on a given project

import { discoverWorkspace, getDependents } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
const dependents = getDependents(workspace, '@myorg/utils')
console.log(`Packages depending on @myorg/utils:`, dependents)
§function

getExpectedChangelogPath(projectPath: string, fileName: string): string

Gets the expected changelog path for a project. Returns the standard CHANGELOG.md path regardless of whether it exists.
Parameters
NameTypeDescription
§projectPath
stringDirectory containing the project files
§fileName
stringChangelog filename to use (default: 'CHANGELOG.md')(default: DEFAULT_CHANGELOG_FILENAME)
Returns
string
Absolute path to changelog file in the project directory
Example

Get expected changelog path for a project

import { getExpectedChangelogPath } from '@hyperfrontend/versioning'

const changelogPath = getExpectedChangelogPath('./libs/my-lib')
// => '/workspace/libs/my-lib/CHANGELOG.md'

const customPath = getExpectedChangelogPath('./libs/my-lib', 'HISTORY.md')
// => '/workspace/libs/my-lib/HISTORY.md'
§function

getProject(workspace: Workspace, projectName: string): Project

Gets a project by name from the workspace.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace to search in
§projectName
stringIdentifier of the project to retrieve
Returns
Project
The project or undefined if not found
Example

Get a project by name from the workspace

import { discoverWorkspace, getProject } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
const project = getProject(workspace, '@myorg/utils')
if (project) {
  console.log(`Version: ${project.version}`)
}
§function

getProjectCount(workspace: Workspace): number

Gets the count of projects in the workspace.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace to count projects in
Returns
number
Number of projects
Example

Get the count of projects in the workspace

import { discoverWorkspace, getProjectCount } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
console.log(`Workspace contains ${getProjectCount(workspace)} projects`)
§function

getProjectNames(workspace: Workspace): unknown

Gets all project names in the workspace.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace to retrieve project names from
Returns
unknown
Array of project names
Example

Get all project names in the workspace

import { discoverWorkspace, getProjectNames } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
const names = getProjectNames(workspace)
console.log(`Found ${names.length} projects:`, names)
§function

getTopologicalOrder(analysis: DependencyGraphAnalysis): unknown

Gets a topological ordering of packages for building. Packages with no dependencies come first.
Parameters
NameTypeDescription
§analysis
DependencyGraphAnalysisDependency graph analysis result
Returns
unknown
Array of package names in build order
Example

Get packages in topological order for building

const buildOrder = getTopologicalOrder(analysis)
for (const pkg of buildOrder) {
  await build(pkg)
}
§function

getTransitiveDependencies(workspace: Workspace, packageName: string): Set<string>

Gets all transitive dependencies of a package (direct and indirect).
Parameters
NameTypeDescription
§workspace
WorkspaceThe workspace containing projects
§packageName
stringName of the package to analyze
Returns
Set<string>
Set of all packages this package depends on
Example

Get all transitive dependencies of a package

import { discoverWorkspace, getTransitiveDependencies } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
const allDeps = getTransitiveDependencies(workspace, '@myorg/app')

console.log(`@myorg/app transitively depends on ${allDeps.size} packages`)
for (const dep of allDeps) {
  console.log(`  - ${dep}`)
}
§function

getTransitiveDependents(workspace: Workspace, packageName: string): Set<string>

Gets all transitive dependents of a package (direct and indirect).
Parameters
NameTypeDescription
§workspace
WorkspaceThe workspace containing projects
§packageName
stringName of the package to analyze
Returns
Set<string>
Set of all packages that depend on this package
Example

Get all transitive dependents of a package

// If lib-a depends on lib-utils and app-main depends on lib-a
// Then getTransitiveDependents('lib-utils') returns ['lib-a', 'app-main']
§function

hasChangelog(projectPath: string): boolean

Checks if a project has a changelog file.
Parameters
NameTypeDescription
§projectPath
stringDirectory containing the project to check
Returns
boolean
True if changelog exists
Example

Check if a project has a changelog

import { hasChangelog } from '@hyperfrontend/versioning'

if (hasChangelog('./libs/my-lib')) {
  console.log('Project has a changelog')
}
§function

hasInternalDependencies(project: Project): boolean

Checks if a project has any internal dependencies.
Parameters
NameTypeDescription
§project
ProjectThe project to check
Returns
boolean
True if project depends on other workspace packages
Example

Check if a project has internal dependencies

import { discoverProject, hasInternalDependencies } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/my-lib')
if (project && hasInternalDependencies(project)) {
  console.log(`${project.name} depends on:`, project.internalDependencies)
}
§function

hasInternalDependents(project: Project): boolean

Checks if a project has any internal dependents.
Parameters
NameTypeDescription
§project
ProjectThe project to check
Returns
boolean
True if other workspace packages depend on this project
Example

Check if a project has internal dependents

import { discoverProject, hasInternalDependents } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/utils')
if (project && hasInternalDependents(project)) {
  console.log(`${project.name} is used by:`, project.internalDependents)
}
§function

hasProject(workspace: Workspace, projectName: string): boolean

Checks if a project exists in the workspace.
Parameters
NameTypeDescription
§workspace
WorkspaceWorkspace to search in
§projectName
stringIdentifier of the project to check
Returns
boolean
True if the project exists
Example

Check if a project exists in the workspace

import { discoverWorkspace, hasProject } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()
if (hasProject(workspace, '@myorg/utils')) {
  console.log('Package exists in workspace')
}
§function

hasProjectChangelog(project: Project): boolean

Checks if a project has a changelog file.
Parameters
NameTypeDescription
§project
ProjectThe project to check
Returns
boolean
True if changelog exists
Example

Check if a project has a changelog

import { discoverProject, hasChangelog } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/my-lib')
if (project && !hasChangelog(project)) {
  console.log('Warning: No changelog found for', project.name)
}
§function

isPrivate(project: Project): boolean

Checks if a project is private.
Parameters
NameTypeDescription
§project
ProjectThe project to check
Returns
boolean
True if the project is marked as private
Example

Check if a project is private

import { discoverProject, isPrivate } from '@hyperfrontend/versioning'

const project = discoverProject('./apps/internal-app')
if (project && isPrivate(project)) {
  console.log('Skipping private package')
}
§function

isPublishable(project: Project): boolean

Checks if a project is publishable (public and has name/version).
Parameters
NameTypeDescription
§project
ProjectThe project to check
Returns
boolean
True if the project can be published
Example

Check if a project is publishable

import { discoverProject, isPublishable } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/my-lib')
if (project && isPublishable(project)) {
  console.log(`${project.name} can be published to npm`)
}
§function

summarizeBatchUpdate(result: BatchUpdateResult): string

Creates a summary of the batch update result.
Parameters
NameTypeDescription
§result
BatchUpdateResultResult object from batch update operation
Returns
string
Human-readable summary
Example

Create a summary of the batch update result

import { batchUpdateVersions, summarizeBatchUpdate } from '@hyperfrontend/versioning'

const result = batchUpdateVersions(workspace, updates)
console.log(summarizeBatchUpdate(result))
// Output:
// Successfully updated 3 package(s)
//
// Updated packages:
//   @myorg/utils: 1.0.0 -> 1.1.0
//   @myorg/core: 2.0.0 -> 2.1.0
§function

summarizeCascadeBumps(result: CascadeBumpResult): string

Gets a summary of the cascade bump calculation.
Parameters
NameTypeDescription
§result
CascadeBumpResultResult object from cascade bump calculation
Returns
string
Human-readable summary
Example

Get a summary of cascade bump results

import { calculateCascadeBumps, summarizeCascadeBumps } from '@hyperfrontend/versioning'

const result = calculateCascadeBumps(workspace, [{ name: '@myorg/utils', bumpType: 'patch' }])
console.log(summarizeCascadeBumps(result))
// Output:
// 3 package(s) affected:
//   - 1 direct bump(s)
//   - 2 cascade bump(s)
§function

summarizeValidation(report: ValidationReport): string

Creates a summary of the validation report.
Parameters
NameTypeDescription
§report
ValidationReportReport object from workspace validation
Returns
string
Human-readable summary
Example

Create a summary of the validation report

import { validateWorkspace, summarizeValidation } from '@hyperfrontend/versioning'

const report = validateWorkspace(workspace)
console.log(summarizeValidation(report))
// Output:
// Workspace validation passed
//   2 warning(s)
§function

transitivelyDependsOn(workspace: Workspace, packageA: string, packageB: string): boolean

Checks if package A transitively depends on package B.
Parameters
NameTypeDescription
§workspace
WorkspaceThe workspace containing projects
§packageA
stringName of the potentially dependent package
§packageB
stringName of the potential dependency
Returns
boolean
True if packageA transitively depends on packageB
Example

Check if one package transitively depends on another

import { discoverWorkspace, transitivelyDependsOn } from '@hyperfrontend/versioning'

const workspace = discoverWorkspace()

if (transitivelyDependsOn(workspace, '@myorg/app', '@myorg/utils')) {
  console.log('Bumping @myorg/utils will affect @myorg/app')
}
§function

updatePackageVersionInTree(tree: Tree, packageJsonPath: string, newVersion: string): void

Updates a package.json file using a VFS Tree.
Parameters
NameTypeDescription
§tree
TreeVirtual file system tree
§packageJsonPath
stringRelative path to package.json
§newVersion
stringNew version string
Example

Update a package.json version using VFS Tree

import { updatePackageVersionInTree } from '@hyperfrontend/versioning'

// Inside an Nx generator
export default function bumpVersion(tree: Tree) {
  updatePackageVersionInTree(tree, 'libs/my-lib/package.json', '2.0.0')
}
§function

validateProject(project: Project): ValidationResult

Validates a single project.
Parameters
NameTypeDescription
§project
ProjectThe project to validate
Returns
ValidationResult
Validation result
Example

Validate a single project

import { discoverProject, validateProject } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/my-lib')
if (project) {
  const result = validateProject(project)
  if (!result.valid) {
    console.error('Validation failed:', result.error)
  }
}
§function

validateWorkspace(workspace: Workspace): ValidationReport

Validates a workspace for common issues.
Parameters
NameTypeDescription
§workspace
WorkspaceThe workspace to validate
Returns
ValidationReport
Validation report
Example

Validate a workspace for common issues

import { validateWorkspace } from '@hyperfrontend/versioning'

const report = validateWorkspace(workspace)

if (!report.valid) {
  console.error(`${report.errorCount} error(s) found`)
  for (const result of report.results) {
    if (!result.result.valid) {
      console.error(`  ${result.checkName}: ${result.result.error}`)
    }
  }
}
§function

withDependents(project: Project, dependents: unknown): Project

Creates a copy of a project with updated internal dependents.
Parameters
NameTypeDescription
§project
ProjectThe project to update
§dependents
unknownNew list of internal dependents
Returns
Project
A new Project with updated dependents
Example

Create a project copy with updated dependents

import { discoverProject, withDependents } from '@hyperfrontend/versioning'

const project = discoverProject('./libs/utils')
if (project) {
  const updated = withDependents(project, ['@myorg/app', '@myorg/web'])
  console.log('Updated dependents:', updated.internalDependents)
}

◈ Interfaces

§interface

BatchUpdateOptions

Options for batch update operations.
Properties
§updateDependencyReferences?:booleanWhether to update dependency references in other packages
§interface

BatchUpdateResult

Result of a batch update operation.
Properties
§readonly failed:unknownPackages that failed to update
§readonly success:booleanWhether all updates succeeded
§readonly total:numberTotal number of packages processed
§readonly updated:unknownPackages successfully updated
§interface

CascadeBumpOptions

Options for cascade bump calculation.
Properties
§cascadeBumpType?:BumpTypeBump type for cascaded dependents. Default is 'patch' - dependents get a patch bump when their dependencies change.
§includeDevDependencies?:booleanWhether to include dev dependencies in cascade. Default is false - only production dependencies trigger cascades.
§includePeerDependencies?:booleanWhether to include peer dependencies in cascade. Default is true - peer dependency updates should cascade.
§prereleaseId?:stringCustom prerelease identifier for prerelease bumps.
§interface

CascadeBumpResult

Result of cascade bump calculation.
Properties
§readonly bumps:unknownAll planned bumps, in topological order
§readonly cascadeBumps:unknownPackages bumped due to cascading
§readonly directBumps:unknownPackages explicitly bumped (direct changes)
§readonly totalAffected:numberTotal number of packages affected
§interface

CreateProjectOptions

Options for creating a project.
Properties
§changelogPath?:stringAbsolute path to CHANGELOG.md
§internalDependencies?:unknownNames of workspace packages this project depends on
§internalDependents?:unknownNames of workspace packages that depend on this project
§name:stringPackage name
§packageJson:PackageJsonParsed package.json content
§packageJsonPath:stringAbsolute path to package.json
§path:stringAbsolute path to project root
§version:stringPackage version
§interface

DependencyEdge

A single dependency edge in the graph.
Properties
§readonly from:stringPackage that has the dependency
§readonly to:stringPackage being depended on
§readonly type:DependencyTypeType of dependency relationship
§readonly versionRange:stringVersion range specified
§interface

DependencyGraphAnalysis

Result of dependency graph analysis.
Properties
§readonly circularDependencies:unknownDetected circular dependency chains
§readonly dependencyGraph:DependencyGraphForward graph: package -> dependents
§readonly edges:unknownAll dependency edges
§readonly hasCircularDependencies:booleanWhether the graph has circular dependencies
§readonly leafPackages:unknownPackages with no dependents (leaf nodes)
§readonly reverseDependencyGraph:DependencyGraphReverse graph: package -> dependencies
§readonly rootPackages:unknownPackages with no dependencies (root nodes)
§interface

DirectBumpInput

Input for calculating cascade bumps.
Properties
§bumpType:BumpTypeType of bump
§name:stringPackage name
§interface

DiscoveredChangelog

Represents a discovered changelog file.
Properties
§readonly filename:stringName of the changelog file
§readonly path:stringAbsolute path to the changelog file
§readonly projectPath:stringPath to the project containing this changelog
§readonly relativePath:stringRelative path from project root
§interface

DiscoveryOptions

Options for package discovery.
Properties
§exclude?:unknownPatterns to exclude
§includeChangelogs?:booleanInclude changelogs in discovery
§patterns?:unknownGlob patterns for finding package.json files
§trackDependencies?:booleanTrack internal dependencies
§tree?:TreeOptional VFS tree for VFS-aware discovery
§workspaceRoot?:stringWorkspace root (auto-detected if not provided)
§interface

DiscoveryResult

Result of package discovery.
Properties
§readonly config:WorkspaceConfigConfiguration used for discovery
§readonly packageNames:ReadonlySet<string>All discovered package names
§readonly projectMap:ReadonlyMap<string, Project>Projects indexed by name
§readonly projects:unknownAll discovered projects
§readonly workspaceRoot:stringWorkspace root path
§interface

FailedUpdate

Information about a failed update.
Properties
§readonly error:stringError message
§readonly name:stringPackage name
§readonly packageJsonPath:stringPath to package.json
§interface

PlannedBump

A planned version bump for a package.
Properties
§readonly bumpType:BumpTypeType of bump
§readonly currentVersion:stringCurrent version
§readonly name:stringPackage name
§readonly nextVersion:stringNext version after bump
§readonly reason:BumpReasonReason for the bump
§readonly triggeredBy:unknownPackages that triggered this bump (for cascade bumps)
§interface

Project

A single project within a workspace.
Properties
§readonly changelogPath:stringAbsolute path to CHANGELOG.md (null if not found)
§readonly internalDependencies:unknownNames of workspace packages this project depends on
§readonly internalDependents:unknownNames of workspace packages that depend on this project
§readonly name:stringPackage name from package.json
§readonly packageJson:PackageJsonParsed package.json content
§readonly packageJsonPath:stringAbsolute path to package.json
§readonly path:stringAbsolute path to project root directory
§readonly private:booleanWhether this is a private package
§readonly publishable:booleanWhether this is a publishable package
§readonly version:stringPackage version from package.json
§interface

UpdatedPackage

Information about a successfully updated package.
Properties
§readonly name:stringPackage name
§readonly newVersion:stringNew version
§readonly packageJsonPath:stringPath to package.json
§readonly previousVersion:stringPrevious version
§interface

ValidationCheckResult

Result of a specific validation check.
Properties
§readonly checkId:stringCheck identifier
§readonly checkName:stringHuman-readable check name
§readonly packageName:stringPackage being checked (null for workspace-level checks)
§readonly result:ValidationResultCheck result
§interface

ValidationReport

Aggregated validation report.
Properties
§readonly errorCount:numberTotal number of errors
§readonly invalidPackages:unknownPackages with validation errors
§readonly results:unknownAll validation results
§readonly valid:booleanWhether all checks passed
§readonly warningCount:numberTotal number of warnings
§interface

WorkspaceValidationResult

Validation result for a single check.
Properties
§readonly error?:stringError message if invalid
§readonly valid:booleanWhether the check passed
§readonly warning?:stringWarning message (valid but potentially problematic)
§interface

Workspace

Complete workspace representation. Contains all discovered projects and their relationships.
Properties
§readonly config:WorkspaceConfigConfiguration used for discovery
§readonly dependencyGraph:ReadonlyMap<string, unknown>Dependency graph (project name -> dependents)
§readonly projectList:unknownProjects ordered by name
§readonly projects:ReadonlyMap<string, Project>All discovered projects indexed by name
§readonly reverseDependencyGraph:ReadonlyMap<string, unknown>Reverse dependency graph (project name -> dependencies)
§readonly root:stringAbsolute path to workspace root
§readonly type:WorkspaceTypeDetected workspace type
§interface

WorkspaceConfig

Workspace configuration options.
Properties
§readonly exclude:unknownPatterns to exclude from discovery
§readonly includeChangelogs:booleanWhether to include changelog paths in discovery
§readonly patterns:unknownGlob patterns for finding packages
§readonly trackDependencies:booleanWhether to track internal dependencies

◆ Types

§type

BumpReason

Reason for a version bump.
type BumpReason = "direct" | "cascade" | "sync"
§type

DependencyGraph

Dependency graph structure. Maps package name to list of packages that depend on it.
type DependencyGraph = ReadonlyMap<string, unknown>
§type

DependencyType

Dependency relation type.
type DependencyType = "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies"
§type

WorkspaceType

Workspace type indicating the package manager / tool in use.
type WorkspaceType = "nx" | "turbo" | "lerna" | "pnpm" | "npm" | "yarn" | "rush" | "unknown"

● Variables

§type

CHANGELOG_NAMES

Common changelog file names in priority order.
§type

DEFAULT_BATCH_UPDATE_OPTIONS

Default batch update options.
§type

DEFAULT_CASCADE_OPTIONS

Default cascade bump options.
§type

DEFAULT_EXCLUDE

Default exclusion patterns.
§type

DEFAULT_PATTERNS

Default workspace discovery patterns.
§type

DEFAULT_WORKSPACE_CONFIG

Default workspace configuration.