@shenvy/cli 0.1.7 → 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);
@@ -59,35 +58,58 @@ function download(url, dest) {
59
58
  });
60
59
  }
61
60
 
62
- async function extractWithRetry(retries = 5) {
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) {
63
78
  for (let i = 0; i < retries; i++) {
64
79
  try {
65
80
  console.log(`Extracting archive (attempt ${i + 1}/${retries})...`);
66
81
  if (platform === 'win32') {
67
- const psCommand = `powershell.exe -NoProfile -Command "Expand-Archive -Path '${tempArchive.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force"`;
82
+ // Try PowerShell Expand-Archive
83
+ const psCommand = `powershell.exe -NoProfile -Command "Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${destDir.replace(/'/g, "''")}' -Force"`;
68
84
  execSync(psCommand, { stdio: 'inherit' });
69
85
  } else {
70
- execSync(`tar -xzf "${tempArchive}" -C "${binDir}"`, { stdio: 'inherit' });
86
+ execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: 'inherit' });
71
87
  }
72
- return; // Success!
88
+ return;
73
89
  } catch (e) {
74
90
  if (i === retries - 1) throw e;
75
- console.log(`Archive locked, retrying in 1s...`);
76
- await new Promise(r => setTimeout(r, 1000));
91
+ console.log(`Extraction failed or file locked, retrying in 1.5s...`);
92
+ await wait(1500);
77
93
  }
78
94
  }
79
95
  }
80
96
 
81
97
  async function install() {
82
98
  try {
99
+ console.log(`Downloading ${PROJECT_NAME} v${VERSION} for ${target}...`);
100
+ if (fs.existsSync(downloadPath)) fs.unlinkSync(downloadPath);
83
101
  if (fs.existsSync(tempArchive)) fs.unlinkSync(tempArchive);
84
102
 
85
- await download(url, tempArchive);
103
+ await download(url, downloadPath);
104
+
105
+ // Atomic rename to help OS release locks
106
+ fs.renameSync(downloadPath, tempArchive);
86
107
 
87
- // Initial delay to let OS release handles
88
- await new Promise(r => setTimeout(r, 1000));
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...');
89
111
 
90
- await extractWithRetry();
112
+ await extractWithRetry(tempArchive, binDir);
91
113
 
92
114
  const extractedBinPath = path.join(binDir, finalBinName);
93
115
  if (fs.existsSync(extractedBinPath)) {
@@ -96,7 +118,7 @@ async function install() {
96
118
  fs.renameSync(extractedBinPath, finalBinPath);
97
119
  }
98
120
  } else {
99
- throw new Error(`Extracted binary ${finalBinName} not found`);
121
+ throw new Error(`Extracted binary ${finalBinName} not found in ${binDir}`);
100
122
  }
101
123
 
102
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.7",
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",