Socket
Socket
Sign inDemoInstall

madge

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

madge - npm Package Compare versions

Comparing version 3.4.4 to 3.5.0

.madgerc

4

CHANGELOG.md
# CHANGELOG
## v3.5.0 (Oct 28, 2019)
* Reduce processing by excluding .git content (Thanks to @villelaitila)
## v3.4.4 (Feb 12, 2019)

@@ -4,0 +8,0 @@

@@ -138,3 +138,3 @@ 'use strict';

dot() {
return graph.dot(this.obj(), this.config);
return graph.dot(this.obj(), this.circular(), this.config);
}

@@ -155,2 +155,11 @@

}
/**
* Return Buffer with XML SVG representation of the dependency graph.
* @api public
* @return {Promise}
*/
svg() {
return graph.svg(this.obj(), this.circular(), this.config);
}
}

@@ -157,0 +166,0 @@

41

lib/graph.js

@@ -49,2 +49,3 @@ 'use strict';

return {
// Graph
G: Object.assign({

@@ -57,5 +58,7 @@ overlap: false,

}, graphVizOptions.G),
// Edge
E: Object.assign({
color: config.edgeColor
}, graphVizOptions.E),
// Node
N: Object.assign({

@@ -118,2 +121,18 @@ fontname: config.fontName,

/**
* Return the module dependency graph XML SVG representation as a Buffer.
* @param {Object} modules
* @param {Array} circular
* @param {Object} config
* @return {Promise}
*/
module.exports.svg = function (modules, circular, config) {
const options = createGraphvizOptions(config);
options.type = 'svg';
return checkGraphvizInstalled(config)
.then(() => createGraph(modules, circular, config, options));
};
/**
* Creates an image from the module dependency graph.

@@ -142,22 +161,14 @@ * @param {Object} modules

* @param {Object} modules
* @param {Array} circular
* @param {Object} config
* @return {Promise}
*/
module.exports.dot = function (modules, config) {
const nodes = {};
const g = graphviz.digraph('G');
module.exports.dot = function (modules, circular, config) {
const options = createGraphvizOptions(config);
options.type = 'dot';
return checkGraphvizInstalled(config)
.then(() => {
Object.keys(modules).forEach((id) => {
nodes[id] = nodes[id] || g.addNode(id);
modules[id].forEach((depId) => {
nodes[depId] = nodes[depId] || g.addNode(depId);
g.addEdge(nodes[id], nodes[depId]);
});
});
return g.to_dot();
});
.then(() => createGraph(modules, circular, config, options))
.then((output) => output.toString('utf8'));
};

@@ -79,3 +79,8 @@ 'use strict';

if (stats.isFile()) {
if (this.isGitPath(srcPath)) {
return;
}
files.push(path.resolve(srcPath));
return;

@@ -85,3 +90,3 @@ }

walk.sync(srcPath, (filePath, stat) => {
if (this.isNpmPath(filePath) || !stat.isFile()) {
if (this.isGitPath(filePath) || this.isNpmPath(filePath) || !stat.isFile()) {
return;

@@ -129,2 +134,6 @@ }

if (this.isGitPath(dependencyFilePath)) {
return false;
}
if (this.config.dependencyFilter) {

@@ -223,2 +232,11 @@ dependencyFilterRes = this.config.dependencyFilter(dependencyFilePath, traversedFilePath, this.baseDir);

/**
* Check if path is from .git folder
* @param {String} filePath
* @return {Boolean}
*/
isGitPath(filePath) {
return filePath.split(path.sep).indexOf('.git') !== -1;
}
/**
* Exclude modules from tree using RegExp.

@@ -225,0 +243,0 @@ * @param {Object} tree

{
"name": "madge",
"version": "3.4.4",
"version": "3.5.0",
"author": "Patrik Henningsson <patrik.henningsson@gmail.com>",

@@ -39,4 +39,9 @@ "repository": "git://github.com/pahen/madge",

"generate:madge": "bin/cli.js --image /tmp/madge.svg bin lib",
"test:output": "./test/output.sh"
"test:output": "./test/output.sh",
"postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1mLove Madge? You can now donate to our open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[34mhttps://opencollective.com/madge/donate\\u001b[0m')\""
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/madge"
},
"dependencies": {

@@ -59,3 +64,5 @@ "chalk": "^2.4.1",

"eslint": "^5.12.0",
"mocha": "^5.1.1",
"expect": "^1.20.2",
"expect-mocha-snapshot": "^1.0.1",
"mocha": "^5.2.0",
"mz": "^2.7.0",

@@ -62,0 +69,0 @@ "should": "^13.2.3"

@@ -19,3 +19,3 @@ <p align="center">

</a>
<a href="https://paypal.me/pahen">
<a href="https://paypal.me/pahen" target="_blank">
<img alt="Donate" src="https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square" />

@@ -25,7 +25,2 @@ </a>

<p align="center">
<a href="https://www.patreon.com/bePatron?u=16473892">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" alt"Become a Patron" width="170" />
</a>
</p>

@@ -43,2 +38,6 @@ **Madge** is a developer tool for generating a visual graph of your module dependencies, finding circular dependencies, and give you other useful info. Joel Kemp's awesome [dependency-tree](https://github.com/mrjoelkemp/node-dependency-tree) is used for extracting the dependency tree.

> I've worked with Madge on my free time for the last couple of years and it's been a great experience. It started as an experiment but turned out to be a very useful tool for many developers. I have many ideas for the project and it would definitely be easier to dedicate more time to it with some [financial support](#donations) 🙏
>
> Regardless of your contribution, thanks for your support!
## Examples

@@ -60,4 +59,4 @@

<a href="https://asciinema.org/a/M5tS7FrwKo8N3KUaCVO41J7iW?autoplay=1">
<img src="https://asciinema.org/a/M5tS7FrwKo8N3KUaCVO41J7iW.png" width="590"/>
<a href="https://asciinema.org/a/l9tM7lIraCpmzH0rdWw2KLrMc?autoplay=1">
<img src="https://asciinema.org/a/l9tM7lIraCpmzH0rdWw2KLrMc.png" width="590"/>
</a>

@@ -187,2 +186,16 @@

#### .svg()
> Return a `Promise` resolved with the XML SVG representation of the dependency graph as a `Buffer`.
```javascript
const madge = require('madge');
madge('path/to/app.js')
.then((res) => res.svg())
.then((output) => {
console.log(output.toString());
});
```
# Configuration

@@ -212,3 +225,3 @@

`graphVizPath` | String | null | Custom Graphviz path
`detectiveOptions` | Object | false | Custom `detective` options for [dependency-tree](https://github.com/dependents/node-dependency-tree)
`detectiveOptions` | Object | false | Custom `detective` options for [dependency-tree](https://github.com/dependents/node-dependency-tree) and [precinct](https://github.com/dependents/node-precinct#usage)
`dependencyFilter` | Function | false | Function called with a dependency filepath (exclude substree by returning false)

@@ -316,2 +329,3 @@

```sh
$ npm install
$ npm test

@@ -326,2 +340,44 @@ ```

## Using both CommonJS and ES6 imports in same file?
Only one syntax is used by default. You can use both though if you're willing to take the degraded performance. Put this in your madge config to enable mixed imports.
```json
{
"detectiveOptions": {
"es6": {
"mixedImports": true
}
}
}
```
## How to ignore `import type` statements in ES6 + Flow?
Put this in your madge config.
```json
{
"detectiveOptions": {
"es6": {
"skipTypeImports": true
}
}
}
```
## How to ignore `import` in type annotations in TypeScript?
Put this in your madge config.
```json
{
"detectiveOptions": {
"ts": {
"skipTypeImports": true
}
}
}
```
## What's the "Error: write EPIPE" when exporting graph to image?

@@ -331,2 +387,12 @@

## How do I fix the "Graphviz not built with triangulation library" error when using sfdp layout?
Homebrew doesn't include GTS by default. Fix this by doing:
```sh
brew uninstall graphviz
brew install gts
brew install graphviz
```
## The image produced by madge is very hard to read, what's wrong?

@@ -349,4 +415,46 @@

# Credits
## Contributors
This project exists thanks to all the people who contribute.
<a href="https://github.com/pahen/madge/graphs/contributors"><img src="https://opencollective.com/madge/contributors.svg?width=890&button=false" alt="Contributors"/></a>
## Donations
Thanks to the awesome people below for making donations! 🙏[[Donate](https://paypal.me/pahen)]
**Landon Alder**
<a href="https://github.com/landonalder" target="_blank">
<img src="https://github.com/landonalder.png" width="64"/>
</a>
## Backers
Thank you so much all awesome backers! 🙏[[Become a backer](https://opencollective.com/madge#backer)]
<a href="https://opencollective.com/madge#backers" target="_blank"><img src="https://opencollective.com/madge/backers.svg?width=890&button=false"></a>
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/madge#sponsor)]
<!-- <a href="https://opencollective.com/madge/sponsor/0/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/1/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/2/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/3/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/4/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/5/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/6/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/7/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/8/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/madge/sponsor/9/website" target="_blank"><img src="https://opencollective.com/madge/sponsor/9/avatar.svg"></a> -->
## Patreon
You can also support the project on Patreon. [[Become a backer or sponsor](https://www.patreon.com/bePatron?u=16473892)]
# License
MIT License

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