import { logger } from '../../logger' ; import { Http } from '../../util/http' ; import type { UpdateArtifact , UpdateArtifactsResult } from '../types' ; const http = new Http ( 'batect-wrapper' ) ; async function updateArtifact ( path , fileName , version ) { const url = `https://github.com/batect/batect/releases/download/${ version }/${ fileName }` ; try { const response = await http . get ( url ) ; const contents = response . body ; return { file : { name : path , contents , } , } ; } catch ( err ) { const errorDescription = err . toString ( ) ; return { artifactError : { lockFile : path , stderr : `HTTP GET ${ url } failed: ${ errorDescription }` , } , } ; } } export async function updateArtifacts ( { packageFileName , config , } ) { const version = config . newVersion ; logger . debug ( { version , packageFileName } , 'Updating Batect wrapper scripts' ) ; return [ await updateArtifact ( packageFileName , 'batect' , version ) , await updateArtifact ( `${ packageFileName }.cmd` , 'batect.cmd' , version ) , ] ; }