enspiral-dev-academy / git-iam Goto Github PK
View Code? Open in Web Editor NEWSave git config keystrokes
Home Page: https://www.npmjs.com/package/git-iam
Save git config keystrokes
Home Page: https://www.npmjs.com/package/git-iam
It would be great if this script unset the global git config before setting the local config so our students don't lose their commits!
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)
})
The script is blatting the global user config which seems like pretty poor behaviour to me, but it was intentionaly introduced in 8c0f2ed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.