-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathgenerate_dependency_table.js
More file actions
72 lines (57 loc) 路 2.03 KB
/
Copy pathgenerate_dependency_table.js
File metadata and controls
72 lines (57 loc) 路 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
| Project | Used For | Build Status | Test Coverage | Dependency Status | Tutorial |
| --------|----------|:-----:|:--------:|:------------:|-------|
**/
var baseurl = 'https://github.com/dwyl/';
var pkg = require('./package.json');
var deps = Object.keys(pkg.dependencies);
// MANUALLY UPDATE package.json "lean" object when ever a new dependency is added
var learn = Object.keys(pkg.learn);
// table header:
table = ['| Project | Used For | Build Status | Test Coverage | Dependency Status | Tutorial |'];
// table row alignment:
table.push('| --------|----------|:-----:|:--------:|:------------:|-------|');
// loop through the list of dependencies and add a line
deps.forEach(function (d) {
table.push(row(d));
pkg.learn[d] = pkg.learn[d] || { 'use': '', 'repo': '' };
});
function row (d) {
return '| ' + [
repo_link,
used_for,
build_status,
coverage,
dependencies,
learn_link
].map(function(fn) {
return fn(d);
}).join(' | ') + ' |';
}
function repo_link (d) {
return '[**' + d + '**](' + baseurl + d +')'
}
function used_for (d) {
return pkg.learn[d] && pkg.learn[d].use ? pkg.learn[d].use : 'please update in package.json';
}
function build_status (d) {
return '[](https://travis-ci.org/dwyl/' + d + ')';
}
function coverage (d) {
return '[](https://codecov.io/github/dwyl/' + d + '?branch=master)';
}
function dependencies (d) {
return '[](https://david-dm.org/dwyl/' + d + ')';
}
function learn_link (d) {
return pkg.learn[d] && pkg.learn[d].repo ?
'[' + pkg.learn[d].repo + '](' + baseurl + pkg.learn[d].repo + ')'
: 'please update in package.json';
}
console.log(table.join('\n'));
// Write the Learn Section to package.json based on latest dependencies list
var fs = require('fs');
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));