@volcengine/cli 1.0.39
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/ve +3 -0
- package/install.js +117 -0
- package/package.json +36 -0
package/bin/ve
ADDED
package/install.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
8
|
+
const VERSION = "1.0.39";
|
|
9
|
+
const BASE_URL = `https://github.com/volcengine/volcengine-cli/releases/download/v${VERSION}`;
|
|
10
|
+
|
|
11
|
+
const PLATFORM_MAP = {
|
|
12
|
+
darwin: "darwin",
|
|
13
|
+
linux: "linux",
|
|
14
|
+
win32: "windows",
|
|
15
|
+
freebsd: "freebsd",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ARCH_MAP = {
|
|
19
|
+
x64: "amd64",
|
|
20
|
+
arm64: "arm64",
|
|
21
|
+
ia32: "386",
|
|
22
|
+
arm: "arm",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const platform = PLATFORM_MAP[process.platform];
|
|
26
|
+
const arch = ARCH_MAP[process.arch];
|
|
27
|
+
|
|
28
|
+
if (!platform || !arch) {
|
|
29
|
+
console.error(`Unsupported platform: ${process.platform} ${process.arch}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const zipName = `volcengine-cli_${VERSION}_${platform}_${arch}.zip`;
|
|
34
|
+
const url = `${BASE_URL}/${zipName}`;
|
|
35
|
+
|
|
36
|
+
const binDir = path.join(__dirname, "bin");
|
|
37
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
38
|
+
|
|
39
|
+
const isWindows = process.platform === "win32";
|
|
40
|
+
const binaryName = isWindows ? "ve.exe" : "ve";
|
|
41
|
+
const binPath = path.join(binDir, binaryName);
|
|
42
|
+
|
|
43
|
+
function download(url) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const follow = (url) => {
|
|
46
|
+
https.get(url, (res) => {
|
|
47
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
48
|
+
follow(res.headers.location);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (res.statusCode !== 200) {
|
|
52
|
+
reject(new Error(`Download failed: HTTP ${res.statusCode} for ${url}`));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const chunks = [];
|
|
56
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
57
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
58
|
+
res.on("error", reject);
|
|
59
|
+
}).on("error", reject);
|
|
60
|
+
};
|
|
61
|
+
follow(url);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function install() {
|
|
66
|
+
console.log(`Downloading ${zipName}...`);
|
|
67
|
+
|
|
68
|
+
const data = await download(url);
|
|
69
|
+
const tmpDir = path.join(__dirname, ".tmp");
|
|
70
|
+
const zipPath = path.join(tmpDir, zipName);
|
|
71
|
+
|
|
72
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
73
|
+
fs.writeFileSync(zipPath, data);
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
if (isWindows) {
|
|
77
|
+
execSync(
|
|
78
|
+
`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${tmpDir}' -Force"`,
|
|
79
|
+
{ stdio: "pipe" }
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
execSync(`unzip -o -q "${zipPath}" -d "${tmpDir}"`, { stdio: "pipe" });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const extracted = fs.readdirSync(tmpDir);
|
|
86
|
+
const veBinary = extracted.find((f) => f === "ve" || f === "ve.exe");
|
|
87
|
+
|
|
88
|
+
if (!veBinary) {
|
|
89
|
+
console.error("Could not find 've' binary in zip archive. Found:", extracted);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fs.copyFileSync(path.join(tmpDir, veBinary), binPath);
|
|
94
|
+
|
|
95
|
+
if (!isWindows) {
|
|
96
|
+
fs.chmodSync(binPath, 0o755);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// macOS: remove quarantine attribute to avoid Gatekeeper blocking
|
|
100
|
+
if (process.platform === "darwin") {
|
|
101
|
+
try {
|
|
102
|
+
execSync(`xattr -d com.apple.quarantine "${binPath}"`, { stdio: "pipe" });
|
|
103
|
+
} catch (_) {
|
|
104
|
+
// Attribute may not exist, ignore
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log(`Volcengine CLI v${VERSION} installed for ${platform}/${arch}`);
|
|
109
|
+
} finally {
|
|
110
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
install().catch((err) => {
|
|
115
|
+
console.error("Installation failed:", err.message);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volcengine/cli",
|
|
3
|
+
"version": "1.0.39",
|
|
4
|
+
"description": "Volcengine CLI - 火山引擎命令行工具",
|
|
5
|
+
"bin": {
|
|
6
|
+
"ve": "bin/ve"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prepack": "node -e \"require('fs').writeFileSync('bin/ve','#!/bin/sh\\necho ve not installed. Run npm rebuild @volcengine/cli >&2\\nexit 1\\n');require('fs').chmodSync('bin/ve',0o755)\"",
|
|
10
|
+
"postinstall": "node install.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"install.js"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"volcengine",
|
|
18
|
+
"cli",
|
|
19
|
+
"cloud",
|
|
20
|
+
"火山引擎"
|
|
21
|
+
],
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/volcengine/volcengine-cli"
|
|
26
|
+
},
|
|
27
|
+
"os": [
|
|
28
|
+
"darwin",
|
|
29
|
+
"linux",
|
|
30
|
+
"win32",
|
|
31
|
+
"freebsd"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=14"
|
|
35
|
+
}
|
|
36
|
+
}
|