Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions create-node-meeting-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ const gitHubAgendaIssues = await github.getAgendaIssues(
);

// Step 10: Parse meeting agenda from GitHub issues
const meetingAgenda = meetings.generateMeetingAgenda(
gitHubAgendaIssues,
meetingConfig
);
const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);

// Step 11: Create HackMD document with meeting notes
const hackmdNote = await hackmd.createMeetingNotesDocument(
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ export const HACKMD_DEFAULT_PERMISSIONS = {
writePermission: 'signed_in',
commentPermission: 'signed_in_users',
};

export const REPOSITORY_URL_PREFIX_LENGTH = 'https://api.github.com/repos/'
.length;
36 changes: 13 additions & 23 deletions src/github.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Octokit } from '@octokit/rest';

import { DEFAULT_CONFIG } from './constants.mjs';
import { DEFAULT_CONFIG, REPOSITORY_URL_PREFIX_LENGTH } from './constants.mjs';

/**
* Creates a GitHub API client
Expand Down Expand Up @@ -47,36 +47,26 @@ export const createGitHubIssue = async (
* @param {import('@octokit/rest').Octokit} githubClient - Authenticated GitHub API client
* @param {import('./types.d.ts').AppConfig} config - Application configuration
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration
* @returns {Promise<{ repoName: string, issues: Array<GitHubIssue> }> } Formatted markdown string of issues
* @returns {Promise<{ [key: string]: Array<GitHubIssue> }>} Formatted markdown string of issues
*/
export const getAgendaIssues = async (
{ paginate, rest },
githubClient,
{ meetingGroup },
{ properties }
) => {
const githubOrg = properties.USER ?? DEFAULT_CONFIG.githubOrg;
const agendaTag = properties.AGENDA_TAG ?? `${meetingGroup}-agenda`;

// Get all public repositories in the organization
const repos = await paginate(rest.repos.listForOrg, {
org: githubOrg,
type: 'public',
per_page: 100,
// Get all issues/PRs in the organization
const issues = await githubClient.paginate('GET /search/issues', {
q: `label:${agendaTag} org:${githubOrg}`,
advanced_search: true,
});

// Fetch issues and PRs from all repositories concurrently
const issuePromises = repos.map(async repo => {
const items = await paginate(rest.issues.listForRepo, {
owner: githubOrg,
repo: repo.name,
labels: agendaTag,
state: 'open',
per_page: 100,
});

// Include both issues and PRs for agenda items
return { repoName: repo.name, issues: items };
});

return Promise.all(issuePromises);
return issues.reduce((obj, issue) => {
(obj[issue.repository_url.slice(REPOSITORY_URL_PREFIX_LENGTH)] ||= []).push(
issue
);
return obj;
}, {});
};
13 changes: 4 additions & 9 deletions src/meeting.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,16 @@ export const generateMeetingTitle = (config, meetingConfig, meetingDate) => {

/**
* Generates the meeting agenda from the list of agenda issues
* @param {Array<{ repoName: string, issues: Array<GitHubIssue> }>} agendaIssues - List of agenda issues
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration
* @param {Array<{ [key: string]: Array<GitHubIssue> }>} agendaIssues - List of agenda issues
* @returns {Promise<string>} Formatted meeting agenda
*/
export const generateMeetingAgenda = (agendaIssues, meetingConfig) => {
const props = meetingConfig.properties;

const githubOrg = props.USER ?? DEFAULT_CONFIG.githubOrg;

export const generateMeetingAgenda = agendaIssues => {
// Format issues as markdown
let agendaMarkdown = '';

agendaIssues.forEach(({ repoName, issues }) => {
Object.entries(agendaIssues).forEach(([repoName, issues]) => {
if (issues.length > 0) {
agendaMarkdown += `### ${githubOrg}/${repoName}\n\n`;
agendaMarkdown += `### ${repoName}\n\n`;

issues.forEach(issue => {
// Escape markdown characters in title
Expand Down
Loading