chore: fmt
This commit is contained in:
@@ -81,7 +81,6 @@ rules:
|
|||||||
no-multiple-empty-lines: error
|
no-multiple-empty-lines: error
|
||||||
no-multi-str: error
|
no-multi-str: error
|
||||||
no-multi-assign: error
|
no-multi-assign: error
|
||||||
no-inline-comments: error
|
|
||||||
yoda: error
|
yoda: error
|
||||||
max-classes-per-file: [error, 1]
|
max-classes-per-file: [error, 1]
|
||||||
grouped-accessor-pairs: error
|
grouped-accessor-pairs: error
|
||||||
@@ -116,9 +115,6 @@ rules:
|
|||||||
quotes: [error, double, {avoidEscape: true}]
|
quotes: [error, double, {avoidEscape: true}]
|
||||||
template-curly-spacing: error
|
template-curly-spacing: error
|
||||||
|
|
||||||
# Coding style (comments rules)
|
|
||||||
line-comment-position: error
|
|
||||||
|
|
||||||
# Coding style (spacing rules)
|
# Coding style (spacing rules)
|
||||||
block-spacing: [error, always]
|
block-spacing: [error, always]
|
||||||
comma-spacing: error
|
comma-spacing: error
|
||||||
|
|||||||
@@ -233,9 +233,7 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
|
|||||||
comment: "",
|
comment: "",
|
||||||
descriptor: yaml.dump({
|
descriptor: yaml.dump({
|
||||||
[key]: Object.fromEntries(
|
[key]: Object.fromEntries(
|
||||||
Object.entries(value).filter(([key]) => ["description", "default", "required"].includes(key)).map(([k, v]) =>
|
Object.entries(value).filter(([key]) => ["description", "default", "required"].includes(key)).map(([k, v]) => k === "description" ? [k, v.split("\n")[0]] : k === "default" ? [k, ((/^\$\{\{[\s\S]+\}\}$/.test(v)) || (["config_presets", "config_timezone", "use_prebuilt_image"].includes(key))) ? v : "<default-value>"] : [k, v]),
|
||||||
k === "description" ? [k, v.split("\n")[0]] : k === "default" ? [k, ((/^\$\{\{[\s\S]+\}\}$/.test(v)) || (["config_presets", "config_timezone", "use_prebuilt_image"].includes(key))) ? v : "<default-value>"] : [k, v]
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
}, {quotingType: '"', noCompatMode: true}),
|
}, {quotingType: '"', noCompatMode: true}),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -238,13 +238,9 @@
|
|||||||
` template: ${this.templates.selected}`,
|
` template: ${this.templates.selected}`,
|
||||||
` base: ${Object.entries(this.plugins.enabled.base).filter(([key, value]) => value).map(([key]) => key).join(", ") || '""'}`,
|
` base: ${Object.entries(this.plugins.enabled.base).filter(([key, value]) => value).map(([key]) => key).join(", ") || '""'}`,
|
||||||
...[
|
...[
|
||||||
...Object.entries(this.plugins.options).filter(([key, value]) => (key in metadata.base.web) && (value !== metadata.base.web[key]?.defaulted)).map(([key, value]) =>
|
...Object.entries(this.plugins.options).filter(([key, value]) => (key in metadata.base.web) && (value !== metadata.base.web[key]?.defaulted)).map(([key, value]) => ` ${key.replace(/[.]/g, "_")}: ${typeof value === "boolean" ? {true: "yes", false: "no"}[value] : value}`),
|
||||||
` ${key.replace(/[.]/g, "_")}: ${typeof value === "boolean" ? {true: "yes", false: "no"}[value] : value}`
|
|
||||||
),
|
|
||||||
...Object.entries(this.plugins.enabled).filter(([key, value]) => (key !== "base") && (value)).map(([key]) => ` plugin_${key}: yes`),
|
...Object.entries(this.plugins.enabled).filter(([key, value]) => (key !== "base") && (value)).map(([key]) => ` plugin_${key}: yes`),
|
||||||
...Object.entries(this.plugins.options).filter(([key, value]) => value).filter(([key, value]) => this.plugins.enabled[key.split(".")[0]]).map(([key, value]) =>
|
...Object.entries(this.plugins.options).filter(([key, value]) => value).filter(([key, value]) => this.plugins.enabled[key.split(".")[0]]).map(([key, value]) => ` plugin_${key.replace(/[.]/g, "_")}: ${typeof value === "boolean" ? {true: "yes", false: "no"}[value] : value}`),
|
||||||
` plugin_${key.replace(/[.]/g, "_")}: ${typeof value === "boolean" ? {true: "yes", false: "no"}[value] : value}`
|
|
||||||
),
|
|
||||||
...Object.entries(this.config).filter(([key, value]) => (value) && (value !== metadata.core.web[key]?.defaulted)).map(([key, value]) => ` config_${key.replace(/[.]/g, "_")}: ${typeof value === "boolean" ? {true: "yes", false: "no"}[value] : value}`),
|
...Object.entries(this.config).filter(([key, value]) => (value) && (value !== metadata.core.web[key]?.defaulted)).map(([key, value]) => ` config_${key.replace(/[.]/g, "_")}: ${typeof value === "boolean" ? {true: "yes", false: "no"}[value] : value}`),
|
||||||
].sort(),
|
].sort(),
|
||||||
].join("\n")
|
].join("\n")
|
||||||
|
|||||||
@@ -402,8 +402,7 @@
|
|||||||
status: "modified",
|
status: "modified",
|
||||||
additions: faker.datatype.number(50),
|
additions: faker.datatype.number(50),
|
||||||
deletions: faker.datatype.number(50),
|
deletions: faker.datatype.number(50),
|
||||||
patch:
|
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`,
|
||||||
`<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()}`,
|
repo: `${faker.random.word()}/${faker.random.word()}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -128,9 +128,7 @@ export default async function({login, data, imports, q, rest, account}, {enabled
|
|||||||
//Compute languages stats
|
//Compute languages stats
|
||||||
for (const {section, stats = {}, lines = {}, missed = {bytes: 0}, total = 0} of [{section: "favorites", stats: languages.stats, lines: languages.lines, total: languages.total, missed: languages.missed}, {section: "recent", ...languages["stats.recent"]}]) {
|
for (const {section, stats = {}, lines = {}, missed = {bytes: 0}, total = 0} of [{section: "favorites", stats: languages.stats, lines: languages.lines, total: languages.total, missed: languages.missed}, {section: "recent", ...languages["stats.recent"]}]) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > computing stats ${section}`)
|
console.debug(`metrics/compute/${login}/plugins > languages > computing stats ${section}`)
|
||||||
languages[section] = Object.entries(stats).filter(([name]) => !ignored.includes(name.toLocaleLowerCase())).sort(([_an, a], [_bn, b]) => b - a).slice(0, limit).map(([name, value]) => ({name, value, size: value, color: languages.colors[name], x: 0})).filter(({value}) =>
|
languages[section] = Object.entries(stats).filter(([name]) => !ignored.includes(name.toLocaleLowerCase())).sort(([_an, a], [_bn, b]) => b - a).slice(0, limit).map(([name, value]) => ({name, value, size: value, color: languages.colors[name], x: 0})).filter(({value}) => value / total > threshold)
|
||||||
value / total > threshold
|
|
||||||
)
|
|
||||||
if (other) {
|
if (other) {
|
||||||
let value = indepth ? missed.bytes : Object.entries(stats).filter(([name]) => !Object.values(languages[section]).map(({name}) => name).includes(name)).reduce((a, [_, b]) => a + b, 0)
|
let value = indepth ? missed.bytes : Object.entries(stats).filter(([name]) => !Object.values(languages[section]).map(({name}) => name).includes(name)).reduce((a, [_, b]) => a + b, 0)
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ export default async function({login, data, imports, rest, q, account}, {enabled
|
|||||||
//Get contributors stats from repositories
|
//Get contributors stats from repositories
|
||||||
console.debug(`metrics/compute/${login}/plugins > lines > querying api`)
|
console.debug(`metrics/compute/${login}/plugins > lines > querying api`)
|
||||||
const lines = {added: 0, deleted: 0, changed: 0}
|
const lines = {added: 0, deleted: 0, changed: 0}
|
||||||
const response = [...await Promise.allSettled(repositories.map(({repo, owner}) => (skipped.includes(repo.toLocaleLowerCase())) || (skipped.includes(`${owner}/${repo}`.toLocaleLowerCase())) ? {} : rest.repos.getContributorsStats({owner, repo})))].filter(({status}) =>
|
const response = [...await Promise.allSettled(repositories.map(({repo, owner}) => (skipped.includes(repo.toLocaleLowerCase())) || (skipped.includes(`${owner}/${repo}`.toLocaleLowerCase())) ? {} : rest.repos.getContributorsStats({owner, repo})))].filter(({status}) => status === "fulfilled").map(({value}) => value)
|
||||||
status === "fulfilled"
|
|
||||||
).map(({value}) => value)
|
|
||||||
|
|
||||||
//Compute changed lines
|
//Compute changed lines
|
||||||
console.debug(`metrics/compute/${login}/plugins > lines > computing total diff`)
|
console.debug(`metrics/compute/${login}/plugins > lines > computing total diff`)
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ export default async function({login, q, imports, rest, graphql, data, account,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Set contributions
|
//Set contributions
|
||||||
contributions = (await Promise.all(contributions.map(async ({handle, stars, issues, pulls, avatarUrl, organization}) => ({name: handle.split("/").shift(), handle, stars, issues, pulls, avatar: await imports.imgb64(avatarUrl), organization})))).sort((a, b) =>
|
contributions = (await Promise.all(contributions.map(async ({handle, stars, issues, pulls, avatarUrl, organization}) => ({name: handle.split("/").shift(), handle, stars, issues, pulls, avatar: await imports.imgb64(avatarUrl), organization})))).sort((a, b) => a.name.localeCompare(b.name))
|
||||||
a.name.localeCompare(b.name)
|
|
||||||
)
|
|
||||||
console.debug(`metrics/compute/${login}/plugins > notable > found ${contributions.length} notable contributions`)
|
console.debug(`metrics/compute/${login}/plugins > notable > found ${contributions.length} notable contributions`)
|
||||||
|
|
||||||
//Extras features
|
//Extras features
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ export default async function({login, imports, data, rest, q, account}, {enabled
|
|||||||
//Get views stats from repositories
|
//Get views stats from repositories
|
||||||
console.debug(`metrics/compute/${login}/plugins > traffic > querying api`)
|
console.debug(`metrics/compute/${login}/plugins > traffic > querying api`)
|
||||||
const views = {count: 0, uniques: 0}
|
const views = {count: 0, uniques: 0}
|
||||||
const response = [...await Promise.allSettled(repositories.map(({repo, owner}) => (skipped.includes(repo.toLocaleLowerCase())) || (skipped.includes(`${owner}/${repo}`.toLocaleLowerCase())) ? {} : rest.repos.getViews({owner, repo})))].filter(({status}) =>
|
const response = [...await Promise.allSettled(repositories.map(({repo, owner}) => (skipped.includes(repo.toLocaleLowerCase())) || (skipped.includes(`${owner}/${repo}`.toLocaleLowerCase())) ? {} : rest.repos.getViews({owner, repo})))].filter(({status}) => status === "fulfilled").map(({value}) => value)
|
||||||
status === "fulfilled"
|
|
||||||
).map(({value}) => value)
|
|
||||||
|
|
||||||
//Compute views
|
//Compute views
|
||||||
console.debug(`metrics/compute/${login}/plugins > traffic > computing stats`)
|
console.debug(`metrics/compute/${login}/plugins > traffic > computing stats`)
|
||||||
|
|||||||
@@ -44,6 +44,5 @@ describe("Check files editions (checkout your files if needed)", () => {
|
|||||||
|
|
||||||
//Templates editions
|
//Templates editions
|
||||||
describe("Check templates editions", () => {
|
describe("Check templates editions", () => {
|
||||||
test("Use community templates instead (see https://github.com/lowlighter/metrics/tree/master/source/templates/community)", async () =>
|
test("Use community templates instead (see https://github.com/lowlighter/metrics/tree/master/source/templates/community)", async () => void expect((await diff()).filter(edited => /^sources[/]templates[/]/.test(edited) && /^source[/]templates[/](?:classic|terminal|markdown|repository|community)[/][\s\S]*$/.test(edited)).length).toBe(0))
|
||||||
void expect((await diff()).filter(edited => /^sources[/]templates[/]/.test(edited) && /^source[/]templates[/](?:classic|terminal|markdown|repository|community)[/][\s\S]*$/.test(edited)).length).toBe(0))
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user