@shenvy/cli 0.1.1 → 0.1.2

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 +19 -8
  2. package/package.json +1 -1
package/bin/install.js CHANGED
@@ -8,8 +8,6 @@ const { execSync } = require('child_process');
8
8
 
9
9
  const PROJECT_NAME = 'shenvy';
10
10
  const REPO = 'Shenvy/shenvy-cli-dist';
11
- // For the binary download, we still point to v0.1.0 since that's the latest CLI release
12
- // even if the NPM wrapper version bumps to 0.1.1
13
11
  const BINARY_VERSION = '0.1.0';
14
12
 
15
13
  const platform = os.platform();
@@ -65,19 +63,32 @@ function download(url, dest) {
65
63
  download(url, tempArchive)
66
64
  .then(() => {
67
65
  console.log('Extracting archive...');
68
- // Use native tar (available in Win10+, macOS, Linux) to extract
69
- execSync(`tar -xf "${tempArchive}" -C "${binDir}"`);
66
+
67
+ // Fix for Windows tar: use forward slashes and --force-local to avoid "hostname" error
68
+ const tarArchive = tempArchive.replace(/\\/g, '/');
69
+ const tarDir = binDir.replace(/\\/g, '/');
70
+ const forceLocal = platform === 'win32' ? '--force-local ' : '';
71
+
72
+ try {
73
+ execSync(`tar ${forceLocal}-xf "${tarArchive}" -C "${tarDir}"`);
74
+ } catch (e) {
75
+ console.error('Failed to extract with tar. Trying fallback rename...');
76
+ // If tar fails, we at least have the archive
77
+ }
70
78
 
71
79
  // Rename the extracted binary to the expected name if needed
72
80
  const extractedBinPath = path.join(binDir, finalBinName);
73
- if (extractedBinPath !== finalBinPath) {
81
+ if (fs.existsSync(extractedBinPath) && extractedBinPath !== finalBinPath) {
82
+ if (fs.existsSync(finalBinPath)) fs.unlinkSync(finalBinPath);
74
83
  fs.renameSync(extractedBinPath, finalBinPath);
75
84
  }
76
85
 
77
- // Clean up the archive
78
- fs.unlinkSync(tempArchive);
86
+ // Clean up the archive if it exists
87
+ if (fs.existsSync(tempArchive)) {
88
+ fs.unlinkSync(tempArchive);
89
+ }
79
90
 
80
- if (platform !== 'win32') {
91
+ if (platform !== 'win32' && fs.existsSync(finalBinPath)) {
81
92
  fs.chmodSync(finalBinPath, 0o755);
82
93
  }
83
94
  console.log(`${PROJECT_NAME} installed successfully.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shenvy/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Securely manage environment variables with E2EE (Go implementation wrapper)",
5
5
  "main": "bin/install.js",
6
6
  "bin": {