import { initializePackageChangeInfo as initializePackageChangeTypes } from '../changefile/getPackageChangeTypes' ; import { readChangeFiles } from '../changefile/readChangeFiles' ; import { BumpInfo } from '../types/BumpInfo' ; import { bumpInPlace } from './bumpInPlace' ; import { BeachballOptions } from '../types/BeachballOptions' ; import { getScopedPackages } from '../monorepo/getScopedPackages' ; import { getChangePath } from '../paths' ; import path from 'path' ; import { PackageInfos } from '../types/PackageInfo' ; function gatherPreBumpInfo ( options , packageInfos ) { const { path : cwd } = options ; const changes = readChangeFiles ( options , packageInfos ) ; const changePath = getChangePath ( cwd ) ; const groupOptions = { } ; const filteredChanges = changes . filter ( ( { changeFile , change } ) => { const errorType = ! packageInfos [ change . packageName ] ? 'nonexistent' : packageInfos [ change . packageName ] . private ? 'private' : undefined ; if ( errorType ) { const resolution = options . groupChanges ? 'remove the entry from this file' : 'delete this file' ; console . warn ( `Change detected for ${ errorType } package ${ change . packageName }; ${ resolution }: "${ path . resolve ( changePath ! , changeFile ) }"` ) ; return false ; } return true ; } ) ; const calculatedChangeTypes = initializePackageChangeTypes ( filteredChanges ) ; Object . keys ( calculatedChangeTypes ) . forEach ( packageName => { if ( ! packageInfos [ packageName ] ) { delete calculatedChangeTypes [ packageName ] ; } } ) ; return { calculatedChangeTypes , packageInfos , packageGroups : { } , changeFileChangeInfos : filteredChanges , modifiedPackages : new Set < string > ( ) , newPackages : new Set < string > ( ) , scopedPackages : new Set ( getScopedPackages ( options , packageInfos ) ) , dependentChangedBy : { } , groupOptions , dependents : { } , } ; } export function gatherBumpInfo ( options , packageInfos ) { const bumpInfo = gatherPreBumpInfo ( options , packageInfos ) ; bumpInPlace ( bumpInfo , options ) ; return bumpInfo ; }