fnva 0.0.12 → 0.0.13

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
@@ -314,28 +314,50 @@ function handleNodeOnlyMode(args) {
314
314
  } else {
315
315
  console.log('Available java environments:');
316
316
  versions.forEach(version => {
317
- const jdkPath = path.join(fnvaDir, version);
318
- if (fs.existsSync(path.join(jdkPath, 'release'))) {
319
- try {
320
- const releaseContent = fs.readFileSync(path.join(jdkPath, 'release'), 'utf8');
321
- const versionMatch = releaseContent.match(/JAVA_VERSION="(.+)"/);
322
- const javaVersion = versionMatch ? versionMatch[1].replace(/"/g, '') : 'Unknown';
323
- console.log(` ${version}: Java ${javaVersion} (${jdkPath})`);
324
- } catch (e) {
325
- console.log(` ${version}: (${jdkPath})`);
317
+ const versionDir = path.join(fnvaDir, version);
318
+ const jdkSubdirs = fs.readdirSync(versionDir, { withFileTypes: true })
319
+ .filter(dirent => dirent.isDirectory())
320
+ .map(dirent => dirent.name);
321
+
322
+ if (jdkSubdirs.length > 0) {
323
+ const jdkSubdir = jdkSubdirs[0];
324
+ const fullJdkPath = path.join(versionDir, jdkSubdir);
325
+
326
+ if (fs.existsSync(path.join(fullJdkPath, 'release'))) {
327
+ try {
328
+ const releaseContent = fs.readFileSync(path.join(fullJdkPath, 'release'), 'utf8');
329
+ const versionMatch = releaseContent.match(/JAVA_VERSION="(.+)"/);
330
+ const javaVersion = versionMatch ? versionMatch[1].replace(/"/g, '') : 'Unknown';
331
+ console.log(` ${version} (current): Java ${javaVersion} (${fullJdkPath})`);
332
+ } catch (e) {
333
+ console.log(` ${version} (${fullJdkPath})`);
334
+ }
326
335
  }
327
336
  }
328
337
  });
329
338
  }
330
339
  } else if (args[1] === 'use' && args[2]) {
331
340
  const version = args[2];
332
- const jdkPath = path.join(fnvaDir, version);
341
+ const versionDir = path.join(fnvaDir, version);
333
342
 
334
- if (!fs.existsSync(jdkPath)) {
343
+ if (!fs.existsSync(versionDir)) {
335
344
  console.error(`Java environment '${version}' not found`);
336
345
  process.exit(1);
337
346
  }
338
347
 
348
+ // 查找实际的 JDK 目录
349
+ const jdkSubdirs = fs.readdirSync(versionDir, { withFileTypes: true })
350
+ .filter(dirent => dirent.isDirectory())
351
+ .map(dirent => dirent.name);
352
+
353
+ if (jdkSubdirs.length === 0) {
354
+ console.error(`No JDK installation found in ${versionDir}`);
355
+ process.exit(1);
356
+ }
357
+
358
+ const jdkPath = path.join(versionDir, jdkSubdirs[0]);
359
+ const jdkBinPath = path.join(jdkPath, 'bin');
360
+
339
361
  // 生成环境切换脚本
340
362
  const envVars = {
341
363
  JAVA_HOME: jdkPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
5
5
  "author": "protagonistss",
6
6
  "license": "MIT",
package/platforms/fnva CHANGED
Binary file
Binary file