import { BumpInfo } from '../types/BumpInfo' ; import { setDependentsInBumpInfo } from './setDependentsInBumpInfo' ; import { updateRelatedChangeType } from './updateRelatedChangeType' ; import { bumpPackageInfoVersion } from './bumpPackageInfoVersion' ; import { BeachballOptions } from '../types/BeachballOptions' ; import { setGroupsInBumpInfo } from './setGroupsInBumpInfo' ; import { setDependentVersions } from './setDependentVersions' ; /**
 * Updates BumpInfo according to change types, bump deps, and version groups
 *
 * NOTE: THIS FUNCTION MUTATES STATE!
 */ export function bumpInPlace ( bumpInfo , options ) { const { bumpDeps } = options ; const { packageInfos , scopedPackages , calculatedChangeTypes , changeFileChangeInfos , modifiedPackages } = bumpInfo ; if ( bumpDeps ) { setDependentsInBumpInfo ( bumpInfo ) ; } setGroupsInBumpInfo ( bumpInfo , options ) ; for ( const { change : changeInfo } of changeFileChangeInfos ) { const groupName = Object . keys ( bumpInfo . packageGroups ) . find ( group => bumpInfo . packageGroups [ group ] . packageNames . includes ( changeInfo . packageName ) ) ; if ( groupName ) { for ( const packageNameInGroup of bumpInfo . packageGroups [ groupName ] . packageNames ) { calculatedChangeTypes [ packageNameInGroup ] = changeInfo . type ; } } } for ( const { changeFile } of changeFileChangeInfos ) { updateRelatedChangeType ( changeFile , bumpInfo , bumpDeps ) ; } Object . keys ( calculatedChangeTypes ) . forEach ( pkgName => { bumpPackageInfoVersion ( pkgName , bumpInfo , options ) ; } ) ; bumpInfo . dependentChangedBy = setDependentVersions ( packageInfos , scopedPackages , options ) ; Object . keys ( bumpInfo . dependentChangedBy ) . forEach ( pkg => modifiedPackages . add ( pkg ) ) ; return bumpInfo ; }