Skip to content

Commit

Permalink
Merge pull request #16 from h1alexbel/cli
Browse files Browse the repository at this point in the history
feat(#5): --tokens
  • Loading branch information
h1alexbel authored May 22, 2024
2 parents 0a50517 + 3c391d9 commit 3180323
Show file tree
Hide file tree
Showing 15 changed files with 315 additions and 137 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
},
"parserOptions": {
"ecmaVersion": 2019
}
},
"ignorePatterns": [
"src/api.js"
]
}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
build:
strategy:
matrix:
os: [ ubuntu-20.04, windows-2022, macos-12 ]
os: [ ubuntu-20.04, macos-12 ]
node: [ 20 ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
1 change: 0 additions & 1 deletion .rultor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ install: |
sudo npm install --no-color --global grunt-cli
npm uninstall --no-color grunt-cli
npm install --no-color mocha
pdd -f /dev/null -v
merge:
script: |
npm test
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ ghminer --query "stars:2..100" --start "2005-01-01" --end "2024-01-01" --tokens
For `--query` you provide [GitHub Search API query], start and end date
of the repository search for `--start` and `--end` respectively.
For `--tokens` you should provide a text file that contains a number of
[GitHub PATs] those will be used in order to pass GitHub API rate limits.
Add as many tokens as needed, considering the amount of data.
[GitHub PATs] those will be used in order to pass GitHub API rate limits
(they should be separated by line break). Add as many tokens as needed,
considering the amount of data.

For `--date` you should provide the type of date field to search on, you can
choose from `craeted`, `updated` and `pushed`, the default one is `created`.
Expand Down
15 changes: 9 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "ghminer",
"version": "0.0.0",
"description": "Command-line GitHub repository miner that aggregates dataset for your researches",
"main": "src",
"main": "./src/index.js",
"bin": {
"ghminer": "./src/index.js"
},
"keywords": [
"github-repositories",
"javascript",
Expand All @@ -20,12 +23,12 @@
"minimist": "^1.2.8"
},
"devDependencies": {
"mocha": "^10.3.0",
"grunt": "^1.6.1",
"eslint": "8.45.0",
"eslint-config-google": "0.14.0",
"grunt": "^1.6.1",
"grunt-contrib-clean": "2.0.1",
"grunt-eslint": "24.3.0",
"grunt-mocha-cli": "^4.0.0"
"grunt-mocha-cli": "^4.0.0",
"mocha": "^10.3.0"
}
}
33 changes: 33 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Aliaksei Bialiauski
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* Dynamic import for GraphQLClient, since 'graphql-request' does not support cjs.
* @returns {Promise<*>} GraphQLClient API client
*/
async function api() {
const {GraphQLClient} = await import('graphql-request');
return GraphQLClient;
}

module.exports = api;
15 changes: 10 additions & 5 deletions src/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ const graph = `query ($searchQuery: String!, $first: Int, $after: String) {
defaultBranchRef {
name
}
primaryLanguage {
name
}
createdAt
defaultBranchRef {
name
target {
repository {
object(expression: "master:README.md") {
object(expression: "HEAD:README.md") {
... on Blob {
text
}
}
}
... on Blob {
text
}
... on Commit {
history(first: 1) {
totalCount
Expand All @@ -57,6 +57,9 @@ const graph = `query ($searchQuery: String!, $first: Int, $after: String) {
}
}
}
mentionableUsers {
totalCount
}
latestRelease {
createdAt
}
Expand All @@ -65,7 +68,9 @@ const graph = `query ($searchQuery: String!, $first: Int, $after: String) {
pullRequests {
totalCount
}
diskUsage
issues(states: [OPEN]) {
totalCount
}
licenseInfo {
spdxId
}
Expand Down
Loading

1 comment on commit 3180323

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 3180323 May 22, 2024

Choose a reason for hiding this comment

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

Puzzle 1-40be398f disappeared from src/index.js), that's why I closed #5. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.