Skip to content

Commit 53e3722

Browse files
authored
feat(cli): add support for dry-run, verbose (#193)
1 parent 1cfb390 commit 53e3722

File tree

9 files changed

+74
-119
lines changed

9 files changed

+74
-119
lines changed

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

Lines changed: 7 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,8 @@ 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+
ADDITIONAL_ARGS: ${{ github.event.inputs.dry_run == 'true' && '--dry-run' || '' }}
77+
run: node create-node-meeting-artifacts.mjs ${{ github.event.inputs.meeting_group }} --verbose $ADDITIONAL_ARGS
7278

7379
- name: Upload artifacts
7480
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: 38 additions & 2 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);
@@ -30,6 +44,28 @@ const meetingConfig = await meetings.readMeetingConfig(config);
3044
// Step 5: Initialize HackMD client with meeting configuration
3145
const hackmdClient = hackmd.createHackMDClient(config, meetingConfig);
3246

47+
if (config.dryRun) {
48+
const gitHubAgendaIssues = await github.getAgendaIssues(
49+
githubClient,
50+
config,
51+
meetingConfig
52+
);
53+
54+
const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);
55+
56+
const issueContent = await meetings.generateMeetingIssue(
57+
config,
58+
meetingConfig,
59+
new Date(),
60+
meetingAgenda,
61+
''
62+
);
63+
64+
console.log(issueContent);
65+
66+
process.exit(0);
67+
}
68+
3369
// Step 6: Find next meeting event in calendar
3470
const event = await google.findNextMeetingEvent(calendarClient, meetingConfig);
3571

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').AppConfig} 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)