ci/github-script/teams: use consistent style
These are style-only changes, that are not enforced via tooling - but used mostly consistently in the other github-script files.
This commit is contained in:
19
ci/github-script/get-teams.js
Executable file → Normal file
19
ci/github-script/get-teams.js
Executable file → Normal file
@@ -7,9 +7,13 @@ const excludeTeams = [
|
|||||||
module.exports = async ({ github, context, core, outFile }) => {
|
module.exports = async ({ github, context, core, outFile }) => {
|
||||||
const withRateLimit = require('./withRateLimit.js')
|
const withRateLimit = require('./withRateLimit.js')
|
||||||
const { writeFileSync } = require('node:fs')
|
const { writeFileSync } = require('node:fs')
|
||||||
|
|
||||||
|
const org = context.repo.owner
|
||||||
|
|
||||||
const result = {}
|
const result = {}
|
||||||
await withRateLimit({ github, core }, async (_stats) => {
|
|
||||||
/// Turn an Array of users into an Object, mapping user.login -> user.id
|
await withRateLimit({ github, core }, async () => {
|
||||||
|
// Turn an Array of users into an Object, mapping user.login -> user.id
|
||||||
function makeUserSet(users) {
|
function makeUserSet(users) {
|
||||||
// Sort in-place and build result by mutation
|
// Sort in-place and build result by mutation
|
||||||
users.sort((a, b) => (a.login > b.login ? 1 : -1))
|
users.sort((a, b) => (a.login > b.login ? 1 : -1))
|
||||||
@@ -20,21 +24,21 @@ module.exports = async ({ github, context, core, outFile }) => {
|
|||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process a list of teams and append to the result variable
|
// Process a list of teams and append to the result variable
|
||||||
async function processTeams(teams) {
|
async function processTeams(teams) {
|
||||||
for (const team of teams) {
|
for (const team of teams) {
|
||||||
core.notice(`Processing team ${team.slug}`)
|
core.notice(`Processing team ${team.slug}`)
|
||||||
if (!excludeTeams.some((regex) => team.slug.match(regex))) {
|
if (!excludeTeams.some((regex) => team.slug.match(regex))) {
|
||||||
const members = makeUserSet(
|
const members = makeUserSet(
|
||||||
await github.paginate(github.rest.teams.listMembersInOrg, {
|
await github.paginate(github.rest.teams.listMembersInOrg, {
|
||||||
org: context.repo.owner,
|
org,
|
||||||
team_slug: team.slug,
|
team_slug: team.slug,
|
||||||
role: 'member',
|
role: 'member',
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const maintainers = makeUserSet(
|
const maintainers = makeUserSet(
|
||||||
await github.paginate(github.rest.teams.listMembersInOrg, {
|
await github.paginate(github.rest.teams.listMembersInOrg, {
|
||||||
org: context.repo.owner,
|
org,
|
||||||
team_slug: team.slug,
|
team_slug: team.slug,
|
||||||
role: 'maintainer',
|
role: 'maintainer',
|
||||||
}),
|
}),
|
||||||
@@ -49,7 +53,7 @@ module.exports = async ({ github, context, core, outFile }) => {
|
|||||||
}
|
}
|
||||||
await processTeams(
|
await processTeams(
|
||||||
await github.paginate(github.rest.teams.listChildInOrg, {
|
await github.paginate(github.rest.teams.listChildInOrg, {
|
||||||
org: context.repo.owner,
|
org,
|
||||||
team_slug: team.slug,
|
team_slug: team.slug,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -57,8 +61,7 @@ module.exports = async ({ github, context, core, outFile }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const teams = await github.paginate(github.rest.repos.listTeams, {
|
const teams = await github.paginate(github.rest.repos.listTeams, {
|
||||||
owner: context.repo.owner,
|
...context.repo,
|
||||||
repo: context.repo.repo,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await processTeams(teams)
|
await processTeams(teams)
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ program
|
|||||||
.argument('[outFile]', 'Path to the output file (Example: github-teams.json). If not set, prints to stdout')
|
.argument('[outFile]', 'Path to the output file (Example: github-teams.json). If not set, prints to stdout')
|
||||||
.action(async (owner, repo, outFile, options) => {
|
.action(async (owner, repo, outFile, options) => {
|
||||||
const getTeams = (await import('./get-teams.js')).default
|
const getTeams = (await import('./get-teams.js')).default
|
||||||
// TODO: Refactor this file so we don't need to pass a PR
|
|
||||||
await run(getTeams, owner, repo, undefined, { ...options, outFile })
|
await run(getTeams, owner, repo, undefined, { ...options, outFile })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user