@ghuser/github-contribs
Advanced tools
Comparing version 2.2.2 to 2.2.3
54
index.js
@@ -86,35 +86,2 @@ 'use strict'; | ||
const getContribs = async (user, joinDate, since, until, ora, console, alsoIssues) => { | ||
const commitsHtmlToRepos = html => { | ||
const repos = new Set(); | ||
const handler = new htmlparser.DefaultHandler((error, dom) => {}); | ||
const parser = new htmlparser.Parser(handler); | ||
parser.parseComplete(html); | ||
for (let i = 0; i < handler.dom.length; ++i) { | ||
if (handler.dom[i].type === 'tag' && handler.dom[i].name === 'ul') { | ||
const ul = handler.dom[i].children; | ||
for (let j = 0; j < ul.length; ++j) { | ||
if (ul[j].type === 'tag' && ul[j].name === 'li') { | ||
const li = ul[j].children; | ||
for (let k = 0; k < li.length; ++k) { | ||
if (li[k].type === 'tag' && li[k].name === 'div') { | ||
const div = li[k].children; | ||
for (let l = 0; l < div.length; ++l) { | ||
if (div[l].type === 'tag' && div[l].name === 'a') { | ||
const a = div[l].children[0].data; | ||
if (!a.includes(' ')) { | ||
repos.add(a); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return repos; | ||
}; | ||
const issuesHtmlToRepos = html => { | ||
@@ -153,6 +120,7 @@ const repos = new Set(); | ||
const bigHtmlToRepos = (html, type) => { // type: 'issues' or 'pulls' | ||
const bigHtmlToRepos = (html, type) => { // type: 'issues', 'pull' or 'commits' | ||
const repos = new Set(); | ||
const regex = new RegExp(`<a.*href="/(.*)/(.*)/${type}/`, 'g'); | ||
const charAfterType = type === 'commits' ? '?' : '/'; | ||
const regex = new RegExp(`<a.*href="/(.*)/(.*)/${type}${charAfterType}`, 'g'); | ||
let linkToIssue; | ||
@@ -209,13 +177,7 @@ while ((linkToIssue = regex.exec(html))) { | ||
return (async () => { | ||
const userCommits = await fetchRetry( | ||
`https://github.com/users/${user}/created_commits?from=${currDateStr}&to=${currDateStr}` | ||
); | ||
const userCommitsHtml = await userCommits.text(); | ||
const commitsRepos = commitsHtmlToRepos(userCommitsHtml); | ||
const userPRsAndHotIssues = await fetchRetry( | ||
const bigHtml = await (await fetchRetry( | ||
`https://github.com/${user}?from=${currDateStr}`, | ||
); | ||
const userPRsAndHotIssuesHtml = await userPRsAndHotIssues.text(); | ||
const prsRepos = bigHtmlToRepos(userPRsAndHotIssuesHtml, 'pull'); | ||
)).text(); | ||
const commitsRepos = bigHtmlToRepos(bigHtml, 'commits'); | ||
const prsRepos = bigHtmlToRepos(bigHtml, 'pull'); | ||
@@ -231,3 +193,3 @@ let issuesRepos = []; | ||
hotIssuesRepos = bigHtmlToRepos(userPRsAndHotIssuesHtml, 'issues'); | ||
hotIssuesRepos = bigHtmlToRepos(bigHtml, 'issues'); | ||
} | ||
@@ -234,0 +196,0 @@ |
{ | ||
"name": "@ghuser/github-contribs", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "List all GitHub repos a user has contributed to since the beginning of time.", | ||
@@ -76,4 +76,4 @@ "license": "Unlicense", | ||
"check-coverage": true, | ||
"lines": 75 | ||
"lines": 70 | ||
} | ||
} |
[![Build Status](https://travis-ci.org/ghuser-io/github-contribs.svg?branch=master)](https://travis-ci.org/ghuser-io/github-contribs) | ||
[![Coverage Status](https://codecov.io/gh/ghuser-io/github-contribs/branch/master/graph/badge.svg)](https://codecov.io/gh/ghuser-io/github-contribs) | ||
[![npm version](https://cdn.jsdelivr.net/gh/ghuser-io/github-contribs@b301e71d69531b0edf1befd1f865a70ced557014/thirdparty/badges/npm.svg)](https://www.npmjs.com/package/@ghuser/github-contribs) | ||
[![npm version](https://cdn.jsdelivr.net/gh/ghuser-io/github-contribs@dd75675a1e8a2c4ba708bf14deaf92c6adcaddc4/thirdparty/badges/npm.svg)](https://www.npmjs.com/package/@ghuser/github-contribs) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors) | ||
@@ -73,3 +73,2 @@ | ||
* https://github.com/users/AurelienLourot/created_commits?from=2018-05-17&to=2018-05-17 | ||
* https://github.com/users/AurelienLourot/created_repositories?from=2018-05-17&to=2018-05-17 | ||
@@ -107,2 +106,9 @@ * https://github.com/users/AurelienLourot/created_pull_request_reviews?from=2018-05-17&to=2018-05-17 | ||
> * Same now with `created_commits`: | ||
> | ||
> ```bash | ||
> $ curl -s "https://github.com/AurelienLourot?from=2017-08-27" | grep commits? | ||
> <a href="/AurelienLourot/mybeir.ut/commits?author=AurelienLourot&since=2017-08-27&until=2017-08-28" class="f6 muted-link ml-1"> | ||
> ``` | ||
### Why is it so slow? | ||
@@ -134,2 +140,6 @@ | ||
**2.2.3** (2018-10-20): | ||
* [ghuser-io/ghuser.io#172](https://github.com/ghuser-io/ghuser.io/issues/172) Fix after GitHub's | ||
interface has changed. The `created_commits` "endpoint" is gone. | ||
**2.2.2** (2018-10-13): | ||
@@ -136,0 +146,0 @@ * [ghuser-io/ghuser.io#172](https://github.com/ghuser-io/ghuser.io/issues/172) Fix after GitHub's |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174
20490
257