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.
Files changed (2) hide show
  1. package/bin/postinstall.js +50 -6
  2. package/package.json +1 -1
@@ -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
- const isCorrect = file === expectedBinary || file === binaryName;
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
- if (file === expectedBinary) {
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
- // Extra validation: Check if platform binary exists
67
- if (!hasPlatformBinary && !fs.existsSync(sourcePath)) {
68
- console.error('âš ī¸ CRITICAL: Platform binary missing!');
69
- console.error(` Expected: ${expectedBinary}`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doc-fetch-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Dynamic documentation fetching CLI that converts entire documentation sites to single markdown files for AI/LLM consumption",
5
5
  "bin": {
6
6
  "doc-fetch": "./bin/doc-fetch.js"