fnva 0.0.50 → 0.0.52
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.ps1 +31 -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 +34 -0
package/bin/fnva.ps1
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
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
|
-
|
|
4
|
-
[Parameter(ValueFromRemainingArguments=$true)]
|
|
5
|
-
[string[]]$Arguments
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
# 检测平台和架构
|
|
9
|
-
$os = "win32"
|
|
5
|
+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
10
6
|
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" }
|
|
7
|
+
$platformDir = "win32-$arch"
|
|
11
8
|
|
|
12
|
-
#
|
|
13
|
-
$
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
# Search paths for native binary (in priority order)
|
|
10
|
+
$searchPaths = @(
|
|
11
|
+
# npm global install: fnva.ps1 is in <prefix>/, binary is in <prefix>/node_modules/fnva/platforms/
|
|
12
|
+
(Join-Path $scriptDir "node_modules\fnva\platforms\$platformDir\fnva.exe"),
|
|
13
|
+
# npm global install (flat): binary next to fnva.ps1
|
|
14
|
+
(Join-Path $scriptDir "fnva.exe"),
|
|
15
|
+
# Source tree: fnva.ps1 is in bin/, binary is in platforms/
|
|
16
|
+
(Join-Path $scriptDir "..\platforms\$platformDir\fnva.exe"),
|
|
17
|
+
# Local dev build
|
|
18
|
+
(Join-Path $scriptDir "..\target\release\fnva.exe")
|
|
19
|
+
)
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
21
|
+
foreach ($binaryPath in $searchPaths) {
|
|
22
|
+
if (Test-Path $binaryPath) {
|
|
23
|
+
& $binaryPath @args
|
|
24
|
+
exit $LASTEXITCODE
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Write-Host " 1. $(Join-Path $scriptDir ".." "platforms" $platformDir "fnva.exe")" -ForegroundColor Yellow
|
|
27
|
-
Write-Host " 2. $(Join-Path $scriptDir ".." "platforms" "fnva.exe")" -ForegroundColor Yellow
|
|
28
|
-
Write-Host "请运行 'npm run build' 构建二进制文件" -ForegroundColor Yellow
|
|
29
|
-
exit 1
|
|
28
|
+
# Last resort: node wrapper
|
|
29
|
+
$nodeScript = Join-Path $scriptDir "node_modules\fnva\bin\fnva.js"
|
|
30
|
+
if (-not (Test-Path $nodeScript)) {
|
|
31
|
+
$nodeScript = Join-Path $scriptDir "fnva.js"
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
& $binaryPath $Arguments
|
|
34
|
-
|
|
35
|
-
if ($LASTEXITCODE) {
|
|
33
|
+
if (Test-Path $nodeScript) {
|
|
34
|
+
& node $nodeScript @args
|
|
36
35
|
exit $LASTEXITCODE
|
|
37
|
-
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Write-Error "fnva: native binary not found. Reinstall with: npm install -g fnva --force"
|
|
39
|
+
exit 1
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/platforms/linux-x64/fnva
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -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 {
|