Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
7 changes: 6 additions & 1 deletion .github/workflows/create-meeting-artifacts-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ on:
- uvwasi
- userfeedback
- web-server-frameworks
dry_run:
type: boolean
description: 'Dry run?'
default: false
required: true

jobs:
create-artifacts:
Expand Down Expand Up @@ -68,7 +73,7 @@ jobs:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
HACKMD_API_TOKEN: ${{ secrets.HACKMD_API_TOKEN }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: node create-node-meeting-artifacts.mjs ${{ github.event.inputs.meeting_group }}
run: node create-node-meeting-artifacts.mjs ${{ github.event.inputs.meeting_group }} --verbose ${{ github.event.inputs.dry_run == 'true' && '--dry-run' || '' }}

- name: Upload artifacts
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-meeting-artifacts-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
HACKMD_API_TOKEN: ${{ secrets.HACKMD_API_TOKEN }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: node create-node-meeting-artifacts.mjs ${{ matrix.meeting_group }}
run: node create-node-meeting-artifacts.mjs ${{ matrix.meeting_group }} --verbose

- name: Upload artifacts
if: always()
Expand Down
42 changes: 40 additions & 2 deletions create-node-meeting-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,28 @@
* npm run dev -- tsc
*/

import { getConfig } from './src/config.mjs';
import { Command } from 'commander';

import environmentConfig from './src/config.mjs';
import * as github from './src/github.mjs';
import * as google from './src/google.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('--verbose', 'Show debug output')
.parse(process.argv);

// Step 1: Application configuration
const config = getConfig();
/** @type {import('./src/types').AppConfig} */
const config = {
...environmentConfig,
...program.opts(),
meetingGroup: program.args[0],
};

// Step 2: Initialize Google Calendar client with API Key
const calendarClient = google.createCalendarClient(config.google);
Expand All @@ -30,6 +44,30 @@ const meetingConfig = await meetings.readMeetingConfig(config);
// Step 5: Initialize HackMD client with meeting configuration
const hackmdClient = hackmd.createHackMDClient(config, meetingConfig);

if (config.dryRun) {
const meetingDate = new Date();

const gitHubAgendaIssues = await github.getAgendaIssues(
githubClient,
config,
meetingConfig
);

const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);

const issueContent = await meetings.generateMeetingIssue(
config,
meetingConfig,
meetingDate,
meetingAgenda,
''
);

console.log(issueContent);

process.exit(0);
}

// Step 6: Find next meeting event in calendar
const event = await google.findNextMeetingEvent(calendarClient, meetingConfig);

Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@googleapis/calendar": "^11.0.1",
"@hackmd/api": "^2.5.0",
"@octokit/rest": "^22.0.0",
"commander": "^14.0.1",
"dedent": "^1.6.0",
"dotenv": "^17.2.2"
},
Expand Down
10 changes: 3 additions & 7 deletions src/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import { join, dirname } from 'node:path';
const defaultMeetingsDirectory = join(homedir(), '.make-node-meeting');

/**
* Gets the application configuration from environment variables and arguments
* @returns {import('./types.d.ts').AppConfig} Application configuration object
* @type {import('./types.d.ts').AppConfig} Environment configuration object
*/
export const getConfig = () => ({
// Meeting group from command line argument, defaults to 'tsc'
meetingGroup: process.argv[2],

export default {
// GitHub personal access token from environment
githubToken: process.env.GITHUB_TOKEN,

Expand All @@ -32,4 +28,4 @@ export const getConfig = () => ({
output: process.env.MEETINGS_OUTPUT_DIR || defaultMeetingsDirectory,
templates: join(dirname(import.meta.dirname), 'templates'),
},
});
};
4 changes: 2 additions & 2 deletions src/github.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { DEFAULT_CONFIG } from './constants.mjs';
* @param {import('./types.d.ts').AppConfig} config - Application configuration
* @returns {import('@octokit/rest').Octokit} Configured GitHub API client
*/
export const createGitHubClient = ({ githubToken: auth }) =>
new Octokit({ auth });
export const createGitHubClient = ({ githubToken: auth, verbose }) =>
new Octokit({ auth, log: verbose ? console : undefined });

/**
* Creates GitHub issue with meeting information and Google Doc link
Expand Down
15 changes: 12 additions & 3 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
* Application configuration object
*/
export interface AppConfig {
/** Meeting group from command line argument */
meetingGroup: string;
export interface EnvironmentConfig {
/** GitHub personal access token */
githubToken: string;
/** Google API configuration (Calendar only) */
Expand All @@ -14,6 +12,17 @@ export interface AppConfig {
directories: DirectoryConfig;
}

/**
* CLI configuration object
*/
export interface CLIConfig {
verbose: boolean;
dryRun: boolean;
meetingGroup: string;
}

export type AppConfig = EnvironmentConfig & CLIConfig;

/**
* Google authentication configuration (Calendar only)
*/
Expand Down
103 changes: 0 additions & 103 deletions test/config.test.mjs

This file was deleted.

Loading