chore: code formatting

This commit is contained in:
github-actions[bot]
2022-08-28 19:23:49 +00:00
parent ff23b4ae98
commit 8fe68ad242
4 changed files with 9 additions and 9 deletions

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]]) q = Object.fromEntries([...Object.entries(q).map(([key, value]) => [key.replace(/^plugin_/, "").replace(/_/g, "."), value]), ["base", false]])
//Check users errors //Check users errors
const warnings = [] const warnings = []
if ((!Object.keys(Plugins).filter(key => q[key]).length)&&(!parts.length)) if ((!Object.keys(Plugins).filter(key => q[key]).length) && (!parts.length))
warnings.push({warning:{message:"No plugin were selected"}}) 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)]) 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 //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]) 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 >>>>>>>>>>>>>>>>>>>>>>`) 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 //Enable state handler
{ {
meta.enabled = function(enabled, {extras = {}, error = true} = {}) { 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.`) 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}) 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})) return (enabled) && (meta.extras("enabled", {extras, error}))
} }

View File

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

View File

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