@@ -83,9 +83,9 @@ type Explanation = {
8383} | null
8484
8585type InstallEffect = {
86- existing : NodeClass [ 'pkgid' ] | null
8786 pkgid : NodeClass [ 'pkgid' ]
8887 repository_url : string
88+ existing ?: NodeClass [ 'pkgid' ] | undefined
8989}
9090
9191type IssueUXLookup = ReturnType < typeof createAlertUXLookup >
@@ -487,22 +487,18 @@ async function getPackagesAlerts(
487487 } )
488488 // Before we ask about problematic issues, check to see if they
489489 // already existed in the old version if they did, be quiet.
490- const pkg = pkgs . find (
491- p => p . pkgid === id && p . existing ?. startsWith ( `${ name } @` )
492- )
493- if ( pkg ?. existing ) {
494- // const oldArtifact: SocketArtifact =
495- // // eslint-disable-next-line no-await-in-loop
496- // (await batchScan([pkg.existing]).next()).value
497- // console.log('oldArtifact', oldArtifact)
498- // if (oldArtifact.type === 'success') {
499- // issues = issues.filter(
500- // ({ type }) =>
501- // oldPkgData.value.issues.find(
502- // oldIssue => oldIssue.type === type
503- // ) === undefined
504- // )
505- // }
490+ const existing = pkgs . find ( p =>
491+ p . existing ?. startsWith ( `${ name } @` )
492+ ) ?. existing
493+ if ( existing ) {
494+ const oldArtifact : SocketArtifact | undefined =
495+ // eslint-disable-next-line no-await-in-loop
496+ ( await batchScan ( [ existing ] ) . next ( ) ) . value
497+ if ( oldArtifact ?. alerts ?. length ) {
498+ alerts = alerts . filter (
499+ ( { type } ) => ! oldArtifact . alerts ?. find ( a => a . type === type )
500+ )
501+ }
506502 }
507503 }
508504 }
@@ -580,31 +576,35 @@ function walk(
580576 if ( ! diff ) {
581577 continue
582578 }
583- if ( diff . action ) {
584- const sameVersion =
585- diff . actual ?. package . version === diff . ideal ?. package . version
579+ const { action } = diff
580+ if ( action ) {
581+ const oldNode = diff . actual
582+ const oldPkgid = oldNode ?. pkgid
583+ const pkgNode = diff . ideal
584+ const pkgid = pkgNode ?. pkgid
585+
586+ let existing
586587 let keep = false
587- let existing = null
588- if ( diff . action === 'CHANGE' ) {
589- if ( ! sameVersion ) {
590- existing = diff . actual . pkgid
588+ if ( action === 'CHANGE' ) {
589+ if ( pkgNode ?. package . version !== oldNode ?. package . version ) {
591590 keep = true
591+ if (
592+ oldNode ?. package . name &&
593+ oldNode . package . name === pkgNode ?. package . name
594+ ) {
595+ existing = oldPkgid
596+ }
592597 } else {
593598 // console.log('SKIPPING META CHANGE ON', diff)
594599 }
595600 } else {
596- keep = diff . action !== 'REMOVE'
601+ keep = action !== 'REMOVE'
597602 }
598- if (
599- keep &&
600- diff . ideal ?. pkgid &&
601- diff . ideal . resolved &&
602- ( ! diff . actual || diff . actual . resolved )
603- ) {
603+ if ( keep && pkgid && pkgNode . resolved && ( ! oldNode || oldNode . resolved ) ) {
604604 needInfoOn . push ( {
605605 existing,
606- pkgid : diff . ideal . pkgid ,
607- repository_url : toRepoUrl ( diff . ideal . resolved )
606+ pkgid,
607+ repository_url : toRepoUrl ( pkgNode . resolved )
608608 } )
609609 }
610610 }
0 commit comments