mntnr / name-your-contributors

Name your GitHub contributors; get commits, issues, and comments
MIT License
73 stars 20 forks source link

Config File Support #50

Closed tgetgood closed 6 years ago

tgetgood commented 6 years ago

Specified a config file format, example is config.json.example which is copied into the readme. Executing name-your-contributors --config config.json spits out a copy of the config file with an extra contributions key in each object which is what nyc would have spit out for that specific query.

Note, this is branched off of the cli-updates branch. I can rebase it after that gets merged if there are any conflicts.

Addresses #29

I can't attach json files, so here are the examples:

config format:

{
  "token": "123435abcdf",
  "repos": [{
    "login": "mntnr",
    "repo": "name-your-contributors",
    "before": "2017-11-30",
    "after": "2017-06-01"
  }, {
    "login": "mntnr",
    "repo": "whodidwhat"
  }],
  "orgs": [{
    "login": "adventure-js",
    "after": "2017-07-01"
  }]
}

Return format:

{
  "repos": [
    {
      "login": "mntnr",
      "repo": "name-your-contributors",
      "before": "2017-11-30",
      "after": "2017-06-01",
      "contributions": {
        "commitAuthors": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 42
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 100
          },
          {
            "login": "jozefizso",
            "name": "Jozef Izso",
            "url": "https://github.com/jozefizso",
            "count": 2
          }
        ],
        "commitCommentators": [],
        "prCreators": [
          {
            "login": "jozefizso",
            "name": "Jozef Izso",
            "url": "https://github.com/jozefizso",
            "count": 1
          },
          {
            "login": "greenkeeper",
            "count": 2
          },
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 2
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 7
          }
        ],
        "prCommentators": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 26
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 16
          }
        ],
        "issueCreators": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 14
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 5
          }
        ],
        "issueCommentators": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 21
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 15
          },
          {
            "login": "jywarren",
            "name": "Jeffrey Warren",
            "url": "https://github.com/jywarren",
            "count": 1
          },
          {
            "login": "diasdavid",
            "name": "David Dias",
            "url": "https://github.com/diasdavid",
            "count": 2
          }
        ],
        "reactors": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 8
          },
          {
            "login": "patcon",
            "name": "Patrick Connolly",
            "url": "https://github.com/patcon",
            "count": 1
          }
        ],
        "reviewers": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 19
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 7
          }
        ]
      }
    },
    {
      "login": "mntnr",
      "repo": "whodidwhat",
      "contributions": {
        "commitAuthors": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 3
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 10
          }
        ],
        "commitCommentators": [],
        "prCreators": [],
        "prCommentators": [],
        "issueCreators": [
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 3
          },
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 3
          }
        ],
        "issueCommentators": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 7
          },
          {
            "login": "tgetgood",
            "name": "Thomas Getgood",
            "url": "https://github.com/tgetgood",
            "count": 6
          }
        ],
        "reactors": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 1
          }
        ],
        "reviewers": []
      }
    }
  ],
  "orgs": [
    {
      "login": "adventure-js",
      "after": "2017-07-01",
      "contributions": {
        "commitAuthors": [],
        "commitCommentators": [],
        "prCreators": [],
        "prCommentators": [],
        "issueCreators": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 2
          }
        ],
        "issueCommentators": [
          {
            "login": "noffle",
            "name": "Stephen Whitmore",
            "url": "https://github.com/noffle",
            "count": 2
          },
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 8
          },
          {
            "login": "reustle",
            "name": "Shane Reustle",
            "url": "https://github.com/reustle",
            "count": 1
          },
          {
            "login": "despairblue",
            "name": "Danny Martini",
            "url": "https://github.com/despairblue",
            "count": 2
          },
          {
            "login": "whyrusleeping",
            "name": "Whyrusleeping",
            "url": "https://github.com/whyrusleeping",
            "count": 2
          },
          {
            "login": "MylesBorins",
            "name": "Myles Borins",
            "url": "https://github.com/MylesBorins",
            "count": 1
          },
          {
            "login": "diffcunha",
            "name": "Diogo Cunha",
            "url": "https://github.com/diffcunha",
            "count": 1
          }
        ],
        "reactors": [
          {
            "login": "RichardLitt",
            "name": "Richard Littauer",
            "url": "https://github.com/RichardLitt",
            "count": 4
          },
          {
            "login": "despairblue",
            "name": "Danny Martini",
            "url": "https://github.com/despairblue",
            "count": 3
          },
          {
            "login": "yangwao",
            "name": "Matej Nemček",
            "url": "https://github.com/yangwao",
            "count": 2
          },
          {
            "login": "noffle",
            "name": "Stephen Whitmore",
            "url": "https://github.com/noffle",
            "count": 1
          },
          {
            "login": "carlesba",
            "name": "Carles Ballester",
            "url": "https://github.com/carlesba",
            "count": 1
          },
          {
            "login": "fbaiodias",
            "name": "Francisco Baio Dias",
            "url": "https://github.com/fbaiodias",
            "count": 1
          },
          {
            "login": "fforres",
            "name": "Felipe Torres (fforres)",
            "url": "https://github.com/fforres",
            "count": 1
          },
          {
            "login": "whyrusleeping",
            "name": "Whyrusleeping",
            "url": "https://github.com/whyrusleeping",
            "count": 1
          }
        ],
        "reviewers": []
      }
    }
  ]
}
RichardLitt commented 6 years ago

Otherwise, looks great!

tgetgood commented 6 years ago

I put some config examples in the README. Which part isn't clear? I'll elaborate on it.

As for login vs user, I was going for uniformity between repos and orgs. At the API level, they're both logins, but they're not both users.

We could do user for repos and org or orgName or just name for orgs.

How about

{
  "token": "123435abcdf",
  "repos": [{
    "user": "mntnr",
    "repo": "name-your-contributors",
    "before": "2017-11-30",
    "after": "2017-06-01"
  }, {
    "user": "mntnr",
    "repo": "whodidwhat"
  }],
  "orgs": [{
    "name": "adventure-js",
    "after": "2017-07-01"
  }]
}
RichardLitt commented 6 years ago

Ah, missed that, sweet.

Hmm. If that is how GitHub's API does it, lets just stay with login. It works for both.

tgetgood commented 6 years ago

Sorry about the mangled rebase. Fixed now.

RichardLitt commented 6 years ago

Not sure it's fixed? There's some reverts which are odd.

tgetgood commented 6 years ago

Was not fixed. This looks better.

RichardLitt commented 6 years ago

Woop woop!

RichardLitt commented 6 years ago

:tada: This PR is included in version 3.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: