The great refactor (#82)

This commit is contained in:
Simon Lecoq
2021-01-30 12:31:09 +01:00
committed by GitHub
parent f8c6d19a4e
commit 682e43e10b
158 changed files with 6738 additions and 5022 deletions

View File

@@ -0,0 +1,22 @@
### 🌟 Recently starred repositories
The *stars* plugin displays your recently starred repositories.
<table>
<td align="center">
<img src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.stars.svg">
<img width="900" height="1" alt="">
</td>
</table>
#### Examples workflows
[➡️ Available options for this plugin](metadata.yml)
```yaml
- uses: lowlighter/metrics@latest
with:
# ... other options
plugin_stars: yes
plugin_stars_limit: 4 # Limit to 4 entries
```

View File

@@ -1,19 +1,18 @@
//Setup
export default async function ({login, graphql, q, queries, account}, {enabled = false} = {}) {
export default async function ({login, data, graphql, q, queries, imports, account}, {enabled = false} = {}) {
//Plugin execution
try {
//Check if plugin is enabled and requirements are met
if ((!enabled)||(!q.stars))
return null
if (account === "organization")
throw {error:{message:"Not available for organizations"}}
//Parameters override
let {"stars.limit":limit = 4} = q
//Limit
limit = Math.max(1, Math.min(100, Number(limit)))
//Load inputs
let {limit} = imports.metadata.plugins.stars.inputs({data, account, q})
//Retrieve user stars from graphql api
console.debug(`metrics/compute/${login}/plugins > stars > querying api`)
const {user:{starredRepositories:{edges:repositories}}} = await graphql(queries.starred({login, limit}))
const {user:{starredRepositories:{edges:repositories}}} = await graphql(queries.stars({login, limit}))
//Format starred repositories
for (const edge of repositories) {
//Format date
@@ -25,6 +24,7 @@
updated = `${Math.floor(time)} day${time >= 2 ? "s" : ""} ago`
edge.starred = updated
}
//Results
return {repositories}
}

View File

@@ -0,0 +1,19 @@
name: "🌟 Recently starred repositories"
cost: 1 GraphQL request
supports:
- user
inputs:
# Enable or disable plugin
plugin_stars:
description: Display recently starred repositories
type: boolean
default: no
# Number of stars to display
plugin_stars_limit:
description: Maximum number of stars to display
type: number
default: 4
min: 1
max: 100

View File

@@ -0,0 +1,32 @@
query StarsDefault {
user(login: "$login") {
starredRepositories(first: $limit, orderBy: {field: STARRED_AT, direction: DESC}) {
edges {
starredAt
node {
description
forkCount
isFork
issues {
totalCount
}
nameWithOwner
openGraphImageUrl
licenseInfo {
nickname
spdxId
name
}
pullRequests {
totalCount
}
stargazerCount
primaryLanguage {
color
name
}
}
}
}
}
}