mirrorurl code

This commit is contained in:
Aparna Jyothi 2025-01-29 18:41:57 +05:30
parent 802632921f
commit 0b66095a84
6 changed files with 210 additions and 62 deletions

View file

@ -25,6 +25,7 @@ export default abstract class BaseDistribution {
}
protected abstract getDistributionUrl(): string;
public async setupNodeJs() {
let nodeJsVersions: INodeVersion[] | undefined;
@ -128,6 +129,31 @@ export default abstract class BaseDistribution {
};
}
protected getNodejsMirrorURLInfo(version: string) {
const mirrorURL = this.nodeInfo.mirrorURL;
const osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
version = semver.clean(version) || '';
const fileName: string =
this.osPlat == 'win32'
? `node-v${version}-win-${osArch}`
: `node-v${version}-${this.osPlat}-${osArch}`;
const urlFileName: string =
this.osPlat == 'win32'
? this.nodeInfo.arch === 'arm64'
? `${fileName}.zip`
: `${fileName}.7z`
: `${fileName}.tar.gz`;
const url = `${mirrorURL}/v${version}/${urlFileName}`;
return <INodeVersionInfo>{
downloadUrl: url,
resolvedVersion: version,
arch: osArch,
fileName: fileName
};
}
protected async downloadNodejs(info: INodeVersionInfo) {
let downloadPath = '';
core.info(