fnva 0.0.33 → 0.0.34

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/bin/fnva.js CHANGED
@@ -301,15 +301,20 @@ function handleNodeOnlyMode(args) {
301
301
  const path = require('path');
302
302
  const os = require('os');
303
303
 
304
- // 简单的命令处理
305
- if (args.length === 0) {
306
- console.log('fnva - 环境管理工具 (Node.js 模式)');
304
+ // 只支持基本帮助信息
305
+ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
306
+ console.log('fnva - 环境管理工具 (Node.js 降级模式)');
307
307
  console.log('');
308
- console.log('支持的命令:');
308
+ console.log('⚠️ 当前运行在 Node.js 降级模式,功能有限');
309
+ console.log('');
310
+ console.log('解决方法:');
311
+ console.log('1. 确保 npm 包包含平台二进制文件');
312
+ console.log('2. 重新安装: npm install -g fnva --force');
313
+ console.log('3. 或者直接下载原生二进制文件');
314
+ console.log('');
315
+ console.log('临时可用功能:');
309
316
  console.log(' java list - 列出 Java 环境');
310
317
  console.log(' java use <n> - 切换 Java 环境');
311
- console.log('');
312
- console.log('注意: Node.js 模式功能有限,建议使用原生二进制版本。');
313
318
  return;
314
319
  }
315
320
 
@@ -389,7 +394,14 @@ function handleNodeOnlyMode(args) {
389
394
  process.exit(1);
390
395
  }
391
396
  } else {
392
- console.error(`Command '${args[0]}' not supported in Node.js mode`);
397
+ console.error(`❌ Command '${args[0]}' requires native binary mode`);
398
+ console.error('');
399
+ console.error('当前运行在 Node.js 降级模式,不支持此命令');
400
+ console.error('');
401
+ console.error('解决方案:');
402
+ console.error('1. 重新安装 npm 包: npm install -g fnva --force');
403
+ console.error('2. 从 GitHub Release 下载原生二进制文件');
404
+ console.error('3. 或者设置 FNVA_SKIP_NATIVE=1 强制使用此模式(功能受限)');
393
405
  process.exit(1);
394
406
  }
395
407
  }
@@ -398,23 +410,92 @@ function run() {
398
410
  // 设置Windows控制台编码
399
411
  EncodingUtils.setWindowsConsoleEncoding();
400
412
 
413
+ // 强制显示调试信息
414
+ const showDebug = process.env.FNVA_DEBUG === '1' || process.argv.includes('--debug');
415
+
416
+ if (showDebug) {
417
+ console.log('=== FNVA DEBUG INFORMATION ===');
418
+ console.log('Node.js version:', process.version);
419
+ console.log('Platform:', process.platform);
420
+ console.log('Architecture:', process.arch);
421
+ console.log('Node binary:', process.execPath);
422
+ console.log('Script directory:', __dirname);
423
+ console.log('Working directory:', process.cwd());
424
+ console.log('Environment variables:');
425
+ console.log(' FNVA_DEBUG:', process.env.FNVA_DEBUG);
426
+ console.log(' FNVA_SKIP_NATIVE:', process.env.FNVA_SKIP_NATIVE);
427
+ console.log(' FNVA_AUTO_MODE:', process.env.FNVA_AUTO_MODE);
428
+ console.log('Command line args:', process.argv);
429
+ console.log('');
430
+ }
431
+
401
432
  const binaryPath = buildBinaryPath();
402
433
 
434
+ if (showDebug) {
435
+ console.log('=== BINARY SEARCH RESULTS ===');
436
+ console.log('Binary path found:', binaryPath);
437
+
438
+ // 手动检查所有可能的路径
439
+ const fs = require('fs');
440
+ const path = require('path');
441
+
442
+ const scriptDir = __dirname;
443
+ const projectRoot = path.resolve(scriptDir, '..');
444
+ const platform = process.platform;
445
+ const arch = process.arch;
446
+ const platformDir = `${platform}-${arch}`;
447
+ const binaryName = platform === 'win32' ? 'fnva.exe' : 'fnva';
448
+ const expectedPath = path.join(projectRoot, 'platforms', platformDir, binaryName);
449
+
450
+ console.log('Expected binary path:', expectedPath);
451
+ console.log('Expected path exists:', fs.existsSync(expectedPath));
452
+
453
+ // 检查platforms目录结构
454
+ console.log('');
455
+ console.log('=== PLATFORMS DIRECTORY ===');
456
+ const platformsDir = path.join(projectRoot, 'platforms');
457
+ if (fs.existsSync(platformsDir)) {
458
+ const platforms = fs.readdirSync(platformsDir, { withFileTypes: true });
459
+ platforms.forEach(item => {
460
+ if (item.isDirectory()) {
461
+ const platformPath = path.join(platformsDir, item.name);
462
+ const files = fs.readdirSync(platformPath);
463
+ console.log(`platforms/${item.name}/:`, files);
464
+ }
465
+ });
466
+ } else {
467
+ console.log('platforms directory does not exist');
468
+ }
469
+
470
+ console.log('=== END DEBUG ===');
471
+ console.log('');
472
+ }
473
+
403
474
  if (!binaryPath) {
404
475
  if (process.env.FNVA_SKIP_NATIVE === '1' || process.env.FNVA_AUTO_MODE === '1') {
476
+ if (showDebug) {
477
+ console.log('Falling back to Node.js mode (FNVA_SKIP_NATIVE or FNVA_AUTO_MODE set)');
478
+ }
405
479
  // 纯 Node.js 模式 - 实现基本的环境切换功能
406
480
  const args = process.argv.slice(2);
407
481
  handleNodeOnlyMode(args);
408
482
  return;
409
483
  }
410
484
 
411
- console.error('Error: fnva native binary not found.');
485
+ console.error('Error: fnva native binary not found.');
412
486
  console.error('');
413
- console.error("Please either:");
414
- console.error(" 1) Run 'npm run build' (or 'npm run build:all') to produce platform binaries,");
415
- console.error(" 2) Install a release package that includes the platforms directory, or");
416
- console.error(" 3) Set FNVA_NATIVE_PATH to the full path of an existing fnva executable.");
417
- console.error(" 4) Set FNVA_SKIP_NATIVE=1 to use Node.js mode (limited functionality).");
487
+
488
+ if (showDebug) {
489
+ console.error('🔍 Debug information is shown above');
490
+ console.error('');
491
+ }
492
+
493
+ console.error("💡 Solutions:");
494
+ console.error(" 1) Run 'npm run build:all' to produce platform binaries");
495
+ console.error(" 2) Reinstall npm package: npm install -g fnva --force");
496
+ console.error(" 3) Download binary from GitHub Release");
497
+ console.error(" 4) Set FNVA_SKIP_NATIVE=1 to use Node.js mode (limited functionality)");
498
+ console.error(" 5) Set FNVA_DEBUG=1 to show debug information");
418
499
  process.exit(1);
419
500
  }
420
501
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
5
5
  "author": "protagonistss",
6
6
  "license": "MIT",
Binary file
Binary file
Binary file
Binary file
Binary file