@hyperfrontend/versioning/workspace/operationsoperations
Workspace-wide operations: cascade bumps, batch updates, dependency-reference rewriting, and validation.
The exports fall into three families:
- The cascade-bump family (
PlannedBump,BumpReason,CascadeBumpOptions,CascadeBumpResult,DirectBumpInput) plans the propagation of a version bump through a monorepo's internal-dependency graph, so that bumping a base package automatically schedules dependent packages with the rightBumpReason. - The batch-update family (
applyBumps,updatePackageVersionInTree,updateDependencyReferencesInTree,summarizeBatchUpdate, plusBatchUpdateResult,UpdatedPackage,FailedUpdate,BatchUpdateOptions,DEFAULT_BATCH_UPDATE_OPTIONS) carries out the planned bumps acrosspackage.jsonfiles in one transactional pass. - The validation family (
ValidationResult,ValidationReport,ValidationCheckResult) verifies that a planned set of changes is internally consistent before any file is written.
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
Changes are buffered in the tree until
commitChanges() is called, enabling atomic commits and rollback on failure.Parameters
Returns
BatchUpdateResultBatch 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.
When packages are directly bumped (e.g., due to commits), their dependents may also need version bumps. This function calculates all affected packages.
Parameters
| Name | Type | Description |
|---|---|---|
§workspace | Workspace | Workspace containing projects and dependency graph |
§directBumps | unknown | Packages with direct changes |
§options | CascadeBumpOptions | Configuration for cascade bump calculation (default: {}) |
Returns
CascadeBumpResultCascade 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
Returns
CascadeBumpResultCascade 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}`)
}Creates a summary of the batch update result.
Parameters
| Name | Type | Description |
|---|---|---|
§result | BatchUpdateResult | Result object from batch update operation |
Returns
stringHuman-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.0Gets a summary of the cascade bump calculation.
Parameters
| Name | Type | Description |
|---|---|---|
§result | CascadeBumpResult | Result object from cascade bump calculation |
Returns
stringHuman-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)Creates a summary of the validation report.
Parameters
| Name | Type | Description |
|---|---|---|
§report | ValidationReport | Report object from workspace validation |
Returns
stringHuman-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
Uses the
changeFile() pattern for cleaner transformation. Silently skips if the file doesn't exist.Parameters
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)
}Updates a package.json file using a VFS Tree.
Parameters
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')
}Validates a single project.
Returns
ValidationResultValidation 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)
}
}Validates a workspace for common issues.
Returns
ValidationReportValidation 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
Options for batch update operations.
Properties
Result of a batch update operation.
Properties
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.
Result of cascade bump calculation.
Properties
Input for calculating cascade bumps.
Information about a failed update.
Properties
A planned version bump for a package.
Properties
Information about a successfully updated package.
Properties
Result of a specific validation check.
Properties
Aggregated validation report.
Properties
Validation result for a single check.
Properties
◆ Types
Reason for a version bump.
type BumpReason = "direct" | "cascade" | "sync"