mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2025-01-03 10:22:11 +01:00
A nice box with the squares
This commit is contained in:
parent
7591ac8a59
commit
0bc0da8e12
1 changed files with 46 additions and 7 deletions
53
lib/index.js
53
lib/index.js
|
@ -2,12 +2,29 @@
|
||||||
var FsExtra = require("fs-extra")
|
var FsExtra = require("fs-extra")
|
||||||
, Ul = require("ul")
|
, Ul = require("ul")
|
||||||
, Moment = require("moment")
|
, Moment = require("moment")
|
||||||
|
, Couleurs = require("couleurs")()
|
||||||
|
, CliBox = require("cli-box")
|
||||||
;
|
;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const STORE_PATH = Ul.USER_DIR + "/.git-stats"
|
const STORE_PATH = Ul.USER_DIR + "/.git-stats"
|
||||||
, LEVELS = 5
|
, LEVELS = 5
|
||||||
, SQUARES = ["⬚", "O", "▢", "▤", "▣", "⬛"]
|
, SQUARES = process.argv.indexOf("--no-ansi") !== -1 ? [
|
||||||
|
"⬚"
|
||||||
|
, "▢"
|
||||||
|
, "▢"
|
||||||
|
, "▤"
|
||||||
|
, "▣"
|
||||||
|
, "⬛"
|
||||||
|
] : [
|
||||||
|
Couleurs.fg("▣", "#eee")
|
||||||
|
, Couleurs.fg("▣", "#eee")
|
||||||
|
, Couleurs.fg("▣", "#d6e685")
|
||||||
|
, Couleurs.fg("▣", "#8cc665")
|
||||||
|
, Couleurs.fg("▣", "#8cc665")
|
||||||
|
, Couleurs.fg("▣", "#44a340")
|
||||||
|
, Couleurs.fg("▣", "#1e6823")
|
||||||
|
]
|
||||||
, DAYS = {
|
, DAYS = {
|
||||||
Sun: 0
|
Sun: 0
|
||||||
, Mon: 1
|
, Mon: 1
|
||||||
|
@ -204,7 +221,6 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
, d = 0
|
, d = 0
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
GitStats.calendar(data, function (err, cal) {
|
GitStats.calendar(data, function (err, cal) {
|
||||||
if (err) { return callback(err); }
|
if (err) { return callback(err); }
|
||||||
GitStats.iterateDays(function (cDay, mDay) {
|
GitStats.iterateDays(function (cDay, mDay) {
|
||||||
|
@ -232,17 +248,40 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
strYear += "\n";
|
strYear += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
strYear = strYear.trimRight().split("\n").map(function (c, i) {
|
strYear = strYear.split("\n").map(function (c, i) {
|
||||||
|
if (i > 6) { return; }
|
||||||
return DAYS_ARR[i] + c;
|
return DAYS_ARR[i] + c;
|
||||||
}).join("\n");
|
}).join("\n");
|
||||||
|
|
||||||
strYear +=
|
strYear +=
|
||||||
"\n" + "Total commits: " + cal.total
|
new Array(4 + 2 * Math.ceil(365 / 7)).join("-")
|
||||||
+ "\n" + "Current Streak: " + cal.cStreak
|
+ "\n" + "Total commits: " + cal.total
|
||||||
+ "\n" + "Longest Streak: " + cal.lStreak
|
+ "\n" + "Current Streak: " + cal.cStreak
|
||||||
|
+ "\n" + "Longest Streak: " + cal.lStreak
|
||||||
;
|
;
|
||||||
|
|
||||||
|
strYear = new CliBox({
|
||||||
|
w: 10
|
||||||
|
, h: 10
|
||||||
|
, marks: {
|
||||||
|
nw: "╔"
|
||||||
|
, n: "═"
|
||||||
|
, ne: "╗"
|
||||||
|
, e: "║"
|
||||||
|
, se: "╝"
|
||||||
|
, s: "═"
|
||||||
|
, sw: "╚"
|
||||||
|
, w: "║"
|
||||||
|
, b: " "
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
text: strYear
|
||||||
|
, stretch: true
|
||||||
|
, hAlign: "left"
|
||||||
|
});
|
||||||
|
|
||||||
callback(null, strYear);
|
|
||||||
|
|
||||||
|
callback(null, strYear.toString());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue