import * as github from '@actions/github' ; import { Octokit } from '@octokit/rest' ; import * as inversify from 'inversify' ; import { iocTypes , setupSharedIocContainer } from '@accessibility-insights-action/shared' ; import { GHTaskConfig } from '../task-config/gh-task-config' ; import { GitHubIocTypes } from './gh-ioc-types' ; import { PullRequestCommentCreator } from '../pull-request/pull-request-comment-creator' ; import { CheckRunCreator } from '../check-run/check-run-creator' ; import { GitHubArtifactsInfoProvider } from '../gh-artifacts-info-provider' ; export function setupIocContainer ( container = new inversify . Container ( { autoBindInjectable : true } ) ) { container = setupSharedIocContainer ( container ) ; container . bind ( GitHubIocTypes . Github ) . toConstantValue ( github ) ; container . bind ( iocTypes . TaskConfig ) . to ( GHTaskConfig ) . inSingletonScope ( ) ; container . bind ( CheckRunCreator ) . toSelf ( ) . inSingletonScope ( ) ; container . bind ( PullRequestCommentCreator ) . toSelf ( ) . inSingletonScope ( ) ; container . bind ( iocTypes . ProgressReporters ) . toDynamicValue ( ( context ) => { const pullRequestCommentCreator = context . container . get ( PullRequestCommentCreator ) ; const checkRunCreator = context . container . get ( CheckRunCreator ) ; return [ checkRunCreator , pullRequestCommentCreator ] ; } ) . inSingletonScope ( ) ; container . bind ( Octokit ) . toDynamicValue ( ( context ) => { const taskConfig = context . container . get ( GHTaskConfig ) ; return new Octokit ( { auth : taskConfig . getToken ( ) } ) ; } ) . inSingletonScope ( ) ; container . bind ( iocTypes . ArtifactsInfoProvider ) . to ( GitHubArtifactsInfoProvider ) . inSingletonScope ( ) ; return container ; }