├── .github └── FUNDING.yml ├── .gitignore ├── CONTRIBUTING.md ├── DOCUMENTATION.md ├── LICENSE ├── README.md ├── bin └── git-stats-html ├── lib ├── index.js └── template.html └── package.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: ionicabizau 2 | patreon: ionicabizau 3 | open_collective: ionicabizau 4 | custom: https://www.buymeacoffee.com/h96wwchmy -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *~ 4 | *.log 5 | node_modules 6 | *.env 7 | .DS_Store 8 | package-lock.json 9 | .bloggify/* 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 🌟 Contributing 2 | 3 | Want to contribute to this project? Great! Please read these quick steps to streamline the process and avoid unnecessary tasks. ✨ 4 | 5 | ## 💬 Discuss Changes 6 | Start by opening an issue in the repository using the [bug tracker][1]. Describe your proposed contribution or the bug you've found. If relevant, include platform info and screenshots. 🖼️ 7 | 8 | Wait for feedback before proceeding unless the fix is straightforward, like a typo. 📝 9 | 10 | ## 🔧 Fixing Issues 11 | 12 | Fork the project and create a branch for your fix, naming it `some-great-feature` or `some-issue-fix`. Commit changes while following the [code style][2]. If the project has tests, add one. ✅ 13 | 14 | If a `package.json` or `bower.json` exists, add yourself to the `contributors` array; create it if it doesn't. 🙌 15 | 16 | ```json 17 | { 18 | "contributors": [ 19 | "Your Name (http://your.website)" 20 | ] 21 | } 22 | ``` 23 | 24 | ## 📬 Creating a Pull Request 25 | Open a pull request and reference the initial issue (e.g., *fixes #*). Provide a clear title and consider adding visual aids for clarity. 📊 26 | 27 | ## ⏳ Wait for Feedback 28 | Your contributions will be reviewed. If feedback is given, update your branch as needed, and the pull request will auto-update. 🔄 29 | 30 | ## 🎉 Everyone Is Happy! 31 | Your contributions will be merged, and everyone will appreciate your effort! 😄❤️ 32 | 33 | Thanks! 🤩 34 | 35 | [1]: /issues 36 | [2]: https://github.com/IonicaBizau/code-style -------------------------------------------------------------------------------- /DOCUMENTATION.md: -------------------------------------------------------------------------------- 1 | ## Documentation 2 | 3 | You can see below the API reference of this module. 4 | 5 | ### `gitStatsHtml(json, cb)` 6 | Turn git-stats result into HTML output. 7 | 8 | #### Params 9 | 10 | - **Object** `json`: The JSON returned by `git-stats --raw` 11 | - **Function** `cb`: The callback function. 12 | 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-25 Ionică Bizău (https://ionicabizau.net) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | # `$ git-stats-html` 21 | 22 | [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Ask me anything](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/git-stats-html.svg)](https://www.npmjs.com/package/git-stats-html) [![Downloads](https://img.shields.io/npm/dt/git-stats-html.svg)](https://www.npmjs.com/package/git-stats-html) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/@johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github) 23 | 24 | Buy Me A Coffee 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | > Turn git-stats result into HTML output. 33 | 34 | 35 | 36 | 37 | 38 | 39 | Check out [`git-stats`](https://github.com/IonicaBizau/git-stats) for more details about git-stats. 40 | 41 | 42 | 43 | 44 | 45 | 46 | [![git-stats-html](http://i.imgur.com/hnSUlCx.png)](#) 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | ## :cloud: Installation 55 | 56 | You can install the package globally and use it as command line tool: 57 | 58 | 59 | ```sh 60 | # Using npm 61 | npm install --global git-stats-html 62 | 63 | # Using yarn 64 | yarn global add git-stats-html 65 | ``` 66 | 67 | 68 | Then, run `git-stats-html --help` and see what the CLI tool can do. 69 | 70 | 71 | ``` 72 | $ git-stats-html --help 73 | Usage: git-stats-html [options] 74 | 75 | Turn git-stats result into HTML output. 76 | 77 | Command arguments: 78 | The input JSON data. 79 | 80 | Options: 81 | --big Use this option for bigger than one year calendars. 82 | -o, --output The output file path. Default it will display the 83 | HTML in the stdout. 84 | -h, --help Displays this help. 85 | -v, --version Displays version information. 86 | 87 | Examples: 88 | $ git-stats --raw | git-stats-html -o out.html 89 | $ git-stats --since '1 January 2015' --raw | ./bin/git-stats-html -o out.html --big 90 | 91 | Documentation can be found at https://github.com/IonicaBizau/git-stats-html#readme. 92 | ``` 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | ## :question: Get Help 117 | 118 | There are few ways to get help: 119 | 120 | 121 | 122 | 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question. 123 | 2. For bug reports and feature requests, open issues. :bug: 124 | 3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket: 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | ## :memo: Documentation 133 | 134 | For full API reference, see the [DOCUMENTATION.md][docs] file. 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | ## :yum: How to contribute 148 | Have an idea? Found a bug? See [how to contribute][contributing]. 149 | 150 | 151 | ## :sparkling_heart: Support my projects 152 | I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, 153 | this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it). 154 | 155 | However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it: 156 | 157 | 158 | - Starring and sharing the projects you like :rocket: 159 | - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book: 160 | - [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea: 161 | - [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone). 162 | - **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6` 163 | 164 | ![](https://i.imgur.com/z6OQI95.png) 165 | 166 | 167 | Thanks! :heart: 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | ## :scroll: License 193 | 194 | [MIT][license] © [Ionică Bizău][website] 195 | 196 | 197 | 198 | 199 | 200 | 201 | [license]: /LICENSE 202 | [website]: https://ionicabizau.net 203 | [contributing]: /CONTRIBUTING.md 204 | [docs]: /DOCUMENTATION.md 205 | [badge_patreon]: https://ionicabizau.github.io/badges/patreon.svg 206 | [badge_amazon]: https://ionicabizau.github.io/badges/amazon.svg 207 | [badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg 208 | [badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg 209 | [patreon]: https://www.patreon.com/ionicabizau 210 | [amazon]: http://amzn.eu/hRo9sIZ 211 | [paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW 212 | -------------------------------------------------------------------------------- /bin/git-stats-html: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | const Tilda = require("tilda") 5 | , gitStatsHtml = require("..") 6 | , fs = require("fs") 7 | ; 8 | 9 | new Tilda(`${__dirname}/../package.json`, { 10 | args: [ 11 | { 12 | name: "data" 13 | , desc: "The input JSON data." 14 | , type: Object 15 | , stdin: true 16 | } 17 | ], 18 | options: [ 19 | { 20 | name: "path" 21 | , desc: "The output file path. Default it will display the HTML in the stdout." 22 | , type: String 23 | , opts: ["o", "output"] 24 | } 25 | , { 26 | desc: "Use this option for bigger than one year calendars." 27 | , opts: ["big"] 28 | } 29 | ], 30 | examples: [ 31 | "git-stats --raw | git-stats-html -o out.html" 32 | , "git-stats --since '1 January 2015' --raw | ./bin/git-stats-html -o out.html --big" 33 | ] 34 | }).main(action => { 35 | gitStatsHtml(action.args.data, (err, result) => { 36 | 37 | if (err) { 38 | return console.error(err); 39 | } 40 | 41 | let output = action.options.output.value; 42 | if (output) { 43 | fs.writeFileSync(output, result); 44 | } else { 45 | console.log(err || result); 46 | } 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const ajs = require("ajs") 4 | , ghLegend = require("github-calendar-legend") 5 | , Daty = require("daty") 6 | , mapO = require("map-o") 7 | ; 8 | 9 | /** 10 | * gitStatsHtml 11 | * Turn git-stats result into HTML output. 12 | * 13 | * @name gitStatsHtml 14 | * @function 15 | * @param {Object} json The JSON returned by `git-stats --raw` 16 | * @param {Function} cb The callback function. 17 | */ 18 | module.exports = function gitStatsHtml (json, cb) { 19 | json.theme = { 20 | levels: ghLegend 21 | }; 22 | json.start = new Daty(json.start); 23 | json.end = new Daty(json.end); 24 | json.months = []; 25 | let lastMonth = null; 26 | json.levels.forEach((c, weekIndex) => { 27 | c.forEach(c => { 28 | if (c.month === lastMonth) { return; } 29 | json.months.push({ 30 | name: c.month 31 | , index: weekIndex 32 | , left: 13 + 12 * weekIndex 33 | }); 34 | lastMonth = c.month; 35 | }); 36 | }); 37 | if (json.months[1].index - json.months[0].index < 4) { 38 | json.months.splice(0, 1); 39 | } 40 | mapO(json.currentStreak, value => new Daty(value)); 41 | mapO(json.longestStreak, value => new Daty(value)); 42 | ajs.renderFile(`${__dirname}/template.html`, json, cb); 43 | }; 44 | -------------------------------------------------------------------------------- /lib/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 32 | 33 | 34 |
35 |
36 |
37 | 38 | 39 | <% var DAY_X = 13; %> 40 | <% var WEEK_X = 0; %> 41 | <% var DAY_Y = 0; %> 42 | <% levels.forEach(function (cWeek) { %> 43 | 44 | <% cWeek.forEach(function (cDayLevel) { %> 45 | 46 | <% DAY_Y += 12; %> 47 | <% }) %> 48 | <% DAY_Y = 0; %> 49 | <% --DAY_X %> 50 | <% WEEK_X += 13%> 51 | 52 | <% }) %> 53 | <% months.forEach(function (month) { %> 54 | <%= month.name %> 55 | <% }) %> 56 | 57 | Mon 58 | 59 | Wed 60 | 61 | Fri 62 | 63 | 64 | 65 |
66 | 67 | 78 | 79 |
80 |
Contributions in the last year 81 | <%= total %> total 82 | <%= start.format("LL") %> – <%= end.format("LL") %> 83 |
84 |
Longest streak 85 | <%= lStreak %> days 86 | <% if (lStreak !== 0) { %> 87 | <%= longestStreak.start.format("LL") %> – <%= longestStreak.end.format("LL") %> 88 | <% } %> 89 |
90 |
Current streak 91 | <%= cStreak %> days 92 | 93 | <% if (cStreak !== 0) { %> 94 | <%= currentStreak.start.format("LL") %> – <%= currentStreak.end.format("LL") %> 95 | <% } %> 96 | 97 |
98 |
99 | 100 | 101 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "bin": { 3 | "git-stats-html": "bin/git-stats-html" 4 | }, 5 | "name": "git-stats-html", 6 | "description": "Turn git-stats result into HTML output.", 7 | "keywords": [ 8 | "git", 9 | "stats", 10 | "html", 11 | "turn", 12 | "result", 13 | "into", 14 | "output" 15 | ], 16 | "license": "MIT", 17 | "version": "1.0.10", 18 | "main": "lib/index.js", 19 | "scripts": { 20 | "test": "echo \"Error: no test specified\" && exit 1" 21 | }, 22 | "author": "Ionică Bizău (https://ionicabizau.net)", 23 | "files": [ 24 | "bin/", 25 | "app/", 26 | "lib/", 27 | "dist/", 28 | "src/", 29 | "scripts/", 30 | "resources/", 31 | "menu/", 32 | "cli.js", 33 | "index.js", 34 | "index.d.ts", 35 | "package-lock.json", 36 | "bloggify.js", 37 | "bloggify.json", 38 | "bloggify/" 39 | ], 40 | "repository": { 41 | "type": "git", 42 | "url": "git+ssh://git@github.com/IonicaBizau/git-stats-html.git" 43 | }, 44 | "bugs": { 45 | "url": "https://github.com/IonicaBizau/git-stats-html/issues" 46 | }, 47 | "homepage": "https://github.com/IonicaBizau/git-stats-html#readme", 48 | "dependencies": { 49 | "ajs": "^1.2.3", 50 | "daty": "^1.0.7", 51 | "git-stats-colors": "^2.3.6", 52 | "github-calendar-legend": "^1.0.5", 53 | "map-o": "^2.0.5", 54 | "tilda": "^4.4.15" 55 | }, 56 | "blah": { 57 | "ex_img": "http://i.imgur.com/hnSUlCx.png", 58 | "description": "Check out [`git-stats`](https://github.com/IonicaBizau/git-stats) for more details about git-stats." 59 | } 60 | } --------------------------------------------------------------------------------