@volcengine/ark-cli 1.0.0 → 1.0.2
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/manifest.json +41 -17
- package/package.json +1 -1
- package/scripts/postinstall.js +66 -28
package/manifest.json
CHANGED
|
@@ -1,40 +1,64 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.2",
|
|
3
3
|
"platforms": {
|
|
4
4
|
"darwin-amd64": {
|
|
5
|
-
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.
|
|
6
|
-
"sha256": "
|
|
5
|
+
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.2/arkcli-1.0.2-darwin-amd64",
|
|
6
|
+
"sha256": "ba7e088f5c2617b52de00c3b3017ee460ce56288ff654a4badbe7561d800136e",
|
|
7
|
+
"fallback": {
|
|
8
|
+
"url": "https://github.com/volcengine/ark-cli/releases/download/v1.0.2/arkcli-1.0.2-darwin-amd64",
|
|
9
|
+
"kind": "github-release"
|
|
10
|
+
}
|
|
7
11
|
},
|
|
8
12
|
"darwin-arm64": {
|
|
9
|
-
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.
|
|
10
|
-
"sha256": "
|
|
13
|
+
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.2/arkcli-1.0.2-darwin-arm64",
|
|
14
|
+
"sha256": "32e4b560dc7a3ba9f5247e18e7359d1a050fbd4412cf75afcef9d98ed619c990",
|
|
15
|
+
"fallback": {
|
|
16
|
+
"url": "https://github.com/volcengine/ark-cli/releases/download/v1.0.2/arkcli-1.0.2-darwin-arm64",
|
|
17
|
+
"kind": "github-release"
|
|
18
|
+
}
|
|
11
19
|
},
|
|
12
20
|
"linux-amd64": {
|
|
13
|
-
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.
|
|
14
|
-
"sha256": "
|
|
21
|
+
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.2/arkcli-1.0.2-linux-amd64",
|
|
22
|
+
"sha256": "2eb1630e5d90f3a572a8bf190a5dbe212435789d9456fcdb2cee029dc50ef476",
|
|
23
|
+
"fallback": {
|
|
24
|
+
"url": "https://github.com/volcengine/ark-cli/releases/download/v1.0.2/arkcli-1.0.2-linux-amd64",
|
|
25
|
+
"kind": "github-release"
|
|
26
|
+
}
|
|
15
27
|
},
|
|
16
28
|
"linux-arm64": {
|
|
17
|
-
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.
|
|
18
|
-
"sha256": "
|
|
29
|
+
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.2/arkcli-1.0.2-linux-arm64",
|
|
30
|
+
"sha256": "b79b92878ba0ebe81b48f15a7b3f6be69cf22de4c84799ef921f075f11be2eae",
|
|
31
|
+
"fallback": {
|
|
32
|
+
"url": "https://github.com/volcengine/ark-cli/releases/download/v1.0.2/arkcli-1.0.2-linux-arm64",
|
|
33
|
+
"kind": "github-release"
|
|
34
|
+
}
|
|
19
35
|
},
|
|
20
36
|
"windows-amd64": {
|
|
21
|
-
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.
|
|
22
|
-
"sha256": "
|
|
37
|
+
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.2/arkcli-1.0.2-windows-amd64.exe",
|
|
38
|
+
"sha256": "c41b597ec6aedca8bfcc5ddc7e2862d26142e5bb83eed63715a23371666602c0",
|
|
39
|
+
"fallback": {
|
|
40
|
+
"url": "https://github.com/volcengine/ark-cli/releases/download/v1.0.2/arkcli-1.0.2-windows-amd64.exe",
|
|
41
|
+
"kind": "github-release"
|
|
42
|
+
}
|
|
23
43
|
},
|
|
24
44
|
"windows-arm64": {
|
|
25
|
-
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.
|
|
26
|
-
"sha256": "
|
|
45
|
+
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.2/arkcli-1.0.2-windows-arm64.exe",
|
|
46
|
+
"sha256": "e8e15cda610bf0ac6697e9226f629af537a0540f66d528834496900e6b61bc6c",
|
|
47
|
+
"fallback": {
|
|
48
|
+
"url": "https://github.com/volcengine/ark-cli/releases/download/v1.0.2/arkcli-1.0.2-windows-arm64.exe",
|
|
49
|
+
"kind": "github-release"
|
|
50
|
+
}
|
|
27
51
|
}
|
|
28
52
|
},
|
|
29
53
|
"skills": {
|
|
30
54
|
"primary": {
|
|
31
|
-
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.
|
|
32
|
-
"sha256": "
|
|
55
|
+
"url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prod/1.0.2/skills.tar.gz",
|
|
56
|
+
"sha256": "08ef3ddf5a8168b93d8623748a6c887b83f514448e10789fa3b6ee95fc509fa0",
|
|
33
57
|
"kind": "cdn"
|
|
34
58
|
},
|
|
35
|
-
"tag": "v1.0.
|
|
59
|
+
"tag": "v1.0.2",
|
|
36
60
|
"fallback": {
|
|
37
|
-
"url": "https://github.com/volcengine/ark-cli/archive/refs/tags/v1.0.
|
|
61
|
+
"url": "https://github.com/volcengine/ark-cli/archive/refs/tags/v1.0.2.tar.gz",
|
|
38
62
|
"kind": "github"
|
|
39
63
|
}
|
|
40
64
|
}
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @volcengine/ark-cli postinstall。
|
|
3
3
|
// 由 npm 的 postinstall lifecycle 触发:读 manifest.json,按当前平台从 CDN 下载
|
|
4
|
-
//
|
|
4
|
+
// 对应二进制;稳定版 CDN 失败时回退 GitHub Release asset。下载后统一校验
|
|
5
|
+
// manifest 里的 sha256,落到 <pkg>/bin/,然后(非 CI 时)调 `arkcli +connect
|
|
5
6
|
// --refresh` —— 由二进制【收口的 Go 实现】下载最新 skill 到 <pkg>/skills/ 再装进
|
|
6
7
|
// 各 agent。skill 的下载/解压/校验逻辑不再在本脚本维护(避免 node / Go 两份),
|
|
7
8
|
// 与用户手动 `arkcli +connect --refresh` 重装/刷新【共用同一份实现】。
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
// - 二进制不内嵌,运行时从 CDN 按平台下载
|
|
13
14
|
//
|
|
14
15
|
// 失败策略:
|
|
15
|
-
// - 下载/校验二进制 =
|
|
16
|
+
// - 下载/校验二进制 = 核心,所有源失败则 exit 1(没有二进制这个包不可用,fail loud)
|
|
16
17
|
// - +connect --refresh(下 skill + 装 agent) = 增强,失败仅告警,不影响安装结果(exit 0)
|
|
17
18
|
|
|
18
19
|
const fs = require("fs");
|
|
@@ -55,7 +56,11 @@ try {
|
|
|
55
56
|
|
|
56
57
|
const entry = manifest.platforms && manifest.platforms[key];
|
|
57
58
|
if (!entry || !entry.url) {
|
|
58
|
-
console.error(`@volcengine/ark-cli: no
|
|
59
|
+
console.error(`@volcengine/ark-cli: no binary entry for platform ${key} in manifest`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
if (!/^[0-9a-f]{64}$/i.test(entry.sha256 || "")) {
|
|
63
|
+
console.error(`@volcengine/ark-cli: missing or malformed sha256 for platform ${key}`);
|
|
59
64
|
process.exit(1);
|
|
60
65
|
}
|
|
61
66
|
|
|
@@ -66,31 +71,38 @@ function httpMod(url) {
|
|
|
66
71
|
return url.startsWith("http://") ? http : https;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
// 下载到临时文件,跟随 3xx 重定向(CDN 边缘常有跳转)。
|
|
74
|
+
// 下载到临时文件,跟随 3xx 重定向(CDN/GitHub 边缘常有跳转)。
|
|
70
75
|
function download(url, dest, redirects = 0) {
|
|
71
76
|
return new Promise((resolve, reject) => {
|
|
72
77
|
if (redirects > 5) return reject(new Error("too many redirects"));
|
|
73
|
-
const file = fs.createWriteStream(dest);
|
|
74
78
|
const req = httpMod(url).get(url, (res) => {
|
|
75
79
|
if (
|
|
76
80
|
res.statusCode >= 300 &&
|
|
77
81
|
res.statusCode < 400 &&
|
|
78
82
|
res.headers.location
|
|
79
83
|
) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return resolve(download(
|
|
84
|
+
res.resume();
|
|
85
|
+
const nextURL = new URL(res.headers.location, url).toString();
|
|
86
|
+
return resolve(download(nextURL, dest, redirects + 1));
|
|
83
87
|
}
|
|
84
88
|
if (res.statusCode !== 200) {
|
|
85
|
-
|
|
86
|
-
fs.rmSync(dest, { force: true });
|
|
89
|
+
res.resume();
|
|
87
90
|
return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
88
91
|
}
|
|
92
|
+
const file = fs.createWriteStream(dest);
|
|
93
|
+
file.on("error", (err) => {
|
|
94
|
+
fs.rmSync(dest, { force: true });
|
|
95
|
+
reject(err);
|
|
96
|
+
});
|
|
97
|
+
res.on("error", (err) => {
|
|
98
|
+
file.close();
|
|
99
|
+
fs.rmSync(dest, { force: true });
|
|
100
|
+
reject(err);
|
|
101
|
+
});
|
|
89
102
|
res.pipe(file);
|
|
90
103
|
file.on("finish", () => file.close(() => resolve()));
|
|
91
104
|
});
|
|
92
105
|
req.on("error", (err) => {
|
|
93
|
-
file.close();
|
|
94
106
|
fs.rmSync(dest, { force: true });
|
|
95
107
|
reject(err);
|
|
96
108
|
});
|
|
@@ -101,38 +113,64 @@ function sha256(file) {
|
|
|
101
113
|
return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
|
102
114
|
}
|
|
103
115
|
|
|
116
|
+
function binarySources(entry) {
|
|
117
|
+
const sources = [{ kind: entry.kind || "cdn", url: entry.url }];
|
|
118
|
+
if (entry.fallback && entry.fallback.url) {
|
|
119
|
+
sources.push({
|
|
120
|
+
kind: entry.fallback.kind || "fallback",
|
|
121
|
+
url: entry.fallback.url,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return sources;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function downloadVerifiedBinary(sources, dest, expectedSHA) {
|
|
128
|
+
const errors = [];
|
|
129
|
+
for (const src of sources) {
|
|
130
|
+
fs.rmSync(dest, { force: true });
|
|
131
|
+
try {
|
|
132
|
+
console.log(`@volcengine/ark-cli: downloading ${key} binary from ${src.kind}...`);
|
|
133
|
+
await download(src.url, dest);
|
|
134
|
+
if (expectedSHA) {
|
|
135
|
+
const actual = sha256(dest);
|
|
136
|
+
if (actual !== expectedSHA.toLowerCase()) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`sha256 mismatch\n expected ${expectedSHA}\n actual ${actual}`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return src;
|
|
143
|
+
} catch (err) {
|
|
144
|
+
fs.rmSync(dest, { force: true });
|
|
145
|
+
errors.push(`${src.kind}: ${err.message || err}`);
|
|
146
|
+
console.warn(
|
|
147
|
+
`@volcengine/ark-cli: ${src.kind} binary source failed: ${err.message || err}`,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
throw new Error(errors.join("; "));
|
|
152
|
+
}
|
|
153
|
+
|
|
104
154
|
(async () => {
|
|
105
155
|
fs.mkdirSync(binDir, { recursive: true });
|
|
106
156
|
const tmp = `${binPath}.download`;
|
|
107
157
|
|
|
158
|
+
let installedFrom;
|
|
108
159
|
try {
|
|
109
|
-
|
|
110
|
-
await download(entry.url, tmp);
|
|
160
|
+
installedFrom = await downloadVerifiedBinary(binarySources(entry), tmp, entry.sha256);
|
|
111
161
|
} catch (err) {
|
|
112
162
|
fs.rmSync(tmp, { force: true });
|
|
113
163
|
console.error(`@volcengine/ark-cli: download failed: ${err.message || err}`);
|
|
114
164
|
process.exit(1);
|
|
115
165
|
}
|
|
116
166
|
|
|
117
|
-
// sha256 完整性校验(烘焙时一定写入 entry.sha256)
|
|
118
|
-
if (entry.sha256) {
|
|
119
|
-
const actual = sha256(tmp);
|
|
120
|
-
if (actual !== entry.sha256) {
|
|
121
|
-
fs.rmSync(tmp, { force: true });
|
|
122
|
-
console.error(
|
|
123
|
-
`@volcengine/ark-cli: sha256 mismatch for ${key}\n` +
|
|
124
|
-
` expected ${entry.sha256}\n` +
|
|
125
|
-
` actual ${actual}`,
|
|
126
|
-
);
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
167
|
fs.renameSync(tmp, binPath);
|
|
132
168
|
if (platform !== "windows") {
|
|
133
169
|
fs.chmodSync(binPath, 0o755);
|
|
134
170
|
}
|
|
135
|
-
console.log(
|
|
171
|
+
console.log(
|
|
172
|
+
`@volcengine/ark-cli: installed ${path.basename(binPath)} from ${installedFrom.kind}`,
|
|
173
|
+
);
|
|
136
174
|
|
|
137
175
|
// CI 环境:不下 skill、不 +connect(无 agent 交互场景,且 CI 常无外网),直接收工。
|
|
138
176
|
if (process.env.CI === "true" || process.env.CI === "1") {
|