[
  {
    "path": ".github/FUNDING.yml",
    "content": "github: ionicabizau\npatreon: ionicabizau\nopen_collective: ionicabizau\ncustom: https://www.buymeacoffee.com/h96wwchmy"
  },
  {
    "path": ".gitignore",
    "content": "*.swp\n*.swo\n*~\n*.log\nnode_modules\n*.env\n.DS_Store\npackage-lock.json\n.bloggify/*\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# 🌟 Contributing\n\nWant to contribute to this project? Great! Please read these quick steps to streamline the process and avoid unnecessary tasks. ✨\n\n## 💬 Discuss Changes\nStart 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. 🖼️\n\nWait for feedback before proceeding unless the fix is straightforward, like a typo. 📝\n\n## 🔧 Fixing Issues\n\nFork 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. ✅\n\nIf a `package.json` or `bower.json` exists, add yourself to the `contributors` array; create it if it doesn't. 🙌\n\n```json\n{\n   \"contributors\": [\n      \"Your Name <your@email.address> (http://your.website)\"\n   ]\n}\n```\n\n## 📬 Creating a Pull Request\nOpen a pull request and reference the initial issue (e.g., *fixes #<your-issue-number>*). Provide a clear title and consider adding visual aids for clarity. 📊\n\n## ⏳ Wait for Feedback\nYour contributions will be reviewed. If feedback is given, update your branch as needed, and the pull request will auto-update. 🔄\n\n## 🎉 Everyone Is Happy!\nYour contributions will be merged, and everyone will appreciate your effort! 😄❤️\n\nThanks! 🤩\n\n[1]: /issues\n[2]: https://github.com/IonicaBizau/code-style"
  },
  {
    "path": "DOCUMENTATION.md",
    "content": "## Documentation\n\nYou can see below the API reference of this module.\n\n### `GhCal(username)`\nFetches the GitHub contributions calendar data (in JSON format).\n\n#### Params\n\n- **String|Object** `username`: The username or an object containing:\n - `username` (String): The GitHub username.\n - `cookie` (String): An optional cookie. Could be useful to get the private calendar stats.\n\n#### Return\n- **Request** The request stream.\n\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015-25 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->\n\n\n\n\n\n\n\n\n[![ghcal](http://i.imgur.com/yzElGZN.png)](#)\n\n\n\n\n\n\n\n\n\n\n\n# `$ ghcal`\n\n [![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/ghcal.svg)](https://www.npmjs.com/package/ghcal) [![Downloads](https://img.shields.io/npm/dt/ghcal.svg)](https://www.npmjs.com/package/ghcal) [![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)\n\n<a href=\"https://www.buymeacoffee.com/H96WwChMy\" target=\"_blank\"><img src=\"https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png\" alt=\"Buy Me A Coffee\"></a>\n\n\n\n\n\n\n\n> See the GitHub contributions calendar of a user in the command line.\n\n\n\n\n\n\nIf you want to track all your git commits (even if you don't push them anywhere), you should [check out the `git-stats` project](https://github.com/IonicaBizau/git-stats).\n\n\n\n\n\n\n[![ghcal](http://i.imgur.com/OhgCb8o.png)](#)\n\n\n\n\n\n\n\n## :cloud: Installation\n\nYou can install the package globally and use it as command line tool:\n\n\n```sh\n# Using npm\nnpm install --global ghcal\n\n# Using yarn\nyarn global add ghcal\n```\n\n\nThen, run `ghcal --help` and see what the CLI tool can do.\n\n\n```\n$ ghcal --help\nUsage: ghcal [options]\n\nOptions:\n  -u, --username <username>  The GitHub username. If you're using CLI GitHub,\n                             by default it will be your username.\n  -c, --cookie <cookie>      Your GitHub cookie. Useful to get private stats.\n  -s, --since <date>         Optional start date.\n  -e, --until <date>         Optional end date.\n  -n, --no-ansi              Forces the tool not to use ANSI styles.\n  -l, --light                Enables the light theme.\n  -h, --help                 Displays this help.\n  -v, --version              Displays version information.\n\nExamples:\n  ghcal -u ionicabizau\n  ghcal -u ionicabizau --light\n  ghcal -u ionicabizau --no-ansi\n  ghcal -u ionicabizau -s '1 January 2015' # All the commits from 1 January 2015 to now\n  ghcal -u ionicabizau -s '1 January 2015' -e '1 March 2015' # Select a time range\n\nNote that only the last year statistics are available.\n\nDocumentation can be found at https://github.com/IonicaBizau/ghcal\n```\n\n\n\n\n\n\n\n## Usage\n\n### Default behavior\n\n\nIf you are already using [`cli-github`](https://github.com/IonicaBizau/cli-github), then your GitHub username is kept into `~/.github-config.json` and `ghcal` will use it if you don't pass another username: `ghcal` will be the same with `ghcal -u <your-username>`.\n\n```sh\nghcal\n```\n\n### Passing the username\n\n\n Using the `-u` (or `--username`) option, you can specify the GitHub username:\n\n```sh\n# Fetches the izuzak's contributions\n$ ghcal -u izuzak\n```\n\n### Themes\n\n\nIf you pass the `--light` option, then the light theme will be activated (the default theme is dark).\n\n```sh\n# jlord's contributions, light theme\n$ ghcal jlord --light\n```\n\n### No ANSI styles\n\n\nThe `--no-ansi` option disables any colors in the output. Unicode characters, without colors will be used.\n\n```sh\n# @pengywynn's contributions, but without ANSI styles\n$ ghcal pengwynn --no-ansi\n```\n\n\n\n\n\n\n\n\n## :clipboard: Example\n\n\n\nHere is an example how to use this package as library. To install it locally, as library, you can use `npm install ghcal` (or `yarn add ghcal`):\n\n\n\n```js\nvar GhCal = require(\"ghcal\");\n\nGhCal(\"ionicabizau\", function (err, data) {\n    console.log(err || data);\n});\n```\n\n\n\n\n\n\n\n\n\n\n\n\n## :question: Get Help\n\nThere are few ways to get help:\n\n\n\n 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.\n 2. For bug reports and feature requests, open issues. :bug:\n 3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:\n\n\n\n\n\n\n\n## :memo: Documentation\n\nFor full API reference, see the [DOCUMENTATION.md][docs] file.\n\n\n\n\n\n\n\n\n\n\n\n\n## :yum: How to contribute\nHave an idea? Found a bug? See [how to contribute][contributing].\n\n\n## :sparkling_heart: Support my projects\nI open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,\nthis 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).\n\nHowever, 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:\n\n\n - Starring and sharing the projects you like :rocket:\n - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book:\n - [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:\n - [![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).\n - **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`\n\n    ![](https://i.imgur.com/z6OQI95.png)\n\n\nThanks! :heart:\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## :dizzy: Where is this library used?\nIf you are using this library in one of your projects, add it in this list. :sparkles:\n\n - `github-stats`\n\n\n\n\n\n\n\n\n\n\n\n## :scroll: License\n\n[MIT][license] © [Ionică Bizău][website]\n\n\n\n\n\n\n[license]: /LICENSE\n[website]: https://ionicabizau.net\n[contributing]: /CONTRIBUTING.md\n[docs]: /DOCUMENTATION.md\n[badge_patreon]: https://ionicabizau.github.io/badges/patreon.svg\n[badge_amazon]: https://ionicabizau.github.io/badges/amazon.svg\n[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg\n[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg\n[patreon]: https://www.patreon.com/ionicabizau\n[amazon]: http://amzn.eu/hRo9sIZ\n[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW\n"
  },
  {
    "path": "bin/ghcal",
    "content": "#!/usr/bin/env node\n\n// Dependencies\nvar GhCal = require(\"../lib\")\n  , GhConfig = {}\n  , Abs = require(\"abs\")\n  , CliGhCal = require(\"cli-gh-cal\")\n  , Logger = require(\"bug-killer\")\n  , Clp = require(\"clp\")\n  , Package = require(\"../package\")\n  , ReadJson = require(\"r-json\")\n  , Moment = require(\"moment\")\n  ;\n\n// Try to get the GitHub config username\nMoment.suppressDeprecationWarnings = true;\ntry {\n    GhConfig = ReadJson(Abs(\"~/.github-config.json\"));\n} catch (e) {}\n\n// Parse the command line arguments\nvar usernameOpt = new Clp.Option([\"u\", \"username\"], \"The GitHub username. If you're using CLI GitHub, by default it will be your username.\", \"username\", GhConfig.username)\n  , cookieOpt = new Clp.Option([\"c\", \"cookie\"], \"Your GitHub cookie. Useful to get private stats.\", \"cookie\")\n  , sinceDateOpt = new Clp.Option([\"s\", \"since\"], \"Optional start date.\", \"date\")\n  , untilDateOpt = new Clp.Option([\"e\", \"until\"], \"Optional end date.\", \"date\")\n  , noAnsiOpt = new Clp.Option([\"n\", \"no-ansi\"], \"Forces the tool not to use ANSI styles.\")\n  , lightOpt = new Clp.Option([\"l\", \"light\"], \"Enables the light theme.\")\n  , parser = new Clp({\n        name: \"GitHub Calendar\"\n      , version: Package.version\n      , exe: Package.name\n      , examples: [\n            \"ghcal -u ionicabizau\"\n          , \"ghcal -u ionicabizau --light\"\n          , \"ghcal -u ionicabizau --no-ansi\"\n          , \"ghcal -u ionicabizau -s '1 January 2015' # All the commits from 1 January 2015 to now\"\n          , \"ghcal -u ionicabizau -s '1 January 2015' -e '1 March 2015' # Select a time range\"\n        ]\n      , docs_url: Package.homepage\n      , notes: \"Note that only the last year statistics are available.\"\n      , process: true\n    }, [\n        usernameOpt\n      , cookieOpt\n      , sinceDateOpt\n      , untilDateOpt\n      , noAnsiOpt\n      , lightOpt\n    ])\n  ;\n\n// Stringify the stats\nGhCal({\n    username: usernameOpt.value\n  , cookie: cookieOpt.value\n}, function (err, data) {\n    if (err) { return Logger.log(err, \"error\"); }\n    console.log(CliGhCal(data, {\n        theme: lightOpt.is_provided ? \"LIGHT\" : noAnsiOpt.is_provided ? null : \"DARK\"\n      , start: sinceDateOpt.value  ? Moment(sinceDateOpt.value) : null\n      , end: untilDateOpt.value ? Moment(untilDateOpt.value) : null\n    }));\n});\n"
  },
  {
    "path": "example/index.js",
    "content": "var GhCal = require(\"../lib\");\n\nGhCal(\"ionicabizau\", function (err, data) {\n    console.log(err || data);\n});\n"
  },
  {
    "path": "lib/index.js",
    "content": "// Dependencies\nvar Cheerio = require(\"cheerio\")\n  , Request = require(\"request\")\n  , Typpy = require(\"typpy\")\n  ;\n\n/**\n * GhCal\n * Fetches the GitHub contributions calendar data (in JSON format).\n *\n * @name GhCal\n * @function\n * @param {String|Object} username The username or an object containing:\n *\n *  - `username` (String): The GitHub username.\n *  - `cookie` (String): An optional cookie. Could be useful to get the private calendar stats.\n *\n * @return {Request} The request stream.\n */\nvar GhCal = module.exports = function (options, callback) {\n\n    if (Typpy(options, String)) {\n        options = {\n            username: options\n        };\n    }\n\n    if (!options.username || !Typpy(options.username, String)) {\n        return callback(new Error(\"Invalid username.\"));\n    }\n\n    var url = \"http://github.com/users/\" + options.username + \"/contributions\"\n      , headers = {}\n      ;\n\n    if (options.cookie) {\n        headers[\"Cookie\"] = options.cookie;\n    }\n\n    return Request({\n        url: url\n      , headers: headers\n    }, function (err, res, body) {\n        if (err) { return callback(err); }\n        if (res.statusCode === 404) {\n            return callback(new Error(\"User doesn't exist.\"));\n        }\n        if (res.statusCode !== 200) {\n            return callback(new Error(\"Cannot fetch data for this user.\"));\n        }\n\n        var $ = Cheerio.load(body)\n          , $g = $(\"g > g\")\n          , $cRect = null\n          , $rect = null\n          , y = 0\n          , resData = []\n          , cDate = \"\"\n          , cCount = null\n          , cColor = \"\"\n          , cMonth = null\n          , monthHack = \"MMM\"\n          ;\n\n        for (; y < 7; ++y) {\n            $g.each(function (i) {\n                $rect = $(\"rect\", this).eq(y)\n                if (!$rect) { return; }\n                cDate = $rect.attr(\"data-date\");\n                cCount = parseInt($rect.attr(\"data-count\"));\n                if (!cDate || isNaN(cCount)) { return; }\n                resData.push([\n                    cDate\n                  , cCount\n                ]);\n            });\n        }\n\n        callback(null, resData);\n    });\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"ghcal\",\n  \"version\": \"2.3.13\",\n  \"description\": \"See the GitHub contributions calendar of a user in the command line.\",\n  \"main\": \"lib/index.js\",\n  \"bin\": {\n    \"ghcal\": \"./bin/ghcal\"\n  },\n  \"scripts\": {\n    \"test\": \"node test\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+ssh://git@github.com/IonicaBizau/ghcal.git\"\n  },\n  \"keywords\": [\n    \"github\",\n    \"contributions\",\n    \"command\",\n    \"line\"\n  ],\n  \"author\": \"Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/IonicaBizau/ghcal/issues\"\n  },\n  \"homepage\": \"https://github.com/IonicaBizau/ghcal\",\n  \"dependencies\": {\n    \"abs\": \"^1.0.0\",\n    \"ansi-parser\": \"^3.0.0\",\n    \"bug-killer\": \"^4.0.0\",\n    \"cheerio\": \"0.22.0\",\n    \"cli-box\": \"^5.0.0\",\n    \"cli-gh-cal\": \"^1.0.0\",\n    \"clp\": \"^3.0.0\",\n    \"git-stats-colors\": \"^2.1.0\",\n    \"moment\": \"^2.10.6\",\n    \"r-json\": \"^1.0.0\",\n    \"request\": \"^2.53.0\",\n    \"typpy\": \"^2.1.2\",\n    \"ul\": \"^5.0.0\"\n  },\n  \"devDependencies\": {},\n  \"blah\": {\n    \"h_img\": \"http://i.imgur.com/yzElGZN.png\",\n    \"ex_img\": \"http://i.imgur.com/OhgCb8o.png\",\n    \"description\": \"If you want to track all your git commits (even if you don't push them anywhere), you should [check out the `git-stats` project](https://github.com/IonicaBizau/git-stats).\",\n    \"installation\": [\n      {\n        \"h2\": \"Usage\"\n      },\n      {\n        \"h3\": \"Default behavior\"\n      },\n      {\n        \"p\": \"If you are already using [`cli-github`](https://github.com/IonicaBizau/cli-github), then your GitHub username is kept into `~/.github-config.json` and `ghcal` will use it if you don't pass another username: `ghcal` will be the same with `ghcal -u <your-username>`.\"\n      },\n      {\n        \"code\": {\n          \"language\": \"sh\",\n          \"content\": \"ghcal\"\n        }\n      },\n      {\n        \"h3\": \"Passing the username\"\n      },\n      {\n        \"p\": \" Using the `-u` (or `--username`) option, you can specify the GitHub username:\"\n      },\n      {\n        \"code\": {\n          \"language\": \"sh\",\n          \"content\": [\n            \"# Fetches the izuzak's contributions\",\n            \"$ ghcal -u izuzak\"\n          ]\n        }\n      },\n      {\n        \"h3\": \"Themes\"\n      },\n      {\n        \"p\": \"If you pass the `--light` option, then the light theme will be activated (the default theme is dark).\"\n      },\n      {\n        \"code\": {\n          \"language\": \"sh\",\n          \"content\": [\n            \"# jlord's contributions, light theme\",\n            \"$ ghcal jlord --light\"\n          ]\n        }\n      },\n      {\n        \"h3\": \"No ANSI styles\"\n      },\n      {\n        \"p\": \"The `--no-ansi` option disables any colors in the output. Unicode characters, without colors will be used.\"\n      },\n      {\n        \"code\": {\n          \"language\": \"sh\",\n          \"content\": [\n            \"# @pengywynn's contributions, but without ANSI styles\",\n            \"$ ghcal pengwynn --no-ansi\"\n          ]\n        }\n      }\n    ]\n  },\n  \"directories\": {\n    \"example\": \"example\"\n  },\n  \"files\": [\n    \"bin/\",\n    \"app/\",\n    \"lib/\",\n    \"dist/\",\n    \"src/\",\n    \"scripts/\",\n    \"resources/\",\n    \"menu/\",\n    \"cli.js\",\n    \"index.js\",\n    \"index.d.ts\",\n    \"package-lock.json\",\n    \"bloggify.js\",\n    \"bloggify.json\",\n    \"bloggify/\"\n  ]\n}"
  },
  {
    "path": "snap/snapcraft.yaml",
    "content": "name: ghcal\nbase: core18\nversion: git\nsummary: See the GitHub contributions calendar of a user in the command line\ndescription: |\n  See the GitHub contributions calendar of a user in the command line.\n  For example:\n    ghcal -u ionicabizau\n    ghcal -u ionicabizau --light\n    ghcal -u ionicabizau --no-ansi\n\ngrade: stable\nconfinement: strict\n\nparts:\n  ghcal:\n    plugin: nodejs\n    source: .\n\napps:\n  ghcal:\n    command: ghcal\n    plugs: [home, network]\n"
  }
]