doc-fetch-cli 2.0.0 â 2.0.1
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/bin/postinstall.js +50 -6
- package/package.json +1 -1
package/bin/postinstall.js
CHANGED
|
@@ -41,6 +41,7 @@ console.log(`đĻ Will copy to: ${binaryName}\n`);
|
|
|
41
41
|
// List all available binaries for debugging
|
|
42
42
|
console.log('đ Available binaries in package:');
|
|
43
43
|
let hasPlatformBinary = false;
|
|
44
|
+
let foundBinary = null;
|
|
44
45
|
try {
|
|
45
46
|
const files = fs.readdirSync(packageDir);
|
|
46
47
|
const binaries = files.filter(f => f.includes('doc-fetch') && !f.endsWith('.js'));
|
|
@@ -50,10 +51,22 @@ try {
|
|
|
50
51
|
binaries.forEach(file => {
|
|
51
52
|
const stats = fs.statSync(path.join(packageDir, file));
|
|
52
53
|
const size = (stats.size / 1024 / 1024).toFixed(2);
|
|
53
|
-
|
|
54
|
+
|
|
55
|
+
// Check if this is the correct binary for current platform
|
|
56
|
+
let isCorrect = false;
|
|
57
|
+
if (platform === 'win32' && file.endsWith('.exe')) {
|
|
58
|
+
isCorrect = true;
|
|
59
|
+
foundBinary = file;
|
|
60
|
+
} else if (platform !== 'win32' && !file.endsWith('.exe') &&
|
|
61
|
+
(file === 'doc-fetch' || file.includes(`_${platform}_`))) {
|
|
62
|
+
isCorrect = true;
|
|
63
|
+
foundBinary = file;
|
|
64
|
+
}
|
|
65
|
+
|
|
54
66
|
const marker = isCorrect ? 'â
' : 'âšī¸ ';
|
|
55
67
|
console.log(` ${marker} ${file} (${size} MB)`);
|
|
56
|
-
|
|
68
|
+
|
|
69
|
+
if (isCorrect && file === expectedBinary) {
|
|
57
70
|
hasPlatformBinary = true;
|
|
58
71
|
}
|
|
59
72
|
});
|
|
@@ -63,10 +76,41 @@ try {
|
|
|
63
76
|
}
|
|
64
77
|
console.log('');
|
|
65
78
|
|
|
66
|
-
//
|
|
67
|
-
if (!hasPlatformBinary &&
|
|
68
|
-
console.
|
|
69
|
-
console.
|
|
79
|
+
// Smart detection: If we found a binary that works, use it!
|
|
80
|
+
if (!hasPlatformBinary && foundBinary && fs.existsSync(path.join(packageDir, foundBinary))) {
|
|
81
|
+
console.log(`â
Found compatible binary: ${foundBinary}`);
|
|
82
|
+
console.log(`đ Copying: ${foundBinary} â ${binaryName}`);
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
fs.copyFileSync(path.join(packageDir, foundBinary), path.join(packageDir, binaryName));
|
|
86
|
+
|
|
87
|
+
if (platform !== 'win32') {
|
|
88
|
+
fs.chmodSync(path.join(packageDir, binaryName), 0o755);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log(`â
Binary installed successfully!\n`);
|
|
92
|
+
|
|
93
|
+
// Verify it works
|
|
94
|
+
try {
|
|
95
|
+
const testPath = path.join(packageDir, binaryName);
|
|
96
|
+
if (fs.existsSync(testPath)) {
|
|
97
|
+
console.log('⨠Installation complete! You can now use: doc-fetch\n');
|
|
98
|
+
return; // Success!
|
|
99
|
+
}
|
|
100
|
+
} catch (e) {
|
|
101
|
+
// Continue to error handling
|
|
102
|
+
}
|
|
103
|
+
} catch (copyError) {
|
|
104
|
+
console.error(`â ī¸ Copy failed: ${copyError.message}`);
|
|
105
|
+
// Continue to error handling
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// If we get here, something really went wrong
|
|
110
|
+
if (!fs.existsSync(sourcePath) && !hasPlatformBinary && !foundBinary) {
|
|
111
|
+
console.error('â ī¸ CRITICAL: No compatible binary found!');
|
|
112
|
+
console.error(` Searched for: ${expectedBinary}`);
|
|
113
|
+
console.error(` Found instead: ${foundBinary || 'nothing compatible'}`);
|
|
70
114
|
console.error('');
|
|
71
115
|
console.error('đĄ This is a packaging error - the NPM package was published without your platform binary.');
|
|
72
116
|
console.error('');
|
package/package.json
CHANGED