update mirrorURL versions

This commit is contained in:
Aparna Jyothi
2025-01-31 11:11:24 +05:30
parent 50efbd2a86
commit 91a5e5da06
8 changed files with 304 additions and 147 deletions

View File

@@ -25,7 +25,7 @@ export default abstract class BaseDistribution {
}
protected abstract getDistributionUrl(): string;
protected abstract getDistributionMirrorUrl(): string;
public async setupNodeJs() {
let nodeJsVersions: INodeVersion[] | undefined;
@@ -105,6 +105,14 @@ export default abstract class BaseDistribution {
return response.result || [];
}
protected async getMirrorUrVersions(): Promise<INodeVersion[]> {
const initialUrl = this.getDistributionMirrorUrl();
const dataUrl = `${initialUrl}/index.json`;
const response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
return response.result || [];
}
protected getNodejsDistInfo(version: string) {
const osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
version = semver.clean(version) || '';
@@ -118,7 +126,7 @@ export default abstract class BaseDistribution {
? `${fileName}.zip`
: `${fileName}.7z`
: `${fileName}.tar.gz`;
const initialUrl = this.getDistributionUrl();
const initialUrl = this.getDistributionMirrorUrl();
const url = `${initialUrl}/v${version}/${urlFileName}`;
return <INodeVersionInfo>{
@@ -143,7 +151,7 @@ export default abstract class BaseDistribution {
? `${fileName}.zip`
: `${fileName}.7z`
: `${fileName}.tar.gz`;
const url = `${mirrorURL}/v${version}/${urlFileName}`;
return <INodeVersionInfo>{
@@ -173,7 +181,9 @@ export default abstract class BaseDistribution {
info.downloadUrl
);
}
core.error(`Download failed from ${info.downloadUrl}. Please check the URl and try again.`);
core.error(
`Download failed from ${info.downloadUrl}. Please check the URl and try again.`
);
throw err;
}
@@ -195,7 +205,7 @@ export default abstract class BaseDistribution {
protected async acquireWindowsNodeFromFallbackLocation(
version: string,
arch: string = os.arch(),
downloadUrl : string
downloadUrl: string
): Promise<string> {
const initialUrl = this.getDistributionUrl();
core.info('url: ' + initialUrl);
@@ -214,8 +224,12 @@ export default abstract class BaseDistribution {
libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`;
core.info(`Downloading only node binary from ${exeUrl}`);
if(downloadUrl != exeUrl ){core.error('unable to download node binary with the provided URL. Please check and try again');}
if (downloadUrl != exeUrl) {
core.error(
'unable to download node binary with the provided URL. Please check and try again'
);
}
const exePath = await tc.downloadTool(exeUrl);
await io.cp(exePath, path.join(tempDir, 'node.exe'));