Skip to content

Commit 636de17

Browse files
author
Robert Jackson
committed
[BACKPORT] Add [email protected] support to v2.x release
This is basically a cherry-pick of 069b85c, but done manually.
1 parent 03f1c13 commit 636de17

File tree

3 files changed

+145
-70
lines changed

3 files changed

+145
-70
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38-
volta-version: ["0.9.0","0.8.7","0.7.2","0.6.8"]
38+
volta-version: ["0.9.0","0.8.7","0.7.2","0.6.8", "1.1.0"]
3939
os: [ubuntu, macOS, windows]
4040
exclude:
4141
# this action didn't support windows until at least Volta 0.7

src/installer.test.ts

Lines changed: 108 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,90 @@ import { buildLayout, buildDownloadUrl } from './installer';
22
import { createTempDir } from 'broccoli-test-helper';
33

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

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

25-
test('win32', async function () {
26-
expect(await buildDownloadUrl('win32', '0.7.2')).toMatchInlineSnapshot(
27-
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
28-
);
25+
expect(
26+
await buildDownloadUrl('linux', 'x64', '0.6.4', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
27+
).toMatchInlineSnapshot(
28+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
29+
);
30+
});
31+
32+
test('win32', async function () {
33+
expect(await buildDownloadUrl('win32', 'x86-64', '0.7.2')).toMatchInlineSnapshot(
34+
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
35+
);
36+
});
37+
38+
test('aix', async function () {
39+
expect(
40+
async () =>
41+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '0.6.4')
42+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
43+
});
2944
});
3045

31-
test('aix', async function () {
32-
expect(
33-
async () => await buildDownloadUrl('aix', '0.6.4')
34-
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
46+
describe('[email protected]', function () {
47+
test('darwin - x64', async function () {
48+
expect(await buildDownloadUrl('darwin', 'x64', '1.1.0')).toMatchInlineSnapshot(
49+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos.tar.gz"`
50+
);
51+
});
52+
53+
test('darwin - arm64', async function () {
54+
expect(await buildDownloadUrl('darwin', 'arm64', '1.1.0')).toMatchInlineSnapshot(
55+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos-aarch64.tar.gz"`
56+
);
57+
});
58+
59+
test('linux', async function () {
60+
expect(
61+
await buildDownloadUrl('linux', 'x64', '1.1.0', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
62+
).toMatchInlineSnapshot(
63+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
64+
);
65+
66+
expect(
67+
await buildDownloadUrl('linux', 'x64', '1.1.0', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
68+
).toMatchInlineSnapshot(
69+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
70+
);
71+
72+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0')).toMatchInlineSnapshot(
73+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
74+
);
75+
});
76+
77+
test('win32', async function () {
78+
expect(await buildDownloadUrl('win32', 'x86-64', '1.1.0')).toMatchInlineSnapshot(
79+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-windows-x86_64.msi"`
80+
);
81+
});
82+
83+
test('aix', async function () {
84+
expect(
85+
async () =>
86+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '1.1.0')
87+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
88+
});
3589
});
3690
});
3791

@@ -48,33 +102,33 @@ describe('buildLayout', () => {
48102
await buildLayout(tmpdir.path());
49103

50104
expect(tmpdir.read()).toMatchInlineSnapshot(`
51-
Object {
52-
"bin": Object {
53-
"node": "shim-file-here",
54-
"npm": "shim-file-here",
55-
"npx": "shim-file-here",
56-
"shim": "shim-file-here",
57-
"yarn": "shim-file-here",
58-
},
59-
"cache": Object {
60-
"node": Object {},
61-
},
62-
"log": Object {},
63-
"tmp": Object {},
64-
"tools": Object {
65-
"image": Object {
66-
"node": Object {},
67-
"packages": Object {},
68-
"yarn": Object {},
69-
},
70-
"inventory": Object {
71-
"node": Object {},
72-
"packages": Object {},
73-
"yarn": Object {},
74-
},
75-
"user": Object {},
76-
},
77-
}
78-
`);
105+
Object {
106+
"bin": Object {
107+
"node": "shim-file-here",
108+
"npm": "shim-file-here",
109+
"npx": "shim-file-here",
110+
"shim": "shim-file-here",
111+
"yarn": "shim-file-here",
112+
},
113+
"cache": Object {
114+
"node": Object {},
115+
},
116+
"log": Object {},
117+
"tmp": Object {},
118+
"tools": Object {
119+
"image": Object {
120+
"node": Object {},
121+
"packages": Object {},
122+
"yarn": Object {},
123+
},
124+
"inventory": Object {
125+
"node": Object {},
126+
"packages": Object {},
127+
"yarn": Object {},
128+
},
129+
"user": Object {},
130+
},
131+
}
132+
`);
79133
});
80134
});

src/installer.ts

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

2424
export async function buildDownloadUrl(
2525
platform: string,
26+
arch: string,
2627
version: string,
2728
openSSLVersion = ''
2829
): Promise<string> {
2930
let fileName: string;
30-
switch (platform) {
31-
case 'darwin':
32-
fileName = `volta-${version}-macos.tar.gz`;
33-
break;
34-
case 'linux': {
35-
openSSLVersion = await getOpenSSLVersion(openSSLVersion);
36-
37-
fileName = `volta-${version}-linux-${openSSLVersion}.tar.gz`;
38-
break;
31+
32+
const isOpenSSLDependent = semver.lt(version, '1.1.0');
33+
34+
if (isOpenSSLDependent) {
35+
switch (platform) {
36+
case 'darwin':
37+
fileName = `volta-${version}-macos.tar.gz`;
38+
break;
39+
case 'linux': {
40+
openSSLVersion = await getOpenSSLVersion(openSSLVersion);
41+
42+
fileName = `volta-${version}-linux-${openSSLVersion}.tar.gz`;
43+
break;
44+
}
45+
case 'win32':
46+
fileName = `volta-${version}-windows-x86_64.msi`;
47+
break;
48+
default:
49+
throw new Error(`your platform ${platform} is not yet supported`);
50+
}
51+
} else {
52+
switch (platform) {
53+
case 'darwin':
54+
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
55+
break;
56+
case 'linux': {
57+
fileName = `volta-${version}-linux.tar.gz`;
58+
break;
59+
}
60+
case 'win32':
61+
fileName = `volta-${version}-windows-x86_64.msi`;
62+
break;
63+
default:
64+
throw new Error(`your platform ${platform} is not yet supported`);
3965
}
40-
case 'win32':
41-
fileName = `volta-${version}-windows-x86_64.msi`;
42-
break;
43-
default:
44-
throw new Error(`your platform ${platform} is not yet supported`);
4566
}
4667

4768
return `https://github.com/volta-cli/volta/releases/download/v${version}/${fileName}`;
@@ -138,7 +159,7 @@ async function acquireVolta(version: string): Promise<string> {
138159

139160
core.info(`downloading volta@${version}`);
140161

141-
const downloadUrl = await buildDownloadUrl(os.platform(), version);
162+
const downloadUrl = await buildDownloadUrl(os.platform(), os.arch(), version);
142163

143164
core.debug(`downloading from \`${downloadUrl}\``);
144165
const downloadPath = await tc.downloadTool(downloadUrl);

0 commit comments

Comments
 (0)