Skip to content

Commit

Permalink
hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
zeke committed Nov 27, 2017
1 parent 5a74440 commit 3aab2c0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
18 changes: 18 additions & 0 deletions hostnames.js
Original file line number Original file line 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 Original file line Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@
"ora": "^1.1.0", "ora": "^1.1.0",
"package-stream": "^3.0.1", "package-stream": "^3.0.1",
"standard": "^8.6.0" "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 Original file line 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` - `foo/bar` becomes `https://github.com/foo/bar`
- [etc...](http://ghub.io/github-url-to-object) - [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 ## Tests


```sh ```sh
Expand Down

0 comments on commit 3aab2c0

Please sign in to comment.