@shenvy/cli 0.1.3 → 0.1.4

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 +20 -13
  2. package/package.json +1 -1
package/bin/install.js CHANGED
@@ -64,26 +64,33 @@ download(url, tempArchive)
64
64
  .then(() => {
65
65
  console.log('Extracting archive...');
66
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
67
  try {
73
- execSync(`tar ${forceLocal}-xf "${tarArchive}" -C "${tarDir}"`);
68
+ if (platform === 'win32') {
69
+ // Use PowerShell for ZIP files on Windows
70
+ const psCommand = `powershell.exe -NoProfile -Command "Expand-Archive -Path '${tempArchive}' -DestinationPath '${binDir}' -Force"`;
71
+ execSync(psCommand);
72
+ } else {
73
+ // Use tar for .tar.gz on Unix-like systems
74
+ execSync(`tar -xzf "${tempArchive}" -C "${binDir}"`);
75
+ }
74
76
  } catch (e) {
75
- console.error('Failed to extract with tar. Trying fallback rename...');
76
- // If tar fails, we at least have the archive
77
+ console.error('Extraction failed:', e.message);
78
+ process.exit(1);
77
79
  }
78
80
 
79
- // Rename the extracted binary to the expected name if needed
81
+ // Rename the extracted binary to the expected name if needed (e.g., shenvy -> shenvy-bin)
80
82
  const extractedBinPath = path.join(binDir, finalBinName);
81
- if (fs.existsSync(extractedBinPath) && extractedBinPath !== finalBinPath) {
82
- if (fs.existsSync(finalBinPath)) fs.unlinkSync(finalBinPath);
83
- fs.renameSync(extractedBinPath, finalBinPath);
83
+ if (fs.existsSync(extractedBinPath)) {
84
+ if (platform !== 'win32' && extractedBinPath !== finalBinPath) {
85
+ if (fs.existsSync(finalBinPath)) fs.unlinkSync(finalBinPath);
86
+ fs.renameSync(extractedBinPath, finalBinPath);
87
+ }
88
+ } else {
89
+ console.error(`Error: Extracted binary ${finalBinName} not found in ${binDir}`);
90
+ process.exit(1);
84
91
  }
85
92
 
86
- // Clean up the archive if it exists
93
+ // Clean up the archive
87
94
  if (fs.existsSync(tempArchive)) {
88
95
  fs.unlinkSync(tempArchive);
89
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shenvy/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Securely manage environment variables with E2EE (Go implementation wrapper)",
5
5
  "main": "bin/install.js",
6
6
  "bin": {