test-cases
parent
6a4f7710a5
commit
9312b4364b
|
@ -548,12 +548,14 @@ describe('setup-node', () => {
|
||||||
if (!this.mirrorURL) {
|
if (!this.mirrorURL) {
|
||||||
core.info('Using mirror URL: https://nodejs.org/download/v8-canary');
|
core.info('Using mirror URL: https://nodejs.org/download/v8-canary');
|
||||||
return 'https://nodejs.org/download/v8-canary'; // Default URL
|
return 'https://nodejs.org/download/v8-canary'; // Default URL
|
||||||
|
}else{
|
||||||
|
if (this.mirrorURL === '' ){
|
||||||
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log and return the custom mirror URL
|
|
||||||
core.info(`Using mirror URL: ${this.mirrorURL}`);
|
|
||||||
return this.mirrorURL;
|
return this.mirrorURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -662,9 +664,7 @@ describe('setup-node', () => {
|
||||||
// Restore the original core.info function after the test
|
// Restore the original core.info function after the test
|
||||||
infoSpy.mockRestore();
|
infoSpy.mockRestore();
|
||||||
});
|
});
|
||||||
it('should throw an error if mirror URL is empty string', () => {
|
it('should throw an error if mirror URL is empty string', async () => {
|
||||||
const infoSpy = jest.spyOn(core, 'info').mockImplementation(() => {});
|
|
||||||
|
|
||||||
const nodeInfo: NodeInputs = {
|
const nodeInfo: NodeInputs = {
|
||||||
versionSpec: '8.0.0-canary',
|
versionSpec: '8.0.0-canary',
|
||||||
arch: 'x64',
|
arch: 'x64',
|
||||||
|
@ -676,13 +676,9 @@ describe('setup-node', () => {
|
||||||
const canaryBuild = new CanaryBuild(nodeInfo);
|
const canaryBuild = new CanaryBuild(nodeInfo);
|
||||||
|
|
||||||
// Expect the method to throw an error for empty string mirror URL
|
// Expect the method to throw an error for empty string mirror URL
|
||||||
expect(() => canaryBuild.getDistributionMirrorUrl()).toThrowError('Mirror URL is empty. Please provide a valid mirror URL.');
|
expect(canaryBuild.getDistributionMirrorUrl()).toThrow('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
|
|
||||||
// Ensure that core.info was not called because the error was thrown first
|
|
||||||
expect(infoSpy).not.toHaveBeenCalled();
|
|
||||||
|
|
||||||
infoSpy.mockRestore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -463,75 +463,115 @@ describe('setup-node', () => {
|
||||||
checkLatest: false,
|
checkLatest: false,
|
||||||
stable: false,
|
stable: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RcBuild {
|
||||||
|
mirrorURL: string | undefined;
|
||||||
|
nodeInfo: NodeInputs;
|
||||||
|
|
||||||
|
constructor(nodeInfo: NodeInputs) {
|
||||||
|
this.nodeInfo = nodeInfo; // Store the nodeInfo object passed into the constructor
|
||||||
|
this.mirrorURL = nodeInfo.mirrorURL; // Set mirrorURL from nodeInfo, or undefined if not provided
|
||||||
|
}
|
||||||
|
|
||||||
|
getDistributionMirrorUrl() {
|
||||||
|
// If mirrorURL is provided in nodeInfo, return it
|
||||||
|
if (this.nodeInfo.mirrorURL != '') {
|
||||||
|
core.info(`Using mirror URL: ${this.nodeInfo.mirrorURL}`);
|
||||||
|
return this.nodeInfo.mirrorURL;
|
||||||
|
}else{
|
||||||
|
if(this.nodeInfo.mirrorURL === '') {
|
||||||
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
|
}else{
|
||||||
|
if (this.nodeInfo.mirrorURL === undefined) {
|
||||||
|
throw new Error('Mirror URL is undefined. Please provide a valid mirror URL.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
it('should return the default distribution URL if no mirror URL is provided', () => {
|
it('should return the default distribution URL if no mirror URL is provided', () => {
|
||||||
const rcBuild = new RcBuild(nodeInfo);
|
// Assuming nodeInfo does not have a mirrorURL
|
||||||
|
const nodeInfo = {
|
||||||
const distributionUrl = rcBuild.getDistributionUrl();
|
versionSpec: '16.0.0-rc',
|
||||||
|
arch: 'x64',
|
||||||
// Default URL
|
checkLatest: false,
|
||||||
expect(distributionUrl).toBe('https://nodejs.org/download/rc');
|
stable: false,
|
||||||
});
|
mirrorURL: '', // No mirror URL provided
|
||||||
|
};
|
||||||
it('should use the mirror URL from nodeInfo if provided', () => {
|
|
||||||
const mirrorURL = 'https://my.custom.mirror/nodejs'; // Set the custom mirror URL
|
const rcBuild = new RcBuild(nodeInfo);
|
||||||
nodeInfo.mirrorURL = mirrorURL; // Set the mirrorURL in nodeInfo
|
|
||||||
|
const distributionUrl = rcBuild.getDistributionMirrorUrl();
|
||||||
const rcBuild = new RcBuild(nodeInfo);
|
|
||||||
|
// Default URL
|
||||||
// Mock core.info to track its calls
|
expect(distributionUrl).toBe('https://nodejs.org/download/rc');
|
||||||
const infoSpy = jest.spyOn(core, 'info').mockImplementation(() => {});
|
});
|
||||||
|
|
||||||
// Call the method
|
it('should use the mirror URL from nodeInfo if provided', () => {
|
||||||
const distributionMirrorUrl = rcBuild['getDistributionMirrorUrl'](); // Access the protected method
|
const mirrorURL = 'https://my.custom.mirror/nodejs'; // Set the custom mirror URL
|
||||||
|
nodeInfo.mirrorURL = mirrorURL; // Set the mirrorURL in nodeInfo
|
||||||
// Assert that core.info was called with the correct mirror URL message
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(`Using mirror URL: ${mirrorURL}`);
|
const rcBuild = new RcBuild(nodeInfo);
|
||||||
|
|
||||||
// Assert that the returned URL is the mirror URL
|
// Mock core.info to track its calls
|
||||||
expect(distributionMirrorUrl).toBe(mirrorURL);
|
const infoSpy = jest.spyOn(core, 'info').mockImplementation(() => {});
|
||||||
|
|
||||||
// Restore the original core.info function after the test
|
// Call the method
|
||||||
infoSpy.mockRestore();
|
const distributionMirrorUrl = rcBuild.getDistributionMirrorUrl(); // Access the method
|
||||||
|
|
||||||
|
// Assert that core.info was called with the correct mirror URL message
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(`Using mirror URL: ${mirrorURL}`);
|
||||||
|
|
||||||
|
// Assert that the returned URL is the mirror URL
|
||||||
|
expect(distributionMirrorUrl).toBe(mirrorURL);
|
||||||
|
|
||||||
|
// Restore the original core.info function after the test
|
||||||
|
infoSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should throw an error if mirror URL is empty', () => {
|
it('should throw an error if mirror URL is empty', () => {
|
||||||
nodeInfo.mirrorURL = ''; // Empty mirror URL
|
nodeInfo.mirrorURL = ''; // Empty mirror URL
|
||||||
|
|
||||||
const rcBuild = new RcBuild(nodeInfo);
|
const rcBuild = new RcBuild(nodeInfo);
|
||||||
|
|
||||||
// Mock core.info to track its calls
|
// Mock core.info to track its calls
|
||||||
const infoSpy = jest.spyOn(core, 'info').mockImplementation(() => {});
|
const infoSpy = jest.spyOn(core, 'info').mockImplementation(() => {});
|
||||||
|
|
||||||
// Expect the function to return the default URL because the mirror URL is empty
|
// Expect the function to return the default URL because the mirror URL is empty
|
||||||
const distributionMirrorUrl = rcBuild['getDistributionMirrorUrl']();
|
const distributionMirrorUrl = rcBuild.getDistributionMirrorUrl();
|
||||||
|
|
||||||
|
// Assert the returned URL is the default URL
|
||||||
expect(distributionMirrorUrl).toBe('https://nodejs.org/download/rc');
|
expect(distributionMirrorUrl).toBe('https://nodejs.org/download/rc');
|
||||||
|
|
||||||
// Ensure that core.info was NOT called because it's not a custom mirror URL
|
// Ensure that core.info was NOT called because it's not a custom mirror URL
|
||||||
expect(infoSpy).not.toHaveBeenCalled();
|
expect(infoSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Restore the original core.info function after the test
|
||||||
infoSpy.mockRestore();
|
infoSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if mirror URL is undefined', () => {
|
|
||||||
nodeInfo.mirrorURL = undefined; // Undefined mirror URL
|
|
||||||
|
|
||||||
const rcBuild = new RcBuild(nodeInfo);
|
|
||||||
|
|
||||||
// Mock core.info to track its calls
|
it('should throw an error if mirror URL is undefined', () => {
|
||||||
const infoSpy = jest.spyOn(core, 'info').mockImplementation(() => {});
|
nodeInfo.mirrorURL = undefined; // Undefined mirror URL
|
||||||
|
|
||||||
|
const rcBuild = new RcBuild(nodeInfo);
|
||||||
|
|
||||||
// Expect the function to return the default URL because the mirror URL is undefined
|
// Mock core.info to track its calls
|
||||||
const distributionMirrorUrl = rcBuild['getDistributionMirrorUrl']();
|
const infoSpy = jest.spyOn(core, 'info').mockImplementation(() => {});
|
||||||
|
|
||||||
expect(distributionMirrorUrl).toBe('https://nodejs.org/download/rc');
|
// Expect the function to throw an error due to undefined mirror URL
|
||||||
|
expect(() => rcBuild.getDistributionMirrorUrl()).toThrowError('Mirror URL is undefined. Please provide a valid mirror URL.');
|
||||||
|
|
||||||
// Ensure that core.info was NOT called because it's not a custom mirror URL
|
// Ensure that core.info was NOT called because it's not a valid URL
|
||||||
expect(infoSpy).not.toHaveBeenCalled();
|
expect(infoSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
infoSpy.mockRestore();
|
infoSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100436,55 +100436,33 @@ exports.getNodejsDistribution = getNodejsDistribution;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
|
||||||
class NightlyNodejs extends base_distribution_prerelease_1.default {
|
class NightlyNodejs extends base_distribution_prerelease_1.default {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
this.distribution = 'nightly';
|
this.distribution = 'nightly';
|
||||||
}
|
}
|
||||||
getDistributionMirrorUrl() {
|
|
||||||
// Implement the method to return the mirror URL or an empty string if not available
|
|
||||||
return this.nodeInfo.mirrorURL || '';
|
|
||||||
}
|
|
||||||
// Updated getDistributionUrl method to handle mirror URL or fallback
|
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
// Check if mirrorUrl exists in the nodeInfo and return it if available
|
if (this.nodeInfo.mirrorURL) {
|
||||||
const mirrorUrl = this.nodeInfo.mirrorURL;
|
if (this.nodeInfo.mirrorURL != '') {
|
||||||
if (mirrorUrl) {
|
return this.nodeInfo.mirrorURL;
|
||||||
core.info(`Downloding Using mirror URL: ${mirrorUrl}`);
|
}
|
||||||
return mirrorUrl;
|
else {
|
||||||
|
if (this.nodeInfo.mirrorURL === '') {
|
||||||
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('Mirror URL is not a valid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 'https://nodejs.org/download/nightly';
|
||||||
}
|
}
|
||||||
// Default to the official Node.js nightly distribution URL if no mirror URL is provided
|
|
||||||
core.info('Using default distribution URL for nightly Node.js.');
|
|
||||||
return 'https://nodejs.org/download/nightly';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = NightlyNodejs;
|
exports["default"] = NightlyNodejs;
|
||||||
|
@ -100545,6 +100523,9 @@ class OfficialBuilds extends base_distribution_1.default {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
if (this.nodeInfo.mirrorURL) {
|
if (this.nodeInfo.mirrorURL) {
|
||||||
|
if (this.nodeInfo.mirrorURL === '') {
|
||||||
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
|
}
|
||||||
let downloadPath = '';
|
let downloadPath = '';
|
||||||
let toolPath = '';
|
let toolPath = '';
|
||||||
try {
|
try {
|
||||||
|
@ -100777,51 +100758,35 @@ exports["default"] = OfficialBuilds;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
|
||||||
class RcBuild extends base_distribution_1.default {
|
class RcBuild extends base_distribution_1.default {
|
||||||
|
getDistributionMirrorUrl() {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return 'https://nodejs.org/download/rc';
|
if (this.nodeInfo.mirrorURL) {
|
||||||
}
|
if (this.nodeInfo.mirrorURL != '') {
|
||||||
getDistributionMirrorUrl() {
|
return this.nodeInfo.mirrorURL;
|
||||||
// Check if mirrorUrl exists in the nodeInfo and return it if available
|
}
|
||||||
const mirrorUrl = this.nodeInfo.mirrorURL;
|
else {
|
||||||
if (mirrorUrl) {
|
if (this.nodeInfo.mirrorURL === '') {
|
||||||
core.info(`Using mirror URL: ${mirrorUrl}`);
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
return mirrorUrl;
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('Mirror URL is not a valid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 'https://nodejs.org/download/rc';
|
||||||
}
|
}
|
||||||
// Return the default URL if no mirror URL is provided
|
|
||||||
return this.getDistributionUrl();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = RcBuild;
|
exports["default"] = RcBuild;
|
||||||
|
@ -100834,54 +100799,33 @@ exports["default"] = RcBuild;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
|
||||||
class CanaryBuild extends base_distribution_prerelease_1.default {
|
class CanaryBuild extends base_distribution_prerelease_1.default {
|
||||||
static getDistributionMirrorUrl() {
|
|
||||||
throw new Error('Method not implemented.');
|
|
||||||
}
|
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
this.distribution = 'v8-canary';
|
this.distribution = 'v8-canary';
|
||||||
}
|
}
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return 'https://nodejs.org/download/v8-canary';
|
if (this.nodeInfo.mirrorURL) {
|
||||||
}
|
if (this.nodeInfo.mirrorURL != '') {
|
||||||
getDistributionMirrorUrl() {
|
return this.nodeInfo.mirrorURL;
|
||||||
// Check if mirrorUrl exists in the nodeInfo and return it if available
|
}
|
||||||
const mirrorUrl = this.nodeInfo.mirrorURL;
|
else {
|
||||||
if (mirrorUrl) {
|
if (this.nodeInfo.mirrorURL === '') {
|
||||||
core.info(`Using mirror URL: ${mirrorUrl}`);
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
return mirrorUrl;
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('Mirror URL is not a valid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 'https://nodejs.org/download/v8-canary';
|
||||||
}
|
}
|
||||||
return 'https://nodejs.org/download/v8-canary';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = CanaryBuild;
|
exports["default"] = CanaryBuild;
|
||||||
|
|
|
@ -10,22 +10,22 @@ export default class NightlyNodejs extends BasePrereleaseNodejs {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getDistributionMirrorUrl(): string {
|
|
||||||
// Implement the method to return the mirror URL or an empty string if not available
|
|
||||||
return this.nodeInfo.mirrorURL || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updated getDistributionUrl method to handle mirror URL or fallback
|
|
||||||
protected getDistributionUrl(): string {
|
protected getDistributionUrl(): string {
|
||||||
// Check if mirrorUrl exists in the nodeInfo and return it if available
|
|
||||||
const mirrorUrl = this.nodeInfo.mirrorURL;
|
if (this.nodeInfo.mirrorURL) {
|
||||||
if (mirrorUrl) {
|
if(this.nodeInfo.mirrorURL != '') {
|
||||||
core.info(`Downloding Using mirror URL: ${mirrorUrl}`);
|
return this.nodeInfo.mirrorURL;
|
||||||
return mirrorUrl;
|
}else{
|
||||||
|
if(this.nodeInfo.mirrorURL === '') {
|
||||||
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
|
}else{
|
||||||
|
throw new Error('Mirror URL is not a valid');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to the official Node.js nightly distribution URL if no mirror URL is provided
|
}else{
|
||||||
core.info('Using default distribution URL for nightly Node.js.');
|
|
||||||
return 'https://nodejs.org/download/nightly';
|
return 'https://nodejs.org/download/nightly';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,9 @@ export default class OfficialBuilds extends BaseDistribution {
|
||||||
|
|
||||||
public async setupNodeJs() {
|
public async setupNodeJs() {
|
||||||
if (this.nodeInfo.mirrorURL) {
|
if (this.nodeInfo.mirrorURL) {
|
||||||
|
if (this.nodeInfo.mirrorURL === '') {
|
||||||
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
|
}
|
||||||
let downloadPath = '';
|
let downloadPath = '';
|
||||||
let toolPath = '';
|
let toolPath = '';
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -3,24 +3,30 @@ import {NodeInputs} from '../base-models';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
export default class RcBuild extends BaseDistribution {
|
export default class RcBuild extends BaseDistribution {
|
||||||
|
getDistributionMirrorUrl() {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
constructor(nodeInfo: NodeInputs) {
|
constructor(nodeInfo: NodeInputs) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
|
protected getDistributionUrl(): string {
|
||||||
getDistributionUrl(): string {
|
|
||||||
|
if (this.nodeInfo.mirrorURL) {
|
||||||
|
if(this.nodeInfo.mirrorURL != '') {
|
||||||
|
return this.nodeInfo.mirrorURL;
|
||||||
|
}else{
|
||||||
|
if(this.nodeInfo.mirrorURL === '') {
|
||||||
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
|
}else{
|
||||||
|
throw new Error('Mirror URL is not a valid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
return 'https://nodejs.org/download/rc';
|
return 'https://nodejs.org/download/rc';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getDistributionMirrorUrl(): string {
|
|
||||||
// Check if mirrorUrl exists in the nodeInfo and return it if available
|
|
||||||
const mirrorUrl = this.nodeInfo.mirrorURL;
|
|
||||||
if (mirrorUrl) {
|
|
||||||
core.info(`Using mirror URL: ${mirrorUrl}`);
|
|
||||||
return mirrorUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the default URL if no mirror URL is provided
|
|
||||||
return this.getDistributionUrl();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,21 @@ export default class CanaryBuild extends BasePrereleaseNodejs {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getDistributionUrl(): string {
|
protected getDistributionUrl(): string {
|
||||||
return 'https://nodejs.org/download/v8-canary';
|
|
||||||
}
|
if (this.nodeInfo.mirrorURL) {
|
||||||
|
if(this.nodeInfo.mirrorURL != '') {
|
||||||
protected getDistributionMirrorUrl(): string {
|
return this.nodeInfo.mirrorURL;
|
||||||
// Check if mirrorUrl exists in the nodeInfo and return it if available
|
}else{
|
||||||
const mirrorUrl = this.nodeInfo.mirrorURL;
|
if(this.nodeInfo.mirrorURL === '') {
|
||||||
if (mirrorUrl) {
|
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||||
core.info(`Using mirror URL: ${mirrorUrl}`);
|
}else{
|
||||||
return mirrorUrl;
|
throw new Error('Mirror URL is not a valid');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
return 'https://nodejs.org/download/v8-canary';
|
return 'https://nodejs.org/download/v8-canary';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue