Giter Site home page Giter Site logo

git-iam's People

Contributors

ahmedanwarhafez avatar bryceknz avatar dependabot[bot] avatar don-smith avatar gerardpaapu avatar meetjohngray avatar rohan-fowlerharper avatar sleepysaurus avatar ysabel-guiang avatar

Watchers

 avatar  avatar  avatar

Forkers

andkenneth

git-iam's Issues

Add a feature that creates the users.json file

Given a JSON file that is an array of GitHub usernames, a --build feature could create the users.json file. Here is an example of that JSON array of usernames.

[
  "github-username-1",
  "github-username-2"
]

It will need a GITHUB_AUTH_TOKEN environment variable defined in order to create the GitHub-specific email addresses for the users (way better than what the README currently describes). Here is some code that is very close to what we currently use outside of git-iam to automatically create the users.json file.

/* eslint-disable no-console */
const fs = require('fs')
const { Octokit } = require('@octokit/rest')

const students = [
  'student-github-username-1',
  'student-github-username-2'
]

const authToken = process.env.GITHUB_AUTH_TOKEN

if (!authToken) {
  console.error('Could not find your GitHub Personal Access Token in GITHUB_AUTH_TOKEN')
  console.info('You can proceed after you complete that step.')
  process.exit(1)
}

const github = new Octokit({ auth: authToken })

Promise.all(usernames.sort().map(username => github.users.getByUsername({ username })))
  .then(results => {
    /* eslint-disable camelcase */
    const userData = results
      .map(result => {
        const user = result.data
        const id = user.id
        const username = user.login
        const name = user.name || user.login
        const created_at = user.created_at
        const email = user.id + '+' + user.login + '@users.noreply.github.com'
        return { id, name, username, email, created_at }
      })
      .reduce((userObj, user) => {
        userObj[user.username.toLowerCase()] = user
        return userObj
      }, {})

    fs.writeFile('users.json', JSON.stringify(userData, null, 2), 'utf8', console.log)
    console.log(userData)
  })
  .catch(err => {
    console.error(err)
  })

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.