mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 13:22:11 +01:00
Use cli-gh-cal to generate the GitHub calendar
This commit is contained in:
parent
f13b9395f8
commit
780098afe9
1 changed files with 20 additions and 18 deletions
38
lib/index.js
38
lib/index.js
|
@ -7,26 +7,11 @@ var Ul = require("ul")
|
||||||
, Gry = require("gry")
|
, Gry = require("gry")
|
||||||
, IsThere = require("is-there")
|
, IsThere = require("is-there")
|
||||||
, CliPie = require("cli-pie")
|
, CliPie = require("cli-pie")
|
||||||
|
, CliGhCal = require("cli-gh-cal")
|
||||||
;
|
;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const STORE_PATH = Ul.USER_DIR + "/.git-stats"
|
const STORE_PATH = Ul.USER_DIR + "/.git-stats"
|
||||||
, LEVELS = [
|
|
||||||
"⬚"
|
|
||||||
, "▢"
|
|
||||||
, "▤"
|
|
||||||
, "▣"
|
|
||||||
, "■"
|
|
||||||
]
|
|
||||||
, DAYS = [
|
|
||||||
"Sun"
|
|
||||||
, "Mon"
|
|
||||||
, "Tue"
|
|
||||||
, "Wed"
|
|
||||||
, "Thu"
|
|
||||||
, "Fri"
|
|
||||||
, "Sat"
|
|
||||||
]
|
|
||||||
, DATE_FORMAT = "MMM D, YYYY"
|
, DATE_FORMAT = "MMM D, YYYY"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -159,8 +144,8 @@ GitStats.iterateDays = function (data, callback) {
|
||||||
data.start = data.start || Moment().subtract(1, "years");
|
data.start = data.start || Moment().subtract(1, "years");
|
||||||
data.format = data.format || DATE_FORMAT;
|
data.format = data.format || DATE_FORMAT;
|
||||||
|
|
||||||
var start = data.start
|
var start = new Moment(data.start.format(DATE_FORMAT), DATE_FORMAT)
|
||||||
, end = data.end
|
, end = new Moment(data.end.format(DATE_FORMAT), DATE_FORMAT)
|
||||||
, tomrrow = Moment(end.format(DATE_FORMAT), DATE_FORMAT).add(1, "days")
|
, tomrrow = Moment(end.format(DATE_FORMAT), DATE_FORMAT).add(1, "days")
|
||||||
, endStr = tomrrow.format(DATE_FORMAT)
|
, endStr = tomrrow.format(DATE_FORMAT)
|
||||||
, cDay = null
|
, cDay = null
|
||||||
|
@ -288,6 +273,23 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
data = undefined;
|
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 = []
|
var year = []
|
||||||
, months = new Array(52) // Stores the months depending on their first week
|
, months = new Array(52) // Stores the months depending on their first week
|
||||||
, cWeek = [" ", " ", " ", " ", " ", " ", " "]
|
, cWeek = [" ", " ", " ", " ", " ", " ", " "]
|
||||||
|
|
Loading…
Reference in a new issue