chore: update README for clarity and formatting improvements

fix: update test imports to use new package path

refactor: improve feed class structure and formatting

refactor: enhance smartfeed class for better readability

chore: streamline plugin exports for consistency

chore: update TypeScript configuration for improved compatibility

ci: add workflows for handling tag and non-tag pushes
This commit is contained in:
2025-10-31 17:07:13 +00:00
parent 29b1420b1a
commit 622b74e628
15 changed files with 8140 additions and 17157 deletions

View File

@@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

7
.gitignore vendored
View File

@@ -3,7 +3,6 @@
# artifacts
coverage/
public/
pages/
# installs
node_modules/
@@ -17,4 +16,8 @@ node_modules/
dist/
dist_*/
# custom
# AI
.claude/
.serena/
#------# custom

View File

@@ -1,137 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

24
.vscode/launch.json vendored
View File

@@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

11040
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,21 +8,19 @@
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
"test": "(tstest test/ --verbose)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/smartfile": "^8.0.8",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.12",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
"@git.zone/tsbuild": "^2.6.8",
"@git.zone/tsbundle": "^2.5.1",
"@git.zone/tstest": "^2.7.0",
"@pushrocks/smartfile": "^10.0.26",
"@types/node": "^24.9.2"
},
"dependencies": {
"@tsclass/tsclass": "^3.0.29",
"@tsclass/tsclass": "^9.3.0",
"feed": "^4.2.1",
"rss-parser": "^3.10.0"
},
@@ -54,9 +52,17 @@
"XML feeds",
"JSON feeds"
],
"homepage": "https://code.foss.global/push.rocks/smartfeed",
"homepage": "https://code.foss.global/push.rocks/smartfeed#readme",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartfeed.git"
},
"packageManager": "pnpm@10.18.1+sha512.77a884a165cbba2d8d1c19e3b4880eee6d2fcabd0d879121e282196b80042351d5eb3ca0935fa599da1dc51265cc68816ad2bddd2a2de5ea9fdf92adbec7cd34",
"bugs": {
"url": "https://code.foss.global/push.rocks/smartfeed/issues"
},
"type": "module",
"pnpm": {
"overrides": {}
}
}

13790
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,9 @@
# @push.rocks/smartfeed
create and parse feeds
## Install
To install `@push.rocks/smartfeed`, you need to have Node.js installed on your machine. After setting up Node.js, run the following command in your terminal:
```bash
@@ -9,9 +11,11 @@ npm install @push.rocks/smartfeed --save
```
## Usage
`@push.rocks/smartfeed` is a powerful library for creating and parsing RSS and Atom feeds with ease. It leverages TypeScript for type safety and improved developer experience. Let's explore how you can utilize this library in your projects.
### Creating Feeds
You can create feeds by instantiating a `Smartfeed` object and configuring feed options and items. Heres an example of how to create an RSS feed:
```typescript
@@ -41,7 +45,8 @@ const feedItem: IFeedItem = {
url: 'https://example.com/news/typescript-adoption',
authorName: 'Jane Doe',
imageUrl: 'https://example.com/images/typescript-news.jpg',
content: 'In a recent survey, TypeScript has seen a significant increase in adoption among developers...',
content:
'In a recent survey, TypeScript has seen a significant increase in adoption among developers...',
};
// Add the item to the feed
@@ -51,9 +56,11 @@ myFeed.addItem(feedItem);
const rssFeedString = myFeed.exportRssFeedString();
console.log(rssFeedString);
```
This code snippet creates an RSS feed for a news article. You can customize the `IFeedOptions` and `IFeedItem` objects to match your content.
### Parsing Feeds
`@push.rocks/smartfeed` also allows parsing of RSS and Atom feeds from a string or URL. Heres how you can parse a feed:
```typescript
@@ -64,13 +71,13 @@ const mySmartfeed = new Smartfeed();
// Parsing a feed from a string
const rssString = `your RSS feed string here`;
mySmartfeed.parseFeedFromString(rssString).then(feed => {
mySmartfeed.parseFeedFromString(rssString).then((feed) => {
console.log(feed);
});
// Parsing a feed from a URL
const feedUrl = 'https://example.com/rss';
mySmartfeed.parseFeedFromUrl(feedUrl).then(feed => {
mySmartfeed.parseFeedFromUrl(feedUrl).then((feed) => {
console.log(feed);
});
```
@@ -78,6 +85,7 @@ mySmartfeed.parseFeedFromUrl(feedUrl).then(feed => {
This example demonstrates how to parse an RSS feed from a given string or URL. The `parseFeedFromString` and `parseFeedFromUrl` methods return a Promise that resolves to the parsed feed object.
### Comprehensive Feed Management
With `@push.rocks/smartfeed`, you have full control over creating and managing feeds. Beyond basic scenarios shown above, you can create feeds from arrays of articles, customize feed and item properties extensively, and export feeds in different formats (RSS, Atom, JSON).
For instance, to create a feed from an array of article objects conforming to `@tsclass/tsclass`'s `IArticle` interface, you can use the `createFeedFromArticleArray` method. Additionally, explore different export options available on the `Feed` class to suit your needs, whether it's RSS 2.0, Atom 1.0, or JSON Feed 1.0.

View File

@@ -1,4 +1,4 @@
import { expect, tap } from '@pushrocks/tapbundle';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartfeed from '../ts/index';
let testSmartFeed: smartfeed.Smartfeed;
@@ -24,7 +24,7 @@ tap.test('should create a feed', async () => {
imageUrl: 'https://central.eu/someimage.png',
timestamp: Date.now(),
url: 'https://central.eu/article/somearticle',
content: 'somecontent'
content: 'somecontent',
});
const rssFeed = feed.exportRssFeedString();
console.log(rssFeed);
@@ -33,7 +33,9 @@ tap.test('should create a feed', async () => {
});
tap.test('should parse a Url', async () => {
const result = await testSmartFeed.parseFeedFromUrl('https://www.theverge.com/rss/index.xml');
const result = await testSmartFeed.parseFeedFromUrl(
'https://www.theverge.com/rss/index.xml',
);
// console.log(result);
});

View File

@@ -39,11 +39,11 @@ export class Feed {
author: {
name: this.options.company,
email: this.options.companyEmail,
link: this.options.companyEmail
link: this.options.companyEmail,
},
description: this.options.description,
generator: '@pushrocks/smartfeed',
language: "en"
language: 'en',
});
feed.addCategory(this.options.category);
@@ -54,9 +54,11 @@ export class Feed {
link: itemArg.url.replace(/&/gm, '&'),
image: itemArg.imageUrl.replace(/&/gm, '&'),
content: itemArg.content,
author: [{
name: itemArg.authorName
}]
author: [
{
name: itemArg.authorName,
},
],
});
}
return feed;

View File

@@ -10,7 +10,10 @@ export class Smartfeed {
/**
* creates a feed from a standardized article object (@tsclass/tsclass).content.IArticle
*/
public async createFeedFromArticleArray(optionsArg: IFeedOptions, articleArray: plugins.tsclass.content.IArticle[]): Promise<string> {
public async createFeedFromArticleArray(
optionsArg: IFeedOptions,
articleArray: plugins.tsclass.content.IArticle[],
): Promise<string> {
const feed = this.createFeed(optionsArg);
for (const article of articleArray) {
feed.addItem({
@@ -19,7 +22,7 @@ export class Smartfeed {
imageUrl: article.featuredImageUrl,
title: article.title,
url: article.url,
content: article.content
content: article.content,
});
}
const feedXmlString = feed.exportAtomFeed();

View File

@@ -1,15 +1,10 @@
// tsclass scope
import * as tsclass from '@tsclass/tsclass';
export {
tsclass
};
export { tsclass };
// third party scope
import rssParser from 'rss-parser';
import * as feed from 'feed';
export {
rssParser,
feed
};
export { rssParser, feed };

View File

@@ -1,14 +1,15 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {}
},
"exclude": [
"dist_*/**/*.d.ts"
]
"exclude": ["dist_*/**/*.d.ts"]
}