fnva 0.0.6 → 0.0.8
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.cmd +9 -1
- package/bin/fnva.js +45 -5
- package/bin/fnva.ps1 +9 -1
- package/package.json +1 -1
- package/platforms/fnva +0 -0
- package/platforms/fnva.exe +0 -0
package/bin/fnva.cmd
CHANGED
|
@@ -17,9 +17,17 @@ REM 构建二进制文件路径
|
|
|
17
17
|
set PLATFORM_DIR=%OS%-%ARCH%
|
|
18
18
|
set BINARY_PATH=%~dp0..\platforms\%PLATFORM_DIR%\fnva.exe
|
|
19
19
|
|
|
20
|
+
REM 如果分层结构不存在,尝试扁平结构
|
|
21
|
+
if not exist "%BINARY_PATH%" (
|
|
22
|
+
set BINARY_PATH=%~dp0..\platforms\fnva.exe
|
|
23
|
+
)
|
|
24
|
+
|
|
20
25
|
REM 检查二进制文件是否存在
|
|
21
26
|
if not exist "%BINARY_PATH%" (
|
|
22
|
-
echo 错误:
|
|
27
|
+
echo 错误: 未找到二进制文件
|
|
28
|
+
echo 尝试的路径:
|
|
29
|
+
echo 1. %~dp0..\platforms\%PLATFORM_DIR%\fnva.exe
|
|
30
|
+
echo 2. %~dp0..\platforms\fnva.exe
|
|
23
31
|
echo 请运行 'npm run build' 构建二进制文件
|
|
24
32
|
exit /b 1
|
|
25
33
|
)
|
package/bin/fnva.js
CHANGED
|
@@ -27,8 +27,8 @@ function resolveArch() {
|
|
|
27
27
|
return 'x64';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function
|
|
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 (!
|
|
44
|
-
console.error(
|
|
80
|
+
if (!binaryPath) {
|
|
81
|
+
console.error('Error: fnva native binary not found.');
|
|
45
82
|
console.error('');
|
|
46
|
-
console.error("Please
|
|
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/bin/fnva.ps1
CHANGED
|
@@ -14,9 +14,17 @@ $platformDir = "$os-$arch"
|
|
|
14
14
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
15
15
|
$binaryPath = Join-Path $scriptDir ".." "platforms" $platformDir "fnva.exe"
|
|
16
16
|
|
|
17
|
+
# 如果分层结构不存在,尝试扁平结构
|
|
18
|
+
if (-not (Test-Path $binaryPath)) {
|
|
19
|
+
$binaryPath = Join-Path $scriptDir ".." "platforms" "fnva.exe"
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
# 检查二进制文件是否存在
|
|
18
23
|
if (-not (Test-Path $binaryPath)) {
|
|
19
|
-
Write-Host "错误:
|
|
24
|
+
Write-Host "错误: 未找到二进制文件" -ForegroundColor Red
|
|
25
|
+
Write-Host "尝试的路径: " -ForegroundColor Yellow
|
|
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
|
|
20
28
|
Write-Host "请运行 'npm run build' 构建二进制文件" -ForegroundColor Yellow
|
|
21
29
|
exit 1
|
|
22
30
|
}
|
package/package.json
CHANGED
package/platforms/fnva
CHANGED
|
Binary file
|
package/platforms/fnva.exe
CHANGED
|
Binary file
|