Skip to content

Commit 98294a7

Browse files
committed
feat(cli): add support for dry-run, verbose
1 parent 1cfb390 commit 98294a7

File tree

9 files changed

+80
-141
lines changed

9 files changed

+80
-141
lines changed

.github/workflows/create-meeting-artifacts-manual.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ on:
3131
- uvwasi
3232
- userfeedback
3333
- web-server-frameworks
34+
dry_run:
35+
type: boolean
36+
description: 'Dry run?'
37+
default: false
38+
required: true
3439

3540
jobs:
3641
create-artifacts:
@@ -68,7 +73,7 @@ jobs:
6873
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
6974
HACKMD_API_TOKEN: ${{ secrets.HACKMD_API_TOKEN }}
7075
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
71-
run: node create-node-meeting-artifacts.mjs ${{ github.event.inputs.meeting_group }}
76+
run: node create-node-meeting-artifacts.mjs ${{ github.event.inputs.meeting_group }} --verbose ${{ github.event.inputs.dry_run && '--dry-run' }}
7277

7378
- name: Upload artifacts
7479
if: always()

.github/workflows/create-meeting-artifacts-scheduled.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
6969
HACKMD_API_TOKEN: ${{ secrets.HACKMD_API_TOKEN }}
7070
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
71-
run: node create-node-meeting-artifacts.mjs ${{ matrix.meeting_group }}
71+
run: node create-node-meeting-artifacts.mjs ${{ matrix.meeting_group }} --verbose
7272

7373
- name: Upload artifacts
7474
if: always()

create-node-meeting-artifacts.mjs

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,28 @@
99
* npm run dev -- tsc
1010
*/
1111

12-
import { getConfig } from './src/config.mjs';
12+
import { Command } from 'commander';
13+
14+
import environmentConfig from './src/config.mjs';
1315
import * as github from './src/github.mjs';
1416
import * as google from './src/google.mjs';
1517
import * as hackmd from './src/hackmd.mjs';
1618
import * as meetings from './src/meeting.mjs';
1719

20+
const program = new Command();
21+
program
22+
.argument('<group>', 'Meeting group')
23+
.option('--dry-run', 'Show output without creating/updating anything', false)
24+
.option('--verbose', 'Show debug output')
25+
.parse(process.argv);
26+
1827
// Step 1: Application configuration
19-
const config = getConfig();
28+
/** @type {import('./src/types').AppConfig} */
29+
const config = {
30+
...environmentConfig,
31+
...program.opts(),
32+
meetingGroup: program.args[0],
33+
};
2034

2135
// Step 2: Initialize Google Calendar client with API Key
2236
const calendarClient = google.createCalendarClient(config.google);
@@ -28,7 +42,8 @@ const githubClient = github.createGitHubClient(config);
2842
const meetingConfig = await meetings.readMeetingConfig(config);
2943

3044
// Step 5: Initialize HackMD client with meeting configuration
31-
const hackmdClient = hackmd.createHackMDClient(config, meetingConfig);
45+
const hackmdClient =
46+
config.dryRun || hackmd.createHackMDClient(config, meetingConfig);
3247

3348
// Step 6: Find next meeting event in calendar
3449
const event = await google.findNextMeetingEvent(calendarClient, meetingConfig);
@@ -54,11 +69,9 @@ const gitHubAgendaIssues = await github.getAgendaIssues(
5469
const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);
5570

5671
// Step 11: Create HackMD document with meeting notes and tags
57-
const hackmdNote = await hackmd.createMeetingNotesDocument(
58-
hackmdClient,
59-
meetingTitle,
60-
''
61-
);
72+
const hackmdNote = config.dryRun
73+
? {}
74+
: await hackmd.createMeetingNotesDocument(hackmdClient, meetingTitle, '');
6275

6376
// Step 12: Get the HackMD document link
6477
const minutesDocLink =
@@ -74,12 +87,14 @@ const issueContent = await meetings.generateMeetingIssue(
7487
);
7588

7689
// Step 14: Create GitHub issue with HackMD link
77-
const githubIssue = await github.createGitHubIssue(
78-
githubClient,
79-
meetingConfig,
80-
meetingTitle,
81-
issueContent
82-
);
90+
const githubIssue = config.dryRun
91+
? {}
92+
: await github.createGitHubIssue(
93+
githubClient,
94+
meetingConfig,
95+
meetingTitle,
96+
issueContent
97+
);
8398

8499
// Step 15: Update the minutes content with the HackMD link
85100
const minutesContent = await meetings.generateMeetingMinutes(
@@ -91,13 +106,19 @@ const minutesContent = await meetings.generateMeetingMinutes(
91106
githubIssue.html_url
92107
);
93108

94-
// Step 16: Update the HackMD document with the self-referencing link
95-
await hackmd.updateMeetingNotesDocument(
96-
hackmdClient,
97-
hackmdNote.id,
98-
minutesContent
99-
);
100-
101-
// Output success information with links
102-
console.log(`Created GitHub issue: ${githubIssue.html_url}`);
103-
console.log(`Created HackMD document: ${minutesDocLink}`);
109+
if (config.dryRun) {
110+
console.log('Would create GitHub issue with the following content:');
111+
console.log(issueContent);
112+
console.log('Would create HackMD note with the following content:');
113+
console.log(minutesContent);
114+
} else {
115+
// Step 16: Update the HackMD document with the self-referencing link
116+
await hackmd.updateMeetingNotesDocument(
117+
hackmdClient,
118+
hackmdNote.id,
119+
minutesContent
120+
);
121+
122+
console.log(`Created GitHub issue: ${githubIssue.html_url}`);
123+
console.log(`Created HackMD document: ${minutesDocLink}`);
124+
}

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@googleapis/calendar": "^11.0.1",
1515
"@hackmd/api": "^2.5.0",
1616
"@octokit/rest": "^22.0.0",
17+
"commander": "^14.0.1",
1718
"dedent": "^1.6.0",
1819
"dotenv": "^17.2.2"
1920
},

src/config.mjs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ import { join, dirname } from 'node:path';
44
const defaultMeetingsDirectory = join(homedir(), '.make-node-meeting');
55

66
/**
7-
* Gets the application configuration from environment variables and arguments
8-
* @returns {import('./types.d.ts').AppConfig} Application configuration object
7+
* @type {import('./types.d.ts').EnvironmentConfig} Environment configuration object
98
*/
10-
export const getConfig = () => ({
11-
// Meeting group from command line argument, defaults to 'tsc'
12-
meetingGroup: process.argv[2],
13-
9+
export default {
1410
// GitHub personal access token from environment
1511
githubToken: process.env.GITHUB_TOKEN,
1612

@@ -32,4 +28,4 @@ export const getConfig = () => ({
3228
output: process.env.MEETINGS_OUTPUT_DIR || defaultMeetingsDirectory,
3329
templates: join(dirname(import.meta.dirname), 'templates'),
3430
},
35-
});
31+
};

src/github.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { DEFAULT_CONFIG } from './constants.mjs';
77
* @param {import('./types.d.ts').AppConfig} config - Application configuration
88
* @returns {import('@octokit/rest').Octokit} Configured GitHub API client
99
*/
10-
export const createGitHubClient = ({ githubToken: auth }) =>
11-
new Octokit({ auth });
10+
export const createGitHubClient = ({ githubToken: auth, verbose }) =>
11+
new Octokit({ auth, log: verbose ? console : undefined });
1212

1313
/**
1414
* Creates GitHub issue with meeting information and Google Doc link

src/types.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/**
22
* Application configuration object
33
*/
4-
export interface AppConfig {
5-
/** Meeting group from command line argument */
6-
meetingGroup: string;
4+
export interface EnvironmentConfig {
75
/** GitHub personal access token */
86
githubToken: string;
97
/** Google API configuration (Calendar only) */
@@ -14,6 +12,17 @@ export interface AppConfig {
1412
directories: DirectoryConfig;
1513
}
1614

15+
/**
16+
* CLI configuration object
17+
*/
18+
export interface CLIConfig {
19+
verbose: boolean;
20+
dryRun: boolean;
21+
meetingGroup: string;
22+
}
23+
24+
export type AppConfig = EnvironmentConfig & CLIConfig;
25+
1726
/**
1827
* Google authentication configuration (Calendar only)
1928
*/

test/config.test.mjs

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)