opendraft 1.6.18 → 1.6.19

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/opendraft.js +87 -4
  2. package/package.json +1 -1
package/bin/opendraft.js CHANGED
@@ -101,6 +101,8 @@ function checkPython() {
101
101
  '/usr/bin/python3',
102
102
  ];
103
103
 
104
+ let oldestFound = null; // Track if we find an old Python version
105
+
104
106
  for (const cmd of pythonCommands) {
105
107
  try {
106
108
  const version = execSync(`${cmd} --version 2>&1`, { encoding: 'utf8' }).trim();
@@ -110,13 +112,25 @@ function checkPython() {
110
112
  const minor = parseInt(match[2]);
111
113
  // Require Python 3.10-3.13
112
114
  if (major === 3 && minor >= 10 && minor <= 13) {
113
- return { cmd, version: `${major}.${minor}` };
115
+ return { cmd, version: `${major}.${minor}`, status: 'ok' };
116
+ }
117
+ // Track old Python versions (3.7, 3.8, 3.9)
118
+ if (major === 3 && minor >= 7 && minor < 10) {
119
+ if (!oldestFound || minor > oldestFound.minor) {
120
+ oldestFound = { cmd, major, minor, version: `${major}.${minor}` };
121
+ }
114
122
  }
115
123
  }
116
124
  } catch (e) {
117
125
  // Command not found, try next
118
126
  }
119
127
  }
128
+
129
+ // Return info about old Python if found
130
+ if (oldestFound) {
131
+ return { cmd: oldestFound.cmd, version: oldestFound.version, status: 'too_old' };
132
+ }
133
+
120
134
  return null;
121
135
  }
122
136
 
@@ -191,6 +205,10 @@ function installOpendraft(pythonCmd) {
191
205
  if (errorMsg.includes('no space') || errorMsg.includes('disk full') || errorMsg.includes('errno 28')) {
192
206
  return { success: false, error: 'disk_full' };
193
207
  }
208
+ if (errorMsg.includes('no module named pip') || errorMsg.includes('pip not found') ||
209
+ errorMsg.includes('no such file') && errorMsg.includes('pip')) {
210
+ return { success: false, error: 'no_pip' };
211
+ }
194
212
 
195
213
  return {
196
214
  success: false,
@@ -265,6 +283,38 @@ function showFriendlyError(errorType, details = {}) {
265
283
  }
266
284
  break;
267
285
 
286
+ case 'python_too_old':
287
+ printBox([
288
+ `${RED}${BOLD}Python Version Too Old${RESET}`,
289
+ ``,
290
+ `You have Python ${details.version}, but OpenDraft needs 3.10+`,
291
+ ], RED);
292
+
293
+ const platOld = os.platform();
294
+ print(`${BOLD}You need to install a newer Python version:${RESET}`);
295
+ console.log();
296
+
297
+ if (platOld === 'darwin') {
298
+ print(`${BOLD}Option 1: Homebrew (recommended)${RESET}`);
299
+ print(` ${CYAN}brew install python@3.11${RESET}`);
300
+ console.log();
301
+ print(`${BOLD}Option 2: Download from python.org${RESET}`);
302
+ print(` ${CYAN}https://python.org/downloads${RESET}`);
303
+ } else if (platOld === 'win32') {
304
+ print(`1. Go to ${CYAN}https://python.org/downloads${RESET}`);
305
+ print(`2. Download Python 3.11 or newer`);
306
+ print(`3. ${YELLOW}Check "Add Python to PATH"${RESET} during install`);
307
+ print(`4. ${BOLD}Restart your terminal${RESET}`);
308
+ } else {
309
+ print(`${CYAN}sudo apt install python3.11${RESET} (Ubuntu/Debian)`);
310
+ print(`${CYAN}sudo dnf install python3.11${RESET} (Fedora)`);
311
+ }
312
+ console.log();
313
+ print(`Then try again: ${CYAN}npx opendraft${RESET}`);
314
+ console.log();
315
+ print(`${GRAY}Your current Python ${details.version} will not be affected.${RESET}`)
316
+ break;
317
+
268
318
  case 'install_failed':
269
319
  printBox([
270
320
  `${RED}${BOLD}Installation Failed${RESET}`,
@@ -344,6 +394,33 @@ function showFriendlyError(errorType, details = {}) {
344
394
  print(`Then try again: ${CYAN}npx opendraft${RESET}`);
345
395
  break;
346
396
 
397
+ case 'no_pip':
398
+ printBox([
399
+ `${RED}${BOLD}pip Not Found${RESET}`,
400
+ ``,
401
+ `Python is installed but pip (package manager) is missing.`,
402
+ ], RED);
403
+
404
+ const platPip = os.platform();
405
+ print(`${BOLD}Install pip:${RESET}`);
406
+ console.log();
407
+
408
+ if (platPip === 'darwin') {
409
+ print(`${CYAN}python3 -m ensurepip --upgrade${RESET}`);
410
+ console.log();
411
+ print(`Or reinstall Python from ${CYAN}https://python.org${RESET}`);
412
+ } else if (platPip === 'win32') {
413
+ print(`${CYAN}python -m ensurepip --upgrade${RESET}`);
414
+ console.log();
415
+ print(`Or reinstall Python and check "pip" during install`);
416
+ } else {
417
+ print(`${CYAN}sudo apt install python3-pip${RESET} (Ubuntu/Debian)`);
418
+ print(`${CYAN}sudo dnf install python3-pip${RESET} (Fedora)`);
419
+ }
420
+ console.log();
421
+ print(`Then try again: ${CYAN}npx opendraft${RESET}`);
422
+ break;
423
+
347
424
  case 'module_not_found':
348
425
  printBox([
349
426
  `${RED}${BOLD}OpenDraft Package Issue${RESET}`,
@@ -538,13 +615,19 @@ async function main() {
538
615
 
539
616
  // Re-check Python after installation
540
617
  const pythonAfter = checkPython();
541
- if (!pythonAfter) {
618
+ if (!pythonAfter || pythonAfter.status === 'too_old') {
542
619
  print(`${RED}Python still not found.${RESET} Please restart your terminal and try again.`);
543
620
  process.exit(1);
544
621
  }
545
622
  return;
546
623
  }
547
624
 
625
+ // Check if Python version is too old
626
+ if (python.status === 'too_old') {
627
+ showFriendlyError('python_too_old', { version: python.version });
628
+ process.exit(1);
629
+ }
630
+
548
631
  print(`${GREEN}✓${RESET} Python ${python.version} found`);
549
632
 
550
633
  // Handle --install
@@ -558,7 +641,7 @@ async function main() {
558
641
  console.log();
559
642
  } else {
560
643
  // Show specific error message based on error type
561
- const errorType = ['permission_denied', 'network_error', 'disk_full'].includes(result.error)
644
+ const errorType = ['permission_denied', 'network_error', 'disk_full', 'no_pip'].includes(result.error)
562
645
  ? result.error : 'install_failed';
563
646
  showFriendlyError(errorType, { error: result.error });
564
647
  process.exit(1);
@@ -578,7 +661,7 @@ async function main() {
578
661
 
579
662
  if (!result.success) {
580
663
  // Show specific error message based on error type
581
- const errorType = ['permission_denied', 'network_error', 'disk_full'].includes(result.error)
664
+ const errorType = ['permission_denied', 'network_error', 'disk_full', 'no_pip'].includes(result.error)
582
665
  ? result.error : 'install_failed';
583
666
  showFriendlyError(errorType, { error: result.error });
584
667
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opendraft",
3
- "version": "1.6.18",
3
+ "version": "1.6.19",
4
4
  "description": "AI-powered research paper generator with verified citations",
5
5
  "bin": {
6
6
  "opendraft": "bin/opendraft.js"