import type { PackageManifest } from "@rnx-kit/tools-node/package" ; import semver from "semver" ; import banned from "./profiles/banned" ; import type { ExcludedPackage } from "./types" ; function isBanned ( name , version ) { const info = banned . find ( ( pkg ) => pkg . name === name ) ; return info && semver . subset ( version , info . version ) ? info : undefined ; } export function findBadPackages ( { dependencies , peerDependencies , devDependencies , } ) { const foundBadPackages = [ dependencies , peerDependencies , devDependencies , ] . reduce < Set < ExcludedPackage > > ( ( badPackages , deps ) => { if ( deps ) { Object . keys ( deps ) . reduce ( ( result , name ) => { const info = isBanned ( name , deps [ name ] ) ; if ( info ) { result . add ( info ) ; } return result ; } , badPackages ) ; } return badPackages ; } , new Set < ExcludedPackage > ( ) ) ; return foundBadPackages . size > 0 ? Array . from ( foundBadPackages ) : undefined ; }