import { logger } from '../../logger' ; import type { RangeStrategy } from '../../types' ; import type { RangeConfig } from '../types' ; import type { ComposerManagerData } from './types' ; export function getRangeStrategy ( config ) { const { managerData = { } , depType , depName , currentValue , rangeStrategy , } = config ; const { composerJsonType } = managerData as ComposerManagerData ; const isComplexRange = currentValue ?. includes ( ' || ' ) ; if ( rangeStrategy === 'bump' && isComplexRange ) { logger . debug ( { currentValue } , 'Replacing bump strategy for complex range with widen' ) ; return 'widen' ; } if ( rangeStrategy !== 'auto' ) { return rangeStrategy ; } if ( depType === 'require-dev' ) { logger . trace ( { dependency : depName } , 'Pinning require-dev' ) ; return 'pin' ; } const isApp = composerJsonType && ! [ 'library' , 'metapackage' , 'composer-plugin' ] . includes ( composerJsonType ) ; if ( isApp && depType === 'require' ) { logger . trace ( { dependency : depName } , 'Pinning app require' ) ; return 'pin' ; } if ( isComplexRange ) { return 'widen' ; } return 'replace' ; }