@lvnt/release-radar 1.1.6 → 1.2.0
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 +8 -1
- package/dist/index.js +38 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -165,7 +165,14 @@ ReleaseRadar includes an optional auto-updater that receives GitHub webhooks and
|
|
|
165
165
|
pm2 save
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
When you publish a new release, the updater will automatically run `npm update -g @lvnt/release-radar` and restart the main service.
|
|
168
|
+
When you publish a new release, the updater will automatically run `sudo npm update -g @lvnt/release-radar` and restart the main service.
|
|
169
|
+
|
|
170
|
+
**Note:** If you installed npm with sudo, configure passwordless sudo for npm:
|
|
171
|
+
```bash
|
|
172
|
+
sudo visudo
|
|
173
|
+
# Add this line:
|
|
174
|
+
# yourusername ALL=(ALL) NOPASSWD: /usr/bin/npm
|
|
175
|
+
```
|
|
169
176
|
|
|
170
177
|
## Project Structure
|
|
171
178
|
|
package/dist/index.js
CHANGED
|
@@ -23,14 +23,29 @@ const notifier = new Notifier(bot, CHAT_ID);
|
|
|
23
23
|
const checker = new Checker(configData.tools, storage, notifier);
|
|
24
24
|
// Track scheduled task for rescheduling
|
|
25
25
|
let scheduledTask = null;
|
|
26
|
+
let lastCheckTime = null;
|
|
27
|
+
let nextCheckTime = null;
|
|
28
|
+
function calculateNextCheckTime(intervalHours) {
|
|
29
|
+
const now = new Date();
|
|
30
|
+
const next = new Date(now);
|
|
31
|
+
next.setMinutes(0, 0, 0);
|
|
32
|
+
next.setHours(Math.ceil(now.getHours() / intervalHours) * intervalHours);
|
|
33
|
+
if (next <= now) {
|
|
34
|
+
next.setHours(next.getHours() + intervalHours);
|
|
35
|
+
}
|
|
36
|
+
return next;
|
|
37
|
+
}
|
|
26
38
|
function scheduleChecks(intervalHours) {
|
|
27
39
|
if (scheduledTask) {
|
|
28
40
|
scheduledTask.stop();
|
|
29
41
|
}
|
|
42
|
+
nextCheckTime = calculateNextCheckTime(intervalHours);
|
|
30
43
|
const cronExpression = `0 */${intervalHours} * * *`;
|
|
31
44
|
scheduledTask = cron.schedule(cronExpression, async () => {
|
|
32
45
|
console.log(`[${new Date().toISOString()}] Running scheduled check`);
|
|
46
|
+
lastCheckTime = new Date();
|
|
33
47
|
await checker.checkAll();
|
|
48
|
+
nextCheckTime = calculateNextCheckTime(intervalHours);
|
|
34
49
|
});
|
|
35
50
|
console.log(`Scheduled checks every ${intervalHours} hours`);
|
|
36
51
|
}
|
|
@@ -39,7 +54,9 @@ bot.onText(/\/check/, async (msg) => {
|
|
|
39
54
|
if (msg.chat.id.toString() !== CHAT_ID)
|
|
40
55
|
return;
|
|
41
56
|
await bot.sendMessage(CHAT_ID, 'Checking for updates...');
|
|
57
|
+
lastCheckTime = new Date();
|
|
42
58
|
await checker.checkAll();
|
|
59
|
+
nextCheckTime = calculateNextCheckTime(configData.checkIntervalHours);
|
|
43
60
|
await bot.sendMessage(CHAT_ID, 'Check complete.');
|
|
44
61
|
});
|
|
45
62
|
bot.onText(/\/status/, async (msg) => {
|
|
@@ -49,9 +66,29 @@ bot.onText(/\/status/, async (msg) => {
|
|
|
49
66
|
const lines = Object.entries(state.versions)
|
|
50
67
|
.map(([name, version]) => `${name}: ${version}`)
|
|
51
68
|
.sort();
|
|
52
|
-
|
|
69
|
+
let message = lines.length > 0
|
|
53
70
|
? lines.join('\n')
|
|
54
71
|
: 'No versions tracked yet. Run /check first.';
|
|
72
|
+
// Add timing info
|
|
73
|
+
message += '\n\n---';
|
|
74
|
+
if (lastCheckTime) {
|
|
75
|
+
const ago = Math.round((Date.now() - lastCheckTime.getTime()) / 60000);
|
|
76
|
+
message += `\nLast check: ${ago} min ago`;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
message += '\nLast check: not yet';
|
|
80
|
+
}
|
|
81
|
+
if (nextCheckTime) {
|
|
82
|
+
const mins = Math.round((nextCheckTime.getTime() - Date.now()) / 60000);
|
|
83
|
+
if (mins > 0) {
|
|
84
|
+
const hours = Math.floor(mins / 60);
|
|
85
|
+
const remainingMins = mins % 60;
|
|
86
|
+
message += `\nNext check: in ${hours > 0 ? hours + 'h ' : ''}${remainingMins}m`;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
message += '\nNext check: soon';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
55
92
|
await bot.sendMessage(CHAT_ID, message);
|
|
56
93
|
});
|
|
57
94
|
bot.onText(/\/interval$/, async (msg) => {
|