sshifu-trust 0.7.8-test.9 → 0.7.9

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/package.json +1 -1
  2. package/scripts/install.js +6 -65
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sshifu-trust",
3
- "version": "0.7.8-test.9",
3
+ "version": "0.7.9",
4
4
  "description": "Configure SSH servers to trust sshifu certificate authority",
5
5
  "main": "bin/sshifu-trust.js",
6
6
  "bin": {
@@ -95,43 +95,7 @@ async function main() {
95
95
  const archiveBinName = `${PACKAGE_NAME}-${platform}${isWindows ? '.exe' : ''}`;
96
96
  const extractedPath = path.join(binDir, archiveBinName);
97
97
  if (isWindows) {
98
- // Retry extraction to handle file lock issues on Windows
99
- const maxRetries = 5;
100
- let lastErr;
101
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
102
- try {
103
- // Small delay before each attempt to ensure file handle is released
104
- if (attempt > 1) {
105
- console.log(`[sshifu-trust] Retry attempt ${attempt}/${maxRetries}...`);
106
- await new Promise(resolve => setTimeout(resolve, attempt * 500));
107
- }
108
-
109
- // Use PowerShell with explicit error action and output redirection
110
- const psCommand = `Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force -ErrorAction Stop`;
111
- console.log(`[sshifu-trust] Running: ${psCommand}`);
112
- execSync(`powershell -Command "${psCommand}"`, { stdio: ['ignore', 'pipe', 'pipe'] });
113
- console.log(`[sshifu-trust] Extraction completed, checking files...`);
114
- const afterExtract = fs.readdirSync(binDir);
115
- console.log(`[sshifu-trust] Files after extraction: ${afterExtract.join(', ')}`);
116
- lastErr = null;
117
- break;
118
- } catch (extractErr) {
119
- lastErr = extractErr;
120
- console.error(`[sshifu-trust] Extraction attempt ${attempt} failed: ${extractErr.message}`);
121
- if (extractErr.message.includes('being used by another process')) {
122
- console.log(`[sshifu-trust] File locked, will retry...`);
123
- continue;
124
- }
125
- // Non-retryable error
126
- break;
127
- }
128
- }
129
- if (lastErr) {
130
- console.error(`[sshifu-trust] All extraction attempts failed`);
131
- console.error(`[sshifu-trust] stderr: ${lastErr.stderr?.toString() || 'N/A'}`);
132
- console.error(`[sshifu-trust] stdout: ${lastErr.stdout?.toString() || 'N/A'}`);
133
- throw lastErr;
134
- }
98
+ execSync(`powershell -Command "Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force"`, { stdio: 'ignore' });
135
99
  } else {
136
100
  execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'ignore' });
137
101
  }
@@ -145,35 +109,12 @@ async function main() {
145
109
  fs.renameSync(extractedPath, binPath);
146
110
  } else {
147
111
  // Try to find the extracted file (in case of path issues)
148
- console.log(`[sshifu-trust] Binary not found at expected location, searching...`);
149
112
  const files = fs.readdirSync(binDir);
150
- console.log(`[sshifu-trust] Files in binDir (top level): ${files.join(', ')}`);
151
-
152
- // Look for .exe file in binDir or any subdirectory
153
- let foundFile = null;
154
- for (const file of files) {
155
- const filePath = path.join(binDir, file);
156
- const stat = fs.statSync(filePath);
157
- if (stat.isDirectory()) {
158
- // Check subdirectory
159
- const subFiles = fs.readdirSync(filePath);
160
- console.log(`[sshifu-trust] Files in ${file}/: ${subFiles.join(', ')}`);
161
- const exeInSubdir = subFiles.find(f => f.endsWith('.exe') && f.startsWith(PACKAGE_NAME));
162
- if (exeInSubdir) {
163
- foundFile = path.join(filePath, exeInSubdir);
164
- break;
165
- }
166
- } else if (file.endsWith('.exe') && file.startsWith(PACKAGE_NAME)) {
167
- foundFile = filePath;
168
- break;
169
- }
170
- }
171
-
172
- if (foundFile) {
173
- console.log(`[sshifu-trust] Found ${foundFile}, renaming to ${binName}`);
174
- fs.renameSync(foundFile, binPath);
175
- } else {
176
- throw new Error(`Could not find binary in ${binDir}`);
113
+ console.log(`[sshifu-trust] Files in binDir: ${files.join(', ')}`);
114
+ const exeFile = files.find(f => f.endsWith('.exe') && f.startsWith(PACKAGE_NAME));
115
+ if (exeFile) {
116
+ console.log(`[sshifu-trust] Found ${exeFile}, renaming to ${binName}`);
117
+ fs.renameSync(path.join(binDir, exeFile), binPath);
177
118
  }
178
119
  }
179
120
  }