Skip to content

Commit

Permalink
Render issues
Browse files Browse the repository at this point in the history
  • Loading branch information
charliegerard committed Nov 13, 2023
1 parent edf65a6 commit c050b04
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/commands/info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ async function fetchPackageData (pkgName, pkgVersion, { includeAllIssues, strict
if (objectSome(severityCount)) {
const issueSummary = formatSeverityCount(severityCount)
spinner[strict ? 'fail' : 'succeed'](`Package has these issues: ${issueSummary}`)

// Return the alert types for critical and high alerts
const issueDetails = result.data.filter(d => d.value?.severity === 'high' || d.value?.severity === 'critical')
const uniqueIssues = issueDetails.reduce((/** @type {{ [key: string]: number }} */ acc, issue) => {
const { type } = issue
if (type) {
let count = 0
if (!acc[type]) {
count += 1
acc[type] = count
} else {
acc[type]++
}
}
return acc
}, {})
Object.keys(uniqueIssues).map(issue => {
if (uniqueIssues[issue] === 1) {
return console.log(`- ${issue}`)
}
return console.log(`- ${issue}: ${uniqueIssues[issue]}`)
})
} else {
spinner.succeed('Package has no issues')
}
Expand All @@ -165,7 +187,7 @@ async function fetchPackageData (pkgName, pkgVersion, { includeAllIssues, strict
if (outputJson) {
console.log(JSON.stringify(data, undefined, 2))
} else {
console.log('\nPackage report card:\n')
console.log('\nPackage report card:')

const scoreResult = {
'Supply Chain Risk': Math.floor(score.supplyChainRisk.score * 100),
Expand Down

0 comments on commit c050b04

Please sign in to comment.