Use cli-gh-cal to generate the GitHub calendar

This commit is contained in:
Ionică Bizău 2015-05-28 21:51:40 +03:00
parent f13b9395f8
commit 780098afe9
1 changed files with 20 additions and 18 deletions

View File

@ -7,26 +7,11 @@ var Ul = require("ul")
, Gry = require("gry")
, IsThere = require("is-there")
, CliPie = require("cli-pie")
, CliGhCal = require("cli-gh-cal")
;
// Constants
const STORE_PATH = Ul.USER_DIR + "/.git-stats"
, LEVELS = [
"⬚"
, "▢"
, "▤"
, "▣"
, "■"
]
, DAYS = [
"Sun"
, "Mon"
, "Tue"
, "Wed"
, "Thu"
, "Fri"
, "Sat"
]
, DATE_FORMAT = "MMM D, YYYY"
;
@ -159,8 +144,8 @@ GitStats.iterateDays = function (data, callback) {
data.start = data.start || Moment().subtract(1, "years");
data.format = data.format || DATE_FORMAT;
var start = data.start
, end = data.end
var start = new Moment(data.start.format(DATE_FORMAT), DATE_FORMAT)
, end = new Moment(data.end.format(DATE_FORMAT), DATE_FORMAT)
, tomrrow = Moment(end.format(DATE_FORMAT), DATE_FORMAT).add(1, "days")
, endStr = tomrrow.format(DATE_FORMAT)
, cDay = null
@ -288,6 +273,23 @@ GitStats.ansiCalendar = function (data, callback) {
data = undefined;
}
GitStats.graph(data, function (err, graph) {
var cal = [];
GitStats.iterateDays(data, function (cDay) {
cDayObj = graph[cDay];
if (!cDayObj) { return; }
cal.push([cDay, cDayObj.c]);
});
debugger
callback(null, CliGhCal(cal, {
theme: data.theme
, start: data.start
, end: data.end
}));
});
return;
var year = []
, months = new Array(52) // Stores the months depending on their first week
, cWeek = [" ", " ", " ", " ", " ", " ", " "]