@@ -394,22 +394,40 @@ async function packagesHaveRiskyIssues(
394
394
const id = `${ name } @${ version } `
395
395
396
396
let displayWarning = false
397
- let failures : { block ?: boolean ; raw ?: any ; type ?: string } [ ] = [ ]
397
+ let failures : {
398
+ type : string
399
+ block : boolean
400
+ raw ?: any
401
+ } [ ] = [ ]
398
402
if ( pkgData . type === 'missing' ) {
399
403
result = true
400
404
failures . push ( {
401
- type : 'missingDependency'
405
+ type : 'missingDependency' ,
406
+ block : false ,
407
+ raw : undefined
402
408
} )
403
409
} else {
404
410
let blocked = false
405
411
for ( const failure of pkgData . value . issues ) {
412
+ const { type } = failure
406
413
// eslint-disable-next-line no-await-in-loop
407
414
const ux = await uxLookup ( {
408
415
package : { name, version } ,
409
- issue : { type : failure . type }
416
+ issue : { type }
410
417
} )
411
- if ( ux . display || ux . block ) {
412
- failures . push ( { raw : failure , block : ux . block } )
418
+ if ( ux . block ) {
419
+ result = true
420
+ blocked = true
421
+ }
422
+ if ( ux . display ) {
423
+ displayWarning = true
424
+ }
425
+ if ( ux . block || ux . display ) {
426
+ failures . push ( {
427
+ type,
428
+ block : ux . block ,
429
+ raw : failure
430
+ } )
413
431
// Before we ask about problematic issues, check to see if they
414
432
// already existed in the old version if they did, be quiet.
415
433
const pkg = pkgs . find (
@@ -422,20 +440,13 @@ async function packagesHaveRiskyIssues(
422
440
failures = failures . filter (
423
441
issue =>
424
442
oldPkgData . value . issues . find (
425
- oldIssue => oldIssue . type === issue . raw . type
426
- ) == null
443
+ oldIssue => oldIssue . type === issue . type
444
+ ) === undefined
427
445
)
428
446
}
429
447
}
430
448
}
431
449
}
432
- if ( ux . block ) {
433
- result = true
434
- blocked = true
435
- }
436
- if ( ux . display ) {
437
- displayWarning = true
438
- }
439
450
}
440
451
if ( ! blocked ) {
441
452
const pkg = pkgs . find ( p => p . pkgid === id )
@@ -455,20 +466,30 @@ async function packagesHaveRiskyIssues(
455
466
spinner . stop (
456
467
`(socket) ${ formatter . hyperlink ( id , `https://socket.dev/npm/package/${ name } /overview/${ version } ` ) } contains risks:`
457
468
)
458
- failures . sort ( ( a , b ) => ( a . raw . type < b . raw . type ? - 1 : 1 ) )
469
+ // Filter issues for blessed packages.
470
+ if (
471
+ name === 'socket' ||
472
+ name . startsWith ( '@socketregistry/' ) ||
473
+ name . startsWith ( '@socketsecurity/' )
474
+ ) {
475
+ failures = failures . filter (
476
+ ( { type } ) =>
477
+ type !== 'unpopularPackage' && type !== 'unstableOwnership'
478
+ )
479
+ }
480
+ failures . sort ( ( a , b ) => ( a . type < b . type ? - 1 : 1 ) )
481
+
459
482
const lines = new Set ( )
460
483
for ( const failure of failures ) {
461
- const type = failure . raw . type
462
- if ( type ) {
463
- // Based data from { pageProps: { alertTypes } } of:
464
- // https://socket.dev/_next/data/94666139314b6437ee4491a0864e72b264547585/en-US.json
465
- const info = translations . issues [ type ]
466
- const title = info ?. title ?? type
467
- const maybeBlocking = failure . block ? '' : ' (non-blocking)'
468
- const maybeDesc = info ?. description ? ` - ${ info . description } ` : ''
469
- // TODO: emoji seems to mis-align terminals sometimes
470
- lines . add ( ` ${ title } ${ maybeBlocking } ${ maybeDesc } \n` )
471
- }
484
+ const { type } = failure
485
+ // Based data from { pageProps: { alertTypes } } of:
486
+ // https://socket.dev/_next/data/94666139314b6437ee4491a0864e72b264547585/en-US.json
487
+ const info = translations . issues [ type ]
488
+ const title = info ?. title ?? type
489
+ const maybeBlocking = failure . block ? '' : ' (non-blocking)'
490
+ const maybeDesc = info ?. description ? ` - ${ info . description } ` : ''
491
+ // TODO: emoji seems to mis-align terminals sometimes
492
+ lines . add ( ` ${ title } ${ maybeBlocking } ${ maybeDesc } \n` )
472
493
}
473
494
for ( const line of lines ) {
474
495
output ?. write ( line )
0 commit comments