Add linter and minor bug fixes (#107)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, url, options, login = faker.internet.userName()}) {
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Last.fm api
|
||||
if (/^https:..ws.audioscrobbler.com.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
@@ -63,4 +63,4 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, url, options, login = faker.internet.userName()}) {
|
||||
/**Mocked data */
|
||||
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
|
||||
@@ -20,17 +20,17 @@
|
||||
"final-screenshot":{
|
||||
id:"final-screenshot",
|
||||
title:"Final Screenshot",
|
||||
score: null,
|
||||
score:null,
|
||||
details:{
|
||||
data:"data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==",
|
||||
type:"screenshot",
|
||||
timestamp:Date.now()
|
||||
}
|
||||
timestamp:Date.now(),
|
||||
},
|
||||
},
|
||||
metrics:{
|
||||
id:"metrics",
|
||||
title:"Metrics",
|
||||
score: null,
|
||||
score:null,
|
||||
details:{
|
||||
items:[
|
||||
{
|
||||
@@ -68,9 +68,9 @@
|
||||
interactive:faker.random.number(1000),
|
||||
observedNavigationStartTs:faker.time.recent(),
|
||||
observedNavigationStart:faker.random.number(10),
|
||||
observedFirstMeaningfulPaintTs:faker.time.recent()
|
||||
observedFirstMeaningfulPaintTs:faker.time.recent(),
|
||||
},
|
||||
]
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -90,16 +90,16 @@
|
||||
title:"Accessibility",
|
||||
score:faker.random.float({max:1}),
|
||||
},
|
||||
performance: {
|
||||
performance:{
|
||||
id:"performance",
|
||||
title:"Performance",
|
||||
score:faker.random.float({max:1}),
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
analysisUTCTimestamp:`${faker.date.recent()}`,
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, url, options, login = faker.internet.userName()}) {
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Spotify api
|
||||
if (/^https:..api.spotify.com.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
@@ -19,24 +19,24 @@
|
||||
{
|
||||
name:artist,
|
||||
type:"artist",
|
||||
}
|
||||
},
|
||||
],
|
||||
images:[
|
||||
{
|
||||
height:640,
|
||||
url:faker.image.abstract(),
|
||||
width:640
|
||||
width:640,
|
||||
},
|
||||
{
|
||||
height:300,
|
||||
url:faker.image.abstract(),
|
||||
width:300
|
||||
width:300,
|
||||
},
|
||||
{
|
||||
height:64,
|
||||
url:faker.image.abstract(),
|
||||
width:64
|
||||
}
|
||||
width:64,
|
||||
},
|
||||
],
|
||||
name:track,
|
||||
release_date:`${faker.date.past()}`.substring(0, 10),
|
||||
@@ -46,7 +46,7 @@
|
||||
{
|
||||
name:artist,
|
||||
type:"artist",
|
||||
}
|
||||
},
|
||||
],
|
||||
name:track,
|
||||
preview_url:faker.internet.url(),
|
||||
@@ -55,11 +55,11 @@
|
||||
played_at:`${faker.date.recent()}`,
|
||||
context:{
|
||||
type:"album",
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, url, options, login = faker.internet.userName()}) {
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Twitter api
|
||||
if (/^https:..api.twitter.com.*$/.test(url)) {
|
||||
//Get user profile
|
||||
@@ -16,7 +16,7 @@
|
||||
id:faker.random.number(1000000).toString(),
|
||||
username,
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
//Get recent tweets
|
||||
@@ -40,7 +40,7 @@
|
||||
id:faker.random.number(100000000000000).toString(),
|
||||
created_at:`${faker.date.recent()}`,
|
||||
text:faker.lorem.paragraph(),
|
||||
}
|
||||
},
|
||||
],
|
||||
includes:{
|
||||
users:[
|
||||
@@ -49,7 +49,7 @@
|
||||
name:"lowlighter",
|
||||
username:"lowlighter",
|
||||
},
|
||||
]
|
||||
],
|
||||
},
|
||||
meta:{
|
||||
newest_id:faker.random.number(100000000000000).toString(),
|
||||
@@ -57,8 +57,8 @@
|
||||
result_count:2,
|
||||
next_token:"MOCKED_CURSOR",
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, url, options, login = faker.internet.userName()}) {
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
//Wakatime api
|
||||
if (/^https:..wakatime.com.api.v1.users.current.stats.*$/.test(url)) {
|
||||
//Get user profile
|
||||
if (/api_key=MOCKED_TOKEN/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking wakatime api result > ${url}`)
|
||||
const stats = (array) => {
|
||||
const stats = array => {
|
||||
const elements = []
|
||||
let results = new Array(4+faker.random.number(2)).fill(null).map(_ => ({
|
||||
get digital() { return `${this.hours}:${this.minutes}` },
|
||||
get digital() {
|
||||
return `${this.hours}:${this.minutes}`
|
||||
},
|
||||
hours:faker.random.number(1000), minutes:faker.random.number(1000),
|
||||
name:array ? faker.random.arrayElement(array) : faker.random.words(2).replace(/ /g, "-").toLocaleLowerCase(),
|
||||
percent:0, total_seconds:faker.random.number(1000000),
|
||||
@@ -43,8 +45,8 @@
|
||||
total_seconds:faker.random.number(1000000000),
|
||||
total_seconds_including_other_language:faker.random.number(1000000000),
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, url, body, login = faker.internet.userName()}) {
|
||||
/**Mocked data */
|
||||
export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
if (/^https:..graphql.anilist.co.*$/.test(url)) {
|
||||
//Initialization and media generator
|
||||
const query = body.query
|
||||
const {query} = body
|
||||
const media = ({type}) => ({
|
||||
title:{romaji:faker.lorem.words(), english:faker.lorem.words(), native:faker.lorem.words()},
|
||||
description:faker.lorem.paragraphs(),
|
||||
@@ -15,11 +15,11 @@
|
||||
countryOfOrigin:"JP",
|
||||
genres:new Array(6).fill(null).map(_ => faker.lorem.word()),
|
||||
coverImage:{medium:null},
|
||||
startDate:{year:faker.date.past(20).getFullYear()}
|
||||
startDate:{year:faker.date.past(20).getFullYear()},
|
||||
})
|
||||
//User statistics query
|
||||
if (/^query Statistics /.test(query)) {
|
||||
console.debug(`metrics/compute/mocks > mocking anilist api result > Statistics`)
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Statistics")
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
@@ -41,15 +41,15 @@
|
||||
volumesRead:faker.random.number(10000),
|
||||
genres:new Array(4).fill(null).map(_ => ({genre:faker.lorem.word()})),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
//Favorites characters
|
||||
if (/^query FavoritesCharacters /.test(query)) {
|
||||
console.debug(`metrics/compute/mocks > mocking anilist api result > Favorites characters`)
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Favorites characters")
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
@@ -59,20 +59,19 @@
|
||||
characters:{
|
||||
nodes:new Array(2+faker.random.number(16)).fill(null).map(_ => ({
|
||||
name:{full:faker.name.findName(), native:faker.name.findName()},
|
||||
image:{medium:null}
|
||||
}),
|
||||
),
|
||||
pageInfo:{currentPage:1, hasNextPage:false}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
image:{medium:null},
|
||||
})),
|
||||
pageInfo:{currentPage:1, hasNextPage:false},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
//Favorites anime/manga query
|
||||
if (/^query Favorites /.test(query)) {
|
||||
console.debug(`metrics/compute/mocks > mocking anilist api result > Favorites`)
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Favorites")
|
||||
const type = /anime[(]/.test(query) ? "ANIME" : /manga[(]/.test(query) ? "MANGA" : "OTHER"
|
||||
return ({
|
||||
status:200,
|
||||
@@ -83,17 +82,17 @@
|
||||
[type.toLocaleLowerCase()]:{
|
||||
nodes:new Array(16).fill(null).map(_ => media({type})),
|
||||
pageInfo:{currentPage:1, hasNextPage:false},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
//Medias query
|
||||
if (/^query Medias /.test(query)) {
|
||||
console.debug(`metrics/compute/mocks > mocking anilist api result > Medias`)
|
||||
const type = body.variables.type
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Medias")
|
||||
const {type} = body.variables
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
@@ -106,19 +105,19 @@
|
||||
entries:new Array(16).fill(null).map(_ => ({
|
||||
status:faker.random.arrayElement(["CURRENT", "PLANNING", "COMPLETED", "DROPPED", "PAUSED", "REPEATING"]),
|
||||
progress:faker.random.number(100),
|
||||
progressVolumes: null,
|
||||
progressVolumes:null,
|
||||
score:0,
|
||||
startedAt:{year:null, month:null, day:null},
|
||||
completedAt:{year:null, month:null, day:null},
|
||||
media:media({type})
|
||||
media:media({type}),
|
||||
})),
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//Imports
|
||||
import urls from "url"
|
||||
|
||||
/** Mocked data */
|
||||
export default function ({faker, url, body, login = faker.internet.userName()}) {
|
||||
/**Mocked data */
|
||||
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)
|
||||
@@ -15,8 +15,8 @@
|
||||
token_type:"Bearer",
|
||||
expires_in:3600,
|
||||
scope:"user-read-recently-played user-read-private",
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > base/repositories`)
|
||||
/**Mocked data */
|
||||
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) ? ({
|
||||
user:{
|
||||
repositories:{
|
||||
edges:[],
|
||||
nodes:[],
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}) : ({
|
||||
user:{
|
||||
repositories:{
|
||||
edges:[
|
||||
{
|
||||
cursor:"MOCKED_CURSOR"
|
||||
cursor:"MOCKED_CURSOR",
|
||||
},
|
||||
],
|
||||
nodes:[
|
||||
@@ -31,7 +31,7 @@
|
||||
{size:faker.random.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.random.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.random.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
]
|
||||
],
|
||||
},
|
||||
issues_open:{totalCount:faker.random.number(100)},
|
||||
issues_closed:{totalCount:faker.random.number(100)},
|
||||
@@ -39,10 +39,10 @@
|
||||
pr_merged:{totalCount:faker.random.number(100)},
|
||||
releases:{totalCount:faker.random.number(100)},
|
||||
forkCount:faker.random.number(100),
|
||||
licenseInfo:{spdxId:"MIT"}
|
||||
licenseInfo:{spdxId:"MIT"},
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > base/repository`)
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/repository")
|
||||
return ({
|
||||
user:{
|
||||
repository:{
|
||||
@@ -20,7 +20,7 @@
|
||||
{size:faker.random.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.random.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.random.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
]
|
||||
],
|
||||
},
|
||||
issues_open:{totalCount:faker.random.number(100)},
|
||||
issues_closed:{totalCount:faker.random.number(100)},
|
||||
@@ -28,8 +28,8 @@
|
||||
pr_merged:{totalCount:faker.random.number(100)},
|
||||
releases:{totalCount:faker.random.number(100)},
|
||||
forkCount:faker.random.number(100),
|
||||
licenseInfo:{spdxId:"MIT"}
|
||||
licenseInfo:{spdxId:"MIT"},
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > base/user`)
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user: {
|
||||
user:{
|
||||
databaseId:faker.random.number(10000000),
|
||||
name:faker.name.findName(),
|
||||
login,
|
||||
@@ -35,7 +35,7 @@
|
||||
{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:[
|
||||
@@ -46,23 +46,23 @@
|
||||
{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"])},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
repositoriesContributedTo:{totalCount:faker.random.number(100)},
|
||||
followers:{totalCount:faker.random.number(1000)},
|
||||
following:{totalCount:faker.random.number(1000)},
|
||||
issueComments:{totalCount:faker.random.number(1000)},
|
||||
organizations:{totalCount:faker.random.number(10)}
|
||||
}
|
||||
organizations:{totalCount:faker.random.number(10)},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > gists/default`)
|
||||
/**Mocked data */
|
||||
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) ? ({
|
||||
user:{
|
||||
gists:{
|
||||
edges:[],
|
||||
nodes:[],
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}) : ({
|
||||
user:{
|
||||
gists:{
|
||||
edges:[
|
||||
{
|
||||
cursor:"MOCKED_CURSOR"
|
||||
cursor:"MOCKED_CURSOR",
|
||||
},
|
||||
],
|
||||
totalCount:faker.random.number(100),
|
||||
@@ -23,17 +23,17 @@
|
||||
isFork:false,
|
||||
forks:{totalCount:faker.random.number(10)},
|
||||
files:[{name:faker.system.fileName()}],
|
||||
comments:{totalCount:faker.random.number(10)}
|
||||
comments:{totalCount:faker.random.number(10)},
|
||||
},
|
||||
{
|
||||
stargazerCount:faker.random.number(10),
|
||||
isFork:false,
|
||||
forks:{totalCount:faker.random.number(10)},
|
||||
files:[{name:faker.system.fileName()}],
|
||||
comments:{totalCount:faker.random.number(10)}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
comments:{totalCount:faker.random.number(10)},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > isocalendar/calendar`)
|
||||
/**Mocked data */
|
||||
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)
|
||||
const to = new Date(query.match(/to: "(?<date>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z)"/)?.groups?.date)
|
||||
@@ -17,16 +17,16 @@
|
||||
contributionDays.push({
|
||||
contributionCount,
|
||||
color:["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"][Math.ceil(contributionCount/10/0.25)],
|
||||
date:date.toISOString().substring(0, 10)
|
||||
date:date.toISOString().substring(0, 10),
|
||||
})
|
||||
}
|
||||
return ({
|
||||
user: {
|
||||
user:{
|
||||
calendar:{
|
||||
contributionCalendar:{
|
||||
weeks
|
||||
}
|
||||
}
|
||||
}
|
||||
weeks,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > people/default`)
|
||||
/**Mocked data */
|
||||
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) ? ({
|
||||
user:{
|
||||
[type]:{
|
||||
edges:[],
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}) : ({
|
||||
user:{
|
||||
[type]:{
|
||||
@@ -16,9 +16,9 @@
|
||||
node:{
|
||||
login,
|
||||
avatarUrl:null,
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > People`)
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > People")
|
||||
const type = query.match(/(?<type>stargazers|watchers)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query) ? ({
|
||||
user:{
|
||||
repository:{
|
||||
[type]:{
|
||||
edges:[],
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}) : ({
|
||||
user:{
|
||||
repository:{
|
||||
@@ -19,10 +19,10 @@
|
||||
node:{
|
||||
login,
|
||||
avatarUrl:null,
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > People`)
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > People")
|
||||
const type = query.match(/(?<type>sponsorshipsAsSponsor|sponsorshipsAsMaintainer)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query) ? ({
|
||||
user:{
|
||||
login,
|
||||
[type]:{
|
||||
edges:[]
|
||||
}
|
||||
}
|
||||
edges:[],
|
||||
},
|
||||
},
|
||||
}) : ({
|
||||
user:{
|
||||
login,
|
||||
@@ -23,10 +23,10 @@
|
||||
sponsorable:{
|
||||
login:faker.internet.userName(),
|
||||
avatarUrl:null,
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > projects/repository`)
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > projects/repository")
|
||||
return ({
|
||||
user:{
|
||||
repository:{
|
||||
@@ -12,10 +12,10 @@
|
||||
doneCount:faker.random.number(10),
|
||||
inProgressCount:faker.random.number(10),
|
||||
todoCount:faker.random.number(10),
|
||||
enabled:true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
enabled:true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > projects/user`)
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > projects/user")
|
||||
return ({
|
||||
user:{
|
||||
projects:{
|
||||
@@ -14,11 +14,11 @@
|
||||
doneCount:faker.random.number(10),
|
||||
inProgressCount:faker.random.number(10),
|
||||
todoCount:faker.random.number(10),
|
||||
enabled:true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
enabled:true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > stargazers/default`)
|
||||
/**Mocked data */
|
||||
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) ? ({
|
||||
repository:{
|
||||
stargazers:{
|
||||
edges:[],
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}) : ({
|
||||
repository:{
|
||||
stargazers:{
|
||||
edges:new Array(faker.random.number({min:50, max:100})).fill(null).map(() => ({
|
||||
starredAt:`${faker.date.recent(30)}`,
|
||||
cursor:"MOCKED_CURSOR"
|
||||
}))
|
||||
}
|
||||
}
|
||||
cursor:"MOCKED_CURSOR",
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug(`metrics/compute/mocks > mocking graphql api result > stars/default`)
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > stars/default")
|
||||
return ({
|
||||
user:{
|
||||
starredRepositories:{
|
||||
@@ -22,16 +22,16 @@
|
||||
stargazerCount:faker.random.number(10000),
|
||||
licenseInfo:{
|
||||
nickname:null,
|
||||
name:"MIT License"
|
||||
name:"MIT License",
|
||||
},
|
||||
primaryLanguage:{
|
||||
color:"#f1e05a",
|
||||
name:"JavaScript"
|
||||
}
|
||||
}
|
||||
name:"JavaScript",
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
export default function ({faker}, target, that, [{username:login, page, per_page}]) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.activity.listEventsForAuthenticatedUser`)
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{username:login, page, per_page}]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listEventsForAuthenticatedUser")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/users/${login}/events?per_page=${per_page}&page=${page}`,
|
||||
@@ -27,7 +27,7 @@
|
||||
path:faker.system.fileName(),
|
||||
commit_id:"MOCKED_SHA",
|
||||
body:faker.lorem.sentence(),
|
||||
}
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -55,7 +55,7 @@
|
||||
login:faker.internet.userName(),
|
||||
},
|
||||
body:"",
|
||||
}
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -77,8 +77,8 @@
|
||||
login,
|
||||
},
|
||||
body:faker.lorem.paragraph(),
|
||||
performed_via_github_app:null
|
||||
}
|
||||
performed_via_github_app:null,
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -99,8 +99,8 @@
|
||||
summary:null,
|
||||
action:"created",
|
||||
sha:"MOCKED_SHA",
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -125,14 +125,14 @@
|
||||
{
|
||||
name:"lorem ipsum",
|
||||
color:"d876e3",
|
||||
}
|
||||
},
|
||||
],
|
||||
state:"open",
|
||||
},
|
||||
comment:{
|
||||
body:faker.lorem.paragraph(),
|
||||
performed_via_github_app:null
|
||||
}
|
||||
performed_via_github_app:null,
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -149,7 +149,7 @@
|
||||
forkee:{
|
||||
name:faker.random.word(),
|
||||
full_name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -178,7 +178,7 @@
|
||||
user:{
|
||||
login:faker.internet.userName(),
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -198,7 +198,7 @@
|
||||
name:faker.random.words(4),
|
||||
draft:faker.random.boolean(),
|
||||
prerelease:faker.random.boolean(),
|
||||
}
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -262,8 +262,8 @@
|
||||
sha:"MOCKED_SHA",
|
||||
message:faker.lorem.sentence(),
|
||||
url:"https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -288,7 +288,7 @@
|
||||
additions:faker.random.number(1000),
|
||||
deletions:faker.random.number(1000),
|
||||
changed_files:faker.random.number(10),
|
||||
}
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -305,7 +305,7 @@
|
||||
member:{
|
||||
login:faker.internet.userName(),
|
||||
},
|
||||
action:"added"
|
||||
action:"added",
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
},
|
||||
@@ -320,7 +320,7 @@
|
||||
},
|
||||
payload:{},
|
||||
created_at:faker.date.recent(7),
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** Mocked data */
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, args) {
|
||||
return ({
|
||||
status:200,
|
||||
@@ -17,7 +17,7 @@
|
||||
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,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{owner, repo}]) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.repos.getContributorsStats`)
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getContributorsStats")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/stats/contributors`,
|
||||
@@ -18,10 +18,10 @@
|
||||
{w:3, a:faker.random.number(10000), d:faker.random.number(10000), c:faker.random.number(10000)},
|
||||
{w:4, a:faker.random.number(10000), d:faker.random.number(10000), c:faker.random.number(10000)},
|
||||
],
|
||||
author: {
|
||||
author:{
|
||||
login:owner,
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Mocked data */
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{owner, repo}]) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.repos.getViews`)
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getViews")
|
||||
const count = faker.random.number(10000)*2
|
||||
const uniques = faker.random.number(count)*2
|
||||
return ({
|
||||
@@ -17,7 +17,7 @@
|
||||
views:[
|
||||
{timestamp:`${faker.date.recent()}`, count:count/2, uniques:uniques/2},
|
||||
{timestamp:`${faker.date.recent()}`, count:count/2, uniques:uniques/2},
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
/** Mocked data */
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{page, per_page, owner, repo}]) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.repos.listCommits`)
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listCommits")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/commits?per_page=${per_page}&page=${page}`,
|
||||
headers: {
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
},
|
||||
data:page < 2 ? new Array(per_page).fill(null).map(() =>
|
||||
({
|
||||
data:page < 2 ? new Array(per_page).fill(null).map(() => ({
|
||||
sha:"MOCKED_SHA",
|
||||
commit:{
|
||||
author:{
|
||||
name:owner,
|
||||
date:`${faker.date.recent(14)}`
|
||||
date:`${faker.date.recent(14)}`,
|
||||
},
|
||||
committer:{
|
||||
name:owner,
|
||||
date:`${faker.date.recent(14)}`
|
||||
date:`${faker.date.recent(14)}`,
|
||||
},
|
||||
}
|
||||
})
|
||||
) : []
|
||||
},
|
||||
})) : [],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** Mocked data */
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{owner, repo}]) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.repos.listContributors`)
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listContributors")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/contributors`,
|
||||
headers: {
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
@@ -13,6 +13,6 @@
|
||||
login:faker.internet.userName(),
|
||||
avatar_url:null,
|
||||
contributions:faker.random.number(1000),
|
||||
}))
|
||||
})),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** Mocked data */
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, args) {
|
||||
//Arguments
|
||||
const [url] = args
|
||||
//Head request
|
||||
if (/^HEAD .$/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.request HEAD`)
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.request HEAD")
|
||||
return ({
|
||||
status:200,
|
||||
url:"https://api.github.com/",
|
||||
@@ -13,7 +13,7 @@
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
},
|
||||
data:undefined
|
||||
data:undefined,
|
||||
})
|
||||
}
|
||||
//Commit content
|
||||
@@ -44,16 +44,16 @@
|
||||
login:faker.internet.userName(),
|
||||
id:faker.random.number(100000000),
|
||||
},
|
||||
files: [
|
||||
files:[
|
||||
{
|
||||
sha:"MOCKED_SHA",
|
||||
filename:faker.system.fileName(),
|
||||
patch:"@@ -0,0 +1,5 @@\n+//Imports\n+ import app from \"./src/app.mjs\"\n+\n+//Start app\n+ await app()\n\\ No newline at end of file"
|
||||
patch:"@@ -0,0 +1,5 @@\n+//Imports\n+ import app from \"./src/app.mjs\"\n+\n+//Start app\n+ await app()\n\\ No newline at end of file",
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return target(...args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** Mocked data */
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{username}]) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.repos.getByUsername`)
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getByUsername")
|
||||
return ({
|
||||
status:200,
|
||||
url:`'https://api.github.com/users/${username}/`,
|
||||
headers: {
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
@@ -13,6 +13,6 @@
|
||||
login:faker.internet.userName(),
|
||||
avatar_url:null,
|
||||
contributions:faker.random.number(1000),
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user