Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostnames #6

Merged
merged 2 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions hostnames.js
Original file line number Diff line number Diff line change
@@ -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))
})
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
39 changes: 39 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down