Permalink
Browse files

Merge pull request #6 from nice-registry/hostnames

hostnames
  • Loading branch information...
zeke committed Nov 27, 2017
2 parents 5a74440 + 2d25aa0 commit 3a6bf4f714cc902b4cbabec06b3e6d41737345ae
Showing with 64 additions and 0 deletions.
  1. +18 −0 hostnames.js
  2. +7 −0 package.json
  3. +39 −0 readme.md
View
@@ -0,0 +1,18 @@
#!/usr/bin/env node
const URL = require('url')
const countValues = require('count-array-values')
const urls = Object.values(require('.'))
const hostnames = urls.map(url => URL.parse(url).hostname.replace(/^www\./i, ''))
const counts = countValues(hostnames)
module.exports = counts
if (!module.parent) {
const pad = require('pad')
const longestHostname = hostnames.sort((a, b) => b.length - a.length)[0]
counts.forEach(hostname => {
console.log(pad(hostname.value, longestHostname.length + 3) + String(hostname.count))
})
}
View
@@ -21,5 +21,12 @@
"ora": "^1.1.0",
"package-stream": "^3.0.1",
"standard": "^8.6.0"
},
"dependencies": {
"count-array-values": "^1.2.1",
"pad": "^2.0.3"
},
"bin": {
"all-the-package-repo-hostnames": "hostnames.js"
}
}
View
@@ -40,6 +40,45 @@ GitHub URLs are normalized to their `https` form using
- `foo/bar` becomes `https://github.com/foo/bar`
- [etc...](http://ghub.io/github-url-to-object)
### Repository Hostnames
For the curious, there's a submodule that collects all the hostnames of all the
repository URLS:
```js
require('./hostnames').slice(0,10)
[
{ value: 'github.com', count: 452768 },
{ value: 'bitbucket.org', count: 553 },
{ value: 'git.oschina.net', count: 219 },
{ value: 'gitlab.com', count: 116 },
{ value: 'git.coding.net', count: 114 },
{ value: 'archive.voodoowarez.com', count: 81 },
{ value: 'gitee.com', count: 60 },
{ value: 'gitlab.baidu.com', count: 49 },
{ value: 'git-wip-us.apache.org', count: 38 },
{ value: 'gitlab.alibaba-inc.com', count: 36 }
]
```
It also has a CLI:
```sh
all-the-package-repo-hostnames | head -n 10
github.com 452768
bitbucket.org 553
git.oschina.net 219
gitlab.com 116
git.coding.net 114
archive.voodoowarez.com 81
gitee.com 60
gitlab.baidu.com 49
git-wip-us.apache.org 38
gitlab.alibaba-inc.com 36
```
## Tests
```sh

0 comments on commit 3a6bf4f

Please sign in to comment.