diff --git a/.env b/.env index 9f8d4bc..60bb1b7 100644 --- a/.env +++ b/.env @@ -1,4 +1,6 @@ GITHUB_USERNAME="" CONTRIBUTION_GOAL_TRACKING=true CONTRIBUTION_GOAL="1000" +CONTRIBUTION_GOAL_DAILY_TRACKING=true +CONTRIBUTION_GOAL_DAILY="5" COMPACT_UI=true diff --git a/README.md b/README.md index 9329676..21c57e5 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,14 @@ $ npm install ### Configure -In the root folder you'll need to modify the `.env` file with **your** GitHub username. Here you'll also be able to customize contribution goal tracking as well. Simply give the tracking value `TRUE` or `FALSE` to turn it on or off, respectively, and provide your ideal goal number to give yourself a completion percentage. +In the root folder you'll need to modify the `.env` file with **your** GitHub username. Here you'll also be able to customize contribution goal tracking as well. Simply give the tracking value `TRUE` or `FALSE` to turn it on or off, respectively, and provide your ideal goal number to give yourself a completion percentage. You can also enable the tracking of daily contributions. ```bash GITHUB_USERNAME="" CONTRIBUTION_GOAL_TRACKING=true CONTRIBUTION_GOAL="1000" +CONTRIBUTION_GOAL_DAILY_TRACKING=true +CONTRIBUTION_GOAL_DAILY="5" COMPACT_UI=true ``` @@ -54,7 +56,7 @@ Obviously [BitBar](https://github.com/matryer/bitbar). I also use the [gh-scrape](https://github.com/Shikkic/gh-scrape) to crawl GitHub and parse selected values from public GitHub profiles. Feel free to contribute if you'd like! -I use this module instead of using the GitHub API for a few reasons. I wanted to make it as easy as possible to setup and requiring users to generate and input an API key made the barrier of entry seem high. Also, this allows us to only focus on publicly available contributions, which was the original intended purpose. +I use this module instead of using the GitHub API for a few reasons. I wanted to make it as easy as possible to setup and requiring users to generate and input an API key made the barrier of entry seem high. Also, this allows us to only focus on publicly available contributions, which was the original intended purpose. #### Suggestions, comments? diff --git a/gitbar_plugin/gh.5m.js b/gitbar_plugin/gh.5m.js index 15f7ff8..c946c89 100755 --- a/gitbar_plugin/gh.5m.js +++ b/gitbar_plugin/gh.5m.js @@ -15,9 +15,16 @@ require('dotenv').config({path: __dirname+'/../.env'}); const username = process.env.GITHUB_USERNAME; const userUrl = "http://github.com/" + username; + +const compactUI = process.env.COMPACT_UI; + +// Yearly contribution goal const contributionGoalTracking = process.env.CONTRIBUTION_GOAL_TRACKING; const contributionGoal = process.env.CONTRIBUTION_GOAL; -const compactUI = process.env.COMPACT_UI; + +// Daily contribution goal +const contributionGoalDailyTracking = process.env.CONTRIBUTION_GOAL_DAILY_TRACKING; +const contributionGoalDaily = process.env.CONTRIBUTION_GOAL_DAILY; // Detect user's menu bar style var child_process = require('child_process'); @@ -32,10 +39,12 @@ try { // Font, Color, and Emoji Settings const redText = "| color=red size=14", - normalText = "| size=14", - boldText = "| color=" + boldColor + " size=14", - heartEmoji = ":heart_decoration:", - brokenHeartEmoji = ":broken_heart:"; + normalText = "| size=14", + boldText = "| color=" + boldColor + " size=14", + heartEmoji = ":heart_decoration:", + brokenHeartEmoji = ":broken_heart:", + chartEmoji = ":chart_with_upwards_trend:", + starEmoji = ":star:"; // Import Github Scraping Library var gh = require('gh-scrape'), @@ -65,8 +74,16 @@ gh.scrapeContributionDataAndStats(userUrl, function(data) { // Set Displayed Emoji var visibleEmoji = data.commitsToday ? heartEmoji : brokenHeartEmoji; + if (contributionGoalDailyTracking == 'true') { + if (commitsToday >= contributionGoalDaily) { + visibleEmoji = starEmoji; + } else { + visibleEmoji = chartEmoji; + } + } + // Log Output To Bitbar - if (compactUI == 'true') { + if (compactUI === "true") { console.log(visibleEmoji + " " + commitsToday + contributionsTodayColor); console.log("---"); console.log("Contributions"); @@ -76,13 +93,20 @@ gh.scrapeContributionDataAndStats(userUrl, function(data) { console.log("---"); } console.log("Total: ", totalContributions, totalContributionsColor); - if (contributionGoalTracking) { - // Log Contribution Goal tracking if enabled + if (contributionGoalTracking === "true") { + // Log Yearly Contribution Goal tracking if enabled console.log("---"); - console.log("Contribution Goal"); + console.log("Yearly Contribution Goal"); console.log("Goal: ", contributionGoal, normalText); console.log("Completion: ", (totalContributions / contributionGoal * 100).toFixed(2) + "% " + boldText); } + if (contributionGoalDailyTracking === "true") { + // Log Yearly Contribution Goal tracking if enabled + console.log("---"); + console.log("Daily Contribution Goal"); + console.log("Goal: ", contributionGoalDaily, normalText); + console.log("Completion: ", (commitsToday / contributionGoalDaily * 100).toFixed(2) + "% " + boldText); + } console.log("---"); console.log("Streaks"); console.log("Current: ", currentStreak, currentStreakColor); diff --git a/package.json b/package.json index b441578..5880d1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitbar", - "version": "0.0.0", + "version": "0.1.0", "description": "text", "main": "index.js", "scripts": {