chore: code formatting
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
//Setup
|
||||
export default async function({login, q}, {conf, data, rest, graphql, plugins, queries, account, convert, template}, {pending, imports}) {
|
||||
//Load inputs
|
||||
const {"config.animations":animations, "config.display":display, "config.timezone":_timezone, "config.base64":_base64, "debug.flags":dflags} = imports.metadata.plugins.core.inputs({data, account, q})
|
||||
imports.metadata.templates[template].check({q, account, format:convert})
|
||||
const {"config.animations": animations, "config.display": display, "config.timezone": _timezone, "config.base64": _base64, "debug.flags": dflags} = imports.metadata.plugins.core.inputs({data, account, q})
|
||||
imports.metadata.templates[template].check({q, account, format: convert})
|
||||
|
||||
//Base64 images
|
||||
if (!_base64) {
|
||||
@@ -17,23 +17,23 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
|
||||
//Init
|
||||
const computed = {
|
||||
commits:0,
|
||||
sponsorships:0,
|
||||
licenses:{favorite:"", used:{}, about:{}},
|
||||
token:{},
|
||||
repositories:{watchers:0, stargazers:0, issues_open:0, issues_closed:0, pr_open:0, pr_closed:0, pr_merged:0, forks:0, forked:0, releases:0, deployments:0, environments:0},
|
||||
commits: 0,
|
||||
sponsorships: 0,
|
||||
licenses: {favorite: "", used: {}, about: {}},
|
||||
token: {},
|
||||
repositories: {watchers: 0, stargazers: 0, issues_open: 0, issues_closed: 0, pr_open: 0, pr_closed: 0, pr_merged: 0, forks: 0, forked: 0, releases: 0, deployments: 0, environments: 0},
|
||||
}
|
||||
const avatar = imports.imgb64(data.user.avatarUrl)
|
||||
data.computed = computed
|
||||
console.debug(`metrics/compute/${login} > formatting common metrics`)
|
||||
|
||||
//Timezone config
|
||||
const offset = Number(new Date().toLocaleString("fr", {timeZoneName:"short"}).match(/UTC[+](?<offset>\d+)/)?.groups?.offset * 60 * 60 * 1000) || 0
|
||||
const offset = Number(new Date().toLocaleString("fr", {timeZoneName: "short"}).match(/UTC[+](?<offset>\d+)/)?.groups?.offset * 60 * 60 * 1000) || 0
|
||||
if (_timezone) {
|
||||
const timezone = {name:_timezone, offset:0}
|
||||
const timezone = {name: _timezone, offset: 0}
|
||||
data.config.timezone = timezone
|
||||
try {
|
||||
timezone.offset = offset - (Number(new Date().toLocaleString("fr", {timeZoneName:"short", timeZone:timezone.name}).match(/UTC[+](?<offset>\d+)/)?.groups?.offset * 60 * 60 * 1000) || 0)
|
||||
timezone.offset = offset - (Number(new Date().toLocaleString("fr", {timeZoneName: "short", timeZone: timezone.name}).match(/UTC[+](?<offset>\d+)/)?.groups?.offset * 60 * 60 * 1000) || 0)
|
||||
console.debug(`metrics/compute/${login} > timezone set to ${timezone.name} (${timezone.offset > 0 ? "+" : ""}${Math.round(timezone.offset / (60 * 60 * 1000))} hours)`)
|
||||
}
|
||||
catch {
|
||||
@@ -41,9 +41,9 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
console.debug(`metrics/compute/${login} > failed to use timezone "${timezone.name}"`)
|
||||
}
|
||||
}
|
||||
else if (process?.env?.TZ)
|
||||
data.config.timezone = {name:process.env.TZ, offset}
|
||||
|
||||
else if (process?.env?.TZ) {
|
||||
data.config.timezone = {name: process.env.TZ, offset}
|
||||
}
|
||||
|
||||
//Display
|
||||
data.large = display === "large"
|
||||
@@ -60,7 +60,7 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
pending.push((async () => {
|
||||
try {
|
||||
console.debug(`metrics/compute/${login}/plugins > ${name} > started`)
|
||||
data.plugins[name] = await imports.plugins[name]({login, q, imports, data, computed, rest, graphql, queries, account}, {extras:conf.settings?.extras?.features ?? conf.settings?.extras?.default ?? false, sandbox:conf.settings?.sandbox ?? false, ...plugins[name]})
|
||||
data.plugins[name] = await imports.plugins[name]({login, q, imports, data, computed, rest, graphql, queries, account}, {extras: conf.settings?.extras?.features ?? conf.settings?.extras?.default ?? false, sandbox: conf.settings?.sandbox ?? false, ...plugins[name]})
|
||||
console.debug(`metrics/compute/${login}/plugins > ${name} > completed`)
|
||||
}
|
||||
catch (error) {
|
||||
@@ -68,8 +68,8 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
data.plugins[name] = error
|
||||
}
|
||||
finally {
|
||||
const result = {name, result:data.plugins[name]}
|
||||
console.debug(imports.util.inspect(result, {depth:Infinity, maxStringLength:256, getters:true}))
|
||||
const result = {name, result: data.plugins[name]}
|
||||
console.debug(imports.util.inspect(result, {depth: Infinity, maxStringLength: 256, getters: true}))
|
||||
return result
|
||||
}
|
||||
})())
|
||||
@@ -108,7 +108,7 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
const months = diff.getUTCMonth() - new Date(0).getUTCMonth()
|
||||
const days = diff.getUTCDate() - new Date(0).getUTCDate()
|
||||
|
||||
computed.registered = {years:years + days / 365.25, months}
|
||||
computed.registered = {years: years + days / 365.25, months}
|
||||
computed.registration = years ? `${years} year${imports.s(years)} ago` : months ? `${months} month${imports.s(months)} ago` : `${days} day${imports.s(days)} ago`
|
||||
computed.cakeday = (years >= 1 && months === 0 && days === 0) ? true : false
|
||||
|
||||
@@ -129,9 +129,9 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
|
||||
//Meta
|
||||
data.meta = {
|
||||
version:conf.package.version,
|
||||
author:conf.package.author,
|
||||
generated:imports.format.date(new Date(), {date:true, time:true}),
|
||||
version: conf.package.version,
|
||||
author: conf.package.author,
|
||||
generated: imports.format.date(new Date(), {date: true, time: true}),
|
||||
}
|
||||
|
||||
//Debug flags
|
||||
@@ -146,7 +146,8 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
if (dflags.includes("--halloween")) {
|
||||
console.debug(`metrics/compute/${login} > applying dflag --halloween`)
|
||||
//Haloween color replacer
|
||||
const halloween = content => content
|
||||
const halloween = content =>
|
||||
content
|
||||
.replace(/--color-calendar-graph/g, "--color-calendar-halloween-graph")
|
||||
.replace(/#9be9a8/gi, "var(--color-calendar-halloween-graph-day-L1-bg)")
|
||||
.replace(/#40c463/gi, "var(--color-calendar-halloween-graph-day-L2-bg)")
|
||||
@@ -160,7 +161,7 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
await Promise.all(waiting)
|
||||
if (data.plugins.isocalendar?.svg)
|
||||
data.plugins.isocalendar.svg = halloween(data.plugins.isocalendar.svg)
|
||||
return {name:"dflag.halloween", result:true}
|
||||
return {name: "dflag.halloween", result: true}
|
||||
})())
|
||||
}
|
||||
if (dflags.includes("--error")) {
|
||||
|
||||
Reference in New Issue
Block a user