import * as cache from '@actions/cache' ; import * as core from '@actions/core' ; import * as exec from '@actions/exec' ; import * as io from '@actions/io' ; import { BASE_BRANCH_DIR , BUILD_DIR , REPORT_DIR } from './const' ; param branch param baseCommit export async function prepareRepositoryForApiExtractor ( branch , baseCommit ) { core . startGroup ( 'Prepare branches for extractor' ) ; await exec . exec ( 'yarn' ) ; await io . mkdirP ( `${ REPORT_DIR }` ) ; await exec . exec ( 'npm' , [ 'i' , '-g' , '@microsoft/api-extractor@^7.12.0' ] ) ; await exec . exec ( 'sh' , [ './.github/api-extractor-action/prepare-repo-for-api-extractor.sh' , branch , BASE_BRANCH_DIR , baseCommit , ] ) ; const paths = [ BUILD_DIR ] ; const key = `dist-${ baseCommit }` ; const cacheKey = await cache . restoreCache ( paths , key , [ ] ) ; if ( cacheKey ) { await io . cp ( BUILD_DIR , `${ BASE_BRANCH_DIR }/${ BUILD_DIR }` , { recursive : true , force : false , } ) ; await io . rmRF ( BUILD_DIR ) ; } const BUILD_COMMAND = 'build:libs' ; await exec . exec ( 'yarn' ) ; await exec . exec ( 'yarn' , [ BUILD_COMMAND ] ) ; if ( ! cacheKey ) { await exec . exec ( 'yarn' , [ '--cwd' , BASE_BRANCH_DIR ] ) ; await exec . exec ( 'yarn' , [ '--cwd' , BASE_BRANCH_DIR , BUILD_COMMAND ] ) ; } core . endGroup ( ) ; }