chore: code formatting
This commit is contained in:
@@ -3,12 +3,12 @@ import core from "@actions/core"
|
||||
import github from "@actions/github"
|
||||
import octokit from "@octokit/graphql"
|
||||
import fs from "fs/promises"
|
||||
import processes from "child_process"
|
||||
import paths from "path"
|
||||
import sgit from "simple-git"
|
||||
import processes from "child_process"
|
||||
import mocks from "../../../tests/mocks/index.mjs"
|
||||
import metrics from "../metrics/index.mjs"
|
||||
import setup from "../metrics/setup.mjs"
|
||||
import mocks from "../../../tests/mocks/index.mjs"
|
||||
process.on("unhandledRejection", error => {
|
||||
throw error
|
||||
})
|
||||
@@ -278,8 +278,8 @@ async function retry(func, {retries = 1, delay = 0} = {}) {
|
||||
try {
|
||||
await new Promise(async (solve, reject) => {
|
||||
let stdout = ""
|
||||
setTimeout(() => reject("Timeout while waiting for Insights webserver"), 5*60*1000)
|
||||
const web = await processes.spawn("node", ["/metrics/source/app/web/index.mjs"], {env:{...process.env, NO_SETTINGS: true }})
|
||||
setTimeout(() => reject("Timeout while waiting for Insights webserver"), 5 * 60 * 1000)
|
||||
const web = await processes.spawn("node", ["/metrics/source/app/web/index.mjs"], {env:{...process.env, NO_SETTINGS:true}})
|
||||
web.stdout.on("data", data => (console.debug(`web > ${data}`), stdout += data, /Server ready !/.test(stdout) ? solve() : null))
|
||||
web.stderr.on("data", data => console.debug(`web > ${data}`))
|
||||
})
|
||||
@@ -339,7 +339,7 @@ async function retry(func, {retries = 1, delay = 0} = {}) {
|
||||
info.break()
|
||||
info.section("Saving")
|
||||
info("Output condition", _output_condition)
|
||||
if ((_output_condition === "data-changed")&&((committer.commit) || (committer.pr))) {
|
||||
if ((_output_condition === "data-changed") && ((committer.commit) || (committer.pr))) {
|
||||
const {svg} = await import("../metrics/utils.mjs")
|
||||
let data = ""
|
||||
await retry(async () => {
|
||||
@@ -485,6 +485,7 @@ async function retry(func, {retries = 1, delay = 0} = {}) {
|
||||
}
|
||||
else
|
||||
throw error
|
||||
|
||||
}
|
||||
info("Pull request number", number)
|
||||
}, {retries:retries_output_action, delay:retries_delay_output_action})
|
||||
@@ -532,7 +533,7 @@ async function retry(func, {retries = 1, delay = 0} = {}) {
|
||||
if (delay) {
|
||||
info.break()
|
||||
info("Delay before ending job", `${delay}s`)
|
||||
await new Promise(solve => setTimeout(solve, delay*1000))
|
||||
await new Promise(solve => setTimeout(solve, delay * 1000))
|
||||
}
|
||||
|
||||
//Success
|
||||
|
||||
@@ -78,11 +78,11 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
|
||||
console.debug(`metrics/compute/${login} > json output`)
|
||||
const cache = new WeakSet()
|
||||
const rendered = JSON.parse(JSON.stringify(data, (key, value) => {
|
||||
if ((value instanceof Set)||(Array.isArray(value)))
|
||||
if ((value instanceof Set) || (Array.isArray(value)))
|
||||
return [...value]
|
||||
if (value instanceof Map)
|
||||
return Object.fromEntries(value)
|
||||
if ((typeof value === "object")&&(value)) {
|
||||
if ((typeof value === "object") && (value)) {
|
||||
if (cache.has(value))
|
||||
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, cache.has(v) ? "[Circular]" : v]))
|
||||
cache.add(value)
|
||||
@@ -227,14 +227,23 @@ metrics.insights = async function({login}, {graphql, rest, conf}, {Plugins, Temp
|
||||
"habits.days":7,
|
||||
"habits.facts":false,
|
||||
"habits.charts":true,
|
||||
introduction:true
|
||||
introduction:true,
|
||||
}
|
||||
const plugins = {
|
||||
achievements:{enabled:true},
|
||||
isocalendar:{enabled:true},
|
||||
languages:{enabled:true, extras:false},
|
||||
activity:{enabled:true, markdown:"extended"},
|
||||
notable:{enabled:true},
|
||||
followup:{enabled:true},
|
||||
habits:{enabled:true, extras:false},
|
||||
introduction:{enabled:true},
|
||||
}
|
||||
const plugins = {achievements:{enabled:true}, isocalendar:{enabled:true}, languages:{enabled:true, extras:false}, activity:{enabled:true, markdown:"extended"}, notable:{enabled:true}, followup:{enabled:true}, habits:{enabled:true, extras:false}, introduction:{enabled:true}}
|
||||
return metrics({login, q}, {graphql, rest, plugins, conf, convert:"json"}, {Plugins, Templates})
|
||||
}
|
||||
|
||||
//Metrics insights static render
|
||||
metrics.insights.output = async function ({login, imports, conf}, {graphql, rest, Plugins, Templates}) {
|
||||
metrics.insights.output = async function({login, imports, conf}, {graphql, rest, Plugins, Templates}) {
|
||||
//Server
|
||||
console.debug(`metrics/compute/${login} > insights`)
|
||||
const server = `http://localhost:${conf.settings.port}`
|
||||
@@ -248,7 +257,7 @@ metrics.insights.output = async function ({login, imports, conf}, {graphql, rest
|
||||
await page.goto(`${server}/about/${login}?embed=1&localstorage=1`)
|
||||
await page.evaluate(async json => localStorage.setItem("local.metrics", json), json) //eslint-disable-line no-undef
|
||||
await page.goto(`${server}/about/${login}?embed=1&localstorage=1`)
|
||||
await page.waitForSelector(".container .user", {timeout:10*60*1000})
|
||||
await page.waitForSelector(".container .user", {timeout:10 * 60 * 1000})
|
||||
|
||||
//Rendering
|
||||
console.debug(`metrics/compute/${login} > insights > rendering data`)
|
||||
@@ -266,4 +275,4 @@ metrics.insights.output = async function ({login, imports, conf}, {graphql, rest
|
||||
</html>`
|
||||
await browser.close()
|
||||
return {mime:"text/html", rendered}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//Imports
|
||||
import fs from "fs"
|
||||
import yaml from "js-yaml"
|
||||
import {marked} from "marked"
|
||||
import fetch from "node-fetch"
|
||||
import path from "path"
|
||||
import url from "url"
|
||||
import fetch from "node-fetch"
|
||||
import {marked} from "marked"
|
||||
|
||||
//Defined categories
|
||||
const categories = ["core", "github", "social", "community"]
|
||||
@@ -293,23 +293,25 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
|
||||
` <td>${Object.entries(compatibility).filter(([_, value]) => value).map(([id]) => `<a href="/source/templates/${id}"><code>${templates[id].name ?? ""}</code></a>`).join(" ")}</td>`,
|
||||
" </tr>",
|
||||
" <tr>",
|
||||
` <td>${[
|
||||
meta.supports?.includes("user") ? "<code>👤 Users</code>" : "",
|
||||
meta.supports?.includes("organization") ? "<code>👥 Organizations</code>" : "",
|
||||
meta.supports?.includes("repository") ? "<code>📓 Repositories</code>" : ""
|
||||
].filter(v => v).join(" ")}</td>`,
|
||||
` <td>${
|
||||
[
|
||||
meta.supports?.includes("user") ? "<code>👤 Users</code>" : "",
|
||||
meta.supports?.includes("organization") ? "<code>👥 Organizations</code>" : "",
|
||||
meta.supports?.includes("repository") ? "<code>📓 Repositories</code>" : "",
|
||||
].filter(v => v).join(" ")
|
||||
}</td>`,
|
||||
" </tr>",
|
||||
" <tr>",
|
||||
` <td>${[
|
||||
...(meta.scopes ?? []).map(scope => `<code>🔑 ${{public_access:"(scopeless)"}[scope] ?? scope}</code>`),
|
||||
...Object.entries(inputs).filter(([_, {type}]) => type === "token").map(([token]) => `<code>🗝️ ${token}</code>`),
|
||||
...(meta.scopes?.length ? ["read:org", "read:user", "repo"].map(scope => !meta.scopes.includes(scope) ? `<code>${scope} (optional)</code>` : null).filter(v => v) : [])
|
||||
...(meta.scopes?.length ? ["read:org", "read:user", "repo"].map(scope => !meta.scopes.includes(scope) ? `<code>${scope} (optional)</code>` : null).filter(v => v) : []),
|
||||
].filter(v => v).join(" ") || "<i>No tokens are required for this plugin</i>"}</td>`,
|
||||
" </tr>",
|
||||
" <tr>",
|
||||
demos({colspan:2, wrap:name === "base", examples:meta.examples}),
|
||||
" </tr>",
|
||||
"</table>"
|
||||
"</table>",
|
||||
].join("\n")
|
||||
|
||||
//Options table
|
||||
@@ -339,14 +341,14 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
|
||||
cell.push(`<i>(${Array.isArray(o.format) ? o.format[0] : o.format})</i>`)
|
||||
if ("min" in o)
|
||||
cell.push(`<i>(${o.min} ≤`)
|
||||
if (("min" in o)||("max" in o))
|
||||
if (("min" in o) || ("max" in o))
|
||||
cell.push(`${"min" in o ? "" : "<i>("}𝑥${"max" in o ? "" : ")</i>"}`)
|
||||
if ("max" in o)
|
||||
cell.push(`≤ ${o.max})</i>`)
|
||||
cell.push("<br>")
|
||||
if ("zero" in o)
|
||||
cell.push(`<b>zero behaviour:</b> ${o.zero}</br>`)
|
||||
if (("default" in o)&&(o.default !== "")) {
|
||||
if (("default" in o) && (o.default !== "")) {
|
||||
let text = o.default
|
||||
if (o.default === ".user.login")
|
||||
text = "<code>→ User login</code>"
|
||||
@@ -414,26 +416,30 @@ metadata.template = async function({__templates, name, plugins, logger}) {
|
||||
` <td>${Object.entries(compatibility).filter(([_, value]) => value).map(([id]) => `<a href="/source/plugins/${id}" title="${plugins[id].name}">${plugins[id].icon}</a>`).join(" ")}${meta.formats?.includes("markdown") ? " <code>✓ embed()</code>" : ""}</td>`,
|
||||
" </tr>",
|
||||
" <tr>",
|
||||
` <td>${[
|
||||
meta.supports?.includes("user") ? "<code>👤 Users</code>" : "",
|
||||
meta.supports?.includes("organization") ? "<code>👥 Organizations</code>" : "",
|
||||
meta.supports?.includes("repository") ? "<code>📓 Repositories</code>" : ""
|
||||
].filter(v => v).join(" ")}</td>`,
|
||||
` <td>${
|
||||
[
|
||||
meta.supports?.includes("user") ? "<code>👤 Users</code>" : "",
|
||||
meta.supports?.includes("organization") ? "<code>👥 Organizations</code>" : "",
|
||||
meta.supports?.includes("repository") ? "<code>📓 Repositories</code>" : "",
|
||||
].filter(v => v).join(" ")
|
||||
}</td>`,
|
||||
" </tr>",
|
||||
" <tr>",
|
||||
` <td>${[
|
||||
meta.formats?.includes("svg") ? "<code>*️⃣ SVG</code>" : "",
|
||||
meta.formats?.includes("png") ? "<code>*️⃣ PNG</code>" : "",
|
||||
meta.formats?.includes("jpeg") ? "<code>*️⃣ JPEG</code>" : "",
|
||||
meta.formats?.includes("json") ? "<code>#️⃣ JSON</code>" : "",
|
||||
meta.formats?.includes("markdown") ? "<code>🔠 Markdown</code>" : "",
|
||||
meta.formats?.includes("markdown-pdf") ? "<code>🔠 Markdown (PDF)</code>" : "",
|
||||
].filter(v => v).join(" ")}</td>`,
|
||||
` <td>${
|
||||
[
|
||||
meta.formats?.includes("svg") ? "<code>*️⃣ SVG</code>" : "",
|
||||
meta.formats?.includes("png") ? "<code>*️⃣ PNG</code>" : "",
|
||||
meta.formats?.includes("jpeg") ? "<code>*️⃣ JPEG</code>" : "",
|
||||
meta.formats?.includes("json") ? "<code>#️⃣ JSON</code>" : "",
|
||||
meta.formats?.includes("markdown") ? "<code>🔠 Markdown</code>" : "",
|
||||
meta.formats?.includes("markdown-pdf") ? "<code>🔠 Markdown (PDF)</code>" : "",
|
||||
].filter(v => v).join(" ")
|
||||
}</td>`,
|
||||
" </tr>",
|
||||
" <tr>",
|
||||
demos({colspan:2, examples:meta.examples}),
|
||||
" </tr>",
|
||||
"</table>"
|
||||
"</table>",
|
||||
].join("\n")
|
||||
|
||||
//Result
|
||||
@@ -448,9 +454,9 @@ metadata.template = async function({__templates, name, plugins, logger}) {
|
||||
compatibility:{
|
||||
...Object.fromEntries(Object.entries(compatibility).filter(([_, value]) => value)),
|
||||
...Object.fromEntries(Object.entries(compatibility).filter(([_, value]) => !value).map(([key, value]) => [key, meta.formats?.includes("markdown") ? "embed" : value])),
|
||||
base:true
|
||||
base:true,
|
||||
},
|
||||
header
|
||||
header,
|
||||
},
|
||||
check({q, account = "bypass", format = null}) {
|
||||
//Support check
|
||||
@@ -481,31 +487,33 @@ metadata.to = {
|
||||
|
||||
//Demo for main and individual readmes
|
||||
function demos({colspan = null, wrap = false, examples = {}} = {}) {
|
||||
if (("default1" in examples)&&("default2" in examples)) {
|
||||
if (("default1" in examples) && ("default2" in examples)) {
|
||||
return [
|
||||
wrap ? '<td colspan="2"><table><tr>' : "",
|
||||
'<td align="center">',
|
||||
`<img src="${examples.default1}" alt=""></img>`,
|
||||
`<img src="${examples.default1}" alt=""></img>`,
|
||||
"</td>",
|
||||
'<td align="center">',
|
||||
`<img src="${examples.default2}" alt=""></img>`,
|
||||
`<img src="${examples.default2}" alt=""></img>`,
|
||||
"</td>",
|
||||
wrap ? "</tr></table></td>" : "",
|
||||
].filter(v => v).join("\n")
|
||||
}
|
||||
return [
|
||||
` <td ${colspan ? `colspan="${colspan}"` : ""} align="center">`,
|
||||
`${Object.entries(examples).map(([text, link]) => {
|
||||
let img = `<img src="${link}" alt=""></img>`
|
||||
if (text !== "default") {
|
||||
const open = text.charAt(0) === "+" ? " open" : ""
|
||||
text = open ? text.substring(1) : text
|
||||
text = `${text.charAt(0).toLocaleUpperCase()}${text.substring(1)}`
|
||||
img = `<details${open}><summary>${text}</summary>${img}</details>`
|
||||
}
|
||||
return ` ${img}`
|
||||
}).join("\n")}`,
|
||||
`${
|
||||
Object.entries(examples).map(([text, link]) => {
|
||||
let img = `<img src="${link}" alt=""></img>`
|
||||
if (text !== "default") {
|
||||
const open = text.charAt(0) === "+" ? " open" : ""
|
||||
text = open ? text.substring(1) : text
|
||||
text = `${text.charAt(0).toLocaleUpperCase()}${text.substring(1)}`
|
||||
img = `<details${open}><summary>${text}</summary>${img}</details>`
|
||||
}
|
||||
return ` ${img}`
|
||||
}).join("\n")
|
||||
}`,
|
||||
' <img width="900" height="1" alt="">',
|
||||
" </td>"
|
||||
" </td>",
|
||||
].filter(v => v).join("\n")
|
||||
}
|
||||
|
||||
@@ -3,38 +3,38 @@ import fs from "fs/promises"
|
||||
import prism_lang from "prismjs/components/index.js"
|
||||
import axios from "axios"
|
||||
import processes from "child_process"
|
||||
import crypto from "crypto"
|
||||
import {minify as csso} from "csso"
|
||||
import emoji from "emoji-name-map"
|
||||
import fss from "fs"
|
||||
import GIFEncoder from "gifencoder"
|
||||
import jimp from "jimp"
|
||||
import linguist from "linguist-js"
|
||||
import {marked} from "marked"
|
||||
import minimatch from "minimatch"
|
||||
import nodechartist from "node-chartist"
|
||||
import fetch from "node-fetch"
|
||||
import opengraph from "open-graph-scraper"
|
||||
import os from "os"
|
||||
import paths from "path"
|
||||
import PNG from "png-js"
|
||||
import prism from "prismjs"
|
||||
import _puppeteer from "puppeteer"
|
||||
import purgecss from "purgecss"
|
||||
import readline from "readline"
|
||||
import rss from "rss-parser"
|
||||
import htmlsanitize from "sanitize-html"
|
||||
import git from "simple-git"
|
||||
import SVGO from "svgo"
|
||||
import twemojis from "twemoji-parser"
|
||||
import url from "url"
|
||||
import util from "util"
|
||||
import fetch from "node-fetch"
|
||||
import readline from "readline"
|
||||
import emoji from "emoji-name-map"
|
||||
import minimatch from "minimatch"
|
||||
import crypto from "crypto"
|
||||
import linguist from "linguist-js"
|
||||
import purgecss from "purgecss"
|
||||
import {minify as csso} from "csso"
|
||||
import SVGO from "svgo"
|
||||
import xmlformat from "xml-formatter"
|
||||
|
||||
prism_lang()
|
||||
|
||||
//Exports
|
||||
export {axios, fs, git, jimp, opengraph, os, paths, processes, rss, url, fetch, util, emoji, minimatch}
|
||||
export {axios, emoji, fetch, fs, git, jimp, minimatch, opengraph, os, paths, processes, rss, url, util}
|
||||
|
||||
/**Returns module __dirname */
|
||||
export function __module(module) {
|
||||
@@ -81,7 +81,7 @@ export function formatters({timeZone} = {}) {
|
||||
}
|
||||
|
||||
/**Bytes formatter */
|
||||
format.bytes = function (n) {
|
||||
format.bytes = function(n) {
|
||||
for (const {u, v} of [{u:"E", v:10 ** 18}, {u:"P", v:10 ** 15}, {u:"T", v:10 ** 12}, {u:"G", v:10 ** 9}, {u:"M", v:10 ** 6}, {u:"k", v:10 ** 3}]) {
|
||||
if (n / v >= 1)
|
||||
return `${(n / v).toFixed(2).substr(0, 4).replace(/[.]0*$/, "")} ${u}B`
|
||||
@@ -90,7 +90,7 @@ export function formatters({timeZone} = {}) {
|
||||
}
|
||||
|
||||
/**Percentage formatter */
|
||||
format.percentage = function (n, {rescale = true} = {}) {
|
||||
format.percentage = function(n, {rescale = true} = {}) {
|
||||
return `${
|
||||
(n * (rescale ? 100 : 1)).toFixed(2)
|
||||
.replace(/(?<=[.])(?<decimal>[1-9]*)0+$/, "$<decimal>")
|
||||
@@ -166,7 +166,7 @@ export async function chartist() {
|
||||
}
|
||||
|
||||
/**Language analyzer (single file) */
|
||||
export async function language({filename, patch, prefix = "", timeout = 20*1000}) {
|
||||
export async function language({filename, patch, prefix = "", timeout = 20 * 1000}) {
|
||||
const path = paths.join(os.tmpdir(), `${prefix}-${Math.random()}`.replace(/[^\w-]/g, ""))
|
||||
return new Promise(async (solve, reject) => {
|
||||
setTimeout(() => {
|
||||
@@ -222,9 +222,9 @@ export async function run(command, options, {prefixed = true, log = true} = {})
|
||||
}
|
||||
|
||||
/**Spawn command (use this to execute commands and process output on the fly) */
|
||||
export async function spawn(command, args = [], options = {}, {prefixed = true, timeout = 300*1000, stdout} = {}) { //eslint-disable-line max-params
|
||||
export async function spawn(command, args = [], options = {}, {prefixed = true, timeout = 300 * 1000, stdout} = {}) { //eslint-disable-line max-params
|
||||
const prefix = {win32:"wsl"}[process.platform] ?? ""
|
||||
if ((prefixed)&&(prefix)) {
|
||||
if ((prefixed) && (prefix)) {
|
||||
args.unshift(command)
|
||||
command = prefix
|
||||
}
|
||||
@@ -403,7 +403,7 @@ export const svg = {
|
||||
if (Number.isFinite(Number(absolute)))
|
||||
padding.absolute[dimension] = Number(absolute)
|
||||
if (Number.isFinite(Number(relative)))
|
||||
padding[dimension] = 1 + Number(relative/100)
|
||||
padding[dimension] = 1 + Number(relative / 100)
|
||||
}
|
||||
console.debug(`metrics/svg/resize > padding width*${padding.width}+${padding.absolute.width}, height*${padding.height}+${padding.absolute.height}`)
|
||||
//Render through browser and resize height
|
||||
@@ -433,7 +433,7 @@ export const svg = {
|
||||
console.debug(`bounds after applying padding width=${width} (*${padding.width}+${padding.absolute.width}), height=${height} (*${padding.height}+${padding.absolute.height})`)
|
||||
//Resize svg
|
||||
if (document.querySelector("svg").getAttribute("height") === "auto")
|
||||
console.debug("skipped height resizing because it was set to \"auto\"")
|
||||
console.debug('skipped height resizing because it was set to "auto"')
|
||||
else
|
||||
document.querySelector("svg").setAttribute("height", height)
|
||||
//Enable animations
|
||||
@@ -575,8 +575,8 @@ export const svg = {
|
||||
if (error)
|
||||
throw new Error(`Could not optimize SVG: \n${error}`)
|
||||
return optimized
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
/**Wait */
|
||||
|
||||
@@ -6,9 +6,9 @@ import express from "express"
|
||||
import ratelimit from "express-rate-limit"
|
||||
import cache from "memory-cache"
|
||||
import util from "util"
|
||||
import mocks from "../../../tests/mocks/index.mjs"
|
||||
import metrics from "../metrics/index.mjs"
|
||||
import setup from "../metrics/setup.mjs"
|
||||
import mocks from "../../../tests/mocks/index.mjs"
|
||||
|
||||
/**App */
|
||||
export default async function({mock, nosettings} = {}) {
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
//Plugins
|
||||
(async () => {
|
||||
const { data: plugins } = await axios.get("/.plugins")
|
||||
this.plugins.list = plugins.filter(({name}) => metadata[name]?.supports.includes("user") || metadata[name]?.supports.includes("organization"))
|
||||
const categories = [...new Set(this.plugins.list.map(({category}) => category))]
|
||||
this.plugins.list = plugins.filter(({ name }) => metadata[name]?.supports.includes("user") || metadata[name]?.supports.includes("organization"))
|
||||
const categories = [...new Set(this.plugins.list.map(({ category }) => category))]
|
||||
this.plugins.categories = Object.fromEntries(categories.map(category => [category, this.plugins.list.filter(value => category === value.category)]))
|
||||
})(),
|
||||
//Base
|
||||
@@ -68,8 +68,10 @@
|
||||
tab: {
|
||||
immediate: true,
|
||||
handler(current) {
|
||||
if (current === 'action') this.clipboard = new ClipboardJS('.copy-action')
|
||||
else this.clipboard?.destroy()
|
||||
if (current === "action")
|
||||
this.clipboard = new ClipboardJS(".copy-action")
|
||||
else
|
||||
this.clipboard?.destroy()
|
||||
},
|
||||
},
|
||||
palette: {
|
||||
@@ -181,7 +183,7 @@
|
||||
scopes() {
|
||||
return new Set([
|
||||
...Object.entries(this.plugins.enabled).filter(([key, value]) => (key !== "base") && (value)).flatMap(([key]) => metadata[key].scopes),
|
||||
...(Object.entries(this.plugins.enabled.base).filter(([key, value]) => value).length ? metadata.base.scopes : [])
|
||||
...(Object.entries(this.plugins.enabled.base).filter(([key, value]) => value).length ? metadata.base.scopes : []),
|
||||
])
|
||||
},
|
||||
//GitHub action auto-generated code
|
||||
@@ -201,17 +203,19 @@
|
||||
` steps:`,
|
||||
` - uses: lowlighter/metrics@latest`,
|
||||
` with:`,
|
||||
...(this.scopes.size ? [
|
||||
` # Your GitHub token`,
|
||||
` # The following scopes are required:`,
|
||||
...[...this.scopes].map(scope => ` # - ${scope}${scope === "public_access" ? " (default scope)" : ""}`),
|
||||
` # The following additional scopes may be required:`,
|
||||
` # - read:org (for organization related metrics)`,
|
||||
` # - read:user (for user related data)`,
|
||||
` # - repo (optional, if you want to include private repositories)`
|
||||
] : [
|
||||
` # Current configuration doesn't require a GitHub token`,
|
||||
]),
|
||||
...(this.scopes.size
|
||||
? [
|
||||
` # Your GitHub token`,
|
||||
` # The following scopes are required:`,
|
||||
...[...this.scopes].map(scope => ` # - ${scope}${scope === "public_access" ? " (default scope)" : ""}`),
|
||||
` # The following additional scopes may be required:`,
|
||||
` # - read:org (for organization related metrics)`,
|
||||
` # - read:user (for user related data)`,
|
||||
` # - repo (optional, if you want to include private repositories)`,
|
||||
]
|
||||
: [
|
||||
` # Current configuration doesn't require a GitHub token`,
|
||||
]),
|
||||
` token: ${this.scopes.size ? `${"$"}{{ secrets.METRICS_TOKEN }}` : "NOT_NEEDED"}`,
|
||||
``,
|
||||
` # Options`,
|
||||
@@ -252,7 +256,7 @@
|
||||
methods: {
|
||||
//Refresh computed properties
|
||||
async refresh() {
|
||||
const keys = {action:["scopes", "action"], markdown:["url", "embed"]}[this.tab]
|
||||
const keys = { action: ["scopes", "action"], markdown: ["url", "embed"] }[this.tab]
|
||||
if (keys) {
|
||||
for (const key of keys)
|
||||
this._computedWatchers[key]?.run()
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
return await ejs.render(partial, data, { async: true, rmWhitespace: true })
|
||||
},
|
||||
//Meta-data
|
||||
meta: { version: set.version, author: "lowlighter", generated:new Date().toGMTString().replace(/GMT$/g, "").trim() },
|
||||
meta: { version: set.version, author: "lowlighter", generated: new Date().toGMTString().replace(/GMT$/g, "").trim() },
|
||||
//Animated
|
||||
animated: false,
|
||||
//Display size
|
||||
@@ -60,14 +60,14 @@
|
||||
//Config
|
||||
config: set.config,
|
||||
//Extras
|
||||
extras:{css:options["extras.css"] ?? ""},
|
||||
extras: { css: options["extras.css"] ?? "" },
|
||||
//Base elements
|
||||
base: set.plugins.enabled.base,
|
||||
//Computed elements
|
||||
computed: {
|
||||
commits: faker.datatype.number(10000),
|
||||
sponsorships: faker.datatype.number(10),
|
||||
licenses: { favorite: [""], used: { MIT: 1 }, about:{} },
|
||||
licenses: { favorite: [""], used: { MIT: 1 }, about: {} },
|
||||
token: { scopes: [] },
|
||||
repositories: {
|
||||
watchers: faker.datatype.number(1000),
|
||||
@@ -193,7 +193,7 @@
|
||||
drafts: faker.datatype.number(this.drafts),
|
||||
skipped: faker.datatype.number(this.skipped),
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
pr: {
|
||||
get count() {
|
||||
@@ -210,7 +210,7 @@
|
||||
merged: faker.datatype.number(this.skipped),
|
||||
drafts: faker.datatype.number(this.drafts),
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
user: {
|
||||
issues: {
|
||||
@@ -232,7 +232,7 @@
|
||||
drafts: faker.datatype.number(100),
|
||||
},
|
||||
},
|
||||
indepth:options["followup.indepth"] ? {} : null
|
||||
indepth: options["followup.indepth"] ? {} : null,
|
||||
},
|
||||
})
|
||||
: null),
|
||||
@@ -240,7 +240,10 @@
|
||||
...(set.plugins.enabled.notable
|
||||
? ({
|
||||
notable: {
|
||||
contributions: new Array(2 + faker.datatype.number(2)).fill(null).map(_ => ({ name: `${options["notable.repositories"] ? `${faker.lorem.slug()}/` : ""}${faker.lorem.slug()}`, avatar: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==" })),
|
||||
contributions: new Array(2 + faker.datatype.number(2)).fill(null).map(_ => ({
|
||||
name: `${options["notable.repositories"] ? `${faker.lorem.slug()}/` : ""}${faker.lorem.slug()}`,
|
||||
avatar: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==",
|
||||
})),
|
||||
},
|
||||
})
|
||||
: null),
|
||||
@@ -335,7 +338,7 @@
|
||||
unlock: null,
|
||||
text: faker.lorem.sentence(),
|
||||
get icon() {
|
||||
const colors = {S:["#FF0000", "#FF8500"], A:["#B59151", "#FFD576"], B:["#7D6CFF", "#B2A8FF"], C:["#2088FF", "#79B8FF"], $:["#FF48BD", "#FF92D8"], X:["#7A7A7A", "#B0B0B0"]}
|
||||
const colors = { S: ["#FF0000", "#FF8500"], A: ["#B59151", "#FFD576"], B: ["#7D6CFF", "#B2A8FF"], C: ["#2088FF", "#79B8FF"], $: ["#FF48BD", "#FF92D8"], X: ["#7A7A7A", "#B0B0B0"] }
|
||||
return `<g xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-width="2" fill="none" fill-rule="evenodd"><g stroke-linejoin="round"><g stroke="#secondary"><path d="M8 43a3 3 0 100 6 3 3 0 000-6zm40 0a3.001 3.001 0 10.002 6.002A3.001 3.001 0 0048 43zm-18 3h-4.971m-11.045 0H11M45 46h-4"/></g><path stroke="#primary" d="M13 51h28M36.992 45.276l6.375-8.017c1.488.63 3.272.29 4.414-.977a3.883 3.883 0 00.658-4.193l-1.96 2.174-1.936-.151-.406-1.955 1.96-2.173a3.898 3.898 0 00-4.107 1.092 3.886 3.886 0 00-.512 4.485l-7.317 7.169c-1.32 1.314-.807 2.59-.236 3.105.67.601 1.888.845 3.067-.56z"/><g stroke="#primary"><path d="M12.652 31.063l9.442 12.578a.512.512 0 01-.087.716l-2.396 1.805a.512.512 0 01-.712-.114L9.46 33.47l-.176-3.557 3.37 1.15zM17.099 43.115l2.395-1.806"/></g></g><path d="M25.68 36.927v-2.54a2.227 2.227 0 01.37-1.265c-.526-.04-3.84-.371-3.84-4.302 0-1.013.305-1.839.915-2.477a4.989 4.989 0 01-.146-1.86c.087-.882.946-.823 2.577.178 1.277-.47 2.852-.47 4.725 0 .248-.303 2.434-1.704 2.658-.268.047.296.016.946-.093 1.95.516.524.776 1.358.78 2.501.007 2.261-1.26 3.687-3.8 4.278.24.436.355.857.346 1.264a117.57 117.57 0 000 2.614c2.43-.744 4.228-2.06 5.395-3.95.837-1.356 1.433-2.932 1.433-4.865 0-2.886-1.175-4.984-2.5-6.388C32.714 19.903 30.266 19 28 19a9.094 9.094 0 00-6.588 2.897C20.028 23.393 19 25.507 19 28.185c0 2.026.701 3.945 1.773 5.38 1.228 1.643 2.864 2.764 4.907 3.362zM52.98 25.002l-3.07 3.065-1.49-1.485M6.98 25.002l-3.07 3.065-1.49-1.485" stroke="#primary" stroke-linejoin="round"/><path d="M19.001 11V9a2 2 0 012-2h14a2 2 0 012 2v2m-21 12.028v-10.03a2 2 0 012-1.998h20a2 2 0 012 2v10.028" stroke="#secondary" stroke-linejoin="round"/><path stroke="#secondary" d="M28.001 7V3M15.039 7.797c-5.297 3.406-9.168 8.837-10.517 15.2m46.737-.936c-1.514-5.949-5.25-11.01-10.273-14.248"/></g>`
|
||||
.replace(/#primary/g, colors[this.rank][0])
|
||||
.replace(/#secondary/g, colors[this.rank][1])
|
||||
@@ -362,20 +365,21 @@
|
||||
})
|
||||
: null),
|
||||
//Code snippet
|
||||
...(set.plugins.enabled.code
|
||||
...(set.plugins.enabled.code
|
||||
? ({
|
||||
code: {
|
||||
snippet: {
|
||||
sha: faker.git.shortSha(),
|
||||
message: faker.lorem.sentence(),
|
||||
filename: 'docs/specifications.html',
|
||||
filename: "docs/specifications.html",
|
||||
status: "modified",
|
||||
additions: faker.datatype.number(50),
|
||||
deletions: faker.datatype.number(50),
|
||||
patch: `<span class="token coord">@@ -0,0 +1,5 @@</span><br> //Imports<br><span class="token inserted">+ import app from "./src/app.mjs"</span><br><span class="token deleted">- import app from "./src/app.js"</span><br> //Start app<br> await app()<br>\\ No newline at end of file`,
|
||||
patch:
|
||||
`<span class="token coord">@@ -0,0 +1,5 @@</span><br> //Imports<br><span class="token inserted">+ import app from "./src/app.mjs"</span><br><span class="token deleted">- import app from "./src/app.js"</span><br> //Start app<br> await app()<br>\\ No newline at end of file`,
|
||||
repo: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
: null),
|
||||
//Sponsors
|
||||
@@ -392,10 +396,10 @@
|
||||
count: faker.datatype.number(100),
|
||||
goal: {
|
||||
progress: faker.datatype.number(100),
|
||||
title: `$${faker.datatype.number(100)*10} per month`,
|
||||
description: "Invest in the software that powers your world"
|
||||
}
|
||||
}
|
||||
title: `$${faker.datatype.number(100) * 10} per month`,
|
||||
description: "Invest in the software that powers your world",
|
||||
},
|
||||
},
|
||||
})
|
||||
: null),
|
||||
//Languages
|
||||
@@ -412,7 +416,7 @@
|
||||
get stats() {
|
||||
return Object.fromEntries(Object.entries(this.favorites).map(([key, { value }]) => [key, value]))
|
||||
},
|
||||
["stats.recent"]:{
|
||||
["stats.recent"]: {
|
||||
total: faker.datatype.number(10000),
|
||||
get lines() {
|
||||
return Object.fromEntries(Object.entries(this.favorites).map(([key, { value }]) => [key, value]))
|
||||
@@ -420,9 +424,9 @@
|
||||
get stats() {
|
||||
return Object.fromEntries(Object.entries(this.favorites).map(([key, { value }]) => [key, value]))
|
||||
},
|
||||
commits:faker.datatype.number(500),
|
||||
files:faker.datatype.number(1000),
|
||||
days:Number(options["languages.recent.days"])
|
||||
commits: faker.datatype.number(500),
|
||||
files: faker.datatype.number(1000),
|
||||
days: Number(options["languages.recent.days"]),
|
||||
},
|
||||
favorites: distribution(7).map((value, index, array) => ({ name: faker.lorem.word(), color: faker.internet.color(), value, size: faker.datatype.number(1000000), x: array.slice(0, index).reduce((a, b) => a + b, 0) })),
|
||||
recent: distribution(7).map((value, index, array) => ({ name: faker.lorem.word(), color: faker.internet.color(), value, size: faker.datatype.number(1000000), x: array.slice(0, index).reduce((a, b) => a + b, 0) })),
|
||||
@@ -470,8 +474,8 @@
|
||||
trim: options["habits.trim"],
|
||||
lines: {
|
||||
average: {
|
||||
chars: faker.datatype.number(1000)/10,
|
||||
}
|
||||
chars: faker.datatype.number(1000) / 10,
|
||||
},
|
||||
},
|
||||
commits: {
|
||||
get hour() {
|
||||
@@ -655,10 +659,10 @@
|
||||
? ({
|
||||
discussions: {
|
||||
categories: {
|
||||
stats: { '🙏 Q&A': faker.datatype.number(100), '📣 Announcements': faker.datatype.number(100), '💡 Ideas': faker.datatype.number(100), '💬 General': faker.datatype.number(100) },
|
||||
favorite: '📣 Announcements'
|
||||
stats: { "🙏 Q&A": faker.datatype.number(100), "📣 Announcements": faker.datatype.number(100), "💡 Ideas": faker.datatype.number(100), "💬 General": faker.datatype.number(100) },
|
||||
favorite: "📣 Announcements",
|
||||
},
|
||||
upvotes: { discussions:faker.datatype.number(1000), comments: faker.datatype.number(1000) },
|
||||
upvotes: { discussions: faker.datatype.number(1000), comments: faker.datatype.number(1000) },
|
||||
started: faker.datatype.number(1000),
|
||||
comments: faker.datatype.number(1000),
|
||||
answers: faker.datatype.number(1000),
|
||||
@@ -753,9 +757,11 @@
|
||||
description: faker.lorem.sentence(),
|
||||
count: faker.datatype.number(100),
|
||||
repositories: new Array(Number(options["starlists.limit.repositories"])).fill(null).map((_, i) => ({
|
||||
description: !i ? "📊 An image generator with 20+ metrics about your GitHub account such as activity, community, repositories, coding habits, website performances, music played, starred topics, etc. that you can put on your profile or elsewhere !" : faker.lorem.sentence(),
|
||||
description: !i
|
||||
? "📊 An image generator with 20+ metrics about your GitHub account such as activity, community, repositories, coding habits, website performances, music played, starred topics, etc. that you can put on your profile or elsewhere !"
|
||||
: faker.lorem.sentence(),
|
||||
name: !i ? "lowlighter/metrics" : `${faker.random.word()}/${faker.random.word()}`,
|
||||
}))
|
||||
})),
|
||||
})),
|
||||
},
|
||||
})
|
||||
@@ -1062,7 +1068,7 @@
|
||||
? ({
|
||||
support: {
|
||||
stats: { solutions: faker.datatype.number(100), posts: faker.datatype.number(1000), topics: faker.datatype.number(1000), received: faker.datatype.number(1000), hearts: faker.datatype.number(1000) },
|
||||
badges: { uniques: [ ], multiples: [], count: faker.datatype.number(1000) }
|
||||
badges: { uniques: [], multiples: [], count: faker.datatype.number(1000) },
|
||||
},
|
||||
})
|
||||
: null),
|
||||
@@ -1070,7 +1076,7 @@
|
||||
...(set.plugins.enabled.screenshot
|
||||
? ({
|
||||
screenshot: {
|
||||
image:"data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==",
|
||||
image: "data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==",
|
||||
title: options["screenshot.title"],
|
||||
height: 440,
|
||||
width: 454,
|
||||
@@ -1081,10 +1087,10 @@
|
||||
...(set.plugins.enabled.skyline
|
||||
? ({
|
||||
skyline: {
|
||||
animation:"data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==",
|
||||
animation: "data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==",
|
||||
width: 454,
|
||||
height: 284,
|
||||
compatibility: false
|
||||
compatibility: false,
|
||||
},
|
||||
})
|
||||
: null),
|
||||
@@ -1175,11 +1181,11 @@
|
||||
data.f.date = function(string, options) {
|
||||
if (options.date) {
|
||||
delete options.date
|
||||
Object.assign(options, {day:"numeric", month:"short", year:"numeric"})
|
||||
Object.assign(options, { day: "numeric", month: "short", year: "numeric" })
|
||||
}
|
||||
if (options.time) {
|
||||
delete options.time
|
||||
Object.assign(options, {hour:"2-digit", minute:"2-digit", second:"2-digit"})
|
||||
Object.assign(options, { hour: "2-digit", minute: "2-digit", second: "2-digit" })
|
||||
}
|
||||
return new Intl.DateTimeFormat("en-GB", options).format(new Date(string))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user