@inference-gateway/cli 0.241.0 → 0.242.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.
Files changed (2) hide show
  1. package/bin/install.js +21 -8
  2. package/package.json +1 -1
package/bin/install.js CHANGED
@@ -5,13 +5,17 @@
5
5
  // GitHub release matching this package's version, and places it next to this
6
6
  // script so `bin/run.js` can exec it. Runs as an npm `postinstall` hook.
7
7
  //
8
- // The CLI publishes raw executables (e.g. `infer-linux-amd64`) plus a
9
- // `checksums.txt`, so this downloads the binary directly - no archive to extract.
8
+ // The CLI publishes one `infer-<os>-<arch>.tar.gz` per platform holding the
9
+ // executable as `infer` (`infer.exe` on Windows), plus a `checksums.txt` over
10
+ // the archives. The system `tar` extracts it: macOS, Linux and Windows 10+
11
+ // all ship one.
10
12
 
11
13
  const fs = require("fs");
14
+ const os = require("os");
12
15
  const path = require("path");
13
16
  const https = require("https");
14
17
  const crypto = require("crypto");
18
+ const { execFileSync } = require("child_process");
15
19
 
16
20
  const REPO = "inference-gateway/cli";
17
21
  const { version } = require("../package.json");
@@ -41,7 +45,15 @@ function resolveAsset() {
41
45
  `Install from source instead: https://github.com/${REPO}#installation`
42
46
  );
43
47
  }
44
- return `infer-${goos}-${goarch}`;
48
+ return `infer-${goos}-${goarch}.tar.gz`;
49
+ }
50
+
51
+ function extract(archive) {
52
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "infer-cli-"));
53
+ const archivePath = path.join(dir, "infer.tar.gz");
54
+ fs.writeFileSync(archivePath, archive);
55
+ execFileSync("tar", ["-xzf", archivePath, "-C", dir], { stdio: "inherit" });
56
+ return fs.readFileSync(path.join(dir, binName));
45
57
  }
46
58
 
47
59
  function download(url) {
@@ -67,7 +79,7 @@ function download(url) {
67
79
  });
68
80
  }
69
81
 
70
- async function verifyChecksum(binary, assetName) {
82
+ async function verifyChecksum(archive, assetName) {
71
83
  let checksums;
72
84
  try {
73
85
  checksums = (await download(`${BASE_URL}/checksums.txt`)).toString("utf8");
@@ -85,7 +97,7 @@ async function verifyChecksum(binary, assetName) {
85
97
  return;
86
98
  }
87
99
  const expected = line.trim().split(/\s+/)[0];
88
- const actual = crypto.createHash("sha256").update(binary).digest("hex");
100
+ const actual = crypto.createHash("sha256").update(archive).digest("hex");
89
101
  if (expected !== actual) {
90
102
  fail(`checksum mismatch for ${assetName} (expected ${expected}, got ${actual})`);
91
103
  }
@@ -104,9 +116,9 @@ async function main() {
104
116
  const url = `${BASE_URL}/${assetName}`;
105
117
  console.log(`@inference-gateway/cli: downloading ${assetName} (v${version})`);
106
118
 
107
- let binary;
119
+ let archive;
108
120
  try {
109
- binary = await download(url);
121
+ archive = await download(url);
110
122
  } catch (err) {
111
123
  fail(
112
124
  `failed to download ${url}: ${err.message}. ` +
@@ -114,8 +126,9 @@ async function main() {
114
126
  );
115
127
  }
116
128
 
117
- await verifyChecksum(binary, assetName);
129
+ await verifyChecksum(archive, assetName);
118
130
 
131
+ const binary = extract(archive);
119
132
  fs.mkdirSync(path.dirname(binPath), { recursive: true });
120
133
  fs.writeFileSync(binPath, binary, { mode: 0o755 });
121
134
  fs.chmodSync(binPath, 0o755);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inference-gateway/cli",
3
- "version": "0.241.0",
3
+ "version": "0.242.0",
4
4
  "description": "A Git-first CLI coding agent that turns ideas, issues, and tasks into real code changes.",
5
5
  "bin": {
6
6
  "infer": "bin/run.js"