@shenvy/cli 0.1.6 → 0.1.8

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/Formula/shenvy.rb CHANGED
@@ -5,20 +5,20 @@
5
5
  class Shenvy < Formula
6
6
  desc "Securely manage environment variables with E2EE."
7
7
  homepage "https://shenvy.dev"
8
- version "0.1.5"
8
+ version "0.1.7"
9
9
 
10
10
  on_macos do
11
11
  if Hardware::CPU.intel?
12
- url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.5/shenvy_darwin_amd64.tar.gz"
13
- sha256 "973fe552f0882cced7344a9625d4bd6e512b6294c2d2f23836a060928f8d1a09"
12
+ url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.7/shenvy_darwin_amd64.tar.gz"
13
+ sha256 "ee1e6c19ad873bdd734d198ef0eebca4888713fe8b3c84a6c374bce17962a3f4"
14
14
 
15
15
  define_method(:install) do
16
16
  bin.install "shenvy"
17
17
  end
18
18
  end
19
19
  if Hardware::CPU.arm?
20
- url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.5/shenvy_darwin_arm64.tar.gz"
21
- sha256 "de37d80eb886b419d34f9bd27d232483e2f321c300b5c0c8c18a8f6f29396a13"
20
+ url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.7/shenvy_darwin_arm64.tar.gz"
21
+ sha256 "fed746ba5b3dc583813e3723878567fb65f82f5e0f5e62c5fe880ab19263ef74"
22
22
 
23
23
  define_method(:install) do
24
24
  bin.install "shenvy"
@@ -28,15 +28,15 @@ class Shenvy < Formula
28
28
 
29
29
  on_linux do
30
30
  if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
31
- url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.5/shenvy_linux_amd64.tar.gz"
32
- sha256 "7a10a12bb695283835de2a3530a27e813d52855566d916464fe82ad247fa89e0"
31
+ url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.7/shenvy_linux_amd64.tar.gz"
32
+ sha256 "7bafe1011b8a6cbf819251f8be90dd16a6786b84f07a0b7bcc5dbd8100209cca"
33
33
  define_method(:install) do
34
34
  bin.install "shenvy"
35
35
  end
36
36
  end
37
37
  if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
38
- url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.5/shenvy_linux_arm64.tar.gz"
39
- sha256 "207acb57c7abef500095320c61848aa87985ebd3f972f08d3e493e0118b45979"
38
+ url "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.7/shenvy_linux_arm64.tar.gz"
39
+ sha256 "315503c0f9d62637b2dd405a25fa85d19647b86e0a159d91c570029b6295279f"
40
40
  define_method(:install) do
41
41
  bin.install "shenvy"
42
42
  end
package/bin/install.js CHANGED
@@ -32,11 +32,10 @@ if (!archiveName) {
32
32
  const url = `https://github.com/${REPO}/releases/download/v${VERSION}/shenvy_${archiveName}`;
33
33
  const binDir = path.join(__dirname);
34
34
  const tempArchive = path.join(binDir, archiveName);
35
+ const downloadPath = tempArchive + '.download';
35
36
  const finalBinName = platform === 'win32' ? 'shenvy.exe' : 'shenvy';
36
37
  const finalBinPath = path.join(binDir, platform === 'win32' ? 'shenvy.exe' : 'shenvy-bin');
37
38
 
38
- console.log(`Downloading ${PROJECT_NAME} v${VERSION} for ${target} from ${url}...`);
39
-
40
39
  function download(url, dest) {
41
40
  return new Promise((resolve, reject) => {
42
41
  const file = fs.createWriteStream(dest);
@@ -49,8 +48,9 @@ function download(url, dest) {
49
48
  return;
50
49
  }
51
50
  response.pipe(file);
52
- // Wait for 'close' instead of 'finish' to ensure OS handle is released
53
- file.on('close', resolve);
51
+ file.on('finish', () => {
52
+ file.close(() => resolve());
53
+ });
54
54
  }).on('error', (err) => {
55
55
  fs.unlink(dest, () => {});
56
56
  reject(err);
@@ -58,22 +58,58 @@ function download(url, dest) {
58
58
  });
59
59
  }
60
60
 
61
+ const wait = (ms) => new Promise(r => setTimeout(r, ms));
62
+
63
+ async function ensureFileReady(filePath) {
64
+ for (let i = 0; i < 10; i++) {
65
+ try {
66
+ // Try to open file for appending to check if it's locked
67
+ const fd = fs.openSync(filePath, 'r+');
68
+ fs.closeSync(fd);
69
+ return true;
70
+ } catch (e) {
71
+ await wait(500);
72
+ }
73
+ }
74
+ return false;
75
+ }
76
+
77
+ async function extractWithRetry(archivePath, destDir, retries = 5) {
78
+ for (let i = 0; i < retries; i++) {
79
+ try {
80
+ console.log(`Extracting archive (attempt ${i + 1}/${retries})...`);
81
+ if (platform === 'win32') {
82
+ // Try PowerShell Expand-Archive
83
+ const psCommand = `powershell.exe -NoProfile -Command "Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${destDir.replace(/'/g, "''")}' -Force"`;
84
+ execSync(psCommand, { stdio: 'inherit' });
85
+ } else {
86
+ execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: 'inherit' });
87
+ }
88
+ return;
89
+ } catch (e) {
90
+ if (i === retries - 1) throw e;
91
+ console.log(`Extraction failed or file locked, retrying in 1.5s...`);
92
+ await wait(1500);
93
+ }
94
+ }
95
+ }
96
+
61
97
  async function install() {
62
98
  try {
99
+ console.log(`Downloading ${PROJECT_NAME} v${VERSION} for ${target}...`);
100
+ if (fs.existsSync(downloadPath)) fs.unlinkSync(downloadPath);
63
101
  if (fs.existsSync(tempArchive)) fs.unlinkSync(tempArchive);
64
102
 
65
- await download(url, tempArchive);
103
+ await download(url, downloadPath);
66
104
 
67
- // Small delay to let the OS settle
68
- await new Promise(r => setTimeout(r, 500));
105
+ // Atomic rename to help OS release locks
106
+ fs.renameSync(downloadPath, tempArchive);
107
+
108
+ console.log('Verifying file access...');
109
+ const isReady = await ensureFileReady(tempArchive);
110
+ if (!isReady) console.warn('Warning: File might still be locked, proceeding anyway...');
69
111
 
70
- console.log('Extracting archive...');
71
- if (platform === 'win32') {
72
- const psCommand = `powershell.exe -NoProfile -Command "Expand-Archive -Path '${tempArchive.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force"`;
73
- execSync(psCommand);
74
- } else {
75
- execSync(`tar -xzf "${tempArchive}" -C "${binDir}"`);
76
- }
112
+ await extractWithRetry(tempArchive, binDir);
77
113
 
78
114
  const extractedBinPath = path.join(binDir, finalBinName);
79
115
  if (fs.existsSync(extractedBinPath)) {
@@ -82,7 +118,7 @@ async function install() {
82
118
  fs.renameSync(extractedBinPath, finalBinPath);
83
119
  }
84
120
  } else {
85
- throw new Error(`Extracted binary ${finalBinName} not found`);
121
+ throw new Error(`Extracted binary ${finalBinName} not found in ${binDir}`);
86
122
  }
87
123
 
88
124
  if (fs.existsSync(tempArchive)) fs.unlinkSync(tempArchive);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shenvy/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Securely manage environment variables with E2EE (Go implementation wrapper)",
5
5
  "main": "bin/install.js",
6
6
  "bin": {
package/scoop/shenvy.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
- "version": "0.1.5",
2
+ "version": "0.1.7",
3
3
  "architecture": {
4
4
  "64bit": {
5
- "url": "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.5/shenvy_windows_amd64.zip",
5
+ "url": "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.7/shenvy_windows_amd64.zip",
6
6
  "bin": [
7
7
  "shenvy.exe"
8
8
  ],
9
- "hash": "19376e027a5ac7ea67f7ebfbd77b6835c91d03586b39cf868dde1da8e6fd6683"
9
+ "hash": "22304a00ee345b6d5a9a3971cc308cadd1530cb3859f2f2ab8a23a9539c50f1a"
10
10
  },
11
11
  "arm64": {
12
- "url": "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.5/shenvy_windows_arm64.zip",
12
+ "url": "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.7/shenvy_windows_arm64.zip",
13
13
  "bin": [
14
14
  "shenvy.exe"
15
15
  ],
16
- "hash": "b9e78019c4fd541db1f13b41e30250d144ca82496295059324d2093d4a1a3215"
16
+ "hash": "0e1daa2744d72e2ed8aaaae758a4501a2ae05cb72b14591a06a4d7803566fd68"
17
17
  }
18
18
  },
19
19
  "homepage": "https://shenvy.dev",