@hyperfrontend/versioning/workspace/operations

operations

Workspace-wide operations: cascade bumps, batch updates, dependency-reference rewriting, and validation.

The exports fall into three families:

API Reference§

ƒ Functions

§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

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

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

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

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}`)
    }
  }
}

◈ 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

DirectBumpInput

Input for calculating cascade bumps.
Properties
§bumpType:BumpTypeType of bump
§name:stringPackage name
§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

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)

◆ Types

§type

BumpReason

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

● Variables

§type

DEFAULT_BATCH_UPDATE_OPTIONS

Default batch update options.
§type

DEFAULT_CASCADE_OPTIONS

Default cascade bump options.