functional initial version
This commit is contained in:
41
dist/index.cjs.js
vendored
41
dist/index.cjs.js
vendored
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var parseXml = require('@rgrove/parse-xml');
|
||||
|
||||
class Updater {
|
||||
archiveURL;
|
||||
feedType;
|
||||
@@ -7,11 +9,46 @@ class Updater {
|
||||
this.archiveURL = archiveURL;
|
||||
this.feedType = feedType;
|
||||
}
|
||||
async getArchive() {
|
||||
async getRawArchive() {
|
||||
const res = await fetch(`${this.archiveURL}.${this.feedType}`, {
|
||||
"mode": "cors"
|
||||
});
|
||||
return res;
|
||||
const text = await res.text();
|
||||
return text;
|
||||
}
|
||||
getVersionDetails(entry) {
|
||||
let outEntry = { title: "", date: new Date, link: "", html: "" };
|
||||
entry.children.forEach((elm) => {
|
||||
let element = elm;
|
||||
if (element.name == "title") {
|
||||
outEntry.title = element.children[0].text;
|
||||
}
|
||||
else if (element.name == "date") {
|
||||
outEntry.date = new Date(element.children[0].text);
|
||||
}
|
||||
else if (element.name == "link") {
|
||||
outEntry.link = element.attributes["href"];
|
||||
}
|
||||
else if (element.name == "content") {
|
||||
outEntry.html = element.children[0].text;
|
||||
}
|
||||
});
|
||||
return outEntry;
|
||||
}
|
||||
async getArchive() {
|
||||
const rawArchive = await this.getRawArchive();
|
||||
const releaseNotes = parseXml.parseXml(rawArchive);
|
||||
const output = [];
|
||||
// console.dir(releaseNotes)
|
||||
releaseNotes.children[0].children.forEach((elm) => {
|
||||
if (elm.type == "element") {
|
||||
const element = elm;
|
||||
if (element.name == "entry") {
|
||||
output.push(this.getVersionDetails(element));
|
||||
}
|
||||
}
|
||||
});
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
5
dist/index.d.ts
vendored
5
dist/index.d.ts
vendored
@@ -1,6 +1,9 @@
|
||||
import * as types from "@/types";
|
||||
export default class Updater {
|
||||
archiveURL: string;
|
||||
feedType: string;
|
||||
constructor(archiveURL?: string, feedType?: string);
|
||||
getArchive(): Promise<Response>;
|
||||
private getRawArchive;
|
||||
private getVersionDetails;
|
||||
getArchive(): Promise<types.versionNotes[]>;
|
||||
}
|
||||
|
||||
41
dist/index.es.js
vendored
41
dist/index.es.js
vendored
@@ -1,3 +1,5 @@
|
||||
import { parseXml } from '@rgrove/parse-xml';
|
||||
|
||||
class Updater {
|
||||
archiveURL;
|
||||
feedType;
|
||||
@@ -5,11 +7,46 @@ class Updater {
|
||||
this.archiveURL = archiveURL;
|
||||
this.feedType = feedType;
|
||||
}
|
||||
async getArchive() {
|
||||
async getRawArchive() {
|
||||
const res = await fetch(`${this.archiveURL}.${this.feedType}`, {
|
||||
"mode": "cors"
|
||||
});
|
||||
return res;
|
||||
const text = await res.text();
|
||||
return text;
|
||||
}
|
||||
getVersionDetails(entry) {
|
||||
let outEntry = { title: "", date: new Date, link: "", html: "" };
|
||||
entry.children.forEach((elm) => {
|
||||
let element = elm;
|
||||
if (element.name == "title") {
|
||||
outEntry.title = element.children[0].text;
|
||||
}
|
||||
else if (element.name == "date") {
|
||||
outEntry.date = new Date(element.children[0].text);
|
||||
}
|
||||
else if (element.name == "link") {
|
||||
outEntry.link = element.attributes["href"];
|
||||
}
|
||||
else if (element.name == "content") {
|
||||
outEntry.html = element.children[0].text;
|
||||
}
|
||||
});
|
||||
return outEntry;
|
||||
}
|
||||
async getArchive() {
|
||||
const rawArchive = await this.getRawArchive();
|
||||
const releaseNotes = parseXml(rawArchive);
|
||||
const output = [];
|
||||
// console.dir(releaseNotes)
|
||||
releaseNotes.children[0].children.forEach((elm) => {
|
||||
if (elm.type == "element") {
|
||||
const element = elm;
|
||||
if (element.name == "entry") {
|
||||
output.push(this.getVersionDetails(element));
|
||||
}
|
||||
}
|
||||
});
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
dist/types.d.ts
vendored
Normal file
6
dist/types.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export type versionNotes = {
|
||||
title: string;
|
||||
date: Date;
|
||||
link: string;
|
||||
html: string;
|
||||
};
|
||||
Reference in New Issue
Block a user