doc-fetch-cli 1.1.4 → 1.1.5

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.
@@ -40,6 +40,7 @@ console.log(`šŸ“¦ Will copy to: ${binaryName}\n`);
40
40
 
41
41
  // List all available binaries for debugging
42
42
  console.log('šŸ“‹ Available binaries in package:');
43
+ let hasPlatformBinary = false;
43
44
  try {
44
45
  const files = fs.readdirSync(packageDir);
45
46
  const binaries = files.filter(f => f.includes('doc-fetch') && !f.endsWith('.js'));
@@ -49,7 +50,12 @@ try {
49
50
  binaries.forEach(file => {
50
51
  const stats = fs.statSync(path.join(packageDir, file));
51
52
  const size = (stats.size / 1024 / 1024).toFixed(2);
52
- console.log(` āœ… ${file} (${size} MB)`);
53
+ const isCorrect = file === expectedBinary || file === binaryName;
54
+ const marker = isCorrect ? 'āœ…' : 'ā„¹ļø ';
55
+ console.log(` ${marker} ${file} (${size} MB)`);
56
+ if (file === expectedBinary) {
57
+ hasPlatformBinary = true;
58
+ }
53
59
  });
54
60
  }
55
61
  } catch (e) {
@@ -57,33 +63,30 @@ try {
57
63
  }
58
64
  console.log('');
59
65
 
60
- // Check if the expected binary exists
61
- if (!fs.existsSync(sourcePath)) {
62
- console.error(`āš ļø CRITICAL: Expected binary not found at: ${sourcePath}`);
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}`);
63
70
  console.error('');
64
- console.error('šŸ’” This might be because:');
65
- console.error(' 1. Your platform/architecture is not supported');
66
- console.error(' 2. The package was published without binaries');
71
+ console.error('šŸ’” This is a packaging error - the NPM package was published without your platform binary.');
67
72
  console.error('');
68
- console.error('Supported platforms:');
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)');
74
- console.error('');
75
- console.error('šŸ’” Manual fix:');
76
- console.error(` 1. Navigate to: ${packageDir}`);
77
- console.error(` 2. Rename the correct binary for your platform:`);
73
+ console.error('šŸ’” Immediate workaround - Install from source:');
74
+ console.error(' 1. Install Go: https://golang.org/dl/');
75
+ console.error(' 2. Run these commands:');
76
+ console.error(' npm uninstall -g doc-fetch-cli');
77
+ console.error(' git clone https://github.com/AlphaTechini/doc-fetch.git');
78
+ console.error(' cd doc-fetch');
78
79
  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}`);
80
+ console.error(' go build -o doc-fetch.exe ./cmd/docfetch');
81
+ console.error(' copy doc-fetch.exe "' + packageDir + '"');
83
82
  } else {
84
- console.error(` cp doc-fetch_linux_amd64 ${binaryName}`);
85
- console.error(` chmod +x ${binaryName}`);
83
+ console.error(' go build -o doc-fetch ./cmd/docfetch');
84
+ console.error(' cp doc-fetch "' + packageDir + '"');
85
+ console.error(' chmod +x "' + path.join(packageDir, 'doc-fetch') + '"');
86
86
  }
87
+ console.error('');
88
+ console.error('šŸ’” Or wait for fixed version (check for updates):');
89
+ console.error(' npm install -g doc-fetch-cli@latest');
87
90
  process.exit(1);
88
91
  }
89
92
 
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "doc-fetch-cli",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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"
7
7
  },
8
8
  "scripts": {
9
- "postinstall": "node ./bin/postinstall.js"
9
+ "prepublishOnly": "node ./scripts/verify-binaries.js",
10
+ "postinstall": "node ./bin/postinstall.js",
11
+ "verify": "node ./scripts/verify-binaries.js"
10
12
  },
11
13
  "repository": {
12
14
  "type": "git",
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Pre-publish verification script
4
+ * Ensures all platform binaries are present before publishing to NPM
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const os = require('os');
10
+
11
+ const packageDir = path.join(__dirname, '..');
12
+
13
+ console.log('šŸ” Verifying platform binaries before publish...\n');
14
+
15
+ const requiredBinaries = [
16
+ { name: 'doc-fetch_linux_amd64', platform: 'linux', arch: 'x64' },
17
+ { name: 'doc-fetch_linux_arm64', platform: 'linux', arch: 'arm64', optional: true },
18
+ { name: 'doc-fetch_darwin_amd64', platform: 'darwin', arch: 'x64' },
19
+ { name: 'doc-fetch_darwin_arm64', platform: 'darwin', arch: 'arm64', optional: true },
20
+ { name: 'doc-fetch_windows_amd64.exe', platform: 'win32', arch: 'x64' },
21
+ ];
22
+
23
+ let allPresent = true;
24
+ const missing = [];
25
+ const present = [];
26
+
27
+ console.log('šŸ“¦ Checking binaries:\n');
28
+
29
+ requiredBinaries.forEach(binary => {
30
+ const binaryPath = path.join(packageDir, binary.name);
31
+ const exists = fs.existsSync(binaryPath);
32
+
33
+ if (exists) {
34
+ const stats = fs.statSync(binaryPath);
35
+ const size = (stats.size / 1024 / 1024).toFixed(2);
36
+ console.log(` āœ… ${binary.name.padEnd(35)} (${size} MB) - ${binary.platform} ${binary.arch}`);
37
+ present.push(binary.name);
38
+ } else {
39
+ const marker = binary.optional ? 'āš ļø ' : 'āŒ';
40
+ const note = binary.optional ? '(optional)' : '(REQUIRED)';
41
+ console.log(` ${marker} ${binary.name.padEnd(35)} MISSING ${note}`);
42
+ if (!binary.optional) {
43
+ missing.push(binary.name);
44
+ allPresent = false;
45
+ }
46
+ }
47
+ });
48
+
49
+ console.log('\nšŸ“Š Summary:');
50
+ console.log(` Present: ${present.length}`);
51
+ console.log(` Missing: ${missing.length}${missing.length > 0 ? ' (' + missing.join(', ') + ')' : ''}`);
52
+ console.log('');
53
+
54
+ if (!allPresent) {
55
+ console.error('āŒ CRITICAL: Required binaries are missing!');
56
+ console.error('');
57
+ console.error('šŸ’” Build all platforms before publishing:');
58
+ console.error('');
59
+ console.error(' # Linux x64');
60
+ console.error(' GOOS=linux GOARCH=amd64 go build -o doc-fetch_linux_amd64 ./cmd/docfetch');
61
+ console.error('');
62
+ console.error(' # Linux ARM64 (optional)');
63
+ console.error(' GOOS=linux GOARCH=arm64 go build -o doc-fetch_linux_arm64 ./cmd/docfetch');
64
+ console.error('');
65
+ console.error(' # macOS Intel');
66
+ console.error(' GOOS=darwin GOARCH=amd64 go build -o doc-fetch_darwin_amd64 ./cmd/docfetch');
67
+ console.error('');
68
+ console.error(' # macOS Apple Silicon (optional)');
69
+ console.error(' GOOS=darwin GOARCH=arm64 go build -o doc-fetch_darwin_arm64 ./cmd/docfetch');
70
+ console.error('');
71
+ console.error(' # Windows x64');
72
+ console.error(' GOOS=windows GOARCH=amd64 go build -o doc-fetch_windows_amd64.exe ./cmd/docfetch');
73
+ console.error('');
74
+ console.error('Then run this script again to verify.');
75
+ console.error('');
76
+ process.exit(1);
77
+ }
78
+
79
+ // Verify minimum file sizes (catches corrupted/empty files)
80
+ console.log('šŸ” Verifying binary integrity...\n');
81
+
82
+ let allValid = true;
83
+ present.forEach(binaryName => {
84
+ const binaryPath = path.join(packageDir, binaryName);
85
+ const stats = fs.statSync(binaryPath);
86
+
87
+ // Minimum expected size: 5MB (actual binaries are ~8-9MB)
88
+ const minSize = 5 * 1024 * 1024;
89
+
90
+ if (stats.size < minSize) {
91
+ const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
92
+ console.log(` āš ļø ${binaryName.padEnd(35)} Suspiciously small (${sizeMB} MB)`);
93
+ allValid = false;
94
+ } else {
95
+ const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
96
+ console.log(` āœ… ${binaryName.padEnd(35)} OK (${sizeMB} MB)`);
97
+ }
98
+ });
99
+
100
+ console.log('');
101
+
102
+ if (!allValid) {
103
+ console.error('āš ļø Warning: Some binaries seem too small and may be corrupted.');
104
+ console.error(' Consider rebuilding them before publishing.\n');
105
+ }
106
+
107
+ // Final verdict
108
+ if (allPresent && allValid) {
109
+ console.log('āœ… All required binaries present and valid!');
110
+ console.log('āœ… Ready to publish to NPM\n');
111
+ process.exit(0);
112
+ } else if (allPresent) {
113
+ console.log('āš ļø All binaries present but some may be corrupted.');
114
+ console.log('āš ļø Proceed with caution!\n');
115
+ process.exit(0); // Allow publishing but warn
116
+ } else {
117
+ process.exit(1);
118
+ }