Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mirror-url parameter to allow downloading Node.js from a custom URL #1211

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
prints
  • Loading branch information
aparnajyothi-y committed Jan 31, 2025
commit 7188cb1e620cbe9837e18010e2783d927b1b1f77
9 changes: 9 additions & 0 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
@@ -100184,7 +100184,9 @@ class BaseDistribution {
}
getNodejsMirrorURLInfo(version) {
const mirrorURL = this.nodeInfo.mirrorURL;
core.info('mirrorURL from getNodejsMirrorURLInfo ' + mirrorURL);
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
core.info('osArch from translateArchToDistUrl ' + osArch);
version = semver_1.default.clean(version) || '';
const fileName = this.osPlat == 'win32'
? `node-v${version}-win-${osArch}`
@@ -100195,6 +100197,7 @@ class BaseDistribution {
: `${fileName}.7z`
: `${fileName}.tar.gz`;
const url = `${mirrorURL}/v${version}/${urlFileName}`;
core.info('url from construct ' + url);
return {
downloadUrl: url,
resolvedVersion: version,
@@ -100528,6 +100531,7 @@ class OfficialBuilds extends base_distribution_1.default {
try {
core.info(`Attempting to download using mirror URL...`);
downloadPath = yield this.downloadFromMirrorURL(); // Attempt to download from the mirror
core.info('downloadPath from downloadFromMirrorURL() ' + downloadPath);
if (downloadPath) {
toolPath = downloadPath;
}
@@ -100723,14 +100727,19 @@ class OfficialBuilds extends base_distribution_1.default {
downloadFromMirrorURL() {
return __awaiter(this, void 0, void 0, function* () {
const nodeJsVersions = yield this.getMirrorUrVersions();
core.info('nodeJsVersions from getMirrorUrVersions ' + nodeJsVersions);
const versions = this.filterVersions(nodeJsVersions);
core.info('versions from filterVersions ' + versions);
const evaluatedVersion = this.evaluateVersions(versions);
core.info('evaluatedVersion from evaluatedVersions ' + evaluatedVersion);
if (!evaluatedVersion) {
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
}
const toolName = this.getNodejsMirrorURLInfo(evaluatedVersion);
core.info('toolName from getNodejsMirrorURLInfo ' + toolName);
try {
const toolPath = yield this.downloadNodejs(toolName);
core.info('toolPath from downloadNodejs ' + toolPath);
return toolPath;
}
catch (error) {
5 changes: 5 additions & 0 deletions src/distributions/base-distribution.ts
Original file line number Diff line number Diff line change
@@ -139,7 +139,11 @@ export default abstract class BaseDistribution {

protected getNodejsMirrorURLInfo(version: string) {
const mirrorURL = this.nodeInfo.mirrorURL;
core.info('mirrorURL from getNodejsMirrorURLInfo '+mirrorURL);

const osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
core.info('osArch from translateArchToDistUrl '+osArch);

version = semver.clean(version) || '';
const fileName: string =
this.osPlat == 'win32'
@@ -153,6 +157,7 @@ export default abstract class BaseDistribution {
: `${fileName}.tar.gz`;

const url = `${mirrorURL}/v${version}/${urlFileName}`;
core.info('url from construct '+url);

return <INodeVersionInfo>{
downloadUrl: url,
12 changes: 12 additions & 0 deletions src/distributions/official_builds/official_builds.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ export default class OfficialBuilds extends BaseDistribution {
try {
core.info(`Attempting to download using mirror URL...`);
downloadPath = await this.downloadFromMirrorURL(); // Attempt to download from the mirror
core.info('downloadPath from downloadFromMirrorURL() '+ downloadPath);
if (downloadPath) {
toolPath = downloadPath;
}
@@ -317,10 +318,16 @@ export default class OfficialBuilds extends BaseDistribution {

protected async downloadFromMirrorURL() {
const nodeJsVersions = await this.getMirrorUrVersions();
core.info('nodeJsVersions from getMirrorUrVersions '+nodeJsVersions);
const versions = this.filterVersions(nodeJsVersions);
core.info('versions from filterVersions '+versions);


const evaluatedVersion = this.evaluateVersions(versions);

core.info('evaluatedVersion from evaluatedVersions '+evaluatedVersion);


if (!evaluatedVersion) {
throw new Error(
`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
@@ -329,8 +336,13 @@ export default class OfficialBuilds extends BaseDistribution {

const toolName = this.getNodejsMirrorURLInfo(evaluatedVersion);

core.info('toolName from getNodejsMirrorURLInfo '+toolName);


try {
const toolPath = await this.downloadNodejs(toolName);
core.info('toolPath from downloadNodejs '+toolPath);

return toolPath;
} catch (error) {
if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
Loading
Oops, something went wrong.