Skip to content

Commit

Permalink
feat: show release notes when update is available
Browse files Browse the repository at this point in the history
  • Loading branch information
agrmohit committed Mar 1, 2024
1 parent 7d65266 commit ac28d38
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ async function checkForUpdates() {
Deno.exit(1);
}
const tags = await response.json();
const latestTag = tags[0].name;

if (tags[0].name !== currentVersion) {
if (latestTag !== currentVersion) {
console.log("ℹ New update available");
console.log(`ℹ ${currentVersion} --> ${tags[0].name}`);
console.log(`ℹ View release notes: https://github.com/agrmohit/omnivore-epub/releases`);
console.log(`ℹ ${currentVersion} --> ${latestTag}`);
console.log("ℹ Release Notes:");

const response = await fetch(`https://api.github.com/repos/agrmohit/omnivore-epub/releases/tags/${latestTag}`);
const releasenotes = await response.json();

console.log(releasenotes.body);
console.log(`\n🌐 View on Web: https://github.com/agrmohit/omnivore-epub/releases/tag/${latestTag}`);
}
}

Expand Down Expand Up @@ -143,24 +150,24 @@ async function getArticle(slug: string) {
};
}

async function makeMagazine() {
console.log("〰️ getting article list");
async function makeEbook() {
console.log("〰️Fetching article list");
const articles = await getUnreadArticles();
console.log("🤖 done");

const chapters: Chapter[] = [];

for (const article of articles) {
if (!article.isArchived) {
console.log(`🌐 fetching ${article.title}`);
console.log(`🌐 Fetching ${article.title}`);
let content = (await getArticle(article.slug)).content;

if (article.labelsArray) {
if (
config.ignoredLinks.some((link) => article.url.includes(link)) ||
article.labelsArray.find((label) => config.ignoredLabels.includes(label))
) {
console.log("⚠️ article skipped");
console.log("⚠️ Article skipped");
continue;
}
if (config.addLabelsInContent) {
Expand All @@ -182,6 +189,8 @@ async function makeMagazine() {
}
}

console.log(`📚 Creating ebook (${config.outputFileName})`);

const fileBuffer = await epub.default(
{
title: config.title,
Expand All @@ -195,11 +204,11 @@ async function makeMagazine() {

await Deno.writeFile(config.outputFileName, fileBuffer);

console.log("📚 Successfully created ebook");
console.log("📔 Successfully created ebook");
}

await checkForUpdates();
await makeMagazine();
await makeEbook();

if (config.emailSupport) {
await sendEmail();
Expand Down

0 comments on commit ac28d38

Please sign in to comment.