@tikoci/rosetta 0.7.1 → 0.7.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tikoci/rosetta",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "RouterOS documentation as SQLite FTS5 — RAG search + command glossary via MCP",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,4 +21,12 @@ describe("buildChangelogVersionSet", () => {
21
21
  expect(versions.filter((v) => v === "7.2")).toHaveLength(1);
22
22
  expect(versions.filter((v) => v === "7.8")).toHaveLength(1);
23
23
  });
24
+
25
+ test("includes live channel head versions so latest long-term patch is not missed", () => {
26
+ const versions = buildChangelogVersionSet(["7.21.3", "7.22.1"], ["7.21.4", "7.22.1", "7.23rc1"]);
27
+
28
+ expect(versions).toContain("7.21.4");
29
+ expect(versions.filter((v) => v === "7.22.1")).toHaveLength(1);
30
+ expect(versions).toContain("7.23rc1");
31
+ });
24
32
  });
@@ -14,6 +14,7 @@ import { db, initDb } from "./db.ts";
14
14
 
15
15
  const CHANGELOG_BASE = "https://download.mikrotik.com/routeros";
16
16
  const FETCH_DELAY_MS = 200; // polite delay between requests
17
+ const VERSION_CHANNELS = ["stable", "long-term", "testing", "development"] as const;
17
18
 
18
19
  // Oldest RouterOS v7 versions that use the current changelog header/entry format.
19
20
  // Keep these in default extraction even though command tree retention starts later.
@@ -149,18 +150,39 @@ function getKnownVersions(): string[] {
149
150
  return rows.map((r) => r.version);
150
151
  }
151
152
 
152
- export function buildChangelogVersionSet(knownVersions: string[]): string[] {
153
- const all = new Set([...knownVersions, ...LEGACY_FORMATTED_V7_BASE_VERSIONS]);
153
+ export function buildChangelogVersionSet(knownVersions: string[], channelHeadVersions: string[] = []): string[] {
154
+ const all = new Set([...knownVersions, ...channelHeadVersions, ...LEGACY_FORMATTED_V7_BASE_VERSIONS]);
154
155
  return [...all];
155
156
  }
156
157
 
157
- function getDefaultVersions(): string[] {
158
- return buildChangelogVersionSet(getKnownVersions());
158
+ async function fetchCurrentChannelVersions(): Promise<string[]> {
159
+ const versions = new Set<string>();
160
+ for (const channel of VERSION_CHANNELS) {
161
+ try {
162
+ const resp = await fetch(`https://upgrade.mikrotik.com/routeros/NEWESTa7.${channel}`);
163
+ if (!resp.ok) {
164
+ console.warn(` channel ${channel}: HTTP ${resp.status}`);
165
+ continue;
166
+ }
167
+ const version = (await resp.text()).trim();
168
+ if (version) {
169
+ versions.add(version);
170
+ }
171
+ } catch (err) {
172
+ console.warn(` channel ${channel}: fetch error — ${err}`);
173
+ }
174
+ }
175
+ return [...versions];
176
+ }
177
+
178
+ async function getDefaultVersions(): Promise<string[]> {
179
+ const channelHeads = await fetchCurrentChannelVersions();
180
+ return buildChangelogVersionSet(getKnownVersions(), channelHeads);
159
181
  }
160
182
 
161
183
  /** Probe patch versions: for each minor (7.X), try 7.X.1, 7.X.2, ... up to first 404. */
162
184
  async function probePatchVersions(): Promise<string[]> {
163
- const known = new Set(getDefaultVersions());
185
+ const known = new Set(await getDefaultVersions());
164
186
  const patches: string[] = [];
165
187
 
166
188
  // Find all minor versions: extract unique 7.X prefixes
@@ -211,15 +233,15 @@ if (versionsArg) {
211
233
  console.log(`Changelog extraction: ${versions.length} explicit versions`);
212
234
  } else if (probePatches) {
213
235
  console.log("Changelog extraction: probing patch versions...");
214
- const known = getDefaultVersions();
236
+ const known = await getDefaultVersions();
215
237
  const patches = await probePatchVersions();
216
238
  // Merge: known + discovered patches (deduplicated)
217
239
  const all = new Set([...known, ...patches]);
218
240
  versions = [...all];
219
241
  console.log(` ${versions.length} versions (${patches.length} from patch probing)`);
220
242
  } else {
221
- versions = getDefaultVersions();
222
- console.log(`Changelog extraction: ${versions.length} versions from ros_versions + legacy v7 baseline`);
243
+ versions = await getDefaultVersions();
244
+ console.log(`Changelog extraction: ${versions.length} versions from ros_versions + channel heads + legacy v7 baseline`);
223
245
  }
224
246
 
225
247
  if (versions.length === 0) {