yougile-cli 0.8.4 → 0.8.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yougile-cli",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "CLI утилита для работы с YouGile API из командной строки",
5
5
  "keywords": [
6
6
  "yougile",
@@ -2,7 +2,7 @@
2
2
  import { platform, arch } from "node:process";
3
3
  import https from "node:https";
4
4
  import http from "node:http";
5
- import { chmodSync, mkdirSync } from "node:fs";
5
+ import { chmodSync, mkdirSync, renameSync, existsSync } from "node:fs";
6
6
  import { join, dirname } from "node:path";
7
7
  import { createGunzip } from "node:zlib";
8
8
  import { fileURLToPath } from "node:url";
@@ -13,12 +13,13 @@ const __dirname = dirname(__filename);
13
13
 
14
14
  const MANIFEST = {
15
15
  "assets": {
16
- "linux-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/1b049ecb-32cf-4ea3-bb5d-08941b8e53b9",
17
- "darwin-arm64": "https://gitverse.ru/sc/sbt/api/v1/attachments/a386f1b4-af9e-4977-ac61-4af9c7fdb695",
18
- "win32-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/7a7ead26-33c1-4679-862c-8d3ac296204d"
16
+ "linux-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/794a64eb-bd58-4393-ac18-8f5e3b07944a",
17
+ "darwin-arm64": "https://gitverse.ru/sc/sbt/api/v1/attachments/838b2f0a-2ef8-4355-98ae-3990d57292f9",
18
+ "win32-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/25153946-5f25-48fd-b7d7-c6ae3dd9d930"
19
19
  },
20
20
  "binName": "yougile",
21
- "version": "0.8.4"
21
+ "version": "0.8.5",
22
+ "sourceBinName": "cli"
22
23
  };
23
24
 
24
25
  const platformKey = `${platform}-${arch}`;
@@ -61,9 +62,10 @@ function download(url, redirectCount = 0) {
61
62
  return;
62
63
  }
63
64
 
65
+ // Extract with strip: 1 to remove the first directory level (e.g., linux-x64/)
64
66
  res
65
67
  .pipe(createGunzip())
66
- .pipe(tar.extract({ cwd: binDir }))
68
+ .pipe(tar.extract({ cwd: binDir, strip: 1 }))
67
69
  .on("finish", resolve)
68
70
  .on("error", reject);
69
71
  });
@@ -80,10 +82,20 @@ console.log(`📦 Installing ${MANIFEST.binName} for ${platformKey}...`);
80
82
 
81
83
  download(downloadUrl)
82
84
  .then(() => {
83
- const binPath = join(binDir, MANIFEST.binName);
85
+ const sourceName = MANIFEST.sourceBinName || MANIFEST.binName;
86
+ const ext = platform === "win32" ? ".exe" : "";
87
+ const sourcePath = join(binDir, sourceName + ext);
88
+ const targetPath = join(binDir, MANIFEST.binName + ext);
89
+
90
+ // Rename binary if sourceBinName differs from binName
91
+ if (sourceName !== MANIFEST.binName && existsSync(sourcePath)) {
92
+ renameSync(sourcePath, targetPath);
93
+ }
94
+
95
+ // Make binary executable on Unix
84
96
  if (platform !== "win32") {
85
97
  try {
86
- chmodSync(binPath, 0o755);
98
+ chmodSync(targetPath, 0o755);
87
99
  } catch (e) {
88
100
  // Ignore chmod errors on some platforms
89
101
  }