This commit is contained in:
lowlighter
2022-09-01 22:23:22 -04:00
10 changed files with 59 additions and 11 deletions

View File

@@ -19,7 +19,7 @@ Generate metrics that can be embedded everywhere, including your GitHub profile
</tr>
<tr>
<th colspan="2" align="center">
<h3><a href="/README.md#-plugins">🧩 Customizable with 40 plugins and 282 options!</a></h3>
<h3><a href="/README.md#-plugins">🧩 Customizable with 40 plugins and 285 options!</a></h3>
</th>
</tr>
<tr>
@@ -362,6 +362,8 @@ Generate metrics that can be embedded everywhere, including your GitHub profile
# 📚 Documentation
> <sup>*⚠️ This is the documentation of **v3.28-beta** (`@master`/`@main` branches) which includes [unreleased features](https://github.com/lowlighter/metrics/compare/latest...master) planned for next release. See documentation for current released version [**v3.27** (`@latest` branch) here](https://github.com/lowlighter/metrics/blob/latest/README.md).* </sup>
## 🦮 Setup

12
action.yml generated
View File

@@ -439,6 +439,10 @@ inputs:
description: Events to use
default: <default-value>
plugin_habits_skipped:
description: Skipped repositories
default: <default-value>
plugin_habits_days:
description: Event maximum age
default: <default-value>
@@ -656,6 +660,10 @@ inputs:
description: Featured repositories display order
default: <default-value>
plugin_repositories_forks:
description: Include repositories forks
default: <default-value>
plugin_repositories_affiliations:
description: Repositories affiliations
default: <default-value>
@@ -783,6 +791,10 @@ inputs:
description: Contribution types filter
default: <default-value>
plugin_notable_self:
description: Include own repositories
default: <default-value>
# ====================================================================================
# 📰 Recent activity

View File

@@ -141,10 +141,10 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
q = Object.fromEntries([...Object.entries(q).map(([key, value]) => [key.replace(/^plugin_/, "").replace(/_/g, "."), value]), ["base", false]])
//Check users errors
const warnings = []
if ((!Object.keys(Plugins).filter(key => q[key]).length)&&(!parts.length))
warnings.push({warning:{message:"No plugin were selected"}})
if ((!Object.keys(Plugins).filter(key => q[key]).length) && (!parts.length))
warnings.push({warning: {message: "No plugin were selected"}})
const ineffective = Object.keys(q).filter(key => (key.includes(".")) && (key.split(".").at(0) !== "base") && (key.split(".").at(0) in Plugins)).filter(key => !q[key.split(".").at(0)])
warnings.push(...ineffective.map(key => ({warning:{message:`"${key}" has no effect because "${key.split(".").at(0)}: true" is not set`}})))
warnings.push(...ineffective.map(key => ({warning: {message: `"${key}" has no effect because "${key.split(".").at(0)}: true" is not set`}})))
//Compute rendering
const {rendered} = await metrics({login, q}, {...arguments[1], convert: ["svg", "png", "jpeg"].includes(q["config.output"]) ? q["config.output"] : null, warnings}, arguments[2])
console.debug(`metrics/compute/${login}/embed > ${name} > success >>>>>>>>>>>>>>>>>>>>>>`)

View File

@@ -220,9 +220,9 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
//Enable state handler
{
meta.enabled = function(enabled, {extras = {}, error = true} = {}) {
if ((process.env.GITHUB_ACTIONS)&&(!enabled))
if ((process.env.GITHUB_ACTIONS) && (!enabled))
console.warn(`::warning::Plugin "${name}" is currently disabled. Add "plugin_${name}: yes" to your workflow to enable it.`)
if ((error)&&(!enabled))
if ((error) && (!enabled))
throw Object.assign(new Error(`Plugin "${name}" is disabled${process.env.GITHUB_ACTIONS ? "" : " on this server"}`), {enabled: true})
return (enabled) && (meta.extras("enabled", {extras, error}))
}

View File

@@ -131,7 +131,7 @@ export function formatters({timeZone} = {}) {
format.error = function(error, {descriptions = {}, ...attributes} = {}) {
try {
//Extras features or enable state error
if ((error.extras)||(error.enabled))
if ((error.extras) || (error.enabled))
throw {error: {message: error.message, instance: error}}
//Already formatted error
if (error.error?.message)

View File

@@ -180,9 +180,9 @@ export default async function({sandbox = false} = {}) {
const custom = uapi(session)
if (custom) {
try {
const {data: {resources}} = await custom.rest.rateLimit.get()
if (resources)
return res.status(200).json({rest: resources.core, graphql: resources.graphql, search: resources.search, login: custom.login})
const {data: {resources}} = await custom.rest.rateLimit.get()
if (resources)
return res.status(200).json({rest: resources.core, graphql: resources.graphql, search: resources.search, login: custom.login})
}
catch (error) {
if (error.status === 401) {

View File

@@ -245,7 +245,7 @@ export default async function(
//Plugin execution
try {
//Check if plugin is enabled and requirements are met
if ((!enabled)||(!q.my_plugin))
if ((!q.my_plugin)||(imports.metadata.plugins.my_plugin.enabled(enabled, {extras})))
return null
//Automatically validate user inputs

View File

@@ -57,6 +57,18 @@ All product and company names are trademarks™ or registered® trademarks of th
≤ 1000)</i>
<br>
<b>default:</b> 200<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_habits_skipped</code></h4></td>
<td rowspan="2"><p>Skipped repositories</p>
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">⏩ Inherits <code>repositories_skipped</code><br>
✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>array</code>
<i>(comma-separated)</i>
<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_habits_days</code></h4></td>

View File

@@ -127,6 +127,17 @@ Some repositories may not be able to reported advanced stats and in the case the
<b>default:</b> commit<br>
<b>allowed values:</b><ul><li>commit</li><li>pull_request</li><li>issue</li></ul></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_notable_self</code></h4></td>
<td rowspan="2"><p>Include own repositories</p>
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>boolean</code>
<br>
<b>default:</b> no<br></td>
</tr>
</table>
<!--/options-->

View File

@@ -110,6 +110,17 @@ All product and company names are trademarks™ or registered® trademarks of th
<br>
<b>default:</b> featured, pinned, starred, random<br>
<b>allowed values:</b><ul><li>featured</li><li>pinned</li><li>starred</li><li>random</li></ul></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_repositories_forks</code></h4></td>
<td rowspan="2"><p>Include repositories forks</p>
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>boolean</code>
<br>
<b>default:</b> no<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_repositories_affiliations</code></h4></td>