-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrender.js
117 lines (101 loc) · 3.18 KB
/
render.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const packages = require('.')
const fs = require('fs')
const path = require('path')
const tableify = require('tableify')
const dedent = require('dedent')
const {chain} = require('lodash')
const {snakeCase} = require('change-case')
const MAX = 50
function pkgLink(pkg) {
return `<a href="http://ghub.io/${pkg.name}">${pkg.name}</a>`
}
let datasets = {
'top dependents of `nan` by dependent count': {
data: chain(packages)
.filter(pkg => pkg.somehowDependsOn('nan'))
.orderBy('dependentCounts.totalDirectDependents', 'desc')
.slice(0, MAX)
.map(pkg => {
return {
name: pkgLink(pkg),
description: pkg.description,
dependents: pkg.dependentCounts.totalDirectDependents
}
})
.value()
},
'top dependents of `nan` by daily download count': {
data: chain(packages)
.filter(pkg => pkg.somehowDependsOn('nan'))
.orderBy('averageDailyDownloads', 'desc')
.slice(0, MAX)
.map(pkg => {
return {
name: pkgLink(pkg),
description: pkg.description,
downloads: pkg.averageDailyDownloads
}
})
.value()
},
'all dependents of `prebuild`': {
data: chain(packages)
.filter(pkg => pkg.somehowDependsOn('prebuild'))
.orderBy('averageDailyDownloads', 'desc')
.map(pkg => {
return {
name: pkgLink(pkg),
description: pkg.description,
downloads: pkg.averageDailyDownloads,
dependents: pkg.dependentCounts.totalDirectDependents
}
})
.value()
},
'all dependents of `prebuildify`': {
data: chain(packages)
.filter(pkg => pkg.somehowDependsOn('prebuildify'))
.orderBy('averageDailyDownloads', 'desc')
.map(pkg => {
return {
name: pkgLink(pkg),
description: pkg.description,
downloads: pkg.averageDailyDownloads,
dependents: pkg.dependentCounts.totalDirectDependents
}
})
.value()
}
}
// Add slugs
Object.keys(datasets).forEach(title => {
datasets[title].slug = snakeCase(title)
})
console.log(dedent`<!-- auto-generated by render.js -->
# Native Modules
> a list of ${packages.length} JavaScript modules with C++ addons
Find more datasets like this at
[nice-registry/about](https://github.com/nice-registry/about#datasets).
## How?
This list is created by consuming the entire npm registry using
[package-stream](http://ghub.io/package-stream), collecting all
packages that depend (or devDepend) on
[nan](http://ghub.io/nan),
[node-pre-gyp](http://ghub.io/node-pre-gyp),
[prebuild](http://ghub.io/prebuild), or
[prebuildify](http://ghub.io/prebuildify).
Then [average daily downloads](http://ghub.io/download-counts) and
[direct dependents](http://ghub.io/dependent-counts) counts are added
to the collected packages so they can be sorted by popularity.
## Lists
`)
Object.keys(datasets).forEach(title => {
const {slug} = datasets[title]
console.log(`- [${title}](#${slug})`)
})
Object.keys(datasets).forEach(title => {
const {data, slug} = datasets[title]
console.log(`\n\n<h2 id="${slug}">${title}</h2>`)
console.log(tableify(data))
console.log('<br><br><br><br><br><br>')
})