chore: code formatting
This commit is contained in:
@@ -10,13 +10,13 @@ const ejs = require("ejs")
|
||||
|
||||
//Github action
|
||||
const action = yaml.load(fs.readFileSync(path.join(__dirname, "../action.yml"), "utf8"))
|
||||
action.defaults = Object.fromEntries(Object.entries(action.inputs).map(([key, { default: value }]) => [key, value]))
|
||||
action.defaults = Object.fromEntries(Object.entries(action.inputs).map(([key, {default: value}]) => [key, value]))
|
||||
action.input = vars => Object.fromEntries([...Object.entries(action.defaults), ...Object.entries(vars)].map(([key, value]) => [`INPUT_${key.toLocaleUpperCase()}`, value]))
|
||||
action.run = async vars =>
|
||||
await new Promise((solve, reject) => {
|
||||
let [stdout, stderr] = ["", ""]
|
||||
const env = { ...process.env, ...action.input(vars), GITHUB_REPOSITORY: "lowlighter/metrics" }
|
||||
const child = processes.spawn("node", ["source/app/action/index.mjs"], { env })
|
||||
const env = {...process.env, ...action.input(vars), GITHUB_REPOSITORY: "lowlighter/metrics"}
|
||||
const child = processes.spawn("node", ["source/app/action/index.mjs"], {env})
|
||||
child.stdout.on("data", data => stdout += data)
|
||||
child.stderr.on("data", data => stderr += data)
|
||||
child.on("close", code => {
|
||||
@@ -33,7 +33,7 @@ web.run = async vars => (await axios(`http://localhost:3000/lowlighter?${new url
|
||||
web.start = async () =>
|
||||
new Promise(solve => {
|
||||
let stdout = ""
|
||||
web.instance = processes.spawn("node", ["source/app/web/index.mjs"], { env: { ...process.env, SANDBOX: true } })
|
||||
web.instance = processes.spawn("node", ["source/app/web/index.mjs"], {env: {...process.env, SANDBOX: true}})
|
||||
web.instance.stdout.on("data", data => (stdout += data, /Server ready !/.test(stdout) ? solve() : null))
|
||||
web.instance.stderr.on("data", data => console.error(`${data}`))
|
||||
})
|
||||
@@ -58,8 +58,8 @@ placeholder.run = async vars => {
|
||||
const config = Object.fromEntries(Object.entries(options).filter(([key]) => /^config[.]/.test(key)))
|
||||
const base = Object.fromEntries(Object.entries(options).filter(([key]) => /^base[.]/.test(key)))
|
||||
return typeof await placeholder({
|
||||
templates: { selected: vars.template },
|
||||
plugins: { enabled: { ...enabled, base }, options },
|
||||
templates: {selected: vars.template},
|
||||
plugins: {enabled: {...enabled, base}, options},
|
||||
config,
|
||||
version: "TEST",
|
||||
user: "lowlighter",
|
||||
@@ -70,7 +70,7 @@ placeholder.run = async vars => {
|
||||
//Setup
|
||||
beforeAll(async () => {
|
||||
//Clean community template
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), { recursive: true, force: true })
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), {recursive: true, force: true})
|
||||
//Start web instance
|
||||
await web.start()
|
||||
})
|
||||
@@ -79,7 +79,7 @@ afterAll(async () => {
|
||||
//Stop web instance
|
||||
await web.stop()
|
||||
//Clean community template
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), { recursive: true, force: true })
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), {recursive: true, force: true})
|
||||
})
|
||||
|
||||
//Load metadata (as jest doesn't support ESM modules, we use this dirty hack)
|
||||
@@ -98,11 +98,11 @@ for (const type of ["plugins", "templates"]) {
|
||||
for (const name in metadata[type]) {
|
||||
const cases = yaml
|
||||
.load(fs.readFileSync(path.join(__dirname, "../tests/cases", `${name}.${type.replace(/s$/, "")}.yml`), "utf8"))
|
||||
?.map(({ name: test, with: inputs, modes = [], timeout }) => {
|
||||
const skip = new Set(Object.entries(metadata.templates).filter(([_, { readme: { compatibility } }]) => !compatibility[name]).map(([template]) => template))
|
||||
?.map(({name: test, with: inputs, modes = [], timeout}) => {
|
||||
const skip = new Set(Object.entries(metadata.templates).filter(([_, {readme: {compatibility}}]) => !compatibility[name]).map(([template]) => template))
|
||||
if (!(metadata[type][name].supports?.includes("repository")))
|
||||
skip.add("repository")
|
||||
return [test, inputs, { skip: [...skip], modes, timeout }]
|
||||
return [test, inputs, {skip: [...skip], modes, timeout}]
|
||||
}) ?? []
|
||||
tests.push(...cases)
|
||||
}
|
||||
@@ -113,13 +113,13 @@ describe("GitHub Action", () =>
|
||||
describe.each([
|
||||
["classic", {}],
|
||||
["terminal", {}],
|
||||
["repository", { repo: "metrics" }],
|
||||
["repository", {repo: "metrics"}],
|
||||
])("Template : %s", (template, query) => {
|
||||
for (const [name, input, { skip = [], modes = [], timeout } = {}] of tests) {
|
||||
for (const [name, input, {skip = [], modes = [], timeout} = {}] of tests) {
|
||||
if ((skip.includes(template)) || ((modes.length) && (!modes.includes("action"))))
|
||||
test.skip(name, () => null)
|
||||
else
|
||||
test(name, async () => expect(await action.run({ template, base: "", query: JSON.stringify(query), plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, ...input })).toBe(true), timeout)
|
||||
test(name, async () => expect(await action.run({template, base: "", query: JSON.stringify(query), plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, ...input})).toBe(true), timeout)
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -127,13 +127,13 @@ describe("Web instance", () =>
|
||||
describe.each([
|
||||
["classic", {}],
|
||||
["terminal", {}],
|
||||
["repository", { repo: "metrics" }],
|
||||
["repository", {repo: "metrics"}],
|
||||
])("Template : %s", (template, query) => {
|
||||
for (const [name, input, { skip = [], modes = [], timeout } = {}] of tests) {
|
||||
for (const [name, input, {skip = [], modes = [], timeout} = {}] of tests) {
|
||||
if ((skip.includes(template)) || ((modes.length) && (!modes.includes("web"))))
|
||||
test.skip(name, () => null)
|
||||
else
|
||||
test(name, async () => expect(await web.run({ template, base: 0, ...query, plugins_errors_fatal: true, verify: true, ...input })).toBe(true), timeout)
|
||||
test(name, async () => expect(await web.run({template, base: 0, ...query, plugins_errors_fatal: true, verify: true, ...input})).toBe(true), timeout)
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -142,10 +142,10 @@ describe("Web instance (placeholder)", () =>
|
||||
["classic", {}],
|
||||
["terminal", {}],
|
||||
])("Template : %s", (template, query) => {
|
||||
for (const [name, input, { skip = [], modes = [], timeout } = {}] of tests) {
|
||||
for (const [name, input, {skip = [], modes = [], timeout} = {}] of tests) {
|
||||
if ((skip.includes(template)) || ((modes.length) && (!modes.includes("placeholder"))))
|
||||
test.skip(name, () => null)
|
||||
else
|
||||
test(name, async () => expect(await placeholder.run({ template, base: 0, ...query, ...input })).toBe(true), timeout)
|
||||
test(name, async () => expect(await placeholder.run({template, base: 0, ...query, ...input})).toBe(true), timeout)
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Last.fm api
|
||||
if (/^https:..ws.audioscrobbler.com.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url }) {
|
||||
export default function({faker, url}) {
|
||||
//Last.fm api
|
||||
if (/^https:..testapp.herokuapp.com.*$/.test(url)) {
|
||||
//Get Nightscout Data
|
||||
@@ -12,8 +12,8 @@ export default function({ faker, url }) {
|
||||
device: "xDrip-DexcomG5",
|
||||
date: lastInterval,
|
||||
dateString: new Date(lastInterval).toISOString(),
|
||||
sgv: faker.datatype.number({ min: 40, max: 400 }),
|
||||
delta: faker.datatype.number({ min: -10, max: 10 }),
|
||||
sgv: faker.datatype.number({min: 40, max: 400}),
|
||||
delta: faker.datatype.number({min: -10, max: 10}),
|
||||
direction: faker.random.arrayElement(["SingleUp", "DoubleUp", "FortyFiveUp", "Flat", "FortyFiveDown", "SingleDown", "DoubleDown"]),
|
||||
type: "sgv",
|
||||
filtered: 0,
|
||||
@@ -21,7 +21,7 @@ export default function({ faker, url }) {
|
||||
rssi: 100,
|
||||
noise: 1,
|
||||
sysTime: new Date(lastInterval).toISOString(),
|
||||
utcOffset: faker.datatype.number({ min: -12, max: 14 }) * 60,
|
||||
utcOffset: faker.datatype.number({min: -12, max: 14}) * 60,
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Tested url
|
||||
const tested = url.match(/&url=(?<tested>.*?)(?:&|$)/)?.groups?.tested ?? faker.internet.url()
|
||||
//Pagespeed api
|
||||
@@ -43,12 +43,12 @@ export default function({ faker, url, options, login = faker.internet.userName()
|
||||
maxPotentialFID: faker.datatype.number(500),
|
||||
observedLoad: faker.datatype.number(500),
|
||||
firstMeaningfulPaint: faker.datatype.number(500),
|
||||
observedCumulativeLayoutShift: faker.datatype.float({ max: 1 }),
|
||||
observedCumulativeLayoutShift: faker.datatype.float({max: 1}),
|
||||
observedSpeedIndex: faker.datatype.number(1000),
|
||||
observedSpeedIndexTs: faker.time.recent(),
|
||||
observedTimeOriginTs: faker.time.recent(),
|
||||
observedLargestContentfulPaint: faker.datatype.number(1000),
|
||||
cumulativeLayoutShift: faker.datatype.float({ max: 1 }),
|
||||
cumulativeLayoutShift: faker.datatype.float({max: 1}),
|
||||
observedFirstPaintTs: faker.time.recent(),
|
||||
observedTraceEndTs: faker.time.recent(),
|
||||
largestContentfulPaint: faker.datatype.number(2000),
|
||||
@@ -78,22 +78,22 @@ export default function({ faker, url, options, login = faker.internet.userName()
|
||||
"best-practices": {
|
||||
id: "best-practices",
|
||||
title: "Best Practices",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
score: faker.datatype.float({max: 1}),
|
||||
},
|
||||
seo: {
|
||||
id: "seo",
|
||||
title: "SEO",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
score: faker.datatype.float({max: 1}),
|
||||
},
|
||||
accessibility: {
|
||||
id: "accessibility",
|
||||
title: "Accessibility",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
score: faker.datatype.float({max: 1}),
|
||||
},
|
||||
performance: {
|
||||
id: "performance",
|
||||
title: "Performance",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
score: faker.datatype.float({max: 1}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Wakatime api
|
||||
if (/^https:..api.poopmap.net.*$/.test(url)) {
|
||||
//Get user profile
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Spotify api
|
||||
if (/^https:..api.spotify.com.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Stackoverflow api
|
||||
if (/^https:..api.stackexchange.com.2.2.*$/.test(url)) {
|
||||
//Extract user id
|
||||
@@ -13,7 +13,7 @@ export default function({ faker, url, options, login = faker.internet.userName()
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
badge_counts: { bronze: faker.datatype.number(500), silver: faker.datatype.number(300), gold: faker.datatype.number(100) },
|
||||
badge_counts: {bronze: faker.datatype.number(500), silver: faker.datatype.number(300), gold: faker.datatype.number(100)},
|
||||
accept_rate: faker.datatype.number(100),
|
||||
answer_count: faker.datatype.number(1000),
|
||||
question_count: faker.datatype.number(1000),
|
||||
@@ -48,7 +48,7 @@ export default function({ faker, url, options, login = faker.internet.userName()
|
||||
data: {
|
||||
items: new Array(pagesize).fill(null).map(_ => ({
|
||||
tags: new Array(5).fill(null).map(_ => faker.lorem.slug()),
|
||||
owner: { display_name: faker.internet.userName() },
|
||||
owner: {display_name: faker.internet.userName()},
|
||||
is_answered: faker.datatype.boolean(),
|
||||
view_count: faker.datatype.number(10000),
|
||||
accepted_answer_id: faker.datatype.number(1000000),
|
||||
@@ -77,7 +77,7 @@ export default function({ faker, url, options, login = faker.internet.userName()
|
||||
status: 200,
|
||||
data: {
|
||||
items: new Array(pagesize).fill(null).map(_ => ({
|
||||
owner: { display_name: faker.internet.userName() },
|
||||
owner: {display_name: faker.internet.userName()},
|
||||
link: faker.internet.url(),
|
||||
is_accepted: faker.datatype.boolean(),
|
||||
score: faker.datatype.number(1000),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Twitter api
|
||||
if (/^https:..api.twitter.com.*$/.test(url)) {
|
||||
//Get user profile
|
||||
@@ -31,7 +31,7 @@ export default function({ faker, url, options, login = faker.internet.userName()
|
||||
created_at: `${faker.date.recent()}`,
|
||||
entities: {
|
||||
mentions: [
|
||||
{ start: 22, end: 33, username: "lowlighter" },
|
||||
{start: 22, end: 33, username: "lowlighter"},
|
||||
],
|
||||
},
|
||||
text: "Checkout metrics from @lowlighter ! #GitHub",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Wakatime api
|
||||
if (/^https:..wakatime.com.api.v1.users..*.stats.*$/.test(url)) {
|
||||
//Get user profile
|
||||
@@ -17,7 +17,7 @@ export default function({ faker, url, options, login = faker.internet.userName()
|
||||
percent: 0,
|
||||
total_seconds: faker.datatype.number(1000000),
|
||||
}))
|
||||
results = results.filter(({ name }) => elements.includes(name) ? false : (elements.push(name), true))
|
||||
results = results.filter(({name}) => elements.includes(name) ? false : (elements.push(name), true))
|
||||
let percents = 100
|
||||
for (const result of results) {
|
||||
result.percent = 1 + faker.datatype.number(percents - 1)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Wakatime api
|
||||
if (/^https:..apidojo-yahoo-finance-v1.p.rapidapi.com.stock.v2.*$/.test(url)) {
|
||||
//Get company profile
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, body, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
if (/^https:..graphql.anilist.co.*$/.test(url)) {
|
||||
//Initialization and media generator
|
||||
const { query } = body
|
||||
const media = ({ type }) => ({
|
||||
title: { romaji: faker.lorem.words(), english: faker.lorem.words(), native: faker.lorem.words() },
|
||||
const {query} = body
|
||||
const media = ({type}) => ({
|
||||
title: {romaji: faker.lorem.words(), english: faker.lorem.words(), native: faker.lorem.words()},
|
||||
description: faker.lorem.paragraphs(),
|
||||
type,
|
||||
status: faker.random.arrayElement(["FINISHED", "RELEASING", "NOT_YET_RELEASED", "CANCELLED", "HIATUS"]),
|
||||
@@ -14,8 +14,8 @@ export default function({ faker, url, body, login = faker.internet.userName() })
|
||||
averageScore: faker.datatype.number(100),
|
||||
countryOfOrigin: "JP",
|
||||
genres: new Array(6).fill(null).map(_ => faker.lorem.word()),
|
||||
coverImage: { medium: null },
|
||||
startDate: { year: faker.date.past(20).getFullYear() },
|
||||
coverImage: {medium: null},
|
||||
startDate: {year: faker.date.past(20).getFullYear()},
|
||||
})
|
||||
//User statistics query
|
||||
if (/^query Statistics /.test(query)) {
|
||||
@@ -33,13 +33,13 @@ export default function({ faker, url, body, login = faker.internet.userName() })
|
||||
count: faker.datatype.number(1000),
|
||||
minutesWatched: faker.datatype.number(100000),
|
||||
episodesWatched: faker.datatype.number(10000),
|
||||
genres: new Array(4).fill(null).map(_ => ({ genre: faker.lorem.word() })),
|
||||
genres: new Array(4).fill(null).map(_ => ({genre: faker.lorem.word()})),
|
||||
},
|
||||
manga: {
|
||||
count: faker.datatype.number(1000),
|
||||
chaptersRead: faker.datatype.number(100000),
|
||||
volumesRead: faker.datatype.number(10000),
|
||||
genres: new Array(4).fill(null).map(_ => ({ genre: faker.lorem.word() })),
|
||||
genres: new Array(4).fill(null).map(_ => ({genre: faker.lorem.word()})),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -58,10 +58,10 @@ export default function({ faker, url, body, login = faker.internet.userName() })
|
||||
favourites: {
|
||||
characters: {
|
||||
nodes: new Array(2 + faker.datatype.number(16)).fill(null).map(_ => ({
|
||||
name: { full: faker.name.findName(), native: faker.name.findName() },
|
||||
image: { medium: null },
|
||||
name: {full: faker.name.findName(), native: faker.name.findName()},
|
||||
image: {medium: null},
|
||||
})),
|
||||
pageInfo: { currentPage: 1, hasNextPage: false },
|
||||
pageInfo: {currentPage: 1, hasNextPage: false},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -80,8 +80,8 @@ export default function({ faker, url, body, login = faker.internet.userName() })
|
||||
User: {
|
||||
favourites: {
|
||||
[type.toLocaleLowerCase()]: {
|
||||
nodes: new Array(16).fill(null).map(_ => media({ type })),
|
||||
pageInfo: { currentPage: 1, hasNextPage: false },
|
||||
nodes: new Array(16).fill(null).map(_ => media({type})),
|
||||
pageInfo: {currentPage: 1, hasNextPage: false},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -92,7 +92,7 @@ export default function({ faker, url, body, login = faker.internet.userName() })
|
||||
//Medias query
|
||||
if (/^query Medias /.test(query)) {
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Medias")
|
||||
const { type } = body.variables
|
||||
const {type} = body.variables
|
||||
return ({
|
||||
status: 200,
|
||||
data: {
|
||||
@@ -100,16 +100,16 @@ export default function({ faker, url, body, login = faker.internet.userName() })
|
||||
MediaListCollection: {
|
||||
lists: [
|
||||
{
|
||||
name: { ANIME: "Watching", MANGA: "Reading", OTHER: "Completed" }[type],
|
||||
name: {ANIME: "Watching", MANGA: "Reading", OTHER: "Completed"}[type],
|
||||
isCustomList: false,
|
||||
entries: new Array(16).fill(null).map(_ => ({
|
||||
status: faker.random.arrayElement(["CURRENT", "PLANNING", "COMPLETED", "DROPPED", "PAUSED", "REPEATING"]),
|
||||
progress: faker.datatype.number(100),
|
||||
progressVolumes: null,
|
||||
score: 0,
|
||||
startedAt: { year: null, month: null, day: null },
|
||||
completedAt: { year: null, month: null, day: null },
|
||||
media: media({ type }),
|
||||
startedAt: {year: null, month: null, day: null},
|
||||
completedAt: {year: null, month: null, day: null},
|
||||
media: media({type}),
|
||||
})),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, body, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
if (/^https:..api.hashnode.com.*$/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking hashnode result > ${url}`)
|
||||
return ({
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import urls from "url"
|
||||
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, body, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
if (/^https:..accounts.spotify.com.api.token.*$/.test(url)) {
|
||||
//Access token generator
|
||||
const params = new urls.URLSearchParams(body)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
if (/^https:..music.youtube.com.youtubei.v1.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
if (/browse/.test(url)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/metrics")
|
||||
return ({
|
||||
user: {
|
||||
@@ -22,14 +22,14 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
popular: {
|
||||
nodes: [{ stargazers: { totalCount: faker.datatype.number(50000) } }],
|
||||
nodes: [{stargazers: {totalCount: faker.datatype.number(50000)}}],
|
||||
},
|
||||
pullRequests: {
|
||||
nodes: [
|
||||
{
|
||||
createdAt: faker.date.recent(),
|
||||
title: faker.lorem.sentence(),
|
||||
repository: { nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}` },
|
||||
repository: {nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`},
|
||||
},
|
||||
],
|
||||
totalCount: faker.datatype.number(50000),
|
||||
@@ -42,29 +42,29 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
pullRequest: {
|
||||
title: faker.lorem.sentence(),
|
||||
number: faker.datatype.number(1000),
|
||||
repository: { nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}` },
|
||||
repository: {nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`},
|
||||
},
|
||||
},
|
||||
],
|
||||
totalCount: faker.datatype.number(1000),
|
||||
},
|
||||
},
|
||||
projects: { totalCount: faker.datatype.number(100) },
|
||||
packages: { totalCount: faker.datatype.number(100) },
|
||||
organizations: { nodes: [], totalCount: faker.datatype.number(5) },
|
||||
projects: {totalCount: faker.datatype.number(100)},
|
||||
packages: {totalCount: faker.datatype.number(100)},
|
||||
organizations: {nodes: [], totalCount: faker.datatype.number(5)},
|
||||
gists: {
|
||||
nodes: [{ createdAt: faker.date.recent(), name: faker.lorem.slug() }],
|
||||
nodes: [{createdAt: faker.date.recent(), name: faker.lorem.slug()}],
|
||||
totalCount: faker.datatype.number(1000),
|
||||
},
|
||||
starredRepositories: { totalCount: faker.datatype.number(1000) },
|
||||
followers: { totalCount: faker.datatype.number(10000) },
|
||||
following: { totalCount: faker.datatype.number(10000) },
|
||||
starredRepositories: {totalCount: faker.datatype.number(1000)},
|
||||
followers: {totalCount: faker.datatype.number(10000)},
|
||||
following: {totalCount: faker.datatype.number(10000)},
|
||||
bio: faker.lorem.sentence(),
|
||||
status: { message: faker.lorem.paragraph() },
|
||||
sponsorshipsAsSponsor: { totalCount: faker.datatype.number(100) },
|
||||
discussionsStarted: { totalCount: faker.datatype.number(1000) },
|
||||
discussionsComments: { totalCount: faker.datatype.number(1000) },
|
||||
discussionAnswers: { totalCount: faker.datatype.number(1000) },
|
||||
status: {message: faker.lorem.paragraph()},
|
||||
sponsorshipsAsSponsor: {totalCount: faker.datatype.number(100)},
|
||||
discussionsStarted: {totalCount: faker.datatype.number(1000)},
|
||||
discussionsComments: {totalCount: faker.datatype.number(1000)},
|
||||
discussionAnswers: {totalCount: faker.datatype.number(1000)},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/metrics")
|
||||
return ({
|
||||
repository: { viewerHasStarred: faker.datatype.boolean() },
|
||||
viewer: { login },
|
||||
repository: {viewerHasStarred: faker.datatype.boolean()},
|
||||
viewer: {login},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/octocat")
|
||||
return ({
|
||||
user: { viewerIsFollowing: faker.datatype.boolean() },
|
||||
viewer: { login },
|
||||
user: {viewerIsFollowing: faker.datatype.boolean()},
|
||||
viewer: {login},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/organizations")
|
||||
return ({
|
||||
organization: {
|
||||
@@ -22,12 +22,12 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
popular: {
|
||||
nodes: [{ stargazers: { totalCount: faker.datatype.number(50000) } }],
|
||||
nodes: [{stargazers: {totalCount: faker.datatype.number(50000)}}],
|
||||
},
|
||||
projects: { totalCount: faker.datatype.number(100) },
|
||||
packages: { totalCount: faker.datatype.number(100) },
|
||||
membersWithRole: { totalCount: faker.datatype.number(100) },
|
||||
sponsorshipsAsSponsor: { totalCount: faker.datatype.number(100) },
|
||||
projects: {totalCount: faker.datatype.number(100)},
|
||||
packages: {totalCount: faker.datatype.number(100)},
|
||||
membersWithRole: {totalCount: faker.datatype.number(100)},
|
||||
sponsorshipsAsSponsor: {totalCount: faker.datatype.number(100)},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/ranking")
|
||||
return ({
|
||||
repo_rank: { repositoryCount: faker.datatype.number(100000) },
|
||||
forks_rank: { repositoryCount: faker.datatype.number(100000) },
|
||||
created_rank: { userCount: faker.datatype.number(100000) },
|
||||
user_rank: { userCount: faker.datatype.number(100000) },
|
||||
repo_total: { repositoryCount: faker.datatype.number(100000) },
|
||||
user_total: { userCount: faker.datatype.number(100000) },
|
||||
repo_rank: {repositoryCount: faker.datatype.number(100000)},
|
||||
forks_rank: {repositoryCount: faker.datatype.number(100000)},
|
||||
created_rank: {userCount: faker.datatype.number(100000)},
|
||||
user_rank: {userCount: faker.datatype.number(100000)},
|
||||
repo_total: {repositoryCount: faker.datatype.number(100000)},
|
||||
user_total: {userCount: faker.datatype.number(100000)},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user: {
|
||||
@@ -8,29 +8,29 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
weeks: [
|
||||
{
|
||||
contributionDays: [
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
],
|
||||
},
|
||||
{
|
||||
contributionDays: [
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
],
|
||||
},
|
||||
{
|
||||
contributionDays: [
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user: {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user: {
|
||||
packages: { totalCount: faker.datatype.number(10) },
|
||||
starredRepositories: { totalCount: faker.datatype.number(1000) },
|
||||
watching: { totalCount: faker.datatype.number(100) },
|
||||
sponsorshipsAsSponsor: { totalCount: faker.datatype.number(10) },
|
||||
sponsorshipsAsMaintainer: { totalCount: faker.datatype.number(10) },
|
||||
repositoriesContributedTo: { totalCount: faker.datatype.number(100) },
|
||||
followers: { totalCount: faker.datatype.number(1000) },
|
||||
following: { totalCount: faker.datatype.number(1000) },
|
||||
issueComments: { totalCount: faker.datatype.number(1000) },
|
||||
organizations: { totalCount: faker.datatype.number(10) },
|
||||
packages: {totalCount: faker.datatype.number(10)},
|
||||
starredRepositories: {totalCount: faker.datatype.number(1000)},
|
||||
watching: {totalCount: faker.datatype.number(100)},
|
||||
sponsorshipsAsSponsor: {totalCount: faker.datatype.number(10)},
|
||||
sponsorshipsAsMaintainer: {totalCount: faker.datatype.number(10)},
|
||||
repositoriesContributedTo: {totalCount: faker.datatype.number(100)},
|
||||
followers: {totalCount: faker.datatype.number(1000)},
|
||||
following: {totalCount: faker.datatype.number(1000)},
|
||||
issueComments: {totalCount: faker.datatype.number(1000)},
|
||||
organizations: {totalCount: faker.datatype.number(10)},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user: {
|
||||
repositories: { totalCount: faker.datatype.number(100), totalDiskUsage: faker.datatype.number(100000) },
|
||||
repositories: {totalCount: faker.datatype.number(100), totalDiskUsage: faker.datatype.number(100000)},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/repositories")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
@@ -27,30 +27,30 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nodes: [
|
||||
{
|
||||
name: faker.random.words(),
|
||||
watchers: { totalCount: faker.datatype.number(1000) },
|
||||
stargazers: { totalCount: faker.datatype.number(10000) },
|
||||
owner: { login },
|
||||
watchers: {totalCount: faker.datatype.number(1000)},
|
||||
stargazers: {totalCount: faker.datatype.number(10000)},
|
||||
owner: {login},
|
||||
languages: {
|
||||
edges: [
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
],
|
||||
},
|
||||
issues_open: { totalCount: faker.datatype.number(100) },
|
||||
issues_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_open: { totalCount: faker.datatype.number(100) },
|
||||
pr_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_merged: { totalCount: faker.datatype.number(100) },
|
||||
releases: { totalCount: faker.datatype.number(100) },
|
||||
issues_open: {totalCount: faker.datatype.number(100)},
|
||||
issues_closed: {totalCount: faker.datatype.number(100)},
|
||||
pr_open: {totalCount: faker.datatype.number(100)},
|
||||
pr_closed: {totalCount: faker.datatype.number(100)},
|
||||
pr_merged: {totalCount: faker.datatype.number(100)},
|
||||
releases: {totalCount: faker.datatype.number(100)},
|
||||
forkCount: faker.datatype.number(100),
|
||||
licenseInfo: { spdxId: "MIT" },
|
||||
deployments: { totalCount: faker.datatype.number(100) },
|
||||
environments: { totalCount: faker.datatype.number(100) },
|
||||
licenseInfo: {spdxId: "MIT"},
|
||||
deployments: {totalCount: faker.datatype.number(100)},
|
||||
environments: {totalCount: faker.datatype.number(100)},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/repository")
|
||||
return ({
|
||||
user: {
|
||||
repository: {
|
||||
name: "metrics",
|
||||
owner: { login },
|
||||
owner: {login},
|
||||
createdAt: new Date().toISOString(),
|
||||
diskUsage: Math.floor(Math.random() * 10000),
|
||||
homepageUrl: faker.internet.url(),
|
||||
watchers: { totalCount: faker.datatype.number(1000) },
|
||||
stargazers: { totalCount: faker.datatype.number(10000) },
|
||||
watchers: {totalCount: faker.datatype.number(1000)},
|
||||
stargazers: {totalCount: faker.datatype.number(10000)},
|
||||
languages: {
|
||||
edges: [
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
{size: faker.datatype.number(100000), node: {color: faker.internet.color(), name: faker.lorem.word()}},
|
||||
],
|
||||
},
|
||||
issues_open: { totalCount: faker.datatype.number(100) },
|
||||
issues_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_open: { totalCount: faker.datatype.number(100) },
|
||||
pr_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_merged: { totalCount: faker.datatype.number(100) },
|
||||
releases: { totalCount: faker.datatype.number(100) },
|
||||
issues_open: {totalCount: faker.datatype.number(100)},
|
||||
issues_closed: {totalCount: faker.datatype.number(100)},
|
||||
pr_open: {totalCount: faker.datatype.number(100)},
|
||||
pr_closed: {totalCount: faker.datatype.number(100)},
|
||||
pr_merged: {totalCount: faker.datatype.number(100)},
|
||||
releases: {totalCount: faker.datatype.number(100)},
|
||||
forkCount: faker.datatype.number(100),
|
||||
licenseInfo: { spdxId: "MIT" },
|
||||
deployments: { totalCount: faker.datatype.number(100) },
|
||||
environments: { totalCount: faker.datatype.number(100) },
|
||||
licenseInfo: {spdxId: "MIT"},
|
||||
deployments: {totalCount: faker.datatype.number(100)},
|
||||
environments: {totalCount: faker.datatype.number(100)},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > contributors/commit")
|
||||
return ({
|
||||
repository: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > discussions/categories")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
@@ -13,7 +13,7 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
: ({
|
||||
user: {
|
||||
repositoryDiscussions: {
|
||||
edges: new Array(100).fill(null).map(_ => ({ cursor: "MOCKED_CURSOR" })),
|
||||
edges: new Array(100).fill(null).map(_ => ({cursor: "MOCKED_CURSOR"})),
|
||||
nodes: new Array(100).fill(null).map(_ => ({
|
||||
category: {
|
||||
emoji: faker.random.arrayElement([":chart_with_upwards_trend:", ":chart_with_downwards_trend:", ":bar_char:"]),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > discussions/comments")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
@@ -13,8 +13,8 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
: ({
|
||||
user: {
|
||||
repositoryDiscussionsComments: {
|
||||
edges: new Array(100).fill(null).map(_ => ({ cursor: "MOCKED_CURSOR" })),
|
||||
nodes: new Array(100).fill(null).map(_ => ({ upvoteCount: faker.datatype.number(10) })),
|
||||
edges: new Array(100).fill(null).map(_ => ({cursor: "MOCKED_CURSOR"})),
|
||||
nodes: new Array(100).fill(null).map(_ => ({upvoteCount: faker.datatype.number(10)})),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > discussions/statistics")
|
||||
return ({
|
||||
user: {
|
||||
started: { totalCount: faker.datatype.number(1000) },
|
||||
comments: { totalCount: faker.datatype.number(1000) },
|
||||
answers: { totalCount: faker.datatype.number(1000) },
|
||||
started: {totalCount: faker.datatype.number(1000)},
|
||||
comments: {totalCount: faker.datatype.number(1000)},
|
||||
answers: {totalCount: faker.datatype.number(1000)},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > followup/repository/collaborators")
|
||||
return ({
|
||||
repository: {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > followup/repository")
|
||||
return ({
|
||||
issues_open: { issueCount: faker.datatype.number(100) },
|
||||
issues_drafts: { issueCount: faker.datatype.number(100) },
|
||||
issues_skipped: { issueCount: faker.datatype.number(100) },
|
||||
issues_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_open: { issueCount: faker.datatype.number(100) },
|
||||
pr_drafts: { issueCount: faker.datatype.number(100) },
|
||||
pr_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_merged: { issueCount: faker.datatype.number(100) },
|
||||
issues_open: {issueCount: faker.datatype.number(100)},
|
||||
issues_drafts: {issueCount: faker.datatype.number(100)},
|
||||
issues_skipped: {issueCount: faker.datatype.number(100)},
|
||||
issues_closed: {issueCount: faker.datatype.number(100)},
|
||||
pr_open: {issueCount: faker.datatype.number(100)},
|
||||
pr_drafts: {issueCount: faker.datatype.number(100)},
|
||||
pr_closed: {issueCount: faker.datatype.number(100)},
|
||||
pr_merged: {issueCount: faker.datatype.number(100)},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > followup/user")
|
||||
return ({
|
||||
issues_open: { issueCount: faker.datatype.number(100) },
|
||||
issues_drafts: { issueCount: faker.datatype.number(100) },
|
||||
issues_skipped: { issueCount: faker.datatype.number(100) },
|
||||
issues_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_open: { issueCount: faker.datatype.number(100) },
|
||||
pr_drafts: { issueCount: faker.datatype.number(100) },
|
||||
pr_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_merged: { issueCount: faker.datatype.number(100) },
|
||||
issues_open: {issueCount: faker.datatype.number(100)},
|
||||
issues_drafts: {issueCount: faker.datatype.number(100)},
|
||||
issues_skipped: {issueCount: faker.datatype.number(100)},
|
||||
issues_closed: {issueCount: faker.datatype.number(100)},
|
||||
pr_open: {issueCount: faker.datatype.number(100)},
|
||||
pr_drafts: {issueCount: faker.datatype.number(100)},
|
||||
pr_closed: {issueCount: faker.datatype.number(100)},
|
||||
pr_merged: {issueCount: faker.datatype.number(100)},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > gists/default")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
@@ -23,16 +23,16 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
{
|
||||
stargazerCount: faker.datatype.number(10),
|
||||
isFork: false,
|
||||
forks: { totalCount: faker.datatype.number(10) },
|
||||
files: [{ name: faker.system.fileName() }],
|
||||
comments: { totalCount: faker.datatype.number(10) },
|
||||
forks: {totalCount: faker.datatype.number(10)},
|
||||
files: [{name: faker.system.fileName()}],
|
||||
comments: {totalCount: faker.datatype.number(10)},
|
||||
},
|
||||
{
|
||||
stargazerCount: faker.datatype.number(10),
|
||||
isFork: false,
|
||||
forks: { totalCount: faker.datatype.number(10) },
|
||||
files: [{ name: faker.system.fileName() }],
|
||||
comments: { totalCount: faker.datatype.number(10) },
|
||||
forks: {totalCount: faker.datatype.number(10)},
|
||||
files: [{name: faker.system.fileName()}],
|
||||
comments: {totalCount: faker.datatype.number(10)},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > introduction/organization")
|
||||
return ({
|
||||
organization: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > introduction/repository")
|
||||
return ({
|
||||
repository: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > introduction/user")
|
||||
return ({
|
||||
user: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > isocalendar/calendar")
|
||||
//Generate calendar
|
||||
const date = new Date(query.match(/from: "(?<date>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z)"/)?.groups?.date)
|
||||
@@ -9,7 +9,7 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
for (; date <= to; date.setDate(date.getDate() + 1)) {
|
||||
//Create new week on sunday
|
||||
if (date.getDay() === 0) {
|
||||
weeks.push({ contributionDays })
|
||||
weeks.push({contributionDays})
|
||||
contributionDays = []
|
||||
}
|
||||
//Random contributions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > licenses/default")
|
||||
return ({
|
||||
licenses: [
|
||||
@@ -9,22 +9,22 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: "GNU AGPLv3",
|
||||
key: "agpl-3.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "network-use-disclose", label: "Network use is distribution" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
{key: "document-changes", label: "State changes"},
|
||||
{key: "disclose-source", label: "Disclose source"},
|
||||
{key: "network-use-disclose", label: "Network use is distribution"},
|
||||
{key: "same-license", label: "Same license"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "patent-use", label: "Patent use"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -33,20 +33,20 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "apache-2.0",
|
||||
limitations: [
|
||||
{ key: "trademark-use", label: "Trademark use" },
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "trademark-use", label: "Trademark use"},
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
{key: "document-changes", label: "State changes"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "patent-use", label: "Patent use"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -55,17 +55,17 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "bsd-2-clause",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -74,17 +74,17 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "bsd-3-clause",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -93,17 +93,17 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "bsl-1.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright--source", label: "License and copyright notice for source" },
|
||||
{key: "include-copyright--source", label: "License and copyright notice for source"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -112,17 +112,17 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "cc0-1.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "trademark-use", label: "Trademark use" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "trademark-use", label: "Trademark use"},
|
||||
{key: "patent-use", label: "Patent use"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -131,20 +131,20 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "epl-2.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
{key: "disclose-source", label: "Disclose source"},
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
{key: "same-license", label: "Same license"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "patent-use", label: "Patent use"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -153,20 +153,20 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: "GNU GPLv2",
|
||||
key: "gpl-2.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
{key: "document-changes", label: "State changes"},
|
||||
{key: "disclose-source", label: "Disclose source"},
|
||||
{key: "same-license", label: "Same license"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -175,21 +175,21 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: "GNU GPLv3",
|
||||
key: "gpl-3.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
{key: "document-changes", label: "State changes"},
|
||||
{key: "disclose-source", label: "Disclose source"},
|
||||
{key: "same-license", label: "Same license"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "patent-use", label: "Patent use"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -198,20 +198,20 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: "GNU LGPLv2.1",
|
||||
key: "lgpl-2.1",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "same-license--library", label: "Same license (library)" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
{key: "disclose-source", label: "Disclose source"},
|
||||
{key: "document-changes", label: "State changes"},
|
||||
{key: "same-license--library", label: "Same license (library)"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -220,17 +220,17 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "mit",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -239,21 +239,21 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "mpl-2.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "trademark-use", label: "Trademark use" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "trademark-use", label: "Trademark use"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "same-license--file", label: "Same license (file)" },
|
||||
{key: "disclose-source", label: "Disclose source"},
|
||||
{key: "include-copyright", label: "License and copyright notice"},
|
||||
{key: "same-license--file", label: "Same license (file)"},
|
||||
],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
{key: "patent-use", label: "Patent use"},
|
||||
{key: "private-use", label: "Private use"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -262,15 +262,15 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
nickname: null,
|
||||
key: "unlicense",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
{key: "liability", label: "Liability"},
|
||||
{key: "warranty", label: "Warranty"},
|
||||
],
|
||||
conditions: [],
|
||||
permissions: [
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{key: "private-use", label: "Private use"},
|
||||
{key: "commercial-use", label: "Commercial use"},
|
||||
{key: "modifications", label: "Modification"},
|
||||
{key: "distribution", label: "Distribution"},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > licenses/repository")
|
||||
return ({
|
||||
user: {
|
||||
repository: {
|
||||
licenseInfo: { spdxId: "MIT", name: "MIT License", nickname: null, key: "mit" },
|
||||
licenseInfo: {spdxId: "MIT", name: "MIT License", nickname: null, key: "mit"},
|
||||
url: "https://github.com/lowlighter/metrics",
|
||||
databaseId: 293860197,
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > notable/contributions")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
@@ -22,11 +22,11 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
avatarUrl: null,
|
||||
},
|
||||
nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
stargazers: { totalCount: faker.datatype.number(1000) },
|
||||
watchers: { totalCount: faker.datatype.number(1000) },
|
||||
forks: { totalCount: faker.datatype.number(1000) },
|
||||
issues: { totalCount: faker.datatype.number(1000) },
|
||||
pullRequests: { totalCount: faker.datatype.number(1000) },
|
||||
stargazers: {totalCount: faker.datatype.number(1000)},
|
||||
watchers: {totalCount: faker.datatype.number(1000)},
|
||||
forks: {totalCount: faker.datatype.number(1000)},
|
||||
issues: {totalCount: faker.datatype.number(1000)},
|
||||
pullRequests: {totalCount: faker.datatype.number(1000)},
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > notable/issues")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > people/default")
|
||||
const type = query.match(/(?<type>followers|following)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > people/repository")
|
||||
const type = query.match(/(?<type>stargazers|watchers)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > people/sponsors")
|
||||
const type = query.match(/(?<type>sponsorshipsAsSponsor|sponsorshipsAsMaintainer)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > projects/repository")
|
||||
return ({
|
||||
user: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > projects/user")
|
||||
return ({
|
||||
user: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > reactions/default")
|
||||
const type = query.match(/(?<type>issues|issueComments)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
@@ -20,7 +20,7 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
createdAt: faker.date.recent(),
|
||||
reactions: {
|
||||
nodes: new Array(50).fill(null).map(_ => ({
|
||||
user: { login: faker.internet.userName() },
|
||||
user: {login: faker.internet.userName()},
|
||||
content: faker.random.arrayElement(["HEART", "THUMBS_UP", "THUMBS_DOWN", "LAUGH", "CONFUSED", "EYES", "ROCKET", "HOORAY"]),
|
||||
})),
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > stars/default")
|
||||
return ({
|
||||
repository: {
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > sponsors/default")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query) ?
|
||||
({
|
||||
user: {
|
||||
sponsorshipsAsMaintainer: {
|
||||
edges:[],
|
||||
nodes:[],
|
||||
}
|
||||
}
|
||||
})
|
||||
: ({
|
||||
user: {
|
||||
sponsorshipsAsMaintainer: {
|
||||
edges: new Array(10).fill("MOCKED_CURSOR"),
|
||||
nodes: new Array(10).fill(null).map(_ => ({
|
||||
sponsorEntity: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
tier: {
|
||||
monthlyPriceInDollars: faker.datatype.number(10),
|
||||
},
|
||||
})),
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user: {
|
||||
sponsorshipsAsMaintainer: {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
: ({
|
||||
user: {
|
||||
sponsorshipsAsMaintainer: {
|
||||
edges: new Array(10).fill("MOCKED_CURSOR"),
|
||||
nodes: new Array(10).fill(null).map(_ => ({
|
||||
sponsorEntity: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
tier: {
|
||||
monthlyPriceInDollars: faker.datatype.number(10),
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > sponsors/all")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query) ?
|
||||
({
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user: {
|
||||
sponsorsActivities: {
|
||||
edges:[],
|
||||
nodes:[],
|
||||
}
|
||||
}
|
||||
})
|
||||
: ({
|
||||
user: {
|
||||
sponsorsActivities: {
|
||||
edges: new Array(10).fill("MOCKED_CURSOR"),
|
||||
nodes: new Array(10).fill(null).map(_ => ({
|
||||
sponsor: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
sponsorsTier: {
|
||||
monthlyPriceInDollars: faker.datatype.number(10),
|
||||
},
|
||||
})),
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
: ({
|
||||
user: {
|
||||
sponsorsActivities: {
|
||||
edges: new Array(10).fill("MOCKED_CURSOR"),
|
||||
nodes: new Array(10).fill(null).map(_ => ({
|
||||
sponsor: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
sponsorsTier: {
|
||||
monthlyPriceInDollars: faker.datatype.number(10),
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > sponsors/default")
|
||||
return ({
|
||||
user: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > stargazers/default")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
@@ -12,7 +12,7 @@ export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
: ({
|
||||
repository: {
|
||||
stargazers: {
|
||||
edges: new Array(faker.datatype.number({ min: 50, max: 100 })).fill(null).map(() => ({
|
||||
edges: new Array(faker.datatype.number({min: 50, max: 100})).fill(null).map(() => ({
|
||||
starredAt: `${faker.date.recent(30)}`,
|
||||
cursor: "MOCKED_CURSOR",
|
||||
})),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > stars/default")
|
||||
return ({
|
||||
user: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ username: login, page, per_page }]) {
|
||||
export default async function({faker}, target, that, [{username: login, page, per_page}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listEventsForAuthenticatedUser")
|
||||
return ({
|
||||
status: 200,
|
||||
@@ -236,7 +236,7 @@ export default async function({ faker }, target, that, [{ username: login, page,
|
||||
repo: {
|
||||
name: "lowlighter/metrics",
|
||||
},
|
||||
payload: { action: "started" },
|
||||
payload: {action: "started"},
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import listEventsForAuthenticatedUser from "./listEventsForAuthenticatedUser.mjs"
|
||||
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ username: login, page, per_page }]) {
|
||||
export default async function({faker}, target, that, [{username: login, page, per_page}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listRepoEvents")
|
||||
return listEventsForAuthenticatedUser(...arguments)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that) {
|
||||
export default async function({faker}, target, that) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.emojis.get")
|
||||
return ({
|
||||
status: 200,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, args) {
|
||||
export default async function({faker}, target, that, args) {
|
||||
return ({
|
||||
status: 200,
|
||||
url: "https://api.github.com/rate_limit",
|
||||
@@ -10,14 +10,14 @@ export default async function({ faker }, target, that, args) {
|
||||
},
|
||||
data: {
|
||||
resources: {
|
||||
core: { limit: 5000, used: 0, remaining: 5000, reset: 0 },
|
||||
search: { limit: 30, used: 0, remaining: 30, reset: 0 },
|
||||
graphql: { limit: 5000, used: 0, remaining: 5000, reset: 0 },
|
||||
integration_manifest: { limit: 5000, used: 0, remaining: 5000, reset: 0 },
|
||||
source_import: { limit: 100, used: 0, remaining: 100, reset: 0 },
|
||||
code_scanning_upload: { limit: 500, used: 0, remaining: 500, reset: 0 },
|
||||
core: {limit: 5000, used: 0, remaining: 5000, reset: 0},
|
||||
search: {limit: 30, used: 0, remaining: 30, reset: 0},
|
||||
graphql: {limit: 5000, used: 0, remaining: 5000, reset: 0},
|
||||
integration_manifest: {limit: 5000, used: 0, remaining: 5000, reset: 0},
|
||||
source_import: {limit: 100, used: 0, remaining: 100, reset: 0},
|
||||
code_scanning_upload: {limit: 500, used: 0, remaining: 500, reset: 0},
|
||||
},
|
||||
rate: { limit: 5000, used: 0, remaining: "MOCKED", reset: 0 },
|
||||
rate: {limit: 5000, used: 0, remaining: "MOCKED", reset: 0},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ owner, repo }]) {
|
||||
export default async function({faker}, target, that, [{owner, repo}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getContributorsStats")
|
||||
return ({
|
||||
status: 200,
|
||||
@@ -13,10 +13,10 @@ export default async function({ faker }, target, that, [{ owner, repo }]) {
|
||||
{
|
||||
total: faker.datatype.number(10000),
|
||||
weeks: [
|
||||
{ w: 1, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
{ w: 2, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
{ w: 3, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
{ w: 4, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
{w: 1, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
|
||||
{w: 2, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
|
||||
{w: 3, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
|
||||
{w: 4, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
|
||||
],
|
||||
author: {
|
||||
login: owner,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ owner, repo }]) {
|
||||
export default async function({faker}, target, that, [{owner, repo}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getViews")
|
||||
const count = faker.datatype.number(10000) * 2
|
||||
const uniques = faker.datatype.number(count) * 2
|
||||
@@ -15,8 +15,8 @@ export default async function({ faker }, target, that, [{ owner, repo }]) {
|
||||
count,
|
||||
uniques,
|
||||
views: [
|
||||
{ timestamp: `${faker.date.recent()}`, count: count / 2, uniques: uniques / 2 },
|
||||
{ timestamp: `${faker.date.recent()}`, count: count / 2, uniques: uniques / 2 },
|
||||
{timestamp: `${faker.date.recent()}`, count: count / 2, uniques: uniques / 2},
|
||||
{timestamp: `${faker.date.recent()}`, count: count / 2, uniques: uniques / 2},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ page, per_page, owner, repo }]) {
|
||||
export default async function({faker}, target, that, [{page, per_page, owner, repo}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listCommits")
|
||||
return ({
|
||||
status: 200,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ owner, repo }]) {
|
||||
export default async function({faker}, target, that, [{owner, repo}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listContributors")
|
||||
return ({
|
||||
status: 200,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, args) {
|
||||
export default async function({faker}, target, that, args) {
|
||||
//Arguments
|
||||
const [url] = args
|
||||
//Head request
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ username }]) {
|
||||
export default async function({faker}, target, that, [{username}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getByUsername")
|
||||
return ({
|
||||
status: 200,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default async function({ faker }, target, that, [{ username }]) {
|
||||
export default async function({faker}, target, that, [{username}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.users.listGpgKeysForUser")
|
||||
return ({
|
||||
status: 200,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//Imports
|
||||
import faker from "@faker-js/faker"
|
||||
import fs from "fs/promises"
|
||||
import axios from "axios"
|
||||
import fs from "fs/promises"
|
||||
import paths from "path"
|
||||
import rss from "rss-parser"
|
||||
import urls from "url"
|
||||
@@ -10,21 +10,21 @@ import urls from "url"
|
||||
let mocked = false
|
||||
|
||||
//Mocking
|
||||
export default async function({ graphql, rest }) {
|
||||
export default async function({graphql, rest}) {
|
||||
//Check if already mocked
|
||||
if (mocked)
|
||||
return { graphql, rest }
|
||||
return {graphql, rest}
|
||||
mocked = true
|
||||
console.debug("metrics/compute/mocks > mocking")
|
||||
|
||||
//Load mocks
|
||||
const __mocks = paths.join(paths.dirname(urls.fileURLToPath(import.meta.url)))
|
||||
const mock = async ({ directory, mocks }) => {
|
||||
const mock = async ({directory, mocks}) => {
|
||||
for (const entry of await fs.readdir(directory)) {
|
||||
if ((await fs.lstat(paths.join(directory, entry))).isDirectory()) {
|
||||
if (!mocks[entry])
|
||||
mocks[entry] = {}
|
||||
await mock({ directory: paths.join(directory, entry), mocks: mocks[entry] })
|
||||
await mock({directory: paths.join(directory, entry), mocks: mocks[entry]})
|
||||
}
|
||||
else {
|
||||
mocks[entry.replace(/[.]mjs$/, "")] = (await import(urls.pathToFileURL(paths.join(directory, entry)).href)).default
|
||||
@@ -32,7 +32,7 @@ export default async function({ graphql, rest }) {
|
||||
}
|
||||
return mocks
|
||||
}
|
||||
const mocks = await mock({ directory: paths.join(__mocks, "api"), mocks: {} })
|
||||
const mocks = await mock({directory: paths.join(__mocks, "api"), mocks: {}})
|
||||
|
||||
//GraphQL API mocking
|
||||
{
|
||||
@@ -49,7 +49,7 @@ export default async function({ graphql, rest }) {
|
||||
//Search for mocked query
|
||||
for (const mocked of Object.keys(mocks.github.graphql)) {
|
||||
if (new RegExp(`^query ${mocked.replace(/([.]\w)/g, (_, g) => g.toLocaleUpperCase().substring(1)).replace(/^(\w)/g, (_, g) => g.toLocaleUpperCase())} `).test(query))
|
||||
return mocks.github.graphql[mocked]({ faker, query, login })
|
||||
return mocks.github.graphql[mocked]({faker, query, login})
|
||||
}
|
||||
|
||||
//Unmocked call
|
||||
@@ -64,26 +64,26 @@ export default async function({ graphql, rest }) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api")
|
||||
const unmocked = {}
|
||||
//Mocked
|
||||
const mocker = ({ path = "rest", mocks, mocked }) => {
|
||||
const mocker = ({path = "rest", mocks, mocked}) => {
|
||||
for (const [key, value] of Object.entries(mocks)) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api > mocking ${path}.${key}`)
|
||||
if (typeof value === "function") {
|
||||
unmocked[path] = value
|
||||
mocked[key] = new Proxy(unmocked[path], { apply: value.bind(null, { faker }) })
|
||||
mocked[key] = new Proxy(unmocked[path], {apply: value.bind(null, {faker})})
|
||||
}
|
||||
else {
|
||||
mocker({ path: `${path}.${key}`, mocks: mocks[key], mocked: mocked[key] })
|
||||
mocker({path: `${path}.${key}`, mocks: mocks[key], mocked: mocked[key]})
|
||||
}
|
||||
}
|
||||
}
|
||||
mocker({ mocks: mocks.github.rest, mocked: rest })
|
||||
mocker({mocks: mocks.github.rest, mocked: rest})
|
||||
}
|
||||
|
||||
//Axios mocking
|
||||
{
|
||||
//Unmocked
|
||||
console.debug("metrics/compute/mocks > mocking axios")
|
||||
const unmocked = { get: axios.get, post: axios.post }
|
||||
const unmocked = {get: axios.get, post: axios.post}
|
||||
|
||||
//Mocked post requests
|
||||
axios.post = new Proxy(unmocked.post, {
|
||||
@@ -93,7 +93,7 @@ export default async function({ graphql, rest }) {
|
||||
|
||||
//Search for mocked request
|
||||
for (const service of Object.keys(mocks.axios.post)) {
|
||||
const mocked = mocks.axios.post[service]({ faker, url, body })
|
||||
const mocked = mocks.axios.post[service]({faker, url, body})
|
||||
if (mocked)
|
||||
return mocked
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export default async function({ graphql, rest }) {
|
||||
|
||||
//Search for mocked request
|
||||
for (const service of Object.keys(mocks.axios.get)) {
|
||||
const mocked = mocks.axios.get[service]({ faker, url, options })
|
||||
const mocked = mocks.axios.get[service]({faker, url, options})
|
||||
if (mocked)
|
||||
return mocked
|
||||
}
|
||||
@@ -146,5 +146,5 @@ export default async function({ graphql, rest }) {
|
||||
}
|
||||
|
||||
//Return mocked elements
|
||||
return { graphql, rest }
|
||||
return {graphql, rest}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ try {
|
||||
fss.accessSync(__presets)
|
||||
}
|
||||
catch {
|
||||
let { HEAD_REF: branch, REPO: repo } = process.env
|
||||
let {HEAD_REF: branch, REPO: repo} = process.env
|
||||
branch = branch || "presets"
|
||||
repo = repo || "lowlighter/metrics"
|
||||
if (!/^[/-\w\d]+$/.test(branch))
|
||||
@@ -38,10 +38,10 @@ for (const path of fss.readdirSync(__presets)) {
|
||||
test("syntax is valid", () => expect(true).toBe(true))
|
||||
try {
|
||||
//Load schema
|
||||
const { properties } = yaml.load(fss.readFileSync(paths.join(__presets, "@schema", `${preset.schema}.yml`)))
|
||||
const {properties} = yaml.load(fss.readFileSync(paths.join(__presets, "@schema", `${preset.schema}.yml`)))
|
||||
test("schema is valid", () => expect(preset.schema).toBeDefined())
|
||||
//Test schema
|
||||
for (const [key, { type, required }] of Object.entries(properties)) {
|
||||
for (const [key, {type, required}] of Object.entries(properties)) {
|
||||
if (required)
|
||||
test(`preset.${key} is defined`, () => expect(preset[key]).toBeDefined())
|
||||
test(`preset.${key} type is ${type}`, () => {
|
||||
|
||||
Reference in New Issue
Block a user