doc-fetch-cli 2.0.0 â 2.0.2
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 +63 -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,54 @@ try {
|
|
|
63
76
|
}
|
|
64
77
|
console.log('');
|
|
65
78
|
|
|
66
|
-
//
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
// Smart detection: Copy platform binary to generic name if needed
|
|
80
|
+
if (foundBinary && fs.existsSync(path.join(packageDir, foundBinary))) {
|
|
81
|
+
// Check if we need to copy (found binary != expected generic name)
|
|
82
|
+
if (foundBinary !== binaryName) {
|
|
83
|
+
console.log(`â
Found platform binary: ${foundBinary}`);
|
|
84
|
+
console.log(`đ Copying to: ${binaryName}`);
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
fs.copyFileSync(path.join(packageDir, foundBinary), path.join(packageDir, binaryName));
|
|
88
|
+
|
|
89
|
+
if (platform !== 'win32') {
|
|
90
|
+
fs.chmodSync(path.join(packageDir, binaryName), 0o755);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log(`â
Binary installed successfully!\n`);
|
|
94
|
+
|
|
95
|
+
// Verify it works
|
|
96
|
+
const testPath = path.join(packageDir, binaryName);
|
|
97
|
+
if (fs.existsSync(testPath)) {
|
|
98
|
+
console.log('⨠Installation complete! You can now use: doc-fetch\n');
|
|
99
|
+
return; // Success!
|
|
100
|
+
}
|
|
101
|
+
} catch (copyError) {
|
|
102
|
+
console.error(`â ī¸ Copy failed: ${copyError.message}`);
|
|
103
|
+
console.error('');
|
|
104
|
+
console.error('đĄ Manual fix:');
|
|
105
|
+
console.error(` cd "${packageDir}"`);
|
|
106
|
+
if (platform === 'win32') {
|
|
107
|
+
console.error(` copy "${foundBinary}" "${binaryName}"`);
|
|
108
|
+
} else {
|
|
109
|
+
console.error(` cp "${foundBinary}" "${binaryName}"`);
|
|
110
|
+
console.error(` chmod +x "${binaryName}"`);
|
|
111
|
+
}
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
// Binary already has correct name
|
|
116
|
+
console.log(`â
Binary already correctly named: ${binaryName}\n`);
|
|
117
|
+
console.log('⨠Installation complete! You can now use: doc-fetch\n');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// If we get here, something really went wrong
|
|
123
|
+
if (!fs.existsSync(sourcePath) && !hasPlatformBinary && !foundBinary) {
|
|
124
|
+
console.error('â ī¸ CRITICAL: No compatible binary found!');
|
|
125
|
+
console.error(` Searched for: ${expectedBinary}`);
|
|
126
|
+
console.error(` Found instead: ${foundBinary || 'nothing compatible'}`);
|
|
70
127
|
console.error('');
|
|
71
128
|
console.error('đĄ This is a packaging error - the NPM package was published without your platform binary.');
|
|
72
129
|
console.error('');
|
package/package.json
CHANGED