Skip to content

Commit 073ebb2

Browse files
committed
Merge branch 'release/3.0.0'
2 parents d4a7b03 + d30667c commit 073ebb2

File tree

7 files changed

+238
-105
lines changed

7 files changed

+238
-105
lines changed

.eslintrc.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module.exports = {
7373
"id-blacklist": "error",
7474
"id-length": "off",
7575
"id-match": "error",
76-
"indent": "off",
76+
"indent": ["error", 4],
7777
"init-declarations": "off",
7878
"jsx-quotes": "error",
7979
"key-spacing": "error",
@@ -152,12 +152,7 @@ module.exports = {
152152
"no-new-require": "error",
153153
"no-new-wrappers": "error",
154154
"no-octal-escape": "error",
155-
"no-param-reassign": [
156-
"error",
157-
{
158-
"props": false
159-
}
160-
],
155+
"no-param-reassign": "off",
161156
"no-path-concat": "error",
162157
"no-plusplus": [
163158
"error",
@@ -183,7 +178,7 @@ module.exports = {
183178
"no-shadow-restricted-names": "error",
184179
"no-spaced-func": "error",
185180
"no-sync": "error",
186-
"no-tabs": "off",
181+
"no-tabs": "error",
187182
"no-template-curly-in-string": "error",
188183
"no-ternary": "off",
189184
"no-throw-literal": "error",

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## 3.0.0
2+
3+
- Changed method signatures
4+
- Updated ESLint rules
5+
- Added CHANGELOG
6+
7+
## 2.1.0
8+
9+
- Added methods to get language data with username
10+
11+
## 2.0.1
12+
13+
- Fixed Regenerator Runtime error with older versions of Node.JS
14+
15+
## 2.0.0
16+
17+
- Syntactic sugar
18+
19+
## 1.2.0
20+
21+
- getCommitLanguages returns commit count per language
22+
- Configured Babel for Building
23+
- Replaced Promises with Async/Await
24+
25+
## 1.1.0
26+
27+
- Linting
28+
- Rewrote promises
29+
30+
## 1.0.0
31+
32+
- First public release

README.md

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,46 @@ Import `const langGetter = require('github-lang-getter');`
1414

1515
Return the language makeup of a user's repositories, in bytes
1616

17-
The numbers returned by these methods reflect the number of bytes committed by all contributors.
17+
NOTE: The numbers returned by these methods reflect the number of bytes committed by all contributors.
1818

1919
```
20-
var visibility = 'all'; // can be all, public, or private
2120
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
22-
langGetter.getRepoLanguages(visibility, token).then((result) => {
21+
langGetter.getRepoLanguages(token).then((result) => {
2322
console.log(result);
2423
}).catch((err) => {
2524
console.log(err);
2625
});
2726
```
2827

29-
or
28+
For `getRepoLanguages`, you can also supply an optional second parameter to specify the `visibility` and `affiliation` of repositories to find.
29+
NOTE: Both `visibility` and `affiliation` are optional.
3030

3131
```
32-
var username = 'YOUR-USERNAME';
3332
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
34-
langGetter.getRepoLanguagesByUsername(username, token).then((result) => {
33+
var options = {
34+
visibility: 'all' // 'all', 'public', or 'private'
35+
affiliation: ['owner'] // combination of 'owner', 'collaborator', and 'organization_member'
36+
};
37+
langGetter.getRepoLanguages(token, options).then((result) => {
3538
console.log(result);
3639
}).catch((err) => {
3740
console.log(err);
3841
});
3942
```
4043

41-
Returns an object like
44+
You can also use `getRepoLanguagesByUsername` to query for another user's language makeup.
45+
46+
```
47+
var username = 'GITHUB-USERNAME';
48+
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
49+
langGetter.getRepoLanguagesByUsername(token, username).then((result) => {
50+
console.log(result);
51+
}).catch((err) => {
52+
console.log(err);
53+
});
54+
```
55+
56+
The above methods return an object similar to the following:
4257

4358
```
4459
{
@@ -52,31 +67,46 @@ Returns an object like
5267

5368
Return the language makeup of a user's commits, in bytes
5469

55-
The numbers returned by these methods reflect the number of bytes only committed by the user.
70+
NOTE: The numbers returned by these methods reflect the number of bytes only committed by the user.
5671

5772
```
58-
var visibility = 'all'; // can be all, public, or private
5973
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
60-
langGetter.getCommitLanguages(visibility, token).then((result) => {
74+
langGetter.getCommitLanguages(token).then((result) => {
6175
console.log(result);
6276
}).catch((err) => {
6377
console.log(err);
6478
});
6579
```
6680

67-
or
81+
For `getCommitLanguages`, you can also supply an optional second parameter to specify the `visibility` and `affiliation` of repositories to find.
82+
NOTE: Both `visibility` and `affiliation` are optional.
83+
84+
```
85+
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
86+
var options = {
87+
visibility: 'all' // 'all', 'public', or 'private'
88+
affiliation: ['owner'] // combination of 'owner', 'collaborator', and 'organization_member'
89+
};
90+
langGetter.getCommitLanguages(token, options).then((result) => {
91+
console.log(result);
92+
}).catch((err) => {
93+
console.log(err);
94+
});
95+
```
96+
97+
You can also use `getCommitLanguagesByUsername` to query for another user's language makeup.
6898

6999
```
70100
var username = 'YOUR-USERNAME';
71101
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
72-
langGetter.getCommitLanguagesByUsername(username, token).then((result) => {
102+
langGetter.getCommitLanguagesByUsername(token, username).then((result) => {
73103
console.log(result);
74104
}).catch((err) => {
75105
console.log(err);
76106
});
77107
```
78108

79-
Returns an object like
109+
The above methods return an object similar to the following:
80110

81111
```
82112
{
@@ -130,11 +160,14 @@ Bug fixes and new features are encouraged, feel free to fork and make a pull req
130160
- Follow the ESLint rules set in .eslintrc.js
131161
- Add Mocha tests for new functionality
132162

163+
## CHANGELOG
164+
165+
[View changes here](CHANGELOG.md)
166+
133167
## TODOS
134168

135169
- Improve API calls to prevent Github rate limit errors
136170
- Find a way to exclude bytes in files that are a result of build processes
137-
- Add methods to get language stats by Github username (only for public repos)
138171

139172
## License
140173

examples/examples.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
const langGetter = require('../src/index');
22

33
// Return the language makeup of a user's repositories, in bytes
4-
langGetter.getRepoLanguages('all', 'YOUR-ACCESS-TOKEN').then((result) => {
4+
langGetter.getRepoLanguages('YOUR-ACCESS-TOKEN', {
5+
visibility: 'all',
6+
affiliation: ['owner', 'collaborator']
7+
}).then((result) => {
58
console.log(result);
69
}).catch((err) => {
710
console.log(err);
811
});
912

1013
// Return the language makeup of a user's repositories, in bytes
11-
langGetter.getRepoLanguagesByUsername('YOUR-USERNAME', 'YOUR-ACCESS-TOKEN').then((result) => {
14+
langGetter.getRepoLanguagesByUsername('YOUR-ACCESS-TOKEN', 'GITHUB-USERNAME').then((result) => {
1215
console.log(result);
1316
}).catch((err) => {
1417
console.log(err);
1518
});
1619

1720
// Return the language makeup of a user's commits, in bytes
18-
langGetter.getCommitLanguages('all', 'YOUR-ACCESS-TOKEN').then((result) => {
21+
langGetter.getCommitLanguages('YOUR-ACCESS-TOKEN', {
22+
visibility: 'all',
23+
affiliation: ['owner', 'collaborator']
24+
}).then((result) => {
1925
console.log(result);
2026
}).catch((err) => {
2127
console.log(err);
2228
});
2329

2430
// Return the language makeup of a user's commits, in bytes
25-
langGetter.getCommitLanguagesByUsername('YOUR-USERNAME', 'YOUR-ACCESS-TOKEN').then((result) => {
31+
langGetter.getCommitLanguagesByUsername('YOUR-ACCESS-TOKEN', 'GITHUB-USERNAME').then((result) => {
2632
console.log(result);
2733
}).catch((err) => {
2834
console.log(err);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-lang-getter",
3-
"version": "2.1.0",
3+
"version": "3.0.0",
44
"description": "Gets a Github user's programming language distribution across repositories and commits",
55
"main": "./dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)