Skip to content
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.

Commit

Permalink
main - Add a bunch of ugly checks for things, run build
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Lemmon committed Dec 4, 2020
1 parent 55dbd27 commit 646ebb4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
42 changes: 24 additions & 18 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,25 +852,29 @@ module.exports = /******/ (function (modules, runtime) {

/***/ 197: /***/ function (module) {
// TODO: can't this be done within the GraphQL query itself?
// This is really fugly as a result...
function formatVulnerabilityAlerts(data) {
console.log('data', data)
// const {
// repository: {
// vulnerabilityAlerts: { edges },
// },
// } = data

// return edges.map(edge => {
// const advisory = edge.node.securityAdvisory
// const { vulnerabilities, ...rest } = advisory
// const firstVulnerabilityNode = vulnerabilities.edges[0].node
// const vulnerableVersionRange = firstVulnerabilityNode.vulnerableVersionRange

// return {
// ...rest,
// versionRange: vulnerableVersionRange,
// }
// })
const { repository } = data

if (!repository) return console.log('No repository found')

const { vulnerabilityAlerts } = repository

if (!vulnerabilityAlerts) return console.log('No vulnerability alerts found')

const { edges } = vulnerabilityAlerts

return edges.map(edge => {
const advisory = edge.node.securityAdvisory
const { vulnerabilities, ...rest } = advisory
const firstVulnerabilityNode = vulnerabilities.edges[0].node
const vulnerableVersionRange = firstVulnerabilityNode.vulnerableVersionRange

return {
...rest,
versionRange: vulnerableVersionRange,
}
})
}

module.exports = {
Expand Down Expand Up @@ -3022,6 +3026,8 @@ module.exports = /******/ (function (modules, runtime) {
const { data } = await getSecurityVulnerabilities()
const vulnerabilityAlerts = formatVulnerabilityAlerts(data)

if (!vulnerabilityAlerts) return console.log('No security vulnerabilities found.')

if (vulnerabilityAlerts.length > 0) {
const introMsg = getIntroMsg(vulnerabilityAlerts.length)

Expand Down
36 changes: 20 additions & 16 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
// TODO: can't this be done within the GraphQL query itself?
// This is really fugly as a result...
function formatVulnerabilityAlerts(data) {
console.log('data', data)
// const {
// repository: {
// vulnerabilityAlerts: { edges },
// },
// } = data
const { repository } = data

// return edges.map(edge => {
// const advisory = edge.node.securityAdvisory
// const { vulnerabilities, ...rest } = advisory
// const firstVulnerabilityNode = vulnerabilities.edges[0].node
// const vulnerableVersionRange = firstVulnerabilityNode.vulnerableVersionRange
if (!repository) return console.log('No repository found')

// return {
// ...rest,
// versionRange: vulnerableVersionRange,
// }
// })
const { vulnerabilityAlerts } = repository

if (!vulnerabilityAlerts) return console.log('No vulnerability alerts found')

const { edges } = vulnerabilityAlerts

return edges.map(edge => {
const advisory = edge.node.securityAdvisory
const { vulnerabilities, ...rest } = advisory
const firstVulnerabilityNode = vulnerabilities.edges[0].node
const vulnerableVersionRange = firstVulnerabilityNode.vulnerableVersionRange

return {
...rest,
versionRange: vulnerableVersionRange,
}
})
}

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ async function start() {
const { data } = await getSecurityVulnerabilities()
const vulnerabilityAlerts = formatVulnerabilityAlerts(data)

if (!vulnerabilityAlerts) return console.log('No security vulnerabilities found.')

if (vulnerabilityAlerts.length > 0) {
const introMsg = getIntroMsg(vulnerabilityAlerts.length)

Expand Down

0 comments on commit 646ebb4

Please sign in to comment.