mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-25 10:17:23 +00:00
Move credits_generator to a different repository (#6524)
This commit is contained in:
parent
9a44ba50b5
commit
77eaad4c0e
1
credits_generator/.gitignore
vendored
1
credits_generator/.gitignore
vendored
@ -1 +0,0 @@
|
||||
.token
|
@ -1,35 +0,0 @@
|
||||
credits_generator
|
||||
=================
|
||||
|
||||
This tool can be used to update the [Credits page for Home Assistant](https://home-assistant.io/developers/credits/).
|
||||
|
||||
Setup
|
||||
-----
|
||||
|
||||
Fetch the dependencies with `npm`.
|
||||
```bash
|
||||
$ cd credits_generator
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
Go to https://github.com/settings/tokens/new and generate a new GitHub personal access token.
|
||||
|
||||
Give the token any name and select the `public_repo` and `read:user` scopes.
|
||||
|
||||
Put the token in this repo in a file named `.token`.
|
||||
|
||||
Run the script.
|
||||
|
||||
```bash
|
||||
$ node update_credits.js
|
||||
```
|
||||
|
||||
Commit the changes (depending on our setup).
|
||||
|
||||
```bash
|
||||
$ git commit ../source/developers/credits.markdown
|
||||
$ git push upstream
|
||||
```
|
||||
|
@ -1,27 +0,0 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Credits"
|
||||
description: "Credits for the developers who contributed to Home Assistant."
|
||||
date: {{ headerDate }}
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
This page contains a list of people who have contributed in one way or another to Home Assistant. Hover over a username to see their contributions.
|
||||
|
||||
### {% linkable_title Author %}
|
||||
|
||||
- [{{fearlessLeader.info.name}} (@{{fearlessLeader.info.username}})](https://github.com/{{fearlessLeader.info.login}} "{{fearlessLeader.countString}}")
|
||||
|
||||
### {% linkable_title Contributors %}
|
||||
|
||||
(in alphabetical order)
|
||||
|
||||
{{#allUsers}}- [{{info.name}} (@{{info.username}})](https://github.com/{{info.username}} "{{countString}}")
|
||||
{{/allUsers}}
|
||||
|
||||
This page is irregularly updated using the [`credits_generator` tool](https://github.com/home-assistant/home-assistant.github.io/tree/next/credits_generator). If you think that you are missing, please let us know.
|
||||
|
||||
<i>This page was last updated {{ footerDate }}.</i>
|
116
credits_generator/package-lock.json
generated
116
credits_generator/package-lock.json
generated
@ -1,116 +0,0 @@
|
||||
{
|
||||
"name": "credits_generator",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"agent-base": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.1.1.tgz",
|
||||
"integrity": "sha1-1t4Q1a9hMtW9aSQn1G/FOFOQlMc=",
|
||||
"requires": {
|
||||
"extend": "3.0.2",
|
||||
"semver": "5.0.3"
|
||||
}
|
||||
},
|
||||
"async": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
|
||||
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
|
||||
"requires": {
|
||||
"lodash": "4.17.10"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"extend": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
||||
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-0.0.7.tgz",
|
||||
"integrity": "sha1-NLkLqyqRGqNHVx2pDyK9NuzYqRk=",
|
||||
"requires": {
|
||||
"debug": "2.6.9",
|
||||
"stream-consume": "0.1.1"
|
||||
}
|
||||
},
|
||||
"github": {
|
||||
"version": "8.2.1",
|
||||
"resolved": "https://registry.npmjs.org/github/-/github-8.2.1.tgz",
|
||||
"integrity": "sha1-YWsiEfvNHMhjFmmu1nZT5i61OBY=",
|
||||
"requires": {
|
||||
"follow-redirects": "0.0.7",
|
||||
"https-proxy-agent": "1.0.0",
|
||||
"mime": "1.6.0",
|
||||
"netrc": "0.1.4"
|
||||
}
|
||||
},
|
||||
"https-proxy-agent": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz",
|
||||
"integrity": "sha1-NffabEjOTdv6JkiRrFk+5f+GceY=",
|
||||
"requires": {
|
||||
"agent-base": "2.1.1",
|
||||
"debug": "2.6.9",
|
||||
"extend": "3.0.2"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.10",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
|
||||
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
|
||||
},
|
||||
"mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.22.2",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
|
||||
"integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y="
|
||||
},
|
||||
"moment-timezone": {
|
||||
"version": "0.5.21",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.21.tgz",
|
||||
"integrity": "sha512-j96bAh4otsgj3lKydm3K7kdtA3iKf2m6MY2iSYCzCm5a1zmHo1g+aK3068dDEeocLZQIS9kU8bsdQHLqEvgW0A==",
|
||||
"requires": {
|
||||
"moment": "2.22.2"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"mu2": {
|
||||
"version": "0.5.21",
|
||||
"resolved": "https://registry.npmjs.org/mu2/-/mu2-0.5.21.tgz",
|
||||
"integrity": "sha1-iIqPD9kOsc/anbgUdvbhmcyeWNM="
|
||||
},
|
||||
"netrc": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/netrc/-/netrc-0.1.4.tgz",
|
||||
"integrity": "sha1-a+lPysqNd63gqWcNxGCRTJRHJEQ="
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz",
|
||||
"integrity": "sha1-d0Zt5YnNXTyV8TiqeLxWmjy10no="
|
||||
},
|
||||
"stream-consume": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.1.tgz",
|
||||
"integrity": "sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg=="
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "credits_generator",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "A tool to generate the Home Assistant credits page",
|
||||
"main": "update_credits.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Home Assistant Community",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"async": "^2.1.4",
|
||||
"github": "^8.1.0",
|
||||
"moment-timezone": "^0.5.11",
|
||||
"mu2": "^0.5.21"
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
var fs = require('fs')
|
||||
, async = require('async')
|
||||
, GitHubApi = require('github')
|
||||
, mu = require('mu2')
|
||||
, moment = require('moment-timezone');
|
||||
|
||||
let token;
|
||||
|
||||
try {
|
||||
token = fs.readFileSync('.token', 'utf-8').trim();
|
||||
} catch (err) {
|
||||
console.error('You must create a .token file that contains a GitHub token.');
|
||||
return;
|
||||
}
|
||||
|
||||
var organizationName = process.env.GITHUB_ORGANIZATION_NAME || 'home-assistant';
|
||||
|
||||
mu.root = __dirname;
|
||||
|
||||
var github = new GitHubApi({
|
||||
headers: { 'user-agent': 'Home Assistant Contributors List Updater <hello@home-assistant.io>' }
|
||||
});
|
||||
|
||||
github.authenticate({ type: 'oauth', token: token });
|
||||
|
||||
var usersMap = {};
|
||||
|
||||
github.repos.getForOrg({
|
||||
org: organizationName,
|
||||
type: 'public',
|
||||
per_page: 100
|
||||
}, function(err, repos){
|
||||
var headerSource = (err && err.headers) ? err.headers : repos.meta;
|
||||
var ratelimitLimit = Number(headerSource['x-ratelimit-limit']);
|
||||
var ratelimitRemaining = Number(headerSource['x-ratelimit-remaining']);
|
||||
console.log('Rate limits: '+ratelimitRemaining+'/'+ratelimitLimit, '(remaining/limit)');
|
||||
if(err) {
|
||||
if(err.code == 403 && ratelimitRemaining == 0) {
|
||||
var resetUnixTime = moment.unix(err.headers['x-ratelimit-reset']);
|
||||
var resetTimeFormatted = resetUnixTime.format();
|
||||
var resetAt = moment().to(resetUnixTime);
|
||||
console.error('Error when getting list of repos in org, because rate limits are exhausted. Rate limits reset', resetAt, 'from now ('+resetTimeFormatted+')');
|
||||
} else {
|
||||
console.error('Error when attempting to get a list of all repos in org...', err.message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
async.each(repos, function(repo, cb){
|
||||
github.repos.getContributors({ owner: organizationName, repo: repo.name, per_page: 100 }, function(err, contributors){
|
||||
getContributors(err, contributors, repo, cb);
|
||||
});
|
||||
}, function(err){
|
||||
if(err){
|
||||
console.error('Error when iterating organization repos', err);
|
||||
return;
|
||||
}
|
||||
console.log('Done getting contributors for '+repos.length+' found organization repos...');
|
||||
async.each(Object.keys(usersMap), function(login, cb){
|
||||
github.users.getForUser({username: login}, function(err, userInfo){
|
||||
if(err){
|
||||
console.error('Got error when get user details for', login, err);
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
if (userInfo.name) {
|
||||
userInfo.name = userInfo.name.replace(/^@/, '')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/[\\`*_{}[\]()#+-.!~|]/g, '\\$&');
|
||||
}
|
||||
usersMap[login].info.name = userInfo.name || userInfo.login;
|
||||
usersMap[login].info.username = userInfo.login;
|
||||
cb();
|
||||
});
|
||||
}, function(err){
|
||||
if(err){
|
||||
console.error('Got error when running', err);
|
||||
return;
|
||||
} else {
|
||||
console.log('Building contributors!!!');
|
||||
buildContributors();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getContributors(err, res, repo, callback){
|
||||
if(err) {
|
||||
console.error('Error when getting contributors', err);
|
||||
callback(err);
|
||||
return
|
||||
} else {
|
||||
console.log('Processing the '+res.length+' contributors to '+repo.name);
|
||||
async.each(res, function(contributor, cb){
|
||||
if(!usersMap[contributor.login]) {
|
||||
usersMap[contributor.login] = {
|
||||
counts: {},
|
||||
info: {login: contributor.login, id: contributor.id}
|
||||
};
|
||||
}
|
||||
usersMap[contributor.login].counts[repo.name] = contributor.contributions;
|
||||
cb(null);
|
||||
}, function(){
|
||||
if (github.hasNextPage(res)) {
|
||||
github.getNextPage(res, function(newErr, newContributors){
|
||||
getContributors(newErr, newContributors, repo, callback);
|
||||
});
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function buildContributors(){
|
||||
var fearlessLeader = usersMap['balloob'];
|
||||
fearlessLeader.countString = buildCountString(fearlessLeader.counts);
|
||||
delete usersMap['balloob'];
|
||||
var users = Object.keys(usersMap).map(function (key) {
|
||||
var obj = usersMap[key];
|
||||
obj.countString = buildCountString(obj.counts);
|
||||
return obj;
|
||||
}).sort(function(a, b){
|
||||
var nameA = a.info.name.toLowerCase();
|
||||
var nameB = b.info.name.toLowerCase();
|
||||
if (nameA < nameB) { return -1; }
|
||||
if (nameA > nameB) { return 1; }
|
||||
return 0;
|
||||
});
|
||||
var headerDate = moment().tz('UTC').format('YYYY-MM-DD HH:mm:ss ZZ');
|
||||
var footerDate = moment().tz('UTC').format('dddd, MMMM Do YYYY, h:mm:ss a zz');
|
||||
var output = '';
|
||||
mu.compileAndRender('credits.mustache', {
|
||||
allUsers: users,
|
||||
fearlessLeader: fearlessLeader,
|
||||
headerDate: headerDate,
|
||||
footerDate: footerDate
|
||||
}).on('data', function (data) {
|
||||
output += data.toString();
|
||||
}).on('end', function(){
|
||||
fs.writeFile('../source/developers/credits.markdown', output, function (writeErr) {
|
||||
if (writeErr) {
|
||||
console.log('Error when writing credits.markdown', writeErr);
|
||||
} else {
|
||||
console.log('Done getting user info, wrote credits.markdown file!');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function buildCountString(counts){
|
||||
var totalCommits = 0;
|
||||
var countStrings = [];
|
||||
Object.keys(counts).sort(function(a, b){
|
||||
return counts[b] - counts[a];
|
||||
}).forEach(function (countKey) {
|
||||
var count = counts[countKey];
|
||||
var word = (count > 1) ? 'commits' : 'commit';
|
||||
totalCommits = totalCommits+count;
|
||||
countStrings.push(count+' '+word+' to '+countKey);
|
||||
});
|
||||
countStrings.unshift(totalCommits+' total commits to the home-assistant organization');
|
||||
return countStrings.join(', ');
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user