@volcano.dev/cli 0.39.1 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/volcano.js +4 -6
- package/package.json +1 -1
- package/scripts/npm/download.js +1 -0
- package/scripts/npm/download.test.js +12 -4
package/bin/volcano.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const { spawn } = require('child_process');
|
|
11
|
-
const { binaryPath, ensureBinary } = require('../scripts/npm/download.js');
|
|
11
|
+
const { assetName, binaryPath, ensureBinary } = require('../scripts/npm/download.js');
|
|
12
12
|
|
|
13
13
|
async function resolveBinary() {
|
|
14
14
|
try {
|
|
@@ -18,12 +18,10 @@ async function resolveBinary() {
|
|
|
18
18
|
}
|
|
19
19
|
return await ensureBinary();
|
|
20
20
|
} catch (err) {
|
|
21
|
-
// Covers
|
|
22
|
-
// resolveTarget() throws for e.g. Windows arm64, which passes the
|
|
23
|
-
// package.json os/cpu gate but has no published binary.
|
|
21
|
+
// Covers download failures and unsupported platforms.
|
|
24
22
|
console.error(`volcano: could not obtain the CLI binary: ${err.message}`);
|
|
25
|
-
const manual = process.platform === 'win32'
|
|
26
|
-
?
|
|
23
|
+
const manual = process.platform === 'win32' && ['x64', 'arm64'].includes(process.arch)
|
|
24
|
+
? `https://download.volcano.dev/builds/releases/latest/download/${assetName()}`
|
|
27
25
|
: 'https://download.volcano.dev/builds/install.sh';
|
|
28
26
|
console.error(`Install it manually from ${manual} or re-install the package.`);
|
|
29
27
|
process.exit(1);
|
package/package.json
CHANGED
package/scripts/npm/download.js
CHANGED
|
@@ -12,6 +12,7 @@ test('maps supported Node platforms to published release assets', () => {
|
|
|
12
12
|
['darwin', 'x64', 'volcano-macos-amd64'],
|
|
13
13
|
['darwin', 'arm64', 'volcano-macos-arm64'],
|
|
14
14
|
['win32', 'x64', 'volcano-windows-amd64.exe'],
|
|
15
|
+
['win32', 'arm64', 'volcano-windows-arm64.exe'],
|
|
15
16
|
];
|
|
16
17
|
|
|
17
18
|
for (const [platform, arch, expected] of cases) {
|
|
@@ -20,7 +21,7 @@ test('maps supported Node platforms to published release assets', () => {
|
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
test('rejects a platform without a published release asset', () => {
|
|
23
|
-
assert.throws(() => assetName('win32', '
|
|
24
|
+
assert.throws(() => assetName('win32', 'ia32'), /Unsupported platform "win32-ia32"/);
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
const fs = require('node:fs');
|
|
@@ -30,15 +31,20 @@ const http = require('node:http');
|
|
|
30
31
|
const crypto = require('node:crypto');
|
|
31
32
|
const { spawn } = require('node:child_process');
|
|
32
33
|
|
|
33
|
-
for (const corrupt of [
|
|
34
|
-
|
|
34
|
+
for (const [platform, arch, corrupt] of [
|
|
35
|
+
[process.platform, process.arch, false],
|
|
36
|
+
[process.platform, process.arch, true],
|
|
37
|
+
['win32', 'arm64', false],
|
|
38
|
+
['win32', 'arm64', true],
|
|
39
|
+
]) {
|
|
40
|
+
test(`${platform}-${arch} first-party download ${corrupt ? 'preserves the installed binary on checksum failure' : 'installs without GitHub'}`, async (t) => {
|
|
35
41
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'volcano-npm-'));
|
|
36
42
|
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
37
43
|
fs.mkdirSync(path.join(root, 'scripts/npm'), { recursive: true });
|
|
38
44
|
fs.mkdirSync(path.join(root, 'bin'));
|
|
39
45
|
fs.copyFileSync(path.join(__dirname, 'download.js'), path.join(root, 'scripts/npm/download.js'));
|
|
40
46
|
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ version: '1.2.3' }));
|
|
41
|
-
const name = assetName();
|
|
47
|
+
const name = assetName(platform, arch);
|
|
42
48
|
const dest = path.join(root, 'bin', name);
|
|
43
49
|
fs.writeFileSync(dest, 'old binary');
|
|
44
50
|
const payload = 'new binary';
|
|
@@ -54,6 +60,8 @@ for (const corrupt of [false, true]) {
|
|
|
54
60
|
t.after(() => new Promise(resolve => server.close(resolve)));
|
|
55
61
|
// Intercept only the first-party host. A GitHub dependency fails the test.
|
|
56
62
|
const script = `
|
|
63
|
+
Object.defineProperty(process, 'platform', { value: ${JSON.stringify(platform)} });
|
|
64
|
+
Object.defineProperty(process, 'arch', { value: ${JSON.stringify(arch)} });
|
|
57
65
|
require('https').get = (url, options, callback) => {
|
|
58
66
|
const parsed = new URL(url);
|
|
59
67
|
if (parsed.origin !== 'https://download.volcano.dev') throw Error('unexpected host: ' + parsed.origin);
|