@volcengine/ark-cli 1.0.46-prerelease.1480a0328c60 → 1.0.46-prerelease.46bd0d6dcc58

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 CHANGED
@@ -1,37 +1,37 @@
1
1
  {
2
- "version": "1.0.46-prerelease.1480a0328c60",
2
+ "version": "1.0.46-prerelease.46bd0d6dcc58",
3
3
  "platforms": {
4
4
  "darwin-amd64": {
5
- "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.1480a0328c60/arkcli-1.0.46-prerelease.1480a0328c60-darwin-amd64",
6
- "sha256": "fa1d9449bee220d33c2594650c1f8d95836a0130d8720099dd22d5cd10cde351"
5
+ "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.46bd0d6dcc58/arkcli-1.0.46-prerelease.46bd0d6dcc58-darwin-amd64",
6
+ "sha256": "a15a2e1907422627fa031ea8be46e01446bc6b72ece0f03558a6b88c62598599"
7
7
  },
8
8
  "darwin-arm64": {
9
- "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.1480a0328c60/arkcli-1.0.46-prerelease.1480a0328c60-darwin-arm64",
10
- "sha256": "122cee5055659487441bf5ece7449049754a10e24b5311e23db63fa3c88e60cb"
9
+ "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.46bd0d6dcc58/arkcli-1.0.46-prerelease.46bd0d6dcc58-darwin-arm64",
10
+ "sha256": "76ac7070fff6851e290895e38e219c66105b3fa0990f7d48c5d4b246b79e98e6"
11
11
  },
12
12
  "linux-amd64": {
13
- "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.1480a0328c60/arkcli-1.0.46-prerelease.1480a0328c60-linux-amd64",
14
- "sha256": "a0b461dc6464ca2d493f3619e2b983ce16eb954f0f57f04d9c28e1996fd5de11"
13
+ "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.46bd0d6dcc58/arkcli-1.0.46-prerelease.46bd0d6dcc58-linux-amd64",
14
+ "sha256": "c7100a385086235b9d505be52ac8072305020dfedae5a161526b59e37159c0be"
15
15
  },
16
16
  "linux-arm64": {
17
- "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.1480a0328c60/arkcli-1.0.46-prerelease.1480a0328c60-linux-arm64",
18
- "sha256": "b4b9a1e9d641a788c4060c95f5e5ff67385382eb089d1d8252a1867b340eb06b"
17
+ "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.46bd0d6dcc58/arkcli-1.0.46-prerelease.46bd0d6dcc58-linux-arm64",
18
+ "sha256": "de345d949150e09b53090078035221e13f0f290a9fd8ac95401e3a1d6d491f0f"
19
19
  },
20
20
  "windows-amd64": {
21
- "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.1480a0328c60/arkcli-1.0.46-prerelease.1480a0328c60-windows-amd64.exe",
22
- "sha256": "a046840ca07028f32f36da7cdd822a35c8fe9d32b14456054a9e19e223ab999a"
21
+ "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.46bd0d6dcc58/arkcli-1.0.46-prerelease.46bd0d6dcc58-windows-amd64.exe",
22
+ "sha256": "d36d1ba5592bc373303c7c2bd4bfe9c130599aa98f76a7a5d268ebb11042abc2"
23
23
  },
24
24
  "windows-arm64": {
25
- "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.1480a0328c60/arkcli-1.0.46-prerelease.1480a0328c60-windows-arm64.exe",
26
- "sha256": "70109bdd2d982253e6ae63e9b1c33dcbda9cd25b3e73c4c931d6037d310953c5"
25
+ "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.46bd0d6dcc58/arkcli-1.0.46-prerelease.46bd0d6dcc58-windows-arm64.exe",
26
+ "sha256": "60bf3e8463d0fc9088b524cc9d613fdba661b6f4c6d655a3ce7e93d16849d390"
27
27
  }
28
28
  },
29
29
  "skills": {
30
30
  "primary": {
31
- "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.1480a0328c60/skills.tar.gz",
32
- "sha256": "3e0a76b1113d47d0e373b98caab88903bf908ab600aa169fc76bd7612ca5718d",
31
+ "url": "https://lf3-static.bytednsdoc.com/obj/eden-cn/psjryh/ljhwZthlaukjlkulzlp/prerelease/1.0.46-prerelease.46bd0d6dcc58/skills.tar.gz",
32
+ "sha256": "587b0421f4ac6d2633e7159574e22be1517285f6afc448d70484f3b58d7a1b76",
33
33
  "kind": "cdn"
34
34
  },
35
- "tag": "v1.0.46-prerelease.1480a0328c60"
35
+ "tag": "v1.0.46-prerelease.46bd0d6dcc58"
36
36
  }
37
37
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@volcengine/ark-cli",
3
- "version": "1.0.46-prerelease.1480a0328c60",
4
- "description": "火山方舟 ARK 平台命令行工具",
3
+ "version": "1.0.46-prerelease.46bd0d6dcc58",
4
+ "description": "\u706b\u5c71\u65b9\u821f ARK \u5e73\u53f0\u547d\u4ee4\u884c\u5de5\u5177",
5
5
  "bin": {
6
6
  "arkcli": "scripts/run.js"
7
7
  },
@@ -29,5 +29,13 @@
29
29
  "repository": {
30
30
  "type": "git",
31
31
  "url": "git+https://github.com/volcengine/ark-cli.git"
32
+ },
33
+ "optionalDependencies": {
34
+ "@volcengine/ark-cli-darwin-x64": "1.0.46-prerelease.46bd0d6dcc58",
35
+ "@volcengine/ark-cli-darwin-arm64": "1.0.46-prerelease.46bd0d6dcc58",
36
+ "@volcengine/ark-cli-linux-x64": "1.0.46-prerelease.46bd0d6dcc58",
37
+ "@volcengine/ark-cli-linux-arm64": "1.0.46-prerelease.46bd0d6dcc58",
38
+ "@volcengine/ark-cli-win32-x64": "1.0.46-prerelease.46bd0d6dcc58",
39
+ "@volcengine/ark-cli-win32-arm64": "1.0.46-prerelease.46bd0d6dcc58"
32
40
  }
33
41
  }
package/scripts/run.js CHANGED
@@ -1,37 +1,66 @@
1
1
  #!/usr/bin/env node
2
- // @volcengine/ark-cli npm bin wrapper。
3
- // 二进制不内嵌在包里——由 postinstall 按当前平台从 CDN 下载到 <pkg>/bin/,
4
- // 这里只负责 exec 它。对外只有 arkcli 一个产品,故产品名硬编码。
5
- const path = require("path");
2
+ "use strict";
3
+ // npm installs the matching optional platform package without lifecycle scripts.
4
+ // Keep the historical bin/ layout for already installed and composite-updated CLI.
6
5
  const fs = require("fs");
6
+ const path = require("path");
7
7
  const { execFileSync } = require("child_process");
8
-
9
- const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" };
10
- const archMap = { x64: "amd64", arm64: "arm64" };
11
- const platform = platformMap[process.platform];
12
- const arch = archMap[process.arch];
13
-
8
+ const PACKAGE_NAME = "@volcengine/ark-cli";
9
+ const root = path.resolve(__dirname, "..");
10
+ const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[process.platform];
11
+ const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
14
12
  if (!platform || !arch) {
15
- console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
13
+ console.error(`${PACKAGE_NAME}: unsupported platform ${process.platform}-${process.arch}`);
16
14
  process.exit(1);
17
15
  }
18
-
19
16
  const ext = platform === "windows" ? ".exe" : "";
20
- const binary = path.join(__dirname, "..", "bin", `arkcli-${platform}-${arch}${ext}`);
17
+ let binary = path.join(root, "bin", `arkcli-${platform}-${arch}${ext}`);
21
18
 
22
- if (!fs.existsSync(binary)) {
23
- console.error(
24
- `arkcli: binary not found at ${binary}\n` +
25
- `安装时平台二进制可能下载失败。请尝试重新安装:\n` +
26
- ` npm install -g @volcengine/ark-cli\n` +
27
- `或手动重跑安装步骤:\n` +
28
- ` node ${path.join(__dirname, "postinstall.js")}`,
29
- );
19
+ function regularFile(file, maxBytes) {
20
+ for (let current = file; ; current = path.dirname(current)) {
21
+ const stat = fs.lstatSync(current);
22
+ if (stat.isSymbolicLink()) throw new Error(`refuse symlink: ${current}`);
23
+ if (current === file) {
24
+ if (!stat.isFile() || stat.size <= 0 || (maxBytes && stat.size > maxBytes)) throw new Error(`invalid file: ${file}`);
25
+ } else if (!stat.isDirectory()) throw new Error(`invalid directory: ${current}`);
26
+ if (current === root) break;
27
+ if (current === path.dirname(current)) throw new Error("platform package escapes its owner");
28
+ }
29
+ }
30
+ function metadata(file) {
31
+ regularFile(file, 1024 * 1024);
32
+ return JSON.parse(fs.readFileSync(file, "utf8"));
33
+ }
34
+ try {
35
+ let legacy = true;
36
+ try { fs.lstatSync(binary); } catch (err) {
37
+ if (err.code !== "ENOENT") throw err;
38
+ legacy = false;
39
+ }
40
+ if (!legacy) {
41
+ const parent = metadata(path.join(root, "package.json"));
42
+ const name = `${PACKAGE_NAME}-${process.platform}-${process.arch}`;
43
+ if (parent.name !== PACKAGE_NAME || !parent.version || parent.optionalDependencies?.[name] !== parent.version) {
44
+ throw new Error("missing exact-version platform dependency declaration");
45
+ }
46
+ const childRoot = path.join(root, "node_modules", name);
47
+ const child = metadata(path.join(childRoot, "package.json"));
48
+ if (child.name !== name || child.version !== parent.version ||
49
+ !Array.isArray(child.os) || child.os.length !== 1 || child.os[0] !== process.platform ||
50
+ !Array.isArray(child.cpu) || child.cpu.length !== 1 || child.cpu[0] !== process.arch) {
51
+ throw new Error("platform package identity/version mismatch");
52
+ }
53
+ binary = path.join(childRoot, "bin", `arkcli-${platform}-${arch}${ext}`);
54
+ }
55
+ regularFile(binary);
56
+ } catch (err) {
57
+ console.error(`${PACKAGE_NAME}: platform binary unavailable: ${err.message}\n` +
58
+ `Reinstall with optional dependencies enabled:\n npm install -g ${PACKAGE_NAME} --include=optional`);
30
59
  process.exit(1);
31
60
  }
32
-
33
61
  try {
34
62
  execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
35
63
  } catch (err) {
64
+ if (err.signal) process.kill(process.pid, err.signal);
36
65
  process.exit(Number.isInteger(err.status) ? err.status : 1);
37
66
  }