Compare commits

..

2 Commits

Author SHA1 Message Date
Marco Ippolito
380cf08b3f
Merge 6e3e989fb8 into 802632921f 2025-03-06 10:53:10 +01:00
Marco Ippolito
6e3e989fb8
feat: support private mirrors 2025-03-06 10:52:23 +01:00
3 changed files with 12 additions and 35 deletions

View File

@ -449,8 +449,8 @@ describe('setup-node', () => {
} }
}, 100000); }, 100000);
it('acquires specified architecture of node from mirror', async () => { it('acquires specified architecture of node', async () => {
for (const {arch, version, osSpec} of [ for (const { arch, version, osSpec } of [
{ {
arch: 'x86', arch: 'x86',
version: '18.0.0-nightly202110204cb3e06ed8', version: '18.0.0-nightly202110204cb3e06ed8',

View File

@ -830,9 +830,9 @@ describe('setup-node', () => {
}); });
it('acquires specified architecture of node from mirror', async () => { it('acquires specified architecture of node from mirror', async () => {
for (const {arch, version, osSpec} of [ for (const { arch, version, osSpec } of [
{arch: 'x86', version: '12.16.2', osSpec: 'win32'}, { arch: 'x86', version: '12.16.2', osSpec: 'win32' },
{arch: 'x86', version: '14.0.0', osSpec: 'win32'} { arch: 'x86', version: '14.0.0', osSpec: 'win32' }
]) { ]) {
os.platform = osSpec; os.platform = osSpec;
os.arch = arch; os.arch = arch;

View File

@ -102,14 +102,11 @@ export default abstract class BaseDistribution {
const headers = {}; const headers = {};
if (this.nodeInfo.mirrorToken) { if(this.nodeInfo.mirrorToken) {
headers['Authorization'] = `Bearer ${this.nodeInfo.mirrorToken}`; headers['Authorization'] = `Bearer ${this.nodeInfo.mirrorToken}`;
} }
const response = await this.httpClient.getJson<INodeVersion[]>( const response = await this.httpClient.getJson<INodeVersion[]>(dataUrl, headers);
dataUrl,
headers
);
return response.result || []; return response.result || [];
} }
@ -143,11 +140,7 @@ export default abstract class BaseDistribution {
`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}` `Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`
); );
try { try {
downloadPath = await tc.downloadTool( downloadPath = await tc.downloadTool(info.downloadUrl, undefined, this.nodeInfo.mirrorToken);
info.downloadUrl,
undefined,
this.nodeInfo.mirrorToken
);
} catch (err) { } catch (err) {
if ( if (
err instanceof tc.HTTPError && err instanceof tc.HTTPError &&
@ -198,34 +191,18 @@ export default abstract class BaseDistribution {
core.info(`Downloading only node binary from ${exeUrl}`); core.info(`Downloading only node binary from ${exeUrl}`);
const exePath = await tc.downloadTool( const exePath = await tc.downloadTool(exeUrl, undefined, this.nodeInfo.mirrorToken);
exeUrl,
undefined,
this.nodeInfo.mirrorToken
);
await io.cp(exePath, path.join(tempDir, 'node.exe')); await io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = await tc.downloadTool( const libPath = await tc.downloadTool(libUrl, undefined, this.nodeInfo.mirrorToken);
libUrl,
undefined,
this.nodeInfo.mirrorToken
);
await io.cp(libPath, path.join(tempDir, 'node.lib')); await io.cp(libPath, path.join(tempDir, 'node.lib'));
} catch (err) { } catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) { if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
exeUrl = `${initialUrl}/v${version}/node.exe`; exeUrl = `${initialUrl}/v${version}/node.exe`;
libUrl = `${initialUrl}/v${version}/node.lib`; libUrl = `${initialUrl}/v${version}/node.lib`;
const exePath = await tc.downloadTool( const exePath = await tc.downloadTool(exeUrl, undefined, this.nodeInfo.mirrorToken);
exeUrl,
undefined,
this.nodeInfo.mirrorToken
);
await io.cp(exePath, path.join(tempDir, 'node.exe')); await io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = await tc.downloadTool( const libPath = await tc.downloadTool(libUrl, undefined, this.nodeInfo.mirrorToken);
libUrl,
undefined,
this.nodeInfo.mirrorToken
);
await io.cp(libPath, path.join(tempDir, 'node.lib')); await io.cp(libPath, path.join(tempDir, 'node.lib'));
} else { } else {
throw err; throw err;