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
49
lib/index.js
49
lib/index.js
|
@ -2,12 +2,29 @@
|
|||
var FsExtra = require("fs-extra")
|
||||
, Ul = require("ul")
|
||||
, Moment = require("moment")
|
||||
, Couleurs = require("couleurs")()
|
||||
, CliBox = require("cli-box")
|
||||
;
|
||||
|
||||
// Constants
|
||||
const STORE_PATH = Ul.USER_DIR + "/.git-stats"
|
||||
, 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 = {
|
||||
Sun: 0
|
||||
, Mon: 1
|
||||
|
@ -204,7 +221,6 @@ GitStats.ansiCalendar = function (data, callback) {
|
|||
, d = 0
|
||||
;
|
||||
|
||||
|
||||
GitStats.calendar(data, function (err, cal) {
|
||||
if (err) { return callback(err); }
|
||||
GitStats.iterateDays(function (cDay, mDay) {
|
||||
|
@ -232,17 +248,40 @@ GitStats.ansiCalendar = function (data, callback) {
|
|||
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;
|
||||
}).join("\n");
|
||||
|
||||
strYear +=
|
||||
"\n" + "Total commits: " + cal.total
|
||||
new Array(4 + 2 * Math.ceil(365 / 7)).join("-")
|
||||
+ "\n" + "Total commits: " + cal.total
|
||||
+ "\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