Add CLI entry point, RSS content extraction, and image support

Features:
- Add CLI with commands: start, add, remove, list, fetch, status, items
- Auto-detect RSS format when adding feeds
- Auto-run database migrations on startup
- Extract full HTML content from RSS description field (NOS-style feeds)
- Extract image URLs from RSS enclosure tags
- Display images in terminal output with emoji
- Include imageUrl in JSON formatter output

Database:
- Add image_url column to feed_items table
- Update storage layer to persist imageUrl field

Tests:
- Add 10 CLI integration tests
- Add 3 RSS parser tests for image/content extraction
- Add 2 storage tests for imageUrl persistence

Dependencies:
- Add commander for CLI framework

All 144 tests passing
This commit is contained in:
Edo Limburg
2026-05-05 23:05:30 +02:00
parent 78a2b27f6d
commit c79eb6d76d
14 changed files with 825 additions and 4 deletions
+42
View File
@@ -136,6 +136,48 @@ describe('SqlStorage', () => {
expect(recent[0].url).toBe('https://example.com/article'); // unchanged
expect(recent[0].publishedAt).toEqual(new Date('2024-09-06T09:00:00Z')); // unchanged
});
it('saves and retrieves imageUrl', async () => {
const item: FeedItem = {
id: 'image-test',
source: 'https://example.com/feed.xml',
title: 'Article with Image',
url: 'https://example.com/article',
publishedAt: new Date('2024-09-06T09:00:00Z'),
summary: 'Summary',
imageUrl: 'https://example.com/image.jpg',
};
await storage.save([item]);
const recent = await storage.getRecent(1);
expect(recent).toHaveLength(1);
expect(recent[0].imageUrl).toBe('https://example.com/image.jpg');
});
it('updates imageUrl on upsert', async () => {
const item: FeedItem = {
id: 'image-update-test',
source: 'https://example.com/feed.xml',
title: 'Article',
url: 'https://example.com/article',
publishedAt: new Date('2024-09-06T09:00:00Z'),
imageUrl: 'https://example.com/old-image.jpg',
};
await storage.save([item]);
// Update with new image URL
const updatedItem: FeedItem = {
...item,
imageUrl: 'https://example.com/new-image.jpg',
};
await storage.save([updatedItem]);
const recent = await storage.getRecent(1);
expect(recent[0].imageUrl).toBe('https://example.com/new-image.jpg');
});
});
describe('getRecent', () => {
+3
View File
@@ -28,6 +28,7 @@ export class SqlStorage implements IStorage {
published_at: item.publishedAt.toISOString(),
content: item.content ?? null,
summary: item.summary ?? null,
image_url: item.imageUrl ?? null,
created_at: new Date().toISOString(),
}));
@@ -40,6 +41,7 @@ export class SqlStorage implements IStorage {
title: (eb) => eb.ref('excluded.title'),
content: (eb) => eb.ref('excluded.content'),
summary: (eb) => eb.ref('excluded.summary'),
image_url: (eb) => eb.ref('excluded.image_url'),
})
)
.execute();
@@ -96,6 +98,7 @@ export class SqlStorage implements IStorage {
publishedAt: new Date(row.published_at),
content: row.content ?? undefined,
summary: row.summary ?? undefined,
imageUrl: row.image_url ?? undefined,
};
}