Skip to content

Commit 043aa0b

Browse files
committed
Update download url to support new architectures for Volta 2.0.0
1 parent 2d68418 commit 043aa0b

File tree

3 files changed

+92
-2
lines changed

3 files changed

+92
-2
lines changed

dist/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23137,6 +23137,7 @@ function voltaVersionHasSetup(version) {
2313723137
async function buildDownloadUrl(platform, arch, version, variant = '', openSSLVersionForTesting = '') {
2313823138
let fileName = '';
2313923139
const isOpenSSLDependent = semver.lt(version, '1.1.0');
23140+
const isVolta1 = semver.lt(version, '2.0.0');
2314023141
if (variant) {
2314123142
fileName = `volta-${version}-${variant}.tar.gz`;
2314223143
}
@@ -23158,7 +23159,7 @@ async function buildDownloadUrl(platform, arch, version, variant = '', openSSLVe
2315823159
throw new Error(`your platform ${platform} is not yet supported`);
2315923160
}
2316023161
}
23161-
else {
23162+
else if (isVolta1) {
2316223163
switch (platform) {
2316323164
case 'darwin':
2316423165
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
@@ -23174,6 +23175,24 @@ async function buildDownloadUrl(platform, arch, version, variant = '', openSSLVe
2317423175
throw new Error(`your platform ${platform} is not yet supported`);
2317523176
}
2317623177
}
23178+
else {
23179+
switch (platform) {
23180+
case 'darwin': {
23181+
fileName = `volta-${version}-macos.tar.gz`;
23182+
break;
23183+
}
23184+
case 'linux': {
23185+
fileName = `volta-${version}-linux${arch === 'arm64' ? '-arm' : ''}.tar.gz`;
23186+
break;
23187+
}
23188+
case 'win32': {
23189+
fileName = `volta-${version}-windows-${arch === 'arm64' ? 'arm64' : '-x86_64'}.msi`;
23190+
break;
23191+
}
23192+
default:
23193+
throw new Error(`your platform ${platform} is not yet supported`);
23194+
}
23195+
}
2317723196
return `https://github.com/volta-cli/volta/releases/download/v${version}/${fileName}`;
2317823197
}
2317923198
async function getOpenSSLVersion(version = '') {

src/installer.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,59 @@ describe('buildDownloadUrl', () => {
9393
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
9494
});
9595
});
96+
97+
describe('[email protected]', function () {
98+
test('darwin - x64', async function () {
99+
expect(await buildDownloadUrl('darwin', 'x64', '2.0.0')).toMatchInlineSnapshot(
100+
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-macos.tar.gz"`
101+
);
102+
});
103+
104+
test('darwin - arm64', async function () {
105+
expect(await buildDownloadUrl('darwin', 'arm64', '2.0.0')).toMatchInlineSnapshot(
106+
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-macos.tar.gz"`
107+
);
108+
});
109+
110+
test('linux - x64', async function () {
111+
expect(await buildDownloadUrl('linux', 'x64', '2.0.0')).toMatchInlineSnapshot(
112+
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-linux.tar.gz"`
113+
);
114+
});
115+
116+
test('linux - arm64', async function () {
117+
expect(await buildDownloadUrl('linux', 'arm64', '2.0.0')).toMatchInlineSnapshot(
118+
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-linux-arm.tar.gz"`
119+
);
120+
});
121+
122+
test('linux with variant input', async function () {
123+
expect(
124+
await buildDownloadUrl('linux', 'x64', '1.1.0', 'linux-openssl-rhel')
125+
).toMatchInlineSnapshot(
126+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux-openssl-rhel.tar.gz"`
127+
);
128+
});
129+
130+
test('win32 - x64', async function () {
131+
expect(await buildDownloadUrl('win32', 'x86-64', '2.0.0')).toMatchInlineSnapshot(
132+
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-windows-x86_64.msi"`
133+
);
134+
});
135+
136+
test('win32 - arm64', async function () {
137+
expect(await buildDownloadUrl('win32', 'arm64', '2.0.0')).toMatchInlineSnapshot(
138+
`"https://github.com/volta-cli/volta/releases/download/v2.0.0/volta-2.0.0-windows-arm64.msi"`
139+
);
140+
});
141+
142+
test('aix', async function () {
143+
expect(
144+
async () =>
145+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '2.0.0')
146+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
147+
});
148+
});
96149
});
97150

98151
describe('getOpenSSLVersion', () => {

src/installer.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export async function buildDownloadUrl(
113113
let fileName = '';
114114

115115
const isOpenSSLDependent = semver.lt(version, '1.1.0');
116+
const isVolta1 = semver.lt(version, '2.0.0');
116117

117118
if (variant) {
118119
fileName = `volta-${version}-${variant}.tar.gz`;
@@ -134,7 +135,7 @@ export async function buildDownloadUrl(
134135
default:
135136
throw new Error(`your platform ${platform} is not yet supported`);
136137
}
137-
} else {
138+
} else if (isVolta1) {
138139
switch (platform) {
139140
case 'darwin':
140141
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
@@ -149,6 +150,23 @@ export async function buildDownloadUrl(
149150
default:
150151
throw new Error(`your platform ${platform} is not yet supported`);
151152
}
153+
} else {
154+
switch (platform) {
155+
case 'darwin': {
156+
fileName = `volta-${version}-macos.tar.gz`;
157+
break;
158+
}
159+
case 'linux': {
160+
fileName = `volta-${version}-linux${arch === 'arm64' ? '-arm' : ''}.tar.gz`;
161+
break;
162+
}
163+
case 'win32': {
164+
fileName = `volta-${version}-windows-${arch === 'arm64' ? 'arm64' : 'x86_64'}.msi`;
165+
break;
166+
}
167+
default:
168+
throw new Error(`your platform ${platform} is not yet supported`);
169+
}
152170
}
153171

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

0 commit comments

Comments
 (0)