Skip to content

Commit

Permalink
Usage info and license
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarchena committed May 27, 2015
1 parent 18fb459 commit 6ef6b49
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 1 deletion.
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 David Marchena

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

111 changes: 110 additions & 1 deletion README.md
Expand Up @@ -6,4 +6,113 @@

Get your project dependency tree from NPM as well as from bower

Current state: Under early development
## Install

npm install dependency-info

## Usage

First af all, you have to retrieve your dependency tree.

### The async way

var dependencyInfo = require('dependency-info');
dependencyInfo.readTree({
manager: 'npm'
})
.then(function (tree) {
...
})
.catch(function (err) {
...
});

### Of course, you can also get it synchronously

var dependencyInfo = require('dependency-info')
list,
tree;
tree = dependencyInfo.readTreeSync({
manager: 'npm'
});

### Parameters
`readTree`and `readTreeSync` accept the same `options` param:

```
{
path: {String} path to module whose dependencies will be fetched.
Default: process.cwd()
manager: {String} Package manager: 'npm' or 'bower'
type: {String} All dependencies: 'all' (default)
or
{Array} Accepted values: 'dependencies' and 'devDependencies'
deep: {Boolean} If true it search for all dependencies, not only the direct ones.
Default value: false
filterBy:
{
keyword: {Array} List of keywords the dependency must have
}
}
```

## How to use this info

`Tree` object provides you a method to get a sorted Array of the information you need.

### tree.list(fields, order)

This method looks over the tree and returns an ordered array of key value objects filled with the specified fields, which will be taken from each dependency json file.

`fields` {Array} The fields to get from json files
`order` {String} Sort dependencies in ascending ('asc') or descending order ('desc')

## Examples

### Logging asynchronously

```
var dependencyInfo = require('dependency-info');
dependencyInfo.readTree({
manager: 'npm'
})
.then(function (tree) {
var list = tree.list(['name', 'version'], 'asc');
console.log(list);
})
```

### Logging synchronously

```
var dependencyInfo = require('dependency-info')
list,
tree;
tree = dependencyInfo.readTreeSync({
manager: 'npm'
});
list = tree.list(['name', 'version'], 'asc');
console.log(list);
```

### Result

Both of them will output a message like this:

```
[ { name: 'connect-livereload', version: '0.5.3' },
{ name: 'express', version: '4.12.3' },
{ name: 'gulp', version: '3.8.11' },
{ name: 'gulp-autoprefixer', version: '2.2.0' },
{ name: 'gulp-copy', version: '0.0.2' },
{ name: 'gulp-kit', version: '0.1.1' },
{ name: 'gulp-minify-css', version: '1.1.0' },
{ name: 'gulp-prettify', version: '0.3.0' },
{ name: 'gulp-rename', version: '1.2.2' },
{ name: 'gulp-sass', version: '1.3.3' },
{ name: 'gulp-strip-css-comments', version: '1.1.0' },
{ name: 'tiny-lr', version: '0.1.5' } ]
```

## License
MIT. See [LICENSE](https://github.com/dmarchena/dependency-info/blob/master/LICENSE) for details.

0 comments on commit 6ef6b49

Please sign in to comment.