sshifu 0.7.7 → 0.7.8-test.11

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 +67 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sshifu",
3
- "version": "0.7.7",
3
+ "version": "0.7.8-test.11",
4
4
  "description": "SSH authentication system with short-lived certificates and OAuth authentication (GitHub organizations)",
5
5
  "main": "bin/sshifu.js",
6
6
  "bin": {
@@ -95,7 +95,45 @@ 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
- execSync(`powershell -Command "Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force"`, { stdio: 'ignore' });
98
+ // On Windows, copy zip to temp location first to avoid file lock issues
99
+ const tempZip = path.join(binDir, 'temp_' + Date.now() + '.zip');
100
+ fs.copyFileSync(archivePath, tempZip);
101
+
102
+ const tempDir = path.join(binDir, 'tmp_extract_' + Date.now());
103
+ fs.mkdirSync(tempDir, { recursive: true });
104
+
105
+ try {
106
+ const psCommand = `Expand-Archive -Path '${tempZip.replace(/'/g, "''")}' -DestinationPath '${tempDir.replace(/'/g, "''")}' -Force -ErrorAction Stop`;
107
+ console.log(`[sshifu] Running: ${psCommand}`);
108
+ execSync(`powershell -Command "${psCommand}"`, { stdio: ['ignore', 'pipe', 'pipe'] });
109
+
110
+ // Find the extracted binary
111
+ const tempFiles = fs.readdirSync(tempDir);
112
+ console.log(`[sshifu] Extracted files: ${tempFiles.join(', ')}`);
113
+
114
+ const extractedBin = tempFiles.find(f => f.endsWith('.exe') || !f.includes('.'));
115
+ if (!extractedBin) {
116
+ throw new Error(`No binary found in temp directory. Files: ${tempFiles.join(', ')}`);
117
+ }
118
+
119
+ // Move to final location
120
+ const tempBinPath = path.join(tempDir, extractedBin);
121
+ fs.renameSync(tempBinPath, binPath);
122
+
123
+ // Cleanup
124
+ fs.unlinkSync(tempZip);
125
+ fs.rmSync(tempDir, { recursive: true, force: true });
126
+ fs.unlinkSync(archivePath);
127
+
128
+ console.log(`[sshifu] Binary installed successfully!`);
129
+ } catch (extractErr) {
130
+ // Cleanup temp files on error
131
+ try { fs.unlinkSync(tempZip); } catch (e) {}
132
+ try { fs.rmSync(tempDir, { recursive: true, force: true }); } catch (e) {}
133
+ console.error(`[sshifu] Extraction failed: ${extractErr.message}`);
134
+ console.error(`[sshifu] stderr: ${extractErr.stderr?.toString() || 'N/A'}`);
135
+ throw extractErr;
136
+ }
99
137
  } else {
100
138
  execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'ignore' });
101
139
  }
@@ -109,12 +147,35 @@ async function main() {
109
147
  fs.renameSync(extractedPath, binPath);
110
148
  } else {
111
149
  // Try to find the extracted file (in case of path issues)
150
+ console.log(`[sshifu] Binary not found at expected location, searching...`);
112
151
  const files = fs.readdirSync(binDir);
113
- console.log(`[sshifu] 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] Found ${exeFile}, renaming to ${binName}`);
117
- fs.renameSync(path.join(binDir, exeFile), binPath);
152
+ console.log(`[sshifu] Files in binDir (top level): ${files.join(', ')}`);
153
+
154
+ // Look for .exe file in binDir or any subdirectory
155
+ let foundFile = null;
156
+ for (const file of files) {
157
+ const filePath = path.join(binDir, file);
158
+ const stat = fs.statSync(filePath);
159
+ if (stat.isDirectory()) {
160
+ // Check subdirectory
161
+ const subFiles = fs.readdirSync(filePath);
162
+ console.log(`[sshifu] Files in ${file}/: ${subFiles.join(', ')}`);
163
+ const exeInSubdir = subFiles.find(f => f.endsWith('.exe') && f.startsWith(PACKAGE_NAME));
164
+ if (exeInSubdir) {
165
+ foundFile = path.join(filePath, exeInSubdir);
166
+ break;
167
+ }
168
+ } else if (file.endsWith('.exe') && file.startsWith(PACKAGE_NAME)) {
169
+ foundFile = filePath;
170
+ break;
171
+ }
172
+ }
173
+
174
+ if (foundFile) {
175
+ console.log(`[sshifu] Found ${foundFile}, renaming to ${binName}`);
176
+ fs.renameSync(foundFile, binPath);
177
+ } else {
178
+ throw new Error(`Could not find binary in ${binDir}`);
118
179
  }
119
180
  }
120
181
  }