fnva 0.0.21 → 0.0.22
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/package.json
CHANGED
package/platforms/fnva
CHANGED
|
Binary file
|
package/platforms/fnva.exe
CHANGED
|
Binary file
|
|
@@ -4,7 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* 检查platforms目录中二进制文件的权限
|
|
7
|
+
* 检查 platforms 目录中二进制文件的权限
|
|
8
8
|
*/
|
|
9
9
|
function checkPermissions() {
|
|
10
10
|
console.log('🔍 检查二进制文件权限...');
|
|
@@ -12,13 +12,14 @@ function checkPermissions() {
|
|
|
12
12
|
const platformsDir = path.join(__dirname, '..', 'platforms');
|
|
13
13
|
|
|
14
14
|
if (!fs.existsSync(platformsDir)) {
|
|
15
|
-
console.log('❌ platforms目录不存在');
|
|
15
|
+
console.log('❌ platforms 目录不存在');
|
|
16
16
|
process.exit(1);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const platforms = fs.readdirSync(platformsDir);
|
|
20
20
|
let allGood = true;
|
|
21
21
|
|
|
22
|
+
// 优先检查新的 platform-arch 目录结构
|
|
22
23
|
for (const platform of platforms) {
|
|
23
24
|
const platformDir = path.join(platformsDir, platform);
|
|
24
25
|
|
|
@@ -43,6 +44,22 @@ function checkPermissions() {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
// 额外检查一次扁平结构: platforms/fnva
|
|
48
|
+
const flatBinaryName = process.platform === 'win32' ? 'fnva.exe' : 'fnva';
|
|
49
|
+
const flatBinaryPath = path.join(platformsDir, flatBinaryName);
|
|
50
|
+
|
|
51
|
+
if (fs.existsSync(flatBinaryPath)) {
|
|
52
|
+
const stats = fs.statSync(flatBinaryPath);
|
|
53
|
+
const hasExecPermission = (stats.mode & 0o111) !== 0;
|
|
54
|
+
const mode = stats.mode.toString(8).padStart(4, '0');
|
|
55
|
+
|
|
56
|
+
console.log(` (legacy)/${flatBinaryName}: ${mode} ${hasExecPermission ? '✅' : '❌'}`);
|
|
57
|
+
|
|
58
|
+
if (!hasExecPermission && flatBinaryName !== 'fnva.exe') {
|
|
59
|
+
allGood = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
console.log(`\n${allGood ? '✅' : '❌'} 权限检查${allGood ? '通过' : '失败'}`);
|
|
47
64
|
|
|
48
65
|
if (!allGood) {
|
|
@@ -56,4 +73,5 @@ if (require.main === module) {
|
|
|
56
73
|
checkPermissions();
|
|
57
74
|
}
|
|
58
75
|
|
|
59
|
-
module.exports = { checkPermissions };
|
|
76
|
+
module.exports = { checkPermissions };
|
|
77
|
+
|
|
@@ -4,8 +4,8 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* 确保fnva二进制文件有可执行权限
|
|
8
|
-
*
|
|
7
|
+
* 确保 fnva 二进制文件有可执行权限
|
|
8
|
+
* 这是一个全局的 postinstall 脚本,处理本地安装和全局安装的权限问题
|
|
9
9
|
*/
|
|
10
10
|
function ensureExecutablePermissions() {
|
|
11
11
|
try {
|
|
@@ -13,82 +13,92 @@ function ensureExecutablePermissions() {
|
|
|
13
13
|
const projectRoot = path.resolve(scriptDir, '..');
|
|
14
14
|
const platformsDir = path.join(projectRoot, 'platforms');
|
|
15
15
|
|
|
16
|
-
console.log('
|
|
16
|
+
console.log('✅ Ensuring fnva binary permissions...');
|
|
17
17
|
|
|
18
|
-
// 如果没有platforms目录,说明是开发模式,不需要处理
|
|
18
|
+
// 如果没有 platforms 目录,说明是开发模式,不需要处理
|
|
19
19
|
if (!fs.existsSync(platformsDir)) {
|
|
20
20
|
console.log('ℹ️ No platforms directory found, skipping permission check');
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// 检测当前平台
|
|
25
24
|
const platform = process.platform;
|
|
26
25
|
const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
|
|
27
26
|
const platformDir = `${platform}-${arch}`;
|
|
28
27
|
|
|
29
|
-
// 确定二进制文件名和路径
|
|
30
28
|
const binaryName = platform === 'win32' ? 'fnva.exe' : 'fnva';
|
|
31
|
-
const
|
|
29
|
+
const archBinaryPath = path.join(platformsDir, platformDir, binaryName);
|
|
30
|
+
const flatBinaryPath = path.join(platformsDir, binaryName);
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/**
|
|
33
|
+
* 确保指定路径的二进制文件具有可执行权限,并做一次简单的运行测试
|
|
34
|
+
*/
|
|
35
|
+
function ensureExecutable(binaryPath, label) {
|
|
35
36
|
try {
|
|
36
37
|
const stats = fs.statSync(binaryPath);
|
|
37
38
|
const hasExecPermission = (stats.mode & 0o111) !== 0;
|
|
38
39
|
|
|
39
|
-
console.log(`📍 Checking binary: ${binaryPath}`);
|
|
40
|
+
console.log(`📍 Checking binary (${label}): ${binaryPath}`);
|
|
40
41
|
console.log(` Current permissions: ${(stats.mode & 0o777).toString(8)}`);
|
|
41
42
|
|
|
42
43
|
if (!hasExecPermission) {
|
|
43
|
-
console.log(
|
|
44
|
+
console.log('🔧 Setting executable permissions...');
|
|
44
45
|
fs.chmodSync(binaryPath, 0o755); // rwxr-xr-x
|
|
45
46
|
|
|
46
|
-
// 验证权限设置成功
|
|
47
47
|
const newStats = fs.statSync(binaryPath);
|
|
48
48
|
const newHasExecPermission = (newStats.mode & 0o111) !== 0;
|
|
49
49
|
|
|
50
50
|
if (newHasExecPermission) {
|
|
51
|
-
console.log(`✅ Successfully set executable permissions (${
|
|
51
|
+
console.log(`✅ Successfully set executable permissions (${label})`);
|
|
52
52
|
} else {
|
|
53
|
-
console.log(`❌ Failed to set executable permissions (${
|
|
53
|
+
console.log(`❌ Failed to set executable permissions (${label})`);
|
|
54
54
|
console.log(` New permissions: ${(newStats.mode & 0o777).toString(8)}`);
|
|
55
55
|
console.log(` Manual fix may be required: chmod +x "${binaryPath}"`);
|
|
56
56
|
}
|
|
57
57
|
} else {
|
|
58
|
-
console.log(`✅ fnva binary already has executable permissions (${
|
|
58
|
+
console.log(`✅ fnva binary already has executable permissions (${label})`);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
//
|
|
61
|
+
// 尝试执行一次 --version 做简单验证
|
|
62
62
|
try {
|
|
63
63
|
const { spawnSync } = require('child_process');
|
|
64
64
|
const testResult = spawnSync(binaryPath, ['--version'], {
|
|
65
65
|
encoding: 'utf8',
|
|
66
66
|
timeout: 3000,
|
|
67
|
-
stdio: 'pipe'
|
|
67
|
+
stdio: 'pipe',
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
if (testResult.status === 0 || testResult.status === 1) {
|
|
71
|
-
console.log(
|
|
70
|
+
if (testResult.status === 0 || testResult.status === 1) {
|
|
71
|
+
console.log('✅ fnva binary is executable and responding');
|
|
72
72
|
} else if (testResult.error && testResult.error.code === 'EACCES') {
|
|
73
|
-
console.log(
|
|
73
|
+
console.log('❌ fnva binary still has permission issues');
|
|
74
74
|
console.log(` Manual fix required: chmod +x "${binaryPath}"`);
|
|
75
75
|
}
|
|
76
|
-
} catch
|
|
77
|
-
//
|
|
76
|
+
} catch {
|
|
77
|
+
// 测试失败不视为致命错误,可能是二进制本身的问题
|
|
78
78
|
}
|
|
79
|
-
|
|
80
79
|
} catch (error) {
|
|
81
|
-
console.warn(`⚠️ Could not fix binary permissions: ${error.message}`);
|
|
80
|
+
console.warn(`⚠️ Could not fix binary permissions (${label}): ${error.message}`);
|
|
82
81
|
console.log(` Manual fix required: chmod +x "${binaryPath}"`);
|
|
83
82
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Windows 不需要 chmod,可直接跳过
|
|
86
|
+
if (platform === 'win32') {
|
|
87
|
+
console.log('ℹ️ Windows platform detected, skipping permission check');
|
|
88
|
+
} else if (fs.existsSync(archBinaryPath)) {
|
|
89
|
+
// 优先处理新的平台子目录结构: platforms/<platform>-<arch>/fnva
|
|
90
|
+
ensureExecutable(archBinaryPath, platformDir);
|
|
91
|
+
} else if (fs.existsSync(flatBinaryPath)) {
|
|
92
|
+
// 兼容旧版本扁平结构: platforms/fnva
|
|
93
|
+
console.log('ℹ️ Platform-specific binary not found, falling back to legacy flat layout');
|
|
94
|
+
ensureExecutable(flatBinaryPath, 'platforms/fnva');
|
|
86
95
|
} else {
|
|
87
|
-
console.log(`❌ Binary not found: ${
|
|
88
|
-
console.log(`
|
|
96
|
+
console.log(`❌ Binary not found: ${archBinaryPath}`);
|
|
97
|
+
console.log(` Also checked legacy path: ${flatBinaryPath}`);
|
|
98
|
+
console.log(' This might indicate an incomplete installation');
|
|
89
99
|
}
|
|
90
100
|
|
|
91
|
-
//
|
|
101
|
+
// 额外检查:如果是全局安装,也尝试检查路径上的 fnva 权限
|
|
92
102
|
if (process.env.npm_config_global === 'true') {
|
|
93
103
|
try {
|
|
94
104
|
const { execSync } = require('child_process');
|
|
@@ -101,22 +111,21 @@ function ensureExecutablePermissions() {
|
|
|
101
111
|
const globalHasExecPermission = (globalStats.mode & 0o111) !== 0;
|
|
102
112
|
|
|
103
113
|
if (!globalHasExecPermission) {
|
|
104
|
-
console.log(
|
|
114
|
+
console.log('❌ Global fnva binary lacks executable permissions');
|
|
105
115
|
console.log(` Please run: sudo chmod +x "${globalFnvaPath}"`);
|
|
106
116
|
} else {
|
|
107
|
-
console.log(
|
|
117
|
+
console.log('✅ Global fnva binary has correct permissions');
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
|
-
} catch
|
|
111
|
-
|
|
112
|
-
console.log(`ℹ️ Could not verify global installation`);
|
|
120
|
+
} catch {
|
|
121
|
+
console.log('ℹ️ Could not verify global installation');
|
|
113
122
|
}
|
|
114
123
|
}
|
|
115
|
-
|
|
116
124
|
} catch (error) {
|
|
117
125
|
console.warn(`⚠️ Permission check failed: ${error.message}`);
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
// 运行权限检查
|
|
122
|
-
ensureExecutablePermissions();
|
|
130
|
+
ensureExecutablePermissions();
|
|
131
|
+
|