@zyzheal/ola-cc 0.3.12 → 0.3.16
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/install.cjs +61 -4
- package/package.json +9 -9
package/install.cjs
CHANGED
|
@@ -25,7 +25,11 @@ const PLATFORM_MAP = {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const pkgRoot = __dirname
|
|
28
|
-
|
|
28
|
+
// npm installs optionalDependencies inside the package's node_modules directory
|
|
29
|
+
// when using global install or certain package managers (pnpm, yarn).
|
|
30
|
+
// Check both locations to support all installation modes.
|
|
31
|
+
const nodeModulesNested = join(pkgRoot, 'node_modules') // npm global / pnpm / yarn
|
|
32
|
+
const nodeModulesTopLevel = join(pkgRoot, '..', '..') // npm local (legacy behavior)
|
|
29
33
|
const binDir = join(pkgRoot, 'bin')
|
|
30
34
|
|
|
31
35
|
function detectPlatform() {
|
|
@@ -33,6 +37,8 @@ function detectPlatform() {
|
|
|
33
37
|
const arch = process.arch
|
|
34
38
|
|
|
35
39
|
let isMusl = false
|
|
40
|
+
let isRedHatCompatible = false
|
|
41
|
+
|
|
36
42
|
if (platform === 'linux') {
|
|
37
43
|
try {
|
|
38
44
|
const report = typeof process.report?.getReport === 'function'
|
|
@@ -42,11 +48,48 @@ function detectPlatform() {
|
|
|
42
48
|
} catch {
|
|
43
49
|
try {
|
|
44
50
|
const ldd = require('child_process').execSync('ldd --version 2>&1', { encoding: 'utf8' })
|
|
45
|
-
|
|
51
|
+
const lddLower = ldd.toLowerCase()
|
|
52
|
+
isMusl = lddLower.includes('musl')
|
|
53
|
+
// 检测 glibc 版本 - RHEL/Rocky/AlmaLinux 8+ 使用 glibc 2.28
|
|
54
|
+
// CentOS 7 使用 glibc 2.17
|
|
55
|
+
const glibcMatch = ldd.match(/glibc(?:64)?\s+(\d+)\.(\d+)/)
|
|
56
|
+
if (glibcMatch) {
|
|
57
|
+
const major = parseInt(glibcMatch[1], 10)
|
|
58
|
+
const minor = parseInt(glibcMatch[2], 10)
|
|
59
|
+
// glibc 2.28+ (RHEL 8+, Rocky 8+, AlmaLinux 8+)
|
|
60
|
+
isRedHatCompatible = major > 2 || (major === 2 && minor >= 28)
|
|
61
|
+
}
|
|
46
62
|
} catch {
|
|
47
63
|
// Assume glibc if we can't determine
|
|
48
64
|
}
|
|
49
65
|
}
|
|
66
|
+
|
|
67
|
+
// 尝试读取 /etc/os-release 获取更精确的发行版信息
|
|
68
|
+
try {
|
|
69
|
+
const osRelease = require('fs').readFileSync('/etc/os-release', 'utf8')
|
|
70
|
+
const idMatch = osRelease.match(/^ID="?([^"\n]+)"?/m)
|
|
71
|
+
if (idMatch) {
|
|
72
|
+
const id = idMatch[1].toLowerCase()
|
|
73
|
+
// Rocky Linux, AlmaLinux, RHEL, CentOS Stream 都使用 glibc 2.28+ (version 8+)
|
|
74
|
+
if (id === 'rocky' || id === 'alma' || id === 'rhel' || id === 'centos') {
|
|
75
|
+
const versionMatch = osRelease.match(/^VERSION_ID="?(\d+)"?/m)
|
|
76
|
+
if (versionMatch) {
|
|
77
|
+
const majorVersion = parseInt(versionMatch[1], 10)
|
|
78
|
+
if (majorVersion >= 8) {
|
|
79
|
+
isRedHatCompatible = true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// 无法读取 os-release
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 对于 Red Hat 兼容系统 (Rock8, Alma8, RHEL 8+) 使用标准 glibc 版本
|
|
90
|
+
// 而不是 musl 版本
|
|
91
|
+
if (platform === 'linux' && isRedHatCompatible && !isMusl) {
|
|
92
|
+
return `${platform}-${arch}`
|
|
50
93
|
}
|
|
51
94
|
|
|
52
95
|
return platform === 'linux'
|
|
@@ -54,6 +97,20 @@ function detectPlatform() {
|
|
|
54
97
|
: `${platform}-${arch}`
|
|
55
98
|
}
|
|
56
99
|
|
|
100
|
+
function findPlatformPackage(depName) {
|
|
101
|
+
// Try nested location first (npm global, pnpm, yarn)
|
|
102
|
+
const nestedPath = join(nodeModulesNested, depName)
|
|
103
|
+
if (existsSync(nestedPath)) {
|
|
104
|
+
return nestedPath
|
|
105
|
+
}
|
|
106
|
+
// Try top-level location (npm local install legacy behavior)
|
|
107
|
+
const topLevelPath = join(nodeModulesTopLevel, depName)
|
|
108
|
+
if (existsSync(topLevelPath)) {
|
|
109
|
+
return topLevelPath
|
|
110
|
+
}
|
|
111
|
+
return null
|
|
112
|
+
}
|
|
113
|
+
|
|
57
114
|
function main() {
|
|
58
115
|
const platformKey = detectPlatform()
|
|
59
116
|
const depName = PLATFORM_MAP[platformKey]
|
|
@@ -63,9 +120,9 @@ function main() {
|
|
|
63
120
|
return
|
|
64
121
|
}
|
|
65
122
|
|
|
66
|
-
const depPath =
|
|
123
|
+
const depPath = findPlatformPackage(depName)
|
|
67
124
|
|
|
68
|
-
if (!
|
|
125
|
+
if (!depPath) {
|
|
69
126
|
console.warn(`ola-cc: Platform package ${depName} not installed.`)
|
|
70
127
|
return
|
|
71
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyzheal/ola-cc",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.16",
|
|
4
4
|
"description": "Ola CC - AI coding assistant in your terminal",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@zyzheal/ola-cc-darwin-arm64": "0.3.
|
|
24
|
-
"@zyzheal/ola-cc-darwin-x64": "0.3.
|
|
25
|
-
"@zyzheal/ola-cc-linux-x64": "0.3.
|
|
26
|
-
"@zyzheal/ola-cc-linux-arm64": "0.3.
|
|
27
|
-
"@zyzheal/ola-cc-linux-x64-musl": "0.3.
|
|
28
|
-
"@zyzheal/ola-cc-linux-arm64-musl": "0.3.
|
|
29
|
-
"@zyzheal/ola-cc-win32-x64": "0.3.
|
|
30
|
-
"@zyzheal/ola-cc-win32-arm64": "0.3.
|
|
23
|
+
"@zyzheal/ola-cc-darwin-arm64": "0.3.16",
|
|
24
|
+
"@zyzheal/ola-cc-darwin-x64": "0.3.16",
|
|
25
|
+
"@zyzheal/ola-cc-linux-x64": "0.3.16",
|
|
26
|
+
"@zyzheal/ola-cc-linux-arm64": "0.3.16",
|
|
27
|
+
"@zyzheal/ola-cc-linux-x64-musl": "0.3.16",
|
|
28
|
+
"@zyzheal/ola-cc-linux-arm64-musl": "0.3.16",
|
|
29
|
+
"@zyzheal/ola-cc-win32-x64": "0.3.16",
|
|
30
|
+
"@zyzheal/ola-cc-win32-arm64": "0.3.16"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"bin/ola-cc.js",
|