UNPKG

apisurf

Version:

Analyze API surface changes between npm package versions to catch breaking changes

27 lines (26 loc) 848 B
/** * Calculates the minimum semantic version bump required based on detected changes. * Follows semantic versioning rules: major for breaking changes, minor for new features, patch for fixes. */ export function calculateSemverImpact(packages) { let hasBreaking = false; let hasFeatures = false; for (const pkg of packages) { if (pkg.breakingChanges.length > 0) { hasBreaking = true; break; } if (pkg.nonBreakingChanges.length > 0) { hasFeatures = true; } } if (hasBreaking) { return { minimumBump: 'major', reason: 'Breaking changes detected' }; } else if (hasFeatures) { return { minimumBump: 'minor', reason: 'New features added' }; } else { return { minimumBump: 'patch', reason: 'No changes detected' }; } }