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

dependency-cruiser

Package Overview
Dependencies
Maintainers
1
Versions
536
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.8.0 to 1.9.0

80

CODE_OF_CONDUCT.md

@@ -1,23 +0,40 @@

# Contributor Code of Conduct
# Contributor Covenant Code of Conduct
As contributors and maintainers of this project, and in the interest of
fostering an open and welcoming community, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating
documentation, submitting pull requests or patches, and other activities.
## Our Pledge
We are committed to making participation in this project a harassment-free
experience for everyone, regardless of level of experience, gender, gender
identity and expression, sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing other's private information, such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or

@@ -29,23 +46,30 @@ reject comments, commits, code, wiki edits, issues, and other contributions

By adopting this Code of Conduct, project maintainers commit themselves to
fairly and consistently applying these principles to every aspect of managing
this project. Project maintainers who do not follow or enforce the Code of
Conduct may be permanently removed from the project team.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting a project maintainer at **[sverweij@yandex.com](sverweij@yandex.com)**. All
reported by contacting the project team at **[sverweij@yandex.com](sverweij@yandex.com)**. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. Maintainers are
obligated to maintain confidentiality with regard to the reporter of an
incident.
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.3.0, available at
[http://contributor-covenant.org/version/1/3/0/][version]
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/3/0/
[version]: http://contributor-covenant.org/version/1/4/

@@ -30,12 +30,12 @@ ## Contributing

- Mocha tests prove your code does what it intends.
- Your code does not introduce regressions - ```make check``` proves this.
- Your code does not introduce regressions - ```make fullcheck``` proves
this.
- Code style (you know, petty things like indentations, where brackets go,
how variables & parameters are named) fits in with the current code base.
- Plan to do something drastic?
Contact @SanderSpeaks on Twitter, or leave an
[issue](https://github.com/sverweij/dependency-cruiser/issues/new) on GitHub
Leave an [issue](https://github.com/sverweij/dependency-cruiser/issues/new)
on GitHub
- dependency-cruiser is released with a [code of conduct](CODE_OF_CONDUCT.md), adapted
from the [contributor covenant](http://contributor-covenant.org/).
### Legal

@@ -46,3 +46,2 @@ - the code you add will be subject to

### Issue template

@@ -49,0 +48,0 @@ ### steps taken

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

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

"acorn": "4.0.3",
"ajv": "4.9.2",
"ajv": "4.10.0",
"chalk": "1.1.3",

@@ -58,0 +58,0 @@ "coffee-script": "1.12.1",

@@ -8,3 +8,3 @@ # Dependency cruiser ![Dependency cruiser](https://raw.githubusercontent.com/sverweij/dependency-cruiser/master/doc/assets/ZKH-Dependency-recolored-160.png)

- Run through the dependencies in any JavaScript, TypeScript or CoffeeScript project and ...
- ... **validate** them against a set of (your own) rules
- ... **validate** them against (your own) rules
- ... **report** violated rules

@@ -11,0 +11,0 @@ - in text (for in your builds)

@@ -20,7 +20,10 @@ "use strict";

.option("-v, --validate [file]", `validate with rules in [file]
(default: .dependency-cruiser.json)`)
.option("-f, --output-to <file>", "file to write output to; - for stdout (default: -)")
(default: .dependency-cruiser.json)`)
.option("-f, --output-to <file>", `file to write output to; - for stdout
(default: -)`)
.option("-x, --exclude <regex>", "a regular expression for excluding modules")
.option("-M, --system <items>", "list of module systems (default: amd,cjs,es6)")
.option("-T, --output-type <type>", "output type - html|dot|err|json (default:json)")
.option("-M, --system <items>", `list of module systems (default: amd,cjs,es6)`)
.option("-T, --output-type <type>", `output type - html|dot|err|json
(default:json)`)
.option("-P --prefix <prefix>")
.arguments("<files-or-directories>")

@@ -27,0 +30,0 @@ .parse(process.argv);

@@ -40,16 +40,9 @@ "use strict";

let lDependencyList = main(
pFileDirArray,
pOptions
);
let lExitCode = lDependencyList.metaData ? lDependencyList.metaData.error : 0;
const lDependencyList = main(pFileDirArray, pOptions);
write(
pOptions.outputTo,
lDependencyList.dependencies
);
write(pOptions.outputTo, lDependencyList.dependencies);
/* istanbul ignore if */
if (lExitCode > 0) {
process.exit(lExitCode);
if (lDependencyList.summary.error > 0) {
process.exit(lDependencyList.summary.error);
}

@@ -56,0 +49,0 @@

@@ -82,9 +82,91 @@ "use strict";

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) {
const SHARABLE_OPTIONS = [
"rulesFile",
"outputTo",
"exclude",
"system",
"outputType",
"prefix"
];
if (!Boolean(pOptions)){
return {};
}
return SHARABLE_OPTIONS
.filter(pOption => pOptions.hasOwnProperty(pOption))
.reduce(
(pAll, pOption) => {
pAll[pOption] = pOptions[pOption];
return pAll;
},
{}
);
}
module.exports = (pFileDirArray, pOptions, pCallback) => {
let lRetvalToTransform = {};
let lCallback = pCallback ? pCallback : pInput => ({dependencies: pInput, metaData: {}});
let lCallback = pCallback ? pCallback : (pInput => pInput);
lRetvalToTransform = extractFileDirArray(pFileDirArray, pOptions);
const lDependencies = extractFileDirArray(pFileDirArray, pOptions).reduce(complete, []);
const lViolations = extractViolations(lDependencies);
return lCallback(lRetvalToTransform.reduce(complete, []));
return lCallback(
{
dependencies : lDependencies,
summary :
Object.assign(
{
violations : lViolations
},
extractMetaData(lViolations),
{
optionsUsed: makeOptionsPresentable(pOptions)
}
)
}
);
};
/* eslint security/detect-object-injection: 0 */

@@ -5,9 +5,49 @@ {

"type": "object",
"required": [ "metaData", "dependencies" ],
"required": [ "summary", "dependencies" ],
"additionalProperties": false,
"properties": {
"metaData": {
"summary": {
"type": "object",
"description": "Data about the found dependencies",
"required": ["violations", "error", "warn", "info", "optionsUsed"],
"additionalProperties": false,
"description": "Data summarizing the found dependencies",
"properties": {
"violations": {
"type": "array",
"description": "A list of violations found in the dependencies. The dependencies themselves also contain this information, this summary is here for convenience.",
"items": {
"type": "object",
"required": ["from", "to", "rule"],
"additionalProperties": false,
"properties" : {
"from": {
"type": "string"
},
"to": {
"type": "string"
},
"rule": {
"type": "object",
"description": "If there was a rule violation (valid === false), this object contains the name of the rule and severity of violating it.",
"required": [ "name", "severity" ],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The (short, eslint style) name of the violated rule. Typically something like 'no-core-punycode' or 'no-outside-deps'."
},
"severity": {
"type": "string",
"enum": [
"error",
"warn",
"info"
],
"description": "The severity of the violation. Only errors make reporters return non-zero exit codes."
}
}
}
}
}
},
"error": {

@@ -24,2 +64,45 @@ "type": "number",

"description": "the number of informational level notices in the dependencies"
},
"optionsUsed": {
"type": "object",
"description": "the (command line) options used to generate the dependency-tree",
"additionalProperties": false,
"properties": {
"rulesFile": {
"type": "string",
"description": "The rules file used to validate the dependencies (if any)"
},
"outputTo": {
"type": "string",
"description": "File the output was written to ('-' for stdout)"
},
"exclude": {
"type": "string",
"description": "The regular expression used for excluding modules from being cruised"
},
"system": {
"type": "array",
"items": {
"type": "string",
"enum": [
"cjs",
"amd",
"es6"
]
}
},
"outputType": {
"type": "string",
"enum": [
"html",
"dot",
"err",
"json",
"vis"
]
},
"prefix": {
"type": "string"
}
}
}

@@ -26,0 +109,0 @@ }

"use strict";
const extract = require("../extract");
const reportHtml = require("../report/htmlReporter");
const reportJson = require("../report/jsonReporter");
const reportDot = require("../report/dotReporter");
const reportCsv = require("../report/csvReporter");
const reportErr = require("../report/errReporter");
const reportVis = require("../report/visReporter");
const extract = require("../extract");
const reportHtml = require("../report/htmlReporter");
const reportJson = require("../report/jsonReporter");
const reportDot = require("../report/dotReporter");
const reportCsv = require("../report/csvReporter");
const reportErr = require("../report/errReporter");
const reportVis = require("../report/visReporter");

@@ -48,10 +48,14 @@ const TYPE2REPORTER = {

* In all other cases: a javascript array with the dependencies
* metaData : meta data with a summary of
* { error : the number of errors,
* warn : the number of warnings,
* info : the number of informational messages
* }
* (meta is filled for 'err' only currently - NOTE: we'll change this to
* always return this in the near future)
* }
* summary : a summary of the violations found in the dependencies:
* {
* violations: each violation;
* from: the resolved 'from'
* to: the resolved 'to'
* rule: the violated rule, which consists of a
* name: the (short) name of the rule
* severity: the severetiy of the violation (error, warn or info)
* error : the number of errors,
* warn : the number of warnings,
* info : the number of informational messages
* }
*/

@@ -58,0 +62,0 @@ module.exports = (pFileDirArray, pOptions) => {

@@ -8,6 +8,11 @@ "use strict";

module.exports = (pInput) => ({
dependencies: Handlebars.templates['csv.template.hbs']({
"things" : dependencyToIncidenceTransformer.transform(pInput)
})
});
module.exports = pInput =>
Object.assign(
{},
pInput,
{
dependencies: Handlebars.templates['csv.template.hbs']({
"things" : dependencyToIncidenceTransformer.transform(pInput.dependencies)
})
}
);

@@ -37,2 +37,3 @@ var Handlebars = require("handlebars/runtime"); var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};

+ "\" URL=\""
+ ((stack1 = ((helper = (helper = helpers.prefix || (depth0 != null ? depth0.prefix : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"prefix","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ ((stack1 = ((helper = (helper = helpers.source || (depth0 != null ? depth0.source : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"source","hash":{},"data":data}) : helper))) != null ? stack1 : "")

@@ -59,6 +60,7 @@ + "\"]";

},"17":function(container,depth0,helpers,partials,data) {
var stack1, helper;
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function";
return " [URL=\""
+ ((stack1 = ((helper = (helper = helpers.source || (depth0 != null ? depth0.source : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"source","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ ((stack1 = ((helper = (helper = helpers.prefix || (depth0 != null ? depth0.prefix : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"prefix","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ ((stack1 = ((helper = (helper = helpers.source || (depth0 != null ? depth0.source : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"source","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "\"]";

@@ -65,0 +67,0 @@ },"19":function(container,depth0,helpers,partials,data,blockParams,depths) {

@@ -42,2 +42,3 @@ "use strict";

return Object.assign(
{},
pDependencyItem,

@@ -56,2 +57,3 @@ lAdditions

return Object.assign(
{},
pDependency,

@@ -64,2 +66,3 @@ lColorAddition

return Object.assign(
{},
pDependencyItem,

@@ -72,6 +75,29 @@ {

module.exports = (pInput) => ({
dependencies: Handlebars.templates['dot.template.hbs']({
"things" : pInput.sort(compareOnSource).map(folderify).map(colorize)
})
});
function prefix(pInput) {
if (pInput.summary.hasOwnProperty("optionsUsed")){
return (pDependencyItem) =>
Object.assign(
{},
pDependencyItem,
{
prefix: pInput.summary.optionsUsed.prefix
}
);
}
return (pDependencyItem => pDependencyItem);
}
module.exports = (pInput) =>
Object.assign(
{},
pInput,
{
dependencies: Handlebars.templates['dot.template.hbs']({
"things" : pInput.dependencies
.sort(compareOnSource)
.map(folderify)
.map(colorize)
.map(prefix(pInput))
})
}
);

@@ -14,3 +14,3 @@ "use strict";

return `${SEVERITY2CHALK[pErr.rule.severity](pErr.rule.severity)} ${pErr.rule.name}: ` +
`${chalk.bold(pErr.source)} ${figures.arrowRight} ${chalk.bold(pErr.resolved)}`;
`${chalk.bold(pErr.from)} ${figures.arrowRight} ${chalk.bold(pErr.to)}`;
}

@@ -32,61 +32,26 @@

function cutNonTransgressions(pSourceEntry) {
return {
source: pSourceEntry.source,
dependencies: pSourceEntry.dependencies.filter(pDep => pDep.valid === false)
};
}
module.exports = (pInput) => {
function addSource(pSource) {
return pDependency => Object.assign(pDependency, {source: pSource});
}
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))),
[]
if (pInput.summary.violations.length === 0){
return Object.assign(
pInput,
{
dependencies: ""
}
);
}
function render(pInput) {
const lViolations = extractViolations(pInput);
if (lViolations.length === 0){
return {
dependencies: ""
};
}
const lMetaData = extractMetaData(lViolations);
return {
dependencies: lViolations.reduce(
return Object.assign(
{},
pInput,
{
dependencies: pInput.summary.violations.reduce(
(pAll, pThis) => `${pAll} ${formatError(pThis)}\n`,
"\n"
).concat(
formatSummary(lMetaData)
),
metaData: lMetaData
};
formatSummary(pInput.summary)
)
}
);
}
module.exports = render;
};

@@ -24,6 +24,11 @@ "use strict";

module.exports = (pInput) => ({
dependencies: Handlebars.templates['html.template.hbs']({
"things" : dependencyToIncidenceTransformer.transform(pInput).map(addShowTitle)
})
});
module.exports = pInput =>
Object.assign(
{},
pInput,
{
dependencies: Handlebars.templates['html.template.hbs']({
"things" : dependencyToIncidenceTransformer.transform(pInput.dependencies).map(addShowTitle)
})
}
);
"use strict";
module.exports = pInput => ({
dependencies: JSON.stringify(pInput, null, " ")
});
module.exports = pInput =>
Object.assign(
{},
pInput,
{
dependencies: JSON.stringify(pInput, null, " ")
}
);

@@ -14,6 +14,11 @@ "use strict";

module.exports = (pInput) => ({
dependencies: Handlebars.templates['vis.template.hbs']({
"things" : pInput.map(addPath)
})
});
module.exports = (pInput) =>
Object.assign(
{},
pInput,
{
dependencies: Handlebars.templates['vis.template.hbs']({
"things" : pInput.dependencies.map(addPath)
})
}
);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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