compact-yarn-audit
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "compact-yarn-audit", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Presents output from yarn audit in a compact table", | ||
@@ -35,4 +35,4 @@ "engines": { | ||
"chalk": "^2.4.0", | ||
"get-stream": "^6.0.1", | ||
"lodash.uniqby": "^4.7.0", | ||
"ndjson": "^2.0.0", | ||
"strip-ansi": "^7.0.0", | ||
@@ -39,0 +39,0 @@ "text-table": "^0.2.0" |
@@ -8,5 +8,9 @@ ## What's this? | ||
```sh | ||
yarn audit --json | npx tersify-yarn-audit | ||
yarn audit --json | npx compact-yarn-audit | ||
``` | ||
> Note: yarn's audit output can be quite large (gigabytes for a sizeable | ||
> monorepo that hasn't had updates for a while), so it can take | ||
> some time to process all that data. | ||
## Sample output | ||
@@ -13,0 +17,0 @@ |
#!/usr/bin/env node | ||
import getStream from "get-stream"; | ||
import { terseLog } from "./log-to-terse-object.js"; | ||
import ndjson from "ndjson"; | ||
import { sortLog, extractUsefulAttributes } from "./log-to-terse-object.js"; | ||
import { terseLog2Table } from "./terse-object-to-table.js"; | ||
getStream(process.stdin) | ||
.then((pLog) => { | ||
const lTerseLog = terseLog(pLog); | ||
console.log(terseLog2Table(lTerseLog)); | ||
let lLog = []; | ||
process.stdin | ||
.pipe(ndjson.parse()) | ||
.on("data", (pLogEntry) => { | ||
if (pLogEntry.type === "auditAdvisory") { | ||
lLog.push(extractUsefulAttributes(pLogEntry)); | ||
} | ||
}) | ||
.catch((pError) => { | ||
.on("error", (pError) => { | ||
console.error(pError); | ||
process.exitCode = 1; | ||
process.exit(); | ||
}) | ||
.on("end", () => { | ||
console.log(terseLog2Table(sortLog(lLog))); | ||
}); |
import uniqBy from "lodash.uniqby"; | ||
function auditLog2Object(pAuditLog) { | ||
return JSON.parse(`[${pAuditLog.split("\n").join(",")}]`.replace(",]", "]")); | ||
} | ||
function extractUsefulAttributesFromLogEntry(pLogEntry) { | ||
const lFixable = pLogEntry.data.advisory.patched_versions !== "<0.0.0"; | ||
const lVia = pLogEntry.data.resolution.path.split(">").shift(); | ||
return { | ||
severity: pLogEntry.data.advisory.severity, | ||
title: pLogEntry.data.advisory.title, | ||
fixable: lFixable, | ||
fixString: lFixable | ||
? `"${pLogEntry.data.advisory.module_name}": "${pLogEntry.data.advisory.patched_versions}"` | ||
: "no fix available", | ||
module_name: pLogEntry.data.advisory.module_name, | ||
via: lVia === pLogEntry.data.advisory.module_name ? "." : lVia, | ||
}; | ||
} | ||
function severity2Order(pSeverity) { | ||
@@ -34,4 +14,2 @@ const lSeverity2Order = { | ||
function unique(pTerseEntries) {} | ||
function sortEntry(pEntryLeft, pEntryRight) { | ||
@@ -47,10 +25,21 @@ return `${severity2Order(pEntryLeft.severity)}|${pEntryLeft.module_name}` > | ||
} | ||
export function terseLog(pLog) { | ||
return uniqBy( | ||
auditLog2Object(pLog) | ||
.filter((pLogEntry) => pLogEntry.type === "auditAdvisory") | ||
.map(extractUsefulAttributesFromLogEntry) | ||
.sort(sortEntry), | ||
wholeRecordAsString | ||
); | ||
export function sortLog(pLog) { | ||
return uniqBy(pLog.sort(sortEntry), wholeRecordAsString); | ||
} | ||
export function extractUsefulAttributes(pLogEntry) { | ||
const lFixable = pLogEntry.data.advisory.patched_versions !== "<0.0.0"; | ||
const lVia = pLogEntry.data.resolution.path.split(">").shift(); | ||
return { | ||
severity: pLogEntry.data.advisory.severity, | ||
title: pLogEntry.data.advisory.title, | ||
fixable: lFixable, | ||
fixString: lFixable | ||
? `"${pLogEntry.data.advisory.module_name}": "${pLogEntry.data.advisory.patched_versions}"` | ||
: "no fix available", | ||
module_name: pLogEntry.data.advisory.module_name, | ||
via: lVia === pLogEntry.data.advisory.module_name ? "." : lVia, | ||
}; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7208
57
92
+ Addedndjson@^2.0.0
+ Addedinherits@2.0.4(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedndjson@2.0.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsplit2@3.2.2(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedthrough2@4.0.2(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedget-stream@^6.0.1
- Removedget-stream@6.0.1(transitive)