import { isFromConfigKit } from './config-name-helpers' ; import { isDependencyMeaningful } from './dependency-guards' ; import { MeaningfulDependency } from './shared-types' ; interface Params { requiredDependencies ? : MeaningfulDependency [ ] ; installedDependencies ? : string [ ] ; wrongDependenciesToUpdate : MeaningfulDependency [ ] ; } export function getDependenciesToDelete ( { requiredDependencies , installedDependencies , wrongDependenciesToUpdate , } ) { if ( ! requiredDependencies || ! installedDependencies ) { return wrongDependenciesToUpdate ; } const requiredDependenciesSet = new Set ( requiredDependencies ) ; return ( installedDependencies . filter ( isDependencyMeaningful ) . filter ( ( dependency ) => { return ! requiredDependenciesSet . has ( dependency ) ; } ) . filter ( isFromConfigKit ) . concat ( wrongDependenciesToUpdate ) ) ; }