Replace use of typed-rest-client with @actions/http-client (#634)

Fixes #630
This commit is contained in:
Daz DeBoer
2025-05-05 13:44:42 -06:00
committed by GitHub
parent 95dcf96b0d
commit 2ad385cb2a
4 changed files with 22 additions and 65 deletions

View File

@@ -1,5 +1,5 @@
import * as httpm from 'typed-rest-client/HttpClient'
import * as core from '@actions/core'
import * as httpm from '@actions/http-client'
import {BuildScanConfig} from '../configuration'
import {recordDeprecation} from '../deprecation-collector'

View File

@@ -1,6 +1,6 @@
import * as httpm from 'typed-rest-client/HttpClient'
import * as cheerio from 'cheerio'
import * as core from '@actions/core'
import * as httpm from '@actions/http-client'
import fileWrapperChecksums from './wrapper-checksums.json'
@@ -69,8 +69,20 @@ async function httpGetJsonArray(url: string): Promise<unknown[]> {
}
async function httpGetText(url: string): Promise<string> {
const response = await httpc.get(url)
return await response.readBody()
const maxAttempts = 4
let attempts = 0
while (attempts < maxAttempts) {
try {
const response = await httpc.get(url)
return await response.readBody()
} catch (error) {
attempts++
if (attempts === maxAttempts) {
return new Promise((_resolve, reject) => reject(error))
}
}
}
return new Promise((_resolve, reject) => reject(new Error('Illegal state')))
}
async function addDistributionSnapshotChecksumUrls(checksumUrls: [string, string][]): Promise<void> {