doc-fetch-cli 1.1.1 → 1.1.3

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.
@@ -0,0 +1,242 @@
1
+ # DocFetch CLI Installation Fix
2
+
3
+ **Issue**: "Binary not found" error when installing via NPM
4
+ **Date**: February 20, 2026
5
+ **Fixed in**: v1.1.2
6
+
7
+ ---
8
+
9
+ ## šŸ› **Problem Analysis**
10
+
11
+ ### **Symptom 1: "Binary not found" error**
12
+ ```bash
13
+ $ npm install -g doc-fetch-cli
14
+ āŒ doc-fetch binary not found!
15
+ ```
16
+
17
+ **Root Cause**: The postinstall script wasn't copying the platform-specific binary to the expected location.
18
+
19
+ ### **Symptom 2: Command name confusion**
20
+ ```bash
21
+ $ npm install -g doc-fetch-cli
22
+ $ doc-fetch-cli --help # āŒ Doesn't work
23
+ $ doc-fetch --help # āœ… Works
24
+ ```
25
+
26
+ **This is actually CORRECT behavior!** Here's why:
27
+
28
+ In NPM packages:
29
+ - **Package name** (`doc-fetch-cli`): What you install
30
+ - **Bin command** (`doc-fetch`): What you run
31
+
32
+ This is standard practice. Examples:
33
+ - `npm install -g nodemon` → run `nodemon`
34
+ - `npm install -g typescript` → run `tsc`
35
+ - `npm install -g doc-fetch-cli` → run `doc-fetch`
36
+
37
+ ---
38
+
39
+ ## šŸ”§ **What Was Fixed**
40
+
41
+ ### **Fix 1: Improved Binary Detection**
42
+
43
+ Updated `bin/doc-fetch.js` to:
44
+ - āœ… Try multiple possible binary locations
45
+ - āœ… Detect platform and architecture correctly
46
+ - āœ… Provide helpful error messages with troubleshooting steps
47
+ - āœ… Support Linux (amd64/arm64), macOS, Windows
48
+
49
+ **Before**:
50
+ ```javascript
51
+ const binaryPath = path.join(__dirname, '..', 'doc-fetch');
52
+ // Only checked one location, failed if binary wasn't there
53
+ ```
54
+
55
+ **After**:
56
+ ```javascript
57
+ const possiblePaths = [
58
+ path.join(packageDir, binaryName), // Root directory
59
+ path.join(packageDir, 'bin', binaryName), // bin/ directory
60
+ // ... fallbacks
61
+ ];
62
+
63
+ // Tries each location until found
64
+ ```
65
+
66
+ ### **Fix 2: Proper Postinstall Script**
67
+
68
+ Updated `bin/postinstall.js` to:
69
+ - āœ… Copy the correct platform-specific binary
70
+ - āœ… Set executable permissions
71
+ - āœ… Verify the binary works
72
+ - āœ… Provide clear error messages if binary is missing
73
+
74
+ **Key logic**:
75
+ ```javascript
76
+ // Determine which binary to use for this platform
77
+ if (platform === 'linux') {
78
+ expectedBinary = 'doc-fetch_linux_amd64';
79
+ } else if (platform === 'darwin') {
80
+ expectedBinary = 'doc-fetch_darwin_amd64';
81
+ }
82
+
83
+ // Copy to expected location
84
+ fs.copyFileSync(sourcePath, destPath);
85
+ ```
86
+
87
+ ### **Fix 3: Added .npmignore**
88
+
89
+ Created `.npmignore` to ensure all necessary files are included in the NPM package:
90
+ - āœ… Go binaries for all platforms
91
+ - āœ… Bin wrapper scripts
92
+ - āœ… Postinstall script
93
+ - āŒ Excludes: source code, Python files, test files
94
+
95
+ ---
96
+
97
+ ## šŸ“¦ **How to Test the Fix**
98
+
99
+ ### **Clean Install Test**
100
+ ```bash
101
+ # Uninstall completely
102
+ npm uninstall -g doc-fetch-cli
103
+
104
+ # Clear npm cache
105
+ npm cache clean --force
106
+
107
+ # Install fresh
108
+ npm install -g doc-fetch-cli@latest
109
+
110
+ # Test (note: command is 'doc-fetch' not 'doc-fetch-cli')
111
+ doc-fetch --help
112
+ ```
113
+
114
+ ### **Expected Output**
115
+ ```
116
+ šŸŽ‰ DocFetch CLI installing...
117
+
118
+ šŸ“¦ Platform: linux x64
119
+ šŸ“¦ Expected binary: doc-fetch_linux_amd64
120
+
121
+ āœ… Binary installed: doc-fetch
122
+ āœ… Binary verified working
123
+
124
+ ✨ DocFetch CLI installed successfully!
125
+
126
+ Usage:
127
+ doc-fetch --url https://docs.example.com --output docs.md
128
+
129
+ Pro tip: Use --llm-txt flag to generate AI-friendly index files!
130
+ ```
131
+
132
+ ---
133
+
134
+ ## šŸŽÆ **Platform Support**
135
+
136
+ | Platform | Architecture | Binary Name | Status |
137
+ |----------|-------------|-------------|--------|
138
+ | Linux | x64 (amd64) | doc-fetch_linux_amd64 | āœ… Supported |
139
+ | Linux | ARM64 | doc-fetch_linux_arm64 | āš ļø Coming soon |
140
+ | macOS | x64 (amd64) | doc-fetch_darwin_amd64 | āœ… Supported |
141
+ | macOS | ARM64 (M1/M2) | doc-fetch_darwin_arm64 | āš ļø Coming soon |
142
+ | Windows | x64 (amd64) | doc-fetch_windows_amd64.exe | āœ… Supported |
143
+
144
+ ---
145
+
146
+ ## šŸ› **Troubleshooting**
147
+
148
+ ### **Error: "Binary not found"**
149
+
150
+ **Solution 1**: Reinstall
151
+ ```bash
152
+ npm uninstall -g doc-fetch-cli
153
+ npm install -g doc-fetch-cli
154
+ ```
155
+
156
+ **Solution 2**: Check what was installed
157
+ ```bash
158
+ ls -la $(npm root -g)/doc-fetch-cli/
159
+ ```
160
+
161
+ You should see:
162
+ ```
163
+ -rwxr-xr-x doc-fetch # ← The actual binary
164
+ -rwxr-xr-x doc-fetch_linux_amd64 # ← Platform-specific binary
165
+ drwxr-xr-x bin/ # ← Contains doc-fetch.js wrapper
166
+ ```
167
+
168
+ **Solution 3**: Manual installation
169
+ ```bash
170
+ # Download binary directly
171
+ wget https://github.com/AlphaTechini/doc-fetch/releases/download/v1.1.1/doc-fetch_linux_amd64
172
+ chmod +x doc-fetch_linux_amd64
173
+ sudo mv doc-fetch_linux_amd64 /usr/local/bin/doc-fetch
174
+ ```
175
+
176
+ ### **Error: "Command not found: doc-fetch-cli"**
177
+
178
+ **This is expected!** The command is `doc-fetch`, not `doc-fetch-cli`.
179
+
180
+ ```bash
181
+ # Wrong āŒ
182
+ doc-fetch-cli --help
183
+
184
+ # Correct āœ…
185
+ doc-fetch --help
186
+ ```
187
+
188
+ ### **Error: "Permission denied"**
189
+
190
+ **Solution**: Fix permissions
191
+ ```bash
192
+ # Find installation directory
193
+ DOC_FETCH_DIR=$(npm root -g)/doc-fetch-cli
194
+
195
+ # Fix permissions
196
+ chmod +x $DOC_FETCH_DIR/doc-fetch
197
+ chmod +x $DOC_FETCH_DIR/bin/doc-fetch.js
198
+ ```
199
+
200
+ ---
201
+
202
+ ## šŸ“ **For Future Releases**
203
+
204
+ ### **Publishing Checklist**
205
+
206
+ 1. Build all platform binaries:
207
+ ```bash
208
+ GOOS=linux GOARCH=amd64 go build -o doc-fetch_linux_amd64 ./cmd
209
+ GOOS=darwin GOARCH=amd64 go build -o doc-fetch_darwin_amd64 ./cmd
210
+ GOOS=windows GOARCH=amd64 go build -o doc-fetch_windows_amd64.exe ./cmd
211
+ ```
212
+
213
+ 2. Verify `.npmignore` includes:
214
+ - āœ… All platform binaries
215
+ - āœ… `bin/` directory
216
+ - āœ… `package.json` with correct `bin` field
217
+
218
+ 3. Test installation locally:
219
+ ```bash
220
+ npm pack # Create tarball
221
+ npm install -g ./doc-fetch-cli-*.tgz # Install locally
222
+ doc-fetch --help # Test
223
+ ```
224
+
225
+ 4. Publish:
226
+ ```bash
227
+ npm publish
228
+ ```
229
+
230
+ ---
231
+
232
+ ## šŸ”— **Related Issues**
233
+
234
+ - GitHub Issue: [#XX](https://github.com/AlphaTechini/doc-fetch/issues/XX)
235
+ - NPM Package: https://www.npmjs.com/package/doc-fetch-cli
236
+ - Documentation: https://github.com/AlphaTechini/doc-fetch/blob/main/README.md
237
+
238
+ ---
239
+
240
+ **Last Updated**: February 20, 2026
241
+ **Version**: 1.1.2
242
+ **Status**: āœ… Fixed and tested
package/bin/doc-fetch.js CHANGED
@@ -2,16 +2,51 @@
2
2
  const { spawn } = require('child_process');
3
3
  const path = require('path');
4
4
  const os = require('os');
5
+ const fs = require('fs');
5
6
 
6
- // Determine binary path based on platform
7
- const binDir = path.join(__dirname, '..');
8
- const binaryName = os.platform() === 'win32' ? 'doc-fetch.exe' : 'doc-fetch';
9
- const binaryPath = path.join(binDir, binaryName);
7
+ // Get the package installation directory
8
+ const packageDir = path.join(__dirname, '..');
10
9
 
11
- // Check if binary exists
12
- if (!require('fs').existsSync(binaryPath)) {
10
+ // Determine binary name based on platform
11
+ const platform = os.platform();
12
+ const arch = os.arch();
13
+ let binaryName;
14
+
15
+ if (platform === 'win32') {
16
+ binaryName = 'doc-fetch.exe';
17
+ } else if (platform === 'darwin') {
18
+ binaryName = 'doc-fetch_darwin_amd64';
19
+ } else {
20
+ // Linux and others
21
+ binaryName = arch === 'arm64' ? 'doc-fetch_linux_arm64' : 'doc-fetch_linux_amd64';
22
+ }
23
+
24
+ // Try multiple possible locations
25
+ const possiblePaths = [
26
+ path.join(packageDir, binaryName), // Root directory
27
+ path.join(packageDir, 'bin', binaryName), // bin/ directory
28
+ path.join(packageDir, binaryName.replace('_linux_amd64', '')), // Fallback to generic name
29
+ ];
30
+
31
+ // Find the binary
32
+ let binaryPath = null;
33
+ for (const testPath of possiblePaths) {
34
+ if (fs.existsSync(testPath)) {
35
+ binaryPath = testPath;
36
+ break;
37
+ }
38
+ }
39
+
40
+ if (!binaryPath) {
13
41
  console.error('āŒ doc-fetch binary not found!');
14
- console.error('šŸ’” Please run: npm install doc-fetch');
42
+ console.error('');
43
+ console.error('šŸ’” Troubleshooting steps:');
44
+ console.error(' 1. Reinstall: npm uninstall -g doc-fetch-cli && npm install -g doc-fetch-cli');
45
+ console.error(' 2. Check installation: ls -la $(npm root -g)/doc-fetch-cli/');
46
+ console.error(' 3. Report issue: https://github.com/AlphaTechini/doc-fetch/issues');
47
+ console.error('');
48
+ console.error(` Expected binary: ${possiblePaths[0]}`);
49
+ console.error(` Platform: ${platform} ${arch}`);
15
50
  process.exit(1);
16
51
  }
17
52
 
@@ -24,8 +59,11 @@ const child = spawn(binaryPath, args, {
24
59
 
25
60
  child.on('error', (err) => {
26
61
  if (err.code === 'ENOENT') {
27
- console.error('āŒ doc-fetch binary not found!');
28
- console.error('šŸ’” Please run: npm install doc-fetch');
62
+ console.error('āŒ Failed to execute doc-fetch binary');
63
+ console.error(` Binary path: ${binaryPath}`);
64
+ console.error(' Error: Binary file may be corrupted or missing execute permissions');
65
+ console.error('');
66
+ console.error('šŸ’” Try reinstalling: npm uninstall -g doc-fetch-cli && npm install -g doc-fetch-cli');
29
67
  } else {
30
68
  console.error('āŒ Failed to start doc-fetch:', err.message);
31
69
  }
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Post-install script for doc-fetch-cli
4
- * Checks if global bin directory is in PATH and provides helpful instructions
4
+ * Copies the correct platform-specific binary and sets up PATH
5
5
  */
6
6
 
7
7
  const { execSync } = require('child_process');
@@ -9,75 +9,119 @@ const path = require('path');
9
9
  const os = require('os');
10
10
  const fs = require('fs');
11
11
 
12
- console.log('šŸŽ‰ DocFetch CLI installed successfully!\n');
12
+ console.log('šŸŽ‰ DocFetch CLI installing...\n');
13
13
 
14
- // Get npm global prefix
15
- let globalPrefix;
14
+ const packageDir = path.join(__dirname, '..');
15
+ const platform = os.platform();
16
+ const arch = os.arch();
17
+
18
+ // Determine which binary to use
19
+ let binaryName;
20
+ let expectedBinary;
21
+
22
+ if (platform === 'win32') {
23
+ binaryName = 'doc-fetch.exe';
24
+ expectedBinary = 'doc-fetch_windows_amd64.exe';
25
+ } else if (platform === 'darwin') {
26
+ binaryName = 'doc-fetch';
27
+ expectedBinary = 'doc-fetch_darwin_amd64';
28
+ } else {
29
+ // Linux
30
+ binaryName = 'doc-fetch';
31
+ expectedBinary = arch === 'arm64' ? 'doc-fetch_linux_arm64' : 'doc-fetch_linux_amd64';
32
+ }
33
+
34
+ const sourcePath = path.join(packageDir, expectedBinary);
35
+ const destPath = path.join(packageDir, binaryName);
36
+
37
+ console.log(`šŸ“¦ Platform: ${platform} ${arch}`);
38
+ console.log(`šŸ“¦ Expected binary: ${expectedBinary}`);
39
+ console.log(`šŸ“¦ Will copy to: ${binaryName}\n`);
40
+
41
+ // Check if the expected binary exists
42
+ if (!fs.existsSync(sourcePath)) {
43
+ console.error(`āš ļø CRITICAL: Expected binary not found at: ${sourcePath}`);
44
+ console.error('');
45
+ console.error('šŸ’” Listing package contents:');
46
+ try {
47
+ const files = fs.readdirSync(packageDir);
48
+ files.forEach(file => {
49
+ if (file.includes('doc-fetch')) {
50
+ console.error(` šŸ“„ ${file}`);
51
+ }
52
+ });
53
+ } catch (e) {
54
+ console.error(` Could not list directory: ${e.message}`);
55
+ }
56
+ console.error('');
57
+ console.error('šŸ’” This might be because:');
58
+ console.error(' 1. The package was published without binaries');
59
+ console.error(' 2. Your platform/architecture is not supported');
60
+ console.error('');
61
+ console.error('Supported platforms:');
62
+ console.error(' - Linux x64 (amd64)');
63
+ console.error(' - macOS x64 (amd64)');
64
+ console.error(' - Windows x64 (amd64)');
65
+ console.error('');
66
+ console.error('šŸ’” Workaround: Install from source');
67
+ console.error(' npm uninstall -g doc-fetch-cli');
68
+ console.error(' git clone https://github.com/AlphaTechini/doc-fetch.git');
69
+ console.error(' cd doc-fetch && go build -o doc-fetch ./cmd/docfetch');
70
+ if (platform === 'win32') {
71
+ console.error(' copy doc-fetch.exe %APPDATA%\\npm\\node_modules\\doc-fetch-cli\\');
72
+ } else {
73
+ console.error(' sudo cp doc-fetch /usr/local/bin/');
74
+ }
75
+ process.exit(1);
76
+ }
77
+
78
+ console.log(`āœ… Found source binary: ${expectedBinary}`);
79
+
80
+ // Copy the binary to the expected location
16
81
  try {
17
- globalPrefix = execSync('npm config get prefix', { encoding: 'utf8' }).trim();
82
+ console.log(`šŸ“‹ Copying: ${expectedBinary} → ${binaryName}`);
83
+ fs.copyFileSync(sourcePath, destPath);
84
+ console.log(`āœ… Copy successful`);
85
+
86
+ // Verify the destination exists
87
+ if (!fs.existsSync(destPath)) {
88
+ throw new Error('Destination file does not exist after copy');
89
+ }
90
+
91
+ // Make executable on Unix-like systems
92
+ if (platform !== 'win32') {
93
+ fs.chmodSync(destPath, 0o755);
94
+ console.log(`āœ… Set executable permissions`);
95
+ } else {
96
+ console.log(`ā„¹ļø Windows: No chmod needed`);
97
+ }
98
+
99
+ console.log(`\nāœ… Binary installed: ${binaryName}`);
18
100
  } catch (error) {
19
- console.error('āš ļø Could not determine npm global prefix');
20
- globalPrefix = null;
101
+ console.error(`\nāŒ CRITICAL: Failed to install binary!`);
102
+ console.error(` Source: ${sourcePath}`);
103
+ console.error(` Destination: ${destPath}`);
104
+ console.error(` Error: ${error.message}`);
105
+ console.error('');
106
+ console.error('šŸ’” Manual fix:');
107
+ console.error(` 1. Navigate to: ${packageDir}`);
108
+ console.error(` 2. Rename: ${expectedBinary} → ${binaryName}`);
109
+ if (platform !== 'win32') {
110
+ console.error(` 3. Run: chmod +x ${binaryName}`);
111
+ }
112
+ process.exit(1);
21
113
  }
22
114
 
23
- if (globalPrefix) {
24
- const binDir = path.join(globalPrefix, 'bin');
25
- const isWindows = os.platform() === 'win32';
26
-
27
- console.log(`šŸ“¦ Installed to: ${binDir}\n`);
28
-
29
- // Check if bin directory is in PATH
30
- const pathEnv = process.env.PATH || '';
31
- const pathDirs = pathEnv.split(isWindows ? ';' : ':');
32
- const isInPath = pathDirs.some(dir => path.resolve(dir) === path.resolve(binDir));
33
-
34
- if (!isInPath) {
35
- console.log('āš ļø WARNING: Global bin directory is not in your PATH!\n');
36
- console.log('To use doc-fetch-cli, add this directory to your PATH:\n');
37
- console.log(` ${binDir}\n`);
38
-
39
- // Provide platform-specific instructions
40
- const shell = process.env.SHELL || '/bin/bash';
41
- const isZsh = shell.includes('zsh');
42
- const isBash = shell.includes('bash');
43
-
44
- console.log('Quick fix:\n');
45
-
46
- if (isWindows) {
47
- console.log('1. Open System Properties → Environment Variables');
48
- console.log('2. Edit PATH variable');
49
- console.log('3. Add this path:');
50
- console.log(` ${binDir}`);
51
- console.log('4. Restart your terminal\n');
52
- } else if (isZsh) {
53
- console.log('Add this to your ~/.zshrc:');
54
- console.log(` export PATH="${binDir}:$PATH"\n`);
55
- console.log('Then run: source ~/.zshrc\n');
56
- } else if (isBash) {
57
- console.log('Add this to your ~/.bashrc or ~/.bash_profile:');
58
- console.log(` export PATH="${binDir}:$PATH"\n`);
59
- console.log('Then run: source ~/.bashrc\n');
60
- }
61
-
62
- console.log('Alternative: Use npx without installing globally\n');
63
- console.log(' npx doc-fetch-cli --url https://docs.example.com --output docs.md\n');
64
- } else {
65
- console.log('āœ… Global bin directory is in your PATH\n');
66
- console.log('You can now use doc-fetch-cli!\n');
67
- console.log('Example usage:');
68
- console.log(' doc-fetch --url https://docs.python.org/3 --output docs.md --llm-txt\n');
69
-
70
- // Test if the command works
71
- try {
72
- execSync('doc-fetch --version', { encoding: 'utf8', stdio: 'pipe' });
73
- console.log('āœ… Command verified working!\n');
74
- } catch (error) {
75
- console.log('āš ļø Command not found in current shell session.\n');
76
- console.log('Try running: hash -r (to clear command cache)\n');
77
- console.log('Or restart your terminal.\n');
78
- }
79
- }
115
+ // Verify installation
116
+ try {
117
+ const result = execSync(`"${destPath}" --help`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
118
+ console.log('āœ… Binary verified working\n');
119
+ } catch (error) {
120
+ console.error('āš ļø Warning: Could not verify binary execution');
121
+ console.error(` Error: ${error.message}\n`);
80
122
  }
81
123
 
82
- console.log('šŸ“š Documentation: https://github.com/AlphaTechini/doc-fetch\n');
83
- console.log('✨ Pro tip: Use --llm-txt flag to generate AI-friendly index files!\n');
124
+ console.log('✨ DocFetch CLI installed successfully!\n');
125
+ console.log('Usage:');
126
+ console.log(' doc-fetch --url https://docs.example.com --output docs.md\n');
127
+ console.log('Pro tip: Use --llm-txt flag to generate AI-friendly index files!\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doc-fetch-cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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"
@@ -12,7 +12,14 @@
12
12
  "type": "git",
13
13
  "url": "https://github.com/AlphaTechini/doc-fetch.git"
14
14
  },
15
- "keywords": ["documentation", "ai", "llm", "markdown", "crawler", "security"],
15
+ "keywords": [
16
+ "documentation",
17
+ "ai",
18
+ "llm",
19
+ "markdown",
20
+ "crawler",
21
+ "security"
22
+ ],
16
23
  "author": "AlphaTechini",
17
24
  "license": "MIT"
18
- }
25
+ }