-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CLI for contributors archiving
- Loading branch information
1 parent
ba4f1b1
commit 4ae95c9
Showing
5 changed files
with
108 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,54 @@ | ||
# open-community-kit | ||
Tools and stats for open-source communities | ||
|
||
# Installation | ||
|
||
``` | ||
npm install -g open-community-kit | ||
``` | ||
|
||
You can use npx as well if you just want to test a CLI command | ||
|
||
# Usage | ||
|
||
## Create a leaderboard of github contributors for all the repos of a user/org | ||
(Contributor with highest # of contributions at the top) | ||
|
||
Run `node contributors.js` from your terminal | ||
### Using CLI | ||
|
||
Run `open-community-kit yourGithubOrgName` from your terminal | ||
|
||
Note: You can also use the shorthand `ock` in place of `open-commmunity-kit` i.e. | ||
|
||
``` | ||
ock yourGitHubOrgName | ||
``` | ||
|
||
This will | ||
* Fetch data from Github APIs and prepare a leaderboard of all the contributors to (default "Git-Commit-Show" org) the user or org you mention in REPO_OWNER variable inside `contributors.js` | ||
* Fetch data from Github APIs and prepare a leaderboard of all the contributors to public repositories of your GitHub organization/user accout | ||
* Save the leaderboard in a csv file in the same folder | ||
|
||
You will hit the API limits soon. To increase API limits, add GITHUB_PERSONAL_TOKEN in `contributors.js` | ||
You will hit the API limits soon. **To increase API limits**, add [`GITHUB_PERSONAL_TOKEN`](https://github.com/settings/tokens) as well in the arguments i.e. | ||
|
||
``` | ||
ock yourGitHubOrgName yourGitHubPersonalToken | ||
``` | ||
|
||
### Using code | ||
|
||
```javascript | ||
const OCK = require('open-community-kit').OCK; | ||
OCK.contributors.github.archive('your_github_org_or_username', | ||
{ GITHUB_PERSONAL_TOKEN: 'your_gh_personal_token_optional' | ||
}); | ||
``` | ||
|
||
## Settings for repeated usage | ||
|
||
If you are going to use this command frequently, you might not want to set organization name and personal token again and again. Instead, you can set following environment variables and then you don't need to pass those variables as CLI arguments or function parameters | ||
|
||
``` | ||
# Set these variables in the environment to avoid repeatedly specifying these variables | ||
1. REPO_OWNER | ||
2. GITHUB_PERSONAL_TOKEN | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env node | ||
|
||
const OCK = require('./index').OCK; | ||
|
||
let mainCommand = process.argv[1]; | ||
console.log("Running "+mainCommand+"..."); | ||
let REPO_OWNER = process.argv[2]; | ||
let GITHUB_PERSONAL_TOKEN = process.argv[3]; | ||
|
||
let options = {}; | ||
if(GITHUB_PERSONAL_TOKEN){ | ||
options.GITHUB_PERSONAL_TOKEN = GITHUB_PERSONAL_TOKEN; | ||
} | ||
OCK.contributors.github.archive(REPO_OWNER, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const contributorsLib = require('./contributors'); | ||
|
||
/** | ||
* Bundling all APIs together | ||
* @param {*} options | ||
*/ | ||
|
||
const OCK = { | ||
contributors: { | ||
github: { | ||
archive: async function(owner, options){ | ||
contributorsLib.archiveContributorsLeaderboard(owner, options) | ||
} | ||
} | ||
} | ||
} | ||
|
||
exports.OCK = OCK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters