Code Monkey home page Code Monkey logo

ghs's Introduction

ghs

Cross-platform CLI tool to generate your Github profile's stats and summary.

MIT License prs welcome platforms

Preview

Hop on to examples for other usecases.


Jump to:

Installation

Using pip

The stable version of this package is maintained on pypi, install using pip:

pip install ghs

Using source code

This can be useful when you want to do a code contribution to this project. You can test and verify your local changes before submitting a Pull Request.

  1. Clone the repository
git clone https://github.com/interviewstreet/ghs.git
  1. Navigate to the project root and create a virtual environment
python -m venv venv
  1. Activate the virtual environment
    • For macOS and linux, run source venv/bin/activate
    • For windows, run .\venv\Scripts\activate
  2. Install the cli by running the following command while you are in the project root
pip install .

Note: You need to reinstall by running the pip command if you want the cli to pick up your code changes.

Docker

docker build -t ghs:latest .
docker run -it ghs ghs --help

Github PAT

Generate a Github personal access token (https://github.com/settings/tokens) and use the ghs -t command to save it in the config file. This will be used to make the API requests to Github. A happy side-effect of this is that your private contributions are also considered while generating the stats and the summary of your username.

Please make sure that you give the following scopes to the token:

  • repo
  • read:user
  • read:packages

PS: Your Github PAT is not compromised by ghs. Please read the Privacy Notice to know more.

Usage

ghs [options]
Option Description
-v --version Print the cli version
-t --token-update Prompts the user for github PAT and saves it in the config file
-u <username> Print the general stats for the provided username
-s --summary Print the summary of the user. The username should be provided using the -u flag.
-c --copy-to-clipboard Copy the output to clipboard. Can be used with -u or -s.
-h --help Show the help message of the cli

Examples

ghs -u <username>

Prints the general Github stats for the given username.

copy to clipboard

Provide the -c flag to copy the output to your clipboard.

Other options for summary

In addition to getting the Github summary from the beginning, you can also get the summary of the last 12 months or you can provide your own custom duration.

Installation hiccups on windows

Could not install package due to Environment Error

It can be solved by scoping the installation. Add the flag --user to the pip command (pip install --user ghs).

Alternatively, you can install the tool inside a virtual environment

ghs command not found even after installing

Most likely the place where the command is installed is not in the system PATH. On windows, there are a few places where the packages might be installed. After confirming the location, add that directory to the PATH.

How to contribute?

Please see Contributing guidelines for more information.

Steps for pushing a new update

  1. Bump the version in ghs/__init__.py (we follow semantic versioning).

  2. Create an annotated tag for this commit with the version name git tag -a v1.2.3 -m "v1.2.3". You can use this to publish a new release on the project's github page and the same can be used for maintaining the changelog.

  3. Make sure you have twine and build installed.

pip install build twine
  1. Build the package
python -m build

This will create a source archive and a wheel inside the dist folder. You can inspect them to make sure that they contain the correct files.

  1. Run twine sanity on the build files
twine check dist/*
  1. First push the package on TestPyPi so that you can test the updates without affecting the real PyPI index
twine upload -r testpypi dist/*

Get the credentials for hackerrank dev PyPI account from karthik.

Twine will list the package url on TestPyPI. You can test and confirm your changes by installing the package.

  1. Finally, run the following command to upload the package to PyPI
twine upload dist/*

Get the credentials for hackerrank PyPI account from karthik.

  1. Treat yourself with a scoop of tender coconut.

Changelog

You can checkout Releases for the changelog.

Privacy Notice

ghs does not collect any data.

  • It has no home server. The Github PAT is stored locally in your machine.
  • It doesn't embed any kind of analytic hooks in its code.

The only time ghs connects to a remote server is when you want to generate the stats and summary of your github profile. The cli uses the Github GraphQL and Github Rest APIs to do so. The data collected via the APIs is not sent anywhere. It's displayed in your terminal or copied to your clipboard (only if you explicitly tell the tool to do so by providing the -c or --copy-to-clipboard flag).

License

MIT ยฉ HackerRank

ghs's People

Contributors

arpit456jain avatar harshcasper avatar jaiakash avatar makkoncept avatar rksharma95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ghs's Issues

Error: Query failed with status code: 401

I'm using this in Ubuntu 20.04
I've installed ghs using pip install ghs command and it's showing this error. I also tried using the source code and still shows the same error.
I used this last month and it worked fine, maybe it's because of the Github Personal Access Token expired or something else. Is there a way to forget the user so it asks for new Access Token (It didn't ask for it this time)

Screenshot from 2022-05-02 20-59-30

Bug: Unable to update token

Hi, earlier I used the cli to generate the summary. Today I updated my token and tried to refresh/insert the new token but seems like the cli isn't accepting it. As a result the summary isn't generated
backstage_bug

Also is the token stored as a variable ? I don't see any .env file here even to manually update my token ๐Ÿค”

Feature Request: Associate roles with each duration for better context of summary

For the --summary tag, we provide 3 options. The 3rd option is to provide custom durations for which the summary needs to be generated. We can compliment this feature by also taking the roles associated with each duration as input.

This would provide better context to the summary. For eg: it's expected that when you move to a leadership role in engineering, you tend to do more code reviews.

There is no options to fill the Required scopes

Hi

ghs -t 


Creating config file
please enter your github pat: [ghp_xxxxxxxxxxxxxxxxxxxx]
Error: The token does not have valid scopes.
 Required scopes: ['read:user', 'repo', 'read:packages'].
 Provided token scopes: ['repo']

I have granted the permission to the repo, however, on the GitHub setting page, there is not an option to make a read, how can I set this?

A suggestion is that, may you delete the judgment of read:* or make this optional

Error: __enter__- Checking if the token is valid

Hey , whenever I try to enter my PAT key I always run into this error , I have ticked all required scopes while generating key
and also added C:\Users\mahim\Appdata\Local\Programs\Python\Python39\lib\site-packages to the PATH
image

Documentation error for Windows

The admin,
Your documentation for Windows Users for activating the virtual environment contains an error that doesn't allow the user to run this

Step 3 . Activate the virtual environment

For windows, run .\venv\Scripts\activate // error

It should be source venv/Scripts/activate
for Windows user
Allow me to change it in your documentation so that next time no one faces the issue that I faced today.

`ghs` not working

Running ghs -u ratika-12 throws:

Error: Query failed with status code: 401
Traceback: 
  File "/Users/ratikaswami/ghs/venv/lib/python3.8/site-packages/ghs/ghs.py", line 293, in main_proxy
    main()
  File "/Users/ratikaswami/ghs/venv/lib/python3.8/site-packages/ghs/ghs.py", line 267, in main
    verify_github_username(args.username)
  File "/Users/ratikaswami/ghs/venv/lib/python3.8/site-packages/ghs/ghs.py", line 33, in verify_github_username
    if fetch_user_id(username) is None:
  File "/Users/ratikaswami/ghs/venv/lib/python3.8/site-packages/ghs/fetchers.py", line 129, in fetch_user_id
    raise Exception(f"Query failed with status code: {request.status_code}")

`ghs` command not working

Hey, I tried using the command but I always ran into this particular problem everytime I ran ghs any-command

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.