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

Allow packages without repository #36

Merged
merged 21 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 13 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
2 changes: 1 addition & 1 deletion hostnames.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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 hostnames = urls.filter(u => u).map(url => URL.parse(url).hostname.replace(/^www\./i, ''))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use .filter(Boolean)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed.

const counts = countValues(hostnames)

module.exports = counts
Expand Down
14 changes: 12 additions & 2 deletions lib/stats-tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@ module.exports = {
const total = metadata.packages
const repos = metadata.repos

const areNull = repos.unsets || 0
const notNull = total - areNull

const perc = (val) => (val * 100 / total).toFixed(2)

return dedent`
<!-- stats -->
Packages | Count | Percentage
-------- | ----- | ----------
With repository in package.json | ${total} | 100%
:------- | -----:| ----------:
With repository | ${notNull} | ${perc(notNull)}%
Null repository | ${areNull} | ${perc(areNull)}%
**Total** | ${total} | ${perc(total)}%

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnecessary whitespace here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's required here to split two tables. See how it looks without it:

Packages Count Percentage
With repository 1004148 64.84%
Null repository 544609 35.16%
Total 1548757 100.00%
Providers Count Percentage
:-------- -----: ----------:
GitHub 986341 63.69%
GitLab 3624 0.23%
Bitbucket 1148 0.07%
Others 13035 0.84%
Total 1004148 64.84%

Providers | Count | Percentage
:-------- | -----:| ----------:
GitHub | ${repos.github} | ${perc(repos.github)}%
GitLab | ${repos.gitlab} | ${perc(repos.gitlab)}%
Bitbucket | ${repos.bitbucket} | ${perc(repos.bitbucket)}%
Others | ${repos.others} | ${perc(repos.others)}%
**Total** | ${notNull} | ${perc(notNull)}%
<!-- /stats -->
`
}
Expand Down
Loading