Skip to content

Commit 7c65195

Browse files
author
Robert Jackson
committed
[BACKPORT] Add [email protected] support to v3.x releases.
This is basically a cherry-pick of 069b85c, but done manually.
1 parent 2216ae1 commit 7c65195

File tree

3 files changed

+162
-77
lines changed

3 files changed

+162
-77
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
volta-version: ["1.0.0", "1.0.8"]
42+
volta-version: ["1.0.0", "1.0.8", "1.1.0"]
4343
os: [ubuntu, macOS, windows]
4444

4545
steps:

src/installer.test.ts

Lines changed: 125 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,110 @@ import { createTempDir } from 'broccoli-test-helper';
33
import nock from 'nock';
44

55
describe('buildDownloadUrl', () => {
6-
test('darwin', async function () {
7-
expect(await buildDownloadUrl('darwin', '0.6.4')).toMatchInlineSnapshot(
8-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-macos.tar.gz"`
9-
);
10-
});
6+
describe('volta < 1.1.0', function () {
7+
test('darwin - x64', async function () {
8+
expect(await buildDownloadUrl('darwin', 'x64', '0.6.4')).toMatchInlineSnapshot(
9+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-macos.tar.gz"`
10+
);
11+
});
1112

12-
test('linux', async function () {
13-
expect(
14-
await buildDownloadUrl('linux', '0.6.4', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
15-
).toMatchInlineSnapshot(
16-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
17-
);
13+
test('darwin - arm64', async function () {
14+
expect(await buildDownloadUrl('darwin', 'arm64', '0.6.4')).toMatchInlineSnapshot(
15+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-macos.tar.gz"`
16+
);
17+
});
1818

19-
expect(
20-
await buildDownloadUrl('linux', '0.6.4', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
21-
).toMatchInlineSnapshot(
22-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
23-
);
24-
});
19+
test('linux', async function () {
20+
expect(
21+
await buildDownloadUrl('linux', 'x64', '0.6.4', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
22+
).toMatchInlineSnapshot(
23+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
24+
);
25+
26+
expect(
27+
await buildDownloadUrl('linux', 'x64', '0.6.4', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
28+
).toMatchInlineSnapshot(
29+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
30+
);
31+
});
2532

26-
test('linux with openssl-version input', async function () {
27-
expect(await buildDownloadUrl('linux', '0.6.4', '1.0')).toMatchInlineSnapshot(
28-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
29-
);
33+
test('linux with openssl-version input', async function () {
34+
expect(await buildDownloadUrl('linux', 'x64', '0.6.4', '1.0')).toMatchInlineSnapshot(
35+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
36+
);
3037

31-
expect(await buildDownloadUrl('linux', '0.6.4', '1.1')).toMatchInlineSnapshot(
32-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
33-
);
34-
});
38+
expect(await buildDownloadUrl('linux', 'x64', '0.6.4', '1.1')).toMatchInlineSnapshot(
39+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
40+
);
41+
});
3542

36-
test('win32', async function () {
37-
expect(await buildDownloadUrl('win32', '0.7.2')).toMatchInlineSnapshot(
38-
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
39-
);
43+
test('win32', async function () {
44+
expect(await buildDownloadUrl('win32', 'x86-64', '0.7.2')).toMatchInlineSnapshot(
45+
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
46+
);
47+
});
48+
49+
test('aix', async function () {
50+
expect(
51+
async () =>
52+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '0.6.4')
53+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
54+
});
4055
});
4156

42-
test('aix', async function () {
43-
expect(
44-
async () => await buildDownloadUrl('aix', '0.6.4')
45-
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
57+
describe('[email protected]', function () {
58+
test('darwin - x64', async function () {
59+
expect(await buildDownloadUrl('darwin', 'x64', '1.1.0')).toMatchInlineSnapshot(
60+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos.tar.gz"`
61+
);
62+
});
63+
64+
test('darwin - arm64', async function () {
65+
expect(await buildDownloadUrl('darwin', 'arm64', '1.1.0')).toMatchInlineSnapshot(
66+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos-aarch64.tar.gz"`
67+
);
68+
});
69+
70+
test('linux', async function () {
71+
expect(
72+
await buildDownloadUrl('linux', 'x64', '1.1.0', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
73+
).toMatchInlineSnapshot(
74+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
75+
);
76+
77+
expect(
78+
await buildDownloadUrl('linux', 'x64', '1.1.0', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
79+
).toMatchInlineSnapshot(
80+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
81+
);
82+
83+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0')).toMatchInlineSnapshot(
84+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
85+
);
86+
});
87+
88+
test('linux with openssl-version input', async function () {
89+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0', '1.0')).toMatchInlineSnapshot(
90+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
91+
);
92+
93+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0', '1.1')).toMatchInlineSnapshot(
94+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
95+
);
96+
});
97+
98+
test('win32', async function () {
99+
expect(await buildDownloadUrl('win32', 'x86-64', '1.1.0')).toMatchInlineSnapshot(
100+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-windows-x86_64.msi"`
101+
);
102+
});
103+
104+
test('aix', async function () {
105+
expect(
106+
async () =>
107+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '1.1.0')
108+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
109+
});
46110
});
47111
});
48112

@@ -59,34 +123,34 @@ describe('buildLayout', () => {
59123
await buildLayout(tmpdir.path());
60124

61125
expect(tmpdir.read()).toMatchInlineSnapshot(`
62-
Object {
63-
"bin": Object {
64-
"node": "shim-file-here",
65-
"npm": "shim-file-here",
66-
"npx": "shim-file-here",
67-
"shim": "shim-file-here",
68-
"yarn": "shim-file-here",
69-
},
70-
"cache": Object {
71-
"node": Object {},
72-
},
73-
"log": Object {},
74-
"tmp": Object {},
75-
"tools": Object {
76-
"image": Object {
77-
"node": Object {},
78-
"packages": Object {},
79-
"yarn": Object {},
80-
},
81-
"inventory": Object {
82-
"node": Object {},
83-
"packages": Object {},
84-
"yarn": Object {},
85-
},
86-
"user": Object {},
87-
},
88-
}
89-
`);
126+
Object {
127+
"bin": Object {
128+
"node": "shim-file-here",
129+
"npm": "shim-file-here",
130+
"npx": "shim-file-here",
131+
"shim": "shim-file-here",
132+
"yarn": "shim-file-here",
133+
},
134+
"cache": Object {
135+
"node": Object {},
136+
},
137+
"log": Object {},
138+
"tmp": Object {},
139+
"tools": Object {
140+
"image": Object {
141+
"node": Object {},
142+
"packages": Object {},
143+
"yarn": Object {},
144+
},
145+
"inventory": Object {
146+
"node": Object {},
147+
"packages": Object {},
148+
"yarn": Object {},
149+
},
150+
"user": Object {},
151+
},
152+
}
153+
`);
90154
});
91155
});
92156

src/installer.ts

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,46 @@ function voltaVersionHasSetup(version: string): boolean {
3939

4040
export async function buildDownloadUrl(
4141
platform: string,
42+
arch: string,
4243
version: string,
4344
openSSLVersion = ''
4445
): Promise<string> {
4546
let fileName: string;
46-
switch (platform) {
47-
case 'darwin':
48-
fileName = `volta-${version}-macos.tar.gz`;
49-
break;
50-
case 'linux': {
51-
openSSLVersion = await getOpenSSLVersion(openSSLVersion);
52-
53-
fileName = `volta-${version}-linux-${openSSLVersion}.tar.gz`;
54-
break;
47+
48+
const isOpenSSLDependent = semver.lt(version, '1.1.0');
49+
50+
if (isOpenSSLDependent) {
51+
switch (platform) {
52+
case 'darwin':
53+
fileName = `volta-${version}-macos.tar.gz`;
54+
break;
55+
case 'linux': {
56+
openSSLVersion = await getOpenSSLVersion(openSSLVersion);
57+
58+
fileName = `volta-${version}-linux-${openSSLVersion}.tar.gz`;
59+
break;
60+
}
61+
case 'win32':
62+
fileName = `volta-${version}-windows-x86_64.msi`;
63+
break;
64+
default:
65+
throw new Error(`your platform ${platform} is not yet supported`);
66+
}
67+
} else {
68+
switch (platform) {
69+
case 'darwin':
70+
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
71+
break;
72+
case 'linux': {
73+
fileName = `volta-${version}-linux.tar.gz`;
74+
break;
75+
}
76+
case 'win32':
77+
fileName = `volta-${version}-windows-x86_64.msi`;
78+
break;
79+
default:
80+
throw new Error(`your platform ${platform} is not yet supported`);
5581
}
56-
case 'win32':
57-
fileName = `volta-${version}-windows-x86_64.msi`;
58-
break;
59-
default:
60-
throw new Error(`your platform ${platform} is not yet supported`);
6182
}
6283

6384
return `https://github.com/volta-cli/volta/releases/download/v${version}/${fileName}`;
@@ -166,7 +187,7 @@ async function acquireVolta(
166187

167188
core.info(`downloading volta@${version}`);
168189

169-
const downloadUrl = await buildDownloadUrl(os.platform(), version, openSSLVersion);
190+
const downloadUrl = await buildDownloadUrl(os.platform(), os.arch(), version, openSSLVersion);
170191

171192
core.debug(`downloading from \`${downloadUrl}\``);
172193
const downloadPath = await tc.downloadTool(downloadUrl, undefined, authToken);

0 commit comments

Comments
 (0)