Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compact-yarn-audit

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compact-yarn-audit - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

62

dist/terse-advisory-to-table.js

@@ -1,5 +0,5 @@

import textTable from "text-table";
import { EOL } from "node:os";
import chalk from "chalk";
import stripAnsi from "strip-ansi";
function colorSeverity(pSeverity) {
function colorBySeverity(pSeverity, pString) {
const lSeverity2ChalkFunction = new Map([

@@ -12,27 +12,41 @@ ["critical", chalk.red],

const lFunction = lSeverity2ChalkFunction.get(pSeverity) || ((pX) => pX);
return lFunction(pSeverity);
return lFunction(pString);
}
function tableTheThing(pMaxTitleWidth) {
return (pAll, pExtractedLogEntry) => {
pAll.push([
colorSeverity(pExtractedLogEntry.severity),
pExtractedLogEntry.title.slice(0, Math.max(0, pMaxTitleWidth)),
pExtractedLogEntry.module_name,
pExtractedLogEntry.via,
pExtractedLogEntry.fixString,
]);
return pAll;
};
function getColumnWidth(pTerseEntries, pColumnName) {
return pTerseEntries.reduce((pAll, pEntry) => Math.max(pAll, stripAnsi(pEntry[pColumnName]).length), 0);
}
function getColumnWidths(pTerseEntries, pWidthAvailable) {
const lColumns = ["severity", "title", "module_name", "via", "fixString"];
const lReturnValue = new Map(lColumns.map((pColumn) => {
return [pColumn, getColumnWidth(pTerseEntries, pColumn)];
}));
const lAllColumnsLength = Array.from(lReturnValue.values()).reduce((pAll, pLength) => {
return pAll + pLength;
}, 0);
const lMinimumTitleColumnWidth = 14;
const lSpacesPerColumn = 2;
const lAvailableForTitle = Math.min(lReturnValue.get("title"), Math.max(lMinimumTitleColumnWidth, pWidthAvailable -
(lAllColumnsLength - lReturnValue.get("title")) -
lSpacesPerColumn * lColumns.length));
lReturnValue.set("title", lAvailableForTitle);
return lReturnValue;
}
export function terseAdvisoryLog2Table(pTerseEntries, pColumnsAvailable = process.stdout.columns) {
const lTable = [
["severity", "title", "module", "via", '"resolutions" string'].map((pHeader) => chalk.bold(pHeader)),
];
const lTableOptions = {
align: ["l", "l", "l", "l", "l", "l"],
stringLength: (pString) => stripAnsi(pString).length,
};
const lTitleMagicDivisionFactor = 5;
const lMaxTitleWidth = Math.round(pColumnsAvailable / lTitleMagicDivisionFactor);
return textTable(pTerseEntries.reduce(tableTheThing(lMaxTitleWidth), lTable), lTableOptions);
const lColumnWidths = getColumnWidths(pTerseEntries, pColumnsAvailable);
const lTitle = chalk.bold(`${"severity".padEnd(lColumnWidths.get("severity"))} ` +
`${"title".padEnd(lColumnWidths.get("title"))} ` +
`${"module".padEnd(lColumnWidths.get("module_name"))} ` +
`${"via".padEnd(lColumnWidths.get("via"))} ` +
`"resolutions" string`);
const lCells = pTerseEntries
.map((pEntry) => {
return (`${colorBySeverity(pEntry.severity, `${pEntry.severity.padEnd(lColumnWidths.get("severity"))} `)}${pEntry.title
.padEnd(lColumnWidths.get("title"))
.slice(0, lColumnWidths.get("title"))} ` +
`${pEntry.module_name.padEnd(lColumnWidths.get("module_name"))} ` +
`${pEntry.via.padEnd(lColumnWidths.get("via"))} ` +
`${pEntry.fixString}`);
})
.join(EOL);
return lTitle + EOL + lCells;
}
{
"name": "compact-yarn-audit",
"version": "3.0.1",
"version": "3.0.2",
"description": "Presents output from yarn audit in a compact table",

@@ -34,3 +34,4 @@ "engines": {

"scm:stage": "git add .",
"test": "NODE_OPTIONS=--no-warnings c8 mocha",
"test": "c8 node --no-warnings --loader 'ts-node/esm' --test-reporter dot --test src/*.test.ts",
"test:only-for-node-16-without-the-test-reporter": "node --no-warnings --loader 'ts-node/esm' --test src/*.test.ts",
"update-dependencies": "npm-run-all upem:update upem:install format test",

@@ -49,4 +50,3 @@ "upem-outdated": "npm outdated --json --long | upem --dry-run",

"ndjson": "^2.0.0",
"strip-ansi": "^7.1.0",
"text-table": "^0.2.0"
"strip-ansi": "^7.1.0"
},

@@ -60,21 +60,18 @@ "overrides": {

"devDependencies": {
"@types/mocha": "10.0.1",
"@types/ndjson": "2.0.1",
"@types/text-table": "0.2.2",
"@typescript-eslint/eslint-plugin": "5.60.1",
"@typescript-eslint/parser": "5.60.1",
"c8": "8.0.0",
"eslint": "8.43.0",
"@typescript-eslint/eslint-plugin": "6.2.0",
"@typescript-eslint/parser": "6.2.0",
"c8": "8.0.1",
"eslint": "8.46.0",
"eslint-config-moving-meadow": "4.0.2",
"eslint-config-prettier": "8.8.0",
"eslint-config-prettier": "8.9.0",
"eslint-plugin-budapestian": "5.0.1",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-import": "2.28.0",
"eslint-plugin-mocha": "10.1.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-security": "1.7.1",
"eslint-plugin-unicorn": "47.0.0",
"mocha": "10.2.0",
"eslint-plugin-unicorn": "48.0.1",
"npm-run-all": "4.1.5",
"prettier": "2.8.8",
"prettier": "3.0.0",
"ts-node": "10.9.1",

@@ -81,0 +78,0 @@ "typescript": "5.1.6",

[![GitHub Workflow Status](https://github.com/sverweij/compact-yarn-audit/actions/workflows/ci.yml/badge.svg)](https://github.com/sverweij/compact-yarn-audit/actions/workflows/ci.yml)
[![Known Vulnerabilities](https://snyk.io/test/github/sverweij/compact-yarn-audit/badge.svg?targetFile=package.json)](https://snyk.io/test/github/sverweij/compact-yarn-audit?targetFile=package.json)
[![npm stable version](https://img.shields.io/npm/v/compact-yarn-audit.svg?logo=npm)](https://npmjs.com/package/compact-yarn-audit)

@@ -4,0 +3,0 @@ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc