-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
60 lines (45 loc) · 1.52 KB
/
index.ts
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
import { GithubAPIClient } from './src/githubAPIClient'
import { GithubGraphQLPageAssembler } from './src/githubGraphQLPageAssembler'
import { Logger } from './src/logger'
import { readFile } from 'node:fs/promises'
import ConfigValidator from './src/validateConfig'
import Labeler from './src/labeler'
async function loadConfig (): Promise<string> {
const configContents = await readFile('./config.json')
return '' + configContents
}
async function main () {
const logger = new Logger()
let configFileContents
try {
logger.info('Loading Config')
configFileContents = await loadConfig()
} catch (error) {
logger.error('Failed to load config', 2)
logger.tryErrorLogErrorObject(error, 4)
process.exitCode = 1
return
}
const configValidator = new ConfigValidator(logger)
const config = configValidator.validateConfig(configFileContents)
if (config === null) {
process.exitCode = 1
return
}
let githubAPIClient
let githubGraphQLPageAssembler
try {
logger.info('Initializing github API objects')
githubAPIClient = new GithubAPIClient(config.accessToken, config.repo.name, config.repo.ownerName)
githubGraphQLPageAssembler = new GithubGraphQLPageAssembler(githubAPIClient)
} catch (error) {
logger.error('Failed to initialize github API objects', 2)
logger.tryErrorLogErrorObject(error, 4)
process.exitCode = 1
return
}
logger.info('Initialized github API client')
const labeler = new Labeler(githubAPIClient, logger)
labeler.labelIssues()
}
main()