(npm, arb, extras = {})
| 19 | const { configSetAllowScripts } = require('./allow-scripts-remediation.js') |
| 20 | |
| 21 | const reifyOutput = (npm, arb, extras = {}) => { |
| 22 | const { diff, actualTree } = arb |
| 23 | const unreviewedScripts = extras.unreviewedScripts || [] |
| 24 | |
| 25 | // note: fails and crashes if we're running audit fix and there was an error which is a good thing, because there's no point printing all this other stuff in that case! |
| 26 | const auditReport = auditError(npm, arb.auditReport) ? null : arb.auditReport |
| 27 | |
| 28 | // don't print any info in --silent mode, but we still need to set the exitCode properly from the audit report, if we have one. |
| 29 | if (npm.silent) { |
| 30 | getAuditReport(npm, auditReport) |
| 31 | return |
| 32 | } |
| 33 | |
| 34 | const summary = { |
| 35 | add: [], |
| 36 | added: 0, |
| 37 | // audit gets added later |
| 38 | audited: auditReport && !auditReport.error ? actualTree.inventory.size : 0, |
| 39 | change: [], |
| 40 | changed: 0, |
| 41 | funding: 0, |
| 42 | remove: [], |
| 43 | removed: 0, |
| 44 | } |
| 45 | |
| 46 | if (diff) { |
| 47 | const showDiff = npm.config.get('dry-run') || npm.config.get('long') |
| 48 | const chalk = npm.chalk |
| 49 | |
| 50 | depth({ |
| 51 | tree: diff, |
| 52 | visit: d => { |
| 53 | switch (d.action) { |
| 54 | case 'REMOVE': |
| 55 | if (showDiff) { |
| 56 | output.standard(`${chalk.blue('remove')} ${d.actual.name} ${d.actual.package.version}`) |
| 57 | } |
| 58 | summary.removed++ |
| 59 | summary.remove.push({ |
| 60 | name: d.actual.name, |
| 61 | version: d.actual.package.version, |
| 62 | path: d.actual.path, |
| 63 | }) |
| 64 | break |
| 65 | case 'ADD': |
| 66 | if (showDiff) { |
| 67 | output.standard(`${chalk.green('add')} ${d.ideal.name} ${d.ideal.package.version}`) |
| 68 | } |
| 69 | if (actualTree.inventory.has(d.ideal)) { |
| 70 | summary.added++ |
| 71 | summary.add.push({ |
| 72 | name: d.ideal.name, |
| 73 | version: d.ideal.package.version, |
| 74 | path: d.ideal.path, |
| 75 | }) |
| 76 | } |
| 77 | break |
| 78 | case 'CHANGE': |
no test coverage detected
searching dependent graphs…