fnva 0.0.18 → 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 CHANGED
@@ -5,7 +5,6 @@
5
5
  ## 功能特性
6
6
 
7
7
  - ✅ **Java 环境管理**:快速切换不同版本的 JDK
8
- - ✅ **LLM 环境管理**:支持多 LLM 提供商配置切换
9
8
  - ✅ **Claude Code (CC) 环境管理**:专门为 Claude Code 设计的环境切换
10
9
  - ✅ **默认环境支持**:支持设置默认环境
11
10
  - ✅ **自动加载**:新 Shell 会话自动加载默认环境
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.18",
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
Binary file
@@ -70,8 +70,8 @@ build_target() {
70
70
 
71
71
  # 设置可执行权限(非Windows平台)
72
72
  if [[ "$binary_name" != "*.exe" ]]; then
73
- chmod +x "$output_dir/$binary_name"
74
- echo "✓ 已设置可执行权限"
73
+ chmod 755 "$output_dir/$binary_name" # rwxr-xr-x, 明确设置权限
74
+ echo "✓ 已设置可执行权限 (755)"
75
75
  fi
76
76
 
77
77
  # 可选:压缩二进制文件(使用 strip)
@@ -68,8 +68,8 @@ if [ -f "$SOURCE_BINARY" ]; then
68
68
 
69
69
  # 设置可执行权限(仅非Windows平台)
70
70
  if [[ "$BINARY_NAME" != "*.exe" ]]; then
71
- chmod +x "$OUTPUT_DIR/$BINARY_NAME"
72
- echo "✓ 已设置可执行权限"
71
+ chmod 755 "$OUTPUT_DIR/$BINARY_NAME" # rwxr-xr-x, 明确设置权限
72
+ echo "✓ 已设置可执行权限 (755)"
73
73
  fi
74
74
 
75
75
  # 优化二进制文件大小
@@ -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();