Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
6d1725ed53 | |||
028acc0218 | |||
ea2e3f9f7b | |||
8909652860 | |||
38d1d4ae0c | |||
d8a21a0c0a | |||
f2e96640fa | |||
72cd9f1a00 | |||
2e9394c330 | |||
f8241b49fb | |||
7adc7b9fb1 | |||
aabb8265cd | |||
b8befa85fa | |||
114cd1900b | |||
17d8cd6585 | |||
87cdc5bb5f | |||
d03b37690f | |||
35680b135d | |||
3170da0303 | |||
8a78cc6831 | |||
911c680452 | |||
0a3768a088 | |||
7ae31b4ee0 | |||
ac3d9aeb2d | |||
c312622fb1 | |||
89829b84f4 | |||
2b2111b2f1 | |||
9c82b3534f | |||
b6abfd11d2 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{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 @shipzone/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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{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 @shipzone/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 @shipzone/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 @shipzone/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 @shipzone/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
|
137
.gitlab-ci.yml
137
.gitlab-ci.yml
@ -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
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartsitemap",
|
"gitrepo": "smartsitemap",
|
||||||
"shortDescription": "a sitemap module",
|
"description": "a sitemap module",
|
||||||
"npmPackagename": "@pushrocks/smartsitemap",
|
"npmPackagename": "@push.rocks/smartsitemap",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "push.rocks"
|
"projectDomain": "push.rocks"
|
||||||
}
|
}
|
||||||
|
11071
package-lock.json
generated
11071
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@ -1,28 +1,34 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartsitemap",
|
"name": "@push.rocks/smartsitemap",
|
||||||
"version": "1.0.4",
|
"version": "2.0.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a sitemap module",
|
"description": "a sitemap module",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@git.zone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@git.zone/tsrun": "^1.2.44",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@types/node": "^14.11.2",
|
"@push.rocks/smartenv": "^5.0.10",
|
||||||
"tslint": "^6.1.3",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"@types/node": "^20.8.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfeed": "^1.0.5",
|
"@push.rocks/smartcache": "^1.0.16",
|
||||||
"@pushrocks/smartxml": "^1.0.6"
|
"@push.rocks/smartfeed": "^1.0.11",
|
||||||
|
"@push.rocks/smartxml": "^1.0.8",
|
||||||
|
"@push.rocks/smartyaml": "^2.0.5",
|
||||||
|
"@push.rocks/webrequest": "^3.0.33",
|
||||||
|
"@tsclass/tsclass": "^4.0.46"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
|
5719
pnpm-lock.yaml
generated
Normal file
5719
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
readme.md
32
readme.md
@ -1,27 +1,26 @@
|
|||||||
# @pushrocks/smartsitemap
|
# @push.rocks/smartsitemap
|
||||||
a sitemap module
|
undefined variable
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartsitemap)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartsitemap)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartsitemap)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartsitemap)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartsitemap)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartsitemap)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartsitemap/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartsitemap/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
Status Category | Status Badge
|
Status Category | Status Badge
|
||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
5
test/sitemap.yml
Normal file
5
test/sitemap.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
daily:
|
||||||
|
- central.eu/
|
||||||
|
- central.eu/privacy
|
||||||
|
- central.eu/someotherlink
|
17
test/test.ts
17
test/test.ts
@ -1,18 +1,23 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
import * as smartsitemap from '../ts/index';
|
import * as smartsitemap from '../ts/index.js';
|
||||||
|
|
||||||
let testSmartsitemap: smartsitemap.SmartSitemap;
|
let testSmartsitemap: smartsitemap.SmartSitemap;
|
||||||
|
|
||||||
tap.test('should create an instance of Smartsitemap', async () => {
|
tap.test('should create an instance of Smartsitemap', async () => {
|
||||||
testSmartsitemap = new smartsitemap.SmartSitemap();
|
testSmartsitemap = new smartsitemap.SmartSitemap();
|
||||||
expect(testSmartsitemap).to.be.instanceOf(smartsitemap.SmartSitemap);
|
expect(testSmartsitemap).toBeInstanceOf(smartsitemap.SmartSitemap);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a sitemap from feed', async () => {
|
tap.test('should create a sitemap from feed', async () => {
|
||||||
const sitemapNews = testSmartsitemap.createSmartsitemapNews();
|
const sitemapString = await testSmartsitemap.createSitemapNewsFromFeedUrl(
|
||||||
await sitemapNews.readFromRssFeed('https://www.theverge.com/rss/index.xml');
|
'https://central.eu/feed'
|
||||||
const sitemapString = sitemapNews.exportSitemapXml();
|
);
|
||||||
console.log(sitemapString);
|
console.log(sitemapString);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should parse a sitemap', async () => {
|
||||||
|
const result = await testSmartsitemap.parseSitemapUrl('https://www.theverge.com/sitemaps/google_news');
|
||||||
|
// console.log(result.urlset.url);
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartsitemap',
|
||||||
|
version: '2.0.3',
|
||||||
|
description: 'a sitemap module'
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
export * from './smartsitemap.classes.smartsitemap';
|
export * from './smartsitemap.classes.smartsitemap.js';
|
||||||
export * from './smartsitemap.classes.sitemapnews';
|
export * from './smartsitemap.classes.sitemapnews.js';
|
||||||
|
export * from './smartsitemap.classes.sitemapwebsite.js';
|
||||||
|
42
ts/interfaces/index.ts
Normal file
42
ts/interfaces/index.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
export interface ISitemapYaml {
|
||||||
|
daily: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IRssItem {
|
||||||
|
[key: string]: any;
|
||||||
|
link?: string;
|
||||||
|
guid?: string;
|
||||||
|
title?: string;
|
||||||
|
pubDate?: string;
|
||||||
|
creator?: string;
|
||||||
|
content?: string;
|
||||||
|
isoDate?: string;
|
||||||
|
categories?: string[];
|
||||||
|
contentSnippet?: string;
|
||||||
|
enclosure?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IParsedSiteMap {
|
||||||
|
urlset: {
|
||||||
|
url:
|
||||||
|
| {
|
||||||
|
loc: string;
|
||||||
|
lastmod: string;
|
||||||
|
changefreq: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
loc: string;
|
||||||
|
lastmod: string;
|
||||||
|
changefreq: string;
|
||||||
|
}[]
|
||||||
|
| {
|
||||||
|
loc: string;
|
||||||
|
'news:news': {
|
||||||
|
'news:publication': [];
|
||||||
|
'news:keywords': string;
|
||||||
|
'news:publication_date': string;
|
||||||
|
'news:title': string;
|
||||||
|
};
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
}
|
@ -1,14 +1,34 @@
|
|||||||
import * as plugins from './smartsitemap.plugins';
|
import * as plugins from './smartsitemap.plugins.js';
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
export class SitemapNews {
|
export class SitemapNews {
|
||||||
public items: any[] = [];
|
public rssItems: interfaces.IRssItem[] = [];
|
||||||
|
|
||||||
constructor(optionsArg: {}) {}
|
constructor(optionsArg: {}) {}
|
||||||
|
|
||||||
public async readFromRssFeed(urlArg: string) {
|
public async readAndAddFromRssFeedString(feedStringArg: string) {
|
||||||
|
const smartfeedInstance = new plugins.smartfeed.Smartfeed();
|
||||||
|
const parsedFeed = await smartfeedInstance.parseFeedFromString(feedStringArg);
|
||||||
|
this.rssItems = this.rssItems.concat(parsedFeed.items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async readAndAddFromRssFeedUrl(urlArg: string) {
|
||||||
const smartfeedInstance = new plugins.smartfeed.Smartfeed();
|
const smartfeedInstance = new plugins.smartfeed.Smartfeed();
|
||||||
const parsedFeed = await smartfeedInstance.parseFeedFromUrl(urlArg);
|
const parsedFeed = await smartfeedInstance.parseFeedFromUrl(urlArg);
|
||||||
this.items = this.items.concat(parsedFeed.items);
|
this.rssItems = this.rssItems.concat(parsedFeed.items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async readAndParseArticles(articleArrayArg: plugins.tsclass.content.IArticle[]) {
|
||||||
|
const rssItemArray = articleArrayArg.map((articleArg): interfaces.IRssItem => {
|
||||||
|
return {
|
||||||
|
title: articleArg.title,
|
||||||
|
content: articleArg.content,
|
||||||
|
isoDate: new Date(/* TODO: put article timestamp here */).toISOString(),
|
||||||
|
link: articleArg.url,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.rssItems = this.rssItems.concat(rssItemArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public exportSitemapXml() {
|
public exportSitemapXml() {
|
||||||
@ -19,24 +39,25 @@ export class SitemapNews {
|
|||||||
'news:name': string;
|
'news:name': string;
|
||||||
'news:language': string;
|
'news:language': string;
|
||||||
};
|
};
|
||||||
"news:publication_date" : string;
|
'news:publication_date': string;
|
||||||
"news:keywords": string;
|
'news:keywords': string;
|
||||||
"news:title": string;
|
'news:title': string;
|
||||||
};
|
};
|
||||||
}[] = [];
|
}[] = [];
|
||||||
for (const itemArg of this.items) {
|
for (const itemArg of this.rssItems) {
|
||||||
|
console.log(itemArg);
|
||||||
urls.push({
|
urls.push({
|
||||||
loc: itemArg.link,
|
loc: itemArg.link,
|
||||||
"news:news": {
|
'news:news': {
|
||||||
"news:publication": {
|
'news:publication': {
|
||||||
"news:language": 'en',
|
'news:language': 'en',
|
||||||
"news:name": 'some name'
|
'news:name': 'some name',
|
||||||
},
|
},
|
||||||
"news:keywords": '',
|
'news:keywords': '',
|
||||||
"news:publication_date": itemArg.isoDate,
|
'news:publication_date': itemArg.isoDate,
|
||||||
"news:title": itemArg.title
|
'news:title': itemArg.title,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
const sitemapObject: any = {
|
const sitemapObject: any = {
|
||||||
urlset: {
|
urlset: {
|
||||||
|
42
ts/smartsitemap.classes.sitemapwebsite.ts
Normal file
42
ts/smartsitemap.classes.sitemapwebsite.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import * as plugins from './smartsitemap.plugins.js';
|
||||||
|
|
||||||
|
export type TUpdateFrequency = 'never' | 'daily' | 'weekly' | 'monthly' | 'yearly';
|
||||||
|
|
||||||
|
export interface IUrlInfo {
|
||||||
|
url: string;
|
||||||
|
timestamp: number;
|
||||||
|
frequency?: TUpdateFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SitemapWebsite {
|
||||||
|
urlInfos: IUrlInfo[] = [];
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
public addUrl(urlInfoArg: IUrlInfo) {
|
||||||
|
this.urlInfos.push(urlInfoArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public exportSitemapXml() {
|
||||||
|
const urls: {
|
||||||
|
loc: string;
|
||||||
|
lastmod: string;
|
||||||
|
changefreq: TUpdateFrequency;
|
||||||
|
}[] = [];
|
||||||
|
for (const urlInfoArg of this.urlInfos) {
|
||||||
|
urls.push({
|
||||||
|
loc: urlInfoArg.url,
|
||||||
|
lastmod: new Date(urlInfoArg.timestamp).toISOString(),
|
||||||
|
changefreq: urlInfoArg.frequency ? urlInfoArg.frequency : 'weekly',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const sitemapObject: any = {
|
||||||
|
urlset: {
|
||||||
|
'@_xmlns': 'http://www.sitemaps.org/schemas/sitemap/0.9',
|
||||||
|
url: urls,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const smartxmlInstance = new plugins.smartxml.SmartXml();
|
||||||
|
const sitemapString = smartxmlInstance.createXmlFromObject(sitemapObject);
|
||||||
|
return sitemapString;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,87 @@
|
|||||||
import { SitemapNews } from './smartsitemap.classes.sitemapnews';
|
import { SitemapNews } from './smartsitemap.classes.sitemapnews.js';
|
||||||
import * as plugins from './smartsitemap.plugins';
|
import { type IUrlInfo, SitemapWebsite } from './smartsitemap.classes.sitemapwebsite.js';
|
||||||
|
import * as plugins from './smartsitemap.plugins.js';
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
export class SmartSitemap {
|
export class SmartSitemap {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a sitemap for news
|
* creates a sitemap for news from feedurl
|
||||||
*/
|
*/
|
||||||
public createSmartsitemapNews(): SitemapNews {
|
public async createSitemapNewsFromFeedUrl(feedUrlArg: string): Promise<string> {
|
||||||
const sitemapNewsInstance = new SitemapNews({});
|
const sitemapNewsInstance = new SitemapNews({});
|
||||||
return sitemapNewsInstance;
|
await sitemapNewsInstance.readAndAddFromRssFeedUrl(feedUrlArg);
|
||||||
|
return sitemapNewsInstance.exportSitemapXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a sitemap for news from feedxmlstring
|
||||||
|
*/
|
||||||
|
public async createSitemapNewsFromAFeedStringArg(feedStringArg: string): Promise<string> {
|
||||||
|
const sitemapNewsInstance = new SitemapNews({});
|
||||||
|
await sitemapNewsInstance.readAndAddFromRssFeedString(feedStringArg);
|
||||||
|
return sitemapNewsInstance.exportSitemapXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a sitemap for news from an array of articles
|
||||||
|
*/
|
||||||
|
public async createSitemapNewsFromArticleArray(
|
||||||
|
articleArrayArg: plugins.tsclass.content.IArticle[]
|
||||||
|
): Promise<string> {
|
||||||
|
const sitemapNewsInstance = new SitemapNews({});
|
||||||
|
await sitemapNewsInstance.readAndParseArticles(articleArrayArg);
|
||||||
|
return sitemapNewsInstance.exportSitemapXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a normal sitemap from a list of urls
|
||||||
|
*/
|
||||||
|
public async createSitemapFromYmlString(yamlString: string): Promise<string> {
|
||||||
|
const yamlObject: interfaces.ISitemapYaml = await plugins.smartyaml.yamlStringToObject(
|
||||||
|
yamlString
|
||||||
|
);
|
||||||
|
const sitemapWebsite = new SitemapWebsite();
|
||||||
|
for (const urlArg of yamlObject.daily) {
|
||||||
|
sitemapWebsite.addUrl({
|
||||||
|
url: urlArg,
|
||||||
|
timestamp: Date.now() - 10000,
|
||||||
|
frequency: 'daily',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return sitemapWebsite.exportSitemapXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a normal sitemap from a list of urls
|
||||||
|
*/
|
||||||
|
public async createSitemapFromUrlInfoArray(urlInfosArg: IUrlInfo[]) {
|
||||||
|
const sitemapWebsite = new SitemapWebsite();
|
||||||
|
for (const urlInfo of urlInfosArg) {
|
||||||
|
sitemapWebsite.addUrl(urlInfo);
|
||||||
|
}
|
||||||
|
return sitemapWebsite.exportSitemapXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parses a sitemap url
|
||||||
|
*/
|
||||||
|
public async parseSitemapUrl(urlArg: string) {
|
||||||
|
const sitemapXml = await (
|
||||||
|
await new plugins.webrequest.WebRequest().request(urlArg, {
|
||||||
|
method: 'GET',
|
||||||
|
})
|
||||||
|
).text();
|
||||||
|
|
||||||
|
const parsedSitemap = await this.parseSitemap(sitemapXml);
|
||||||
|
return parsedSitemap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parses a sitemap
|
||||||
|
*/
|
||||||
|
public async parseSitemap(sitemapXmlArg: string): Promise<interfaces.IParsedSiteMap> {
|
||||||
|
return new plugins.smartxml.SmartXml().parseXmlToObject(sitemapXmlArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as smartfeed from '@pushrocks/smartfeed';
|
import * as smartcache from '@push.rocks/smartcache';
|
||||||
import * as smartxml from '@pushrocks/smartxml';
|
import * as smartfeed from '@push.rocks/smartfeed';
|
||||||
|
import * as smartxml from '@push.rocks/smartxml';
|
||||||
|
import * as smartyaml from '@push.rocks/smartyaml';
|
||||||
|
import * as webrequest from '@push.rocks/webrequest';
|
||||||
|
|
||||||
export {
|
export { smartcache, smartfeed, smartxml, smartyaml, webrequest };
|
||||||
smartfeed,
|
|
||||||
smartxml
|
// tsclass
|
||||||
};
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
export { tsclass };
|
||||||
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
Reference in New Issue
Block a user