@chrysb/alphaclaw 0.3.2-beta.0 → 0.3.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.
|
@@ -10,6 +10,20 @@ const {
|
|
|
10
10
|
kRootDir,
|
|
11
11
|
} = require("./constants");
|
|
12
12
|
|
|
13
|
+
const isNewerVersion = (latest, current) => {
|
|
14
|
+
if (!latest || !current) return false;
|
|
15
|
+
const parse = (v) => {
|
|
16
|
+
const [core] = String(v).replace(/^v/, "").split("-");
|
|
17
|
+
const parts = core.split(".").map(Number);
|
|
18
|
+
return { major: parts[0] || 0, minor: parts[1] || 0, patch: parts[2] || 0 };
|
|
19
|
+
};
|
|
20
|
+
const l = parse(latest);
|
|
21
|
+
const c = parse(current);
|
|
22
|
+
if (l.major !== c.major) return l.major > c.major;
|
|
23
|
+
if (l.minor !== c.minor) return l.minor > c.minor;
|
|
24
|
+
return l.patch > c.patch;
|
|
25
|
+
};
|
|
26
|
+
|
|
13
27
|
const createAlphaclawVersionService = () => {
|
|
14
28
|
let kUpdateStatusCache = {
|
|
15
29
|
latestVersion: null,
|
|
@@ -82,11 +96,7 @@ const createAlphaclawVersionService = () => {
|
|
|
82
96
|
}
|
|
83
97
|
const currentVersion = readAlphaclawVersion();
|
|
84
98
|
const latestVersion = await fetchLatestVersionFromRegistry();
|
|
85
|
-
const hasUpdate =
|
|
86
|
-
currentVersion &&
|
|
87
|
-
latestVersion &&
|
|
88
|
-
latestVersion !== currentVersion
|
|
89
|
-
);
|
|
99
|
+
const hasUpdate = isNewerVersion(latestVersion, currentVersion);
|
|
90
100
|
kUpdateStatusCache = { latestVersion, hasUpdate, fetchedAt: Date.now() };
|
|
91
101
|
if (hasUpdate) {
|
|
92
102
|
console.log(
|
|
@@ -33,7 +33,8 @@ const getPairedIds = (channel) => {
|
|
|
33
33
|
return Array.from(ids);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
const formatDiscordMessage = (message) =>
|
|
36
|
+
const formatDiscordMessage = (message) =>
|
|
37
|
+
String(message || "").replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "**$1**");
|
|
37
38
|
|
|
38
39
|
const createWatchdogNotifier = ({ telegramApi, discordApi }) => {
|
|
39
40
|
const notify = async (message) => {
|