@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 +9 -9
- package/bin/install.js +51 -15
- package/package.json +1 -1
- package/scoop/shenvy.json +5 -5
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.
|
|
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.
|
|
13
|
-
sha256 "
|
|
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.
|
|
21
|
-
sha256 "
|
|
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.
|
|
32
|
-
sha256 "
|
|
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.
|
|
39
|
-
sha256 "
|
|
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
|
-
|
|
53
|
-
|
|
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,
|
|
103
|
+
await download(url, downloadPath);
|
|
66
104
|
|
|
67
|
-
//
|
|
68
|
-
|
|
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
|
-
|
|
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
package/scoop/shenvy.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
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
|
+
"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": "
|
|
9
|
+
"hash": "22304a00ee345b6d5a9a3971cc308cadd1530cb3859f2f2ab8a23a9539c50f1a"
|
|
10
10
|
},
|
|
11
11
|
"arm64": {
|
|
12
|
-
"url": "https://github.com/Shenvy/shenvy-cli-dist/releases/download/v0.1.
|
|
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": "
|
|
16
|
+
"hash": "0e1daa2744d72e2ed8aaaae758a4501a2ae05cb72b14591a06a4d7803566fd68"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://shenvy.dev",
|