fnva 0.0.49 → 0.0.51
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/README.md +1 -1
- package/bin/fnva.js +25 -0
- package/bin/fnva.ps1 +23 -29
- package/package.json +1 -1
- package/platforms/darwin-arm64/fnva +0 -0
- package/platforms/darwin-x64/fnva +0 -0
- package/platforms/linux-arm64/fnva +0 -0
- package/platforms/linux-x64/fnva +0 -0
- package/platforms/win32-x64/fnva.exe +0 -0
- package/scripts/install-shell-integration.js +35 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Cross-platform environment switcher for Java, Claude Code (CC), and LLM setups.
|
|
|
15
15
|
## Quick start
|
|
16
16
|
|
|
17
17
|
- Init shell (Bash/Zsh): `eval "$(fnva env env --shell bash)"`
|
|
18
|
-
PowerShell: `
|
|
18
|
+
PowerShell: `fnva env env --shell powershell | Out-String | Invoke-Expression`
|
|
19
19
|
Fish: `fnva env env --shell fish | source`
|
|
20
20
|
- Scan Java: `fnva java scan`
|
|
21
21
|
- Switch Java for current session: `fnva java use jdk-17` (with shell integration)
|
package/bin/fnva.js
CHANGED
|
@@ -651,6 +651,31 @@ function run() {
|
|
|
651
651
|
|
|
652
652
|
process.exit(0);
|
|
653
653
|
} else {
|
|
654
|
+
// For env commands, capture output and write as single string to avoid
|
|
655
|
+
// PowerShell splitting multi-line output into Object[] (which breaks
|
|
656
|
+
// the standard | Out-String | Invoke-Expression profile pattern).
|
|
657
|
+
const isEnvOutputCommand = args[0] === 'env' && args[1] === 'env';
|
|
658
|
+
if (isEnvOutputCommand) {
|
|
659
|
+
const result = spawnSync(binaryPath, args, {
|
|
660
|
+
encoding: 'utf8',
|
|
661
|
+
shell: false,
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
if (result.error) {
|
|
665
|
+
console.error(`[ERROR] Failed to execute fnva: ${result.error.message}`);
|
|
666
|
+
process.exit(result.status ?? 1);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if (result.stdout) {
|
|
670
|
+
process.stdout.write(result.stdout);
|
|
671
|
+
}
|
|
672
|
+
if (result.stderr) {
|
|
673
|
+
process.stderr.write(result.stderr);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
process.exit(result.status ?? 0);
|
|
677
|
+
}
|
|
678
|
+
|
|
654
679
|
// 对于其他命令,使用原有的 stdio: 'inherit' 方式
|
|
655
680
|
const result = spawnSync(binaryPath, args, {
|
|
656
681
|
stdio: 'inherit',
|
package/bin/fnva.ps1
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# fnva PowerShell wrapper - calls native binary directly
|
|
3
|
+
# PowerShell prefers .ps1 over .cmd, avoiding Object[] output splitting
|
|
2
4
|
|
|
3
|
-
param(
|
|
4
|
-
[Parameter(ValueFromRemainingArguments=$true)]
|
|
5
|
-
[string[]]$Arguments
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
# 检测平台和架构
|
|
9
|
-
$os = "win32"
|
|
10
|
-
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" }
|
|
11
|
-
|
|
12
|
-
# 构建二进制文件路径
|
|
13
|
-
$platformDir = "$os-$arch"
|
|
14
5
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
15
|
-
$
|
|
6
|
+
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" }
|
|
7
|
+
$platformDir = "win32-$arch"
|
|
16
8
|
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
# Try native binary in npm package
|
|
10
|
+
$binaryPath = Join-Path $scriptDir "..\platforms\$platformDir\fnva.exe"
|
|
11
|
+
if (Test-Path $binaryPath) {
|
|
12
|
+
& $binaryPath @args
|
|
13
|
+
exit $LASTEXITCODE
|
|
20
14
|
}
|
|
21
15
|
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Write-Host " 2. $(Join-Path $scriptDir ".." "platforms" "fnva.exe")" -ForegroundColor Yellow
|
|
28
|
-
Write-Host "请运行 'npm run build' 构建二进制文件" -ForegroundColor Yellow
|
|
29
|
-
exit 1
|
|
16
|
+
# Fallback: local dev build
|
|
17
|
+
$devPath = Join-Path $scriptDir "..\target\release\fnva.exe"
|
|
18
|
+
if (Test-Path $devPath) {
|
|
19
|
+
& $devPath @args
|
|
20
|
+
exit $LASTEXITCODE
|
|
30
21
|
}
|
|
31
22
|
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
# Last resort: node wrapper
|
|
24
|
+
$nodeScript = Join-Path $scriptDir "fnva.js"
|
|
25
|
+
if (Test-Path $nodeScript) {
|
|
26
|
+
& node $nodeScript @args
|
|
36
27
|
exit $LASTEXITCODE
|
|
37
|
-
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Write-Error "fnva: native binary not found. Reinstall with: npm install -g fnva --force"
|
|
31
|
+
exit 1
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/platforms/linux-x64/fnva
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -50,7 +50,7 @@ function getShellConfigPath(shell) {
|
|
|
50
50
|
function getIntegrationLine(shell) {
|
|
51
51
|
switch (shell) {
|
|
52
52
|
case 'powershell':
|
|
53
|
-
return '
|
|
53
|
+
return 'fnva env env --shell powershell | Out-String | Invoke-Expression';
|
|
54
54
|
case 'bash':
|
|
55
55
|
case 'zsh':
|
|
56
56
|
return 'eval "$(fnva env env --shell bash)"';
|
|
@@ -142,12 +142,46 @@ function promptInstallation() {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
function getNpmGlobalBinDir() {
|
|
146
|
+
// Try npm_config_prefix first (set by npm during install)
|
|
147
|
+
if (process.env.npm_config_prefix) {
|
|
148
|
+
return process.env.npm_config_prefix;
|
|
149
|
+
}
|
|
150
|
+
// Fallback: find where fnva.cmd lives
|
|
151
|
+
try {
|
|
152
|
+
const result = spawnSync('npm', ['prefix', '-g'], { encoding: 'utf8', timeout: 10000 });
|
|
153
|
+
if (result.status === 0 && result.stdout.trim()) {
|
|
154
|
+
return result.stdout.trim();
|
|
155
|
+
}
|
|
156
|
+
} catch (_) {}
|
|
157
|
+
// Last resort: derive from node executable path
|
|
158
|
+
return path.dirname(process.execPath);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function installPowershellWrapper() {
|
|
162
|
+
if (process.platform !== 'win32') return;
|
|
163
|
+
|
|
164
|
+
const srcPs1 = path.resolve(__dirname, '..', 'bin', 'fnva.ps1');
|
|
165
|
+
if (!fs.existsSync(srcPs1)) return;
|
|
166
|
+
|
|
167
|
+
const npmBinDir = getNpmGlobalBinDir();
|
|
168
|
+
const destPs1 = path.join(npmBinDir, 'fnva.ps1');
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
fs.copyFileSync(srcPs1, destPs1);
|
|
172
|
+
console.log(`PowerShell wrapper installed: ${destPs1}`);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.log(`PowerShell wrapper install skipped: ${error.message}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
145
178
|
function main() {
|
|
146
179
|
console.log('fnva shell integration installer');
|
|
147
180
|
console.log(`Node.js version: ${process.version}`);
|
|
148
181
|
console.log(`CWD: ${process.cwd()}`);
|
|
149
182
|
|
|
150
183
|
if (process.argv.includes('--auto') || process.argv.includes('--yes')) {
|
|
184
|
+
installPowershellWrapper();
|
|
151
185
|
const result = installShellIntegration();
|
|
152
186
|
console.log(`Install result: ${result ? 'success' : 'failed'}`);
|
|
153
187
|
} else {
|