forgot to build
This commit is contained in:
53
dist/index.cjs.js
vendored
53
dist/index.cjs.js
vendored
@@ -5,18 +5,19 @@ var parseXml = require('@rgrove/parse-xml');
|
|||||||
class Updater {
|
class Updater {
|
||||||
archiveURL;
|
archiveURL;
|
||||||
feedType;
|
feedType;
|
||||||
constructor(archiveURL = "/", feedType = "rss") {
|
constructor(archiveURL = "/", feedType = "atom") {
|
||||||
this.archiveURL = archiveURL;
|
this.archiveURL = archiveURL;
|
||||||
this.feedType = feedType;
|
this.feedType = feedType;
|
||||||
}
|
}
|
||||||
async getRawArchive() {
|
async getRawArchive() {
|
||||||
const res = await fetch(`${this.archiveURL}.${this.feedType}`, {
|
const res = await fetch(`https://cors.emaker.limited/?url=${this.archiveURL}.${this.feedType}`, {
|
||||||
"mode": "cors"
|
"mode": "cors"
|
||||||
});
|
});
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
getVersionDetails(entry) {
|
// atom feeds
|
||||||
|
atomGetVersionDetails(entry) {
|
||||||
let outEntry = { title: "", date: new Date, link: "", html: "" };
|
let outEntry = { title: "", date: new Date, link: "", html: "" };
|
||||||
entry.children.forEach((elm) => {
|
entry.children.forEach((elm) => {
|
||||||
let element = elm;
|
let element = elm;
|
||||||
@@ -35,7 +36,7 @@ class Updater {
|
|||||||
});
|
});
|
||||||
return outEntry;
|
return outEntry;
|
||||||
}
|
}
|
||||||
async getArchive() {
|
async atomGetArchive() {
|
||||||
const rawArchive = await this.getRawArchive();
|
const rawArchive = await this.getRawArchive();
|
||||||
const releaseNotes = parseXml.parseXml(rawArchive);
|
const releaseNotes = parseXml.parseXml(rawArchive);
|
||||||
const output = [];
|
const output = [];
|
||||||
@@ -44,12 +45,54 @@ class Updater {
|
|||||||
if (elm.type == "element") {
|
if (elm.type == "element") {
|
||||||
const element = elm;
|
const element = elm;
|
||||||
if (element.name == "entry") {
|
if (element.name == "entry") {
|
||||||
output.push(this.getVersionDetails(element));
|
output.push(this.atomGetVersionDetails(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
// rss feeds
|
||||||
|
rssGetVersionDetails(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 == "pubDate") {
|
||||||
|
outEntry.date = element.children[0].text;
|
||||||
|
}
|
||||||
|
else if (element.name == "link") {
|
||||||
|
outEntry.link = element.children[0].text;
|
||||||
|
}
|
||||||
|
else if (element.name == "content") {
|
||||||
|
outEntry.html = element.children[0].text;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return outEntry;
|
||||||
|
}
|
||||||
|
async rssGetArchive() {
|
||||||
|
const rawArchive = await this.getRawArchive();
|
||||||
|
const releaseNotes = parseXml.parseXml(rawArchive);
|
||||||
|
const output = [];
|
||||||
|
releaseNotes.children[0].children[1].children.forEach((elm) => {
|
||||||
|
if (elm.type == "element") {
|
||||||
|
const element = elm;
|
||||||
|
if (element.name == "item") {
|
||||||
|
output.push(this.atomGetVersionDetails(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
async getArchive() {
|
||||||
|
if (this.feedType == "atom") {
|
||||||
|
return this.atomGetArchive();
|
||||||
|
}
|
||||||
|
else if (this.feedType == "rss") {
|
||||||
|
return this.rssGetArchive();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Updater;
|
module.exports = Updater;
|
||||||
|
|||||||
5
dist/index.d.ts
vendored
5
dist/index.d.ts
vendored
@@ -4,6 +4,9 @@ export default class Updater {
|
|||||||
feedType: string;
|
feedType: string;
|
||||||
constructor(archiveURL?: string, feedType?: string);
|
constructor(archiveURL?: string, feedType?: string);
|
||||||
private getRawArchive;
|
private getRawArchive;
|
||||||
private getVersionDetails;
|
private atomGetVersionDetails;
|
||||||
|
private atomGetArchive;
|
||||||
|
private rssGetVersionDetails;
|
||||||
|
private rssGetArchive;
|
||||||
getArchive(): Promise<types.versionNotes[]>;
|
getArchive(): Promise<types.versionNotes[]>;
|
||||||
}
|
}
|
||||||
|
|||||||
53
dist/index.es.js
vendored
53
dist/index.es.js
vendored
@@ -3,18 +3,19 @@ import { parseXml } from '@rgrove/parse-xml';
|
|||||||
class Updater {
|
class Updater {
|
||||||
archiveURL;
|
archiveURL;
|
||||||
feedType;
|
feedType;
|
||||||
constructor(archiveURL = "/", feedType = "rss") {
|
constructor(archiveURL = "/", feedType = "atom") {
|
||||||
this.archiveURL = archiveURL;
|
this.archiveURL = archiveURL;
|
||||||
this.feedType = feedType;
|
this.feedType = feedType;
|
||||||
}
|
}
|
||||||
async getRawArchive() {
|
async getRawArchive() {
|
||||||
const res = await fetch(`${this.archiveURL}.${this.feedType}`, {
|
const res = await fetch(`https://cors.emaker.limited/?url=${this.archiveURL}.${this.feedType}`, {
|
||||||
"mode": "cors"
|
"mode": "cors"
|
||||||
});
|
});
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
getVersionDetails(entry) {
|
// atom feeds
|
||||||
|
atomGetVersionDetails(entry) {
|
||||||
let outEntry = { title: "", date: new Date, link: "", html: "" };
|
let outEntry = { title: "", date: new Date, link: "", html: "" };
|
||||||
entry.children.forEach((elm) => {
|
entry.children.forEach((elm) => {
|
||||||
let element = elm;
|
let element = elm;
|
||||||
@@ -33,7 +34,7 @@ class Updater {
|
|||||||
});
|
});
|
||||||
return outEntry;
|
return outEntry;
|
||||||
}
|
}
|
||||||
async getArchive() {
|
async atomGetArchive() {
|
||||||
const rawArchive = await this.getRawArchive();
|
const rawArchive = await this.getRawArchive();
|
||||||
const releaseNotes = parseXml(rawArchive);
|
const releaseNotes = parseXml(rawArchive);
|
||||||
const output = [];
|
const output = [];
|
||||||
@@ -42,12 +43,54 @@ class Updater {
|
|||||||
if (elm.type == "element") {
|
if (elm.type == "element") {
|
||||||
const element = elm;
|
const element = elm;
|
||||||
if (element.name == "entry") {
|
if (element.name == "entry") {
|
||||||
output.push(this.getVersionDetails(element));
|
output.push(this.atomGetVersionDetails(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
// rss feeds
|
||||||
|
rssGetVersionDetails(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 == "pubDate") {
|
||||||
|
outEntry.date = element.children[0].text;
|
||||||
|
}
|
||||||
|
else if (element.name == "link") {
|
||||||
|
outEntry.link = element.children[0].text;
|
||||||
|
}
|
||||||
|
else if (element.name == "content") {
|
||||||
|
outEntry.html = element.children[0].text;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return outEntry;
|
||||||
|
}
|
||||||
|
async rssGetArchive() {
|
||||||
|
const rawArchive = await this.getRawArchive();
|
||||||
|
const releaseNotes = parseXml(rawArchive);
|
||||||
|
const output = [];
|
||||||
|
releaseNotes.children[0].children[1].children.forEach((elm) => {
|
||||||
|
if (elm.type == "element") {
|
||||||
|
const element = elm;
|
||||||
|
if (element.name == "item") {
|
||||||
|
output.push(this.atomGetVersionDetails(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
async getArchive() {
|
||||||
|
if (this.feedType == "atom") {
|
||||||
|
return this.atomGetArchive();
|
||||||
|
}
|
||||||
|
else if (this.feedType == "rss") {
|
||||||
|
return this.rssGetArchive();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Updater as default };
|
export { Updater as default };
|
||||||
|
|||||||
2
dist/types.d.ts
vendored
2
dist/types.d.ts
vendored
@@ -1,6 +1,6 @@
|
|||||||
export type versionNotes = {
|
export type versionNotes = {
|
||||||
title: string;
|
title: string;
|
||||||
date: Date;
|
date: Date | string;
|
||||||
link: string;
|
link: string;
|
||||||
html: string;
|
html: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user