sshifu 0.7.6 → 0.7.8-test.10
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.
- package/package.json +1 -1
- package/scripts/install.js +59 -6
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -95,7 +95,37 @@ 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
|
-
|
|
98
|
+
// On Windows, extract to temp directory first to avoid file lock issues
|
|
99
|
+
const tempDir = path.join(binDir, 'tmp_extract_' + Date.now());
|
|
100
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
const psCommand = `Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${tempDir.replace(/'/g, "''")}' -Force -ErrorAction Stop`;
|
|
104
|
+
console.log(`[sshifu] Running: ${psCommand}`);
|
|
105
|
+
execSync(`powershell -Command "${psCommand}"`, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
106
|
+
|
|
107
|
+
// Find the extracted binary
|
|
108
|
+
const tempFiles = fs.readdirSync(tempDir);
|
|
109
|
+
console.log(`[sshifu] Extracted files: ${tempFiles.join(', ')}`);
|
|
110
|
+
|
|
111
|
+
const extractedBin = tempFiles.find(f => f.endsWith('.exe') || !f.includes('.'));
|
|
112
|
+
if (!extractedBin) {
|
|
113
|
+
throw new Error(`No binary found in temp directory. Files: ${tempFiles.join(', ')}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Move to final location
|
|
117
|
+
const tempBinPath = path.join(tempDir, extractedBin);
|
|
118
|
+
fs.renameSync(tempBinPath, binPath);
|
|
119
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
120
|
+
|
|
121
|
+
console.log(`[sshifu] Binary installed successfully!`);
|
|
122
|
+
} catch (extractErr) {
|
|
123
|
+
// Cleanup temp dir on error
|
|
124
|
+
try { fs.rmSync(tempDir, { recursive: true, force: true }); } catch (e) {}
|
|
125
|
+
console.error(`[sshifu] Extraction failed: ${extractErr.message}`);
|
|
126
|
+
console.error(`[sshifu] stderr: ${extractErr.stderr?.toString() || 'N/A'}`);
|
|
127
|
+
throw extractErr;
|
|
128
|
+
}
|
|
99
129
|
} else {
|
|
100
130
|
execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'ignore' });
|
|
101
131
|
}
|
|
@@ -109,12 +139,35 @@ async function main() {
|
|
|
109
139
|
fs.renameSync(extractedPath, binPath);
|
|
110
140
|
} else {
|
|
111
141
|
// Try to find the extracted file (in case of path issues)
|
|
142
|
+
console.log(`[sshifu] Binary not found at expected location, searching...`);
|
|
112
143
|
const files = fs.readdirSync(binDir);
|
|
113
|
-
console.log(`[sshifu] Files in binDir: ${files.join(', ')}`);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
144
|
+
console.log(`[sshifu] Files in binDir (top level): ${files.join(', ')}`);
|
|
145
|
+
|
|
146
|
+
// Look for .exe file in binDir or any subdirectory
|
|
147
|
+
let foundFile = null;
|
|
148
|
+
for (const file of files) {
|
|
149
|
+
const filePath = path.join(binDir, file);
|
|
150
|
+
const stat = fs.statSync(filePath);
|
|
151
|
+
if (stat.isDirectory()) {
|
|
152
|
+
// Check subdirectory
|
|
153
|
+
const subFiles = fs.readdirSync(filePath);
|
|
154
|
+
console.log(`[sshifu] Files in ${file}/: ${subFiles.join(', ')}`);
|
|
155
|
+
const exeInSubdir = subFiles.find(f => f.endsWith('.exe') && f.startsWith(PACKAGE_NAME));
|
|
156
|
+
if (exeInSubdir) {
|
|
157
|
+
foundFile = path.join(filePath, exeInSubdir);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
} else if (file.endsWith('.exe') && file.startsWith(PACKAGE_NAME)) {
|
|
161
|
+
foundFile = filePath;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (foundFile) {
|
|
167
|
+
console.log(`[sshifu] Found ${foundFile}, renaming to ${binName}`);
|
|
168
|
+
fs.renameSync(foundFile, binPath);
|
|
169
|
+
} else {
|
|
170
|
+
throw new Error(`Could not find binary in ${binDir}`);
|
|
118
171
|
}
|
|
119
172
|
}
|
|
120
173
|
}
|