fnva 0.0.6 → 0.0.7

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
@@ -27,8 +27,8 @@ function resolveArch() {
27
27
  return 'x64';
28
28
  }
29
29
 
30
- function buildBinaryPath() {
31
- const platform = resolvePlatform();
30
+ function platformBinaryPath(platformOverride) {
31
+ const platform = platformOverride || resolvePlatform();
32
32
  const arch = resolveArch();
33
33
  const scriptDir = __dirname;
34
34
  const projectRoot = path.resolve(scriptDir, '..');
@@ -37,13 +37,53 @@ function buildBinaryPath() {
37
37
  return path.join(projectRoot, 'platforms', platformDir, binaryName);
38
38
  }
39
39
 
40
+ function buildBinaryPath() {
41
+ const platform = resolvePlatform();
42
+ const binaryCandidates = [];
43
+
44
+ // 1. Prebuilt binary shipped with the npm package
45
+ binaryCandidates.push(platformBinaryPath(platform));
46
+
47
+ // Flat legacy structure: platforms/fnva(.exe)
48
+ const scriptDir = __dirname;
49
+ const projectRoot = path.resolve(scriptDir, '..');
50
+ const flatBinaryName = platform === 'win32' ? 'fnva.exe' : 'fnva';
51
+ binaryCandidates.push(path.join(projectRoot, 'platforms', flatBinaryName));
52
+
53
+ // 2. User-provided override via environment variable
54
+ if (process.env.FNVA_NATIVE_PATH) {
55
+ binaryCandidates.push(process.env.FNVA_NATIVE_PATH);
56
+ }
57
+
58
+ // 3. Local cargo build outputs (helpful for development installs)
59
+ const targetDir = path.resolve(__dirname, '..', 'target');
60
+ if (platform === 'win32') {
61
+ binaryCandidates.push(path.join(targetDir, 'release', 'fnva.exe'));
62
+ binaryCandidates.push(path.join(targetDir, 'debug', 'fnva.exe'));
63
+ } else {
64
+ binaryCandidates.push(path.join(targetDir, 'release', 'fnva'));
65
+ binaryCandidates.push(path.join(targetDir, 'debug', 'fnva'));
66
+ }
67
+
68
+ for (const candidate of binaryCandidates) {
69
+ if (candidate && fs.existsSync(candidate)) {
70
+ return candidate;
71
+ }
72
+ }
73
+
74
+ return null;
75
+ }
76
+
40
77
  function run() {
41
78
  const binaryPath = buildBinaryPath();
42
79
 
43
- if (!fs.existsSync(binaryPath)) {
44
- console.error(`Error: binary not found: ${binaryPath}`);
80
+ if (!binaryPath) {
81
+ console.error('Error: fnva native binary not found.');
45
82
  console.error('');
46
- console.error("Please build the CLI binaries first, e.g. run 'npm run build' or 'npm run build:all'.");
83
+ console.error("Please either:");
84
+ console.error(" 1) Run 'npm run build' (or 'npm run build:all') to produce platform binaries,");
85
+ console.error(" 2) Install a release package that includes the platforms directory, or");
86
+ console.error(" 3) Set FNVA_NATIVE_PATH to the full path of an existing fnva executable.");
47
87
  process.exit(1);
48
88
  }
49
89
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
5
5
  "author": "protagonistss",
6
6
  "license": "MIT",
package/platforms/fnva CHANGED
Binary file
Binary file