Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pkgjs/statusboard into replace-libnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
bjohansebas committed Jan 29, 2025
2 parents 07d76f8 + ad88b09 commit e9a4ff7
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 44 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,43 @@ on:
- main

concurrency:
group: "test"
group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: false

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- name: Install dependencies
run: npm install --ignore-scripts --only=dev

- name: Run lint
run: npm run lint

test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 19, 20, 21, 22, 23]
steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: npm install and test

- name: Install dependencies
run: npm install

- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm it
run: npm test
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const DEFAULTS = {
baseUrl: '',
port: 5005,
template: builder,
indicies: indicies,
indicies,
title: 'StatusBoard',
description: 'Project StatusBoard',
issueLabels: ['top priority', 'good first issue', 'help wanted', 'discussion', 'meeting']
Expand Down
20 changes: 10 additions & 10 deletions lib/db/build-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const { Project } = require('../project')

module.exports = async function buildIndex (config, db) {
// Loop projects
for await (let evt of iterateProjects(config)) {
let { type, project, detail } = evt
for await (const evt of iterateProjects(config)) {
const { type, project, detail } = evt
let key = `${project.repoOwner}:${project.repoName}:${type}`
switch (type) {
case 'ISSUE':
Expand All @@ -32,21 +32,21 @@ async function * iterateProjects (config) {
const [octokit, graphQL] = await github(config.github)

// Load projects
for (let proj of config.projects) {
for await (let evt of loadProject(octokit, graphQL, proj, config)) {
for (const proj of config.projects) {
for await (const evt of loadProject(octokit, graphQL, proj, config)) {
yield evt
}
}

// Load projects for org
for (let org of config.orgs) {
for (const org of config.orgs) {
try {
for await (let repo of github.getOrgRepos(graphQL, org.name)) {
for await (const repo of github.getOrgRepos(graphQL, org.name)) {
const proj = new Project({
repoOwner: repo.owner,
repoName: repo.name
})
for await (let evt of loadProject(octokit, graphQL, proj, config, repo)) {
for await (const evt of loadProject(octokit, graphQL, proj, config, repo)) {
yield evt
}
}
Expand Down Expand Up @@ -130,23 +130,23 @@ async function * loadProject (octokit, graphQL, project, config, _repo) {
}

try {
for await (let issue of github.getRepoIssues(graphQL, project.repoOwner, project.repoName)) {
for await (const issue of github.getRepoIssues(graphQL, project.repoOwner, project.repoName)) {
yield projectDetail('ISSUE', project, issue)
}
} catch (e) {
yield projectDetail('ERROR', project, e)
}

try {
for await (let activity of github.getRepoActivity(octokit, project.repoOwner, project.repoName)) {
for await (const activity of github.getRepoActivity(octokit, project.repoOwner, project.repoName)) {
yield projectDetail('ACTIVITY', project, activity)
}
} catch (e) {
yield projectDetail('ERROR', project, e)
}

try {
for await (let commit of github.getRepoCommits(graphQL, project.repoOwner, project.repoName)) {
for await (const commit of github.getRepoCommits(graphQL, project.repoOwner, project.repoName)) {
yield projectDetail('COMMIT', project, commit)
}
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion lib/files.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict'
const fetch = require('node-fetch')
const yaml = require('js-yaml')
const GHRAW = 'https://raw.githubusercontent.com/'

Expand Down
44 changes: 22 additions & 22 deletions lib/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ module.exports.getRepo =
${repoQuerySnip}
}`,
org: owner,
repo: repo
repo
})
return new Repo(owner, resp.repository)
} catch (error) {
Expand Down Expand Up @@ -206,8 +206,8 @@ async function getRemainingPullRequests (graphQL, owner, repo, cursor) {
}
`,
org: owner,
repo: repo,
cursor: cursor
repo,
cursor
})
const { pageInfo, edges } = resp.organization.repository.pullRequests
const pullRequests = !pageInfo.hasNextPage ? edges : edges.concat(await getRemainingPullRequests(graphQL, owner, repo, pageInfo.endCursor))
Expand All @@ -232,7 +232,7 @@ async function getPullRequests (graphQL, owner, repo) {
}
}`,
org: owner,
repo: repo
repo
})
const { pageInfo, edges } = resp.organization.repository.pullRequests
const pullRequests = !pageInfo.hasNextPage ? edges : edges.concat(await getRemainingPullRequests(graphQL, owner, repo, pageInfo.endCursor))
Expand All @@ -258,8 +258,8 @@ async function getRemainingIssues (graphQL, owner, repo, cursor) {
}
`,
org: owner,
repo: repo,
cursor: cursor
repo,
cursor
})
const { pageInfo, edges } = resp.organization.repository.issues
const issues = !pageInfo.hasNextPage ? edges : edges.concat(await getRemainingIssues(graphQL, owner, repo, pageInfo.endCursor))
Expand All @@ -274,7 +274,7 @@ async function getRemainingIssues (graphQL, owner, repo, cursor) {
module.exports.getRepoIssues =
async function * getRepoIssues (graphQL, owner, repo) {
try {
let resp = await graphQL({
const resp = await graphQL({
query: `query ($org: String!, $repo: String!) {
organization(login: $org) {
repository(name: $repo) {
Expand All @@ -285,14 +285,14 @@ module.exports.getRepoIssues =
}
}`,
org: owner,
repo: repo
repo
})
const { pageInfo, edges } = resp.organization.repository.issues
const issues = !pageInfo.hasNextPage ? edges : edges.concat(await getRemainingIssues(graphQL, owner, repo, pageInfo.endCursor))

issues.push.apply(issues, await getPullRequests(graphQL, owner, repo))

for (let i of issues) {
for (const i of issues) {
yield new Issue(owner, repo, i.node)
}
} catch (error) {
Expand Down Expand Up @@ -333,7 +333,7 @@ async function * getRepoActivity (octokit, owner, repo) {
throw e
}

for (let a of resp.data) {
for (const a of resp.data) {
yield new Activity(owner, repo, a)
}
}
Expand Down Expand Up @@ -364,7 +364,7 @@ module.exports.getReadme =
}
`,
org: owner,
repo: repo
repo
})
let readmeText
Object.values(resp.repository).forEach(element => {
Expand Down Expand Up @@ -396,8 +396,8 @@ async function getRemainingRepos (graphQL, org, cursor) {
}
}
}`,
org: org,
cursor: cursor
org,
cursor
})

const { pageInfo, nodes } = resp.organization.repositories
Expand All @@ -414,7 +414,7 @@ async function getRemainingRepos (graphQL, org, cursor) {
module.exports.getOrgRepos =
async function * getOrgRepos (graphQL, org) {
try {
let resp = await graphQL({
const resp = await graphQL({
query: `query($org: String!)
{
organization(login: $org) {
Expand All @@ -428,13 +428,13 @@ module.exports.getOrgRepos =
}
}
}`,
org: org
org
})

const { pageInfo, nodes } = resp.organization.repositories
const repos = !pageInfo.hasNextPage ? nodes : nodes.concat(await getRemainingRepos(graphQL, org, pageInfo.endCursor))

for (let r of repos) {
for (const r of repos) {
yield new Repo(org, r)
}
} catch (error) {
Expand Down Expand Up @@ -467,7 +467,7 @@ class Commit {

async function getRemainingCommits (graphQL, owner, repo, cursor) {
try {
let resp = await graphQL({
const resp = await graphQL({
query: `query ($org: String!, $repo: String!, $cursor: String!) {
repository(name: $repo, owner: $org) {
object(expression: "master") {
Expand Down Expand Up @@ -501,8 +501,8 @@ async function getRemainingCommits (graphQL, owner, repo, cursor) {
}
`,
org: owner,
repo: repo,
cursor: cursor
repo,
cursor
})
const { pageInfo, nodes } = resp.repository.object.history
const commits = !pageInfo.hasNextPage ? nodes : nodes.concat(await getRemainingCommits(graphQL, owner, repo, pageInfo.endCursor))
Expand All @@ -517,7 +517,7 @@ async function getRemainingCommits (graphQL, owner, repo, cursor) {
module.exports.getRepoCommits =
async function * getRepoCommits (graphQL, owner, repo) {
try {
let resp = await graphQL({
const resp = await graphQL({
query: `query ($org: String!, $repo: String!) {
repository(name: $repo, owner: $org) {
object(expression: "master") {
Expand Down Expand Up @@ -551,12 +551,12 @@ async function * getRepoCommits (graphQL, owner, repo) {
}
`,
org: owner,
repo: repo
repo
})
const { pageInfo, nodes } = resp.repository.object.history
const commits = !pageInfo.hasNextPage ? nodes : nodes.concat(await getRemainingCommits(graphQL, owner, repo, pageInfo.endCursor))

for (let c of commits) {
for (const c of commits) {
yield new Commit(owner, repo, c)
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion lib/template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = async function (config, db) {
const accumulator = {}

// Read full index
for await (let { key, value } of readFullIndex(db)) {
for await (const { key, value } of readFullIndex(db)) {
await Promise.all(Object.keys(indicies).map(async (index) => {
accumulator[index] = await indicies[index](accumulator[index], config, key, value)
}))
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"statusboard": "./bin/statusboard"
},
"scripts": {
"test": "standard && mocha",
"lint": "standard",
"test": "mocha",
"prepublushOnly": "npm t",
"postpublish": "git push origin && git push origin --tags",
"clean": "./bin/statusboard clean -C ./test/fixtures/config -d ./gh-pages/data.db",
Expand All @@ -29,9 +30,8 @@
"serve": "./bin/statusboard serve -o ./gh-pages -C ./test/fixtures/config -d ./gh-pages/data.db"
},
"devDependencies": {
"mocha": "^6.1.4",
"serve": "^11.1.0",
"standard": "^12.0.1"
"mocha": "^10.8.2",
"standard": "^17.1.2"
},
"dependencies": {
"@octokit/graphql": "^7.1.0",
Expand All @@ -53,7 +53,6 @@
"level": "^5.0.1",
"lit-element": "^2.2.1",
"nighthawk": "^2.3.0-1",
"node-fetch": "^2.6.0",
"pacote": "^20.0.0",
"regenerator-runtime": "^0.13.3",
"yargs": "^13.3.0"
Expand Down
2 changes: 1 addition & 1 deletion template/indicies.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = {

labels[label.name] = labels[label.name] || []
const d = {
label: label,
label,
issue: detail,
project
}
Expand Down
1 change: 1 addition & 0 deletions template/js/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Page extends LitElement {
config: { type: Object }
}
}

render () {
return html`
<link rel="stylesheet" href="${this.config.files.css.page}" />
Expand Down
1 change: 1 addition & 0 deletions template/js/project-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ProjectList extends LitElement {
projects: { type: Object }
}
}

render () {
return html`
<link rel="stylesheet" href="${this.config.files.css.projectList}" />
Expand Down

0 comments on commit e9a4ff7

Please sign in to comment.