Socket
Socket
Sign inDemoInstall

dependency-cruiser

Package Overview
Dependencies
Maintainers
1
Versions
533
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-cruiser - npm Package Compare versions

Comparing version 1.9.2 to 1.9.3

src/extract/summarize.js

8

package.json
{
"name": "dependency-cruiser",
"version": "1.9.2",
"version": "1.9.3",
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",

@@ -40,3 +40,3 @@ "bin": {

"istanbul": "0.4.5",
"js-makedepend": "2.0.0",
"js-makedepend": "2.0.1",
"mocha": "3.2.0",

@@ -55,6 +55,6 @@ "npm-check-updates": "2.8.8",

"dependencies": {
"acorn": "4.0.3",
"acorn": "4.0.4",
"ajv": "4.10.0",
"chalk": "1.1.3",
"coffee-script": "1.12.1",
"coffee-script": "1.12.2",
"commander": "2.9.0",

@@ -61,0 +61,0 @@ "figures": "2.0.0",

"use strict";
const _ = require('lodash');
const _ = require('lodash');
const extract = require('./extract');
const gather = require('./gatherInitialSources');
const extract = require('./extract');
const gather = require('./gatherInitialSources');
const summarize = require('./summarize');

@@ -82,44 +83,2 @@ function extractRecursive (pFileName, pOptions, pVisited) {

function cutNonTransgressions(pSourceEntry) {
return {
source: pSourceEntry.source,
dependencies: pSourceEntry.dependencies.filter(pDep => pDep.valid === false)
};
}
function addSource(pSource) {
return pDependency => Object.assign(
{
from: pSource,
to: pDependency.resolved,
rule: pDependency.rule
}
);
}
function extractMetaData(pViolations) {
return pViolations.reduce(
(pAll, pThis) => {
pAll[pThis.rule.severity] += 1;
return pAll;
}
, {
error : 0,
warn : 0,
info : 0
}
);
}
function extractViolations(pInput){
return pInput
.map(cutNonTransgressions)
.filter(pDep => pDep.dependencies.length > 0)
.sort((pOne, pTwo) => pOne.source > pTwo.source ? 1 : -1)
.reduce(
(pAll, pThis) => pAll.concat(pThis.dependencies.map(addSource(pThis.source))),
[]
);
}
function makeOptionsPresentable(pOptions) {

@@ -150,3 +109,3 @@ const SHARABLE_OPTIONS = [

module.exports = (pFileDirArray, pOptions, pCallback) => {
let lCallback = pCallback ? pCallback : (pInput => pInput);
const lCallback = pCallback ? pCallback : (pInput => pInput);

@@ -157,3 +116,2 @@ const lDependencies = _(

.value();
const lViolations = extractViolations(lDependencies);

@@ -165,7 +123,4 @@ return lCallback(

Object.assign(
summarize(lDependencies),
{
violations : lViolations
},
extractMetaData(lViolations),
{
optionsUsed: makeOptionsPresentable(pOptions)

@@ -172,0 +127,0 @@ }

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