Skip to content

Commit

Permalink
Merge pull request #151 from volta-cli/chuck/v2-support
Browse files Browse the repository at this point in the history
Update download url to support new architectures for Volta 2.0.0
  • Loading branch information
rwjblue authored Aug 1, 2024
2 parents 2d68418 + 043aa0b commit 289e7b0
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
21 changes: 20 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23137,6 +23137,7 @@ function voltaVersionHasSetup(version) {
async function buildDownloadUrl(platform, arch, version, variant = '', openSSLVersionForTesting = '') {
let fileName = '';
const isOpenSSLDependent = semver.lt(version, '1.1.0');
const isVolta1 = semver.lt(version, '2.0.0');
if (variant) {
fileName = `volta-${version}-${variant}.tar.gz`;
}
Expand All @@ -23158,7 +23159,7 @@ async function buildDownloadUrl(platform, arch, version, variant = '', openSSLVe
throw new Error(`your platform ${platform} is not yet supported`);
}
}
else {
else if (isVolta1) {
switch (platform) {
case 'darwin':
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
Expand All @@ -23174,6 +23175,24 @@ async function buildDownloadUrl(platform, arch, version, variant = '', openSSLVe
throw new Error(`your platform ${platform} is not yet supported`);
}
}
else {
switch (platform) {
case 'darwin': {
fileName = `volta-${version}-macos.tar.gz`;
break;
}
case 'linux': {
fileName = `volta-${version}-linux${arch === 'arm64' ? '-arm' : ''}.tar.gz`;
break;
}
case 'win32': {
fileName = `volta-${version}-windows-${arch === 'arm64' ? 'arm64' : '-x86_64'}.msi`;
break;
}
default:
throw new Error(`your platform ${platform} is not yet supported`);
}
}
return `https://github.com/volta-cli/volta/releases/download/v${version}/${fileName}`;
}
async function getOpenSSLVersion(version = '') {
Expand Down
53 changes: 53 additions & 0 deletions src/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,59 @@ describe('buildDownloadUrl', () => {
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
});
});

describe('volta@2.0.0', function () {
test('darwin - x64', async function () {
expect(await buildDownloadUrl('darwin', 'x64', '2.0.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-macos.tar.gz"`
);
});

test('darwin - arm64', async function () {
expect(await buildDownloadUrl('darwin', 'arm64', '2.0.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-macos.tar.gz"`
);
});

test('linux - x64', async function () {
expect(await buildDownloadUrl('linux', 'x64', '2.0.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-linux.tar.gz"`
);
});

test('linux - arm64', async function () {
expect(await buildDownloadUrl('linux', 'arm64', '2.0.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-linux-arm.tar.gz"`
);
});

test('linux with variant input', async function () {
expect(
await buildDownloadUrl('linux', 'x64', '1.1.0', 'linux-openssl-rhel')
).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux-openssl-rhel.tar.gz"`
);
});

test('win32 - x64', async function () {
expect(await buildDownloadUrl('win32', 'x86-64', '2.0.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-windows-x86_64.msi"`
);
});

test('win32 - arm64', async function () {
expect(await buildDownloadUrl('win32', 'arm64', '2.0.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-windows-arm64.msi"`
);
});

test('aix', async function () {
expect(
async () =>
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '2.0.0')
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
});
});
});

describe('getOpenSSLVersion', () => {
Expand Down
20 changes: 19 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export async function buildDownloadUrl(
let fileName = '';

const isOpenSSLDependent = semver.lt(version, '1.1.0');
const isVolta1 = semver.lt(version, '2.0.0');

if (variant) {
fileName = `volta-${version}-${variant}.tar.gz`;
Expand All @@ -134,7 +135,7 @@ export async function buildDownloadUrl(
default:
throw new Error(`your platform ${platform} is not yet supported`);
}
} else {
} else if (isVolta1) {
switch (platform) {
case 'darwin':
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
Expand All @@ -149,6 +150,23 @@ export async function buildDownloadUrl(
default:
throw new Error(`your platform ${platform} is not yet supported`);
}
} else {
switch (platform) {
case 'darwin': {
fileName = `volta-${version}-macos.tar.gz`;
break;
}
case 'linux': {
fileName = `volta-${version}-linux${arch === 'arm64' ? '-arm' : ''}.tar.gz`;
break;
}
case 'win32': {
fileName = `volta-${version}-windows-${arch === 'arm64' ? 'arm64' : 'x86_64'}.msi`;
break;
}
default:
throw new Error(`your platform ${platform} is not yet supported`);
}
}

return `https://github.com/volta-cli/volta/releases/download/v${version}/${fileName}`;
Expand Down

0 comments on commit 289e7b0

Please sign in to comment.