@volcano.dev/cli 0.34.3 → 0.35.1

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/README.md CHANGED
@@ -38,7 +38,7 @@ volcano --help
38
38
  Or install manually:
39
39
 
40
40
  ```bash
41
- curl -fsSL https://github.com/Kong/volcano-cli/releases/latest/download/install.sh | bash
41
+ curl -fsSL https://github.com/Kong/volcano-cli/releases/latest/download/install.sh | sh
42
42
  volcano --help
43
43
  ```
44
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcano.dev/cli",
3
- "version": "0.34.3",
3
+ "version": "0.35.1",
4
4
  "description": "CLI for Volcano's hosting platform.",
5
5
  "keywords": [
6
6
  "volcano",
@@ -32,8 +32,8 @@ const TARGETS = {
32
32
  'win32-x64': 'windows-amd64',
33
33
  };
34
34
 
35
- function resolveTarget() {
36
- const key = `${process.platform}-${process.arch}`;
35
+ function resolveTarget(platform = process.platform, arch = process.arch) {
36
+ const key = `${platform}-${arch}`;
37
37
  const target = TARGETS[key];
38
38
  if (!target) {
39
39
  throw new Error(
@@ -44,12 +44,12 @@ function resolveTarget() {
44
44
  return target;
45
45
  }
46
46
 
47
- function binaryExt() {
48
- return process.platform === 'win32' ? '.exe' : '';
47
+ function binaryExt(platform = process.platform) {
48
+ return platform === 'win32' ? '.exe' : '';
49
49
  }
50
50
 
51
- function assetName() {
52
- return `volcano-${resolveTarget()}${binaryExt()}`;
51
+ function assetName(platform = process.platform, arch = process.arch) {
52
+ return `volcano-${resolveTarget(platform, arch)}${binaryExt(platform)}`;
53
53
  }
54
54
 
55
55
  // Absolute path where the downloaded binary lives (next to the launcher shim).
@@ -218,6 +218,7 @@ async function ensureBinary({ force = false } = {}) {
218
218
 
219
219
  module.exports = {
220
220
  resolveTarget,
221
+ binaryExt,
221
222
  assetName,
222
223
  binaryPath,
223
224
  releaseTag,
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const assert = require('node:assert/strict');
4
+ const test = require('node:test');
5
+
6
+ const { assetName } = require('./download.js');
7
+
8
+ test('maps supported Node platforms to published release assets', () => {
9
+ const cases = [
10
+ ['linux', 'x64', 'volcano-linux-amd64'],
11
+ ['linux', 'arm64', 'volcano-linux-arm64'],
12
+ ['darwin', 'x64', 'volcano-macos-amd64'],
13
+ ['darwin', 'arm64', 'volcano-macos-arm64'],
14
+ ['win32', 'x64', 'volcano-windows-amd64.exe'],
15
+ ];
16
+
17
+ for (const [platform, arch, expected] of cases) {
18
+ assert.equal(assetName(platform, arch), expected);
19
+ }
20
+ });
21
+
22
+ test('rejects a platform without a published release asset', () => {
23
+ assert.throws(() => assetName('win32', 'arm64'), /Unsupported platform "win32-arm64"/);
24
+ });