Skip to content

Commit 2d150f6

Browse files
committed
🔥
0 parents  commit 2d150f6

10 files changed

+173
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[{package.json,*.yml}]
11+
indent_style = space
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.jshintrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"node": true,
3+
"esnext": true,
4+
"bitwise": true,
5+
"curly": true,
6+
"immed": true,
7+
"mocha": true,
8+
"newcap": true,
9+
"noarg": true,
10+
"undef": true,
11+
"unused": "vars",
12+
"strict": true
13+
}

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- 'iojs'
4+
- '0.12'
5+
- '0.10'

index.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
var registry = require('npm-stats')();
3+
var packageJson = require('package-json');
4+
var PJV = require('package-json-validator').PJV;
5+
var asyncMap = require('async').map
6+
7+
module.exports = function (username, cb) {
8+
if (typeof username !== 'string') {
9+
throw new TypeError('Expected a string');
10+
}
11+
registry.user(username).list( function (err,modules) {
12+
asyncMap(modules, function(module, callback) {
13+
packageJson(module, 'latest', function (err, json) {
14+
if (err) return callback(err);
15+
callback(null, {
16+
module: module,
17+
homepage: json.homepage,
18+
info : PJV.validate(JSON.stringify(json), "npm", {warnings: true, recommendations: true})
19+
});
20+
})
21+
}, function(err, results) {
22+
cb(err, results);
23+
});
24+
});
25+
};
26+

license

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Hemanth.HM <[email protected]> (h3manth.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

package.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "npm-janitor",
3+
"version": "0.0.0",
4+
"description": "Validate package.json for all the user modules",
5+
"license": "MIT",
6+
"repository": "hemanth/node-npm-janitor",
7+
"author": {
8+
"name": "Hemanth.HM",
9+
"email": "[email protected]",
10+
"url": "h3manth.com"
11+
},
12+
"engines": {
13+
"node": ">=0.10.0"
14+
},
15+
"scripts": {
16+
"test": "mocha"
17+
},
18+
"files": [
19+
"index.js"
20+
],
21+
"keywords": [
22+
""
23+
],
24+
"dependencies": {
25+
"async": "^1.4.2",
26+
"es6-promisify": "^3.0.0",
27+
"lie-denodify": "^0.3.0",
28+
"npm-stats": "^1.1.0",
29+
"package-json": "^1.2.0",
30+
"package-json-validator": "^0.6.0"
31+
},
32+
"devDependencies": {
33+
"mocha": "^2.2.5"
34+
}
35+
}

readme.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# npm-janitor [![Build Status](https://travis-ci.org/hemanth/node-npm-janitor.svg?branch=master)](https://travis-ci.org/hemanth/node-npm-janitor)
2+
3+
> Validates `package.json` for all the user modules.
4+
5+
6+
## Install
7+
8+
```sh
9+
$ npm install --save npm-janitor
10+
```
11+
12+
13+
## Usage
14+
15+
```js
16+
var npmJanitor = require('npm-janitor');
17+
18+
npmJanitor('hemanth', function(err, data){
19+
if(!err) console.log(data);
20+
});
21+
22+
// data would be array of objects that look like:
23+
24+
/*
25+
{ module: 'an-async',
26+
homepage: 'https://github.com/hemanth/node-an-async',
27+
info:
28+
{ valid: true,
29+
warnings: [ 'Missing recommended field: contributors' ],
30+
recommendations:
31+
[ 'Missing optional field: dependencies',
32+
'Missing optional field: engines' ] } }
33+
*/
34+
35+
```
36+
37+
## TODO
38+
39+
* Promisifiy stuff?
40+
41+
## License
42+
43+
MIT © [Hemanth.HM](http://h3manth.com)

test.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
var assert = require('assert');
3+
var npmJanitor = require('./');
4+
5+
it('should return an array of json validator data. ', function (done) {
6+
this.timeout(150000);
7+
npmJanitor('hemanth', function (err,data) {
8+
assert.equal(data.length > 1, true, "Expected some data to be present!");
9+
done();
10+
});
11+
});
12+
13+

0 commit comments

Comments
 (0)