ci(docs): add support for option flags

This commit is contained in:
lowlighter
2022-01-14 01:40:00 -05:00
parent adc2924570
commit 48c1d5c249
15 changed files with 108 additions and 41 deletions

View File

@@ -106,7 +106,7 @@ metadata.plugin = async function({__plugins, name, logger}) {
} }
//Inputs checks //Inputs checks
const result = Object.fromEntries( const result = Object.fromEntries(
Object.entries(inputs).map(([key, {type, format, default:defaulted, min, max, values}]) => [ Object.entries(inputs).map(([key, {type, format, default:defaulted, min, max, values, inherits}]) => [
//Format key //Format key
metadata.to.query(key, {name}), metadata.to.query(key, {name}),
//Format value //Format value
@@ -269,25 +269,46 @@ metadata.plugin = async function({__plugins, name, logger}) {
const demo = raw.match(/(?<demo><table>[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? "<td></td>" const demo = raw.match(/(?<demo><table>[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? "<td></td>"
//Options table //Options table
let flags = new Set()
const table = [ const table = [
"| Option | Type *(format)* **[default]** *{allowed values}* | Description |", "| Option | Type *(format)* **[default]** *{allowed values}* | Description |",
"| ------ | -------------------------------- | ----------- |", "| ------ | -------------------------------- | ----------- |",
Object.entries(inputs).map(([option, {description, type, ...o}]) => { Object.entries(inputs).map(([option, {description, type, ...o}]) => {
let row = [] let row = []
{ {
const cell = [`${"`"}${option}${"`"}`] let cell = []
if (o.required)
cell.push("✔️"), flags.add("required")
if (type === "token") if (type === "token")
cell.push("🔐") cell.push("🔐"), flags.add("secret")
if (o.inherits)
cell.push("⏩"), flags.add("inherits")
if (o.global)
cell.push("⏭️"), flags.add("global")
if (o.testing)
cell.push("🔧"), flags.add("testing")
if (!Object.keys(previous?.inputs ?? {}).includes(option)) if (!Object.keys(previous?.inputs ?? {}).includes(option))
cell.push("✨") cell.push("✨"), flags.add("beta")
if (o.extras)
cell.push("🧰"), flags.add("extras")
cell = cell.map(flag => `<sup>${flag}</sup>`)
cell.unshift(`${"`"}${option}${"`"}`)
row.push(cell.join(" ")) row.push(cell.join(" "))
} }
{ {
const cell = [`${"`"}${type}${"`"}`] const cell = [`${"`"}${type}${"`"}`]
if ("format" in o) if ("format" in o)
cell.push(`*(${o.format})*`) cell.push(`*(${Array.isArray(o.format) ? o.format[0] : o.format})*`)
if ("default" in o) if ("default" in o) {
cell.push(`**[${o.default}]**`) let text = o.default
if (o.default === ".user.login")
text = "*→ User login*"
if (o.default === ".user.twitter")
text = "*→ User attached twitter*"
if (o.default === ".user.website")
text = "*→ User attached website*"
cell.push(`**[${text}]**`)
}
if ("values" in o) if ("values" in o)
cell.push(`*{${o.values.map(value => `"${value}"`).join(", ")}}*`) cell.push(`*{${o.values.map(value => `"${value}"`).join(", ")}}*`)
if ("min" in o) if ("min" in o)
@@ -302,9 +323,14 @@ metadata.plugin = async function({__plugins, name, logger}) {
return `| ${row.join(" | ")} |` return `| ${row.join(" | ")} |`
}).join("\n"), }).join("\n"),
"\n", "\n",
"Legend for option icons:", flags.size ? "Legend for option icons:" : "",
"* 🔐 Value should be stored in repository secrets", flags.has("required") ? "* ✔️ Value must be provided" : "",
"* ✨ New feature currently in testing on `master`/`main`" flags.has("secret") ? "* 🔐 Value should be stored in repository secrets" : "",
flags.has("inherits") ? "* ⏩ Value inherits from its related global-level option" : "",
flags.has("global") ? "* ⏭️ Value be inherited by its related plugin-level option" : "",
flags.has("testing") ? "* 🔧 For development purposes, use with caution" : "",
flags.has("beta") ? "* ✨ Currently in beta-testing on `master`/`main`" : "",
flags.has("extras") ? "* 🧰 Must be enabled in `settings.json` (for web instances)" : "",
].flat(Infinity).filter(s => s).join("\n") ].flat(Infinity).filter(s => s).join("\n")
//Readme descriptor //Readme descriptor

View File

@@ -88,8 +88,10 @@ inputs:
format: comma-separated format: comma-separated
default: "" default: ""
example: my-repo-1, my-repo-2, owner/repo-3, ... example: my-repo-1, my-repo-2, owner/repo-3, ...
inherits: repositories_skipped
# Ignored actors (useful to ignore bots users) # Ignored actors (useful to ignore bots users)
plugin_activity_ignored: plugin_activity_ignored:
description: Actors to ignore description: Actors to ignore
default: github-actions[bot], dependabot[bot], dependabot-preview[bot] default: ""
inherits: users_ignored

View File

@@ -29,7 +29,6 @@ inputs:
default: 100 default: 100
min: 0 min: 0
# Number of repositories to load at once by queries # Number of repositories to load at once by queries
# If you encounter GitHub queries timeouts, using a lower value here may solve issues # If you encounter GitHub queries timeouts, using a lower value here may solve issues
repositories_batch: repositories_batch:
@@ -66,6 +65,16 @@ inputs:
format: comma-separated format: comma-separated
default: "" default: ""
example: my-repo-1, my-repo-2, owner/repo-3, ... example: my-repo-1, my-repo-2, owner/repo-3, ...
global: yes
# List of default ignored users
# Plugins supporting a "skip users option" will automatically append users listed in this option
users_ignored:
description: Default users to ignore
type: array
format: comma-separated
default: github-actions[bot], dependabot[bot], dependabot-preview[bot]
global: yes
# List of surnames or email addresses you use when authoring commits # List of surnames or email addresses you use when authoring commits
# These are mostly used to perform commits analysis to detect ownership # These are mostly used to perform commits analysis to detect ownership
@@ -75,3 +84,4 @@ inputs:
format: comma-seperated format: comma-seperated
default: .user.login default: .user.login
example: lowlighter, lowlighter@users.noreply.github.com example: lowlighter, lowlighter@users.noreply.github.com
global: yes

View File

@@ -45,6 +45,7 @@ inputs:
format: comma-separated format: comma-separated
default: "" default: ""
example: my-repo-1, my-repo-2, owner/repo-3, ... example: my-repo-1, my-repo-2, owner/repo-3, ...
inherits: repositories_skipped
# Restrict code snippet languages # Restrict code snippet languages
# These are guessed through linguist # These are guessed through linguist

View File

@@ -32,6 +32,7 @@ inputs:
type: array type: array
format: comma-separated format: comma-separated
default: github-actions[bot], dependabot[bot], dependabot-preview[bot] default: github-actions[bot], dependabot[bot], dependabot-preview[bot]
inherits: users_ignored
# Display total contributions for each contributor # Display total contributions for each contributor
plugin_contributors_contributions: plugin_contributors_contributions:
@@ -65,3 +66,4 @@ inputs:
"💻 Code": ["source/**", "src/**"], "💻 Code": ["source/**", "src/**"],
"#️⃣ Others": ["*"] "#️⃣ Others": ["*"]
} }
extras: yes

View File

@@ -1,4 +1,4 @@
- name: 📗 Classic template - name: Classic template
uses: lowlighter/metrics@latest uses: lowlighter/metrics@latest
with: with:
filename: metrics.classic.svg filename: metrics.classic.svg
@@ -6,7 +6,7 @@
base: header, repositories base: header, repositories
plugin_lines: yes plugin_lines: yes
- name: 📘 Repository template - name: Repository template
uses: lowlighter/metrics@latest uses: lowlighter/metrics@latest
with: with:
template: repository template: repository
@@ -19,7 +19,7 @@
plugin_projects: yes plugin_projects: yes
plugin_projects_repositories: lowlighter/metrics/projects/1 plugin_projects_repositories: lowlighter/metrics/projects/1
- name: 📙 Terminal template - name: Terminal template
uses: lowlighter/metrics@latest uses: lowlighter/metrics@latest
with: with:
template: terminal template: terminal
@@ -27,7 +27,7 @@
token: ${{ secrets.METRICS_TOKEN }} token: ${{ secrets.METRICS_TOKEN }}
base: header, metadata base: header, metadata
- name: 📒 Markdown template - name: Markdown template
uses: lowlighter/metrics@latest uses: lowlighter/metrics@latest
with: with:
template: markdown template: markdown
@@ -36,7 +36,7 @@
config_output: markdown config_output: markdown
token: ${{ secrets.METRICS_TOKEN }} token: ${{ secrets.METRICS_TOKEN }}
- name: 📒 Markdown template (with plugins) - name: Markdown template (with plugins)
uses: lowlighter/metrics@latest uses: lowlighter/metrics@latest
with: with:
template: markdown template: markdown
@@ -66,7 +66,7 @@
plugin_languages: yes plugin_languages: yes
token: ${{ secrets.METRICS_TOKEN }} token: ${{ secrets.METRICS_TOKEN }}
- name: 📒 Markdown template (pdf output) - name: Markdown template (pdf output)
uses: lowlighter/metrics@latest uses: lowlighter/metrics@latest
with: with:
template: markdown template: markdown
@@ -81,7 +81,7 @@
config_padding: 5% config_padding: 5%
token: ${{ secrets.METRICS_TOKEN }} token: ${{ secrets.METRICS_TOKEN }}
- name: 📕 Community templates - name: Community templates
uses: lowlighter/metrics@latest uses: lowlighter/metrics@latest
with: with:
token: ${{ secrets.METRICS_TOKEN }} token: ${{ secrets.METRICS_TOKEN }}

View File

@@ -124,6 +124,7 @@ inputs:
- comma-separated - comma-separated
- /(?<user>[-a-z0-9]+)[/](?<repo>[-a-z0-9]+)@(?<branch>[-a-z0-9]+):(?<template>[-a-z0-9]+)/ - /(?<user>[-a-z0-9]+)[/](?<repo>[-a-z0-9]+)@(?<branch>[-a-z0-9]+):(?<template>[-a-z0-9]+)/
default: "" default: ""
extras: yes
# Template to use # Template to use
# To use community template, prefix its name with "@" # To use community template, prefix its name with "@"
@@ -150,6 +151,7 @@ inputs:
description: Extra CSS description: Extra CSS
type: string type: string
default: "" default: ""
extras: yes
# Timezone used by metrics # Timezone used by metrics
# See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones # See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
@@ -157,6 +159,7 @@ inputs:
description: Timezone used description: Timezone used
type: string type: string
default: "" default: ""
global: yes
# Specify in which order metrics content will be displayed # Specify in which order metrics content will be displayed
# If you omit some partials, they'll be appended at the end in default order # If you omit some partials, they'll be appended at the end in default order
@@ -167,6 +170,7 @@ inputs:
format: comma-separated format: comma-separated
default: "" default: ""
example: base.header, base.repositories example: base.header, base.repositories
global: yes
# Use twemojis instead of emojis # Use twemojis instead of emojis
# May increase filesize but emojis will be rendered the same across all platforms # May increase filesize but emojis will be rendered the same across all platforms
@@ -174,6 +178,7 @@ inputs:
description: Use twemojis instead of emojis description: Use twemojis instead of emojis
type: boolean type: boolean
default: no default: no
global: yes
# Render GitHub custom emojis (like ":octocat:", see full list at https://api.github.com/emojis) # Render GitHub custom emojis (like ":octocat:", see full list at https://api.github.com/emojis)
# May increase filesize # May increase filesize
@@ -181,6 +186,7 @@ inputs:
description: Use GitHub custom emojis description: Use GitHub custom emojis
type: boolean type: boolean
default: yes default: yes
global: yes
# Render display width # Render display width
config_display: config_display:
@@ -191,12 +197,14 @@ inputs:
- regular # 480px width - regular # 480px width
- large # 960px width (may not be supported by all templates) - large # 960px width (may not be supported by all templates)
- columns # Full width with two columns on desktop / One column on mobile - columns # Full width with two columns on desktop / One column on mobile
global: yes
# Enable SVG CSS animations # Enable SVG CSS animations
config_animations: config_animations:
description: SVG CSS animations description: SVG CSS animations
type: boolean type: boolean
default: yes default: yes
global: yes
# Encode images links into base64 data # Encode images links into base64 data
# Advised to be true when generating images and false when generating texts or JSON # Advised to be true when generating images and false when generating texts or JSON
@@ -204,6 +212,7 @@ inputs:
description: Encode images links into base64 data description: Encode images links into base64 data
type: boolean type: boolean
default: yes default: yes
global: yes
# Configure padding for output image (percentage value) # Configure padding for output image (percentage value)
# It can be used to add padding to generated metrics if rendering is cropped or has too much empty space # It can be used to add padding to generated metrics if rendering is cropped or has too much empty space
@@ -260,6 +269,23 @@ inputs:
min: 0 min: 0
max: 3600 max: 3600
# Time to wait (in seconds) at the end of job
# Use this to avoid triggering abuse mechanics on large workflows
delay:
description: Use this to avoid triggering abuse mechanics on large workflows
type: number
default: 0
min: 0
max: 3600
# Use a pre-built image from GitHub registry when using unreleased versions of "lowlighter/metrics"
# This option has no effect on forks (images will always be rebuilt from Dockerfile)
# See https://github.com/users/lowlighter/packages/container/package/metrics for more information
use_prebuilt_image:
description: Use pre-built image from GitHub registry
type: boolean
default: yes
# ==================================================================================== # ====================================================================================
# 🚧 Options below are mostly used for testing # 🚧 Options below are mostly used for testing
@@ -269,6 +295,7 @@ inputs:
description: Die on plugins errors description: Die on plugins errors
type: boolean type: boolean
default: no default: no
testing: yes
# Debug mode # Debug mode
# Note that this will automatically be enabled if job fails # Note that this will automatically be enabled if job fails
@@ -276,12 +303,14 @@ inputs:
description: Debug logs description: Debug logs
type: boolean type: boolean
default: no default: no
testing: yes
# Ensure SVG can be correctly parsed after generation # Ensure SVG can be correctly parsed after generation
verify: verify:
description: Verify SVG description: Verify SVG
type: boolean type: boolean
default: no default: no
testing: yes
# Debug flags # Debug flags
debug_flags: debug_flags:
@@ -294,6 +323,7 @@ inputs:
- --hireable - --hireable
- --halloween - --halloween
- --error - --error
testing: yes
# Dry-run mode (perform generation without output) # Dry-run mode (perform generation without output)
# Unlike "output_action" set to "none", output file won't be available in "/metrics_renders" # Unlike "output_action" set to "none", output file won't be available in "/metrics_renders"
@@ -301,6 +331,7 @@ inputs:
description: Enable dry-run description: Enable dry-run
type: boolean type: boolean
default: no default: no
testing: yes
# Experimental features # Experimental features
# Note that no backward compatibility are guaranteed for these features # Note that no backward compatibility are guaranteed for these features
@@ -311,26 +342,11 @@ inputs:
default: "" default: ""
values: values:
- --optimize-svg - --optimize-svg
testing: yes
# Use mocked data to bypass external APIs # Use mocked data to bypass external APIs
use_mocked_data: use_mocked_data:
description: Use mocked data instead of live APIs description: Use mocked data instead of live APIs
type: boolean type: boolean
default: no default: no
testing: yes
# Use a pre-built image from GitHub registry when using unreleased versions of "lowlighter/metrics"
# This option has no effect on forks (images will always be rebuilt from Dockerfile)
# See https://github.com/users/lowlighter/packages/container/package/metrics for more information
use_prebuilt_image:
description: Use pre-built image from GitHub registry
type: boolean
default: yes
# Time to wait (in seconds) at the end of job
# Use this to avoid triggering abuse mechanics on large workflows
delay:
description: Use this to avoid triggering abuse mechanics on large workflows
type: number
default: 0
min: 0
max: 3600

View File

@@ -30,3 +30,4 @@ inputs:
description: Indepth follow-up processing description: Indepth follow-up processing
type: boolean type: boolean
default: no default: no
extras: yes

View File

@@ -44,6 +44,7 @@ inputs:
description: Display coding habits charts based on recent activity description: Display coding habits charts based on recent activity
type: boolean type: boolean
default: no default: no
extras: yes
# Trim unused hours on daily chart # Trim unused hours on daily chart
plugin_habits_trim: plugin_habits_trim:

View File

@@ -50,6 +50,7 @@ inputs:
values: values:
- most-used # Most used languages - most-used # Most used languages
- recently-used # Recently used languages - recently-used # Recently used languages
extras: yes
# Overrides default languages colors # Overrides default languages colors
# Use `${n}:${color}` to change the color of the n-th most used language (e.g. "0:red" to make your most used language red) # Use `${n}:${color}` to change the color of the n-th most used language (e.g. "0:red" to make your most used language red)
@@ -98,6 +99,7 @@ inputs:
description: Indepth languages processing (see documentation before enabling) description: Indepth languages processing (see documentation before enabling)
type: boolean type: boolean
default: false default: false
extras: yes
# Analysis timeout (in minutes) # Analysis timeout (in minutes)
# In case of timeout, it'll automatically fallback to default algorithm # In case of timeout, it'll automatically fallback to default algorithm
@@ -109,6 +111,7 @@ inputs:
default: 15 default: 15
min: 1 min: 1
max: 30 max: 30
extras: yes
# GitHub language categories to display # GitHub language categories to display
plugin_languages_categories: plugin_languages_categories:

View File

@@ -12,6 +12,7 @@ inputs:
description: Display licenses informations description: Display licenses informations
type: boolean type: boolean
default: no default: no
extras: yes
# Command to use to setup target repository # Command to use to setup target repository
# It is required to install all dependencies that will be analyzed with github/licensed # It is required to install all dependencies that will be analyzed with github/licensed

View File

@@ -22,3 +22,4 @@ inputs:
format: comma-separated format: comma-separated
default: "" default: ""
example: my-repo-1, my-repo-2, owner/repo-3, ... example: my-repo-1, my-repo-2, owner/repo-3, ...
inherits: repositories_skipped

View File

@@ -44,3 +44,4 @@ inputs:
description: Indepth notable contributions processing description: Indepth notable contributions processing
type: boolean type: boolean
default: no default: no
extras: yes

View File

@@ -82,4 +82,5 @@ inputs:
description: Users to ignore description: Users to ignore
type: array type: array
format: comma-separated format: comma-separated
default: github-actions[bot], dependabot[bot], dependabot-preview[bot] default: ""
inherits: users_ignored

View File

@@ -21,4 +21,5 @@ inputs:
type: array type: array
format: comma-separated format: comma-separated
default: "" default: ""
example: my-repo-1, my-repo-2, owner/repo-3 ... example: my-repo-1, my-repo-2, owner/repo-3, ...
inherits: repositories_skipped