import { parseRange } from 'semver-utils' ; import { logger } from '../../logger' ; import type { RangeStrategy } from '../../types' ; import type { RangeConfig } from '../types' ; export function getRangeStrategy ( config ) { const { depType , depName , packageJsonType , currentValue , rangeStrategy } = config ; const isComplexRange = parseRange ( currentValue ) . length > 1 ; if ( rangeStrategy === 'bump' && isComplexRange ) { logger . debug ( { currentValue } , 'Replacing bump strategy for complex range with widen' ) ; return 'widen' ; } if ( rangeStrategy !== 'auto' ) { return rangeStrategy ; } if ( depType === 'devDependencies' ) { logger . trace ( { dependency : depName } , 'Pinning devDependency' ) ; return 'pin' ; } if ( depType === 'dependencies' && packageJsonType === 'app' ) { logger . trace ( { dependency : depName } , 'Pinning app dependency' ) ; return 'pin' ; } if ( depType === 'peerDependencies' ) { logger . debug ( 'Widening peer dependencies' ) ; return 'widen' ; } if ( isComplexRange ) { return 'widen' ; } return 'replace' ; }