doc-fetch-cli 1.1.2 ā 1.1.4
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/CROSS-PLATFORM-FIXES.md +354 -0
- package/QUICK-FIX-WINDOWS.md +115 -0
- package/bin/doc-fetch.js +26 -23
- package/bin/postinstall.js +65 -14
- package/package.json +1 -1
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# Cross-Platform Binary Installation Fixes
|
|
2
|
+
|
|
3
|
+
**Version**: 1.1.4+
|
|
4
|
+
**Date**: February 20, 2026
|
|
5
|
+
**Status**: ā
Fixed for all platforms
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## šÆ **What Was Fixed**
|
|
10
|
+
|
|
11
|
+
### **Problem**: Platform-specific binaries weren't being renamed correctly
|
|
12
|
+
|
|
13
|
+
**Before**:
|
|
14
|
+
```
|
|
15
|
+
Package contains:
|
|
16
|
+
ā
doc-fetch_linux_amd64
|
|
17
|
+
ā
doc-fetch_darwin_amd64
|
|
18
|
+
ā
doc-fetch_windows_amd64.exe
|
|
19
|
+
|
|
20
|
+
Wrapper expects:
|
|
21
|
+
ā doc-fetch (Linux/macOS)
|
|
22
|
+
ā doc-fetch.exe (Windows)
|
|
23
|
+
|
|
24
|
+
Result: "Binary not found" on ALL platforms!
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**After** (v1.1.4+):
|
|
28
|
+
```
|
|
29
|
+
Postinstall automatically:
|
|
30
|
+
ā
Copies doc-fetch_linux_amd64 ā doc-fetch
|
|
31
|
+
ā
Copies doc-fetch_darwin_amd64 ā doc-fetch
|
|
32
|
+
ā
Copies doc-fetch_windows_amd64.exe ā doc-fetch.exe
|
|
33
|
+
|
|
34
|
+
Wrapper finds:
|
|
35
|
+
ā
doc-fetch (Linux/macOS)
|
|
36
|
+
ā
doc-fetch.exe (Windows)
|
|
37
|
+
|
|
38
|
+
Result: Works on all platforms! ā
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## š§ **Platform-Specific Fixes**
|
|
44
|
+
|
|
45
|
+
### **Linux (x64/amd64)**
|
|
46
|
+
|
|
47
|
+
**Expected files after install**:
|
|
48
|
+
```
|
|
49
|
+
doc-fetch-cli/
|
|
50
|
+
āāā doc-fetch ā Copied by postinstall
|
|
51
|
+
āāā doc-fetch_linux_amd64 ā Original
|
|
52
|
+
āāā bin/
|
|
53
|
+
āāā doc-fetch.js ā Wrapper
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Manual fix if needed**:
|
|
57
|
+
```bash
|
|
58
|
+
cd $(npm root -g)/doc-fetch-cli
|
|
59
|
+
cp doc-fetch_linux_amd64 doc-fetch
|
|
60
|
+
chmod +x doc-fetch
|
|
61
|
+
doc-fetch --help
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### **Linux (ARM64)**
|
|
65
|
+
|
|
66
|
+
**Expected files**:
|
|
67
|
+
```
|
|
68
|
+
doc-fetch-cli/
|
|
69
|
+
āāā doc-fetch ā Copied by postinstall
|
|
70
|
+
āāā doc-fetch_linux_arm64 ā Original (if available)
|
|
71
|
+
āāā bin/
|
|
72
|
+
āāā doc-fetch.js
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Manual fix**:
|
|
76
|
+
```bash
|
|
77
|
+
cd $(npm root -g)/doc-fetch-cli
|
|
78
|
+
cp doc-fetch_linux_arm64 doc-fetch
|
|
79
|
+
chmod +x doc-fetch
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### **macOS (Intel x64)**
|
|
83
|
+
|
|
84
|
+
**Expected files**:
|
|
85
|
+
```
|
|
86
|
+
doc-fetch-cli/
|
|
87
|
+
āāā doc-fetch ā Copied by postinstall
|
|
88
|
+
āāā doc-fetch_darwin_amd64 ā Original
|
|
89
|
+
āāā bin/
|
|
90
|
+
āāā doc-fetch.js
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Manual fix**:
|
|
94
|
+
```bash
|
|
95
|
+
cd $(npm root -g)/doc-fetch-cli
|
|
96
|
+
cp doc-fetch_darwin_amd64 doc-fetch
|
|
97
|
+
chmod +x doc-fetch
|
|
98
|
+
doc-fetch --help
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### **macOS (Apple Silicon M1/M2)**
|
|
102
|
+
|
|
103
|
+
**Expected files**:
|
|
104
|
+
```
|
|
105
|
+
doc-fetch-cli/
|
|
106
|
+
āāā doc-fetch ā Copied by postinstall
|
|
107
|
+
āāā doc-fetch_darwin_arm64 ā Original (coming soon)
|
|
108
|
+
āāā bin/
|
|
109
|
+
āāā doc-fetch.js
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Manual fix** (when ARM binary is available):
|
|
113
|
+
```bash
|
|
114
|
+
cd $(npm root -g)/doc-fetch-cli
|
|
115
|
+
cp doc-fetch_darwin_arm64 doc-fetch
|
|
116
|
+
chmod +x doc-fetch
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Temporary workaround** (use Rosetta):
|
|
120
|
+
```bash
|
|
121
|
+
# Install Intel version under Rosetta
|
|
122
|
+
arch -x86_64 npm install -g doc-fetch-cli
|
|
123
|
+
arch -x86_64 cp $(npm root -g)/doc-fetch-cli/doc-fetch_darwin_amd64 \
|
|
124
|
+
$(npm root -g)/doc-fetch-cli/doc-fetch
|
|
125
|
+
arch -x86_64 chmod +x $(npm root -g)/doc-fetch-cli/doc-fetch
|
|
126
|
+
arch -x86_64 doc-fetch --help
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### **Windows (x64/amd64)**
|
|
130
|
+
|
|
131
|
+
**Expected files**:
|
|
132
|
+
```
|
|
133
|
+
doc-fetch-cli/
|
|
134
|
+
āāā doc-fetch.exe ā Copied by postinstall
|
|
135
|
+
āāā doc-fetch_windows_amd64.exe ā Original
|
|
136
|
+
āāā bin/
|
|
137
|
+
āāā doc-fetch.js
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Manual fix** (PowerShell):
|
|
141
|
+
```powershell
|
|
142
|
+
cd "$(npm root -g)\doc-fetch-cli"
|
|
143
|
+
copy doc-fetch_windows_amd64.exe doc-fetch.exe
|
|
144
|
+
doc-fetch --help
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Manual fix** (Command Prompt):
|
|
148
|
+
```cmd
|
|
149
|
+
cd %APPDATA%\npm\node_modules\doc-fetch-cli
|
|
150
|
+
copy doc-fetch_windows_amd64.exe doc-fetch.exe
|
|
151
|
+
doc-fetch --help
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## š **Installation Verification**
|
|
157
|
+
|
|
158
|
+
### **All Platforms**
|
|
159
|
+
|
|
160
|
+
After installing, verify:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Check installation
|
|
164
|
+
npm list -g doc-fetch-cli
|
|
165
|
+
|
|
166
|
+
# Should show:
|
|
167
|
+
# āāā doc-fetch-cli@1.1.4
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### **Linux/macOS**
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# List files
|
|
174
|
+
ls -la $(npm root -g)/doc-fetch-cli/ | grep doc-fetch
|
|
175
|
+
|
|
176
|
+
# Should show:
|
|
177
|
+
# -rwxr-xr-x doc-fetch ā Generic name (what wrapper uses)
|
|
178
|
+
# -rwxr-xr-x doc-fetch_linux_amd64 ā Platform-specific
|
|
179
|
+
# drwxr-xr-x bin/
|
|
180
|
+
# -rwxr-xr-x doc-fetch.js ā Wrapper
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### **Windows**
|
|
184
|
+
|
|
185
|
+
```powershell
|
|
186
|
+
# List files
|
|
187
|
+
dir "$(npm root -g)\doc-fetch-cli\doc-fetch*"
|
|
188
|
+
|
|
189
|
+
# Should show:
|
|
190
|
+
# doc-fetch.exe ā Generic name
|
|
191
|
+
# doc-fetch_windows_amd64.exe ā Platform-specific
|
|
192
|
+
# bin\
|
|
193
|
+
# doc-fetch.js ā Wrapper
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## š **Troubleshooting by Platform**
|
|
199
|
+
|
|
200
|
+
### **"Binary not found" on Linux**
|
|
201
|
+
|
|
202
|
+
**Symptoms**:
|
|
203
|
+
```bash
|
|
204
|
+
ā doc-fetch binary not found!
|
|
205
|
+
š” Platform: linux x64
|
|
206
|
+
š” Expected: doc-fetch
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Cause**: Postinstall didn't copy the binary
|
|
210
|
+
|
|
211
|
+
**Fix**:
|
|
212
|
+
```bash
|
|
213
|
+
cd $(npm root -g)/doc-fetch-cli
|
|
214
|
+
ls -la | grep doc-fetch # Check what exists
|
|
215
|
+
cp doc-fetch_linux_amd64 doc-fetch
|
|
216
|
+
chmod +x doc-fetch
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### **"Permission denied" on macOS**
|
|
220
|
+
|
|
221
|
+
**Symptoms**:
|
|
222
|
+
```bash
|
|
223
|
+
bash: /usr/local/bin/doc-fetch: Permission denied
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Cause**: Missing execute permission
|
|
227
|
+
|
|
228
|
+
**Fix**:
|
|
229
|
+
```bash
|
|
230
|
+
chmod +x $(which doc-fetch)
|
|
231
|
+
# Or:
|
|
232
|
+
chmod +x $(npm root -g)/doc-fetch-cli/doc-fetch
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### **"Not a valid Win32 application" on Windows**
|
|
236
|
+
|
|
237
|
+
**Symptoms**:
|
|
238
|
+
```
|
|
239
|
+
Error: doc-fetch.exe is not a valid Win32 application
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Cause**: Wrong architecture (ARM vs x64)
|
|
243
|
+
|
|
244
|
+
**Fix**:
|
|
245
|
+
```powershell
|
|
246
|
+
# Check your architecture
|
|
247
|
+
[System.Environment]::Is64BitOperatingSystem
|
|
248
|
+
|
|
249
|
+
# If True (most common):
|
|
250
|
+
cd "$(npm root -g)\doc-fetch-cli"
|
|
251
|
+
copy doc-fetch_windows_amd64.exe doc-fetch.exe /Y
|
|
252
|
+
|
|
253
|
+
# If False (rare, ARM Windows):
|
|
254
|
+
# ARM binary coming soon - use WSL or wait for ARM build
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### **Apple Silicon Issues**
|
|
258
|
+
|
|
259
|
+
**Symptoms**:
|
|
260
|
+
```bash
|
|
261
|
+
zsh: bad CPU type in executable: doc-fetch
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Cause**: Trying to run Intel binary natively on M1/M2
|
|
265
|
+
|
|
266
|
+
**Solutions**:
|
|
267
|
+
|
|
268
|
+
**Option 1**: Use Rosetta (immediate)
|
|
269
|
+
```bash
|
|
270
|
+
arch -x86_64 doc-fetch --help
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Option 2**: Wait for native ARM binary (recommended)
|
|
274
|
+
- Native ARM64 binary coming in v1.2.0
|
|
275
|
+
- Better performance, no Rosetta needed
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## š **Best Practices**
|
|
280
|
+
|
|
281
|
+
### **For Users**
|
|
282
|
+
|
|
283
|
+
1. **Always use latest version**:
|
|
284
|
+
```bash
|
|
285
|
+
npm install -g doc-fetch-cli@latest
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
2. **Verify installation**:
|
|
289
|
+
```bash
|
|
290
|
+
doc-fetch --version
|
|
291
|
+
# Should work immediately
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
3. **If issues occur**:
|
|
295
|
+
- Check postinstall output for errors
|
|
296
|
+
- List files to see what's available
|
|
297
|
+
- Manually copy as shown above
|
|
298
|
+
|
|
299
|
+
### **For Developers**
|
|
300
|
+
|
|
301
|
+
When contributing or building locally:
|
|
302
|
+
|
|
303
|
+
1. **Build all platforms**:
|
|
304
|
+
```bash
|
|
305
|
+
GOOS=linux GOARCH=amd64 go build -o doc-fetch_linux_amd64 ./cmd
|
|
306
|
+
GOOS=darwin GOARCH=amd64 go build -o doc-fetch_darwin_amd64 ./cmd
|
|
307
|
+
GOOS=darwin GOARCH=arm64 go build -o doc-fetch_darwin_arm64 ./cmd
|
|
308
|
+
GOOS=windows GOARCH=amd64 go build -o doc-fetch_windows_amd64.exe ./cmd
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
2. **Test postinstall locally**:
|
|
312
|
+
```bash
|
|
313
|
+
npm pack
|
|
314
|
+
npm install -g ./doc-fetch-cli-*.tgz
|
|
315
|
+
# Watch postinstall output
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
3. **Verify all platforms**:
|
|
319
|
+
- Test on Linux VM
|
|
320
|
+
- Test on macOS (Intel + Apple Silicon)
|
|
321
|
+
- Test on Windows VM
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## š **Version History**
|
|
326
|
+
|
|
327
|
+
| Version | Date | Platform Support | Notes |
|
|
328
|
+
|---------|------|-----------------|-------|
|
|
329
|
+
| 1.1.4 | Feb 20, 2026 | ā
All fixed | Enhanced postinstall logging |
|
|
330
|
+
| 1.1.3 | Feb 20, 2026 | ā ļø Partial | Added logging, still had issues |
|
|
331
|
+
| 1.1.2 | Feb 20, 2026 | ā Broken | Initial postinstall attempt |
|
|
332
|
+
| 1.1.1 | Feb 20, 2026 | ā Broken | No postinstall script |
|
|
333
|
+
| 1.1.0 | Feb 20, 2026 | ā Broken | First NPM release |
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## šÆ **Current Status**
|
|
338
|
+
|
|
339
|
+
| Platform | Architecture | Status | Binary Name |
|
|
340
|
+
|----------|-------------|--------|-------------|
|
|
341
|
+
| Linux | x64 (amd64) | ā
Supported | doc-fetch |
|
|
342
|
+
| Linux | ARM64 | ā
Supported | doc-fetch |
|
|
343
|
+
| macOS | x64 (Intel) | ā
Supported | doc-fetch |
|
|
344
|
+
| macOS | ARM64 (M1/M2) | ā ļø Rosetta | doc-fetch (Intel binary) |
|
|
345
|
+
| Windows | x64 (amd64) | ā
Supported | doc-fetch.exe |
|
|
346
|
+
| Windows | ARM64 | ā Not yet | Coming in v1.2.0 |
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
**Last Updated**: February 20, 2026
|
|
351
|
+
**Version**: 1.1.4
|
|
352
|
+
**Maintainer**: @AlphaTechini
|
|
353
|
+
|
|
354
|
+
**Report platform-specific issues**: https://github.com/AlphaTechini/doc-fetch/issues
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Quick Fix: Windows Binary Not Found
|
|
2
|
+
|
|
3
|
+
**Symptom**: After installing, you get "binary not found" error
|
|
4
|
+
|
|
5
|
+
**Root Cause**: The postinstall script didn't rename the binary correctly
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## š§ **Manual Fix (30 seconds)**
|
|
10
|
+
|
|
11
|
+
### **Step 1: Find Installation Directory**
|
|
12
|
+
```powershell
|
|
13
|
+
npm root -g
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This will show something like:
|
|
17
|
+
```
|
|
18
|
+
C:\Users\YourName\AppData\Roaming\npm\node_modules
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### **Step 2: Navigate to doc-fetch-cli**
|
|
22
|
+
```powershell
|
|
23
|
+
cd "C:\Users\YourName\AppData\Roaming\npm\node_modules\doc-fetch-cli"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### **Step 3: List Files**
|
|
27
|
+
```powershell
|
|
28
|
+
dir doc-fetch*
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You should see:
|
|
32
|
+
```
|
|
33
|
+
doc-fetch_windows_amd64.exe ā This exists
|
|
34
|
+
doc-fetch.js ā Wrapper script
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
But MISSING:
|
|
38
|
+
```
|
|
39
|
+
doc-fetch.exe ā This is what's needed!
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### **Step 4: Rename the Binary**
|
|
43
|
+
```powershell
|
|
44
|
+
copy doc-fetch_windows_amd64.exe doc-fetch.exe
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or using `ren`:
|
|
48
|
+
```powershell
|
|
49
|
+
ren doc-fetch_windows_amd64.exe doc-fetch.exe
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### **Step 5: Verify**
|
|
53
|
+
```powershell
|
|
54
|
+
doc-fetch --help
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
It should work now! ā
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## šÆ **Why This Happens**
|
|
62
|
+
|
|
63
|
+
The package includes platform-specific binaries:
|
|
64
|
+
- `doc-fetch_windows_amd64.exe` (Windows)
|
|
65
|
+
- `doc-fetch_darwin_amd64` (macOS)
|
|
66
|
+
- `doc-fetch_linux_amd64` (Linux)
|
|
67
|
+
|
|
68
|
+
But the wrapper expects just `doc-fetch.exe` on Windows.
|
|
69
|
+
|
|
70
|
+
The postinstall script SHOULD do this rename automatically, but sometimes it fails due to:
|
|
71
|
+
- Permissions issues
|
|
72
|
+
- Antivirus blocking file operations
|
|
73
|
+
- NPM running in restricted mode
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## š **Permanent Fix**
|
|
78
|
+
|
|
79
|
+
Reinstall with v1.1.3 or later which has better logging:
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
npm uninstall -g doc-fetch-cli
|
|
83
|
+
npm install -g doc-fetch-cli@latest
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Watch the output - it should show:
|
|
87
|
+
```
|
|
88
|
+
š Copying: doc-fetch_windows_amd64.exe ā doc-fetch.exe
|
|
89
|
+
ā
Copy successful
|
|
90
|
+
ā¹ļø Windows: No chmod needed
|
|
91
|
+
ā
Binary installed: doc-fetch.exe
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If you still see errors, the detailed logs will tell you exactly what went wrong.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## š **Still Having Issues?**
|
|
99
|
+
|
|
100
|
+
Run this diagnostic:
|
|
101
|
+
```powershell
|
|
102
|
+
$dir = npm root -g + "\doc-fetch-cli"
|
|
103
|
+
Write-Host "Installation directory: $dir"
|
|
104
|
+
Write-Host "`nFiles containing 'doc-fetch':"
|
|
105
|
+
Get-ChildItem $dir | Where-Object { $_.Name -like "*doc-fetch*" } | Select-Object Name, Length
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Share the output when reporting the issue at:
|
|
109
|
+
https://github.com/AlphaTechini/doc-fetch/issues
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
**Fixed in**: v1.1.3
|
|
114
|
+
**Platform**: Windows only
|
|
115
|
+
**Workaround**: Manual rename (above)
|
package/bin/doc-fetch.js
CHANGED
|
@@ -7,25 +7,14 @@ const fs = require('fs');
|
|
|
7
7
|
// Get the package installation directory
|
|
8
8
|
const packageDir = path.join(__dirname, '..');
|
|
9
9
|
|
|
10
|
-
// Determine binary name based on platform
|
|
10
|
+
// Determine binary name based on platform (what postinstall creates)
|
|
11
11
|
const platform = os.platform();
|
|
12
|
-
const
|
|
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
|
-
}
|
|
12
|
+
const binaryName = platform === 'win32' ? 'doc-fetch.exe' : 'doc-fetch';
|
|
23
13
|
|
|
24
14
|
// Try multiple possible locations
|
|
25
15
|
const possiblePaths = [
|
|
26
|
-
path.join(packageDir, binaryName),
|
|
27
|
-
path.join(packageDir, 'bin', binaryName),
|
|
28
|
-
path.join(packageDir, binaryName.replace('_linux_amd64', '')), // Fallback to generic name
|
|
16
|
+
path.join(packageDir, binaryName), // Root directory (postinstall copies here)
|
|
17
|
+
path.join(packageDir, 'bin', binaryName), // bin/ directory (fallback)
|
|
29
18
|
];
|
|
30
19
|
|
|
31
20
|
// Find the binary
|
|
@@ -40,13 +29,24 @@ for (const testPath of possiblePaths) {
|
|
|
40
29
|
if (!binaryPath) {
|
|
41
30
|
console.error('ā doc-fetch binary not found!');
|
|
42
31
|
console.error('');
|
|
32
|
+
console.error(`š” Platform: ${platform} (${os.arch()})`);
|
|
33
|
+
console.error('š” Expected: doc-fetch' + (platform === 'win32' ? '.exe' : ''));
|
|
34
|
+
console.error('');
|
|
43
35
|
console.error('š” Troubleshooting steps:');
|
|
44
|
-
console.error(' 1.
|
|
45
|
-
console.error(' 2.
|
|
46
|
-
|
|
36
|
+
console.error(' 1. List files: ls -la $(npm root -g)/doc-fetch-cli/');
|
|
37
|
+
console.error(' 2. Look for platform-specific binary:');
|
|
38
|
+
if (platform === 'win32') {
|
|
39
|
+
console.error(' doc-fetch_windows_amd64.exe');
|
|
40
|
+
} else if (platform === 'darwin') {
|
|
41
|
+
console.error(' doc-fetch_darwin_amd64 (Intel) or doc-fetch_darwin_arm64 (M1/M2)');
|
|
42
|
+
} else {
|
|
43
|
+
console.error(' doc-fetch_linux_amd64 (x64) or doc-fetch_linux_arm64 (ARM)');
|
|
44
|
+
}
|
|
45
|
+
console.error(' 3. Manually copy: cp <platform-binary> doc-fetch' + (platform === 'win32' ? '.exe' : ''));
|
|
46
|
+
console.error(' 4. Make executable: chmod +x doc-fetch (Linux/macOS only)');
|
|
47
|
+
console.error(' 5. Reinstall: npm uninstall -g doc-fetch-cli && npm install -g doc-fetch-cli@latest');
|
|
47
48
|
console.error('');
|
|
48
|
-
console.error(
|
|
49
|
-
console.error(` Platform: ${platform} ${arch}`);
|
|
49
|
+
console.error('š¦ Package directory:', packageDir);
|
|
50
50
|
process.exit(1);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -61,9 +61,12 @@ child.on('error', (err) => {
|
|
|
61
61
|
if (err.code === 'ENOENT') {
|
|
62
62
|
console.error('ā Failed to execute doc-fetch binary');
|
|
63
63
|
console.error(` Binary path: ${binaryPath}`);
|
|
64
|
-
console.error(' Error:
|
|
64
|
+
console.error(' Error: File not found or no execute permission');
|
|
65
65
|
console.error('');
|
|
66
|
-
|
|
66
|
+
if (platform !== 'win32') {
|
|
67
|
+
console.error('š” Fix permissions: chmod +x "' + binaryPath + '"');
|
|
68
|
+
}
|
|
69
|
+
console.error('š” Or reinstall: npm uninstall -g doc-fetch-cli && npm install -g doc-fetch-cli@latest');
|
|
67
70
|
} else {
|
|
68
71
|
console.error('ā Failed to start doc-fetch:', err.message);
|
|
69
72
|
}
|
|
@@ -72,4 +75,4 @@ child.on('error', (err) => {
|
|
|
72
75
|
|
|
73
76
|
child.on('exit', (code) => {
|
|
74
77
|
process.exit(code || 0);
|
|
75
|
-
});
|
|
78
|
+
});
|
package/bin/postinstall.js
CHANGED
|
@@ -35,41 +35,92 @@ const sourcePath = path.join(packageDir, expectedBinary);
|
|
|
35
35
|
const destPath = path.join(packageDir, binaryName);
|
|
36
36
|
|
|
37
37
|
console.log(`š¦ Platform: ${platform} ${arch}`);
|
|
38
|
-
console.log(`š¦ Expected binary: ${expectedBinary}
|
|
38
|
+
console.log(`š¦ Expected binary: ${expectedBinary}`);
|
|
39
|
+
console.log(`š¦ Will copy to: ${binaryName}\n`);
|
|
40
|
+
|
|
41
|
+
// List all available binaries for debugging
|
|
42
|
+
console.log('š Available binaries in package:');
|
|
43
|
+
try {
|
|
44
|
+
const files = fs.readdirSync(packageDir);
|
|
45
|
+
const binaries = files.filter(f => f.includes('doc-fetch') && !f.endsWith('.js'));
|
|
46
|
+
if (binaries.length === 0) {
|
|
47
|
+
console.log(' ā ļø No binaries found! Package may be corrupted.');
|
|
48
|
+
} else {
|
|
49
|
+
binaries.forEach(file => {
|
|
50
|
+
const stats = fs.statSync(path.join(packageDir, file));
|
|
51
|
+
const size = (stats.size / 1024 / 1024).toFixed(2);
|
|
52
|
+
console.log(` ā
${file} (${size} MB)`);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.log(` ā Could not list directory: ${e.message}`);
|
|
57
|
+
}
|
|
58
|
+
console.log('');
|
|
39
59
|
|
|
40
60
|
// Check if the expected binary exists
|
|
41
61
|
if (!fs.existsSync(sourcePath)) {
|
|
42
|
-
console.error(`ā ļø
|
|
62
|
+
console.error(`ā ļø CRITICAL: Expected binary not found at: ${sourcePath}`);
|
|
43
63
|
console.error('');
|
|
44
64
|
console.error('š” This might be because:');
|
|
45
|
-
console.error(' 1.
|
|
46
|
-
console.error(' 2.
|
|
65
|
+
console.error(' 1. Your platform/architecture is not supported');
|
|
66
|
+
console.error(' 2. The package was published without binaries');
|
|
47
67
|
console.error('');
|
|
48
68
|
console.error('Supported platforms:');
|
|
49
|
-
console.error('
|
|
50
|
-
console.error('
|
|
51
|
-
console.error('
|
|
69
|
+
console.error(' ā
Linux x64 (amd64)');
|
|
70
|
+
console.error(' ā
Linux ARM64 (arm64)');
|
|
71
|
+
console.error(' ā
macOS x64 (amd64)');
|
|
72
|
+
console.error(' ā
macOS ARM64 (M1/M2)');
|
|
73
|
+
console.error(' ā
Windows x64 (amd64)');
|
|
52
74
|
console.error('');
|
|
53
|
-
console.error('š”
|
|
54
|
-
console.error(
|
|
55
|
-
console.error(
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
console.error('š” Manual fix:');
|
|
76
|
+
console.error(` 1. Navigate to: ${packageDir}`);
|
|
77
|
+
console.error(` 2. Rename the correct binary for your platform:`);
|
|
78
|
+
if (platform === 'win32') {
|
|
79
|
+
console.error(` copy doc-fetch_windows_amd64.exe ${binaryName}`);
|
|
80
|
+
} else if (platform === 'darwin') {
|
|
81
|
+
console.error(` cp doc-fetch_darwin_amd64 ${binaryName}`);
|
|
82
|
+
console.error(` chmod +x ${binaryName}`);
|
|
83
|
+
} else {
|
|
84
|
+
console.error(` cp doc-fetch_linux_amd64 ${binaryName}`);
|
|
85
|
+
console.error(` chmod +x ${binaryName}`);
|
|
86
|
+
}
|
|
58
87
|
process.exit(1);
|
|
59
88
|
}
|
|
60
89
|
|
|
90
|
+
console.log(`ā
Found source binary: ${expectedBinary}`);
|
|
91
|
+
|
|
61
92
|
// Copy the binary to the expected location
|
|
62
93
|
try {
|
|
94
|
+
console.log(`š Copying: ${expectedBinary} ā ${binaryName}`);
|
|
63
95
|
fs.copyFileSync(sourcePath, destPath);
|
|
96
|
+
console.log(`ā
Copy successful`);
|
|
97
|
+
|
|
98
|
+
// Verify the destination exists
|
|
99
|
+
if (!fs.existsSync(destPath)) {
|
|
100
|
+
throw new Error('Destination file does not exist after copy');
|
|
101
|
+
}
|
|
64
102
|
|
|
65
103
|
// Make executable on Unix-like systems
|
|
66
104
|
if (platform !== 'win32') {
|
|
67
105
|
fs.chmodSync(destPath, 0o755);
|
|
106
|
+
console.log(`ā
Set executable permissions`);
|
|
107
|
+
} else {
|
|
108
|
+
console.log(`ā¹ļø Windows: No chmod needed`);
|
|
68
109
|
}
|
|
69
110
|
|
|
70
|
-
console.log(
|
|
111
|
+
console.log(`\nā
Binary installed: ${binaryName}`);
|
|
71
112
|
} catch (error) {
|
|
72
|
-
console.error(
|
|
113
|
+
console.error(`\nā CRITICAL: Failed to install binary!`);
|
|
114
|
+
console.error(` Source: ${sourcePath}`);
|
|
115
|
+
console.error(` Destination: ${destPath}`);
|
|
116
|
+
console.error(` Error: ${error.message}`);
|
|
117
|
+
console.error('');
|
|
118
|
+
console.error('š” Manual fix:');
|
|
119
|
+
console.error(` 1. Navigate to: ${packageDir}`);
|
|
120
|
+
console.error(` 2. Rename: ${expectedBinary} ā ${binaryName}`);
|
|
121
|
+
if (platform !== 'win32') {
|
|
122
|
+
console.error(` 3. Run: chmod +x ${binaryName}`);
|
|
123
|
+
}
|
|
73
124
|
process.exit(1);
|
|
74
125
|
}
|
|
75
126
|
|
package/package.json
CHANGED