chore: code formatting

This commit is contained in:
github-actions[bot]
2022-04-23 23:18:43 +00:00
parent 73cd43c18f
commit 4c98629bbc
130 changed files with 1839 additions and 1788 deletions

View File

@@ -8,7 +8,7 @@ export default async function({login, data, imports, q, account}, {enabled = fal
//Load inputs
let {sort, mode, limit} = imports.metadata.plugins.topics.inputs({data, account, q})
const type = {starred:"labels", labels:"labels", mastered:"icons", icons:"icons"}[mode]
const type = {starred: "labels", labels: "labels", mastered: "icons", icons: "icons"}[mode]
const shuffle = (sort === "random")
//Start puppeteer and navigate to topics
@@ -27,10 +27,11 @@ export default async function({login, data, imports, q, account}, {enabled = fal
const frame = page.mainFrame()
//Extract topics
await Promise.race([frame.waitForSelector("ul.repo-list"), frame.waitForSelector(".blankslate")])
const starred = await frame.evaluate(() => [...document.querySelectorAll("ul.repo-list li")].map(li => ({
name:li.querySelector(".f3").innerText,
description:li.querySelector(".f5").innerText,
icon:li.querySelector("img")?.src ?? null,
const starred = await frame.evaluate(() =>
[...document.querySelectorAll("ul.repo-list li")].map(li => ({
name: li.querySelector(".f3").innerText,
description: li.querySelector(".f5").innerText,
icon: li.querySelector("img")?.src ?? null,
}))
)
console.debug(`metrics/compute/${login}/plugins > topics > extracted ${starred.length} starred topics`)
@@ -57,7 +58,7 @@ export default async function({login, data, imports, q, account}, {enabled = fal
console.debug(`metrics/compute/${login}/plugins > topics > keeping only ${limit} topics`)
const removed = topics.splice(limit)
if (removed.length)
topics.push({name:`And ${removed.length} more...`, description:removed.map(({name}) => name).join(", "), icon:null})
topics.push({name: `And ${removed.length} more...`, description: removed.map(({name}) => name).join(", "), icon: null})
}
//Convert icons to base64
@@ -67,7 +68,7 @@ export default async function({login, data, imports, q, account}, {enabled = fal
console.debug(`metrics/compute/${login}/plugins > topics > processing ${topic.name}`)
const {icon} = topic
topic.icon = await imports.imgb64(icon)
topic.icon24 = await imports.imgb64(icon, {force:true, width:24, height:24})
topic.icon24 = await imports.imgb64(icon, {force: true, width: 24, height: 24})
}
//Escape HTML description
topic.description = imports.htmlescape(topic.description)
@@ -86,12 +87,12 @@ export default async function({login, data, imports, q, account}, {enabled = fal
}
//Results
return {mode, type, list:topics}
return {mode, type, list: topics}
}
//Handle errors
catch (error) {
if (error.error?.message)
throw error
throw {error:{message:"An error occured", instance:error}}
throw {error: {message: "An error occured", instance: error}}
}
}