fnva 0.0.33 → 0.0.35

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
@@ -44,11 +44,6 @@ function buildBinaryPath() {
44
44
  return null;
45
45
  }
46
46
 
47
- // 如果设置了 FNVA_AUTO_MODE,自动使用 Node.js 模式
48
- if (process.env.FNVA_AUTO_MODE === '1') {
49
- return null;
50
- }
51
-
52
47
  const platform = resolvePlatform();
53
48
  const binaryCandidates = [];
54
49
 
@@ -301,15 +296,20 @@ function handleNodeOnlyMode(args) {
301
296
  const path = require('path');
302
297
  const os = require('os');
303
298
 
304
- // 简单的命令处理
305
- if (args.length === 0) {
306
- console.log('fnva - 环境管理工具 (Node.js 模式)');
299
+ // 只支持基本帮助信息
300
+ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
301
+ console.log('fnva - 环境管理工具 (Node.js 降级模式)');
302
+ console.log('');
303
+ console.log('⚠️ 当前运行在 Node.js 降级模式,功能有限');
307
304
  console.log('');
308
- console.log('支持的命令:');
305
+ console.log('解决方法:');
306
+ console.log('1. 确保 npm 包包含平台二进制文件');
307
+ console.log('2. 重新安装: npm install -g fnva --force');
308
+ console.log('3. 或者直接下载原生二进制文件');
309
+ console.log('');
310
+ console.log('临时可用功能:');
309
311
  console.log(' java list - 列出 Java 环境');
310
312
  console.log(' java use <n> - 切换 Java 环境');
311
- console.log('');
312
- console.log('注意: Node.js 模式功能有限,建议使用原生二进制版本。');
313
313
  return;
314
314
  }
315
315
 
@@ -389,7 +389,14 @@ function handleNodeOnlyMode(args) {
389
389
  process.exit(1);
390
390
  }
391
391
  } else {
392
- console.error(`Command '${args[0]}' not supported in Node.js mode`);
392
+ console.error(`❌ Command '${args[0]}' requires native binary mode`);
393
+ console.error('');
394
+ console.error('当前运行在 Node.js 降级模式,不支持此命令');
395
+ console.error('');
396
+ console.error('解决方案:');
397
+ console.error('1. 重新安装 npm 包: npm install -g fnva --force');
398
+ console.error('2. 从 GitHub Release 下载原生二进制文件');
399
+ console.error('3. 或者设置 FNVA_SKIP_NATIVE=1 强制使用此模式(功能受限)');
393
400
  process.exit(1);
394
401
  }
395
402
  }
@@ -398,23 +405,90 @@ function run() {
398
405
  // 设置Windows控制台编码
399
406
  EncodingUtils.setWindowsConsoleEncoding();
400
407
 
408
+ // 强制显示调试信息
409
+ const showDebug = process.env.FNVA_DEBUG === '1' || process.argv.includes('--debug');
410
+
411
+ if (showDebug) {
412
+ console.log('=== FNVA DEBUG INFORMATION ===');
413
+ console.log('Node.js version:', process.version);
414
+ console.log('Platform:', process.platform);
415
+ console.log('Architecture:', process.arch);
416
+ console.log('Node binary:', process.execPath);
417
+ console.log('Script directory:', __dirname);
418
+ console.log('Working directory:', process.cwd());
419
+ console.log('Environment variables:');
420
+ console.log(' FNVA_DEBUG:', process.env.FNVA_DEBUG);
421
+ console.log(' FNVA_SKIP_NATIVE:', process.env.FNVA_SKIP_NATIVE);
422
+ console.log('Command line args:', process.argv);
423
+ console.log('');
424
+ }
425
+
401
426
  const binaryPath = buildBinaryPath();
402
427
 
428
+ if (showDebug) {
429
+ console.log('=== BINARY SEARCH RESULTS ===');
430
+ console.log('Binary path found:', binaryPath);
431
+
432
+ // 手动检查所有可能的路径
433
+ const fs = require('fs');
434
+ const path = require('path');
435
+
436
+ const scriptDir = __dirname;
437
+ const projectRoot = path.resolve(scriptDir, '..');
438
+ const platform = process.platform;
439
+ const arch = process.arch;
440
+ const platformDir = `${platform}-${arch}`;
441
+ const binaryName = platform === 'win32' ? 'fnva.exe' : 'fnva';
442
+ const expectedPath = path.join(projectRoot, 'platforms', platformDir, binaryName);
443
+
444
+ console.log('Expected binary path:', expectedPath);
445
+ console.log('Expected path exists:', fs.existsSync(expectedPath));
446
+
447
+ // 检查platforms目录结构
448
+ console.log('');
449
+ console.log('=== PLATFORMS DIRECTORY ===');
450
+ const platformsDir = path.join(projectRoot, 'platforms');
451
+ if (fs.existsSync(platformsDir)) {
452
+ const platforms = fs.readdirSync(platformsDir, { withFileTypes: true });
453
+ platforms.forEach(item => {
454
+ if (item.isDirectory()) {
455
+ const platformPath = path.join(platformsDir, item.name);
456
+ const files = fs.readdirSync(platformPath);
457
+ console.log(`platforms/${item.name}/:`, files);
458
+ }
459
+ });
460
+ } else {
461
+ console.log('platforms directory does not exist');
462
+ }
463
+
464
+ console.log('=== END DEBUG ===');
465
+ console.log('');
466
+ }
467
+
403
468
  if (!binaryPath) {
404
- if (process.env.FNVA_SKIP_NATIVE === '1' || process.env.FNVA_AUTO_MODE === '1') {
469
+ if (process.env.FNVA_SKIP_NATIVE === '1') {
470
+ if (showDebug) {
471
+ console.log('Falling back to Node.js mode (FNVA_SKIP_NATIVE set)');
472
+ }
405
473
  // 纯 Node.js 模式 - 实现基本的环境切换功能
406
474
  const args = process.argv.slice(2);
407
475
  handleNodeOnlyMode(args);
408
476
  return;
409
477
  }
410
478
 
411
- console.error('Error: fnva native binary not found.');
479
+ console.error('Error: fnva native binary not found.');
412
480
  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).");
481
+
482
+ if (showDebug) {
483
+ console.error('🔍 Debug information is shown above');
484
+ console.error('');
485
+ }
486
+
487
+ console.error("💡 Solutions:");
488
+ console.error(" 1) Reinstall npm package: npm install -g fnva --force");
489
+ console.error(" 2) Download binary from GitHub Release");
490
+ console.error(" 3) Set FNVA_SKIP_NATIVE=1 to use Node.js mode (limited functionality)");
491
+ console.error(" 4) Set FNVA_DEBUG=1 to show debug information");
418
492
  process.exit(1);
419
493
  }
420
494
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
5
5
  "author": "protagonistss",
6
6
  "license": "MIT",
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -44,9 +44,8 @@ function fnva {
44
44
  if ($args.Count -ge 2 -and ($args[0] -eq "java" -or $args[0] -eq "llm" -or $args[0] -eq "cc") -and ($args[1] -eq "use")) {
45
45
  $tempFile = Join-Path $env:TEMP ("fnva_script_" + (Get-Random) + ".ps1")
46
46
 
47
- $env:FNVAAUTOMODE = "1"
48
47
  try {
49
- $output = cmd.exe /c "set FNVA_AUTO_MODE=%FNVAAUTOMODE% && fnva $args" 2>&1
48
+ $output = cmd.exe /c "fnva $args" 2>&1
50
49
 
51
50
  if ($output -match '\\$env:' -or $output -match 'Write-Host') {
52
51
  $output | Out-File -FilePath $tempFile -Encoding UTF8
@@ -55,12 +54,10 @@ function fnva {
55
54
  $output
56
55
  }
57
56
  } finally {
58
- $env:FNVAAUTOMODE = ""
59
57
  if (Test-Path $tempFile) { Remove-Item $tempFile -ErrorAction SilentlyContinue }
60
58
  }
61
59
  } else {
62
- $env:FNVAAUTOMODE = "1"
63
- try { cmd.exe /c "set FNVA_AUTO_MODE=%FNVAAUTOMODE% && fnva $args" } finally { $env:FNVAAUTOMODE = "" }
60
+ try { cmd.exe /c "fnva $args" } finally { }
64
61
  }
65
62
  }
66
63
  `;
@@ -96,11 +93,11 @@ fnva() {
96
93
  temp_file="$(mktemp)"
97
94
  chmod +x "$temp_file"
98
95
 
99
- FNVA_AUTO_MODE=1 "$__fnva_bin" "$@" > "$temp_file"
96
+ "$__fnva_bin" "$@" > "$temp_file"
100
97
  source "$temp_file"
101
98
  rm -f "$temp_file"
102
99
  else
103
- FNVA_AUTO_MODE=1 "$__fnva_bin" "$@"
100
+ "$__fnva_bin" "$@"
104
101
  fi
105
102
  }
106
103
  `;
@@ -119,11 +116,11 @@ function fnva
119
116
  if test (count $argv) -ge 2; and string match -q -r "^(java|llm|cc)$" $argv[1]; and test $argv[2] = "use"
120
117
  set temp_file (mktemp)
121
118
  chmod +x $temp_file
122
- env FNVA_AUTO_MODE=1 "$__fnva_bin" $argv > $temp_file
119
+ env "$__fnva_bin" $argv > $temp_file
123
120
  source $temp_file
124
121
  rm -f $temp_file
125
122
  else
126
- env FNVA_AUTO_MODE=1 "$__fnva_bin" $argv
123
+ env "$__fnva_bin" $argv
127
124
  end
128
125
  end
129
126
  `;