move all script into the same file

This commit is contained in:
2025-10-30 23:02:03 +00:00
parent 2a942d8fc9
commit eac14571e2
5 changed files with 23 additions and 25 deletions

View File

@@ -1,6 +1,12 @@
import * as types from "@/types";
import { parseXml, XmlDocument, XmlElement, XmlText } from "@rgrove/parse-xml";
export type versionNotes = {
title: string;
date: Date | string;
link: string;
html: string;
}
export default class Updater {
public archiveURL: string;
public feedType: string;
@@ -18,8 +24,8 @@ export default class Updater {
}
// atom feeds
private atomGetVersionDetails(entry: XmlElement): types.versionNotes {
let outEntry: types.versionNotes = {title: "", date: new Date, link: "", html: ""};
private atomGetVersionDetails(entry: XmlElement): versionNotes {
let outEntry: versionNotes = {title: "", date: new Date, link: "", html: ""};
entry.children.forEach((elm) => {
let element = elm as XmlElement;
if (element.name == "title") {
@@ -38,11 +44,11 @@ export default class Updater {
return outEntry;
}
private async atomGetArchive(): Promise<types.versionNotes[]> {
private async atomGetArchive(): Promise<versionNotes[]> {
const rawArchive: string = await this.getRawArchive();
const releaseNotes: XmlDocument = parseXml(rawArchive);
const output: types.versionNotes[] = [];
const output: versionNotes[] = [];
// console.dir(releaseNotes)
(releaseNotes.children[0] as XmlElement).children.forEach((elm) => {
if (elm.type == "element") {
@@ -56,8 +62,8 @@ export default class Updater {
}
// rss feeds
private rssGetVersionDetails(entry: XmlElement): types.versionNotes {
let outEntry: types.versionNotes = {title: "", date: new Date, link: "", html: ""};
private rssGetVersionDetails(entry: XmlElement): versionNotes {
let outEntry: versionNotes = {title: "", date: new Date, link: "", html: ""};
entry.children.forEach((elm) => {
let element = elm as XmlElement;
if (element.name == "title") {
@@ -76,11 +82,11 @@ export default class Updater {
return outEntry;
}
private async rssGetArchive(): Promise<types.versionNotes[]> {
private async rssGetArchive(): Promise<versionNotes[]> {
const rawArchive: string = await this.getRawArchive();
const releaseNotes: XmlDocument = parseXml(rawArchive);
const output: types.versionNotes[] = [];
const output: versionNotes[] = [];
((releaseNotes.children[0] as XmlElement).children[1] as XmlElement).children.forEach((elm) => {
if (elm.type == "element") {
const element = elm as XmlElement;
@@ -92,7 +98,7 @@ export default class Updater {
return output;
}
public async getArchive(): Promise<types.versionNotes[]> {
public async getArchive(): Promise<versionNotes[]> {
if (this.feedType == "atom") {
return this.atomGetArchive()
} else if (this.feedType == "rss"){

View File

@@ -1,6 +0,0 @@
export type versionNotes = {
title: string;
date: Date | string;
link: string;
html: string;
}