-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrender.js
61 lines (44 loc) · 2.57 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
const requireDir = require('require-dir')
const path = require('path')
const fs = require('fs')
const blacklist = fs.readFileSync(path.join(__dirname, 'blacklist.txt'), 'utf8').split('\n')
const counts = require('download-counts')
const dependentCounts = require('dependent-counts')
const pluralize = require('pluralize')
const dedent = require('dedent')
const packages = Object.values(requireDir('./packages'))
.filter(pkg => !blacklist.includes(pkg.name))
.map(pkg => Object.assign(pkg, {averageDailyDownloads: counts[pkg.name] || 0}))
.map(pkg => Object.assign(pkg, {
dependentCounts: (dependentCounts.find(dep => dep.name === pkg.name) || {totalDirectDependents: 0})
}))
.sort((a, b) => b.dependentCounts.totalDirectDependents - a.dependentCounts.totalDirectDependents)
console.log(dedent`<!-- auto-generated by render.js -->
# nock Modules
> a list of ${packages.length} javascript modules that extend or depend on [nock](http://ghub.io/nock)
Find more datasets like this at
[nice-registry/about](https://github.com/nice-registry/about#datasets).
## How?
This list is created by:
1. Consuming the entire npm registry using [package-stream](http://ghub.io/package-stream).
1. Plucking out packages that depend on "nock" or have the word "nock" in their name or description.
1. Sorting results by [average daily downloads](http://ghub.io/download-counts) and [direct dependents](http://ghub.io/dependent-counts) counts.
## Lists
- [Modules with 'nock' in name or description](#modules-with-nock-in-name-or-description)
- [Modules that depend on nock](#modules-that-depend-on-nock)
## Modules with 'nock' in name or description
`)
packages
.filter(pkg => pkg.name.match(/nock/i) || pkg.description.match(/nock/i))
.forEach((pkg, i) => {
console.log(`${i+1}. [${pkg.name}](http://ghub.io/${pkg.name}) - ${pkg.description} (${pkg.dependentCounts.totalDirectDependents} ${pluralize('direct dependent', pkg.dependentCounts.totalDirectDependents)}; ${pkg.averageDailyDownloads} ${pluralize('download', pkg.averageDailyDownloads)}/day)`)
})
console.log(`
## Modules that depend on nock
`)
packages
.filter(pkg => pkg.dependencies && pkg.dependencies.nock)
.sort((a,b) => Number(b.dependentCounts.totalDirectDependents) - Number(a.dependentCounts.totalDirectDependents))
.forEach((pkg, i) => {
console.log(`${i+1}. [${pkg.name}](http://ghub.io/${pkg.name}) - ${pkg.description} (${pkg.dependentCounts.totalDirectDependents} ${pluralize('direct dependent', pkg.dependentCounts.totalDirectDependents)}; ${pkg.averageDailyDownloads} ${pluralize('download', pkg.averageDailyDownloads)}/day)`)
})