-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathcreate-node-meeting-artifacts.mjs
More file actions
163 lines (134 loc) · 4.44 KB
/
create-node-meeting-artifacts.mjs
File metadata and controls
163 lines (134 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env node
/**
* Node.js Meeting Artifacts Creator
*
* Usage:
* node create-node-meeting-artifacts.mjs [meetingGroup]
* npm run tsc-meeting
* npm run dev -- tsc
*/
import { Command } from 'commander';
import * as calendar from './src/calendar.mjs';
import environmentConfig from './src/config.mjs';
import * as github from './src/github.mjs';
import * as hackmd from './src/hackmd.mjs';
import * as meetings from './src/meeting.mjs';
const program = new Command();
program
.argument('<group>', 'Meeting group')
.option('--dry-run', 'Show output without creating/updating anything', false)
.option('--force', 'Create a new issue even if one already exists', false)
.option('--verbose', 'Show debug output')
.parse(process.argv);
// Step 1: Application configuration
process.env.TZ = 'UTC';
/** @type {import('./src/types').AppConfig} */
const config = {
...environmentConfig,
...program.opts(),
meetingGroup: program.args[0],
};
console.log('Application config loaded', config);
// Step 3: Initialize GitHub client
const githubClient = github.createGitHubClient(config);
// Step 4: Read meeting configuration from templates
const meetingConfig = await meetings.readMeetingConfig(config);
console.debug('Meeting config loaded', meetingConfig);
// Step 5: Initialize HackMD client with meeting configuration
const hackmdClient = hackmd.createHackMDClient(config, meetingConfig);
if (config.dryRun) {
const gitHubAgendaIssues = await github.getAgendaIssues(
githubClient,
config,
meetingConfig
);
console.debug('Found agenda issues', gitHubAgendaIssues);
const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);
const issueContent = await meetings.generateMeetingIssue(
config,
meetingConfig,
new Date(),
meetingAgenda,
''
);
console.log(issueContent);
process.exit(0);
}
// Step 6: Find next meeting event in calendar
const events = await calendar.getEventsFromCalendar(
meetingConfig.properties.ICAL_URL
);
console.debug('Loaded calendar', events);
const meetingDate = await calendar.findNextMeetingDate(events, meetingConfig);
console.debug('Next meeting date', meetingDate);
// If no meeting is found, exit gracefully
if (!meetingDate) {
const [weekStart, weekEnd] = calendar.getNextWeek();
console.log(
`No meeting found for ${meetingConfig.properties.GROUP_NAME || 'this group'} ` +
`in the next week (${weekStart.toISOString().split('T')[0]} to ${weekEnd.toISOString().split('T')[0]}). ` +
`This is expected for bi-weekly meetings or meetings that don't occur every week.`
);
process.exit(0);
}
// Step 8: Get Meeting Title
const meetingTitle = meetings.generateMeetingTitle(
config,
meetingConfig,
meetingDate
);
console.debug('Meeting title', meetingTitle);
// Step 9: Get agenda information using native implementation
const gitHubAgendaIssues = await github.getAgendaIssues(
githubClient,
config,
meetingConfig
);
console.debug('Found agenda issues', gitHubAgendaIssues);
// Step 10: Parse meeting agenda from GitHub issues
const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);
// Step 11: Create HackMD document with meeting notes and tags
const hackmdNote = await hackmd.getOrCreateMeetingNotesDocument(
hackmdClient,
meetingTitle,
config
);
console.debug('HackMD document created/retrieved:', hackmdNote);
// Step 12: Get the HackMD document link
const minutesDocLink =
hackmdNote.publishLink || `https://hackmd.io/${hackmdNote.id}`;
// Step 13: Generate meeting issue content using native implementation
const issueContent = await meetings.generateMeetingIssue(
config,
meetingConfig,
meetingDate,
meetingAgenda,
minutesDocLink
);
// Step 14: Create GitHub issue with HackMD link
const githubIssue = await github.createOrUpdateGitHubIssue(
githubClient,
config,
meetingConfig,
meetingTitle,
issueContent
);
console.debug('GitHub issue created/updated', githubIssue);
// Step 15: Update the minutes content with the HackMD link
const minutesContent = await meetings.generateMeetingMinutes(
config,
meetingConfig,
meetingTitle,
meetingAgenda,
minutesDocLink,
githubIssue.html_url
);
// Step 16: Update the HackMD document with the self-referencing link
await hackmd.updateMeetingNotesDocument(
hackmdClient,
hackmdNote.id,
minutesContent
);
// Output success information with links
console.log(`Created GitHub issue: ${githubIssue.html_url}`);
console.log(`Created HackMD document: ${minutesDocLink}`);