fnva 0.0.28 → 0.0.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
5
5
  "author": "protagonistss",
6
6
  "license": "MIT",
package/platforms/fnva CHANGED
Binary file
Binary file
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // Shell integration installer for fnva (npm postinstall helper).
4
- // Generates a lightweight function wrapper per shell that calls the real
5
- // `fnva` binary and applies environment switch scripts.
4
+ // Generates a minimal shell function that invokes the real fnva binary.
6
5
 
7
6
  const fs = require('fs');
8
7
  const path = require('path');
9
8
  const os = require('os');
10
9
 
10
+ // Absolute path to the packaged fnva shim (bin/fnva.js)
11
+ const FNVA_SHIM = path.resolve(__dirname, '..', 'bin', 'fnva.js');
12
+
11
13
  function detectShell() {
12
14
  if (process.platform === 'win32') {
13
15
  return 'powershell';
@@ -64,13 +66,27 @@ function fnva {
64
66
  `;
65
67
  }
66
68
 
69
+ function resolveBinaryPath() {
70
+ // Prefer real binary, avoid this function name
71
+ if (process.platform === 'win32') {
72
+ return process.argv[0];
73
+ }
74
+ let bin = '';
75
+ try {
76
+ const which = require('child_process').spawnSync('which', ['fnva'], { encoding: 'utf8' });
77
+ if (which.status === 0) {
78
+ bin = (which.stdout || '').trim();
79
+ }
80
+ } catch {}
81
+ return bin;
82
+ }
83
+
67
84
  function getBashFunction() {
68
85
  return `
69
86
  # fnva auto integration (added by npm install)
70
87
  fnva() {
71
- local __fnva_bin
72
- __fnva_bin="$(command -v fnva | head -n 1)"
73
- if [[ -z "$__fnva_bin" ]]; then
88
+ local __fnva_bin="${FNVA_SHIM}"
89
+ if [[ ! -x "$__fnva_bin" ]]; then
74
90
  echo "fnva: binary not found in PATH" >&2
75
91
  return 127
76
92
  fi
@@ -94,8 +110,8 @@ function getFishFunction() {
94
110
  return `
95
111
  # fnva auto integration (added by npm install)
96
112
  function fnva
97
- set __fnva_bin (command -v fnva | head -n 1)
98
- if test -z "$__fnva_bin"
113
+ set __fnva_bin "${FNVA_SHIM}"
114
+ if test ! -x "$__fnva_bin"
99
115
  echo "fnva: binary not found in PATH" >&2
100
116
  return 127
101
117
  end
@@ -140,13 +156,13 @@ function installShellIntegration() {
140
156
  const configPath = getShellConfigPath(shell);
141
157
 
142
158
  if (!configPath) {
143
- console.log(`⚠️ Unsupported shell: ${shell}`);
159
+ console.log(`Unsupported shell: ${shell}`);
144
160
  console.log('Please configure fnva manually (see README).');
145
161
  return false;
146
162
  }
147
163
 
148
164
  if (isFunctionInstalled(configPath)) {
149
- console.log(`✅ fnva shell integration already present: ${configPath}`);
165
+ console.log(`fnva shell integration already present: ${configPath}`);
150
166
  return true;
151
167
  }
152
168
 
@@ -165,25 +181,11 @@ function installShellIntegration() {
165
181
  fs.writeFileSync(configPath, functionCode);
166
182
  }
167
183
 
168
- console.log(`✅ fnva shell integration installed at: ${configPath}`);
169
- console.log('🔄 Reload your shell config:');
170
- switch (shell) {
171
- case 'powershell':
172
- console.log(' . $PROFILE');
173
- break;
174
- case 'bash':
175
- console.log(' source ~/.bashrc');
176
- break;
177
- case 'zsh':
178
- console.log(' source ~/.zshrc');
179
- break;
180
- case 'fish':
181
- console.log(' source ~/.config/fish/config.fish');
182
- break;
183
- }
184
+ console.log(`fnva shell integration installed at: ${configPath}`);
185
+ console.log('Reload your shell config after install.');
184
186
  return true;
185
187
  } catch (error) {
186
- console.log(`❌ Install failed: ${error.message}`);
188
+ console.log(`Install failed: ${error.message}`);
187
189
  console.log('Please configure fnva manually (see README).');
188
190
  return false;
189
191
  }
@@ -191,13 +193,13 @@ function installShellIntegration() {
191
193
 
192
194
  function promptInstallation() {
193
195
  if (process.env.FNVA_SKIP_SHELL_SETUP === '1') {
194
- console.log('⏭️ Skipping shell integration (FNVA_SKIP_SHELL_SETUP=1)');
196
+ console.log('Skipping shell integration (FNVA_SKIP_SHELL_SETUP=1)');
195
197
  return;
196
198
  }
197
199
 
198
200
  const shell = detectShell();
199
- console.log(`🔍 Detected shell: ${shell}`);
200
- console.log('Install fnva shell integration? (y/N)');
201
+ console.log(`Detected shell: ${shell}`);
202
+ console.log('Install fnva shell integration? (y/N)');
201
203
 
202
204
  const readline = require('readline');
203
205
  const rl = readline.createInterface({
@@ -210,21 +212,20 @@ function promptInstallation() {
210
212
  if (normalized === 'y' || normalized === 'yes') {
211
213
  installShellIntegration();
212
214
  } else {
213
- console.log('Skipped shell integration.');
215
+ console.log('Skipped shell integration.');
214
216
  }
215
217
  rl.close();
216
218
  });
217
219
  }
218
220
 
219
221
  function main() {
220
- console.log('🛠️ fnva shell integration installer');
221
- console.log(`📦 Node.js version: ${process.version}`);
222
- console.log(`📍 CWD: ${process.cwd()}`);
222
+ console.log('fnva shell integration installer');
223
+ console.log(`Node.js version: ${process.version}`);
224
+ console.log(`CWD: ${process.cwd()}`);
223
225
 
224
226
  if (process.argv.includes('--auto') || process.argv.includes('--yes')) {
225
- console.log('🤖 Auto mode: installing...');
226
227
  const result = installShellIntegration();
227
- console.log(`📄 Install result: ${result ? 'success' : 'failed'}`);
228
+ console.log(`Install result: ${result ? 'success' : 'failed'}`);
228
229
  } else {
229
230
  promptInstallation();
230
231
  }