cc-connect 1.2.1 → 1.2.2-beta.2
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.js +32 -1
- package/package.json +1 -1
- package/run.js +31 -1
package/install.js
CHANGED
|
@@ -122,6 +122,30 @@ function extractZip(buffer, destDir, binaryName) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
// parseVersion splits "1.2.3-beta.1" into { nums: [1,2,3], pre: "beta.1" }
|
|
126
|
+
function parseVersion(v) {
|
|
127
|
+
v = v.replace(/^v/, "").trim();
|
|
128
|
+
const [base, ...rest] = v.split("-");
|
|
129
|
+
const nums = base.split(".").map(Number);
|
|
130
|
+
return { nums, pre: rest.join("-") };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// isNewerOrEqual returns true if installed >= expected
|
|
134
|
+
function isNewerOrEqual(installed, expected) {
|
|
135
|
+
const a = parseVersion(installed);
|
|
136
|
+
const b = parseVersion(expected);
|
|
137
|
+
const len = Math.max(a.nums.length, b.nums.length);
|
|
138
|
+
for (let i = 0; i < len; i++) {
|
|
139
|
+
const av = a.nums[i] || 0;
|
|
140
|
+
const bv = b.nums[i] || 0;
|
|
141
|
+
if (av > bv) return true;
|
|
142
|
+
if (av < bv) return false;
|
|
143
|
+
}
|
|
144
|
+
if (!a.pre && b.pre) return true;
|
|
145
|
+
if (a.pre && !b.pre) return false;
|
|
146
|
+
return a.pre >= b.pre;
|
|
147
|
+
}
|
|
148
|
+
|
|
125
149
|
async function main() {
|
|
126
150
|
const { platform, arch, ext, filename } = getPlatformInfo();
|
|
127
151
|
console.log(`[cc-connect] Platform: ${platform}/${arch}`);
|
|
@@ -135,10 +159,17 @@ async function main() {
|
|
|
135
159
|
if (fs.existsSync(binaryPath)) {
|
|
136
160
|
try {
|
|
137
161
|
const out = execSync(`"${binaryPath}" --version`, { encoding: "utf8", timeout: 5000 });
|
|
138
|
-
|
|
162
|
+
const expectedVer = VERSION.slice(1); // remove leading "v"
|
|
163
|
+
if (out.includes(expectedVer)) {
|
|
139
164
|
console.log(`[cc-connect] Binary ${VERSION} already installed, skipping.`);
|
|
140
165
|
return;
|
|
141
166
|
}
|
|
167
|
+
// Don't downgrade: if existing binary is newer, keep it
|
|
168
|
+
const match = out.match(/(\d+\.\d+\.\d+[^\s]*)/);
|
|
169
|
+
if (match && isNewerOrEqual(match[1], expectedVer)) {
|
|
170
|
+
console.log(`[cc-connect] Binary ${match[1]} is newer than ${VERSION}, skipping.`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
142
173
|
console.log(`[cc-connect] Existing binary is outdated, upgrading to ${VERSION}...`);
|
|
143
174
|
fs.unlinkSync(binaryPath);
|
|
144
175
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-connect",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2-beta.2",
|
|
4
4
|
"description": "Bridge local AI coding agents (Claude Code, Cursor, Gemini CLI) to messaging platforms (Feishu, DingTalk, Slack, Telegram, Discord, LINE, WeChat Work)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
package/run.js
CHANGED
|
@@ -13,11 +13,41 @@ const binDir = path.join(__dirname, "bin");
|
|
|
13
13
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
14
14
|
const binaryPath = path.join(binDir, NAME + ext);
|
|
15
15
|
|
|
16
|
+
// parseVersion splits "1.2.3-beta.1" into { nums: [1,2,3], pre: "beta.1" }
|
|
17
|
+
function parseVersion(v) {
|
|
18
|
+
v = v.replace(/^v/, "").trim();
|
|
19
|
+
const [base, ...rest] = v.split("-");
|
|
20
|
+
const nums = base.split(".").map(Number);
|
|
21
|
+
return { nums, pre: rest.join("-") };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// isNewerOrEqual returns true if installed >= expected
|
|
25
|
+
function isNewerOrEqual(installed, expected) {
|
|
26
|
+
const a = parseVersion(installed);
|
|
27
|
+
const b = parseVersion(expected);
|
|
28
|
+
const len = Math.max(a.nums.length, b.nums.length);
|
|
29
|
+
for (let i = 0; i < len; i++) {
|
|
30
|
+
const av = a.nums[i] || 0;
|
|
31
|
+
const bv = b.nums[i] || 0;
|
|
32
|
+
if (av > bv) return true;
|
|
33
|
+
if (av < bv) return false;
|
|
34
|
+
}
|
|
35
|
+
// Same base: no pre-release >= any pre-release (1.2.3 >= 1.2.3-beta.1)
|
|
36
|
+
if (!a.pre && b.pre) return true;
|
|
37
|
+
if (a.pre && !b.pre) return false;
|
|
38
|
+
// Both have pre-release or both don't
|
|
39
|
+
return a.pre >= b.pre;
|
|
40
|
+
}
|
|
41
|
+
|
|
16
42
|
function needsReinstall() {
|
|
17
43
|
if (!fs.existsSync(binaryPath)) return true;
|
|
18
44
|
try {
|
|
19
45
|
const out = execFileSync(binaryPath, ["--version"], { encoding: "utf8", timeout: 5000 });
|
|
20
|
-
|
|
46
|
+
if (out.includes(EXPECTED_VER)) return false;
|
|
47
|
+
// Extract version from output (e.g. "cc-connect 1.2.2-beta.1" or "1.2.2-beta.1")
|
|
48
|
+
const match = out.match(/(\d+\.\d+\.\d+[^\s]*)/);
|
|
49
|
+
if (match && isNewerOrEqual(match[1], EXPECTED_VER)) return false;
|
|
50
|
+
return true;
|
|
21
51
|
} catch {
|
|
22
52
|
return true;
|
|
23
53
|
}
|