Skip to content

Commit f313bfc

Browse files
author
Robert Jackson
committed
[BACKPORT] Add [email protected] support to v1.x release
This is basically a cherry-pick of 069b85c, but done manually.
1 parent 76620aa commit f313bfc

File tree

3 files changed

+132
-61
lines changed

3 files changed

+132
-61
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: 96 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,78 @@ import { buildLayout, buildDownloadUrl } from './installer';
22
import { createTempDir } from 'broccoli-test-helper';
33

44
describe('buildDownloadUrl', () => {
5-
test('darwin', function () {
6-
expect(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', function () {
12-
expect(buildDownloadUrl('linux', '0.6.4')).toMatchInlineSnapshot(
13-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
14-
);
15-
});
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(await buildDownloadUrl('linux', 'x64', '0.6.4')).toMatchInlineSnapshot(
20+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
21+
);
22+
});
23+
24+
test('win32', async function () {
25+
expect(await buildDownloadUrl('win32', 'x86-64', '0.7.2')).toMatchInlineSnapshot(
26+
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
27+
);
28+
});
1629

17-
test('win32', function () {
18-
expect(buildDownloadUrl('win32', '0.7.2')).toMatchInlineSnapshot(
19-
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
20-
);
30+
test('aix', async function () {
31+
expect(
32+
async () =>
33+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '0.6.4')
34+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
35+
});
2136
});
2237

23-
test('aix', function () {
24-
expect(() => buildDownloadUrl('aix', '0.6.4')).toThrowErrorMatchingInlineSnapshot(
25-
`"your platform aix is not yet supported"`
26-
);
38+
describe('[email protected]', function () {
39+
test('darwin - x64', async function () {
40+
expect(await buildDownloadUrl('darwin', 'x64', '1.1.0')).toMatchInlineSnapshot(
41+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos.tar.gz"`
42+
);
43+
});
44+
45+
test('darwin - arm64', async function () {
46+
expect(await buildDownloadUrl('darwin', 'arm64', '1.1.0')).toMatchInlineSnapshot(
47+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos-aarch64.tar.gz"`
48+
);
49+
});
50+
51+
test('linux', async function () {
52+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0')).toMatchInlineSnapshot(
53+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
54+
);
55+
56+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0')).toMatchInlineSnapshot(
57+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
58+
);
59+
60+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0')).toMatchInlineSnapshot(
61+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
62+
);
63+
});
64+
65+
test('win32', async function () {
66+
expect(await buildDownloadUrl('win32', 'x86-64', '1.1.0')).toMatchInlineSnapshot(
67+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-windows-x86_64.msi"`
68+
);
69+
});
70+
71+
test('aix', async function () {
72+
expect(
73+
async () =>
74+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '1.1.0')
75+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
76+
});
2777
});
2878
});
2979

@@ -40,33 +90,33 @@ describe('buildLayout', () => {
4090
await buildLayout(tmpdir.path());
4191

4292
expect(tmpdir.read()).toMatchInlineSnapshot(`
43-
Object {
44-
"bin": Object {
45-
"node": "shim-file-here",
46-
"npm": "shim-file-here",
47-
"npx": "shim-file-here",
48-
"shim": "shim-file-here",
49-
"yarn": "shim-file-here",
50-
},
51-
"cache": Object {
52-
"node": Object {},
53-
},
54-
"log": Object {},
55-
"tmp": Object {},
56-
"tools": Object {
57-
"image": Object {
58-
"node": Object {},
59-
"packages": Object {},
60-
"yarn": Object {},
61-
},
62-
"inventory": Object {
63-
"node": Object {},
64-
"packages": Object {},
65-
"yarn": Object {},
66-
},
67-
"user": Object {},
68-
},
69-
}
70-
`);
93+
Object {
94+
"bin": Object {
95+
"node": "shim-file-here",
96+
"npm": "shim-file-here",
97+
"npx": "shim-file-here",
98+
"shim": "shim-file-here",
99+
"yarn": "shim-file-here",
100+
},
101+
"cache": Object {
102+
"node": Object {},
103+
},
104+
"log": Object {},
105+
"tmp": Object {},
106+
"tools": Object {
107+
"image": Object {
108+
"node": Object {},
109+
"packages": Object {},
110+
"yarn": Object {},
111+
},
112+
"inventory": Object {
113+
"node": Object {},
114+
"packages": Object {},
115+
"yarn": Object {},
116+
},
117+
"user": Object {},
118+
},
119+
}
120+
`);
71121
});
72122
});

src/installer.ts

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,41 @@ function voltaVersionHasSetup(version: string): boolean {
2121
return semver.gte(version, '0.7.0');
2222
}
2323

24-
export function buildDownloadUrl(platform: string, version: string): string {
24+
export function buildDownloadUrl(platform: string, arch: string, version: string): string {
2525
let fileName: string;
26-
switch (platform) {
27-
case 'darwin':
28-
fileName = `volta-${version}-macos.tar.gz`;
29-
break;
30-
case 'linux':
31-
fileName = `volta-${version}-linux-openssl-1.1.tar.gz`;
32-
break;
33-
case 'win32':
34-
fileName = `volta-${version}-windows-x86_64.msi`;
35-
break;
36-
default:
37-
throw new Error(`your platform ${platform} is not yet supported`);
26+
27+
const isOpenSSLDependent = semver.lt(version, '1.1.0');
28+
29+
if (isOpenSSLDependent) {
30+
switch (platform) {
31+
case 'darwin':
32+
fileName = `volta-${version}-macos.tar.gz`;
33+
break;
34+
case 'linux': {
35+
fileName = `volta-${version}-linux-openssl-1.1.tar.gz`;
36+
break;
37+
}
38+
case 'win32':
39+
fileName = `volta-${version}-windows-x86_64.msi`;
40+
break;
41+
default:
42+
throw new Error(`your platform ${platform} is not yet supported`);
43+
}
44+
} else {
45+
switch (platform) {
46+
case 'darwin':
47+
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
48+
break;
49+
case 'linux': {
50+
fileName = `volta-${version}-linux.tar.gz`;
51+
break;
52+
}
53+
case 'win32':
54+
fileName = `volta-${version}-windows-x86_64.msi`;
55+
break;
56+
default:
57+
throw new Error(`your platform ${platform} is not yet supported`);
58+
}
3859
}
3960

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

96117
core.info(`downloading volta@${version}`);
97118

98-
const downloadUrl = buildDownloadUrl(os.platform(), version);
119+
const downloadUrl = await buildDownloadUrl(os.platform(), os.arch(), version);
99120

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

0 commit comments

Comments
 (0)