import * as actionCore from '@actions/core' ; import { inject , injectable } from 'inversify' ; import { isEmpty } from 'lodash' ; import * as process from 'process' ; import { iocTypes , TaskConfig } from '@accessibility-insights-action/shared' ; import normalizePath from 'normalize-path' ; import { resolve } from 'path' ; @ injectable ( ) export class GHTaskConfig extends TaskConfig { constructor ( @ inject ( iocTypes . Process ) protected readonly processObj , private readonly actionCoreObj = actionCore , private readonly resolvePath = resolve ) { super ( processObj ) ; } public getReportOutDir ( ) { return this . getAbsolutePath ( this . actionCoreObj . getInput ( 'output-dir' ) ) ; } public getSiteDir ( ) { return this . actionCoreObj . getInput ( 'site-dir' ) ; } public getScanUrlRelativePath ( ) { return this . actionCoreObj . getInput ( 'scan-url-relative-path' ) ; } public getToken ( ) { return this . actionCoreObj . getInput ( 'repo-token' ) ; } public getChromePath ( ) { let chromePath ; chromePath = this . getAbsolutePath ( this . actionCoreObj . getInput ( 'chrome-path' ) ) ; if ( isEmpty ( chromePath ) ) { chromePath = this . processObj . env . CHROME_BIN ; } return chromePath ; } public getUrl ( ) { return this . actionCoreObj . getInput ( 'url' ) ; } public getMaxUrls ( ) { return parseInt ( this . actionCoreObj . getInput ( 'max-urls' ) ) ; } public getDiscoveryPatterns ( ) { const value = this . actionCoreObj . getInput ( 'discovery-patterns' ) ; return isEmpty ( value ) ? undefined : value ; } public getInputFile ( ) { return this . getAbsolutePath ( this . actionCoreObj . getInput ( 'input-file' ) ) ; } public getInputUrls ( ) { const value = this . actionCoreObj . getInput ( 'input-urls' ) ; return isEmpty ( value ) ? undefined : value ; } public getScanTimeout ( ) { return parseInt ( this . actionCoreObj . getInput ( 'scan-timeout' ) ) ; } public getLocalhostPort ( ) { const value = this . actionCoreObj . getInput ( 'localhost-port' ) ; return isEmpty ( value ) ? undefined : parseInt ( value , 10 ) ; } public getRunId ( ) { return parseInt ( this . processObj . env . GITHUB_RUN_ID , 10 ) ; } public getSingleWorker ( ) { const value = this . actionCoreObj . getInput ( 'single-worker' ) ; return isEmpty ( value ) || value . toLowerCase ( ) . trim ( ) !== 'false' ? true : false ; } public getBaselineFile ( ) { const value = this . getAbsolutePath ( this . actionCoreObj . getInput ( 'baseline-file' ) ) ; return isEmpty ( value ) ? undefined : value ; } private getAbsolutePath ( path ) { if ( isEmpty ( path ) ) { return undefined ; } const dirname = this . processObj . env . GITHUB_WORKSPACE ?? __dirname ; return normalizePath ( this . resolvePath ( dirname , normalizePath ( path ) ) ) ; } }