fnva 0.0.32 → 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
@@ -53,7 +53,8 @@ function buildBinaryPath() {
53
53
  const binaryCandidates = [];
54
54
 
55
55
  // 1. Prebuilt binary shipped with the npm package
56
- binaryCandidates.push(platformBinaryPath(platform));
56
+ const npmBinaryPath = platformBinaryPath(platform);
57
+ binaryCandidates.push(npmBinaryPath);
57
58
 
58
59
  // 2. User-provided override via environment variable
59
60
  if (process.env.FNVA_NATIVE_PATH) {
@@ -70,12 +71,32 @@ function buildBinaryPath() {
70
71
  binaryCandidates.push(path.join(targetDir, 'debug', 'fnva'));
71
72
  }
72
73
 
74
+ // Debug: Show all candidates and their existence
75
+ if (process.env.FNVA_DEBUG === '1') {
76
+ console.log('[DEBUG] Looking for fnva binary...');
77
+ console.log('[DEBUG] Platform:', platform, 'Arch:', resolveArch());
78
+ console.log('[DEBUG] Binary candidates:');
79
+ binaryCandidates.forEach((candidate, index) => {
80
+ const exists = candidate && fs.existsSync(candidate);
81
+ console.log(` ${index + 1}. ${candidate} - ${exists ? 'EXISTS' : 'MISSING'}`);
82
+ });
83
+ }
84
+
73
85
  for (const candidate of binaryCandidates) {
74
86
  if (candidate && fs.existsSync(candidate)) {
87
+ if (process.env.FNVA_DEBUG === '1') {
88
+ console.log(`[DEBUG] Found binary at: ${candidate}`);
89
+ }
75
90
  return candidate;
76
91
  }
77
92
  }
78
93
 
94
+ if (process.env.FNVA_DEBUG === '1') {
95
+ console.log('[DEBUG] No binary found, falling back to Node.js mode');
96
+ console.log('[DEBUG] Expected npm package binary path:', npmBinaryPath);
97
+ console.log('[DEBUG] npmBinaryPath exists:', fs.existsSync(npmBinaryPath));
98
+ }
99
+
79
100
  return null;
80
101
  }
81
102
 
@@ -280,15 +301,20 @@ function handleNodeOnlyMode(args) {
280
301
  const path = require('path');
281
302
  const os = require('os');
282
303
 
283
- // 简单的命令处理
284
- if (args.length === 0) {
285
- console.log('fnva - 环境管理工具 (Node.js 模式)');
304
+ // 只支持基本帮助信息
305
+ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
306
+ console.log('fnva - 环境管理工具 (Node.js 降级模式)');
307
+ 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. 或者直接下载原生二进制文件');
286
314
  console.log('');
287
- console.log('支持的命令:');
315
+ console.log('临时可用功能:');
288
316
  console.log(' java list - 列出 Java 环境');
289
317
  console.log(' java use <n> - 切换 Java 环境');
290
- console.log('');
291
- console.log('注意: Node.js 模式功能有限,建议使用原生二进制版本。');
292
318
  return;
293
319
  }
294
320
 
@@ -368,7 +394,14 @@ function handleNodeOnlyMode(args) {
368
394
  process.exit(1);
369
395
  }
370
396
  } else {
371
- 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 强制使用此模式(功能受限)');
372
405
  process.exit(1);
373
406
  }
374
407
  }
@@ -377,23 +410,92 @@ function run() {
377
410
  // 设置Windows控制台编码
378
411
  EncodingUtils.setWindowsConsoleEncoding();
379
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
+
380
432
  const binaryPath = buildBinaryPath();
381
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
+
382
474
  if (!binaryPath) {
383
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
+ }
384
479
  // 纯 Node.js 模式 - 实现基本的环境切换功能
385
480
  const args = process.argv.slice(2);
386
481
  handleNodeOnlyMode(args);
387
482
  return;
388
483
  }
389
484
 
390
- console.error('Error: fnva native binary not found.');
485
+ console.error('Error: fnva native binary not found.');
391
486
  console.error('');
392
- console.error("Please either:");
393
- console.error(" 1) Run 'npm run build' (or 'npm run build:all') to produce platform binaries,");
394
- console.error(" 2) Install a release package that includes the platforms directory, or");
395
- console.error(" 3) Set FNVA_NATIVE_PATH to the full path of an existing fnva executable.");
396
- 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");
397
499
  process.exit(1);
398
500
  }
399
501
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.32",
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