Update documentation and reorder plugins by categorie

This commit is contained in:
lowlighter
2021-02-17 14:09:20 +01:00
parent 27ff6585ff
commit 404c643bcf
9 changed files with 27 additions and 19 deletions

View File

@@ -1,15 +1,10 @@
name: "🧩 <%= `${name.charAt(0).toLocaleUpperCase()}${name.substring(1)}` %>" name: "🧩 <%= `${name.charAt(0).toLocaleUpperCase()}${name.substring(1)}` %>"
cost: Estimates how many GitHub requests is used during plugin execution ("N/A" for Third-Party services)
# Estimate of how many GitHub requests will be used categorie: other # Set plugin categorie ("github", "social", "health" or "other")
cost: N/A
# Supported modes
supports: supports:
- user - user # Support users account
- organization - organization # Support organizations account
- repository - repository # Support repositories metrics
# Inputs list
inputs: inputs:
# Enable or disable plugin # Enable or disable plugin

View File

@@ -2,6 +2,6 @@
![Build](https://github.com/lowlighter/metrics/workflows/Build/badge.svg) ![Build](https://github.com/lowlighter/metrics/workflows/Build/badge.svg)
<% for (const partial of ["introduction", "shared", "setup", "documentation", "references", "license"]) { -%> <% for (const partial of ["introduction", "shared", "setup", "documentation", "license", "references"]) { -%>
<%- await include(`/partials/${partial}.md`) %> <%- await include(`/partials/${partial}.md`) %>
<% } %> <% } %>

View File

@@ -3,8 +3,8 @@
<table> <table>
<tr> <tr>
<th nowrap="nowrap">Template\Plugin</th><%# -%> <th nowrap="nowrap">Template\Plugin</th><%# -%>
<% for (const [plugin, {icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %> <% for (const [plugin, {name, icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %>
<th nowrap="nowrap" align="center"><%= icon %></th><% } %> <th nowrap="nowrap" align="center" title="<%= name %>"><%= icon %></th><% } %>
</tr><%# -%> </tr><%# -%>
<% for (const [template, {name, readme}] of Object.entries(templates).filter(([key, value]) => (value)&&(!["community"].includes(key)))) { %> <% for (const [template, {name, readme}] of Object.entries(templates).filter(([key, value]) => (value)&&(!["community"].includes(key)))) { %>
<tr> <tr>

View File

@@ -2,6 +2,9 @@
Plugins are features which provide additional content and lets you customize your rendered metrics. Plugins are features which provide additional content and lets you customize your rendered metrics.
See their respective documentation for more informations about how to setup them: See their respective documentation for more informations about how to setup them:
<% for (const [plugin, {name}] of Object.entries(plugins).filter(([key, value]) => value)) { %> <% { let previous = null; for (const [plugin, {name, categorie}] of Object.entries(plugins).filter(([key, value]) => value)) { %>
* [<%= name %>](/source/plugins/<%= plugin %>/README.md)<%# -%> <% if (previous !== categorie) { previous = categorie -%>
<% } %> * **<%= `${categorie.charAt(0).toLocaleUpperCase()}${categorie.substring(1)}` %>**
<% } -%>
* [<%= name %>](/source/plugins/<%= plugin %>/README.md)<%# -%>
<% }} %>

View File

@@ -298,6 +298,7 @@ Here's an example:
```yaml ```yaml
name: "🧩 Plugin name (with emoji icon)" name: "🧩 Plugin name (with emoji icon)"
cost: Estimates how many GitHub requests is used during plugin execution ("N/A" for Third-Party services) cost: Estimates how many GitHub requests is used during plugin execution ("N/A" for Third-Party services)
categorie: github # Plugin categorie ("github", "social", "health" or "other")
supports: supports:
- user # Support users account - user # Support users account
- organization # Support organizations account - organization # Support organizations account

View File

@@ -4,6 +4,9 @@
import url from "url" import url from "url"
import yaml from "js-yaml" import yaml from "js-yaml"
//Defined categories
const categories = ["core", "github", "social", "health", "other"]
/**Metadata descriptor parser */ /**Metadata descriptor parser */
export default async function metadata({log = true} = {}) { export default async function metadata({log = true} = {}) {
//Paths //Paths
@@ -25,7 +28,7 @@
} }
//Reorder keys //Reorder keys
const {base, core, ...plugins} = Plugins const {base, core, ...plugins} = Plugins
Plugins = {base, core, ...plugins} Plugins = Object.fromEntries(Object.entries(Plugins).sort(([_an, a], [_bn, b]) => categories.indexOf(a.categorie) - categories.indexOf(b.categorie)))
//Load templates metadata //Load templates metadata
let Templates = {} let Templates = {}
@@ -53,6 +56,10 @@
const raw = `${await fs.promises.readFile(path.join(__plugins, name, "metadata.yml"), "utf-8")}` const raw = `${await fs.promises.readFile(path.join(__plugins, name, "metadata.yml"), "utf-8")}`
const {inputs, ...meta} = yaml.load(raw) const {inputs, ...meta} = yaml.load(raw)
//Categorie
if (!categories.includes(meta.categorie))
meta.categorie = "other"
//Inputs parser //Inputs parser
{ {
meta.inputs = function({data:{user = null} = {}, q, account}, defaults = {}) { meta.inputs = function({data:{user = null} = {}, q, account}, defaults = {}) {
@@ -260,7 +267,7 @@
return { return {
name:raw.match(/^### (?<name>[\s\S]+?)\n/)?.groups?.name?.trim(), name:raw.match(/^### (?<name>[\s\S]+?)\n/)?.groups?.name?.trim(),
readme:{ readme:{
demo:raw.match(/(?<demo><table>[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? (name === "community" ? "<td align=\"center\">See <a href=\"/source/templates/community/README.md\">documentation</a> 🌍</td>" : "<td></td>"), demo:raw.match(/(?<demo><table>[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? (name === "community" ? "<td align=\"center\"><h3>See <a href=\"/source/templates/community/README.md\">documentation</a> 🌍</h3></td>" : "<td></td>"),
compatibility:{...compatibility, base:true}, compatibility:{...compatibility, base:true},
}, },
} }

View File

@@ -1,5 +1,6 @@
name: "🏅 Contributors" name: "🏅 Contributors"
cost: N/A cost: N/A
categorie: github
supports: supports:
- repository - repository
inputs: inputs:

View File

@@ -1,5 +1,6 @@
name: "📜 Licenses" name: "📜 Licenses"
cost: N/A cost: N/A
categorie: github
supports: supports:
- repository - repository
inputs: inputs: