sshifu 0.7.8-test.5 → 0.7.8-test.7

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 +42 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sshifu",
3
- "version": "0.7.8-test.5",
3
+ "version": "0.7.8-test.7",
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,20 @@ 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
+ try {
99
+ // Use PowerShell with explicit error action and output redirection
100
+ const psCommand = `Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force -ErrorAction Stop`;
101
+ console.log(`[sshifu] Running: ${psCommand}`);
102
+ execSync(`powershell -Command "${psCommand}"`, { stdio: ['ignore', 'pipe', 'pipe'] });
103
+ console.log(`[sshifu] Extraction completed, checking files...`);
104
+ const afterExtract = fs.readdirSync(binDir);
105
+ console.log(`[sshifu] Files after extraction: ${afterExtract.join(', ')}`);
106
+ } catch (extractErr) {
107
+ console.error(`[sshifu] Extraction failed: ${extractErr.message}`);
108
+ console.error(`[sshifu] stderr: ${extractErr.stderr?.toString() || 'N/A'}`);
109
+ console.error(`[sshifu] stdout: ${extractErr.stdout?.toString() || 'N/A'}`);
110
+ throw extractErr;
111
+ }
99
112
  } else {
100
113
  execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'ignore' });
101
114
  }
@@ -109,12 +122,35 @@ async function main() {
109
122
  fs.renameSync(extractedPath, binPath);
110
123
  } else {
111
124
  // Try to find the extracted file (in case of path issues)
125
+ console.log(`[sshifu] Binary not found at expected location, searching...`);
112
126
  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);
127
+ console.log(`[sshifu] Files in binDir (top level): ${files.join(', ')}`);
128
+
129
+ // Look for .exe file in binDir or any subdirectory
130
+ let foundFile = null;
131
+ for (const file of files) {
132
+ const filePath = path.join(binDir, file);
133
+ const stat = fs.statSync(filePath);
134
+ if (stat.isDirectory()) {
135
+ // Check subdirectory
136
+ const subFiles = fs.readdirSync(filePath);
137
+ console.log(`[sshifu] Files in ${file}/: ${subFiles.join(', ')}`);
138
+ const exeInSubdir = subFiles.find(f => f.endsWith('.exe') && f.startsWith(PACKAGE_NAME));
139
+ if (exeInSubdir) {
140
+ foundFile = path.join(filePath, exeInSubdir);
141
+ break;
142
+ }
143
+ } else if (file.endsWith('.exe') && file.startsWith(PACKAGE_NAME)) {
144
+ foundFile = filePath;
145
+ break;
146
+ }
147
+ }
148
+
149
+ if (foundFile) {
150
+ console.log(`[sshifu] Found ${foundFile}, renaming to ${binName}`);
151
+ fs.renameSync(foundFile, binPath);
152
+ } else {
153
+ throw new Error(`Could not find binary in ${binDir}`);
118
154
  }
119
155
  }
120
156
  }