@@ -83,9 +83,9 @@ type Explanation = {
83
83
} | null
84
84
85
85
type InstallEffect = {
86
- existing : NodeClass [ 'pkgid' ] | null
87
86
pkgid : NodeClass [ 'pkgid' ]
88
87
repository_url : string
88
+ existing ?: NodeClass [ 'pkgid' ] | undefined
89
89
}
90
90
91
91
type IssueUXLookup = ReturnType < typeof createAlertUXLookup >
@@ -487,22 +487,18 @@ async function getPackagesAlerts(
487
487
} )
488
488
// Before we ask about problematic issues, check to see if they
489
489
// 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
+ }
506
502
}
507
503
}
508
504
}
@@ -580,31 +576,35 @@ function walk(
580
576
if ( ! diff ) {
581
577
continue
582
578
}
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
586
587
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 ) {
591
590
keep = true
591
+ if (
592
+ oldNode ?. package . name &&
593
+ oldNode . package . name === pkgNode ?. package . name
594
+ ) {
595
+ existing = oldPkgid
596
+ }
592
597
} else {
593
598
// console.log('SKIPPING META CHANGE ON', diff)
594
599
}
595
600
} else {
596
- keep = diff . action !== 'REMOVE'
601
+ keep = action !== 'REMOVE'
597
602
}
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 ) ) {
604
604
needInfoOn . push ( {
605
605
existing,
606
- pkgid : diff . ideal . pkgid ,
607
- repository_url : toRepoUrl ( diff . ideal . resolved )
606
+ pkgid,
607
+ repository_url : toRepoUrl ( pkgNode . resolved )
608
608
} )
609
609
}
610
610
}
0 commit comments