Skip to content

Commit

Permalink
feat: add config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhenry committed Jan 31, 2024
1 parent 64f3968 commit 84b1193
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
organization: "WorldHealthOrganization"
4 changes: 2 additions & 2 deletions ts-backend/package-lock.json

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

3 changes: 2 additions & 1 deletion ts-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@octokit/rest": "^20.0.2",
"dotenv": "^16.4.1",
"fs-extra": "^11.2.0",
"octokit": "^3.1.2"
"octokit": "^3.1.2",
"yaml": "^2.3.4"
}
}
21 changes: 19 additions & 2 deletions ts-backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import "dotenv/config";
import fs from "fs-extra";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
import { parse } from "yaml";
import {
addDiscussionData,
addIssueAndPrData,
Expand Down Expand Up @@ -89,15 +92,29 @@ console.log("🔑 Authenticating with GitHub");
const octokit = personalOctokit(process.env.GRAPHQL_TOKEN!);

// Read in configuration for the fetchers
// TODO: Figure this out
let yamlConfig: Partial<Config> = {};
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const configFileLocation = resolve(__dirname, "../../config.yml");
try {
const configFile = fs.readFileSync(configFileLocation, "utf-8");
yamlConfig = parse(configFile) as Partial<Config>;
} catch (e) {
console.error("Error reading config file at", configFileLocation);
console.log(e);
}

const config: Config = {
organization: "sbv-world-health-org-metrics",
organization: "github",
includeForks: false,
includeArchived: false,
// Default since date is 180 days ago
since: new Date(Date.now() - 180 * (24 * 60 * 60 * 1000)).toISOString(),
...yamlConfig,
};

console.log(`📋 Configuration: \n${JSON.stringify(config, null, 2)}`);

const pipeline =
(octokit: CustomOctokit, config: Config) =>
async (...fetchers: Fetcher[]) => {
Expand Down

0 comments on commit 84b1193

Please sign in to comment.