From 7ff3a7f46be2523819747a0852af8e7979763628 Mon Sep 17 00:00:00 2001
From: lowlighter <22963968+lowlighter@users.noreply.github.com>
Date: Tue, 13 Oct 2020 23:00:05 +0200
Subject: [PATCH] Add new plugin habits
---
README.md | 52 ++++++++++++++++++++++++++++++
action.yml | 2 ++
action/dist/index.js | 35 ++++++++++++++++++--
action/index.mjs | 1 +
package.json | 2 +-
settings.example.json | 6 +++-
src/html/index.html | 25 ++++++++++-----
src/html/placeholder.svg | 2 +-
src/metrics.mjs | 1 +
src/plugins/habits/index.mjs | 57 +++++++++++++++++++++++++++++++++
src/plugins/index.mjs | 2 ++
src/plugins/lines/index.mjs | 7 ++--
src/plugins/pagespeed/index.mjs | 11 ++++---
src/plugins/traffic/index.mjs | 10 +++---
src/style.css | 7 ++++
src/template.svg | 26 ++++++++++++++-
16 files changed, 221 insertions(+), 25 deletions(-)
create mode 100644 src/plugins/habits/index.mjs
diff --git a/README.md b/README.md
index c917a02f..e93a6298 100644
--- a/README.md
+++ b/README.md
@@ -106,6 +106,9 @@ jobs:
# The provided GitHub token will require "repo" permissions
plugin_traffic: no
+ # Enable or disable coding habits metrics
+ plugin_habits: no
+
# Enable debug logs
debug: no
@@ -273,6 +276,17 @@ Open and edit `settings.json` to configure your instance.
//When enabled, pass "?traffic=1" in url to compute total page views in your repositories in last two weeks
//Note that this requires that the passed GitHub API token requires a push access
"enabled":true
+ },
+ //Habits plugin
+ "habits":{
+ //Enable or disable this plugin
+ //When enabled, pass "?habits=1" in url to generate coding habits based on your recent activity
+ //This includes stuff like if you're using tabs or space and the time of the day when you push the most
+ //Note that this requires that the passed GitHub API token requires a push access
+ "enabled":true,
+ //Specify the number of events used to compute coding habits. Capped at 100 by GitHub API
+ //Defaults to 50
+ "from":50,
}
}
}
@@ -485,6 +499,44 @@ And pass `?traffic=1` in url when generating metrics.
+#### 💡 Habits
+
+The *habits* plugin allows you to add deduced coding about based on your recent activity.
+
+
+
+
+💬 About
+
+It will consume an additional GitHub request per event fetched.
+
+##### Setup with GitHub actions
+
+Add the following to your workflow :
+
+```yaml
+- uses: lowlighter/metrics@latest
+ with:
+ # ... other options
+ plugin_habits: yes
+```
+
+##### Setup in your own instance
+
+Add the following to your `settings.json`
+
+```json
+ "plugins":{
+ "habits":{
+ "enabled":true
+ }
+ }
+```
+
+And pass `?habits=1` in url when generating metrics.
+
+
+
### 🗂️ Project structure
* `index.mjs` contains the entry points and the settings instance
diff --git a/action.yml b/action.yml
index 5d66cd6d..45be0c17 100644
--- a/action.yml
+++ b/action.yml
@@ -24,6 +24,8 @@ inputs:
description: Enable repositories lines metrics
plugin_traffic:
description: Enable repositories traffic metrics (due to GitHub API limitations, "token" must have "repo" permissions)
+ plugin_habits:
+ description: Enable coding habits metrics
debug:
description: Enable debug logs
runs:
diff --git a/action/dist/index.js b/action/dist/index.js
index bc36a77b..b3a0c960 100644
--- a/action/dist/index.js
+++ b/action/dist/index.js
@@ -1,4 +1,4 @@
-module.exports=(()=>{var __webpack_modules__={76677:(e,t,r)=>{"use strict";r.r(t);var n=r(85622);var i=r.n(n);var a=r(60270);var o=r(3584);var s=r(32882);var l=r.n(s);var c=r(29483);var u=r.n(c);(async function(){const[e,t,r,n]=[s,c,o,a].map(e=>e&&e.default?e.default:e);try{console.log(`GitHub metrics as SVG image`);console.log(`========================================================`);console.log(`Version | 1.6.0`);process.on("unhandledRejection",e=>{throw e});const a=`