fnva 0.0.17 → 0.0.19
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 +0 -1
- package/bin/fnva.js +14 -2
- package/package.json +4 -3
- package/platforms/fnva +0 -0
- package/platforms/fnva.exe +0 -0
- package/scripts/build-all.sh +7 -1
- package/scripts/build-local.sh +9 -3
- package/scripts/check-permissions.js +59 -0
- package/scripts/ensure-executable-permissions.js +59 -0
- package/scripts/prepare-publish.sh +30 -0
package/README.md
CHANGED
package/bin/fnva.js
CHANGED
|
@@ -431,7 +431,13 @@ function run() {
|
|
|
431
431
|
});
|
|
432
432
|
|
|
433
433
|
if (result.error) {
|
|
434
|
-
|
|
434
|
+
if (result.error.code === 'EACCES' && process.platform !== 'win32') {
|
|
435
|
+
console.error(`❌ Permission denied. The fnva binary is not executable.`);
|
|
436
|
+
console.error(`💡 To fix this, run: sudo chmod +x "${binaryPath}"`);
|
|
437
|
+
console.error(` Or reinstall: npm install -g fnva --force`);
|
|
438
|
+
} else {
|
|
439
|
+
console.error(`Failed to execute fnva: ${result.error.message}`);
|
|
440
|
+
}
|
|
435
441
|
process.exit(result.status ?? 1);
|
|
436
442
|
}
|
|
437
443
|
|
|
@@ -541,7 +547,13 @@ function run() {
|
|
|
541
547
|
});
|
|
542
548
|
|
|
543
549
|
if (result.error) {
|
|
544
|
-
|
|
550
|
+
if (result.error.code === 'EACCES' && process.platform !== 'win32') {
|
|
551
|
+
console.error(`❌ Permission denied. The fnva binary is not executable.`);
|
|
552
|
+
console.error(`💡 To fix this, run: sudo chmod +x "${binaryPath}"`);
|
|
553
|
+
console.error(` Or reinstall: npm install -g fnva --force`);
|
|
554
|
+
} else {
|
|
555
|
+
console.error(`Failed to execute fnva: ${result.error.message}`);
|
|
556
|
+
}
|
|
545
557
|
process.exit(result.status ?? 1);
|
|
546
558
|
}
|
|
547
559
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fnva",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
|
|
5
5
|
"author": "protagonistss",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prepublishOnly": "scripts/prepare-publish.sh",
|
|
12
|
-
"postinstall": "echo 'Setting up fnva shell integration...' && node scripts/install-shell-integration.js --auto",
|
|
12
|
+
"postinstall": "node scripts/ensure-executable-permissions.js && echo 'Setting up fnva shell integration...' && node scripts/install-shell-integration.js --auto",
|
|
13
13
|
"install-shell": "node scripts/install-shell-integration.js",
|
|
14
14
|
"uninstall-shell": "node scripts/uninstall-shell-integration.js",
|
|
15
15
|
"build": "scripts/build-local.sh",
|
|
16
|
-
"build:all": "scripts/build-all.sh"
|
|
16
|
+
"build:all": "scripts/build-all.sh",
|
|
17
|
+
"check-permissions": "node scripts/check-permissions.js"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
20
|
"bin/",
|
package/platforms/fnva
CHANGED
|
Binary file
|
package/platforms/fnva.exe
CHANGED
|
Binary file
|
package/scripts/build-all.sh
CHANGED
|
@@ -67,7 +67,13 @@ build_target() {
|
|
|
67
67
|
if [ -f "$source_binary" ]; then
|
|
68
68
|
cp "$source_binary" "$output_dir/$binary_name"
|
|
69
69
|
echo "✓ 成功构建: $output_dir/$binary_name"
|
|
70
|
-
|
|
70
|
+
|
|
71
|
+
# 设置可执行权限(非Windows平台)
|
|
72
|
+
if [[ "$binary_name" != "*.exe" ]]; then
|
|
73
|
+
chmod 755 "$output_dir/$binary_name" # rwxr-xr-x, 明确设置权限
|
|
74
|
+
echo "✓ 已设置可执行权限 (755)"
|
|
75
|
+
fi
|
|
76
|
+
|
|
71
77
|
# 可选:压缩二进制文件(使用 strip)
|
|
72
78
|
if command -v strip &> /dev/null && [[ "$binary_name" != "*.exe" ]]; then
|
|
73
79
|
strip "$output_dir/$binary_name"
|
package/scripts/build-local.sh
CHANGED
|
@@ -65,14 +65,20 @@ SOURCE_BINARY="$PROJECT_ROOT/target/$TARGET/release/$BINARY_NAME"
|
|
|
65
65
|
if [ -f "$SOURCE_BINARY" ]; then
|
|
66
66
|
cp "$SOURCE_BINARY" "$OUTPUT_DIR/$BINARY_NAME"
|
|
67
67
|
echo "✓ 成功构建: $OUTPUT_DIR/$BINARY_NAME"
|
|
68
|
-
|
|
68
|
+
|
|
69
|
+
# 设置可执行权限(仅非Windows平台)
|
|
70
|
+
if [[ "$BINARY_NAME" != "*.exe" ]]; then
|
|
71
|
+
chmod 755 "$OUTPUT_DIR/$BINARY_NAME" # rwxr-xr-x, 明确设置权限
|
|
72
|
+
echo "✓ 已设置可执行权限 (755)"
|
|
73
|
+
fi
|
|
74
|
+
|
|
69
75
|
# 优化二进制文件大小
|
|
70
76
|
if command -v strip &> /dev/null; then
|
|
71
77
|
strip "$OUTPUT_DIR/$BINARY_NAME"
|
|
72
78
|
echo "✓ 已优化二进制文件大小"
|
|
73
79
|
fi
|
|
74
|
-
|
|
75
|
-
#
|
|
80
|
+
|
|
81
|
+
# 显示文件大小和权限
|
|
76
82
|
ls -lh "$OUTPUT_DIR/$BINARY_NAME"
|
|
77
83
|
else
|
|
78
84
|
echo "✗ 错误: 未找到构建产物: $SOURCE_BINARY"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 检查platforms目录中二进制文件的权限
|
|
8
|
+
*/
|
|
9
|
+
function checkPermissions() {
|
|
10
|
+
console.log('🔍 检查二进制文件权限...');
|
|
11
|
+
|
|
12
|
+
const platformsDir = path.join(__dirname, '..', 'platforms');
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(platformsDir)) {
|
|
15
|
+
console.log('❌ platforms目录不存在');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const platforms = fs.readdirSync(platformsDir);
|
|
20
|
+
let allGood = true;
|
|
21
|
+
|
|
22
|
+
for (const platform of platforms) {
|
|
23
|
+
const platformDir = path.join(platformsDir, platform);
|
|
24
|
+
|
|
25
|
+
if (!fs.statSync(platformDir).isDirectory()) continue;
|
|
26
|
+
|
|
27
|
+
const binaryName = platform.includes('win32') ? 'fnva.exe' : 'fnva';
|
|
28
|
+
const binaryPath = path.join(platformDir, binaryName);
|
|
29
|
+
|
|
30
|
+
if (fs.existsSync(binaryPath)) {
|
|
31
|
+
const stats = fs.statSync(binaryPath);
|
|
32
|
+
const hasExecPermission = (stats.mode & 0o111) !== 0;
|
|
33
|
+
const mode = stats.mode.toString(8).padStart(4, '0');
|
|
34
|
+
|
|
35
|
+
console.log(` ${platform}/${binaryName}: ${mode} ${hasExecPermission ? '✅' : '❌'}`);
|
|
36
|
+
|
|
37
|
+
if (!hasExecPermission && binaryName !== 'fnva.exe') {
|
|
38
|
+
allGood = false;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
console.log(` ${platform}/${binaryName}: ❌ 文件不存在`);
|
|
42
|
+
allGood = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(`\n${allGood ? '✅' : '❌'} 权限检查${allGood ? '通过' : '失败'}`);
|
|
47
|
+
|
|
48
|
+
if (!allGood) {
|
|
49
|
+
console.log('\n修复建议:');
|
|
50
|
+
console.log(' 运行以下命令设置权限:');
|
|
51
|
+
console.log(' find platforms -name "fnva" -type f -exec chmod 755 {} \\;');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (require.main === module) {
|
|
56
|
+
checkPermissions();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = { checkPermissions };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 确保fnva二进制文件有可执行权限
|
|
8
|
+
* 这是一个轻量级的postinstall脚本,专门用来解决npm打包时权限丢失的问题
|
|
9
|
+
*/
|
|
10
|
+
function ensureExecutablePermissions() {
|
|
11
|
+
try {
|
|
12
|
+
const scriptDir = __dirname;
|
|
13
|
+
const projectRoot = path.resolve(scriptDir, '..');
|
|
14
|
+
const platformsDir = path.join(projectRoot, 'platforms');
|
|
15
|
+
|
|
16
|
+
// 如果没有platforms目录,说明是开发模式,不需要处理
|
|
17
|
+
if (!fs.existsSync(platformsDir)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 检测当前平台
|
|
22
|
+
const platform = process.platform;
|
|
23
|
+
const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
|
|
24
|
+
const platformDir = `${platform}-${arch}`;
|
|
25
|
+
|
|
26
|
+
// 确定二进制文件名和路径
|
|
27
|
+
const binaryName = platform === 'win32' ? 'fnva.exe' : 'fnva';
|
|
28
|
+
const binaryPath = path.join(platformsDir, platformDir, binaryName);
|
|
29
|
+
|
|
30
|
+
// 如果二进制文件存在且不是Windows,设置可执行权限
|
|
31
|
+
if (fs.existsSync(binaryPath) && platform !== 'win32') {
|
|
32
|
+
try {
|
|
33
|
+
const stats = fs.statSync(binaryPath);
|
|
34
|
+
const hasExecPermission = (stats.mode & 0o111) !== 0;
|
|
35
|
+
|
|
36
|
+
if (!hasExecPermission) {
|
|
37
|
+
fs.chmodSync(binaryPath, 0o755); // rwxr-xr-x
|
|
38
|
+
// 只在实际修复了权限时才输出消息,避免在正常安装时产生噪音
|
|
39
|
+
if (process.env.DEBUG || process.env.NPM_DEBUG) {
|
|
40
|
+
console.log(`🔧 Fixed executable permissions for fnva binary`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// 静默处理错误,不干扰正常安装流程
|
|
45
|
+
if (process.env.DEBUG || process.env.NPM_DEBUG) {
|
|
46
|
+
console.warn(`⚠️ Could not fix binary permissions: ${error.message}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
// 静默处理错误,不干扰正常安装流程
|
|
52
|
+
if (process.env.DEBUG || process.env.NPM_DEBUG) {
|
|
53
|
+
console.warn(`⚠️ Permission check failed: ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 运行权限检查
|
|
59
|
+
ensureExecutablePermissions();
|
|
@@ -37,6 +37,36 @@ else
|
|
|
37
37
|
exit 1
|
|
38
38
|
fi
|
|
39
39
|
|
|
40
|
+
# 本地环境: 验证二进制文件的可执行权限
|
|
41
|
+
echo "验证二进制文件权限..."
|
|
42
|
+
PERMISSION_ERROR_COUNT=0
|
|
43
|
+
for platform_dir in platforms/*/; do
|
|
44
|
+
if [ -d "$platform_dir" ]; then
|
|
45
|
+
BINARY_NAME="fnva"
|
|
46
|
+
if [[ "$platform_dir" == *"win32"* ]]; then
|
|
47
|
+
BINARY_NAME="fnva.exe"
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
BINARY_PATH="$platform_dir/$BINARY_NAME"
|
|
51
|
+
if [ -f "$BINARY_PATH" ]; then
|
|
52
|
+
# 检查是否有可执行权限(非Windows文件)
|
|
53
|
+
if [[ "$BINARY_NAME" != "*.exe" ]] && [ ! -x "$BINARY_PATH" ]; then
|
|
54
|
+
echo "⚠️ 警告: $BINARY_PATH 缺少可执行权限"
|
|
55
|
+
PERMISSION_ERROR_COUNT=$((PERMISSION_ERROR_COUNT + 1))
|
|
56
|
+
else
|
|
57
|
+
echo "✓ $BINARY_PATH 权限正确"
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
fi
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
if [ $PERMISSION_ERROR_COUNT -gt 0 ]; then
|
|
64
|
+
echo "错误: 发现 $PERMISSION_ERROR_COUNT 个二进制文件缺少可执行权限"
|
|
65
|
+
echo "请运行以下命令修复权限:"
|
|
66
|
+
echo " find platforms -name 'fnva' -type f -exec chmod +x {} \\;"
|
|
67
|
+
exit 1
|
|
68
|
+
fi
|
|
69
|
+
|
|
40
70
|
# 本地环境: 提示用户确认
|
|
41
71
|
read -p "确认发布版本 $VERSION? (y/N) " -n 1 -r
|
|
42
72
|
echo
|