@lvnt/release-radar 1.6.0 → 1.6.1
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/dist/index.js +17 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,15 +3,21 @@ import { config } from 'dotenv';
|
|
|
3
3
|
config();
|
|
4
4
|
import TelegramBot from 'node-telegram-bot-api';
|
|
5
5
|
import cron from 'node-cron';
|
|
6
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
6
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { dirname, join } from 'path';
|
|
7
9
|
import { Storage } from './storage.js';
|
|
8
10
|
import { Notifier } from './notifier.js';
|
|
9
11
|
import { Checker } from './checker.js';
|
|
10
12
|
import { generateVersionsJson } from './versions-generator.js';
|
|
11
13
|
import { CliPublisher } from './cli-publisher.js';
|
|
14
|
+
// Get package directory for resolving config paths
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
const PKG_ROOT = join(__dirname, '..'); // dist/../ = package root
|
|
12
18
|
const BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
|
|
13
19
|
const CHAT_ID = process.env.TELEGRAM_CHAT_ID;
|
|
14
|
-
const CONFIG_PATH = '
|
|
20
|
+
const CONFIG_PATH = join(PKG_ROOT, 'config', 'tools.json');
|
|
15
21
|
if (!BOT_TOKEN || !CHAT_ID) {
|
|
16
22
|
console.error('Missing TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID environment variables');
|
|
17
23
|
process.exit(1);
|
|
@@ -20,7 +26,7 @@ if (!BOT_TOKEN || !CHAT_ID) {
|
|
|
20
26
|
const validatedChatId = CHAT_ID;
|
|
21
27
|
// Load config
|
|
22
28
|
let configData = JSON.parse(readFileSync(CONFIG_PATH, 'utf-8'));
|
|
23
|
-
const DOWNLOADS_PATH = '
|
|
29
|
+
const DOWNLOADS_PATH = join(PKG_ROOT, 'config', 'downloads.json');
|
|
24
30
|
let downloadsConfig = {};
|
|
25
31
|
try {
|
|
26
32
|
downloadsConfig = JSON.parse(readFileSync(DOWNLOADS_PATH, 'utf-8'));
|
|
@@ -28,12 +34,17 @@ try {
|
|
|
28
34
|
catch {
|
|
29
35
|
console.log('No downloads.json found, CLI generation disabled');
|
|
30
36
|
}
|
|
37
|
+
// Data directory - use package root for now, could be made configurable
|
|
38
|
+
const DATA_DIR = join(PKG_ROOT, 'data');
|
|
39
|
+
if (!existsSync(DATA_DIR)) {
|
|
40
|
+
mkdirSync(DATA_DIR, { recursive: true });
|
|
41
|
+
}
|
|
31
42
|
// Initialize components
|
|
32
43
|
const bot = new TelegramBot(BOT_TOKEN, { polling: true });
|
|
33
|
-
const storage = new Storage('
|
|
44
|
+
const storage = new Storage(join(DATA_DIR, 'versions.json'));
|
|
34
45
|
const notifier = new Notifier(bot, validatedChatId);
|
|
35
46
|
const checker = new Checker(configData.tools, storage, notifier);
|
|
36
|
-
const cliPublisher = new CliPublisher(downloadsConfig);
|
|
47
|
+
const cliPublisher = new CliPublisher(downloadsConfig, join(PKG_ROOT, 'cli'));
|
|
37
48
|
// Track scheduled task for rescheduling
|
|
38
49
|
let scheduledTask = null;
|
|
39
50
|
let lastCheckTime = null;
|
|
@@ -157,7 +168,7 @@ bot.onText(/\/generate/, async (msg) => {
|
|
|
157
168
|
}
|
|
158
169
|
const state = storage.load();
|
|
159
170
|
const versionsJson = generateVersionsJson(state.versions, downloadsConfig);
|
|
160
|
-
const outputPath = '
|
|
171
|
+
const outputPath = join(DATA_DIR, 'cli-versions.json');
|
|
161
172
|
writeFileSync(outputPath, JSON.stringify(versionsJson, null, 2));
|
|
162
173
|
await bot.sendMessage(CHAT_ID, `Generated versions.json with ${versionsJson.tools.length} tools.\nPath: ${outputPath}`);
|
|
163
174
|
});
|